From 86090fcac5e27b630656fe3d963a6b80e26dac44 Mon Sep 17 00:00:00 2001 From: Planet-Lab Support Date: Wed, 2 Jun 2004 19:38:26 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'fedora'. --- .config | 2348 +++++++++++ .config.old | 2415 +++++++++++ Documentation/COPYING.modules | 708 ++++ Documentation/arm/SA1100/PCMCIA | 374 -- Documentation/arm/XScale/ADIFCC/80200EVB | 110 - Documentation/arm/XScale/IOP3XX/IQ80310 | 247 -- Documentation/arm/XScale/IOP3XX/IQ80321 | 215 - Documentation/arm/XScale/IOP3XX/aau.txt | 178 - Documentation/arm/XScale/IOP3XX/dma.txt | 214 - Documentation/arm/XScale/IOP3XX/message.txt | 110 - Documentation/arm/XScale/IOP3XX/pmon.txt | 71 - Documentation/arm/XScale/cache-lock.txt | 123 - Documentation/arm/XScale/pmu.txt | 168 - Documentation/arm/XScale/tlb-lock.txt | 64 - Documentation/fb/pxafb.txt | 54 + Documentation/numastat.txt | 22 + Documentation/sched-domains.txt | 55 + Documentation/scsi/sym53c500_cs.txt | 23 + arch/arm/mach-ixp4xx/Kconfig | 89 + arch/arm/mach-ixp4xx/coyote-setup.c | 90 + arch/arm/mach-ixp4xx/ixdp425-setup.c | 147 + arch/arm/mach-omap/innovator1510.c | 99 - arch/arm/mach-omap/innovator1610.c | 91 - arch/arm/mach-omap/irq.h | 172 - arch/arm/mach-omap/omap-generic.c | 77 - arch/arm/mach-omap/omap-perseus2.c | 116 - arch/arm/mach-pxa/leds-mainstone.c | 118 + arch/arm/mach-pxa/mainstone.c | 139 + arch/arm/mach-pxa/pxa25x.c | 94 + arch/arm/mach-pxa/pxa27x.c | 120 + arch/h8300/Kconfig.cpu | 183 + arch/h8300/kernel/module.c | 122 + .../mach-es7000/{es7000.c => es7000plat.c} | 53 +- arch/i386/mach-es7000/setup.c | 106 - arch/i386/mach-es7000/topology.c | 64 - arch/ia64/kernel/perfmon_hpsim.h | 75 - arch/ia64/scripts/check-serialize.S | 2 + arch/ppc/configs/bubinga_defconfig | 593 +++ arch/ppc/mm/cachemap.c | 174 - arch/ppc/ocp/Makefile | 6 - arch/ppc/ocp/ocp-driver.c | 195 - arch/ppc/ocp/ocp-probe.c | 113 - arch/ppc/ocp/ocp.c | 109 - arch/ppc/syslib/ibm_ocp.c | 9 + arch/x86_64/kernel/Makefile-HEAD | 38 + drivers/char/crash.c | 129 + drivers/char/dz.c | 1540 ------- drivers/char/dz.h | 230 - drivers/char/sh-sci.c | 1646 -------- drivers/char/sh-sci.h | 478 --- drivers/i2c/busses/i2c-ixp42x.c | 176 - drivers/ide/arm/ide_arm.c | 43 + drivers/ide/pci/cmd640.h | 32 - drivers/ide/ppc/swarm.c | 101 - drivers/net/auto_irq.c | 68 - drivers/net/ibm_emac/Makefile | 12 + drivers/net/ibm_emac/ibm_emac_core.c | 1968 +++++++++ drivers/net/ibm_emac/ibm_emac_phy.h | 137 + drivers/net/rcif.h | 292 -- drivers/net/rclanmtl.c | 2029 --------- drivers/net/rclanmtl.h | 701 ---- drivers/net/rcpci45.c | 1049 ----- drivers/net/wan/comx-hw-comx.c | 1450 ------- drivers/net/wan/comx-hw-locomx.c | 496 --- drivers/net/wan/comx-hw-mixcom.c | 960 ----- drivers/net/wan/comx-hw-munich.c | 2854 ------------- drivers/net/wan/comx-proto-fr.c | 1014 ----- drivers/net/wan/comx-proto-lapb.c | 551 --- drivers/net/wan/comx-proto-ppp.c | 269 -- drivers/net/wan/comx.c | 1128 ----- drivers/net/wan/comx.h | 232 -- drivers/net/wan/comxhw.h | 113 - drivers/net/wan/falc-lh.h | 102 - drivers/net/wan/hscx.h | 103 - drivers/net/wan/mixcom.h | 35 - drivers/net/wan/munich32x.h | 191 - drivers/pcmcia/pxa2xx_base.c | 333 ++ drivers/pcmcia/pxa2xx_lubbock.c | 236 ++ drivers/pcmcia/pxa2xx_mainstone.c | 176 + drivers/pcmcia/sa11xx_base.c | 242 ++ drivers/pcmcia/{sa1100.h => sa11xx_base.h} | 69 +- drivers/pcmcia/sa11xx_core.h | 121 - .../pcmcia/{sa11xx_core.c => soc_common.c} | 464 +-- drivers/pcmcia/soc_common.h | 186 + drivers/scsi/pcmcia/qlogic_core.c | 2 - drivers/scsi/qlogicfas.h | 124 - drivers/scsi/qlogicfas408.c | 637 +++ drivers/scsi/sata_sx4.c | 1446 +++++++ drivers/usb/core/driverfs.c | 229 - drivers/video/pxafb.c | 1381 ++++++ fs/ext3/resize.c | 956 +++++ fs/intermezzo/Makefile | 11 - fs/intermezzo/cache.c | 207 - fs/intermezzo/dcache.c | 342 -- fs/intermezzo/dir.c | 1333 ------ fs/intermezzo/ext_attr.c | 197 - fs/intermezzo/file.c | 534 --- fs/intermezzo/fileset.c | 674 --- fs/intermezzo/inode.c | 179 - fs/intermezzo/intermezzo_fs.h | 923 ----- fs/intermezzo/intermezzo_idl.h | 304 -- fs/intermezzo/intermezzo_journal.h | 24 - fs/intermezzo/intermezzo_kml.h | 260 -- fs/intermezzo/intermezzo_lib.h | 162 - fs/intermezzo/intermezzo_psdev.h | 55 - fs/intermezzo/intermezzo_upcall.h | 146 - fs/intermezzo/journal.c | 2452 ----------- fs/intermezzo/journal_ext2.c | 90 - fs/intermezzo/journal_ext3.c | 283 -- fs/intermezzo/journal_obdfs.c | 193 - fs/intermezzo/journal_reiserfs.c | 140 - fs/intermezzo/journal_tmpfs.c | 107 - fs/intermezzo/journal_xfs.c | 161 - fs/intermezzo/kml.c | 194 - fs/intermezzo/kml_decode.c | 1016 ----- fs/intermezzo/kml_reint.c | 647 --- fs/intermezzo/kml_setup.c | 58 - fs/intermezzo/kml_unpack.c | 712 ---- fs/intermezzo/kml_utils.c | 43 - fs/intermezzo/methods.c | 493 --- fs/intermezzo/presto.c | 736 ---- fs/intermezzo/psdev.c | 647 --- fs/intermezzo/replicator.c | 290 -- fs/intermezzo/super.c | 407 -- fs/intermezzo/sysctl.c | 368 -- fs/intermezzo/upcall.c | 559 --- fs/intermezzo/vfs.c | 2416 ----------- fs/reiserfs/xattr_security.c | 69 + fs/reiserfs/xattr_trusted.c | 81 + fs/reiserfs/xattr_user.c | 99 + fs/xfs/{linux => linux-2.6}/mutex.h | 0 fs/xfs/{linux => linux-2.6}/spin.h | 34 +- fs/xfs/{linux => linux-2.6}/time.h | 2 +- fs/xfs/{linux => linux-2.6}/xfs_cred.h | 0 fs/xfs/{linux => linux-2.6}/xfs_fs_subr.h | 0 fs/xfs/{linux => linux-2.6}/xfs_globals.h | 0 fs/xfs/{linux => linux-2.6}/xfs_iops.c | 44 +- fs/xfs/{linux => linux-2.6}/xfs_stats.h | 0 fs/xfs/{linux => linux-2.6}/xfs_version.h | 0 fs/xfs/linux/kmem.h | 197 - fs/xfs/linux/mrlock.h | 106 - fs/xfs/linux/sema.h | 67 - fs/xfs/linux/sv.h | 89 - fs/xfs/linux/xfs_aops.c | 1276 ------ fs/xfs/linux/xfs_buf.c | 1811 -------- fs/xfs/linux/xfs_buf.h | 594 --- fs/xfs/linux/xfs_file.c | 546 --- fs/xfs/linux/xfs_fs_subr.c | 124 - fs/xfs/linux/xfs_globals.c | 72 - fs/xfs/linux/xfs_ioctl.c | 1236 ------ fs/xfs/linux/xfs_iops.h | 51 - fs/xfs/linux/xfs_linux.h | 367 -- fs/xfs/linux/xfs_lrw.c | 1028 ----- fs/xfs/linux/xfs_lrw.h | 116 - fs/xfs/linux/xfs_stats.c | 132 - fs/xfs/linux/xfs_super.c | 850 ---- fs/xfs/linux/xfs_super.h | 129 - fs/xfs/linux/xfs_sysctl.c | 163 - fs/xfs/linux/xfs_sysctl.h | 107 - fs/xfs/linux/xfs_vfs.c | 327 -- fs/xfs/linux/xfs_vfs.h | 206 - fs/xfs/linux/xfs_vnode.c | 442 -- fs/xfs/linux/xfs_vnode.h | 651 --- include/asm-alpha/8253pit.h | 10 + include/asm-alpha/rmap.h | 7 - include/asm-arm/arch-cl7500/ide.h | 50 - include/asm-arm/arch-cl7500/keyboard.h | 16 - include/asm-arm/arch-clps711x/keyboard.h | 26 - include/asm-arm/arch-ebsa110/ide.h | 1 - include/asm-arm/arch-ebsa285/ide.h | 49 - include/asm-arm/arch-iop3xx/ide.h | 49 - include/asm-arm/arch-ixp4xx/coyote.h | 36 + include/asm-arm/arch-ixp4xx/hardware.h | 41 + include/asm-arm/arch-ixp4xx/irqs.h | 78 + include/asm-arm/arch-ixp4xx/ixdp425.h | 38 + include/asm-arm/arch-ixp4xx/ixp4xx-regs.h | 551 +++ include/asm-arm/arch-ixp4xx/prpmc1100.h | 33 + include/asm-arm/arch-ixp4xx/timex.h | 13 + include/asm-arm/arch-ixp4xx/vmalloc.h | 17 + include/asm-arm/arch-l7200/ide.h | 27 - include/asm-arm/arch-l7200/keyboard.h | 51 - include/asm-arm/arch-nexuspci/ide.h | 37 - include/asm-arm/arch-pxa/ide.h | 54 - include/asm-arm/arch-pxa/keyboard.h | 28 - include/asm-arm/arch-pxa/mainstone.h | 120 + include/asm-arm/arch-rpc/ide.h | 48 - include/asm-arm/arch-s3c2410/ide.h | 49 - include/asm-arm/arch-sa1100/keyboard.h | 23 - include/asm-arm/arch-shark/ide.h | 47 - include/asm-arm/arch-shark/keyboard.h | 68 - include/asm-arm/arch-tbox/ide.h | 3 - include/asm-arm/rmap.h | 6 - include/asm-arm26/rmap.h | 66 - include/asm-cris/rmap.h | 7 - include/asm-generic/rmap.h | 91 - include/asm-h8300/aki3068net/machine-depend.h | 29 - include/asm-h8300/edosk2674/machine-depend.h | 70 - include/asm-h8300/generic/machine-depend.h | 17 - include/asm-h8300/generic/timer_rate.h | 15 - include/asm-h8300/h8300_smsc.h | 20 - include/asm-h8300/h8max/machine-depend.h | 100 - include/asm-i386/8253pit.h | 12 + include/asm-i386/crash.h | 75 + include/asm-i386/rmap.h | 21 - include/asm-ia64/cpu.h | 17 + include/asm-ia64/crash.h | 90 + include/asm-ia64/rmap.h | 7 - include/asm-m68k/rmap.h | 7 - include/asm-m68knommu/rmap.h | 2 - include/asm-mips/8253pit.h | 10 + include/asm-mips/pmon.h | 22 + include/asm-mips/rmap.h | 7 - include/asm-parisc/rmap.h | 7 - include/asm-parisc/unwind.h | 72 + include/asm-ppc/ibm_ocp.h | 163 + include/asm-ppc/rmap.h | 9 - include/asm-ppc64/rmap.h | 9 - include/asm-s390/rmap.h | 7 - include/asm-sh/rmap.h | 7 - include/asm-sparc/rmap.h | 7 - include/asm-sparc64/const.h | 19 + include/asm-sparc64/rmap.h | 7 - include/asm-um/rmap.h | 6 - include/asm-v850/rmap.h | 1 - include/asm-x86_64/8253pit.h | 10 + include/asm-x86_64/rmap.h | 7 - include/linux/autoconf.h | 2349 +++++++++++ include/linux/prio_tree.h | 64 + include/net/tux.h | 800 ++++ include/net/tux_u.h | 163 + include/video/gbe.h | 317 ++ mm/mempolicy.c | 1015 +++++ mm/prio_tree.c | 663 +++ net/bluetooth/syms.c | 84 - net/bridge/br_sysfs_if.c | 269 ++ net/tux/Kconfig | 25 + net/tux/Makefile | 12 + net/tux/abuf.c | 186 + net/tux/accept.c | 859 ++++ net/tux/cachemiss.c | 264 ++ net/tux/cgi.c | 173 + net/tux/directory.c | 297 ++ net/tux/extcgi.c | 329 ++ net/tux/gzip.c | 40 + net/tux/input.c | 641 +++ net/tux/logger.c | 855 ++++ net/tux/main.c | 1413 +++++++ net/tux/mod.c | 262 ++ net/tux/output.c | 352 ++ net/tux/parser.h | 102 + net/tux/postpone.c | 77 + net/tux/proc.c | 1190 ++++++ net/tux/proto_ftp.c | 1549 +++++++ net/tux/proto_http.c | 2199 ++++++++++ net/tux/redirect.c | 154 + net/tux/times.c | 392 ++ net/tux/times.h | 26 + net/tux/userspace.c | 27 + scripts/basic/.docproc.cmd | 69 + scripts/basic/.fixdep.cmd | 74 + scripts/basic/.split-include.cmd | 57 + scripts/basic/docproc | Bin 0 -> 19832 bytes scripts/basic/fixdep | Bin 0 -> 15691 bytes scripts/basic/split-include | Bin 0 -> 14592 bytes scripts/kconfig/.conf.cmd | 1 + scripts/kconfig/.conf.o.cmd | 53 + scripts/kconfig/.mconf.o.cmd | 91 + scripts/kconfig/.zconf.tab.o.cmd | 73 + scripts/kconfig/conf | Bin 0 -> 20591 bytes scripts/kconfig/conf.o | Bin 0 -> 10348 bytes scripts/kconfig/lex.zconf.c | 3688 +++++++++++++++++ scripts/kconfig/mconf.o | Bin 0 -> 20532 bytes scripts/kconfig/zconf.tab.c | 2127 ++++++++++ scripts/kconfig/zconf.tab.o | Bin 0 -> 95696 bytes scripts/reference_discarded.pl | 109 + sound/pci/ice1712/prodigy.c | 663 --- sound/pci/ice1712/prodigy.h | 67 - 277 files changed, 40563 insertions(+), 52052 deletions(-) create mode 100644 .config create mode 100644 .config.old create mode 100644 Documentation/COPYING.modules delete mode 100644 Documentation/arm/SA1100/PCMCIA delete mode 100644 Documentation/arm/XScale/ADIFCC/80200EVB delete mode 100644 Documentation/arm/XScale/IOP3XX/IQ80310 delete mode 100644 Documentation/arm/XScale/IOP3XX/IQ80321 delete mode 100644 Documentation/arm/XScale/IOP3XX/aau.txt delete mode 100644 Documentation/arm/XScale/IOP3XX/dma.txt delete mode 100644 Documentation/arm/XScale/IOP3XX/message.txt delete mode 100644 Documentation/arm/XScale/IOP3XX/pmon.txt delete mode 100644 Documentation/arm/XScale/cache-lock.txt delete mode 100644 Documentation/arm/XScale/pmu.txt delete mode 100644 Documentation/arm/XScale/tlb-lock.txt create mode 100644 Documentation/fb/pxafb.txt create mode 100644 Documentation/numastat.txt create mode 100644 Documentation/sched-domains.txt create mode 100644 Documentation/scsi/sym53c500_cs.txt create mode 100644 arch/arm/mach-ixp4xx/Kconfig create mode 100644 arch/arm/mach-ixp4xx/coyote-setup.c create mode 100644 arch/arm/mach-ixp4xx/ixdp425-setup.c delete mode 100644 arch/arm/mach-omap/innovator1510.c delete mode 100644 arch/arm/mach-omap/innovator1610.c delete mode 100644 arch/arm/mach-omap/irq.h delete mode 100644 arch/arm/mach-omap/omap-generic.c delete mode 100644 arch/arm/mach-omap/omap-perseus2.c create mode 100644 arch/arm/mach-pxa/leds-mainstone.c create mode 100644 arch/arm/mach-pxa/mainstone.c create mode 100644 arch/arm/mach-pxa/pxa25x.c create mode 100644 arch/arm/mach-pxa/pxa27x.c create mode 100644 arch/h8300/Kconfig.cpu create mode 100644 arch/h8300/kernel/module.c rename arch/i386/mach-es7000/{es7000.c => es7000plat.c} (89%) delete mode 100644 arch/i386/mach-es7000/setup.c delete mode 100644 arch/i386/mach-es7000/topology.c delete mode 100644 arch/ia64/kernel/perfmon_hpsim.h create mode 100644 arch/ia64/scripts/check-serialize.S create mode 100644 arch/ppc/configs/bubinga_defconfig delete mode 100644 arch/ppc/mm/cachemap.c delete mode 100644 arch/ppc/ocp/Makefile delete mode 100644 arch/ppc/ocp/ocp-driver.c delete mode 100644 arch/ppc/ocp/ocp-probe.c delete mode 100644 arch/ppc/ocp/ocp.c create mode 100644 arch/ppc/syslib/ibm_ocp.c create mode 100644 arch/x86_64/kernel/Makefile-HEAD create mode 100644 drivers/char/crash.c delete mode 100644 drivers/char/dz.c delete mode 100644 drivers/char/dz.h delete mode 100644 drivers/char/sh-sci.c delete mode 100644 drivers/char/sh-sci.h delete mode 100644 drivers/i2c/busses/i2c-ixp42x.c create mode 100644 drivers/ide/arm/ide_arm.c delete mode 100644 drivers/ide/pci/cmd640.h delete mode 100644 drivers/ide/ppc/swarm.c delete mode 100644 drivers/net/auto_irq.c create mode 100644 drivers/net/ibm_emac/Makefile create mode 100644 drivers/net/ibm_emac/ibm_emac_core.c create mode 100644 drivers/net/ibm_emac/ibm_emac_phy.h delete mode 100644 drivers/net/rcif.h delete mode 100644 drivers/net/rclanmtl.c delete mode 100644 drivers/net/rclanmtl.h delete mode 100644 drivers/net/rcpci45.c delete mode 100644 drivers/net/wan/comx-hw-comx.c delete mode 100644 drivers/net/wan/comx-hw-locomx.c delete mode 100644 drivers/net/wan/comx-hw-mixcom.c delete mode 100644 drivers/net/wan/comx-hw-munich.c delete mode 100644 drivers/net/wan/comx-proto-fr.c delete mode 100644 drivers/net/wan/comx-proto-lapb.c delete mode 100644 drivers/net/wan/comx-proto-ppp.c delete mode 100644 drivers/net/wan/comx.c delete mode 100644 drivers/net/wan/comx.h delete mode 100644 drivers/net/wan/comxhw.h delete mode 100644 drivers/net/wan/falc-lh.h delete mode 100644 drivers/net/wan/hscx.h delete mode 100644 drivers/net/wan/mixcom.h delete mode 100644 drivers/net/wan/munich32x.h create mode 100644 drivers/pcmcia/pxa2xx_base.c create mode 100644 drivers/pcmcia/pxa2xx_lubbock.c create mode 100644 drivers/pcmcia/pxa2xx_mainstone.c create mode 100644 drivers/pcmcia/sa11xx_base.c rename drivers/pcmcia/{sa1100.h => sa11xx_base.h} (72%) delete mode 100644 drivers/pcmcia/sa11xx_core.h rename drivers/pcmcia/{sa11xx_core.c => soc_common.c} (56%) create mode 100644 drivers/pcmcia/soc_common.h delete mode 100644 drivers/scsi/pcmcia/qlogic_core.c delete mode 100644 drivers/scsi/qlogicfas.h create mode 100644 drivers/scsi/qlogicfas408.c create mode 100644 drivers/scsi/sata_sx4.c delete mode 100644 drivers/usb/core/driverfs.c create mode 100644 drivers/video/pxafb.c create mode 100644 fs/ext3/resize.c delete mode 100644 fs/intermezzo/Makefile delete mode 100644 fs/intermezzo/cache.c delete mode 100644 fs/intermezzo/dcache.c delete mode 100644 fs/intermezzo/dir.c delete mode 100644 fs/intermezzo/ext_attr.c delete mode 100644 fs/intermezzo/file.c delete mode 100644 fs/intermezzo/fileset.c delete mode 100644 fs/intermezzo/inode.c delete mode 100644 fs/intermezzo/intermezzo_fs.h delete mode 100644 fs/intermezzo/intermezzo_idl.h delete mode 100644 fs/intermezzo/intermezzo_journal.h delete mode 100644 fs/intermezzo/intermezzo_kml.h delete mode 100644 fs/intermezzo/intermezzo_lib.h delete mode 100644 fs/intermezzo/intermezzo_psdev.h delete mode 100644 fs/intermezzo/intermezzo_upcall.h delete mode 100644 fs/intermezzo/journal.c delete mode 100644 fs/intermezzo/journal_ext2.c delete mode 100644 fs/intermezzo/journal_ext3.c delete mode 100644 fs/intermezzo/journal_obdfs.c delete mode 100644 fs/intermezzo/journal_reiserfs.c delete mode 100644 fs/intermezzo/journal_tmpfs.c delete mode 100644 fs/intermezzo/journal_xfs.c delete mode 100644 fs/intermezzo/kml.c delete mode 100644 fs/intermezzo/kml_decode.c delete mode 100644 fs/intermezzo/kml_reint.c delete mode 100644 fs/intermezzo/kml_setup.c delete mode 100644 fs/intermezzo/kml_unpack.c delete mode 100644 fs/intermezzo/kml_utils.c delete mode 100644 fs/intermezzo/methods.c delete mode 100644 fs/intermezzo/presto.c delete mode 100644 fs/intermezzo/psdev.c delete mode 100644 fs/intermezzo/replicator.c delete mode 100644 fs/intermezzo/super.c delete mode 100644 fs/intermezzo/sysctl.c delete mode 100644 fs/intermezzo/upcall.c delete mode 100644 fs/intermezzo/vfs.c create mode 100644 fs/reiserfs/xattr_security.c create mode 100644 fs/reiserfs/xattr_trusted.c create mode 100644 fs/reiserfs/xattr_user.c rename fs/xfs/{linux => linux-2.6}/mutex.h (100%) rename fs/xfs/{linux => linux-2.6}/spin.h (77%) rename fs/xfs/{linux => linux-2.6}/time.h (97%) rename fs/xfs/{linux => linux-2.6}/xfs_cred.h (100%) rename fs/xfs/{linux => linux-2.6}/xfs_fs_subr.h (100%) rename fs/xfs/{linux => linux-2.6}/xfs_globals.h (100%) rename fs/xfs/{linux => linux-2.6}/xfs_iops.c (96%) rename fs/xfs/{linux => linux-2.6}/xfs_stats.h (100%) rename fs/xfs/{linux => linux-2.6}/xfs_version.h (100%) delete mode 100644 fs/xfs/linux/kmem.h delete mode 100644 fs/xfs/linux/mrlock.h delete mode 100644 fs/xfs/linux/sema.h delete mode 100644 fs/xfs/linux/sv.h delete mode 100644 fs/xfs/linux/xfs_aops.c delete mode 100644 fs/xfs/linux/xfs_buf.c delete mode 100644 fs/xfs/linux/xfs_buf.h delete mode 100644 fs/xfs/linux/xfs_file.c delete mode 100644 fs/xfs/linux/xfs_fs_subr.c delete mode 100644 fs/xfs/linux/xfs_globals.c delete mode 100644 fs/xfs/linux/xfs_ioctl.c delete mode 100644 fs/xfs/linux/xfs_iops.h delete mode 100644 fs/xfs/linux/xfs_linux.h delete mode 100644 fs/xfs/linux/xfs_lrw.c delete mode 100644 fs/xfs/linux/xfs_lrw.h delete mode 100644 fs/xfs/linux/xfs_stats.c delete mode 100644 fs/xfs/linux/xfs_super.c delete mode 100644 fs/xfs/linux/xfs_super.h delete mode 100644 fs/xfs/linux/xfs_sysctl.c delete mode 100644 fs/xfs/linux/xfs_sysctl.h delete mode 100644 fs/xfs/linux/xfs_vfs.c delete mode 100644 fs/xfs/linux/xfs_vfs.h delete mode 100644 fs/xfs/linux/xfs_vnode.c delete mode 100644 fs/xfs/linux/xfs_vnode.h create mode 100644 include/asm-alpha/8253pit.h delete mode 100644 include/asm-alpha/rmap.h delete mode 100644 include/asm-arm/arch-cl7500/ide.h delete mode 100644 include/asm-arm/arch-cl7500/keyboard.h delete mode 100644 include/asm-arm/arch-clps711x/keyboard.h delete mode 100644 include/asm-arm/arch-ebsa110/ide.h delete mode 100644 include/asm-arm/arch-ebsa285/ide.h delete mode 100644 include/asm-arm/arch-iop3xx/ide.h create mode 100644 include/asm-arm/arch-ixp4xx/coyote.h create mode 100644 include/asm-arm/arch-ixp4xx/hardware.h create mode 100644 include/asm-arm/arch-ixp4xx/irqs.h create mode 100644 include/asm-arm/arch-ixp4xx/ixdp425.h create mode 100644 include/asm-arm/arch-ixp4xx/ixp4xx-regs.h create mode 100644 include/asm-arm/arch-ixp4xx/prpmc1100.h create mode 100644 include/asm-arm/arch-ixp4xx/timex.h create mode 100644 include/asm-arm/arch-ixp4xx/vmalloc.h delete mode 100644 include/asm-arm/arch-l7200/ide.h delete mode 100644 include/asm-arm/arch-l7200/keyboard.h delete mode 100644 include/asm-arm/arch-nexuspci/ide.h delete mode 100644 include/asm-arm/arch-pxa/ide.h delete mode 100644 include/asm-arm/arch-pxa/keyboard.h create mode 100644 include/asm-arm/arch-pxa/mainstone.h delete mode 100644 include/asm-arm/arch-rpc/ide.h delete mode 100644 include/asm-arm/arch-s3c2410/ide.h delete mode 100644 include/asm-arm/arch-sa1100/keyboard.h delete mode 100644 include/asm-arm/arch-shark/ide.h delete mode 100644 include/asm-arm/arch-shark/keyboard.h delete mode 100644 include/asm-arm/arch-tbox/ide.h delete mode 100644 include/asm-arm/rmap.h delete mode 100644 include/asm-arm26/rmap.h delete mode 100644 include/asm-cris/rmap.h delete mode 100644 include/asm-generic/rmap.h delete mode 100644 include/asm-h8300/aki3068net/machine-depend.h delete mode 100644 include/asm-h8300/edosk2674/machine-depend.h delete mode 100644 include/asm-h8300/generic/machine-depend.h delete mode 100644 include/asm-h8300/generic/timer_rate.h delete mode 100644 include/asm-h8300/h8300_smsc.h delete mode 100644 include/asm-h8300/h8max/machine-depend.h create mode 100644 include/asm-i386/8253pit.h create mode 100644 include/asm-i386/crash.h delete mode 100644 include/asm-i386/rmap.h create mode 100644 include/asm-ia64/cpu.h create mode 100644 include/asm-ia64/crash.h delete mode 100644 include/asm-ia64/rmap.h delete mode 100644 include/asm-m68k/rmap.h delete mode 100644 include/asm-m68knommu/rmap.h create mode 100644 include/asm-mips/8253pit.h create mode 100644 include/asm-mips/pmon.h delete mode 100644 include/asm-mips/rmap.h delete mode 100644 include/asm-parisc/rmap.h create mode 100644 include/asm-parisc/unwind.h create mode 100644 include/asm-ppc/ibm_ocp.h delete mode 100644 include/asm-ppc/rmap.h delete mode 100644 include/asm-ppc64/rmap.h delete mode 100644 include/asm-s390/rmap.h delete mode 100644 include/asm-sh/rmap.h delete mode 100644 include/asm-sparc/rmap.h create mode 100644 include/asm-sparc64/const.h delete mode 100644 include/asm-sparc64/rmap.h delete mode 100644 include/asm-um/rmap.h delete mode 100644 include/asm-v850/rmap.h create mode 100644 include/asm-x86_64/8253pit.h delete mode 100644 include/asm-x86_64/rmap.h create mode 100644 include/linux/autoconf.h create mode 100644 include/linux/prio_tree.h create mode 100644 include/net/tux.h create mode 100644 include/net/tux_u.h create mode 100644 include/video/gbe.h create mode 100644 mm/mempolicy.c create mode 100644 mm/prio_tree.c delete mode 100644 net/bluetooth/syms.c create mode 100644 net/bridge/br_sysfs_if.c create mode 100644 net/tux/Kconfig create mode 100644 net/tux/Makefile create mode 100644 net/tux/abuf.c create mode 100644 net/tux/accept.c create mode 100644 net/tux/cachemiss.c create mode 100644 net/tux/cgi.c create mode 100644 net/tux/directory.c create mode 100644 net/tux/extcgi.c create mode 100644 net/tux/gzip.c create mode 100644 net/tux/input.c create mode 100644 net/tux/logger.c create mode 100644 net/tux/main.c create mode 100644 net/tux/mod.c create mode 100644 net/tux/output.c create mode 100644 net/tux/parser.h create mode 100644 net/tux/postpone.c create mode 100644 net/tux/proc.c create mode 100644 net/tux/proto_ftp.c create mode 100644 net/tux/proto_http.c create mode 100644 net/tux/redirect.c create mode 100644 net/tux/times.c create mode 100644 net/tux/times.h create mode 100644 net/tux/userspace.c create mode 100644 scripts/basic/.docproc.cmd create mode 100644 scripts/basic/.fixdep.cmd create mode 100644 scripts/basic/.split-include.cmd create mode 100755 scripts/basic/docproc create mode 100755 scripts/basic/fixdep create mode 100755 scripts/basic/split-include create mode 100644 scripts/kconfig/.conf.cmd create mode 100644 scripts/kconfig/.conf.o.cmd create mode 100644 scripts/kconfig/.mconf.o.cmd create mode 100644 scripts/kconfig/.zconf.tab.o.cmd create mode 100755 scripts/kconfig/conf create mode 100644 scripts/kconfig/conf.o create mode 100644 scripts/kconfig/lex.zconf.c create mode 100644 scripts/kconfig/mconf.o create mode 100644 scripts/kconfig/zconf.tab.c create mode 100644 scripts/kconfig/zconf.tab.o create mode 100644 scripts/reference_discarded.pl delete mode 100644 sound/pci/ice1712/prodigy.c delete mode 100644 sound/pci/ice1712/prodigy.h diff --git a/.config b/.config new file mode 100644 index 000000000..de7e3e791 --- /dev/null +++ b/.config @@ -0,0 +1,2348 @@ +# +# 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_STANDALONE=y + +# +# General setup +# +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +CONFIG_POSIX_MQUEUE=y +CONFIG_BSD_PROCESS_ACCT=y +CONFIG_SYSCTL=y +# CONFIG_AUDIT is not set +CONFIG_LOG_BUF_SHIFT=17 +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=y +# CONFIG_MODULE_FORCE_UNLOAD is not set +CONFIG_OBSOLETE_MODPARM=y +# CONFIG_MODVERSIONS is not set +CONFIG_KMOD=y +CONFIG_STOP_MACHINE=y + +# +# Processor type and features +# +# CONFIG_X86_PC is not set +# 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=y +# CONFIG_X86_ES7000 is not set +CONFIG_X86_CYCLONE_TIMER=y +# 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_HPET_EMULATE_RTC=y +CONFIG_SMP=y +CONFIG_NR_CPUS=32 +CONFIG_SCHED_SMT=y +# CONFIG_PREEMPT is not set +CONFIG_X86_LOCAL_APIC=y +CONFIG_X86_IO_APIC=y +CONFIG_X86_TSC=y +CONFIG_X86_MCE=y +# CONFIG_X86_MCE_NONFATAL is not set +CONFIG_X86_MCE_P4THERMAL=y +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 is not set +CONFIG_HIGHMEM64G=y +CONFIG_HIGHMEM=y +CONFIG_X86_PAE=y +# CONFIG_NUMA is not set +CONFIG_HIGHPTE=y +# CONFIG_MATH_EMULATION is not set +CONFIG_MTRR=y +# CONFIG_EFI is not set +# CONFIG_IRQBALANCE is not set +CONFIG_HAVE_DEC_LOCK=y +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=y +# 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=y +CONFIG_X86_POWERNOW_K8=m +# CONFIG_X86_GX_SUSPMOD is not set +CONFIG_X86_SPEEDSTEP_CENTRINO=y +CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE=y +CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI=y +CONFIG_X86_SPEEDSTEP_ICH=y +CONFIG_X86_SPEEDSTEP_SMI=m +CONFIG_X86_P4_CLOCKMOD=m +CONFIG_X86_SPEEDSTEP_LIB=y +# CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK is not set +CONFIG_X86_LONGRUN=y +# CONFIG_X86_LONGHAUL 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_USE_VECTOR=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 + +# +# PCMCIA/CardBus support +# +CONFIG_PCMCIA=m +# CONFIG_PCMCIA_DEBUG is not set +CONFIG_YENTA=m +CONFIG_CARDBUS=y +CONFIG_I82092=m +CONFIG_I82365=m +CONFIG_TCIC=m +CONFIG_PCMCIA_PROBE=y + +# +# PCI Hotplug Support +# +CONFIG_HOTPLUG_PCI=y +# CONFIG_HOTPLUG_PCI_FAKE is not set +CONFIG_HOTPLUG_PCI_COMPAQ=m +# CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM is not set +CONFIG_HOTPLUG_PCI_IBM=m +# CONFIG_HOTPLUG_PCI_ACPI is not set +# CONFIG_HOTPLUG_PCI_CPCI is not set +CONFIG_HOTPLUG_PCI_PCIE=m +CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE=y +CONFIG_HOTPLUG_PCI_SHPC=m +CONFIG_HOTPLUG_PCI_SHPC_POLL_EVENT_MODE=y + +# +# Executable file formats +# +CONFIG_BINFMT_ELF=y +# CONFIG_BINFMT_AOUT is not set +CONFIG_BINFMT_MISC=m + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_FW_LOADER=y +# CONFIG_DEBUG_DRIVER is not set + +# +# Memory Technology Devices (MTD) +# +CONFIG_MTD=m +# CONFIG_MTD_DEBUG is not set +CONFIG_MTD_PARTITIONS=m +CONFIG_MTD_CONCAT=m +CONFIG_MTD_REDBOOT_PARTS=m +CONFIG_MTD_CMDLINE_PARTS=m + +# +# 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_CFI_INTELEXT=m +CONFIG_MTD_CFI_AMDSTD=m +CONFIG_MTD_CFI_STAA=m +CONFIG_MTD_RAM=m +CONFIG_MTD_ROM=m +CONFIG_MTD_ABSENT=m +# 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_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=m +CONFIG_MTD_ICH2ROM=m +CONFIG_MTD_SCB2_FLASH=m +# CONFIG_MTD_NETtel is not set +# CONFIG_MTD_DILNETPC is not set +CONFIG_MTD_L440GX=m +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_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_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 + +# +# Parallel port support +# +CONFIG_PARPORT=m +CONFIG_PARPORT_PC=m +CONFIG_PARPORT_PC_CML1=m +CONFIG_PARPORT_SERIAL=m +# CONFIG_PARPORT_PC_FIFO is not set +# CONFIG_PARPORT_PC_SUPERIO is not set +CONFIG_PARPORT_PC_PCMCIA=m +# CONFIG_PARPORT_OTHER is not set +CONFIG_PARPORT_1284=y + +# +# 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_PARIDE 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=m +CONFIG_BLK_DEV_NBD=m +CONFIG_BLK_DEV_CARMEL=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_HD_IDE is not set +CONFIG_BLK_DEV_IDEDISK=y +CONFIG_IDEDISK_MULTI_MODE=y +# CONFIG_IDEDISK_STROKE is not set +CONFIG_BLK_DEV_IDECS=m +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_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_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_ADVANSYS=m +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_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_CPQFCTS is not set +# CONFIG_SCSI_DMX3191D is not set +# CONFIG_SCSI_DTC3280 is not set +# CONFIG_SCSI_EATA is not set +# CONFIG_SCSI_EATA_PIO is not set +CONFIG_SCSI_FUTURE_DOMAIN=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_PPA=m +CONFIG_SCSI_IMM=m +# CONFIG_SCSI_IZIP_EPP16 is not set +# CONFIG_SCSI_IZIP_SLOW_CTR is not set +# 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 + +# +# PCMCIA SCSI adapter support +# +CONFIG_PCMCIA_AHA152X=m +CONFIG_PCMCIA_FDOMAIN=m +CONFIG_PCMCIA_NINJA_SCSI=m +CONFIG_PCMCIA_QLOGIC=m +CONFIG_PCMCIA_SYM53C500=m + +# +# 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=m + +# +# Fusion MPT device support +# +CONFIG_FUSION=m +CONFIG_FUSION_MAX_SGE=40 +# CONFIG_FUSION_ISENSE is not set +CONFIG_FUSION_CTL=m +CONFIG_FUSION_LAN=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=m +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=y +CONFIG_UNIX=y +CONFIG_NET_KEY=m +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 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=m +CONFIG_INET_ESP=m +CONFIG_INET_IPCOMP=m + +# +# IP: Virtual Server Configuration +# +CONFIG_IP_VS=m +# CONFIG_IP_VS_DEBUG is not set +CONFIG_IP_VS_TAB_BITS=12 + +# +# IPVS transport protocol load balancing support +# +CONFIG_IP_VS_PROTO_TCP=y +CONFIG_IP_VS_PROTO_UDP=y +CONFIG_IP_VS_PROTO_ESP=y +CONFIG_IP_VS_PROTO_AH=y + +# +# 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=m +CONFIG_IP_VS_NQ=m + +# +# IPVS application helper +# +CONFIG_IP_VS_FTP=m +CONFIG_IPV6=m +CONFIG_IPV6_PRIVACY=y +CONFIG_INET6_AH=m +CONFIG_INET6_ESP=m +CONFIG_INET6_IPCOMP=m +CONFIG_IPV6_TUNNEL=m +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=m +CONFIG_IP_NF_AMANDA=m +CONFIG_IP_NF_QUEUE=m +CONFIG_IP_NF_IPTABLES=m +CONFIG_IP_NF_MATCH_LIMIT=m +CONFIG_IP_NF_MATCH_IPRANGE=m +CONFIG_IP_NF_MATCH_MAC=m +CONFIG_IP_NF_MATCH_PKTTYPE=m +CONFIG_IP_NF_MATCH_MARK=m +CONFIG_IP_NF_MATCH_MULTIPORT=m +CONFIG_IP_NF_MATCH_TOS=m +CONFIG_IP_NF_MATCH_RECENT=m +CONFIG_IP_NF_MATCH_ECN=m +CONFIG_IP_NF_MATCH_DSCP=m +CONFIG_IP_NF_MATCH_AH_ESP=m +CONFIG_IP_NF_MATCH_LENGTH=m +CONFIG_IP_NF_MATCH_TTL=m +CONFIG_IP_NF_MATCH_TCPMSS=m +CONFIG_IP_NF_MATCH_HELPER=m +CONFIG_IP_NF_MATCH_STATE=m +CONFIG_IP_NF_MATCH_CONNTRACK=m +CONFIG_IP_NF_MATCH_OWNER=m +CONFIG_IP_NF_MATCH_PHYSDEV=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 + +# +# IPv6: Netfilter Configuration +# +# CONFIG_IP6_NF_QUEUE is not set +CONFIG_IP6_NF_IPTABLES=m +CONFIG_IP6_NF_MATCH_LIMIT=m +CONFIG_IP6_NF_MATCH_MAC=m +CONFIG_IP6_NF_MATCH_RT=m +CONFIG_IP6_NF_MATCH_OPTS=m +CONFIG_IP6_NF_MATCH_FRAG=m +CONFIG_IP6_NF_MATCH_HL=m +CONFIG_IP6_NF_MATCH_MULTIPORT=m +CONFIG_IP6_NF_MATCH_OWNER=m +CONFIG_IP6_NF_MATCH_MARK=m +CONFIG_IP6_NF_MATCH_IPV6HEADER=m +CONFIG_IP6_NF_MATCH_AHESP=m +CONFIG_IP6_NF_MATCH_LENGTH=m +CONFIG_IP6_NF_MATCH_EUI64=m +CONFIG_IP6_NF_FILTER=m +CONFIG_IP6_NF_TARGET_LOG=m +CONFIG_IP6_NF_MANGLE=m +CONFIG_IP6_NF_TARGET_MARK=m +CONFIG_IP6_NF_RAW=m + +# +# Bridge: Netfilter Configuration +# +CONFIG_BRIDGE_NF_EBTABLES=m +CONFIG_BRIDGE_EBT_BROUTE=m +CONFIG_BRIDGE_EBT_T_FILTER=m +CONFIG_BRIDGE_EBT_T_NAT=m +CONFIG_BRIDGE_EBT_802_3=m +CONFIG_BRIDGE_EBT_AMONG=m +CONFIG_BRIDGE_EBT_ARP=m +CONFIG_BRIDGE_EBT_IP=m +CONFIG_BRIDGE_EBT_LIMIT=m +CONFIG_BRIDGE_EBT_MARK=m +CONFIG_BRIDGE_EBT_PKTTYPE=m +CONFIG_BRIDGE_EBT_STP=m +CONFIG_BRIDGE_EBT_VLAN=m +CONFIG_BRIDGE_EBT_ARPREPLY=m +CONFIG_BRIDGE_EBT_DNAT=m +CONFIG_BRIDGE_EBT_MARK_T=m +CONFIG_BRIDGE_EBT_REDIRECT=m +CONFIG_BRIDGE_EBT_SNAT=m +CONFIG_BRIDGE_EBT_LOG=m +CONFIG_XFRM=y +CONFIG_XFRM_USER=y + +# +# SCTP Configuration (EXPERIMENTAL) +# +CONFIG_IP_SCTP=m +# CONFIG_SCTP_DBG_MSG is not set +# CONFIG_SCTP_DBG_OBJCNT is not set +# CONFIG_SCTP_HMAC_NONE is not set +# CONFIG_SCTP_HMAC_SHA1 is not set +CONFIG_SCTP_HMAC_MD5=y +# CONFIG_ATM is not set +CONFIG_BRIDGE=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_LTPC=m +CONFIG_COPS=m +CONFIG_COPS_DAYNA=y +CONFIG_COPS_TANGENT=y +CONFIG_IPDDP=m +CONFIG_IPDDP_ENCAP=y +CONFIG_IPDDP_DECAP=y +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +CONFIG_NET_DIVERT=y +# CONFIG_ECONET is not set +CONFIG_WAN_ROUTER=m +# CONFIG_NET_FASTROUTE is not set +# 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=m +CONFIG_NET_SCH_CSZ=m +CONFIG_NET_SCH_PRIO=m +CONFIG_NET_SCH_RED=m +CONFIG_NET_SCH_SFQ=m +CONFIG_NET_SCH_TEQL=m +CONFIG_NET_SCH_TBF=m +CONFIG_NET_SCH_GRED=m +CONFIG_NET_SCH_DSMARK=m +CONFIG_NET_SCH_DELAY=m +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 is not set +CONFIG_NETPOLL=y +# CONFIG_NETPOLL_RX is not set +# CONFIG_NETPOLL_TRAP is not set +CONFIG_NET_POLL_CONTROLLER=y +# CONFIG_HAMRADIO is not set +CONFIG_IRDA=m + +# +# IrDA protocols +# +CONFIG_IRLAN=m +CONFIG_IRNET=m +CONFIG_IRCOMM=m +# CONFIG_IRDA_ULTRA is not set + +# +# IrDA options +# +CONFIG_IRDA_CACHE_LAST_LSAP=y +CONFIG_IRDA_FAST_RR=y +# CONFIG_IRDA_DEBUG is not set + +# +# Infrared-port device drivers +# + +# +# SIR device drivers +# +CONFIG_IRTTY_SIR=m + +# +# Dongle support +# +CONFIG_DONGLE=y +CONFIG_ESI_DONGLE=m +CONFIG_ACTISYS_DONGLE=m +CONFIG_TEKRAM_DONGLE=m +CONFIG_LITELINK_DONGLE=m +CONFIG_MA600_DONGLE=m +CONFIG_GIRBIL_DONGLE=m +CONFIG_MCP2120_DONGLE=m +CONFIG_OLD_BELKIN_DONGLE=m +CONFIG_ACT200L_DONGLE=m + +# +# Old SIR device drivers +# + +# +# Old Serial dongle support +# + +# +# FIR device drivers +# +CONFIG_USB_IRDA=m +CONFIG_SIGMATEL_FIR=m +CONFIG_NSC_FIR=m +# CONFIG_WINBOND_FIR is not set +# CONFIG_TOSHIBA_FIR is not set +# CONFIG_SMC_IRCC_FIR is not set +# CONFIG_ALI_FIR is not set +# CONFIG_VLSI_FIR is not set +# CONFIG_VIA_FIR is not set +CONFIG_BT=m +CONFIG_BT_L2CAP=m +CONFIG_BT_SCO=m +CONFIG_BT_RFCOMM=m +CONFIG_BT_RFCOMM_TTY=y +CONFIG_BT_BNEP=m +CONFIG_BT_BNEP_MC_FILTER=y +CONFIG_BT_BNEP_PROTO_FILTER=y +CONFIG_BT_CMTP=m + +# +# Bluetooth device drivers +# +CONFIG_BT_HCIUSB=m +CONFIG_BT_HCIUSB_SCO=y +CONFIG_BT_HCIUART=m +CONFIG_BT_HCIUART_H4=y +CONFIG_BT_HCIUART_BCSP=y +CONFIG_BT_HCIUART_BCSP_TXCRC=y +CONFIG_BT_HCIBCM203X=m +CONFIG_BT_HCIBFUSB=m +CONFIG_BT_HCIDTL1=m +CONFIG_BT_HCIBT3C=m +CONFIG_BT_HCIBLUECARD=m +CONFIG_BT_HCIBTUART=m +CONFIG_BT_HCIVHCI=m +CONFIG_TUX=m + +# +# TUX options +# +CONFIG_TUX_EXTCGI=y +# CONFIG_TUX_EXTENDED_LOG is not set +# CONFIG_TUX_DEBUG is not set +CONFIG_NETDEVICES=y +CONFIG_DUMMY=m +CONFIG_BONDING=m +CONFIG_EQUALIZER=m +CONFIG_TUN=m +CONFIG_ETHERTAP=m +CONFIG_NET_SB1000=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_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_PCMCIA_XIRCOM=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_NET_POCKET=y +CONFIG_ATP=m +CONFIG_DE600=m +CONFIG_DE620=m + +# +# Gigabit Ethernet (1000/10000 Mbit) +# +CONFIG_NET_GIGE=y +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 +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=y + +# +# Obsolete Wireless cards support (pre-802.11) +# +# CONFIG_STRIP is not set +# CONFIG_ARLAN is not set +CONFIG_WAVELAN=m +CONFIG_PCMCIA_WAVELAN=m +CONFIG_PCMCIA_NETWAVE=m + +# +# Wireless 802.11 Frequency Hopping cards support +# +# CONFIG_PCMCIA_RAYCS is not set + +# +# Wireless 802.11b ISA/PCI cards support +# +CONFIG_AIRO=m +CONFIG_HERMES=m +CONFIG_PLX_HERMES=m +CONFIG_TMD_HERMES=m +CONFIG_PCI_HERMES=m +CONFIG_ATMEL=m +CONFIG_PCI_ATMEL=m + +# +# Wireless 802.11b Pcmcia/Cardbus cards support +# +CONFIG_PCMCIA_HERMES=m +CONFIG_AIRO_CS=m +CONFIG_PCMCIA_ATMEL=m +CONFIG_PCMCIA_WL3501=m + +# +# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support +# +CONFIG_PRISM54=m +CONFIG_NET_WIRELESS=y + +# +# PCMCIA network device support +# +CONFIG_NET_PCMCIA=y +CONFIG_PCMCIA_3C589=m +CONFIG_PCMCIA_3C574=m +CONFIG_PCMCIA_FMVJ18X=m +CONFIG_PCMCIA_PCNET=m +CONFIG_PCMCIA_NMCLAN=m +CONFIG_PCMCIA_SMC91C92=m +CONFIG_PCMCIA_XIRC2PS=m +CONFIG_PCMCIA_AXNET=m + +# +# Wan interfaces +# +# CONFIG_WAN is not set +CONFIG_FDDI=y +# CONFIG_DEFXX is not set +CONFIG_SKFP=m +# CONFIG_HIPPI is not set +CONFIG_PLIP=m +CONFIG_PPP=m +CONFIG_PPP_MULTILINK=y +CONFIG_PPP_FILTER=y +CONFIG_PPP_ASYNC=m +CONFIG_PPP_SYNC_TTY=m +CONFIG_PPP_DEFLATE=m +# CONFIG_PPP_BSDCOMP is not set +CONFIG_PPPOE=m +# CONFIG_SLIP is not set +CONFIG_NET_FC=y +# CONFIG_SHAPER is not set +CONFIG_NETCONSOLE=m + +# +# ISDN subsystem +# +CONFIG_ISDN=m + +# +# Old ISDN4Linux +# +CONFIG_ISDN_I4L=m +CONFIG_ISDN_PPP=y +CONFIG_ISDN_PPP_VJ=y +CONFIG_ISDN_MPP=y +CONFIG_IPPP_FILTER=y +# CONFIG_ISDN_PPP_BSDCOMP is not set +CONFIG_ISDN_AUDIO=y +CONFIG_ISDN_TTY_FAX=y + +# +# ISDN feature submodules +# + +# +# ISDN4Linux hardware drivers +# + +# +# Passive cards +# +CONFIG_ISDN_DRV_HISAX=m + +# +# D-channel protocol features +# +CONFIG_HISAX_EURO=y +CONFIG_DE_AOC=y +CONFIG_HISAX_NO_SENDCOMPLETE=y +CONFIG_HISAX_NO_LLC=y +CONFIG_HISAX_NO_KEYPAD=y +CONFIG_HISAX_1TR6=y +CONFIG_HISAX_NI1=y +CONFIG_HISAX_MAX_CARDS=8 + +# +# HiSax supported cards +# +CONFIG_HISAX_16_0=y +CONFIG_HISAX_16_3=y +CONFIG_HISAX_TELESPCI=y +CONFIG_HISAX_S0BOX=y +CONFIG_HISAX_AVM_A1=y +CONFIG_HISAX_FRITZPCI=y +CONFIG_HISAX_AVM_A1_PCMCIA=y +CONFIG_HISAX_ELSA=y +CONFIG_HISAX_IX1MICROR2=y +CONFIG_HISAX_DIEHLDIVA=y +CONFIG_HISAX_ASUSCOM=y +CONFIG_HISAX_TELEINT=y +CONFIG_HISAX_HFCS=y +CONFIG_HISAX_SEDLBAUER=y +CONFIG_HISAX_SPORTSTER=y +CONFIG_HISAX_MIC=y +CONFIG_HISAX_NETJET=y +CONFIG_HISAX_NETJET_U=y +CONFIG_HISAX_NICCY=y +CONFIG_HISAX_ISURF=y +CONFIG_HISAX_HSTSAPHIR=y +CONFIG_HISAX_BKM_A4T=y +CONFIG_HISAX_SCT_QUADRO=y +CONFIG_HISAX_GAZEL=y +CONFIG_HISAX_HFC_PCI=y +CONFIG_HISAX_W6692=y +CONFIG_HISAX_HFC_SX=y +CONFIG_HISAX_ENTERNOW_PCI=y +# CONFIG_HISAX_DEBUG is not set + +# +# HiSax PCMCIA card service modules +# +CONFIG_HISAX_SEDLBAUER_CS=m +CONFIG_HISAX_ELSA_CS=m +CONFIG_HISAX_AVM_A1_CS=m +CONFIG_HISAX_TELES_CS=m + +# +# HiSax sub driver modules +# +CONFIG_HISAX_ST5481=m +CONFIG_HISAX_HFCUSB=m +CONFIG_HISAX_FRITZ_PCIPNP=m +CONFIG_HISAX_HDLC=y + +# +# Active cards +# +CONFIG_ISDN_DRV_ICN=m +CONFIG_ISDN_DRV_PCBIT=m +CONFIG_ISDN_DRV_SC=m +CONFIG_ISDN_DRV_ACT2000=m +CONFIG_ISDN_DRV_TPAM=m + +# +# CAPI subsystem +# +CONFIG_ISDN_CAPI=m +CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y +CONFIG_ISDN_CAPI_MIDDLEWARE=y +CONFIG_ISDN_CAPI_CAPI20=m +CONFIG_ISDN_CAPI_CAPIFS_BOOL=y +CONFIG_ISDN_CAPI_CAPIFS=m +CONFIG_ISDN_CAPI_CAPIDRV=m + +# +# CAPI hardware drivers +# + +# +# Active AVM cards +# +CONFIG_CAPI_AVM=y + +# +# Active Eicon DIVA Server cards +# +CONFIG_CAPI_EICON=y +CONFIG_ISDN_DIVAS=m +CONFIG_ISDN_DIVAS_BRIPCI=y +CONFIG_ISDN_DIVAS_PRIPCI=y +CONFIG_ISDN_DIVAS_DIVACAPI=m +CONFIG_ISDN_DIVAS_USERIDI=m +CONFIG_ISDN_DIVAS_MAINT=m + +# +# 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=m +# CONFIG_INPUT_TSDEV is not set +CONFIG_INPUT_EVDEV=y +# CONFIG_INPUT_EVBUG is not set + +# +# Input I/O drivers +# +CONFIG_GAMEPORT=m +CONFIG_SOUND_GAMEPORT=m +CONFIG_GAMEPORT_NS558=m +CONFIG_GAMEPORT_L4=m +CONFIG_GAMEPORT_EMU10K1=m +CONFIG_GAMEPORT_VORTEX=m +CONFIG_GAMEPORT_FM801=m +CONFIG_GAMEPORT_CS461x=m +CONFIG_SERIO=y +CONFIG_SERIO_I8042=y +CONFIG_SERIO_SERPORT=y +# CONFIG_SERIO_CT82C710 is not set +# CONFIG_SERIO_PARKBD 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=m +CONFIG_MOUSE_INPORT=m +CONFIG_MOUSE_ATIXL=y +CONFIG_MOUSE_LOGIBM=m +CONFIG_MOUSE_PC110PAD=m +CONFIG_MOUSE_VSXXXAA=m +CONFIG_INPUT_JOYSTICK=y +CONFIG_JOYSTICK_ANALOG=m +CONFIG_JOYSTICK_A3D=m +CONFIG_JOYSTICK_ADI=m +CONFIG_JOYSTICK_COBRA=m +CONFIG_JOYSTICK_GF2K=m +CONFIG_JOYSTICK_GRIP=m +CONFIG_JOYSTICK_GRIP_MP=m +CONFIG_JOYSTICK_GUILLEMOT=m +CONFIG_JOYSTICK_INTERACT=m +CONFIG_JOYSTICK_SIDEWINDER=m +CONFIG_JOYSTICK_TMDC=m +CONFIG_JOYSTICK_IFORCE=m +CONFIG_JOYSTICK_IFORCE_USB=y +CONFIG_JOYSTICK_IFORCE_232=y +CONFIG_JOYSTICK_WARRIOR=m +CONFIG_JOYSTICK_MAGELLAN=m +CONFIG_JOYSTICK_SPACEORB=m +CONFIG_JOYSTICK_SPACEBALL=m +CONFIG_JOYSTICK_STINGER=m +CONFIG_JOYSTICK_TWIDDLER=m +CONFIG_JOYSTICK_DB9=m +CONFIG_JOYSTICK_GAMECON=m +CONFIG_JOYSTICK_TURBOGRAFX=m +# CONFIG_INPUT_JOYDUMP is not set +CONFIG_INPUT_TOUCHSCREEN=y +CONFIG_TOUCHSCREEN_GUNZE=m +CONFIG_INPUT_MISC=y +CONFIG_INPUT_PCSPKR=m +# CONFIG_INPUT_UINPUT is not set + +# +# Character devices +# +CONFIG_VT=y +CONFIG_VT_CONSOLE=y +CONFIG_HW_CONSOLE=y +CONFIG_SERIAL_NONSTANDARD=y +CONFIG_ROCKETPORT=m +# CONFIG_CYCLADES is not set +CONFIG_SYNCLINK=m +CONFIG_SYNCLINKMP=m +CONFIG_N_HDLC=m +CONFIG_STALDRV=y + +# +# Serial drivers +# +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_CS=m +# 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 is not set +CONFIG_CRASH=m +CONFIG_PRINTER=m +CONFIG_LP_CONSOLE=y +CONFIG_PPDEV=m +CONFIG_TIPAR=m +# 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=y +# CONFIG_WATCHDOG_NOWAYOUT is not set + +# +# Watchdog Device Drivers +# +CONFIG_SOFT_WATCHDOG=m +CONFIG_ACQUIRE_WDT=m +CONFIG_ADVANTECH_WDT=m +CONFIG_ALIM1535_WDT=m +CONFIG_ALIM7101_WDT=m +CONFIG_SC520_WDT=m +CONFIG_EUROTECH_WDT=m +CONFIG_IB700_WDT=m +CONFIG_WAFER_WDT=m +CONFIG_I8XX_TCO=m +CONFIG_SC1200_WDT=m +# CONFIG_SCx200_WDT is not set +# CONFIG_60XX_WDT is not set +CONFIG_CPU5_WDT=m +CONFIG_W83627HF_WDT=m +CONFIG_W83877F_WDT=m +CONFIG_MACHZ_WDT=m + +# +# ISA-based Watchdog Cards +# +CONFIG_PCWATCHDOG=m +# CONFIG_MIXCOMWD is not set +CONFIG_WDT=m +# CONFIG_WDT_501 is not set + +# +# PCI-based Watchdog Cards +# +CONFIG_PCIPCWATCHDOG=m +CONFIG_WDTPCI=m +CONFIG_WDT_501_PCI=y + +# +# USB-based Watchdog Cards +# +CONFIG_USBPCWATCHDOG=m +CONFIG_HW_RANDOM=m +CONFIG_NVRAM=m +CONFIG_RTC=y +CONFIG_DTLK=m +CONFIG_R3964=m +# CONFIG_APPLICOM is not set +CONFIG_SONYPI=m + +# +# Ftape, the floppy tape device driver +# +CONFIG_AGP=y +CONFIG_AGP_ALI=y +CONFIG_AGP_ATI=y +CONFIG_AGP_AMD=y +CONFIG_AGP_AMD64=y +CONFIG_AGP_INTEL=y +CONFIG_AGP_INTEL_MCH=y +CONFIG_AGP_NVIDIA=y +CONFIG_AGP_SIS=y +CONFIG_AGP_SWORKS=y +CONFIG_AGP_VIA=y +CONFIG_AGP_EFFICEON=y +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 + +# +# PCMCIA character devices +# +CONFIG_SYNCLINK_CS=m +CONFIG_MWAVE=m +# CONFIG_RAW_DRIVER 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_I801=m +CONFIG_I2C_I810=m +CONFIG_I2C_ISA=m +CONFIG_I2C_NFORCE2=m +# CONFIG_I2C_PARPORT is not set +# 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_ASB100=m +CONFIG_SENSORS_DS1621=m +CONFIG_SENSORS_FSCHER=m +CONFIG_SENSORS_GL518SM=m +CONFIG_SENSORS_IT87=m +CONFIG_SENSORS_LM75=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 + +# +# Misc devices +# +CONFIG_IBM_ASM=m + +# +# Multimedia devices +# +CONFIG_VIDEO_DEV=m + +# +# Video For Linux +# + +# +# Video Adapters +# +CONFIG_VIDEO_BT848=m +CONFIG_VIDEO_PMS=m +CONFIG_VIDEO_BWQCAM=m +CONFIG_VIDEO_CQCAM=m +CONFIG_VIDEO_W9966=m +CONFIG_VIDEO_CPIA=m +CONFIG_VIDEO_CPIA_PP=m +CONFIG_VIDEO_CPIA_USB=m +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 + +# +# 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_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_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_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 is not set +# CONFIG_LOGO_LINUX_VGA16 is not set +CONFIG_LOGO_LINUX_CLUT224=y + +# +# Sound +# +CONFIG_SOUND=m + +# +# Advanced Linux Sound Architecture +# +CONFIG_SND=m +CONFIG_SND_TIMER=m +CONFIG_SND_PCM=m +CONFIG_SND_HWDEP=m +CONFIG_SND_RAWMIDI=m +CONFIG_SND_SEQUENCER=m +CONFIG_SND_SEQ_DUMMY=m +CONFIG_SND_OSSEMUL=y +CONFIG_SND_MIXER_OSS=m +CONFIG_SND_PCM_OSS=m +CONFIG_SND_SEQUENCER_OSS=y +CONFIG_SND_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=m + +# +# PCMCIA devices +# +# CONFIG_SND_VXPOCKET is not set +# CONFIG_SND_VXP440 is not set +CONFIG_SND_PDAUDIOCF=m + +# +# Open Sound System +# +# CONFIG_SOUND_PRIME is not set + +# +# USB support +# +CONFIG_USB=y +# CONFIG_USB_DEBUG is not set + +# +# Miscellaneous USB options +# +CONFIG_USB_DEVICEFS=y +# CONFIG_USB_BANDWIDTH is not set +# CONFIG_USB_DYNAMIC_MINORS is not set + +# +# 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=m + +# +# USB Bluetooth TTY can only be used with disabled Bluetooth subsystem +# +CONFIG_USB_MIDI=m +CONFIG_USB_ACM=m +CONFIG_USB_PRINTER=m +CONFIG_USB_STORAGE=m +# CONFIG_USB_STORAGE_DEBUG is not set +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=y +CONFIG_USB_HIDINPUT=y +CONFIG_HID_FF=y +CONFIG_HID_PID=y +CONFIG_LOGITECH_FF=y +CONFIG_THRUSTMASTER_FF=y +CONFIG_USB_HIDDEV=y +CONFIG_USB_AIPTEK=m +CONFIG_USB_WACOM=m +CONFIG_USB_KBTAB=m +CONFIG_USB_POWERMATE=m +CONFIG_USB_MTOUCH=m +CONFIG_USB_EGALAX=m +CONFIG_USB_XPAD=m +CONFIG_USB_ATI_REMOTE=m + +# +# USB Imaging devices +# +CONFIG_USB_MDC800=m +CONFIG_USB_MICROTEK=m +CONFIG_USB_HPUSBSCSI=m + +# +# USB Multimedia devices +# +CONFIG_USB_DABUSB=m +CONFIG_USB_VICAM=m +CONFIG_USB_DSBR=m +CONFIG_USB_IBMCAM=m +CONFIG_USB_KONICAWC=m +CONFIG_USB_OV511=m +CONFIG_USB_SE401=m +CONFIG_USB_STV680=m +CONFIG_USB_W9968CF=m + +# +# 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 +# +CONFIG_USB_USS720=m + +# +# USB Serial Converter support +# +CONFIG_USB_SERIAL=m +CONFIG_USB_SERIAL_GENERIC=y +CONFIG_USB_SERIAL_BELKIN=m +CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m +CONFIG_USB_SERIAL_EMPEG=m +CONFIG_USB_SERIAL_FTDI_SIO=m +CONFIG_USB_SERIAL_VISOR=m +CONFIG_USB_SERIAL_IPAQ=m +CONFIG_USB_SERIAL_IR=m +CONFIG_USB_SERIAL_EDGEPORT=m +CONFIG_USB_SERIAL_EDGEPORT_TI=m +CONFIG_USB_SERIAL_KEYSPAN_PDA=m +CONFIG_USB_SERIAL_KEYSPAN=m +CONFIG_USB_SERIAL_KEYSPAN_MPR=y +CONFIG_USB_SERIAL_KEYSPAN_USA28=y +CONFIG_USB_SERIAL_KEYSPAN_USA28X=y +CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y +CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y +CONFIG_USB_SERIAL_KEYSPAN_USA19=y +CONFIG_USB_SERIAL_KEYSPAN_USA18X=y +CONFIG_USB_SERIAL_KEYSPAN_USA19W=y +CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y +CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y +CONFIG_USB_SERIAL_KEYSPAN_USA49W=y +CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y +CONFIG_USB_SERIAL_KLSI=m +CONFIG_USB_SERIAL_KOBIL_SCT=m +CONFIG_USB_SERIAL_MCT_U232=m +CONFIG_USB_SERIAL_PL2303=m +CONFIG_USB_SERIAL_SAFE=m +CONFIG_USB_SERIAL_SAFE_PADDED=y +CONFIG_USB_SERIAL_CYBERJACK=m +CONFIG_USB_SERIAL_XIRCOM=m +CONFIG_USB_SERIAL_OMNINET=m +CONFIG_USB_EZUSB=y + +# +# USB Miscellaneous drivers +# +CONFIG_USB_EMI62=m +# CONFIG_USB_EMI26 is not set +CONFIG_USB_TIGL=m +CONFIG_USB_AUERSWALD=m +CONFIG_USB_RIO500=m +CONFIG_USB_LEGOTOWER=m +CONFIG_USB_LCD=m +CONFIG_USB_LED=m +# CONFIG_USB_CYTHERM is not set +CONFIG_USB_PHIDGETSERVO=m +CONFIG_USB_TEST=m + +# +# 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=m +CONFIG_EXT3_FS_XATTR=y +CONFIG_EXT3_FS_POSIX_ACL=y +CONFIG_EXT3_FS_SECURITY=y +CONFIG_JBD=m +# CONFIG_JBD_DEBUG is not set +CONFIG_FS_MBCACHE=y +CONFIG_REISERFS_FS=m +# CONFIG_REISERFS_CHECK is not set +CONFIG_REISERFS_PROC_INFO=y +CONFIG_REISERFS_FS_XATTR=y +CONFIG_REISERFS_FS_POSIX_ACL=y +CONFIG_REISERFS_FS_SECURITY=y +CONFIG_JFS_FS=m +CONFIG_JFS_POSIX_ACL=y +# CONFIG_JFS_DEBUG is not set +# CONFIG_JFS_STATISTICS is not set +CONFIG_FS_POSIX_ACL=y +CONFIG_XFS_FS=m +# CONFIG_XFS_RT is not set +CONFIG_XFS_QUOTA=y +CONFIG_XFS_SECURITY=y +CONFIG_XFS_POSIX_ACL=y +CONFIG_MINIX_FS=m +CONFIG_ROMFS_FS=m +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 + +# +# DOS/FAT/NT Filesystems +# +CONFIG_FAT_FS=m +CONFIG_MSDOS_FS=m +CONFIG_VFAT_FS=m +# 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 + +# +# Miscellaneous filesystems +# +# CONFIG_ADFS_FS is not set +CONFIG_AFFS_FS=m +CONFIG_HFS_FS=m +CONFIG_HFSPLUS_FS=m +CONFIG_BEFS_FS=m +# CONFIG_BEFS_DEBUG is not set +CONFIG_BFS_FS=m +CONFIG_EFS_FS=m +# CONFIG_JFFS_FS is not set +CONFIG_JFFS2_FS=m +CONFIG_JFFS2_FS_DEBUG=0 +CONFIG_JFFS2_FS_NAND=y +CONFIG_CRAMFS=m +CONFIG_VXFS_FS=m +# CONFIG_HPFS_FS is not set +CONFIG_QNX4FS_FS=m +# CONFIG_QNX4FS_RW is not set +CONFIG_SYSV_FS=m +CONFIG_UFS_FS=m +# CONFIG_UFS_FS_WRITE is not set + +# +# Network File Systems +# +CONFIG_NFS_FS=m +CONFIG_NFS_V3=y +CONFIG_NFS_V4=y +CONFIG_NFS_DIRECTIO=y +CONFIG_NFSD=m +CONFIG_NFSD_V3=y +CONFIG_NFSD_V4=y +CONFIG_NFSD_TCP=y +CONFIG_LOCKD=m +CONFIG_LOCKD_V4=y +CONFIG_EXPORTFS=m +CONFIG_SUNRPC=m +CONFIG_SUNRPC_GSS=m +CONFIG_RPCSEC_GSS_KRB5=m +CONFIG_SMB_FS=m +# CONFIG_SMB_NLS_DEFAULT is not set +CONFIG_CIFS=m +# CONFIG_CIFS_STATS is not set +CONFIG_NCP_FS=m +CONFIG_NCPFS_PACKET_SIGNING=y +CONFIG_NCPFS_IOCTL_LOCKING=y +CONFIG_NCPFS_STRONG=y +CONFIG_NCPFS_NFS_NS=y +CONFIG_NCPFS_OS2_NS=y +CONFIG_NCPFS_SMALLDOS=y +CONFIG_NCPFS_NLS=y +CONFIG_NCPFS_EXTRAS=y +# 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=y +# CONFIG_AMIGA_PARTITION is not set +# CONFIG_ATARI_PARTITION is not set +CONFIG_MAC_PARTITION=y +CONFIG_MSDOS_PARTITION=y +CONFIG_BSD_DISKLABEL=y +CONFIG_MINIX_SUBPARTITION=y +CONFIG_SOLARIS_X86_PARTITION=y +CONFIG_UNIXWARE_DISKLABEL=y +# CONFIG_LDM_PARTITION is not set +# CONFIG_NEC98_PARTITION is not set +CONFIG_SGI_PARTITION=y +# CONFIG_ULTRIX_PARTITION is not set +CONFIG_SUN_PARTITION=y +CONFIG_EFI_PARTITION=y + +# +# Native Language Support +# +CONFIG_NLS=y +CONFIG_NLS_DEFAULT="utf8" +CONFIG_NLS_CODEPAGE_437=m +CONFIG_NLS_CODEPAGE_737=m +CONFIG_NLS_CODEPAGE_775=m +CONFIG_NLS_CODEPAGE_850=m +CONFIG_NLS_CODEPAGE_852=m +CONFIG_NLS_CODEPAGE_855=m +CONFIG_NLS_CODEPAGE_857=m +CONFIG_NLS_CODEPAGE_860=m +CONFIG_NLS_CODEPAGE_861=m +CONFIG_NLS_CODEPAGE_862=m +CONFIG_NLS_CODEPAGE_863=m +CONFIG_NLS_CODEPAGE_864=m +CONFIG_NLS_CODEPAGE_865=m +CONFIG_NLS_CODEPAGE_866=m +CONFIG_NLS_CODEPAGE_869=m +CONFIG_NLS_CODEPAGE_936=m +CONFIG_NLS_CODEPAGE_950=m +CONFIG_NLS_CODEPAGE_932=m +CONFIG_NLS_CODEPAGE_949=m +CONFIG_NLS_CODEPAGE_874=m +CONFIG_NLS_ISO8859_8=m +CONFIG_NLS_CODEPAGE_1250=m +CONFIG_NLS_CODEPAGE_1251=m +CONFIG_NLS_ISO8859_1=m +CONFIG_NLS_ISO8859_2=m +CONFIG_NLS_ISO8859_3=m +CONFIG_NLS_ISO8859_4=m +CONFIG_NLS_ISO8859_5=m +CONFIG_NLS_ISO8859_6=m +CONFIG_NLS_ISO8859_7=m +CONFIG_NLS_ISO8859_9=m +CONFIG_NLS_ISO8859_13=m +CONFIG_NLS_ISO8859_14=m +CONFIG_NLS_ISO8859_15=m +CONFIG_NLS_KOI8_R=m +CONFIG_NLS_KOI8_U=m +CONFIG_NLS_UTF8=m + +# +# Profiling support +# +CONFIG_PROFILING=y +CONFIG_OPROFILE=m + +# +# Kernel hacking +# +CONFIG_DEBUG_KERNEL=y +CONFIG_EARLY_PRINTK=y +CONFIG_DEBUG_STACKOVERFLOW=y +# CONFIG_DEBUG_STACK_USAGE is not set +# CONFIG_DEBUG_SLAB is not set +CONFIG_MAGIC_SYSRQ=y +# CONFIG_DEBUG_SPINLOCK is not set +# CONFIG_DEBUG_PAGEALLOC is not set +# CONFIG_DEBUG_HIGHMEM is not set +CONFIG_DEBUG_INFO=y +CONFIG_DEBUG_SPINLOCK_SLEEP=y +# CONFIG_FRAME_POINTER is not set +CONFIG_X86_FIND_SMP_CONFIG=y +CONFIG_X86_MPPARSE=y + +# +# Security options +# +CONFIG_SECURITY=y +CONFIG_SECURITY_NETWORK=y +CONFIG_SECURITY_CAPABILITIES=y +# CONFIG_SECURITY_ROOTPLUG is not set +CONFIG_SECURITY_SELINUX=y +CONFIG_SECURITY_SELINUX_BOOTPARAM=y +CONFIG_SECURITY_SELINUX_DISABLE=y +CONFIG_SECURITY_SELINUX_DEVELOP=y +# CONFIG_SECURITY_SELINUX_MLS is not set + +# +# Cryptographic options +# +CONFIG_CRYPTO=y +CONFIG_CRYPTO_HMAC=y +CONFIG_CRYPTO_NULL=m +CONFIG_CRYPTO_MD4=m +CONFIG_CRYPTO_MD5=y +CONFIG_CRYPTO_SHA1=m +CONFIG_CRYPTO_SHA256=m +CONFIG_CRYPTO_SHA512=m +CONFIG_CRYPTO_DES=m +CONFIG_CRYPTO_BLOWFISH=m +CONFIG_CRYPTO_TWOFISH=m +CONFIG_CRYPTO_SERPENT=m +CONFIG_CRYPTO_AES=m +CONFIG_CRYPTO_CAST5=m +CONFIG_CRYPTO_CAST6=m +CONFIG_CRYPTO_ARC4=m +CONFIG_CRYPTO_DEFLATE=m +CONFIG_CRYPTO_MICHAEL_MIC=m +CONFIG_CRYPTO_CRC32C=m +# CONFIG_CRYPTO_TEST is not set + +# +# Library routines +# +CONFIG_CRC32=y +CONFIG_LIBCRC32C=m +CONFIG_ZLIB_INFLATE=y +CONFIG_ZLIB_DEFLATE=m +CONFIG_X86_SMP=y +CONFIG_X86_HT=y +CONFIG_X86_BIOS_REBOOT=y +CONFIG_X86_TRAMPOLINE=y +CONFIG_X86_STD_RESOURCES=y +CONFIG_PC=y diff --git a/.config.old b/.config.old new file mode 100644 index 000000000..a1d48d7b8 --- /dev/null +++ b/.config.old @@ -0,0 +1,2415 @@ +# +# Automatically generated make config: don't edit +# +CONFIG_MMU=y +CONFIG_UID16=y +CONFIG_GENERIC_ISA_DMA=y +CONFIG_SMP=y +# CONFIG_HOTPLUG_CPU is not set +CONFIG_SCHED_SMT=y + +# +# Code maturity level options +# +CONFIG_EXPERIMENTAL=y +CONFIG_CLEAN_COMPILE=y +CONFIG_STANDALONE=y + +# +# General setup +# +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +CONFIG_BSD_PROCESS_ACCT=y +CONFIG_SYSCTL=y +CONFIG_LOG_BUF_SHIFT=17 +# 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_NUMA is not set +# CONFIG_PREEMPT is not set +# CONFIG_IRQBALANCE is not set +CONFIG_POSIX_MQUEUE=y +CONFIG_EDD=m +# CONFIG_SMBIOS is not set +CONFIG_IRQSTACKS=y + +# +# Loadable module support +# +CONFIG_MODULES=y +CONFIG_MODULE_UNLOAD=y +# CONFIG_MODULE_FORCE_UNLOAD is not set +CONFIG_OBSOLETE_MODPARM=y +# CONFIG_MODVERSIONS is not set +CONFIG_KMOD=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_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_ACPI_NUMA=y + +# +# 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=m +# CONFIG_CPU_FREQ_24_API is not set +CONFIG_CPU_FREQ_TABLE=y + + +# +# 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_PCI_USE_VECTOR=y +CONFIG_ISA=y +# CONFIG_EISA is not set +# CONFIG_MCA is not set +# CONFIG_SCx200 is not set +CONFIG_HOTPLUG=y + +# +# PCMCIA/CardBus support +# +CONFIG_PCMCIA=m +# CONFIG_PCMCIA_DEBUG is not set +CONFIG_YENTA=y +CONFIG_CARDBUS=y +CONFIG_I82092=m +CONFIG_I82365=m +CONFIG_TCIC=m +CONFIG_PCMCIA_PROBE=y + +# +# PCI Hotplug Support +# +CONFIG_HOTPLUG_PCI=y +# CONFIG_HOTPLUG_PCI_FAKE is not set +CONFIG_HOTPLUG_PCI_COMPAQ=m +# CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM is not set +CONFIG_HOTPLUG_PCI_IBM=m +# CONFIG_HOTPLUG_PCI_ACPI is not set +# CONFIG_HOTPLUG_PCI_CPCI is not set +CONFIG_HOTPLUG_PCI_PCIE=m +CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE=y +CONFIG_HOTPLUG_PCI_SHPC=m +CONFIG_HOTPLUG_PCI_SHPC_POLL_EVENT_MODE=y +# CONFIG_HOTPLUG_PCI_SHPC_PHPRM_LEGACY is not set + +# +# Executable file formats +# +CONFIG_BINFMT_ELF=y +# CONFIG_BINFMT_AOUT is not set +CONFIG_BINFMT_MISC=m + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_FW_LOADER=y + +# +# Memory Technology Devices (MTD) +# +CONFIG_MTD=m +# CONFIG_MTD_DEBUG is not set +CONFIG_MTD_PARTITIONS=m +CONFIG_MTD_CONCAT=m +CONFIG_MTD_REDBOOT_PARTS=m +CONFIG_MTD_CMDLINE_PARTS=m + +# +# 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_CFI_INTELEXT=m +CONFIG_MTD_CFI_AMDSTD=m +CONFIG_MTD_CFI_STAA=m +CONFIG_MTD_RAM=m +CONFIG_MTD_ROM=m +CONFIG_MTD_ABSENT=m +# 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_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=m +CONFIG_MTD_ICH2ROM=m +CONFIG_MTD_SCB2_FLASH=m +# CONFIG_MTD_NETtel is not set +# CONFIG_MTD_DILNETPC is not set +CONFIG_MTD_L440GX=m +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_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_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 + +# +# Parallel port support +# +CONFIG_PARPORT=m +CONFIG_PARPORT_PC=m +CONFIG_PARPORT_PC_CML1=m +CONFIG_PARPORT_SERIAL=m +# CONFIG_PARPORT_PC_FIFO is not set +# CONFIG_PARPORT_PC_SUPERIO is not set +CONFIG_PARPORT_PC_PCMCIA=m +# CONFIG_PARPORT_OTHER is not set +CONFIG_PARPORT_1284=y + +# +# 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_PARIDE 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=m +CONFIG_BLK_DEV_NBD=m +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_SIZE=16384 +CONFIG_BLK_DEV_INITRD=y +CONFIG_BLK_DEV_ATIIXP=y +CONFIG_LBD=y +# CONFIG_DCSSBLK is not set + + +# +# ATA/ATAPI/MFM/RLL support +# +CONFIG_IDE=y +CONFIG_IDE_GENERIC=y +# CONFIG_HPT34X_AUTODMA is not set + +CONFIG_BLK_DEV_IDE=y + +# +# Please see Documentation/ide.txt for help/info on IDE drives +# +# CONFIG_BLK_DEV_HD_IDE is not set +CONFIG_BLK_DEV_IDEDISK=y +CONFIG_IDEDISK_MULTI_MODE=y +# CONFIG_IDEDISK_STROKE is not set +CONFIG_BLK_DEV_IDECS=m +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_BLK_DEV_CMD640 is not set +# CONFIG_BLK_DEV_CMD640_ENHANCED 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_IDE_TCQ is not set +# 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_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_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_CHIPSETS is not set +CONFIG_BLK_DEV_IDEDMA=y +# CONFIG_IDEDMA_IVB is not set +CONFIG_IDEDMA_AUTO=y +# CONFIG_DMA_NONPCI is not set +# CONFIG_BLK_DEV_HD is not set + +# +# 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_REPORT_LUNS=y +CONFIG_SCSI_CONSTANTS=y +CONFIG_SCSI_LOGGING=y +CONFIG_SCSI_SPI_ATTRS=y +CONFIG_SCSI_FC_ATTRS=y + +# +# SCSI low-level drivers +# +CONFIG_BLK_DEV_3W_XXXX_RAID=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_PROBE_EISA_VL is not set +# 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_ADVANSYS=m +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_PROMISE=m +CONFIG_SCSI_SATA_VIA=m +CONFIG_BLK_DEV_CARMEL=m +CONFIG_SCSI_SATA_VITESSE=m +CONFIG_SCSI_SATA_SIL=m +CONFIG_SCSI_SATA_SIS=m +CONFIG_SCSI_SATA_SX4=m + +CONFIG_SCSI_BUSLOGIC=m +# CONFIG_SCSI_OMIT_FLASHPOINT is not set +# CONFIG_SCSI_CPQFCTS is not set +# CONFIG_SCSI_DMX3191D is not set +# CONFIG_SCSI_DTC3280 is not set +# CONFIG_SCSI_EATA is not set +# CONFIG_SCSI_EATA_PIO is not set +CONFIG_SCSI_FUTURE_DOMAIN=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_PPA=m +CONFIG_SCSI_IMM=m +# CONFIG_SCSI_IZIP_EPP16 is not set +# CONFIG_SCSI_IZIP_SLOW_CTR is not set +# 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_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_FC_FIRMWARE is not set +CONFIG_SCSI_QLOGIC_1280=m +# CONFIG_SCSI_SYM53C416 is not set +# CONFIG_SCSI_DC395x is not set +# 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 +CONFIG_SCSI_DC390T=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_IPR is not set +# CONFIG_SCSI_DPT_I2O is not set + +# +# PCMCIA SCSI adapter support +# +CONFIG_PCMCIA_AHA152X=m +CONFIG_PCMCIA_FDOMAIN=m +CONFIG_PCMCIA_NINJA_SCSI=m +CONFIG_PCMCIA_QLOGIC=m +CONFIG_PCMCIA_SYM53C500=m + + +# +# 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=m + +# +# Fusion MPT device support +# +CONFIG_FUSION=m +CONFIG_FUSION_MAX_SGE=40 +# CONFIG_FUSION_ISENSE is not set +CONFIG_FUSION_CTL=m +CONFIG_FUSION_LAN=m + +# +# IEEE 1394 (FireWire) support (EXPERIMENTAL) +# +CONFIG_IEEE1394=m + +# +# Subsystem Options +# +# CONFIG_IEEE1394_VERBOSEDEBUG is not set +CONFIG_IEEE1394_OUI_DB=y + +# +# Device Drivers +# +# CONFIG_IEEE1394_PCILYNX is not set +CONFIG_IEEE1394_OHCI1394=m + +# +# Protocol Drivers +# +CONFIG_IEEE1394_VIDEO1394=m +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 +# CONFIG_IEEE1394_EXTRA_CONFIG_ROMS is not set + +# +# I2O device support +# +CONFIG_I2O=m +CONFIG_I2O_PCI=m +CONFIG_I2O_BLOCK=m +CONFIG_I2O_SCSI=m +CONFIG_I2O_PROC=m +CONFIG_I2O_CONFIG=y + +# +# Networking support +# +CONFIG_NET=y + +# +# Networking options +# +CONFIG_PACKET=y +CONFIG_PACKET_MMAP=y +CONFIG_NETLINK_DEV=y +CONFIG_UNIX=y +CONFIG_NET_KEY=m +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 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=m +CONFIG_INET_ESP=m +CONFIG_INET_IPCOMP=m +CONFIG_NETCONSOLE=m +# CONFIG_NETPOLL_RX is not set +# CONFIG_NETPOLL_TRAP is not set + +# +# IP: Virtual Server Configuration +# +CONFIG_IP_VS=m +# CONFIG_IP_VS_DEBUG is not set +CONFIG_IP_VS_TAB_BITS=12 +CONFIG_IP_VS_PROTO_TCP=y +CONFIG_IP_VS_PROTO_UDP=y +CONFIG_IP_VS_PROTO_ESP=y +CONFIG_IP_VS_PROTO_AH=y +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=m +CONFIG_IP_VS_NQ=m +CONFIG_IP_VS_FTP=m + + +CONFIG_IPV6=m +CONFIG_IPV6_PRIVACY=y +CONFIG_INET6_AH=m +CONFIG_INET6_ESP=m +CONFIG_INET6_IPCOMP=m +CONFIG_IPV6_TUNNEL=m +# CONFIG_DECNET is not set +CONFIG_BRIDGE=m +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=m +CONFIG_IP_NF_AMANDA=m +CONFIG_IP_NF_QUEUE=m +CONFIG_IP_NF_RAW=m +CONFIG_IP_NF_IPTABLES=m +CONFIG_IP_NF_MATCH_LIMIT=m +CONFIG_IP_NF_MATCH_IPRANGE=m +CONFIG_IP_NF_MATCH_MAC=m +CONFIG_IP_NF_MATCH_PKTTYPE=m +CONFIG_IP_NF_MATCH_MARK=m +CONFIG_IP_NF_MATCH_MULTIPORT=m +CONFIG_IP_NF_MATCH_TOS=m +CONFIG_IP_NF_MATCH_RECENT=m +CONFIG_IP_NF_MATCH_ECN=m +CONFIG_IP_NF_MATCH_DSCP=m +CONFIG_IP_NF_MATCH_AH_ESP=m +CONFIG_IP_NF_MATCH_LENGTH=m +CONFIG_IP_NF_MATCH_TTL=m +CONFIG_IP_NF_MATCH_TCPMSS=m +CONFIG_IP_NF_MATCH_HELPER=m +CONFIG_IP_NF_MATCH_STATE=m +CONFIG_IP_NF_MATCH_CONNTRACK=m +CONFIG_IP_NF_MATCH_OWNER=m +CONFIG_IP_NF_MATCH_PHYSDEV=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_TARGET_NOTRACK=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 + +# +# IPv6: Netfilter Configuration +# +# CONFIG_IP6_NF_QUEUE is not set +CONFIG_IP6_NF_IPTABLES=m +CONFIG_IP6_NF_MATCH_LIMIT=m +CONFIG_IP6_NF_MATCH_MAC=m +CONFIG_IP6_NF_MATCH_RT=m +CONFIG_IP6_NF_MATCH_OPTS=m +CONFIG_IP6_NF_MATCH_FRAG=m +CONFIG_IP6_NF_MATCH_HL=m +CONFIG_IP6_NF_MATCH_MULTIPORT=m +CONFIG_IP6_NF_MATCH_OWNER=m +CONFIG_IP6_NF_MATCH_MARK=m +CONFIG_IP6_NF_MATCH_IPV6HEADER=m +CONFIG_IP6_NF_MATCH_AHESP=m +CONFIG_IP6_NF_MATCH_LENGTH=m +CONFIG_IP6_NF_MATCH_EUI64=m +CONFIG_IP6_NF_FILTER=m +CONFIG_IP6_NF_TARGET_LOG=m +CONFIG_IP6_NF_MANGLE=m +CONFIG_IP6_NF_TARGET_MARK=m +CONFIG_IP6_NF_RAW=m + +# +# Bridge: Netfilter Configuration +# +CONFIG_BRIDGE_NF_EBTABLES=m +CONFIG_BRIDGE_EBT_BROUTE=m +CONFIG_BRIDGE_EBT_T_FILTER=m +CONFIG_BRIDGE_EBT_T_NAT=m +CONFIG_BRIDGE_EBT_802_3=m +CONFIG_BRIDGE_EBT_AMONG=m +CONFIG_BRIDGE_EBT_ARP=m +CONFIG_BRIDGE_EBT_IP=m +CONFIG_BRIDGE_EBT_LIMIT=m +CONFIG_BRIDGE_EBT_MARK=m +CONFIG_BRIDGE_EBT_PKTTYPE=m +CONFIG_BRIDGE_EBT_STP=m +CONFIG_BRIDGE_EBT_VLAN=m +CONFIG_BRIDGE_EBT_ARPREPLY=m +CONFIG_BRIDGE_EBT_DNAT=m +CONFIG_BRIDGE_EBT_MARK_T=m +CONFIG_BRIDGE_EBT_REDIRECT=m +CONFIG_BRIDGE_EBT_SNAT=m +CONFIG_BRIDGE_EBT_LOG=m +CONFIG_XFRM=y +CONFIG_XFRM_USER=y + +# +# SCTP Configuration (EXPERIMENTAL) +# +CONFIG_IP_SCTP=m +# CONFIG_SCTP_DBG_MSG is not set +# CONFIG_SCTP_DBG_OBJCNT is not set +# CONFIG_SCTP_HMAC_NONE is not set +# CONFIG_SCTP_HMAC_SHA1 is not set +CONFIG_SCTP_HMAC_MD5=y +# CONFIG_ATM is not set +CONFIG_VLAN_8021Q=m +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_LTPC=m +CONFIG_COPS=m +CONFIG_COPS_DAYNA=y +CONFIG_COPS_TANGENT=y +CONFIG_IPDDP=m +CONFIG_IPDDP_ENCAP=y +CONFIG_IPDDP_DECAP=y +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +CONFIG_NET_DIVERT=y +# CONFIG_ECONET is not set +CONFIG_WAN_ROUTER=m +# CONFIG_NET_FASTROUTE is not set +# 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_CSZ=m +CONFIG_NET_SCH_PRIO=m +CONFIG_NET_SCH_RED=m +CONFIG_NET_SCH_SFQ=m +CONFIG_NET_SCH_TEQL=m +CONFIG_NET_SCH_TBF=m +CONFIG_NET_SCH_GRED=m +CONFIG_NET_SCH_DSMARK=m +CONFIG_NET_SCH_INGRESS=m +CONFIG_NET_SCH_HFSC=m +CONFIG_NET_SCH_DELAY=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 is not set +CONFIG_NETDEVICES=y + +# +# ARCnet devices +# +# CONFIG_ARCNET is not set +CONFIG_DUMMY=m +CONFIG_BONDING=m +CONFIG_EQUALIZER=m +CONFIG_TUN=m +CONFIG_ETHERTAP=m +CONFIG_NET_SB1000=m + +# +# 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_NI52=m +CONFIG_NI65=m + +# +# Tulip family network device support +# +CONFIG_NET_TULIP=y +CONFIG_DE2104X=m +CONFIG_TULIP=m +# CONFIG_TULIP_NAPI is not set + +# CONFIG_TULIP_MWI is not set +CONFIG_TULIP_MMIO=y +# CONFIG_NI5010 is not set +# CONFIG_PCMCIA_XIRTULIP is not set +CONFIG_DE4X5=m +CONFIG_WINBOND_840=m +CONFIG_DM9102=m +CONFIG_PCMCIA_XIRCOM=m +# CONFIG_AT1700 is not set +CONFIG_DEPCA=m +CONFIG_HP100=m +# CONFIG_NET_ISA is not set +# CONFIG_EWRK3 is not set +CONFIG_E2100=m +CONFIG_EEXPRESS=m +CONFIG_EEXPRESS_PRO=m +CONFIG_HPLAN_PLUS=m +CONFIG_HPLAN=m +CONFIG_LP486E=m +CONFIG_ETH16I=m +CONFIG_NE2000=m +CONFIG_ZNET=m +CONFIG_SEEQ8005=m +CONFIG_LNE390=m +CONFIG_NE3210=m +CONFIG_ES3210=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_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_FORCEDETH=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_8139_RXBUF_IDX=2 +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_NET_POCKET=y +CONFIG_ATP=m +CONFIG_DE600=m +CONFIG_DE620=m + +# +# Ethernet (1000 Mbit) +# +CONFIG_NET_GIGE=y +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 +CONFIG_FDDI=y +# CONFIG_DEFXX is not set +CONFIG_SKFP=m +# CONFIG_HIPPI is not set +CONFIG_PLIP=m +CONFIG_PPP=m +CONFIG_PPP_MULTILINK=y +CONFIG_PPP_FILTER=y +CONFIG_PPP_ASYNC=m +CONFIG_PPP_SYNC_TTY=m +CONFIG_PPP_DEFLATE=m +CONFIG_IPPP_FILTER=y +# CONFIG_PPP_BSDCOMP is not set +CONFIG_PPPOE=m +# 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=m +CONFIG_PCMCIA_WAVELAN=m +CONFIG_PCMCIA_NETWAVE=m + +# +# Wireless 802.11 Frequency Hopping cards support +# +# CONFIG_PCMCIA_RAYCS is not set + +# +# Wireless 802.11b ISA/PCI cards support +# +CONFIG_AIRO=m +CONFIG_HERMES=m +CONFIG_PLX_HERMES=m +CONFIG_TMD_HERMES=m +CONFIG_PCI_HERMES=m +CONFIG_ATMEL=m +CONFIG_PCI_ATMEL=m +CONFIG_PRISM54=m + +# +# Wireless 802.11b Pcmcia/Cardbus cards support +# +CONFIG_PCMCIA_HERMES=m +CONFIG_AIRO_CS=m +CONFIG_PCMCIA_ATMEL=m +CONFIG_PCMCIA_WL3501=m +CONFIG_NET_WIRELESS=y + +# +# Token Ring devices +# +# CONFIG_TR is not set + +CONFIG_NET_FC=y +CONFIG_RCPCI=m +# CONFIG_SHAPER is not set + +# +# Wan interfaces +# +# CONFIG_WAN is not set + +# +# PCMCIA network device support +# +CONFIG_NET_PCMCIA=y +CONFIG_PCMCIA_3C589=m +CONFIG_PCMCIA_3C574=m +CONFIG_PCMCIA_FMVJ18X=m +CONFIG_PCMCIA_PCNET=m +CONFIG_PCMCIA_NMCLAN=m +CONFIG_PCMCIA_SMC91C92=m +CONFIG_PCMCIA_XIRC2PS=m +CONFIG_PCMCIA_AXNET=m + +# +# Amateur Radio support +# +# CONFIG_HAMRADIO is not set + +# +# IrDA (infrared) support +# +CONFIG_IRDA=m +# CONFIG_IRDA_DEBUG is not set +CONFIG_IRLAN=m +CONFIG_IRNET=m +CONFIG_IRCOMM=m +# CONFIG_IRDA_ULTRA is not set +CONFIG_IRDA_CACHE_LAST_LSAP=y +CONFIG_IRDA_FAST_RR=y +CONFIG_IRTTY_SIR=m +CONFIG_DONGLE=y +CONFIG_ESI_DONGLE=m +CONFIG_ACTISYS_DONGLE=m +CONFIG_TEKRAM_DONGLE=m +CONFIG_IRPORT_SIR=m +# CONFIG_DONGLE_OLD is not set +CONFIG_LITELINK_DONGLE=m +CONFIG_MA600_DONGLE=m +CONFIG_GIRBIL_DONGLE=m +CONFIG_MCP2120_DONGLE=m +CONFIG_OLD_BELKIN_DONGLE=m +CONFIG_ACT200L_DONGLE=m + +CONFIG_USB_IRDA=m +CONFIG_NSC_FIR=m +CONFIG_SIGMATEL_FIR=m +# CONFIG_WINBOND_FIR is not set +# CONFIG_TOSHIBA_FIR is not set +# CONFIG_SMC_IRCC_FIR is not set +# CONFIG_ALI_FIR is not set +# CONFIG_VLSI_FIR is not set +# CONFIG_VIA_FIR is not set + + + +# +# Bluetooth support +# +CONFIG_BT=m +CONFIG_BT_L2CAP=m +CONFIG_BT_SCO=m +CONFIG_BT_CMTP=m +CONFIG_BT_RFCOMM=m +CONFIG_BT_RFCOMM_TTY=y +CONFIG_BT_BNEP=m +CONFIG_BT_BNEP_MC_FILTER=y +CONFIG_BT_BNEP_PROTO_FILTER=y + +# +# Bluetooth device drivers +# +CONFIG_BT_HCIUSB=m +CONFIG_BT_HCIUART=m +CONFIG_BT_HCIUART_H4=y +CONFIG_BT_HCIUART_BCSP=y +CONFIG_BT_HCIUART_BCSP_TXCRC=y +CONFIG_BT_HCIDTL1=m +CONFIG_BT_HCIBT3C=m +CONFIG_BT_HCIBLUECARD=m +CONFIG_BT_HCIBTUART=m +CONFIG_BT_HCIVHCI=m +CONFIG_BT_HCIUSB_SCO=y +CONFIG_BT_HCIBCM203X=m +CONFIG_BT_HCIBFUSB=m +CONFIG_BT_CMTP=m +CONFIG_BT_HCIUSB_SCO=m +CONFIG_BT_HCIBCM203X=m +CONFIG_BT_HCIBFUSB=m +CONFIG_USB_BLUETOOTH_TTY=m + +# +# ISDN subsystem +# + +CONFIG_ISDN=m +CONFIG_ISDN_I4L=m +CONFIG_ISDN_DRV_AVMB1_B1ISA=m +CONFIG_ISDN_DRV_AVMB1_B1PCI=m +CONFIG_ISDN_DRV_AVMB1_T1ISA=m +CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m +CONFIG_ISDN_DRV_AVMB1_T1PCI=m +CONFIG_ISDN_DRV_AVMB1_C4=m + +CONFIG_ISDN_PPP=y +CONFIG_ISDN_PPP_VJ=y +CONFIG_ISDN_MPP=y +# CONFIG_ISDN_PPP_BSDCOMP is not set +CONFIG_ISDN_TTY_FAX=y +CONFIG_DE_AOC=y + +CONFIG_ISDN_AUDIO=y + +CONFIG_ISDN_DRV_HISAX=m +CONFIG_ISDN_DRV_ICN=m +CONFIG_ISDN_DRV_PCBIT=m +CONFIG_ISDN_DRV_SC=m +CONFIG_ISDN_DRV_ACT2000=m +CONFIG_ISDN_DRV_TPAM=m +CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y +CONFIG_ISDN_DRV_AVMB1_AVM_CS=m + +CONFIG_ISDN_CAPI_CAPIDRV=m + +CONFIG_HISAX_EURO=y +CONFIG_HISAX_1TR6=y +CONFIG_HISAX_NI1=y +CONFIG_HISAX_MAX_CARDS=8 +CONFIG_HISAX_16_0=y +CONFIG_HISAX_16_3=y +CONFIG_HISAX_TELESPCI=y +CONFIG_HISAX_S0BOX=y +CONFIG_HISAX_AVM_A1=y +CONFIG_HISAX_FRITZPCI=y +CONFIG_HISAX_AVM_A1_PCMCIA=y +CONFIG_HISAX_ELSA=y +CONFIG_HISAX_IX1MICROR2=y +CONFIG_HISAX_DIEHLDIVA=y +CONFIG_HISAX_ASUSCOM=y +CONFIG_HISAX_TELEINT=y +CONFIG_HISAX_HFCS=y +CONFIG_HISAX_SEDLBAUER=y +CONFIG_HISAX_SPORTSTER=y +CONFIG_HISAX_MIC=y +CONFIG_HISAX_NETJET=y +CONFIG_HISAX_NETJET_U=y +CONFIG_HISAX_NICCY=y +CONFIG_HISAX_ISURF=y +CONFIG_HISAX_HSTSAPHIR=y +CONFIG_HISAX_BKM_A4T=y +CONFIG_HISAX_SCT_QUADRO=y +CONFIG_HISAX_GAZEL=y +CONFIG_HISAX_HFC_PCI=y +CONFIG_HISAX_W6692=y +CONFIG_HISAX_HFC_SX=y +CONFIG_HISAX_ENTERNOW_PCI=y +# CONFIG_HISAX_DEBUG is not set +CONFIG_HISAX_AVM_A1_CS=m +CONFIG_HISAX_ST5481=m +CONFIG_HISAX_HFCUSB=m +CONFIG_HISAX_FRITZ_PCIPNP=m +CONFIG_HISAX_NO_SENDCOMPLETE=y +CONFIG_HISAX_NO_LLC=y +CONFIG_HISAX_NO_KEYPAD=y +CONFIG_HISAX_SEDLBAUER_CS=m +CONFIG_HISAX_ELSA_CS=m +CONFIG_HISAX_TELES_CS=m + +CONFIG_ISDN_DRV_LOOP=m +CONFIG_HYSDN=m +CONFIG_HYSDN_CAPI=y + + +# +# CAPI subsystem +# +CONFIG_ISDN_CAPI=m +CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y +CONFIG_ISDN_CAPI_MIDDLEWARE=y +CONFIG_ISDN_CAPI_CAPI20=m +CONFIG_ISDN_CAPI_CAPIFS_BOOL=y +CONFIG_ISDN_CAPI_CAPIFS=m + +# +# CAPI hardware drivers +# + +# +# Active AVM cards +# +CONFIG_CAPI_AVM=y + +# +# Active Eicon DIVA Server cards +# +CONFIG_CAPI_EICON=y +CONFIG_ISDN_DIVAS=m +CONFIG_ISDN_DIVAS_BRIPCI=y +CONFIG_ISDN_DIVAS_PRIPCI=y +CONFIG_ISDN_DIVAS_DIVACAPI=m +CONFIG_ISDN_DIVAS_USERIDI=m +CONFIG_ISDN_DIVAS_MAINT=m + +# +# 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=m +# CONFIG_INPUT_TSDEV is not set +CONFIG_INPUT_EVDEV=y +# CONFIG_INPUT_EVBUG is not set + +# +# Input I/O drivers +# +CONFIG_GAMEPORT=m +CONFIG_SOUND_GAMEPORT=m +CONFIG_GAMEPORT_NS558=m +CONFIG_GAMEPORT_L4=m +CONFIG_GAMEPORT_EMU10K1=m +CONFIG_GAMEPORT_VORTEX=m +CONFIG_GAMEPORT_FM801=m +CONFIG_GAMEPORT_CS461x=m +CONFIG_SERIO=y +CONFIG_SERIO_I8042=y +CONFIG_SERIO_SERPORT=y +# CONFIG_SERIO_CT82C710 is not set +# CONFIG_SERIO_PARKBD is not set +# CONFIG_SERIO_PCIPS2 is not set + +# +# Input Device Drivers +# +CONFIG_INPUT_KEYBOARD=y +CONFIG_KEYBOARD_ATKBD=y +# CONFIG_KEYBOARD_SUNKBD is not set +# CONFIG_KEYBOARD_XTKBD is not set +# CONFIG_KEYBOARD_NEWTON is not set +# CONFIG_KEYBOARD_LKKBD is not set +CONFIG_INPUT_MOUSE=y +CONFIG_MOUSE_PS2=y +CONFIG_MOUSE_SERIAL=m +CONFIG_MOUSE_INPORT=m +CONFIG_MOUSE_ATIXL=y +CONFIG_MOUSE_LOGIBM=m +CONFIG_MOUSE_PC110PAD=m +CONFIG_MOUSE_VSXXXAA=m +CONFIG_INPUT_JOYSTICK=y +CONFIG_JOYSTICK_ANALOG=m +CONFIG_JOYSTICK_A3D=m +CONFIG_JOYSTICK_ADI=m +CONFIG_JOYSTICK_COBRA=m +CONFIG_JOYSTICK_GF2K=m +CONFIG_JOYSTICK_GRIP=m +CONFIG_JOYSTICK_GRIP_MP=m +CONFIG_JOYSTICK_GUILLEMOT=m +CONFIG_JOYSTICK_INTERACT=m +CONFIG_JOYSTICK_SIDEWINDER=m +CONFIG_JOYSTICK_TMDC=m +CONFIG_JOYSTICK_IFORCE=m +CONFIG_JOYSTICK_IFORCE_USB=y +CONFIG_JOYSTICK_IFORCE_232=y +CONFIG_JOYSTICK_WARRIOR=m +CONFIG_JOYSTICK_MAGELLAN=m +CONFIG_JOYSTICK_SPACEORB=m +CONFIG_JOYSTICK_SPACEBALL=m +CONFIG_JOYSTICK_STINGER=m +CONFIG_JOYSTICK_TWIDDLER=m +CONFIG_JOYSTICK_DB9=m +CONFIG_JOYSTICK_GAMECON=m +CONFIG_JOYSTICK_TURBOGRAFX=m +# CONFIG_INPUT_JOYDUMP is not set +CONFIG_INPUT_TOUCHSCREEN=y +CONFIG_TOUCHSCREEN_GUNZE=m +CONFIG_INPUT_MISC=y +CONFIG_INPUT_PCSPKR=m +# CONFIG_INPUT_UINPUT is not set + +# +# Character devices +# +CONFIG_VT=y +CONFIG_VT_CONSOLE=y +CONFIG_HW_CONSOLE=y +CONFIG_SERIAL_NONSTANDARD=y +CONFIG_ROCKETPORT=m +CONFIG_SYNCLINK=m +CONFIG_SYNCLINKMP=m +CONFIG_N_HDLC=m +CONFIG_STALDRV=y +# CONFIG_FTAPE is not set +CONFIG_IBM_ASM=m + +# +# Serial drivers +# +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_CS=m +# 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 +# CONFIG_COMPUTONE is not set +# CONFIG_CYCLADES is not set +# CONFIG_DIGIEPCA is not set +# CONFIG_DIGI is not set +# CONFIG_ESPSERIAL is not set +# CONFIG_MOXA_INTELLIO is not set +# CONFIG_MOXA_SMARTIO is not set +# CONFIG_ISI is not set +# CONFIG_RISCOM8 is not set +# CONFIG_SPECIALIX is not set +# CONFIG_SX is not set +# CONFIG_RIO is not set +# CONFIG_STALLION is not set +# CONFIG_ISTALLION is not set + +# +# Non-8250 serial port support +# +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_UNIX98_PTYS=y +CONFIG_UNIX98_PTY_COUNT=2048 +# CONFIG_LEGACY_PTYS is not set +CONFIG_PRINTER=m +CONFIG_LP_CONSOLE=y +CONFIG_PPDEV=m +CONFIG_TIPAR=m + +# +# I2C support +# +CONFIG_I2C=m +CONFIG_I2C_CHARDEV=m + +# +# I2C Algorithms +# +# CONFIG_I2C_DEBUG_ALGO is not set +CONFIG_I2C_ALGOBIT=m +CONFIG_I2C_ALGOPCF=m + +# +# I2C Hardware Bus support +# +CONFIG_I2C_ALI1535=m +CONFIG_I2C_ALI15X3=m +CONFIG_I2C_AMD756=m +CONFIG_I2C_AMD8111=m +CONFIG_I2C_I801=m +CONFIG_I2C_I810=m +CONFIG_I2C_ISA=m +CONFIG_I2C_NFORCE2=m +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 +# CONFIG_I2C_ELEKTOR is not set +CONFIG_I2C_PARPORT=m +CONFIG_I2C_PARPORT_LIGHT=m +# CONFIG_I2C_DEBUG_CORE is not set +# CONFIG_I2C_DEBUG_BUS is not set +# CONFIG_I2C_DEBUG_CHIP is not set +# CONFIG_I2C_PARPORT is not set +CONFIG_I2C_ALI1563=m +# CONFIG_I2C_PARPORT_LIGHT is not set + + + +# +# I2C Hardware Sensors Chip support +# +CONFIG_I2C_SENSOR=m +CONFIG_SENSORS_ADM1021=m +CONFIG_SENSORS_EEPROM=m +CONFIG_SENSORS_IT87=m +CONFIG_SENSORS_LM75=m +CONFIG_SENSORS_LM78=m +CONFIG_SENSORS_LM80=m +CONFIG_SENSORS_LM83=m +CONFIG_SENSORS_LM85=m +CONFIG_SENSORS_VIA686A=m +CONFIG_SENSORS_W83781D=m +CONFIG_SENSORS_ASB100=m +CONFIG_SENSORS_LM90=m +CONFIG_SENSORS_W83L785TS=m +CONFIG_SENSORS_FSCHER=m +CONFIG_SENSORS_GL518SM=m +CONFIG_SENSORS_DS1621=m +CONFIG_SENSORS_W83627HF=m +CONFIG_SENSORS_PCF8574=m +CONFIG_SENSORS_PCF8591=m +CONFIG_SENSORS_RTC8564=m +CONFIG_SENSORS_MAX1619=m + + +# +# Mice +# +CONFIG_BUSMOUSE=m +# CONFIG_QIC02_TAPE is not set +CONFIG_CRASH=m + +# +# IPMI +# +CONFIG_IPMI_HANDLER=m +# CONFIG_IPMI_PANIC_EVENT is not set +CONFIG_IPMI_DEVICE_INTERFACE=m +CONFIG_IPMI_KCS=m +CONFIG_IPMI_WATCHDOG=m +CONFIG_IPMI_SI=m + +# +# Watchdog Cards +# +CONFIG_WATCHDOG=y +# CONFIG_WATCHDOG_NOWAYOUT is not set +CONFIG_SOFT_WATCHDOG=m +CONFIG_WDT=m +# CONFIG_WDT_501 is not set +CONFIG_WDTPCI=m +CONFIG_WDT_501_PCI=y +CONFIG_PCWATCHDOG=m +CONFIG_ACQUIRE_WDT=m +CONFIG_ADVANTECH_WDT=m +CONFIG_EUROTECH_WDT=m +CONFIG_IB700_WDT=m +CONFIG_I8XX_TCO=m +# CONFIG_MIXCOMWD is not set +# CONFIG_SCx200_WDT is not set +# CONFIG_60XX_WDT is not set +CONFIG_W83877F_WDT=m +CONFIG_W83627HF_WDT=m +CONFIG_MACHZ_WDT=m +CONFIG_SC520_WDT=m +CONFIG_AMD7XX_TCO=m +CONFIG_ALIM7101_WDT=m +CONFIG_ALIM1535_WDT=m +CONFIG_SC1200_WDT=m +CONFIG_WAFER_WDT=m +CONFIG_CPU5_WDT=m +CONFIG_PCIPCWATCHDOG=m +CONFIG_USBPCWATCHDOG=m + + +CONFIG_HW_RANDOM=m +CONFIG_NVRAM=m +CONFIG_RTC=y +CONFIG_DTLK=m +CONFIG_R3964=m +# CONFIG_APPLICOM is not set +CONFIG_SONYPI=m + +# +# Ftape, the floppy tape device driver +# +CONFIG_AGP=y +CONFIG_AGP_ALI=y +CONFIG_AGP_ATI=y +CONFIG_AGP_AMD=y +CONFIG_AGP_AMD64=y +CONFIG_AGP_INTEL=y +CONFIG_AGP_INTEL_MCH=y +CONFIG_AGP_NVIDIA=y +CONFIG_AGP_SIS=y +CONFIG_AGP_SWORKS=y +CONFIG_AGP_VIA=y +CONFIG_AGP_EFFICEON=y +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 + + +# +# PCMCIA character devices +# +CONFIG_SYNCLINK_CS=m + + + +CONFIG_MWAVE=m +# CONFIG_RAW_DRIVER is not set +CONFIG_MAX_RAW_DEVS=8192 +CONFIG_HANGCHECK_TIMER=m + +# +# Multimedia devices +# +CONFIG_VIDEO_DEV=m + +# +# Video For Linux +# + +# +# Video Adapters +# +CONFIG_VIDEO_BT848=m +CONFIG_VIDEO_PMS=m +CONFIG_VIDEO_BWQCAM=m +CONFIG_VIDEO_CQCAM=m +CONFIG_VIDEO_W9966=m +CONFIG_VIDEO_CPIA=m +CONFIG_VIDEO_CPIA_PP=m +CONFIG_VIDEO_CPIA_USB=m +CONFIG_VIDEO_SAA5249=m +CONFIG_TUNER_3036=m +CONFIG_VIDEO_STRADIS=m +CONFIG_VIDEO_ZORAN=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_MEYE=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_SAA5246A=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_MIROPCM20=m +CONFIG_RADIO_MIROPCM20_RDS=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_DVB_CORE=m + +# +# Supported Frontend Modules +# +CONFIG_DVB_STV0299=m +# CONFIG_DVB_SP887X is not set +# CONFIG_DVB_ALPS_TDLB7 is not set +CONFIG_DVB_ALPS_TDMB7=m +CONFIG_DVB_ATMEL_AT76C651=m +CONFIG_DVB_CX24110=m +CONFIG_DVB_GRUNDIG_29504_491=m +CONFIG_DVB_GRUNDIG_29504_401=m +CONFIG_DVB_MT312=m +CONFIG_DVB_VES1820=m +CONFIG_DVB_VES1X93=m +CONFIG_DVB_TWINHAN_DST=m +CONFIG_DVB_TTUSB_DEC=m +CONFIG_DVB_BT8XX=m +# CONFIG_DVB_TDA1004X is not set +CONFIG_DVB_NXT6000=m + +# +# Supported SAA7146 based PCI Adapters +# +CONFIG_DVB_AV7110=m +CONFIG_DVB_AV7110_OSD=y +# CONFIG_DVB_AV7110_FIRMWARE is not set +CONFIG_DVB_BUDGET=m +CONFIG_DVB_BUDGET_CI=m +CONFIG_DVB_BUDGET_AV=m +CONFIG_DVB_BUDGET_PATCH=m + +# +# Supported USB Adapters +# +CONFIG_DVB_TTUSB_BUDGET=m + +# +# Supported FlexCopII (B2C2) Adapters +# +CONFIG_DVB_B2C2_SKYSTAR=m +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 + +# +# Graphics support +# +CONFIG_FB=y +# CONFIG_FB_CYBER2000 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_RIVA=m +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=m +# CONFIG_FB_RADEON_DEBUG is not set +# CONFIG_FB_RADEON_OLD is not set +CONFIG_FB_RADEON_I2C=y +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_SIS_300=y +CONFIG_FB_SIS_315=y +CONFIG_FB_NEOMAGIC=m +CONFIG_FB_3DFX=m +CONFIG_FB_VOODOO1=m +CONFIG_FB_TRIDENT=m +# CONFIG_FB_VIRTUAL is not set +CONFIG_FB_KYRO=m +# CONFIG_FB_PM2 is not set +# CONFIG_FB_PM2_FIFO_DISCONNECT is not set +# CONFIG_FB_ASILIANT is not set +CONFIG_FB_HGA_ACCEL=y +CONFIG_FB_3DFX_ACCEL=y +CONFIG_FB_TRIDENT_ACCEL=y + +# +# 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 + + +# +# Logo configuration +# +CONFIG_LOGO=y +# CONFIG_LOGO_LINUX_MONO is not set +# CONFIG_LOGO_LINUX_VGA16 is not set +CONFIG_LOGO_LINUX_CLUT224=y + +# +# Sound +# +CONFIG_SOUND=m + +# +# Advanced Linux Sound Architecture +# +CONFIG_SND=m +CONFIG_SND_SEQUENCER=m +CONFIG_SND_SEQ_DUMMY=m +CONFIG_SND_OSSEMUL=y +CONFIG_SND_MIXER_OSS=m +CONFIG_SND_PCM_OSS=m +CONFIG_SND_SEQUENCER_OSS=y +CONFIG_SND_RTCTIMER=m +# CONFIG_SND_VERBOSE_PRINTK is not set +# CONFIG_SND_DEBUG is not set +CONFIG_SND_BIT32_EMUL=y + +# +# Generic devices +# +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_ALI5451=m +CONFIG_SND_AZT3328=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_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_ICE1712=m +CONFIG_SND_ICE1724=m +CONFIG_SND_INTEL8X0=m +CONFIG_SND_SONICVIBES=m +CONFIG_SND_VIA82XX=m +CONFIG_SND_VX222=m +CONFIG_SND_BT87X=m +CONFIG_SND_ATIIXP=m +CONFIG_SND_AU8810=m +CONFIG_SND_AU8820=m +CONFIG_SND_AU8830=m +CONFIG_SND_MIXART=m +CONFIG_SND_FM801_TEA575X=m +CONFIG_SND_INTEL8X0M=m +CONFIG_SND_PDAUDIOCF=m + + +# +# ALSA USB devices +# +CONFIG_SND_USB_AUDIO=m + +# +# PCMCIA devices +# +# CONFIG_SND_VXPOCKET is not set +# CONFIG_SND_VXP440 is not set + +# +# Open Sound System +# +# CONFIG_SOUND_PRIME is not set +# CONFIG_SOUND_BT878 is not set +# CONFIG_SOUND_CMPCI is not set + +# +# USB support +# +CONFIG_USB=y +# CONFIG_USB_DEBUG is not set + +# +# Miscellaneous USB options +# +CONFIG_USB_DEVICEFS=y +# CONFIG_USB_BANDWIDTH is not set +# CONFIG_USB_DYNAMIC_MINORS is not set + +# +# 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=m + +# +# USB Bluetooth TTY can only be used with disabled Bluetooth subsystem +# +CONFIG_USB_MIDI=m +CONFIG_USB_ACM=m +CONFIG_USB_PRINTER=m +CONFIG_USB_STORAGE=m +# CONFIG_USB_STORAGE_DEBUG is not set +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=y +CONFIG_USB_HIDINPUT=y +CONFIG_HID_FF=y +CONFIG_HID_PID=y +CONFIG_LOGITECH_FF=y +CONFIG_THRUSTMASTER_FF=y +CONFIG_USB_HIDDEV=y + +# +# USB HID Boot Protocol drivers +# +# CONFIG_USB_KBD is not set +# CONFIG_USB_MOUSE is not set +CONFIG_USB_AIPTEK=m +CONFIG_USB_WACOM=m +CONFIG_USB_KBTAB=m +CONFIG_USB_POWERMATE=m +CONFIG_USB_XPAD=m + +# +# USB Imaging devices +# +CONFIG_USB_MDC800=m +CONFIG_USB_MICROTEK=m +CONFIG_USB_HPUSBSCSI=m + +# +# USB Multimedia devices +# +CONFIG_USB_DABUSB=m +CONFIG_USB_VICAM=m +CONFIG_USB_DSBR=m +CONFIG_USB_IBMCAM=m +CONFIG_USB_KONICAWC=m +CONFIG_USB_OV511=m +CONFIG_USB_PWC=m +CONFIG_USB_SE401=m +CONFIG_USB_STV680=m + +# +# 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_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 +# +CONFIG_USB_USS720=m + +# +# USB Serial Converter support +# +CONFIG_USB_SERIAL=m +CONFIG_USB_SERIAL_GENERIC=y +CONFIG_USB_SERIAL_BELKIN=m +CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m +CONFIG_USB_SERIAL_EMPEG=m +CONFIG_USB_SERIAL_FTDI_SIO=m +CONFIG_USB_SERIAL_VISOR=m +CONFIG_USB_SERIAL_IPAQ=m +CONFIG_USB_SERIAL_IR=m +CONFIG_USB_SERIAL_EDGEPORT=m +CONFIG_USB_SERIAL_EDGEPORT_TI=m +CONFIG_USB_SERIAL_KEYSPAN_PDA=m +CONFIG_USB_SERIAL_KEYSPAN=m +CONFIG_USB_SERIAL_KEYSPAN_MPR=y +CONFIG_USB_SERIAL_KEYSPAN_USA28=y +CONFIG_USB_SERIAL_KEYSPAN_USA28X=y +CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y +CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y +CONFIG_USB_SERIAL_KEYSPAN_USA19=y +CONFIG_USB_SERIAL_KEYSPAN_USA18X=y +CONFIG_USB_SERIAL_KEYSPAN_USA19W=y +CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y +CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y +CONFIG_USB_SERIAL_KEYSPAN_USA49W=y +CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y +CONFIG_USB_SERIAL_KLSI=m +CONFIG_USB_SERIAL_KOBIL_SCT=m +CONFIG_USB_SERIAL_MCT_U232=m +CONFIG_USB_SERIAL_PL2303=m +CONFIG_USB_SERIAL_SAFE=m +CONFIG_USB_SERIAL_SAFE_PADDED=y +CONFIG_USB_SERIAL_CYBERJACK=m +CONFIG_USB_SERIAL_XIRCOM=m +CONFIG_USB_SERIAL_OMNINET=m +CONFIG_USB_SERIAL_WHITEHEAT=m +CONFIG_USB_EZUSB=y +CONFIG_USB_EMI62=m +CONFIG_USB_LED=m +CONFIG_USB_G_SERIAL=m + + +# +# USB Miscellaneous drivers +# +# CONFIG_USB_EMI26 is not set +CONFIG_USB_TIGL=m +CONFIG_USB_AUERSWALD=m +CONFIG_USB_RIO500=m +CONFIG_USB_BRLVGER=m +CONFIG_USB_LCD=m +CONFIG_USB_TEST=m +# CONFIG_USB_GADGET is not set +# CONFIG_USB_GADGET_PXA2XX is not set +# CONFIG_USB_GADGET_GOKU is not set +# CONFIG_USB_GADGET_SA1100 is not set +CONFIG_USB_ZERO=m +CONFIG_USB_ETH=m +CONFIG_USB_GADGETFS=m +CONFIG_USB_W9968CF=m +CONFIG_USB_LEGOTOWER=m +CONFIG_USB_FILE_STORAGE=m +# CONFIG_USB_FILE_STORAGE_TEST is not set +CONFIG_USB_MTOUCH=m +CONFIG_USB_ATI_REMOTE=m +CONFIG_USB_ALI_M5632=y +# CONFIG_USB_CYTHERM is not set +CONFIG_USB_EGALAX=m +CONFIG_USB_PHIDGETSERVO=m + +# +# 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=m +CONFIG_EXT3_FS_XATTR=y +CONFIG_EXT3_FS_POSIX_ACL=y +CONFIG_EXT3_FS_SECURITY=y +CONFIG_JBD=m +# CONFIG_JBD_DEBUG is not set +CONFIG_FS_MBCACHE=y +CONFIG_REISERFS_FS=m +# CONFIG_REISERFS_CHECK is not set +CONFIG_REISERFS_PROC_INFO=y +CONFIG_REISERFS_FS_XATTR=y +CONFIG_REISERFS_FS_POSIX_ACL=y +CONFIG_REISERFS_FS_SECURITY=y +CONFIG_JFS_FS=m +# CONFIG_JFS_DEBUG is not set +# CONFIG_JFS_STATISTICS is not set +CONFIG_JFS_POSIX_ACL=y +CONFIG_XFS_FS=m +# CONFIG_XFS_RT is not set +CONFIG_XFS_QUOTA=y +CONFIG_XFS_POSIX_ACL=y +CONFIG_XFS_SECURITY=y +CONFIG_MINIX_FS=m +CONFIG_ROMFS_FS=m +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 + +# +# DOS/FAT/NT Filesystems +# +CONFIG_FAT_FS=m +CONFIG_MSDOS_FS=m +CONFIG_VFAT_FS=m +# 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=y +CONFIG_DEVPTS_FS_SECURITY=y +CONFIG_TMPFS=y +CONFIG_HUGETLBFS=y +CONFIG_HUGETLB_PAGE=y +CONFIG_RAMFS=y + +# +# Miscellaneous filesystems +# +# CONFIG_ADFS_FS is not seta +CONFIG_AFFS_FS=m +# uses sleepon and needs a major update +CONFIG_HFS_FS=m +CONFIG_HFSPLUS_FS=m +CONFIG_BEFS_FS=m +# CONFIG_BEFS_DEBUG is not set +CONFIG_BFS_FS=m +CONFIG_EFS_FS=m +# CONFIG_JFFS_FS is not set +CONFIG_JFFS2_FS=m +CONFIG_JFFS2_FS_DEBUG=0 +CONFIG_JFFS2_FS_NAND=y +CONFIG_CRAMFS=m +CONFIG_VXFS_FS=m +# CONFIG_HPFS_FS is not set +CONFIG_QNX4FS_FS=m +# CONFIG_QNX4FS_RW is not set +CONFIG_SYSV_FS=m +CONFIG_UFS_FS=m +# CONFIG_UFS_FS_WRITE is not set + +# +# Network File Systems +# +CONFIG_NFS_FS=m +CONFIG_NFS_V3=y +CONFIG_NFS_V4=y +CONFIG_NFS_DIRECTIO=y +CONFIG_NFSD=m +CONFIG_NFSD_V3=y +CONFIG_NFSD_V4=y +CONFIG_NFSD_TCP=y +CONFIG_LOCKD=m +CONFIG_LOCKD_V4=y +CONFIG_EXPORTFS=m +CONFIG_SUNRPC=m +CONFIG_SUNRPC_GSS=m +CONFIG_RPCSEC_GSS_KRB5=m +CONFIG_SMB_FS=m +# CONFIG_SMB_NLS_DEFAULT is not set +CONFIG_CIFS=m +# CONFIG_CIFS_STATS is not set +CONFIG_NCP_FS=m +CONFIG_NCPFS_PACKET_SIGNING=y +CONFIG_NCPFS_IOCTL_LOCKING=y +CONFIG_NCPFS_STRONG=y +CONFIG_NCPFS_NFS_NS=y +CONFIG_NCPFS_OS2_NS=y +CONFIG_NCPFS_SMALLDOS=y +CONFIG_NCPFS_NLS=y +CONFIG_NCPFS_EXTRAS=y +# CONFIG_CODA_FS is not set +# CONFIG_INTERMEZZO_FS is not set +# CONFIG_AFS_FS is not set +# CONFIG_RXRPC is not set + +# +# Partition Types +# +CONFIG_PARTITION_ADVANCED=y +# CONFIG_ACORN_PARTITION is not set +CONFIG_OSF_PARTITION=y +# CONFIG_AMIGA_PARTITION is not set +# CONFIG_ATARI_PARTITION is not set +CONFIG_MAC_PARTITION=y +CONFIG_MSDOS_PARTITION=y +CONFIG_BSD_DISKLABEL=y +CONFIG_MINIX_SUBPARTITION=y +CONFIG_SOLARIS_X86_PARTITION=y +CONFIG_UNIXWARE_DISKLABEL=y +# CONFIG_LDM_PARTITION is not set +# CONFIG_NEC98_PARTITION is not set +CONFIG_SGI_PARTITION=y +# CONFIG_ULTRIX_PARTITION is not set +CONFIG_SUN_PARTITION=y +CONFIG_EFI_PARTITION=y +CONFIG_NLS=y + +# +# Native Language Support +# +CONFIG_NLS_DEFAULT="utf8" +CONFIG_NLS_CODEPAGE_437=m +CONFIG_NLS_CODEPAGE_737=m +CONFIG_NLS_CODEPAGE_775=m +CONFIG_NLS_CODEPAGE_850=m +CONFIG_NLS_CODEPAGE_852=m +CONFIG_NLS_CODEPAGE_855=m +CONFIG_NLS_CODEPAGE_857=m +CONFIG_NLS_CODEPAGE_860=m +CONFIG_NLS_CODEPAGE_861=m +CONFIG_NLS_CODEPAGE_862=m +CONFIG_NLS_CODEPAGE_863=m +CONFIG_NLS_CODEPAGE_864=m +CONFIG_NLS_CODEPAGE_865=m +CONFIG_NLS_CODEPAGE_866=m +CONFIG_NLS_CODEPAGE_869=m +CONFIG_NLS_CODEPAGE_936=m +CONFIG_NLS_CODEPAGE_950=m +CONFIG_NLS_CODEPAGE_932=m +CONFIG_NLS_CODEPAGE_949=m +CONFIG_NLS_CODEPAGE_874=m +CONFIG_NLS_ISO8859_8=m +CONFIG_NLS_CODEPAGE_1250=m +CONFIG_NLS_CODEPAGE_1251=m +CONFIG_NLS_ISO8859_1=m +CONFIG_NLS_ISO8859_2=m +CONFIG_NLS_ISO8859_3=m +CONFIG_NLS_ISO8859_4=m +CONFIG_NLS_ISO8859_5=m +CONFIG_NLS_ISO8859_6=m +CONFIG_NLS_ISO8859_7=m +CONFIG_NLS_ISO8859_9=m +CONFIG_NLS_ISO8859_13=m +CONFIG_NLS_ISO8859_14=m +CONFIG_NLS_ISO8859_15=m +CONFIG_NLS_KOI8_R=m +CONFIG_NLS_KOI8_U=m +CONFIG_NLS_UTF8=m + +# +# Profiling support +# +CONFIG_PROFILING=y +CONFIG_OPROFILE=m + +# +# Tux +# +CONFIG_TUX=m +CONFIG_TUX_EXTCGI=y +# CONFIG_TUX_EXTENDED_LOG is not set +# CONFIG_TUX_DEBUG is not set + + +# +# Kernel hacking +# +CONFIG_DEBUG_KERNEL=y +CONFIG_DEBUG_STACKOVERFLOW=y +# CONFIG_DEBUG_SLAB is not set +CONFIG_MAGIC_SYSRQ=y +# CONFIG_DEBUG_SPINLOCK is not set +# CONFIG_DEBUG_PAGEALLOC is not set +# CONFIG_DEBUG_HIGHMEM is not set +CONFIG_DEBUG_INFO=y +CONFIG_DEBUG_SPINLOCK_SLEEP=y +# CONFIG_FRAME_POINTER is not set +CONFIG_CC_OPTIMIZE_FOR_SIZE=y +# CONFIG_DEBUG_STACK_USAGE is not set +# CONFIG_DEBUG_DRIVER is not set + + +# +# Security options +# +CONFIG_SECURITY=y +CONFIG_SECURITY_NETWORK=y +CONFIG_SECURITY_CAPABILITIES=y +# CONFIG_SECURITY_ROOTPLUG is not set +CONFIG_SECURITY_SELINUX=y +CONFIG_SECURITY_SELINUX_BOOTPARAM=y +CONFIG_SECURITY_SELINUX_DISABLE=y +CONFIG_SECURITY_SELINUX_DEVELOP=y +# CONFIG_SECURITY_SELINUX_MLS is not set +# CONFIG_AUDIT is not set +CONFIG_AUDITSYSCALL=y + +# +# Cryptographic options +# +CONFIG_CRYPTO=y +CONFIG_CRYPTO_HMAC=y +CONFIG_CRYPTO_NULL=m +CONFIG_CRYPTO_MD4=m +CONFIG_CRYPTO_MD5=m +CONFIG_CRYPTO_SHA1=m +CONFIG_CRYPTO_SHA256=m +CONFIG_CRYPTO_SHA512=m +CONFIG_CRYPTO_DES=m +CONFIG_CRYPTO_BLOWFISH=m +CONFIG_CRYPTO_TWOFISH=m +CONFIG_CRYPTO_SERPENT=m +CONFIG_CRYPTO_AES=m +CONFIG_CRYPTO_CAST5=m +CONFIG_CRYPTO_CAST6=m +CONFIG_CRYPTO_DEFLATE=m +CONFIG_CRYPTO_ARC4=m +CONFIG_CRYPTO_MICHAEL_MIC=m +# CONFIG_CRYPTO_TEST is not set +CONFIG_LIBCRC32C=m +CONFIG_CRYPTO_CRC32C=m + +# +# Library routines +# +CONFIG_CRC32=m +CONFIG_ZLIB_INFLATE=y +CONFIG_ZLIB_DEFLATE=m +CONFIG_PC=y +# CONFIG_X86_PC is not set +# 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=y +# 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_HPET_TIMER=y +CONFIG_HPET_EMULATE_RTC=y +CONFIG_NR_CPUS=32 +CONFIG_X86_LOCAL_APIC=y +CONFIG_X86_IO_APIC=y +CONFIG_X86_TSC=y +CONFIG_X86_MCE=y +# CONFIG_X86_MCE_NONFATAL is not set +CONFIG_X86_MCE_P4THERMAL=y +CONFIG_TOSHIBA=m +CONFIG_I8K=m +CONFIG_SONYPI=m +CONFIG_MICROCODE=m +CONFIG_X86_MSR=m +CONFIG_X86_CPUID=m +CONFIG_EDD=m +# CONFIG_NOHIGHMEM is not set +CONFIG_HIGHMEM4G=y +CONFIG_HIGHMEM64G=y +# CONFIG_HIGHMEM64G is not set +CONFIG_HIGHMEM=y +CONFIG_HIGHPTE=y +# CONFIG_MATH_EMULATION is not set +CONFIG_MTRR=y +CONFIG_HAVE_DEC_LOCK=y +# CONFIG_X86_UP_APIC is not set +CONFIG_X86_PM_TIMER=y +CONFIG_X86_4G=y +# CONFIG_EFI is not set +CONFIG_REGPARM=y +# CONFIG_PCI_GOBIOS is not set +# CONFIG_PCI_GODIRECT is not set +CONFIG_PCI_GOANY=y +CONFIG_MDA_CONSOLE=m +CONFIG_SYNCLINK_CS=m +CONFIG_SYNCLINK=m +CONFIG_SYNCLINKMP=m +CONFIG_HP100=m +CONFIG_PCMCIA_FDOMAIN=m +CONFIG_SCSI_FUTURE_DOMAIN=m +CONFIG_CRASH=m +CONFIG_I2O=m +CONFIG_APM=y +# 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 +CONFIG_X86_FIND_SMP_CONFIG=y +CONFIG_X86_MPPARSE=y +CONFIG_4KSTACKS=y +CONFIG_X86_ACPI_CPUFREQ=m +# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set +CONFIG_X86_POWERNOW_K6=m +CONFIG_X86_POWERNOW_K7=y +CONFIG_X86_POWERNOW_K8=m +# CONFIG_X86_GX_SUSPMOD is not set +CONFIG_X86_SPEEDSTEP_CENTRINO=y +CONFIG_X86_SPEEDSTEP_ICH=y +CONFIG_X86_SPEEDSTEP_SMI=m +CONFIG_X86_SPEEDSTEP_LIB=y +CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI=y +# CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK is not set +CONFIG_X86_P4_CLOCKMOD=m +CONFIG_X86_LONGRUN=y +# CONFIG_X86_LONGHAUL is not set +CONFIG_X86_SMP=y +CONFIG_X86_HT=y +CONFIG_X86_BIOS_REBOOT=y +CONFIG_X86_TRAMPOLINE=y +CONFIG_TUX=m +CONFIG_NVRAM=m +CONFIG_IBM_ASM=m +CONFIG_M686=y +# CONFIG_NOHIGHMEM is not set +CONFIG_HIGHMEM64G=y +CONFIG_HOTPLUG_PCI=y +CONFIG_HOTPLUG_PCI_COMPAQ=m +CONFIG_HOTPLUG_PCI_IBM=m +# CONFIG_HIGHMEM64G is not set +# CONFIG_EWRK3 is not set +CONFIG_NR_CPUS=32 +# CONFIG_X86_PC is not set +CONFIG_X86_GENERICARCH=y diff --git a/Documentation/COPYING.modules b/Documentation/COPYING.modules new file mode 100644 index 000000000..da0266e78 --- /dev/null +++ b/Documentation/COPYING.modules @@ -0,0 +1,708 @@ +Date: Thu, 29 Apr 2004 14:10:41 -0700 (PDT) +From: Linus Torvalds +To: Giuliano Colla +cc: Linux Kernel Mailing List +Subject: Re: [hsflinux] [PATCH] Blacklist binary-only modules lying about + their license +Message-ID: + +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 +To: Peter Chubb +cc: linux-kernel@vger.kernel.org +Subject: Re: Linux GPL and binary module exception clause? +Message-ID: + +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 +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 +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 +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 +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 +To: Christoph Hellwig +Cc: +Subject: Re: [PATCH] make LSM register functions GPLonly exports +In-Reply-To: <20021017175403.A32516@infradead.org> +Message-ID: + +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 +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 index 5eb5d3ab3..000000000 --- a/Documentation/arm/SA1100/PCMCIA +++ /dev/null @@ -1,374 +0,0 @@ -Kernel Low-Level PCMCIA Interface Documentation -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -John G Dorsey -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 index 3762de418..000000000 --- a/Documentation/arm/XScale/ADIFCC/80200EVB +++ /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 - 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 index 5312a5742..000000000 --- a/Documentation/arm/XScale/IOP3XX/IQ80310 +++ /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 - Initial discovery of RedBoot issues -Dave Jiang - IRQ demux fixes, AAU, DMA, MU -Nicolas Pitre - Initial port, cleanup, debugging -Matt Porter - PCI subsystem development, debugging -Tim Sanders - Initial PCI code -Mark Salter - RedBoot fixes -Deepak Saxena - Cleanup, debug, cache lock, PMU - ------------------------------ -Enjoy. - -If you have any problems please contact Deepak Saxena - -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 index e3253279d..000000000 --- a/Documentation/arm/XScale/IOP3XX/IQ80321 +++ /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 - Initial port, debugging. - -This port was based on the IQ80310 port with the following contributors: - -Nicolas Pitre - Initial port, cleanup, debugging -Matt Porter - PCI subsystem development, debugging -Tim Sanders - Initial PCI code -Deepak Saxena - Cleanup, debug, cache lock, PMU - -The port is currently maintained by Deepak Saxena - ------------------------------ -Enjoy. diff --git a/Documentation/arm/XScale/IOP3XX/aau.txt b/Documentation/arm/XScale/IOP3XX/aau.txt deleted file mode 100644 index e3852ccbf..000000000 --- a/Documentation/arm/XScale/IOP3XX/aau.txt +++ /dev/null @@ -1,178 +0,0 @@ -Support functions for the Intel 80310 AAU -=========================================== - -Dave Jiang -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 index 50c7f99e4..000000000 --- a/Documentation/arm/XScale/IOP3XX/dma.txt +++ /dev/null @@ -1,214 +0,0 @@ -Support functions forthe Intel 80310 DMA channels -================================================== - -Dave Jiang -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 - -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 index 480d13e7a..000000000 --- a/Documentation/arm/XScale/IOP3XX/message.txt +++ /dev/null @@ -1,110 +0,0 @@ -Support functions for the Intel 80310 MU -=========================================== - -Dave Jiang -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 index 7978494a9..000000000 --- a/Documentation/arm/XScale/IOP3XX/pmon.txt +++ /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 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 diff --git a/Documentation/arm/XScale/cache-lock.txt b/Documentation/arm/XScale/cache-lock.txt deleted file mode 100644 index 9728c94f1..000000000 --- a/Documentation/arm/XScale/cache-lock.txt +++ /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 - -API DESCRIPTION - - -I. Header File - - #include - -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 index 508575d65..000000000 --- a/Documentation/arm/XScale/pmu.txt +++ /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 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 - diff --git a/Documentation/arm/XScale/tlb-lock.txt b/Documentation/arm/XScale/tlb-lock.txt deleted file mode 100644 index 1ba3e11d0..000000000 --- a/Documentation/arm/XScale/tlb-lock.txt +++ /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 - - -API DESCRIPTION - -I. Header file - - #include - -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/fb/pxafb.txt b/Documentation/fb/pxafb.txt new file mode 100644 index 000000000..db9b8500b --- /dev/null +++ b/Documentation/fb/pxafb.txt @@ -0,0 +1,54 @@ +Driver for PXA25x LCD controller +================================ + +The driver supports the following options, either via +options= when modular or video=pxafb: when built in. + +For example: + modprobe pxafb options=mode:640x480-8,passive +or on the kernel command line + video=pxafb:mode:640x480-8,passive + +mode:XRESxYRES[-BPP] + XRES == LCCR1_PPL + 1 + YRES == LLCR2_LPP + 1 + The resolution of the display in pixels + BPP == The bit depth. Valid values are 1, 2, 4, 8 and 16. + +pixclock:PIXCLOCK + Pixel clock in picoseconds + +left:LEFT == LCCR1_BLW + 1 +right:RIGHT == LCCR1_ELW + 1 +hsynclen:HSYNC == LCCR1_HSW + 1 +upper:UPPER == LCCR2_BFW +lower:LOWER == LCCR2_EFR +vsynclen:VSYNC == LCCR2_VSW + 1 + Display margins and sync times + +color | mono => LCCR0_CMS + umm... + +active | passive => LCCR0_PAS + Active (TFT) or Passive (STN) display + +single | dual => LCCR0_SDS + Single or dual panel passive display + +4pix | 8pix => LCCR0_DPD + 4 or 8 pixel monochrome single panel data + +hsync:HSYNC +vsync:VSYNC + Horizontal and vertical sync. 0 => active low, 1 => active + high. + +dpc:DPC + Double pixel clock. 1=>true, 0=>false + +outputen:POLARITY + Output Enable Polarity. 0 => active low, 1 => active high + +pixclockpol:POLARITY + pixel clock polarity + 0 => falling edge, 1 => rising edge diff --git a/Documentation/numastat.txt b/Documentation/numastat.txt new file mode 100644 index 000000000..80133ace1 --- /dev/null +++ b/Documentation/numastat.txt @@ -0,0 +1,22 @@ + +Numa policy hit/miss statistics + +/sys/devices/system/node/node*/numastat + +All units are pages. Hugepages have separate counters. + +numa_hit A process wanted to allocate memory from this node, + and succeeded. +numa_miss A process wanted to allocate memory from this node, + but ended up with memory from another. +numa_foreign A process wanted to allocate on another node, + but ended up with memory from this one. +local_node A process ran on this node and got memory from it. +other_node A process ran on this node and got memory from another node. +interleave_hit Interleaving wanted to allocate from this node + and succeeded. + +For easier reading you can use the numastat utility from the numactl package +(ftp://ftp.suse.com/pub/people/ak/numa/numactl*). Note that it only works +well right now on machines with a small number of CPUs. + diff --git a/Documentation/sched-domains.txt b/Documentation/sched-domains.txt new file mode 100644 index 000000000..b5da811fc --- /dev/null +++ b/Documentation/sched-domains.txt @@ -0,0 +1,55 @@ +Each CPU has a "base" scheduling domain (struct sched_domain). These are +accessed via cpu_sched_domain(i) and this_sched_domain() macros. The domain +hierarchy is built from these base domains via the ->parent pointer. ->parent +MUST be NULL terminated, and domain structures should be per-CPU as they +are locklessly updated. + +Each scheduling domain spans a number of CPUs (stored in the ->span field). +A domain's span MUST be a superset of it child's span, and a base domain +for CPU i MUST span at least i. The top domain for each CPU will generally +span all CPUs in the system although strictly it doesn't have to, but this +could lead to a case where some CPUs will never be given tasks to run unless +the CPUs allowed mask is explicitly set. A sched domain's span means "balance +process load among these CPUs". + +Each scheduling domain must have one or more CPU groups (struct sched_group) +which are organised as a circular one way linked list from the ->groups +pointer. The union of cpumasks of these groups MUST be the same as the +domain's span. The intersection of cpumasks from any two of these groups +MUST be the empty set. The group pointed to by the ->groups pointer MUST +contain the CPU to which the domain belongs. Groups may be shared among +CPUs as they contain read only data after they have been set up. + +Balancing within a sched domain occurs between groups. That is, each group +is treated as one entity. The load of a group is defined as the sum of the +load of each of its member CPUs, and only when the load of a group becomes +out of balance are tasks moved between groups. + +In kernel/sched.c, rebalance_tick is run periodically on each CPU. This +function takes its CPU's base sched domain and checks to see if has reached +its rebalance interval. If so, then it will run load_balance on that domain. +rebalance_tick then checks the parent sched_domain (if it exists), and the +parent of the parent and so forth. + +*** Implementing sched domains *** +The "base" domain will "span" the first level of the hierarchy. In the case +of SMT, you'll span all siblings of the physical CPU, with each group being +a single virtual CPU. + +In SMP, the parent of the base domain will span all physical CPUs in the +node. Each group being a single physical CPU. Then with NUMA, the parent +of the SMP domain will span the entire machine, with each group having the +cpumask of a node. Or, you could do multi-level NUMA or Opteron, for example, +might have just one domain covering its one NUMA level. + +The implementor should read comments in include/linux/sched.h: +struct sched_domain fields, SD_FLAG_*, SD_*_INIT to get an idea of +the specifics and what to tune. + +Implementors should change the line +#undef SCHED_DOMAIN_DEBUG +to +#define SCHED_DOMAIN_DEBUG +in kernel/sched.c as this enables an error checking parse of the sched domains +which should catch most possible errors (described above). It also prints out +the domain structure in a visual format. diff --git a/Documentation/scsi/sym53c500_cs.txt b/Documentation/scsi/sym53c500_cs.txt new file mode 100644 index 000000000..75febcf92 --- /dev/null +++ b/Documentation/scsi/sym53c500_cs.txt @@ -0,0 +1,23 @@ +The sym53c500_cs driver originated as an add-on to David Hinds' pcmcia-cs +package, and was written by Tom Corner (tcorner@via.at). A rewrite was +long overdue, and the current version addresses the following concerns: + + (1) extensive kernel changes between 2.4 and 2.6. + (2) deprecated PCMCIA support outside the kernel. + +All the USE_BIOS code has been ripped out. It was never used, and could +not have worked anyway. The USE_DMA code is likewise gone. Many thanks +to YOKOTA Hiroshi (nsp_cs driver) and David Hinds (qlogic_cs driver) for +the code fragments I shamelessly adapted for this work. Thanks also to +Christoph Hellwig for his patient tutelage while I stumbled about. + +The Symbios Logic 53c500 chip was used in the "newer" (circa 1997) version +of the New Media Bus Toaster PCMCIA SCSI controller. Presumably there are +other products using this chip, but I've never laid eyes (much less hands) +on one. + +Through the years, there have been a number of downloads of the pcmcia-cs +version of this driver, and I guess it worked for those users. It worked +for Tom Corner, and it works for me. Your mileage will probably vary. + +--Bob Tracy (rct@frus.com) diff --git a/arch/arm/mach-ixp4xx/Kconfig b/arch/arm/mach-ixp4xx/Kconfig new file mode 100644 index 000000000..3377f887b --- /dev/null +++ b/arch/arm/mach-ixp4xx/Kconfig @@ -0,0 +1,89 @@ + +config ARCH_SUPPORTS_BIG_ENDIAN + bool + depends on ARCH_IXP4XX + default y + +menu "Intel IXP4xx Implementation Options" + +comment "IXP4xx Platforms" + +config ARCH_AVILA + bool "Avila" + depends on ARCH_IXP4XX + help + Say 'Y' here if you want your kernel to support the Gateworks + Avila Network Platform. For more information on this platform, + see Documentation/arm/IXP4xx. + +config ARCH_ADI_COYOTE + bool "Coyote" + depends on ARCH_IXP4XX + help + Say 'Y' here if you want your kernel to support the ADI + Engineering Coyote Gateway Reference Platform. For more + information on this platform, see Documentation/arm/IXP4xx. + +config ARCH_IXDP425 + bool "IXDP425" + depends on ARCH_IXP4XX + help + Say 'Y' here if you want your kernel to support Intel's + IXDP425 Development Platform (Also known as Richfield). + For more information on this platform, see Documentation/arm/IXP4xx. + +# +# IXCDP1100 is the exact same HW as IXDP425, but with a different machine +# number from the bootloader due to marketing monkeys, so we just enable it +# by default if IXDP425 is enabled. +# +config ARCH_IXCDP1100 + bool + depends on ARCH_IXDP425 + default y + +config ARCH_PRPMC1100 + bool "PrPMC1100" + depends on ARCH_IXP4XX + help + Say 'Y' here if you want your kernel to support the Motorola + PrPCM1100 Processor Mezanine Module. For more information on + this platform, see Documentation/arm/IXP4xx. + +# +# Avila and IXDP share the same source for now. Will change in future +# +config ARCH_IXDP4XX + bool + depends on ARCH_IXDP425 || ARCH_AVILA + default y + +comment "IXP4xx Options" + +config IXP4XX_INDIRECT_PCI + bool "Use indirect PCI memory access" + depends on ARCH_IXP4XX + help + IXP4xx provides two methods of accessing PCI memory space: + + 1) A direct mapped window from 0x48000000 to 0x4bffffff (64MB). + To access PCI via this space, we simply ioremap() the BAR + into the kernel and we can use the standard read[bwl]/write[bwl] + macros. This is the preffered method due to speed but it + limits the system to just 64MB of PCI memory. This can be + problamatic if using video cards and other memory-heavy devices. + + 2) If > 64MB of memory space is required, the IXP4xx can be + configured to use indirect registers to access PCI This allows + for up to 128MB (0x48000000 to 0x4fffffff) of memory on the bus. + The disadvantadge of this is that every PCI access requires + three local register accesses plus a spinlock, but in some + cases the performance hit is acceptable. In addition, you cannot + mmap() PCI devices in this case due to the indirect nature + of the PCI window. + + By default, the direct method is used. Choose this option if you + need to use the indirect method instead. If you don't know + what you need, leave this option unselected. + +endmenu diff --git a/arch/arm/mach-ixp4xx/coyote-setup.c b/arch/arm/mach-ixp4xx/coyote-setup.c new file mode 100644 index 000000000..bc6e0d042 --- /dev/null +++ b/arch/arm/mach-ixp4xx/coyote-setup.c @@ -0,0 +1,90 @@ +/* + * arch/arm/mach-ixp4xx/coyote-setup.c + * + * ADI Engineering Coyote board-setup + * + * Copyright (C) 2003-2004 MontaVista Software, Inc. + * + * Author: Deepak Saxena + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#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_device = { + .name = "IXP4XX-Flash", + .id = 0, + .dev = { + .platform_data = &coyote_flash_data, + }, + .num_resources = 1, + .resource = &coyote_flash_resource, +}; + +static void __init coyote_init(void) +{ + platform_add_device(&coyote_flash_device); +} + +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) + 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 new file mode 100644 index 000000000..160117c67 --- /dev/null +++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c @@ -0,0 +1,147 @@ +/* + * arch/arm/mach-ixp4xx/ixdp425-setup.c + * + * IXDP425/IXCDP1100 board-setup + * + * Copyright (C) 2003-2004 MontaVista Software, Inc. + * + * Author: Deepak Saxena + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#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_device = { + .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 void __init ixdp425_init(void) +{ + platform_add_device(&ixdp425_flash_device); + platform_add_device(&ixdp425_i2c_controller); +} + +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) + 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) + 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 ") + BOOT_MEM(PHYS_OFFSET, IXP4XX_PERIPHERAL_BASE_PHYS, + IXP4XX_PERIPHERAL_BASE_VIRT) + MAPIO(ixdp425_map_io) + INITIRQ(ixp4xx_init_irq) + BOOT_PARAMS(0x0100) + INIT_MACHINE(ixdp425_init) +MACHINE_END +#endif + diff --git a/arch/arm/mach-omap/innovator1510.c b/arch/arm/mach-omap/innovator1510.c deleted file mode 100644 index 1309f9664..000000000 --- a/arch/arm/mach-omap/innovator1510.c +++ /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 - * - * 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 - * - * 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 -#include -#include - -#include -#include -#include - -#include -#include -#include - -#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 index 4081735b0..000000000 --- a/arch/arm/mach-omap/innovator1610.c +++ /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 - * - * 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 -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#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 index 8e1aa7810..000000000 --- a/arch/arm/mach-omap/irq.h +++ /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 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU 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 index 982830dcd..000000000 --- a/arch/arm/mach-omap/omap-generic.c +++ /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 -#include -#include - -#include -#include -#include - -#include -#include -#include - -#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 ") - 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 index ec05093c9..000000000 --- a/arch/arm/mach-omap/omap-perseus2.c +++ /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 -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#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 ") - 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-pxa/leds-mainstone.c b/arch/arm/mach-pxa/leds-mainstone.c new file mode 100644 index 000000000..cb6f6ddb0 --- /dev/null +++ b/arch/arm/mach-pxa/leds-mainstone.c @@ -0,0 +1,118 @@ +/* + * linux/arch/arm/mach-pxa/leds-mainstone.c + * + * Author: Nicolas Pitre + * Created: Nov 05, 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. + */ + +#include +#include + +#include +#include +#include + +#include "leds.h" + + +/* 8 discrete leds available for general use: */ +#define D28 (1 << 0) +#define D27 (1 << 1) +#define D26 (1 << 2) +#define D25 (1 << 3) +#define D24 (1 << 4) +#define D23 (1 << 5) +#define D22 (1 << 6) +#define D21 (1 << 7) + +#define LED_STATE_ENABLED 1 +#define LED_STATE_CLAIMED 2 + +static unsigned int led_state; +static unsigned int hw_led_state; + +void mainstone_leds_event(led_event_t evt) +{ + unsigned long flags; + + local_irq_save(flags); + + switch (evt) { + case led_start: + hw_led_state = 0; + led_state = LED_STATE_ENABLED; + break; + + case led_stop: + led_state &= ~LED_STATE_ENABLED; + break; + + case led_claim: + led_state |= LED_STATE_CLAIMED; + hw_led_state = 0; + break; + + case led_release: + led_state &= ~LED_STATE_CLAIMED; + hw_led_state = 0; + break; + +#ifdef CONFIG_LEDS_TIMER + case led_timer: + hw_led_state ^= D26; + break; +#endif + +#ifdef CONFIG_LEDS_CPU + case led_idle_start: + hw_led_state &= ~D27; + break; + + case led_idle_end: + hw_led_state |= D27; + break; +#endif + + case led_halted: + break; + + case led_green_on: + hw_led_state |= D21;; + break; + + case led_green_off: + hw_led_state &= ~D21; + break; + + case led_amber_on: + hw_led_state |= D22;; + break; + + case led_amber_off: + hw_led_state &= ~D22; + break; + + case led_red_on: + hw_led_state |= D23;; + break; + + case led_red_off: + hw_led_state &= ~D23; + break; + + default: + break; + } + + if (led_state & LED_STATE_ENABLED) + MST_LEDCTRL = (MST_LEDCTRL | 0xff) & ~hw_led_state; + else + MST_LEDCTRL |= 0xff; + + local_irq_restore(flags); +} diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c new file mode 100644 index 000000000..cd7da1ddf --- /dev/null +++ b/arch/arm/mach-pxa/mainstone.c @@ -0,0 +1,139 @@ +/* + * linux/arch/arm/mach-pxa/mainstone.c + * + * Support for the Intel HCDDBBVA0 Development Platform. + * (go figure how they came up with such name...) + * + * Author: Nicolas Pitre + * Created: Nov 05, 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. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "generic.h" + + +static unsigned long mainstone_irq_enabled; + +static void mainstone_mask_irq(unsigned int irq) +{ + int mainstone_irq = (irq - MAINSTONE_IRQ(0)); + MST_INTMSKENA = (mainstone_irq_enabled &= ~(1 << mainstone_irq)); +} + +static void mainstone_unmask_irq(unsigned int irq) +{ + int mainstone_irq = (irq - MAINSTONE_IRQ(0)); + /* the irq can be acknowledged only if deasserted, so it's done here */ + MST_INTSETCLR &= ~(1 << mainstone_irq); + MST_INTMSKENA = (mainstone_irq_enabled |= (1 << mainstone_irq)); +} + +static struct irqchip mainstone_irq_chip = { + .ack = mainstone_mask_irq, + .mask = mainstone_mask_irq, + .unmask = mainstone_unmask_irq, +}; + + +static void mainstone_irq_handler(unsigned int irq, struct irqdesc *desc, + struct pt_regs *regs) +{ + unsigned long pending = MST_INTSETCLR & mainstone_irq_enabled; + do { + GEDR(0) = GPIO_bit(0); /* clear useless edge notification */ + if (likely(pending)) { + irq = MAINSTONE_IRQ(0) + __ffs(pending); + desc = irq_desc + irq; + desc->handle(irq, desc, regs); + } + pending = MST_INTSETCLR & mainstone_irq_enabled; + } while (pending); +} + +static void __init mainstone_init_irq(void) +{ + int irq; + + pxa_init_irq(); + + /* setup extra Mainstone irqs */ + for(irq = MAINSTONE_IRQ(0); irq <= MAINSTONE_IRQ(15); irq++) { + set_irq_chip(irq, &mainstone_irq_chip); + set_irq_handler(irq, do_level_IRQ); + set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); + } + set_irq_flags(MAINSTONE_IRQ(8), 0); + set_irq_flags(MAINSTONE_IRQ(12), 0); + + MST_INTMSKENA = 0; + MST_INTSETCLR = 0; + + set_irq_chained_handler(IRQ_GPIO(0), mainstone_irq_handler); + set_irq_type(IRQ_GPIO(0), IRQT_FALLING); +} + + +static struct resource smc91x_resources[] = { + [0] = { + .start = (MST_ETH_PHYS + 0x300), + .end = (MST_ETH_PHYS + 0xfffff), + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = MAINSTONE_IRQ(3), + .end = MAINSTONE_IRQ(3), + .flags = IORESOURCE_IRQ, + } +}; + +static struct platform_device smc91x_device = { + .name = "smc91x", + .id = 0, + .num_resources = ARRAY_SIZE(smc91x_resources), + .resource = smc91x_resources, +}; + +static void __init mainstone_init(void) +{ + platform_add_device(&smc91x_device); +} + + +static struct map_desc mainstone_io_desc[] __initdata = { + { MST_FPGA_VIRT, MST_FPGA_PHYS, 0x00100000, MT_DEVICE }, /* CPLD */ +}; + +static void __init mainstone_map_io(void) +{ + pxa_map_io(); + iotable_init(mainstone_io_desc, ARRAY_SIZE(mainstone_io_desc)); +} + +MACHINE_START(MAINSTONE, "Intel HCDDBBVA0 Development Platform (aka Mainstone)") + MAINTAINER("MontaVista Software Inc.") + BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000)) + MAPIO(mainstone_map_io) + INITIRQ(mainstone_init_irq) + INIT_MACHINE(mainstone_init) +MACHINE_END diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c new file mode 100644 index 000000000..f57c96222 --- /dev/null +++ b/arch/arm/mach-pxa/pxa25x.c @@ -0,0 +1,94 @@ +/* + * linux/arch/arm/mach-pxa/pxa25x.c + * + * Author: Nicolas Pitre + * Created: Jun 15, 2001 + * Copyright: MontaVista Software Inc. + * + * Code specific to PXA21x/25x/26x variants. + * + * 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. + * + * Since this file should be linked before any other machine specific file, + * the __initcall() here will be executed first. This serves as default + * initialization stuff for PXA machines which can be overridden later if + * need be. + */ +#include +#include +#include +#include + +#include + +#include "generic.h" + +/* + * Various clock factors driven by the CCCR register. + */ + +/* Crystal Frequency to Memory Frequency Multiplier (L) */ +static unsigned char L_clk_mult[32] = { 0, 27, 32, 36, 40, 45, 0, }; + +/* Memory Frequency to Run Mode Frequency Multiplier (M) */ +static unsigned char M_clk_mult[4] = { 0, 1, 2, 4 }; + +/* Run Mode Frequency to Turbo Mode Frequency Multiplier (N) */ +/* Note: we store the value N * 2 here. */ +static unsigned char N2_clk_mult[8] = { 0, 0, 2, 3, 4, 0, 6, 0 }; + +/* Crystal clock */ +#define BASE_CLK 3686400 + +/* + * Get the clock frequency as reflected by CCCR and the turbo flag. + * We assume these values have been applied via a fcs. + * If info is not 0 we also display the current settings. + */ +unsigned int get_clk_frequency_khz(int info) +{ + unsigned long cccr, turbo; + unsigned int l, L, m, M, n2, N; + + cccr = CCCR; + asm( "mrc\tp14, 0, %0, c6, c0, 0" : "=r" (turbo) ); + + l = L_clk_mult[(cccr >> 0) & 0x1f]; + m = M_clk_mult[(cccr >> 5) & 0x03]; + n2 = N2_clk_mult[(cccr >> 7) & 0x07]; + + L = l * BASE_CLK; + M = m * L; + N = n2 * M / 2; + + if(info) + { + L += 5000; + printk( KERN_INFO "Memory clock: %d.%02dMHz (*%d)\n", + L / 1000000, (L % 1000000) / 10000, l ); + M += 5000; + printk( KERN_INFO "Run Mode clock: %d.%02dMHz (*%d)\n", + M / 1000000, (M % 1000000) / 10000, m ); + N += 5000; + printk( KERN_INFO "Turbo Mode clock: %d.%02dMHz (*%d.%d, %sactive)\n", + N / 1000000, (N % 1000000) / 10000, n2 / 2, (n2 % 2) * 5, + (turbo & 1) ? "" : "in" ); + } + + return (turbo & 1) ? (N/1000) : (M/1000); +} + +EXPORT_SYMBOL(get_clk_frequency_khz); + +/* + * Return the current lclk requency in units of 10kHz + */ +unsigned int get_lclk_frequency_10khz(void) +{ + return L_clk_mult[(CCCR >> 0) & 0x1f] * BASE_CLK / 10000; +} + +EXPORT_SYMBOL(get_lclk_frequency_10khz); + diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c new file mode 100644 index 000000000..1addceb0f --- /dev/null +++ b/arch/arm/mach-pxa/pxa27x.c @@ -0,0 +1,120 @@ +/* + * linux/arch/arm/mach-pxa/pxa27x.c + * + * Author: Nicolas Pitre + * Created: Nov 05, 2002 + * Copyright: MontaVista Software Inc. + * + * Code specific to PXA27x aka Bulverde. + * + * 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 +#include +#include +#include +#include + +#include + +#include "generic.h" + +/* Crystal clock : 13-MHZ*/ +#define BASE_CLK 13000000 + +/* + * Get the clock frequency as reflected by CCSR and the turbo flag. + * We assume these values have been applied via a fcs. + * If info is not 0 we also display the current settings. + * + * For more details, refer to Bulverde Manual, section 3.8.2.1 + */ +unsigned int get_clk_frequency_khz( int info) +{ + unsigned long ccsr, turbo, b, ht; + unsigned int l, L, m, M, n2, N, S, cccra; + + ccsr = CCSR; + cccra = CCCR & (0x1 << 25); + + /* Read clkcfg register: it has turbo, b, half-turbo (and f) */ + asm( "mrc\tp14, 0, %0, c6, c0, 0" : "=r" (turbo) ); + b = (turbo & (0x1 << 3)); + ht = (turbo & (0x1 << 2)); + + l = ccsr & 0x1f; + n2 = (ccsr>>7) & 0xf; + if (l == 31) { + /* The calculation from the Yellow Book is incorrect: + it says M=4 for L=21-30 (which is easy to calculate + by subtracting 1 and then dividing by 10, but not + with 31, so we'll do it manually */ + m = 1 << 2; + } else { + m = 1 << ((l-1)/10); + } + + L = l * BASE_CLK; + N = (n2 * L) / 2; + S = (b) ? L : (L/2); + if (cccra == 0) + M = L/m; + else + M = (b) ? L : (L/2); + + if (info) { + printk( KERN_INFO "Run Mode clock: %d.%02dMHz (*%d)\n", + L / 1000000, (L % 1000000) / 10000, l ); + printk( KERN_INFO "Memory clock: %d.%02dMHz (/%d)\n", + M / 1000000, (M % 1000000) / 10000, m ); + printk( KERN_INFO "Turbo Mode clock: %d.%02dMHz (*%d.%d, %sactive)\n", + N / 1000000, (N % 1000000)/10000, n2 / 2, (n2 % 2)*5, + (turbo & 1) ? "" : "in" ); + printk( KERN_INFO "System bus clock: %d.%02dMHz \n", + S / 1000000, (S % 1000000) / 10000 ); + } + + return (turbo & 1) ? (N/1000) : (L/1000); +} + +/* + * Return the current mem clock frequency in units of 10kHz as + * reflected by CCCR[A], B, and L + */ +unsigned int get_lclk_frequency_10khz(void) +{ + unsigned long ccsr, clkcfg, b; + unsigned int l, L, m, M, cccra; + + cccra = CCCR & (0x1 << 25); + + /* Read clkcfg register to obtain b */ + asm( "mrc\tp14, 0, %0, c6, c0, 0" : "=r" (clkcfg) ); + b = (clkcfg & (0x1 << 3)); + + ccsr = CCSR; + l = ccsr & 0x1f; + if (l == 31) { + /* The calculation from the Yellow Book is incorrect: + it says M=4 for L=21-30 (which is easy to calculate + by subtracting 1 and then dividing by 10, but not + with 31, so we'll do it manually */ + m = 1 << 2; + } else { + m = 1 << ((l-1)/10); + } + + L = l * BASE_CLK; + if (cccra == 0) + M = L/m; + else + M = (b) ? L : L/2; + + return (M / 10000); +} + +EXPORT_SYMBOL(get_clk_frequency_khz); +EXPORT_SYMBOL(get_lclk_frequency_10khz); + diff --git a/arch/h8300/Kconfig.cpu b/arch/h8300/Kconfig.cpu new file mode 100644 index 000000000..d9dd62a56 --- /dev/null +++ b/arch/h8300/Kconfig.cpu @@ -0,0 +1,183 @@ +menu "Processor type and features" + +choice + prompt "H8/300 platform" + default H8300H_GENERIC + +config H8300H_GENERIC + bool "H8/300H Generic" + help + H8/300H CPU Generic Hardware Support + +config H8300H_AKI3068NET + bool "AE-3068/69" + help + AKI-H8/3068F / AKI-H8/3069F Flashmicom LAN Board Support + More Information. (Japanese Only) + + AE-3068/69 Evaluation Board Support + More Information. + + +config H8300H_H8MAX + bool "H8MAX" + help + H8MAX Evaluation Board Support + More Information. (Japanese Only) + + +config H8300H_SIM + bool "H8/300H Simulator" + help + GDB Simulator Support + More Information. + arch/h8300/Doc/simulator.txt + +config H8S_GENERIC + bool "H8S Generic" + help + H8S CPU Generic Hardware Support + +config H8S_EDOSK2674 + bool "EDOSK-2674" + help + Renesas EDOSK-2674 Evaluation Board Support + More Information. + + + +config H8S_SIM + bool "H8S Simulator" + help + GDB Simulator Support + More Information. + arch/h8300/Doc/simulator.txt + +endchoice + +if (H8300H_GENERIC || H8S_GENERIC) +menu "Detail Selection" +if (H8300H_GENERIC) +choice + prompt "CPU Selection" + +config H83002 + bool "H8/3001,3002,3003" + +config H83007 + bool "H8/3006,3007" + +config H83048 + bool "H8/3044,3045,3046,3047,3048,3052" + +config H83068 + bool "H8/3065,3066,3067,3068,3069" +endchoice +endif + +if (H8S_GENERIC) +choice + prompt "CPU Selection" + +config H8S2678 + bool "H8S/2670,2673,2674R,2675,2676" +endchoice +endif + +config CPU_CLOCK + int "CPU Clock Frequency (/1KHz)" + default "20000" + help + CPU Clock Frequency divide to 1000 +endmenu +endif + +if (H8300H_GENERIC || H8S_GENERIC || H8300H_SIM || H8S_SIM || H8S_EDOSK2674) +choice + prompt "Kernel executes from" + ---help--- + Choose the memory type that the kernel will be running in. + +config RAMKERNEL + bool "RAM" + help + The kernel will be resident in RAM when running. + +config ROMKERNEL + bool "ROM" + help + The kernel will be resident in FLASH/ROM when running. + +endchoice +endif + +if (H8300H_AKI3068NET) +config H83068 + bool + default y + +config CPU_CLOCK + int + default "20000" + +config RAMKERNEL + bool + default y +endif + +if (H8300H_H8MAX) +config H83068 + bool + default y + +config CPU_CLOCK + int + default 25000 + +config RAMKERNEL + bool + default y +endif + +if (H8300H_SIM) +config H83007 + bool + default y + +config CPU_CLOCK + int + default "16000" +endif + +if (H8S_EDOSK2674) +config H8S2678 + bool + default y +config CPU_CLOCK + int + default 33000 +endif + +if (H8S_SIM) +config H8S2678 + bool + default y +config CPU_CLOCK + int + default 33000 +endif + +config CPU_H8300H + bool + depends on (H8002 || H83007 || H83048 || H83068) + default y + +config CPU_H8S + bool + depends on H8S2678 + default y + +config PREEMPT + bool "Preemptible Kernel" + default n +endmenu diff --git a/arch/h8300/kernel/module.c b/arch/h8300/kernel/module.c new file mode 100644 index 000000000..4fd7138a6 --- /dev/null +++ b/arch/h8300/kernel/module.c @@ -0,0 +1,122 @@ +#include +#include +#include +#include +#include +#include + +#if 0 +#define DEBUGP printk +#else +#define DEBUGP(fmt...) +#endif + +void *module_alloc(unsigned long size) +{ + if (size == 0) + return NULL; + return vmalloc(size); +} + + +/* Free memory returned from module_alloc */ +void module_free(struct module *mod, void *module_region) +{ + vfree(module_region); + /* FIXME: If module_region == mod->init_region, trim exception + table entries. */ +} + +/* We don't need anything special. */ +int module_frob_arch_sections(Elf_Ehdr *hdr, + Elf_Shdr *sechdrs, + char *secstrings, + struct module *mod) +{ + return 0; +} + +int apply_relocate(Elf32_Shdr *sechdrs, + const char *strtab, + unsigned int symindex, + unsigned int relsec, + struct module *me) +{ + printk(KERN_ERR "module %s: RELOCATION unsupported\n", + me->name); + return -ENOEXEC; +} + +int apply_relocate_add(Elf32_Shdr *sechdrs, + const char *strtab, + unsigned int symindex, + unsigned int relsec, + struct module *me) +{ + unsigned int i; + Elf32_Rela *rela = (void *)sechdrs[relsec].sh_addr; + + DEBUGP("Applying relocate section %u to %u\n", relsec, + sechdrs[relsec].sh_info); + for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rela); i++) { + /* This is where to make the change */ + uint32_t *loc = (uint32_t *)(sechdrs[sechdrs[relsec].sh_info].sh_addr + + rela[i].r_offset); + /* This is the symbol it is referring to. Note that all + undefined symbols have been resolved. */ + Elf32_Sym *sym = (Elf32_Sym *)sechdrs[symindex].sh_addr + + ELF32_R_SYM(rela[i].r_info); + uint32_t v = sym->st_value + rela[i].r_addend; + + switch (ELF32_R_TYPE(rela[i].r_info)) { + case R_H8_DIR24R8: + loc = (uint32_t *)((uint32_t)loc - 1); + *loc = (*loc & 0xff000000) | ((*loc & 0xffffff) + v); + break; + case R_H8_DIR24A8: + if (ELF32_R_SYM(rela[i].r_info)) + *loc += v; + break; + case R_H8_DIR32: + case R_H8_DIR32A16: + *loc += v; + break; + case R_H8_PCREL16: + v -= (unsigned long)loc + 2; + if ((Elf32_Sword)v > 0x7fff || + (Elf32_Sword)v < -(Elf32_Sword)0x8000) + goto overflow; + else + *(unsigned short *)loc = v; + break; + case R_H8_PCREL8: + v -= (unsigned long)loc + 1; + if ((Elf32_Sword)v > 0x7f || + (Elf32_Sword)v < -(Elf32_Sword)0x80) + goto overflow; + else + *(unsigned char *)loc = v; + break; + default: + printk(KERN_ERR "module %s: Unknown relocation: %u\n", + me->name, ELF32_R_TYPE(rela[i].r_info)); + return -ENOEXEC; + } + } + return 0; + overflow: + printk(KERN_ERR "module %s: relocation offset overflow: %08x\n", + me->name, rela[i].r_offset); + return -ENOEXEC; +} + +int module_finalize(const Elf_Ehdr *hdr, + const Elf_Shdr *sechdrs, + struct module *me) +{ + return 0; +} + +void module_arch_cleanup(struct module *mod) +{ +} diff --git a/arch/i386/mach-es7000/es7000.c b/arch/i386/mach-es7000/es7000plat.c similarity index 89% rename from arch/i386/mach-es7000/es7000.c rename to arch/i386/mach-es7000/es7000plat.c index defe41e6c..70db26443 100644 --- a/arch/i386/mach-es7000/es7000.c +++ b/arch/i386/mach-es7000/es7000plat.c @@ -1,7 +1,7 @@ /* * Written by: Garry Forsgren, Unisys Corporation * Natalie Protasevich, Unisys Corporation - * This file contains the code to configure and interface + * This file contains the code to configure and interface * with Unisys ES7000 series hardware system manager. * * Copyright (c) 2003 Unisys Corporation. All Rights Reserved. @@ -18,7 +18,7 @@ * 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 + * Contact information: Unisys Corporation, Township Line & Union Meeting * Roads-A, Unisys Way, Blue Bell, Pennsylvania, 19424, or: * * http://www.unisys.com @@ -46,23 +46,46 @@ */ volatile unsigned long *psai = NULL; -struct mip_reg *mip_reg; +struct mip_reg *mip_reg; struct mip_reg *host_reg; int mip_port; unsigned long mip_addr, host_addr; +extern int (*platform_rename_gsi)(); + +static int __init +es7000_rename_gsi(int ioapic, int gsi) +{ + if (ioapic) + return gsi; + else { + if (gsi == 0) + return 13; + if (gsi == 1) + return 16; + if (gsi == 4) + return 17; + if (gsi == 6) + return 18; + if (gsi == 7) + return 19; + if (gsi == 8) + return 20; + return gsi; + } +} /* * Parse the OEM Table */ -void __init +int __init parse_unisys_oem (char *oemptr, int oem_entries) { int i; int success = 0; unsigned char type, size; unsigned long val; - char *tp = NULL; + char *tp = NULL; struct psai *psaip = NULL; struct mip_reg_info *mi; struct mip_reg *host, *mip; @@ -83,12 +106,13 @@ parse_unisys_oem (char *oemptr, int oem_entries) host = (struct mip_reg *)val; host_reg = __va(host); val = MIP_RD_LO(mi->mip_reg); + mip_port = MIP_PORT(mi->mip_info); mip_addr = val; mip = (struct mip_reg *)val; mip_reg = __va(mip); - Dprintk("es7000_mipcfg: host_reg = 0x%lx \n", + Dprintk("es7000_mipcfg: host_reg = 0x%lx \n", (unsigned long)host_reg); - Dprintk("es7000_mipcfg: mip_reg = 0x%lx \n", + Dprintk("es7000_mipcfg: mip_reg = 0x%lx \n", (unsigned long)mip_reg); success++; break; @@ -115,12 +139,13 @@ parse_unisys_oem (char *oemptr, int oem_entries) } else { printk("\nEnabling ES7000 specific features...\n"); es7000_plat = 1; + platform_rename_gsi = es7000_rename_gsi; } - return; + return es7000_plat; } -int __init -find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length) +int __init +find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length) { struct acpi_table_rsdp *rsdp = NULL; unsigned long rsdp_phys = 0; @@ -179,7 +204,7 @@ es7000_spin(int n) { int i = 0; - while (i++ < n) + while (i++ < n) rep_nop(); } @@ -220,7 +245,7 @@ es7000_mip_write(struct mip_reg *mip_reg) return status; } -int +int es7000_start_cpu(int cpu, unsigned long eip) { unsigned long vect = 0, psaival = 0; @@ -240,7 +265,7 @@ es7000_start_cpu(int cpu, unsigned long eip) } -int +int es7000_stop_cpu(int cpu) { int startup; @@ -272,7 +297,7 @@ es7000_sw_apic() 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", + 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 index 4caed0e43..000000000 --- a/arch/i386/mach-es7000/setup.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Machine specific setup for es7000 - */ - -#include -#include -#include -#include -#include -#include -#include - -/** - * 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 index e96d8910a..000000000 --- a/arch/i386/mach-es7000/topology.c +++ /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 - */ -#include -#include -#include - -struct i386_cpu cpu_devices[NR_CPUS]; - -#ifdef CONFIG_NUMA -#include -#include - -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); diff --git a/arch/ia64/kernel/perfmon_hpsim.h b/arch/ia64/kernel/perfmon_hpsim.h deleted file mode 100644 index 9c6fe7fc1..000000000 --- a/arch/ia64/kernel/perfmon_hpsim.h +++ /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 - * - * File mostly contributed by Ian Wienand - * - * 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 -}; diff --git a/arch/ia64/scripts/check-serialize.S b/arch/ia64/scripts/check-serialize.S new file mode 100644 index 000000000..0400c1068 --- /dev/null +++ b/arch/ia64/scripts/check-serialize.S @@ -0,0 +1,2 @@ + .serialize.data + .serialize.instruction diff --git a/arch/ppc/configs/bubinga_defconfig b/arch/ppc/configs/bubinga_defconfig new file mode 100644 index 000000000..ea60105b2 --- /dev/null +++ b/arch/ppc/configs/bubinga_defconfig @@ -0,0 +1,593 @@ +# +# 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_FASTROUTE is not set +# CONFIG_NET_HW_FLOWCONTROL is not set + +# +# QoS and/or fair queueing +# +# CONFIG_NET_SCHED is not set + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +CONFIG_NETDEVICES=y + +# +# ARCnet devices +# +# CONFIG_ARCNET is not set +# CONFIG_DUMMY is not set +# CONFIG_BONDING is not set +# CONFIG_EQUALIZER is not set +# CONFIG_TUN is not set + +# +# Ethernet (10 or 100Mbit) +# +CONFIG_NET_ETHERNET=y +CONFIG_MII=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/mm/cachemap.c b/arch/ppc/mm/cachemap.c deleted file mode 100644 index 2033eec9b..000000000 --- a/arch/ppc/mm/cachemap.c +++ /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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -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); diff --git a/arch/ppc/ocp/Makefile b/arch/ppc/ocp/Makefile deleted file mode 100644 index f669ee042..000000000 --- a/arch/ppc/ocp/Makefile +++ /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 index 9f6bb3f42..000000000 --- a/arch/ppc/ocp/ocp-driver.c +++ /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 - * - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU 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 -#include -#include - -/* - * 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 index bb4aff7a6..000000000 --- a/arch/ppc/ocp/ocp-probe.c +++ /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 - * - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU 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 -#include -#include -#include -#include - -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 index 8df60d79f..000000000 --- a/arch/ppc/ocp/ocp.c +++ /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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/** - * 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/syslib/ibm_ocp.c b/arch/ppc/syslib/ibm_ocp.c new file mode 100644 index 000000000..3f6e55c79 --- /dev/null +++ b/arch/ppc/syslib/ibm_ocp.c @@ -0,0 +1,9 @@ +#include +#include + +struct ocp_sys_info_data ocp_sys_info = { + .opb_bus_freq = 50000000, /* OPB Bus Frequency (Hz) */ + .ebc_bus_freq = 33333333, /* EBC Bus Frequency (Hz) */ +}; + +EXPORT_SYMBOL(ocp_sys_info); diff --git a/arch/x86_64/kernel/Makefile-HEAD b/arch/x86_64/kernel/Makefile-HEAD new file mode 100644 index 000000000..dc6f2695e --- /dev/null +++ b/arch/x86_64/kernel/Makefile-HEAD @@ -0,0 +1,38 @@ +# +# Makefile for the linux kernel. +# + +extra-y := head.o head64.o init_task.o vmlinux.lds.s +EXTRA_AFLAGS := -traditional +obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \ + ptrace.o i8259.o ioport.o ldt.o setup.o time.o sys_x86_64.o \ + x8664_ksyms.o i387.o syscall.o vsyscall.o \ + setup64.o bootflag.o e820.o reboot.o warmreboot.o +obj-y += mce.o + +obj-$(CONFIG_MTRR) += ../../i386/kernel/cpu/mtrr/ +obj-$(CONFIG_ACPI_BOOT) += acpi/ +obj-$(CONFIG_X86_MSR) += msr.o +obj-$(CONFIG_MICROCODE) += microcode.o +obj-$(CONFIG_X86_CPUID) += cpuid.o +obj-$(CONFIG_SMP) += smp.o smpboot.o trampoline.o +obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o +obj-$(CONFIG_X86_IO_APIC) += io_apic.o mpparse.o +obj-$(CONFIG_PM) += suspend.o +obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend_asm.o +obj-$(CONFIG_CPU_FREQ) += cpufreq/ +obj-$(CONFIG_EARLY_PRINTK) += early_printk.o +obj-$(CONFIG_GART_IOMMU) += pci-gart.o aperture.o +obj-$(CONFIG_DUMMY_IOMMU) += pci-nommu.o pci-dma.o +obj-$(CONFIG_SWIOTLB) += swiotlb.o +obj-$(CONFIG_SCHED_SMT) += domain.o + +obj-$(CONFIG_MODULES) += module.o + +obj-y += topology.o + +bootflag-y += ../../i386/kernel/bootflag.o +cpuid-$(subst m,y,$(CONFIG_X86_CPUID)) += ../../i386/kernel/cpuid.o +topology-y += ../../i386/mach-default/topology.o +swiotlb-$(CONFIG_SWIOTLB) += ../../ia64/lib/swiotlb.o +microcode-$(subst m,y,$(CONFIG_MICROCODE)) += ../../i386/kernel/microcode.o diff --git a/drivers/char/crash.c b/drivers/char/crash.c new file mode 100644 index 000000000..43cc96f38 --- /dev/null +++ b/drivers/char/crash.c @@ -0,0 +1,129 @@ +/* + * linux/drivers/char/crash.c + * + * Copyright (C) 2004 Dave Anderson + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#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/dz.c b/drivers/char/dz.c deleted file mode 100644 index 23630030e..000000000 --- a/drivers/char/dz.c +++ /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 - cleanups - * - * Parts (C) 1999 David Airlie, airlied@linux.ie - * [07-SEP-99] Bugfixes - */ - -/* #define DEBUG_DZ 1 */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* 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 -#endif /* if defined(CONFIG_SERIAL_CONSOLE) || defined(DEBUG_DZ) */ - -#include -#include - -#include -#include -#include -#include -#include - -#ifdef DEBUG_DZ -#include -#include -#include - -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 index 989f927a4..000000000 --- a/drivers/char/dz.h +++ /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/sh-sci.c b/drivers/char/sh-sci.c deleted file mode 100644 index d3894a6f9..000000000 --- a/drivers/char/sh-sci.c +++ /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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_SH_KGDB_CONSOLE) -#include -#endif -#ifdef CONFIG_CPU_FREQ -#include -#include -#endif - -#include -#include -#include -#include -#include - -#include - -#ifdef CONFIG_SH_STANDARD_BIOS -#include -#endif - -#include "sh-sci.h" - -#ifdef CONFIG_SH_KGDB -#include - -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 -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) { - /* $#. */ - do { - unsigned char c; - put_char(port, '$'); - put_char(port, 'O'); /* 'O'utput to console */ - checksum = 'O'; - - for (i=0; ibase - 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; igs.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; ibreak_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.countflip.flag_buf_ptr++ = TTY_OVERRUN; - dprintk("sci: overrun error\n"); - } - - if (status&SCxSR_FER(port) && tty->flip.countflip.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.countflip.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.countbreak_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.countflip.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; jbase, - (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 index 5d07cd107..000000000 --- a/drivers/char/sh-sci.h +++ /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 - -#if defined(__H8300H__) || defined(__H8300S__) -#include -#if defined(CONFIG_H83007) || defined(CONFIG_H83068) -#include -#endif -#if defined(CONFIG_H8S2678) -#include -#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/i2c/busses/i2c-ixp42x.c b/drivers/i2c/busses/i2c-ixp42x.c deleted file mode 100644 index 59fcb70fd..000000000 --- a/drivers/i2c/busses/i2c-ixp42x.c +++ /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 - * - * 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 -#include -#include -#include -#include -#include - -#include /* 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 "); - diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/arm/ide_arm.c new file mode 100644 index 000000000..23488c4d1 --- /dev/null +++ b/drivers/ide/arm/ide_arm.c @@ -0,0 +1,43 @@ +/* + * ARM/ARM26 default IDE host driver + * + * Copyright (C) 2004 Bartlomiej Zolnierkiewicz + * Based on code by: Russell King, Ian Molton and Alexander Schulz. + * + * May be copied or modified under the terms of the GNU General Public License. + */ + +#include +#include +#include + +#include +#include + +#ifdef CONFIG_ARM26 +# define IDE_ARM_HOST (machine_is_a5k()) +#else +# define IDE_ARM_HOST (1) +#endif + +#ifdef CONFIG_ARCH_CLPS7500 +# include +# +# define IDE_ARM_IO (ISASLOT_IO + 0x1f0) +# define IDE_ARM_IRQ IRQ_ISA_14 +#else +# define IDE_ARM_IO 0x1f0 +# define IDE_ARM_IRQ IRQ_HARDDISK +#endif + +void __init ide_arm_init(void) +{ + if (IDE_ARM_HOST) { + hw_regs_t hw; + + memset(&hw, 0, sizeof(hw)); + ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206); + hw.irq = IDE_ARM_IRQ; + ide_register_hw(&hw, NULL); + } +} diff --git a/drivers/ide/pci/cmd640.h b/drivers/ide/pci/cmd640.h deleted file mode 100644 index 28b6e0452..000000000 --- a/drivers/ide/pci/cmd640.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef CMD640_H -#define CMD640_H - -#include -#include -#include - -#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 */ diff --git a/drivers/ide/ppc/swarm.c b/drivers/ide/ppc/swarm.c deleted file mode 100644 index d54a55525..000000000 --- a/drivers/ide/ppc/swarm.c +++ /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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define __IDE_SWARM_C - -#include - -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/net/auto_irq.c b/drivers/net/auto_irq.c deleted file mode 100644 index 96ddc77b7..000000000 --- a/drivers/net/auto_irq.c +++ /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 -#include -#include -#include -#include -#include -#include - -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); - - -/* - * 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/ibm_emac/Makefile b/drivers/net/ibm_emac/Makefile new file mode 100644 index 000000000..7f583a333 --- /dev/null +++ b/drivers/net/ibm_emac/Makefile @@ -0,0 +1,12 @@ +# +# Makefile for the IBM PPC4xx EMAC controllers +# + +obj-$(CONFIG_IBM_EMAC) += ibm_emac.o + +ibm_emac-objs := ibm_emac_mal.o ibm_emac_core.o ibm_emac_phy.o + +# Only need this if you want to see additional debug messages +ifeq ($(CONFIG_IBM_EMAC_ERRMSG), y) +ibm_emac-objs += ibm_emac_debug.o +endif diff --git a/drivers/net/ibm_emac/ibm_emac_core.c b/drivers/net/ibm_emac/ibm_emac_core.c new file mode 100644 index 000000000..0bc7f8242 --- /dev/null +++ b/drivers/net/ibm_emac/ibm_emac_core.c @@ -0,0 +1,1968 @@ +/* + * ibm_emac_core.c + * + * Ethernet driver for the built in ethernet on the IBM 4xx PowerPC + * processors. + * + * (c) 2003 Benjamin Herrenschmidt + * + * Based on original work by + * + * Armin Kuster + * Johnnie Peters + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * TODO + * - Check for races in the "remove" code path + * - Add some Power Management to the MAC and the PHY + * - Audit remaining of non-rewritten code (--BenH) + * - Cleanup message display using msglevel mecanism + * - Address all errata + * - Audit all register update paths to ensure they + * are being written post soft reset if required. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "ibm_emac_core.h" + +//#define MDIO_DEBUG(fmt) printk fmt +#define MDIO_DEBUG(fmt) + +//#define LINK_DEBUG(fmt) printk fmt +#define LINK_DEBUG(fmt) + +//#define PKT_DEBUG(fmt) printk fmt +#define PKT_DEBUG(fmt) + +#define DRV_NAME "emac" +#define DRV_VERSION "2.0" +#define DRV_AUTHOR "Benjamin Herrenschmidt " +#define DRV_DESC "IBM EMAC Ethernet driver" + +/* + * When mdio_idx >= 0, contains a list of emac ocp_devs + * that have had their initialization deferred until the + * common MDIO controller has been initialized. + */ +LIST_HEAD(emac_init_list); + +MODULE_AUTHOR(DRV_AUTHOR); +MODULE_DESCRIPTION(DRV_DESC); +MODULE_LICENSE("GPL"); + +static int skb_res = SKB_RES; +module_param(skb_res, int, 0444); +MODULE_PARM_DESC(skb_res, "Amount of data to reserve on skb buffs\n" + "The 405 handles a misaligned IP header fine but\n" + "this can help if you are routing to a tunnel or a\n" + "device that needs aligned data. 0..2"); + +#define RGMII_PRIV(ocpdev) ((struct ibm_ocp_rgmii*)ocp_get_drvdata(ocpdev)) + +static unsigned int rgmii_enable[] = + { RGMII_RTBI, RGMII_RGMII, RGMII_TBI, RGMII_GMII }; + +static unsigned int rgmii_speed_mask[] = { 0, + 0, + RGMII_MII2_SPDMASK, + RGMII_MII3_SPDMASK +}; + +static unsigned int rgmii_speed100[] = { 0, + 0, + RGMII_MII2_100MB, + RGMII_MII3_100MB +}; + +static unsigned int rgmii_speed1000[] = { 0, + 0, + RGMII_MII2_1000MB, + RGMII_MII3_1000MB +}; + +#define ZMII_PRIV(ocpdev) ((struct ibm_ocp_zmii*)ocp_get_drvdata(ocpdev)) + +static unsigned int zmii_enable[][4] = { + {ZMII_SMII0, ZMII_RMII0, ZMII_MII0, + ~(ZMII_MDI1 | ZMII_MDI2 | ZMII_MDI3)}, + {ZMII_SMII1, ZMII_RMII1, ZMII_MII1, + ~(ZMII_MDI0 | ZMII_MDI2 | ZMII_MDI3)}, + {ZMII_SMII2, ZMII_RMII2, ZMII_MII2, + ~(ZMII_MDI0 | ZMII_MDI1 | ZMII_MDI3)}, + {ZMII_SMII3, ZMII_RMII3, ZMII_MII3, ~(ZMII_MDI0 | ZMII_MDI1 | ZMII_MDI2)} +}; +static unsigned int mdi_enable[] = + { ZMII_MDI0, ZMII_MDI1, ZMII_MDI2, ZMII_MDI3 }; + +static unsigned int zmii_speed = 0x0; +static unsigned int zmii_speed100[] = { ZMII_MII0_100MB, ZMII_MII1_100MB }; + +/* Since multiple EMACs share MDIO lines in various ways, we need + * to avoid re-using the same PHY ID in cases where the arch didn't + * setup precise phy_map entries + */ +static u32 busy_phy_map = 0; + +/* If EMACs share a common MDIO device, this points to it */ +static struct net_device *mdio_ndev = NULL; + +struct emac_def_dev { + struct list_head link; + struct ocp_device *ocpdev; + struct ibm_ocp_mal *mal; +}; + +static struct net_device_stats *emac_stats(struct net_device *dev) +{ + struct ocp_enet_private *fep = dev->priv; + return &fep->stats; +}; + +static int +emac_init_rgmii(struct ocp_device *rgmii_dev, int input, int phy_mode) +{ + struct ibm_ocp_rgmii *rgmii = RGMII_PRIV(rgmii_dev); + const char *mode_name[] = { "RTBI", "RGMII", "TBI", "GMII" }; + int mode = -1; + + if (!rgmii) { + rgmii = kmalloc(sizeof(struct ibm_ocp_rgmii), GFP_KERNEL); + + if (rgmii == NULL) { + printk(KERN_ERR + "rgmii%d: Out of memory allocating RGMII structure!\n", + rgmii_dev->def->index); + return -ENOMEM; + } + + memset(rgmii, 0, sizeof(*rgmii)); + + rgmii->base = + (struct rgmii_regs *)ioremap(rgmii_dev->def->paddr, + sizeof(*rgmii->base)); + if (rgmii->base == NULL) { + printk(KERN_ERR + "rgmii%d: Cannot ioremap bridge registers!\n", + rgmii_dev->def->index); + + kfree(rgmii); + return -ENOMEM; + } + ocp_set_drvdata(rgmii_dev, rgmii); + } + + if (phy_mode) { + switch (phy_mode) { + case PHY_MODE_GMII: + mode = GMII; + break; + case PHY_MODE_TBI: + mode = TBI; + break; + case PHY_MODE_RTBI: + mode = RTBI; + break; + case PHY_MODE_RGMII: + default: + mode = RGMII; + } + rgmii->base->fer &= ~RGMII_FER_MASK(input); + rgmii->base->fer |= rgmii_enable[mode] << (4 * input); + } else { + switch ((rgmii->base->fer & RGMII_FER_MASK(input)) >> (4 * + input)) { + case RGMII_RTBI: + mode = RTBI; + break; + case RGMII_RGMII: + mode = RGMII; + break; + case RGMII_TBI: + mode = TBI; + break; + case RGMII_GMII: + mode = GMII; + } + } + + /* Set mode to RGMII if nothing valid is detected */ + if (mode < 0) + mode = RGMII; + + printk(KERN_NOTICE "rgmii%d: input %d in %s mode\n", + rgmii_dev->def->index, input, mode_name[mode]); + + rgmii->mode[input] = mode; + rgmii->users++; + + return 0; +} + +static void +emac_rgmii_port_speed(struct ocp_device *ocpdev, int input, int speed) +{ + struct ibm_ocp_rgmii *rgmii = RGMII_PRIV(ocpdev); + unsigned int rgmii_speed; + + rgmii_speed = in_be32(&rgmii->base->ssr); + + rgmii_speed &= ~rgmii_speed_mask[input]; + + if (speed == 1000) + rgmii_speed |= rgmii_speed1000[input]; + else if (speed == 100) + rgmii_speed |= rgmii_speed100[input]; + + out_be32(&rgmii->base->ssr, rgmii_speed); +} + +static void emac_close_rgmii(struct ocp_device *ocpdev) +{ + struct ibm_ocp_rgmii *rgmii = RGMII_PRIV(ocpdev); + BUG_ON(!rgmii || rgmii->users == 0); + + if (!--rgmii->users) { + ocp_set_drvdata(ocpdev, NULL); + iounmap((void *)rgmii->base); + kfree(rgmii); + } +} + +static int emac_init_zmii(struct ocp_device *zmii_dev, int input, int phy_mode) +{ + struct ibm_ocp_zmii *zmii = ZMII_PRIV(zmii_dev); + const char *mode_name[] = { "SMII", "RMII", "MII" }; + int mode = -1; + + if (!zmii) { + zmii = kmalloc(sizeof(struct ibm_ocp_zmii), GFP_KERNEL); + if (zmii == NULL) { + printk(KERN_ERR + "zmii%d: Out of memory allocating ZMII structure!\n", + zmii_dev->def->index); + return -ENOMEM; + } + memset(zmii, 0, sizeof(*zmii)); + + zmii->base = + (struct zmii_regs *)ioremap(zmii_dev->def->paddr, + sizeof(*zmii->base)); + if (zmii->base == NULL) { + printk(KERN_ERR + "zmii%d: Cannot ioremap bridge registers!\n", + zmii_dev->def->index); + + kfree(zmii); + return -ENOMEM; + } + ocp_set_drvdata(zmii_dev, zmii); + } + + if (phy_mode) { + switch (phy_mode) { + case PHY_MODE_MII: + mode = MII; + break; + case PHY_MODE_RMII: + mode = RMII; + break; + case PHY_MODE_SMII: + default: + mode = SMII; + } + zmii->base->fer &= ~ZMII_FER_MASK(input); + zmii->base->fer |= zmii_enable[input][mode]; + } else { + switch ((zmii->base->fer & ZMII_FER_MASK(input)) << (4 * input)) { + case ZMII_MII0: + mode = MII; + break; + case ZMII_RMII0: + mode = RMII; + break; + case ZMII_SMII0: + mode = SMII; + } + } + + /* Set mode to SMII if nothing valid is detected */ + if (mode < 0) + mode = SMII; + + printk(KERN_NOTICE "zmii%d: input %d in %s mode\n", + zmii_dev->def->index, input, mode_name[mode]); + + zmii->mode[input] = mode; + zmii->users++; + + return 0; +} + +static void emac_enable_zmii_port(struct ocp_device *ocpdev, int input) +{ + u32 mask; + struct ibm_ocp_zmii *zmii = ZMII_PRIV(ocpdev); + + mask = in_be32(&zmii->base->fer); + mask &= zmii_enable[input][MDI]; /* turn all non enabled MDI's off */ + mask |= zmii_enable[input][zmii->mode[input]] | mdi_enable[input]; + out_be32(&zmii->base->fer, mask); +} + +static void +emac_zmii_port_speed(struct ocp_device *ocpdev, int input, int speed) +{ + struct ibm_ocp_zmii *zmii = ZMII_PRIV(ocpdev); + + if (speed == 100) + zmii_speed |= zmii_speed100[input]; + else + zmii_speed &= ~zmii_speed100[input]; + + out_be32(&zmii->base->ssr, zmii_speed); +} + +static void emac_close_zmii(struct ocp_device *ocpdev) +{ + struct ibm_ocp_zmii *zmii = ZMII_PRIV(ocpdev); + BUG_ON(!zmii || zmii->users == 0); + + if (!--zmii->users) { + ocp_set_drvdata(ocpdev, NULL); + iounmap((void *)zmii->base); + kfree(zmii); + } +} + +int emac_phy_read(struct net_device *dev, int mii_id, int reg) +{ + uint32_t stacr; + struct ocp_enet_private *fep = dev->priv; + emac_t *emacp = fep->emacp; + + MDIO_DEBUG(("%s: phy_read, id: 0x%x, reg: 0x%x\n", dev->name, mii_id, + reg)); + + /* Enable proper ZMII port */ + if (fep->zmii_dev) + emac_enable_zmii_port(fep->zmii_dev, fep->zmii_input); + + /* Use the EMAC that has the MDIO port */ + if (fep->mdio_dev) { + dev = fep->mdio_dev; + fep = dev->priv; + emacp = fep->emacp; + } + + udelay(MDIO_DELAY); + + if ((in_be32(&emacp->em0stacr) & EMAC_STACR_OC) == 0) { + printk(KERN_WARNING "%s: PHY read timeout #1!\n", dev->name); + return -1; + } + + /* Clear the speed bits and make a read request to the PHY */ + stacr = ((EMAC_STACR_READ | (reg & 0x1f)) & ~EMAC_STACR_CLK_100MHZ); + stacr |= ((mii_id & 0x1F) << 5); + + out_be32(&emacp->em0stacr, stacr); + + udelay(MDIO_DELAY); + stacr = in_be32(&emacp->em0stacr); + + if ((stacr & EMAC_STACR_OC) == 0) { + printk(KERN_WARNING "%s: PHY read timeout #2!\n", dev->name); + return -1; + } + + /* Check for a read error */ + if (stacr & EMAC_STACR_PHYE) { + MDIO_DEBUG(("EMAC MDIO PHY error !\n")); + return -1; + } + + MDIO_DEBUG((" -> 0x%x\n", stacr >> 16)); + + return (stacr >> 16); +} + +void emac_phy_write(struct net_device *dev, int mii_id, int reg, int data) +{ + uint32_t stacr; + struct ocp_enet_private *fep = dev->priv; + emac_t *emacp = fep->emacp; + + MDIO_DEBUG(("%s phy_write, id: 0x%x, reg: 0x%x, data: 0x%x\n", + dev->name, mii_id, reg, data)); + + /* Enable proper ZMII port */ + if (fep->zmii_dev) + emac_enable_zmii_port(fep->zmii_dev, fep->zmii_input); + + /* Use the EMAC that has the MDIO port */ + if (fep->mdio_dev) { + dev = fep->mdio_dev; + fep = dev->priv; + emacp = fep->emacp; + } + + udelay(MDIO_DELAY); + + if ((in_be32(&emacp->em0stacr) & EMAC_STACR_OC) == 0) { + printk(KERN_WARNING "%s: PHY write timeout #2!\n", dev->name); + return; + } + + /* Clear the speed bits and make a read request to the PHY */ + + stacr = ((EMAC_STACR_WRITE | (reg & 0x1f)) & ~EMAC_STACR_CLK_100MHZ); + stacr |= ((mii_id & 0x1f) << 5) | ((data & 0xffff) << 16); + + out_be32(&emacp->em0stacr, stacr); + + udelay(MDIO_DELAY); + + if ((in_be32(&emacp->em0stacr) & EMAC_STACR_OC) == 0) + printk(KERN_WARNING "%s: PHY write timeout #2!\n", dev->name); + + /* Check for a write error */ + if ((stacr & EMAC_STACR_PHYE) != 0) { + MDIO_DEBUG(("EMAC MDIO PHY error !\n")); + } +} + +static void emac_txeob_dev(void *param, u32 chanmask) +{ + struct net_device *dev = param; + struct ocp_enet_private *fep = dev->priv; + unsigned long flags; + + spin_lock_irqsave(&fep->lock, flags); + + PKT_DEBUG(("emac_txeob_dev() entry, tx_cnt: %d\n", fep->tx_cnt)); + + while (fep->tx_cnt && + !(fep->tx_desc[fep->ack_slot].ctrl & MAL_TX_CTRL_READY)) { + + if (fep->tx_desc[fep->ack_slot].ctrl & MAL_TX_CTRL_LAST) { + /* Tell the system the transmit completed. */ + dma_unmap_single(&fep->ocpdev->dev, + fep->tx_desc[fep->ack_slot].data_ptr, + fep->tx_desc[fep->ack_slot].data_len, + DMA_TO_DEVICE); + dev_kfree_skb_irq(fep->tx_skb[fep->ack_slot]); + + if (fep->tx_desc[fep->ack_slot].ctrl & + (EMAC_TX_ST_EC | EMAC_TX_ST_MC | EMAC_TX_ST_SC)) + fep->stats.collisions++; + } + + fep->tx_skb[fep->ack_slot] = (struct sk_buff *)NULL; + if (++fep->ack_slot == NUM_TX_BUFF) + fep->ack_slot = 0; + + fep->tx_cnt--; + } + if (fep->tx_cnt < NUM_TX_BUFF) + netif_wake_queue(dev); + + PKT_DEBUG(("emac_txeob_dev() exit, tx_cnt: %d\n", fep->tx_cnt)); + + spin_unlock_irqrestore(&fep->lock, flags); +} + +/* + Fill/Re-fill the rx chain with valid ctrl/ptrs. + This function will fill from rx_slot up to the parm end. + So to completely fill the chain pre-set rx_slot to 0 and + pass in an end of 0. + */ +static void emac_rx_fill(struct net_device *dev, int end) +{ + int i; + struct ocp_enet_private *fep = dev->priv; + + i = fep->rx_slot; + do { + /* We don't want the 16 bytes skb_reserve done by dev_alloc_skb, + * it breaks our cache line alignement. However, we still allocate + * +16 so that we end up allocating the exact same size as + * dev_alloc_skb() would do. + * Also, because of the skb_res, the max DMA size we give to EMAC + * is slighly wrong, causing it to potentially DMA 2 more bytes + * from a broken/oversized packet. These 16 bytes will take care + * that we don't walk on somebody else toes with that. + */ + fep->rx_skb[i] = + alloc_skb(fep->rx_buffer_size + 16, GFP_ATOMIC); + + if (fep->rx_skb[i] == NULL) { + /* Keep rx_slot here, the next time clean/fill is called + * we will try again before the MAL wraps back here + * If the MAL tries to use this descriptor with + * the EMPTY bit off it will cause the + * rxde interrupt. That is where we will + * try again to allocate an sk_buff. + */ + break; + + } + + if (skb_res) + skb_reserve(fep->rx_skb[i], skb_res); + + /* We must NOT dma_map_single the cache line right after the + * buffer, so we must crop our sync size to account for the + * reserved space + */ + fep->rx_desc[i].data_ptr = + (unsigned char *)dma_map_single(&fep->ocpdev->dev, + (void *)fep->rx_skb[i]-> + data, + fep->rx_buffer_size - + skb_res, DMA_FROM_DEVICE); + + /* + * Some 4xx implementations use the previously + * reserved bits in data_len to encode the MS + * 4-bits of a 36-bit physical address (ERPN) + * This must be initialized. + */ + fep->rx_desc[i].data_len = 0; + fep->rx_desc[i].ctrl = MAL_RX_CTRL_EMPTY | MAL_RX_CTRL_INTR | + (i == (NUM_RX_BUFF - 1) ? MAL_RX_CTRL_WRAP : 0); + + } while ((i = (i + 1) % NUM_RX_BUFF) != end); + + fep->rx_slot = i; +} + +static void +emac_rx_csum(struct net_device *dev, unsigned short ctrl, struct sk_buff *skb) +{ + struct ocp_enet_private *fep = dev->priv; + + /* Exit if interface has no TAH engine */ + if (!fep->tah_dev) { + skb->ip_summed = CHECKSUM_NONE; + return; + } + + /* Check for TCP/UDP/IP csum error */ + if (ctrl & EMAC_CSUM_VER_ERROR) { + /* Let the stack verify checksum errors */ + skb->ip_summed = CHECKSUM_NONE; +/* adapter->hw_csum_err++; */ + } else { + /* Csum is good */ + skb->ip_summed = CHECKSUM_UNNECESSARY; +/* adapter->hw_csum_good++; */ + } +} + +static int emac_rx_clean(struct net_device *dev) +{ + int i, b, bnum, buf[6]; + int error, frame_length; + struct ocp_enet_private *fep = dev->priv; + unsigned short ctrl; + + i = fep->rx_slot; + + PKT_DEBUG(("emac_rx_clean() entry, rx_slot: %d\n", fep->rx_slot)); + + do { + if (fep->rx_skb[i] == NULL) + continue; /*we have already handled the packet but haved failed to alloc */ + /* + since rx_desc is in uncached mem we don't keep reading it directly + we pull out a local copy of ctrl and do the checks on the copy. + */ + ctrl = fep->rx_desc[i].ctrl; + if (ctrl & MAL_RX_CTRL_EMPTY) + break; /*we don't have any more ready packets */ + + if (EMAC_IS_BAD_RX_PACKET(ctrl)) { + fep->stats.rx_errors++; + fep->stats.rx_dropped++; + + if (ctrl & EMAC_RX_ST_OE) + fep->stats.rx_fifo_errors++; + if (ctrl & EMAC_RX_ST_AE) + fep->stats.rx_frame_errors++; + if (ctrl & EMAC_RX_ST_BFCS) + fep->stats.rx_crc_errors++; + if (ctrl & (EMAC_RX_ST_RP | EMAC_RX_ST_PTL | + EMAC_RX_ST_ORE | EMAC_RX_ST_IRE)) + fep->stats.rx_length_errors++; + } else { + if ((ctrl & (MAL_RX_CTRL_FIRST | MAL_RX_CTRL_LAST)) == + (MAL_RX_CTRL_FIRST | MAL_RX_CTRL_LAST)) { + /* Single descriptor packet */ + emac_rx_csum(dev, ctrl, fep->rx_skb[i]); + /* Send the skb up the chain. */ + frame_length = fep->rx_desc[i].data_len - 4; + skb_put(fep->rx_skb[i], frame_length); + fep->rx_skb[i]->dev = dev; + fep->rx_skb[i]->protocol = + eth_type_trans(fep->rx_skb[i], dev); + error = netif_rx(fep->rx_skb[i]); + + if ((error == NET_RX_DROP) || + (error == NET_RX_BAD)) { + fep->stats.rx_dropped++; + } else { + fep->stats.rx_packets++; + fep->stats.rx_bytes += frame_length; + } + fep->rx_skb[i] = NULL; + } else { + /* Multiple descriptor packet */ + if (ctrl & MAL_RX_CTRL_FIRST) { + if (fep->rx_desc[(i + 1) % NUM_RX_BUFF]. + ctrl & MAL_RX_CTRL_EMPTY) + break; + bnum = 0; + buf[bnum] = i; + ++bnum; + continue; + } + if (((ctrl & MAL_RX_CTRL_FIRST) != + MAL_RX_CTRL_FIRST) && + ((ctrl & MAL_RX_CTRL_LAST) != + MAL_RX_CTRL_LAST)) { + if (fep->rx_desc[(i + 1) % + NUM_RX_BUFF].ctrl & + MAL_RX_CTRL_EMPTY) { + i = buf[0]; + break; + } + buf[bnum] = i; + ++bnum; + continue; + } + if (ctrl & MAL_RX_CTRL_LAST) { + buf[bnum] = i; + ++bnum; + skb_put(fep->rx_skb[buf[0]], + fep->rx_desc[buf[0]].data_len); + for (b = 1; b < bnum; b++) { + /* + * MAL is braindead, we need + * to copy the remainder + * of the packet from the + * latter descriptor buffers + * to the first skb. Then + * dispose of the source + * skbs. + * + * Once the stack is fixed + * to handle frags on most + * protocols we can generate + * a fragmented skb with + * no copies. + */ + memcpy(fep->rx_skb[buf[0]]-> + data + + fep->rx_skb[buf[0]]->len, + fep->rx_skb[buf[b]]-> + data, + fep->rx_desc[buf[b]]. + data_len); + skb_put(fep->rx_skb[buf[0]], + fep->rx_desc[buf[b]]. + data_len); + dma_unmap_single(&fep->ocpdev-> + dev, + fep-> + rx_desc[buf + [b]]. + data_ptr, + fep-> + rx_desc[buf + [b]]. + data_len, + DMA_FROM_DEVICE); + dev_kfree_skb(fep-> + rx_skb[buf[b]]); + } + emac_rx_csum(dev, ctrl, + fep->rx_skb[buf[0]]); + + fep->rx_skb[buf[0]]->dev = dev; + fep->rx_skb[buf[0]]->protocol = + eth_type_trans(fep->rx_skb[buf[0]], + dev); + error = netif_rx(fep->rx_skb[buf[0]]); + + if ((error == NET_RX_DROP) + || (error == NET_RX_BAD)) { + fep->stats.rx_dropped++; + } else { + fep->stats.rx_packets++; + fep->stats.rx_bytes += + fep->rx_skb[buf[0]]->len; + } + for (b = 0; b < bnum; b++) + fep->rx_skb[buf[b]] = NULL; + } + } + } + } while ((i = (i + 1) % NUM_RX_BUFF) != fep->rx_slot); + + PKT_DEBUG(("emac_rx_clean() exit, rx_slot: %d\n", fep->rx_slot)); + + return i; +} + +static void emac_rxeob_dev(void *param, u32 chanmask) +{ + struct net_device *dev = param; + struct ocp_enet_private *fep = dev->priv; + unsigned long flags; + int n; + + spin_lock_irqsave(&fep->lock, flags); + if ((n = emac_rx_clean(dev)) != fep->rx_slot) + emac_rx_fill(dev, n); + spin_unlock_irqrestore(&fep->lock, flags); +} + +/* + * This interrupt should never occurr, we don't program + * the MAL for contiunous mode. + */ +static void emac_txde_dev(void *param, u32 chanmask) +{ + struct net_device *dev = param; + struct ocp_enet_private *fep = dev->priv; + + printk(KERN_WARNING "%s: transmit descriptor error\n", dev->name); + + emac_mac_dump(dev); + emac_mal_dump(dev); + + /* Reenable the transmit channel */ + mal_enable_tx_channels(fep->mal, fep->commac.tx_chan_mask); +} + +/* + * This interrupt should be very rare at best. This occurs when + * the hardware has a problem with the receive descriptors. The manual + * states that it occurs when the hardware cannot the receive descriptor + * empty bit is not set. The recovery mechanism will be to + * traverse through the descriptors, handle any that are marked to be + * handled and reinitialize each along the way. At that point the driver + * will be restarted. + */ +static void emac_rxde_dev(void *param, u32 chanmask) +{ + struct net_device *dev = param; + struct ocp_enet_private *fep = dev->priv; + unsigned long flags; + + if (net_ratelimit()) { + printk(KERN_WARNING "%s: receive descriptor error\n", + fep->ndev->name); + + emac_mac_dump(dev); + emac_mal_dump(dev); + emac_desc_dump(dev); + } + + /* Disable RX channel */ + spin_lock_irqsave(&fep->lock, flags); + mal_disable_rx_channels(fep->mal, fep->commac.rx_chan_mask); + + /* For now, charge the error against all emacs */ + fep->stats.rx_errors++; + + /* so do we have any good packets still? */ + emac_rx_clean(dev); + + /* When the interface is restarted it resets processing to the + * first descriptor in the table. + */ + + fep->rx_slot = 0; + emac_rx_fill(dev, 0); + + set_mal_dcrn(fep->mal, DCRN_MALRXEOBISR, fep->commac.rx_chan_mask); + set_mal_dcrn(fep->mal, DCRN_MALRXDEIR, fep->commac.rx_chan_mask); + + /* Reenable the receive channels */ + mal_enable_rx_channels(fep->mal, fep->commac.rx_chan_mask); + spin_unlock_irqrestore(&fep->lock, flags); +} + +static irqreturn_t +emac_mac_irq(int irq, void *dev_instance, struct pt_regs *regs) +{ + struct net_device *dev = dev_instance; + struct ocp_enet_private *fep = dev->priv; + emac_t *emacp = fep->emacp; + unsigned long tmp_em0isr; + + /* EMAC interrupt */ + tmp_em0isr = in_be32(&emacp->em0isr); + if (tmp_em0isr & (EMAC_ISR_TE0 | EMAC_ISR_TE1)) { + /* This error is a hard transmit error - could retransmit */ + fep->stats.tx_errors++; + + /* Reenable the transmit channel */ + mal_enable_tx_channels(fep->mal, fep->commac.tx_chan_mask); + + } else { + fep->stats.rx_errors++; + } + + if (tmp_em0isr & EMAC_ISR_RP) + fep->stats.rx_length_errors++; + if (tmp_em0isr & EMAC_ISR_ALE) + fep->stats.rx_frame_errors++; + if (tmp_em0isr & EMAC_ISR_BFCS) + fep->stats.rx_crc_errors++; + if (tmp_em0isr & EMAC_ISR_PTLE) + fep->stats.rx_length_errors++; + if (tmp_em0isr & EMAC_ISR_ORE) + fep->stats.rx_length_errors++; + if (tmp_em0isr & EMAC_ISR_TE0) + fep->stats.tx_aborted_errors++; + + emac_err_dump(dev, tmp_em0isr); + + out_be32(&emacp->em0isr, tmp_em0isr); + + return IRQ_HANDLED; +} + +static int emac_start_xmit(struct sk_buff *skb, struct net_device *dev) +{ + unsigned short ctrl; + unsigned long flags; + struct ocp_enet_private *fep = dev->priv; + emac_t *emacp = fep->emacp; + int len = skb->len; + unsigned int offset = 0, size, f, tx_slot_first; + unsigned int nr_frags = skb_shinfo(skb)->nr_frags; + + spin_lock_irqsave(&fep->lock, flags); + + len -= skb->data_len; + + if ((fep->tx_cnt + nr_frags + len / DESC_BUF_SIZE + 1) > NUM_TX_BUFF) { + PKT_DEBUG(("emac_start_xmit() stopping queue\n")); + netif_stop_queue(dev); + spin_unlock_irqrestore(&fep->lock, flags); + restore_flags(flags); + return -EBUSY; + } + + tx_slot_first = fep->tx_slot; + + while (len) { + size = min(len, DESC_BUF_SIZE); + + fep->tx_desc[fep->tx_slot].data_len = (short)size; + fep->tx_desc[fep->tx_slot].data_ptr = + (unsigned char *)dma_map_single(&fep->ocpdev->dev, + (void *)((unsigned int)skb-> + data + offset), + size, DMA_TO_DEVICE); + + ctrl = EMAC_TX_CTRL_DFLT; + if (fep->tx_slot != tx_slot_first) + ctrl |= MAL_TX_CTRL_READY; + if ((NUM_TX_BUFF - 1) == fep->tx_slot) + ctrl |= MAL_TX_CTRL_WRAP; + if (!nr_frags && (len == size)) { + ctrl |= MAL_TX_CTRL_LAST; + fep->tx_skb[fep->tx_slot] = skb; + } + if (skb->ip_summed == CHECKSUM_HW) + ctrl |= EMAC_TX_CTRL_TAH_CSUM; + + fep->tx_desc[fep->tx_slot].ctrl = ctrl; + + len -= size; + offset += size; + + /* Bump tx count */ + if (++fep->tx_cnt == NUM_TX_BUFF) + netif_stop_queue(dev); + + /* Next descriptor */ + if (++fep->tx_slot == NUM_TX_BUFF) + fep->tx_slot = 0; + } + + for (f = 0; f < nr_frags; f++) { + struct skb_frag_struct *frag; + + frag = &skb_shinfo(skb)->frags[f]; + len = frag->size; + offset = 0; + + while (len) { + size = min(len, DESC_BUF_SIZE); + + dma_map_page(&fep->ocpdev->dev, + frag->page, + frag->page_offset + offset, + size, DMA_TO_DEVICE); + + ctrl = EMAC_TX_CTRL_DFLT | MAL_TX_CTRL_READY; + if ((NUM_TX_BUFF - 1) == fep->tx_slot) + ctrl |= MAL_TX_CTRL_WRAP; + if ((f == (nr_frags - 1)) && (len == size)) { + ctrl |= MAL_TX_CTRL_LAST; + fep->tx_skb[fep->tx_slot] = skb; + } + + if (skb->ip_summed == CHECKSUM_HW) + ctrl |= EMAC_TX_CTRL_TAH_CSUM; + + fep->tx_desc[fep->tx_slot].data_len = (short)size; + fep->tx_desc[fep->tx_slot].data_ptr = + (char *)((page_to_pfn(frag->page) << PAGE_SHIFT) + + frag->page_offset + offset); + fep->tx_desc[fep->tx_slot].ctrl = ctrl; + + len -= size; + offset += size; + + /* Bump tx count */ + if (++fep->tx_cnt == NUM_TX_BUFF) + netif_stop_queue(dev); + + /* Next descriptor */ + if (++fep->tx_slot == NUM_TX_BUFF) + fep->tx_slot = 0; + } + } + + /* + * Deferred set READY on first descriptor of packet to + * avoid TX MAL race. + */ + fep->tx_desc[tx_slot_first].ctrl |= MAL_TX_CTRL_READY; + + /* Send the packet out. */ + out_be32(&emacp->em0tmr0, EMAC_TMR0_XMIT); + + fep->stats.tx_packets++; + fep->stats.tx_bytes += skb->len; + + PKT_DEBUG(("emac_start_xmit() exitn")); + + spin_unlock_irqrestore(&fep->lock, flags); + + return 0; +} + +static int emac_adjust_to_link(struct ocp_enet_private *fep) +{ + emac_t *emacp = fep->emacp; + struct ibm_ocp_rgmii *rgmii; + unsigned long mode_reg; + int full_duplex, speed; + + full_duplex = 0; + speed = SPEED_10; + + /* set mode register 1 defaults */ + mode_reg = EMAC_M1_DEFAULT; + + /* Read link mode on PHY */ + if (fep->phy_mii.def->ops->read_link(&fep->phy_mii) == 0) { + /* If an error occurred, we don't deal with it yet */ + full_duplex = (fep->phy_mii.duplex == DUPLEX_FULL); + speed = fep->phy_mii.speed; + } + + if (fep->rgmii_dev) + rgmii = RGMII_PRIV(fep->rgmii_dev); + + /* set speed (default is 10Mb) */ + switch (speed) { + case SPEED_1000: + mode_reg |= EMAC_M1_JUMBO_ENABLE | EMAC_M1_RFS_16K; + if ((rgmii->mode[fep->rgmii_input] == RTBI) + || (rgmii->mode[fep->rgmii_input] == TBI)) + mode_reg |= EMAC_M1_MF_1000GPCS; + else + mode_reg |= EMAC_M1_MF_1000MBPS; + if (fep->rgmii_dev) + emac_rgmii_port_speed(fep->rgmii_dev, fep->rgmii_input, + 1000); + break; + case SPEED_100: + mode_reg |= EMAC_M1_MF_100MBPS | EMAC_M1_RFS_4K; + if (fep->rgmii_dev) + emac_rgmii_port_speed(fep->rgmii_dev, fep->rgmii_input, + 100); + if (fep->zmii_dev) + emac_zmii_port_speed(fep->zmii_dev, fep->zmii_input, + 100); + break; + case SPEED_10: + default: + mode_reg = (mode_reg & ~EMAC_M1_MF_100MBPS) | EMAC_M1_RFS_4K; + if (fep->rgmii_dev) + emac_rgmii_port_speed(fep->rgmii_dev, fep->rgmii_input, + 10); + if (fep->zmii_dev) + emac_zmii_port_speed(fep->zmii_dev, fep->zmii_input, + 10); + } + + if (full_duplex) + mode_reg |= EMAC_M1_FDE | EMAC_M1_EIFC | EMAC_M1_IST; + else + mode_reg &= ~(EMAC_M1_FDE | EMAC_M1_EIFC | EMAC_M1_ILE); + + LINK_DEBUG(("%s: adjust to link, speed: %d, duplex: %d, opened: %d\n", + fep->ndev->name, speed, full_duplex, fep->opened)); + + printk(KERN_INFO "%s: Speed: %d, %s duplex.\n", + fep->ndev->name, speed, full_duplex ? "Full" : "Half"); + if (fep->opened) + out_be32(&emacp->em0mr1, mode_reg); + + return 0; +} + +static int emac_set_mac_address(struct net_device *ndev, void *p) +{ + struct ocp_enet_private *fep = ndev->priv; + emac_t *emacp = fep->emacp; + struct sockaddr *addr = p; + + if (!is_valid_ether_addr(addr->sa_data)) + return -EADDRNOTAVAIL; + + memcpy(ndev->dev_addr, addr->sa_data, ndev->addr_len); + + /* set the high address */ + out_be32(&emacp->em0iahr, + (fep->ndev->dev_addr[0] << 8) | fep->ndev->dev_addr[1]); + + /* set the low address */ + out_be32(&emacp->em0ialr, + (fep->ndev->dev_addr[2] << 24) | (fep->ndev->dev_addr[3] << 16) + | (fep->ndev->dev_addr[4] << 8) | fep->ndev->dev_addr[5]); + + return 0; +} + +static int emac_change_mtu(struct net_device *dev, int new_mtu) +{ + struct ocp_enet_private *fep = dev->priv; + int old_mtu = dev->mtu; + emac_t *emacp = fep->emacp; + u32 em0mr0; + int i, full; + unsigned long flags; + + if ((new_mtu < EMAC_MIN_MTU) || (new_mtu > EMAC_MAX_MTU)) { + printk(KERN_ERR + "emac: Invalid MTU setting, MTU must be between %d and %d\n", + EMAC_MIN_MTU, EMAC_MAX_MTU); + return -EINVAL; + } + + if (old_mtu != new_mtu && netif_running(dev)) { + /* Stop rx engine */ + em0mr0 = in_be32(&emacp->em0mr0); + out_be32(&emacp->em0mr0, em0mr0 & ~EMAC_M0_RXE); + + /* Wait for descriptors to be empty */ + do { + full = 0; + for (i = 0; i < NUM_RX_BUFF; i++) + if (!(fep->rx_desc[i].ctrl & MAL_RX_CTRL_EMPTY)) { + printk(KERN_NOTICE + "emac: RX ring is still full\n"); + full = 1; + } + } while (full); + + spin_lock_irqsave(&fep->lock, flags); + + mal_disable_rx_channels(fep->mal, fep->commac.rx_chan_mask); + + /* Destroy all old rx skbs */ + for (i = 0; i < NUM_RX_BUFF; i++) { + dma_unmap_single(&fep->ocpdev->dev, + fep->rx_desc[i].data_ptr, + fep->rx_desc[i].data_len, + DMA_FROM_DEVICE); + dev_kfree_skb(fep->rx_skb[i]); + fep->rx_skb[i] = NULL; + } + + /* Set new rx_buffer_size and advertise new mtu */ + fep->rx_buffer_size = + new_mtu + ENET_HEADER_SIZE + ENET_FCS_SIZE; + dev->mtu = new_mtu; + + /* Re-init rx skbs */ + fep->rx_slot = 0; + emac_rx_fill(dev, 0); + + /* Restart the rx engine */ + mal_enable_rx_channels(fep->mal, fep->commac.rx_chan_mask); + out_be32(&emacp->em0mr0, em0mr0 | EMAC_M0_RXE); + + spin_unlock_irqrestore(&fep->lock, flags); + } + + return 0; +} + +static void __emac_set_multicast_list(struct net_device *dev) +{ + struct ocp_enet_private *fep = dev->priv; + emac_t *emacp = fep->emacp; + u32 rmr = in_be32(&emacp->em0rmr); + + /* First clear all special bits, they can be set later */ + rmr &= ~(EMAC_RMR_PME | EMAC_RMR_PMME | EMAC_RMR_MAE); + + if (dev->flags & IFF_PROMISC) { + rmr |= EMAC_RMR_PME; + } else if (dev->flags & IFF_ALLMULTI || 32 < dev->mc_count) { + /* + * Must be setting up to use multicast + * Now check for promiscuous multicast + */ + rmr |= EMAC_RMR_PMME; + } else if (dev->flags & IFF_MULTICAST && 0 < dev->mc_count) { + unsigned short em0gaht[4] = { 0, 0, 0, 0 }; + struct dev_mc_list *dmi; + + /* Need to hash on the multicast address. */ + for (dmi = dev->mc_list; dmi; dmi = dmi->next) { + unsigned long mc_crc; + unsigned int bit_number; + + mc_crc = ether_crc(6, (char *)dmi->dmi_addr); + bit_number = 63 - (mc_crc >> 26); /* MSB: 0 LSB: 63 */ + em0gaht[bit_number >> 4] |= + 0x8000 >> (bit_number & 0x0f); + } + emacp->em0gaht1 = em0gaht[0]; + emacp->em0gaht2 = em0gaht[1]; + emacp->em0gaht3 = em0gaht[2]; + emacp->em0gaht4 = em0gaht[3]; + + /* Turn on multicast addressing */ + rmr |= EMAC_RMR_MAE; + } + out_be32(&emacp->em0rmr, rmr); +} + +static int emac_init_tah(struct ocp_enet_private *fep) +{ + tah_t *tahp; + + /* Initialize TAH and enable checksum verification */ + tahp = (tah_t *) ioremap(fep->tah_dev->def->paddr, sizeof(*tahp)); + + if (tahp == NULL) { + printk(KERN_ERR "tah%d: Cannot ioremap TAH registers!\n", + fep->tah_dev->def->index); + + return -ENOMEM; + } + + out_be32(&tahp->tah_mr, TAH_MR_SR); + + /* wait for reset to complete */ + while (in_be32(&tahp->tah_mr) & TAH_MR_SR) ; + + /* 10KB TAH TX FIFO accomodates the max MTU of 9000 */ + out_be32(&tahp->tah_mr, + TAH_MR_CVR | TAH_MR_ST_768 | TAH_MR_TFS_10KB | TAH_MR_DTFP | + TAH_MR_DIG); + + iounmap(&tahp); + + return 0; +} + +static void emac_init_rings(struct net_device *dev) +{ + struct ocp_enet_private *ep = dev->priv; + int loop; + + ep->tx_desc = (struct mal_descriptor *)((char *)ep->mal->tx_virt_addr + + (ep->mal_tx_chan * + MAL_DT_ALIGN)); + ep->rx_desc = + (struct mal_descriptor *)((char *)ep->mal->rx_virt_addr + + (ep->mal_rx_chan * MAL_DT_ALIGN)); + + /* Fill in the transmit descriptor ring. */ + for (loop = 0; loop < NUM_TX_BUFF; loop++) { + if (ep->tx_skb[loop]) { + dma_unmap_single(&ep->ocpdev->dev, + ep->tx_desc[loop].data_ptr, + ep->tx_desc[loop].data_len, + DMA_TO_DEVICE); + dev_kfree_skb_irq(ep->tx_skb[loop]); + } + ep->tx_skb[loop] = NULL; + ep->tx_desc[loop].ctrl = 0; + ep->tx_desc[loop].data_len = 0; + ep->tx_desc[loop].data_ptr = NULL; + } + ep->tx_desc[loop - 1].ctrl |= MAL_TX_CTRL_WRAP; + + /* Format the receive descriptor ring. */ + ep->rx_slot = 0; + /* Default is MTU=1500 + Ethernet overhead */ + ep->rx_buffer_size = ENET_DEF_BUF_SIZE; + emac_rx_fill(dev, 0); + if (ep->rx_slot != 0) { + printk(KERN_ERR + "%s: Not enough mem for RxChain durning Open?\n", + dev->name); + /*We couldn't fill the ring at startup? + *We could clean up and fail to open but right now we will try to + *carry on. It may be a sign of a bad NUM_RX_BUFF value + */ + } + + ep->tx_cnt = 0; + ep->tx_slot = 0; + ep->ack_slot = 0; +} + +static void emac_reset_configure(struct ocp_enet_private *fep) +{ + emac_t *emacp = fep->emacp; + int i; + + mal_disable_tx_channels(fep->mal, fep->commac.tx_chan_mask); + mal_disable_rx_channels(fep->mal, fep->commac.rx_chan_mask); + + /* + * Check for a link, some PHYs don't provide a clock if + * no link is present. Some EMACs will not come out of + * soft reset without a PHY clock present. + */ + if (fep->phy_mii.def->ops->poll_link(&fep->phy_mii)) { + /* Reset the EMAC */ + out_be32(&emacp->em0mr0, EMAC_M0_SRST); + udelay(20); + for (i = 0; i < 100; i++) { + if ((in_be32(&emacp->em0mr0) & EMAC_M0_SRST) == 0) + break; + udelay(10); + } + + if (i >= 100) { + printk(KERN_ERR "%s: Cannot reset EMAC\n", + fep->ndev->name); + return; + } + } + + /* Switch IRQs off for now */ + out_be32(&emacp->em0iser, 0); + + /* Configure MAL rx channel */ + mal_set_rcbs(fep->mal, fep->mal_rx_chan, DESC_BUF_SIZE_REG); + + /* set the high address */ + out_be32(&emacp->em0iahr, + (fep->ndev->dev_addr[0] << 8) | fep->ndev->dev_addr[1]); + + /* set the low address */ + out_be32(&emacp->em0ialr, + (fep->ndev->dev_addr[2] << 24) | (fep->ndev->dev_addr[3] << 16) + | (fep->ndev->dev_addr[4] << 8) | fep->ndev->dev_addr[5]); + + /* Adjust to link */ + if (netif_carrier_ok(fep->ndev)) + emac_adjust_to_link(fep); + + /* enable broadcast/individual address and RX FIFO defaults */ + out_be32(&emacp->em0rmr, EMAC_RMR_DEFAULT); + + /* set transmit request threshold register */ + out_be32(&emacp->em0trtr, EMAC_TRTR_DEFAULT); + + /* Reconfigure multicast */ + __emac_set_multicast_list(fep->ndev); + + /* Set receiver/transmitter defaults */ + out_be32(&emacp->em0rwmr, EMAC_RWMR_DEFAULT); + out_be32(&emacp->em0tmr0, EMAC_TMR0_DEFAULT); + out_be32(&emacp->em0tmr1, EMAC_TMR1_DEFAULT); + + /* set frame gap */ + out_be32(&emacp->em0ipgvr, CONFIG_IBM_EMAC_FGAP); + + /* Init ring buffers */ + emac_init_rings(fep->ndev); +} + +static void emac_kick(struct ocp_enet_private *fep) +{ + emac_t *emacp = fep->emacp; + unsigned long emac_ier; + + emac_ier = EMAC_ISR_PP | EMAC_ISR_BP | EMAC_ISR_RP | + EMAC_ISR_SE | EMAC_ISR_PTLE | EMAC_ISR_ALE | + EMAC_ISR_BFCS | EMAC_ISR_ORE | EMAC_ISR_IRE; + + out_be32(&emacp->em0iser, emac_ier); + + /* enable all MAL transmit and receive channels */ + mal_enable_tx_channels(fep->mal, fep->commac.tx_chan_mask); + mal_enable_rx_channels(fep->mal, fep->commac.rx_chan_mask); + + /* set transmit and receive enable */ + out_be32(&emacp->em0mr0, EMAC_M0_TXE | EMAC_M0_RXE); +} + +static void +emac_start_link(struct ocp_enet_private *fep, struct ethtool_cmd *ep) +{ + u32 advertise; + int autoneg; + int forced_speed; + int forced_duplex; + + /* Default advertise */ + advertise = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full | + ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full | + ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full; + autoneg = fep->want_autoneg; + forced_speed = fep->phy_mii.speed; + forced_duplex = fep->phy_mii.duplex; + + /* Setup link parameters */ + if (ep) { + if (ep->autoneg == AUTONEG_ENABLE) { + advertise = ep->advertising; + autoneg = 1; + } else { + autoneg = 0; + forced_speed = ep->speed; + forced_duplex = ep->duplex; + } + } + + /* Configure PHY & start aneg */ + fep->want_autoneg = autoneg; + if (autoneg) { + LINK_DEBUG(("%s: start link aneg, advertise: 0x%x\n", + fep->ndev->name, advertise)); + fep->phy_mii.def->ops->setup_aneg(&fep->phy_mii, advertise); + } else { + LINK_DEBUG(("%s: start link forced, speed: %d, duplex: %d\n", + fep->ndev->name, forced_speed, forced_duplex)); + fep->phy_mii.def->ops->setup_forced(&fep->phy_mii, forced_speed, + forced_duplex); + } + fep->timer_ticks = 0; + mod_timer(&fep->link_timer, jiffies + HZ); +} + +static void emac_link_timer(unsigned long data) +{ + struct ocp_enet_private *fep = (struct ocp_enet_private *)data; + int link; + + if (fep->going_away) + return; + + spin_lock_irq(&fep->lock); + + link = fep->phy_mii.def->ops->poll_link(&fep->phy_mii); + LINK_DEBUG(("%s: poll_link: %d\n", fep->ndev->name, link)); + + if (link == netif_carrier_ok(fep->ndev)) { + if (!link && fep->want_autoneg && (++fep->timer_ticks) > 10) + emac_start_link(fep, NULL); + goto out; + } + printk(KERN_INFO "%s: Link is %s\n", fep->ndev->name, + link ? "Up" : "Down"); + if (link) { + netif_carrier_on(fep->ndev); + /* Chip needs a full reset on config change. That sucks, so I + * should ultimately move that to some tasklet to limit + * latency peaks caused by this code + */ + emac_reset_configure(fep); + if (fep->opened) + emac_kick(fep); + } else { + fep->timer_ticks = 0; + netif_carrier_off(fep->ndev); + } + out: + mod_timer(&fep->link_timer, jiffies + HZ); + spin_unlock_irq(&fep->lock); +} + +static void emac_set_multicast_list(struct net_device *dev) +{ + struct ocp_enet_private *fep = dev->priv; + + spin_lock_irq(&fep->lock); + __emac_set_multicast_list(dev); + spin_unlock_irq(&fep->lock); +} + +static int emac_get_settings(struct net_device *ndev, struct ethtool_cmd *cmd) +{ + struct ocp_enet_private *fep = ndev->priv; + + cmd->supported = fep->phy_mii.def->features; + cmd->port = PORT_MII; + cmd->transceiver = XCVR_EXTERNAL; + cmd->phy_address = fep->mii_phy_addr; + spin_lock_irq(&fep->lock); + cmd->autoneg = fep->want_autoneg; + cmd->speed = fep->phy_mii.speed; + cmd->duplex = fep->phy_mii.duplex; + spin_unlock_irq(&fep->lock); + return 0; +} + +static int emac_set_settings(struct net_device *ndev, struct ethtool_cmd *cmd) +{ + struct ocp_enet_private *fep = ndev->priv; + unsigned long features = fep->phy_mii.def->features; + + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + + if (cmd->autoneg != AUTONEG_ENABLE && cmd->autoneg != AUTONEG_DISABLE) + return -EINVAL; + if (cmd->autoneg == AUTONEG_ENABLE && cmd->advertising == 0) + return -EINVAL; + if (cmd->duplex != DUPLEX_HALF && cmd->duplex != DUPLEX_FULL) + return -EINVAL; + if (cmd->autoneg == AUTONEG_DISABLE) + switch (cmd->speed) { + case SPEED_10: + if (cmd->duplex == DUPLEX_HALF && + (features & SUPPORTED_10baseT_Half) == 0) + return -EINVAL; + if (cmd->duplex == DUPLEX_FULL && + (features & SUPPORTED_10baseT_Full) == 0) + return -EINVAL; + break; + case SPEED_100: + if (cmd->duplex == DUPLEX_HALF && + (features & SUPPORTED_100baseT_Half) == 0) + return -EINVAL; + if (cmd->duplex == DUPLEX_FULL && + (features & SUPPORTED_100baseT_Full) == 0) + return -EINVAL; + break; + case SPEED_1000: + if (cmd->duplex == DUPLEX_HALF && + (features & SUPPORTED_1000baseT_Half) == 0) + return -EINVAL; + if (cmd->duplex == DUPLEX_FULL && + (features & SUPPORTED_1000baseT_Full) == 0) + return -EINVAL; + break; + default: + return -EINVAL; + } else if ((features & SUPPORTED_Autoneg) == 0) + return -EINVAL; + spin_lock_irq(&fep->lock); + emac_start_link(fep, cmd); + spin_unlock_irq(&fep->lock); + return 0; +} + +static void +emac_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *info) +{ + struct ocp_enet_private *fep = ndev->priv; + + strcpy(info->driver, DRV_NAME); + strcpy(info->version, DRV_VERSION); + info->fw_version[0] = '\0'; + sprintf(info->bus_info, "IBM EMAC %d", fep->ocpdev->def->index); + info->regdump_len = 0; +} + +static int emac_nway_reset(struct net_device *ndev) +{ + struct ocp_enet_private *fep = ndev->priv; + + if (!fep->want_autoneg) + return -EINVAL; + spin_lock_irq(&fep->lock); + emac_start_link(fep, NULL); + spin_unlock_irq(&fep->lock); + return 0; +} + +static u32 emac_get_link(struct net_device *ndev) +{ + return netif_carrier_ok(ndev); +} + +static struct ethtool_ops emac_ethtool_ops = { + .get_settings = emac_get_settings, + .set_settings = emac_set_settings, + .get_drvinfo = emac_get_drvinfo, + .nway_reset = emac_nway_reset, + .get_link = emac_get_link +}; + +static int emac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +{ + struct ocp_enet_private *fep = dev->priv; + uint *data = (uint *) & rq->ifr_data; + + switch (cmd) { + case SIOCGMIIPHY: + data[0] = fep->mii_phy_addr; + /* Fall through */ + case SIOCGMIIREG: + data[3] = emac_phy_read(dev, fep->mii_phy_addr, data[1]); + return 0; + case SIOCSMIIREG: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + + emac_phy_write(dev, fep->mii_phy_addr, data[1], data[2]); + return 0; + default: + return -EOPNOTSUPP; + } +} + +static int emac_open(struct net_device *dev) +{ + struct ocp_enet_private *fep = dev->priv; + int rc; + + spin_lock_irq(&fep->lock); + + fep->opened = 1; + netif_carrier_off(dev); + + /* Reset & configure the chip */ + emac_reset_configure(fep); + + spin_unlock_irq(&fep->lock); + + /* Request our interrupt lines */ + rc = request_irq(dev->irq, emac_mac_irq, 0, "IBM EMAC MAC", dev); + if (rc != 0) { + printk("dev->irq %d failed\n", dev->irq); + goto bail; + } + /* Kick the chip rx & tx channels into life */ + spin_lock_irq(&fep->lock); + emac_kick(fep); + spin_unlock_irq(&fep->lock); + + netif_start_queue(dev); + bail: + return rc; +} + +static int emac_close(struct net_device *dev) +{ + struct ocp_enet_private *fep = dev->priv; + emac_t *emacp = fep->emacp; + + /* XXX Stop IRQ emitting here */ + spin_lock_irq(&fep->lock); + fep->opened = 0; + mal_disable_tx_channels(fep->mal, fep->commac.tx_chan_mask); + mal_disable_rx_channels(fep->mal, fep->commac.rx_chan_mask); + netif_carrier_off(dev); + netif_stop_queue(dev); + + /* + * Check for a link, some PHYs don't provide a clock if + * no link is present. Some EMACs will not come out of + * soft reset without a PHY clock present. + */ + if (fep->phy_mii.def->ops->poll_link(&fep->phy_mii)) { + out_be32(&emacp->em0mr0, EMAC_M0_SRST); + udelay(10); + + if (emacp->em0mr0 & EMAC_M0_SRST) { + /*not sure what to do here hopefully it clears before another open */ + printk(KERN_ERR + "%s: Phy SoftReset didn't clear, no link?\n", + dev->name); + } + } + + /* Free the irq's */ + free_irq(dev->irq, dev); + + spin_unlock_irq(&fep->lock); + + return 0; +} + +static void emac_remove(struct ocp_device *ocpdev) +{ + struct net_device *dev = ocp_get_drvdata(ocpdev); + struct ocp_enet_private *ep = dev->priv; + + /* FIXME: locking, races, ... */ + ep->going_away = 1; + ocp_set_drvdata(ocpdev, NULL); + if (ep->rgmii_dev) + emac_close_rgmii(ep->rgmii_dev); + if (ep->zmii_dev) + emac_close_zmii(ep->zmii_dev); + + unregister_netdev(dev); + del_timer_sync(&ep->link_timer); + mal_unregister_commac(ep->mal, &ep->commac); + iounmap((void *)ep->emacp); + kfree(dev); +} + +struct mal_commac_ops emac_commac_ops = { + .txeob = &emac_txeob_dev, + .txde = &emac_txde_dev, + .rxeob = &emac_rxeob_dev, + .rxde = &emac_rxde_dev, +}; + +static int emac_init_device(struct ocp_device *ocpdev, struct ibm_ocp_mal *mal) +{ + int deferred_init = 0; + int rc = 0, i; + struct net_device *ndev; + struct ocp_enet_private *ep; + struct ocp_func_emac_data *emacdata; + int commac_reg = 0; + u32 phy_map; + + emacdata = (struct ocp_func_emac_data *)ocpdev->def->additions; + if (!emacdata) { + printk(KERN_ERR "emac%d: Missing additional data!\n", + ocpdev->def->index); + return -ENODEV; + } + + /* Allocate our net_device structure */ + ndev = alloc_etherdev(sizeof(struct ocp_enet_private)); + if (ndev == NULL) { + printk(KERN_ERR + "emac%d: Could not allocate ethernet device.\n", + ocpdev->def->index); + return -ENOMEM; + } + ep = ndev->priv; + ep->ndev = ndev; + ep->ocpdev = ocpdev; + ndev->irq = ocpdev->def->irq; + ep->wol_irq = emacdata->wol_irq; + if (emacdata->mdio_idx >= 0) { + if (emacdata->mdio_idx == ocpdev->def->index) { + /* Set the common MDIO net_device */ + mdio_ndev = ndev; + deferred_init = 1; + } + ep->mdio_dev = mdio_ndev; + } else { + ep->mdio_dev = ndev; + } + + ocp_set_drvdata(ocpdev, ndev); + + spin_lock_init(&ep->lock); + + /* Fill out MAL informations and register commac */ + ep->mal = mal; + ep->mal_tx_chan = emacdata->mal_tx_chan; + ep->mal_rx_chan = emacdata->mal_rx_chan; + ep->commac.ops = &emac_commac_ops; + ep->commac.dev = ndev; + ep->commac.tx_chan_mask = MAL_CHAN_MASK(ep->mal_tx_chan); + ep->commac.rx_chan_mask = MAL_CHAN_MASK(ep->mal_rx_chan); + rc = mal_register_commac(ep->mal, &ep->commac); + if (rc != 0) + goto bail; + commac_reg = 1; + + /* Map our MMIOs */ + ep->emacp = (emac_t *) ioremap(ocpdev->def->paddr, sizeof(emac_t)); + + /* Check if we need to attach to a ZMII */ + if (emacdata->zmii_idx >= 0) { + ep->zmii_input = emacdata->zmii_mux; + ep->zmii_dev = + ocp_find_device(OCP_ANY_ID, OCP_FUNC_ZMII, + emacdata->zmii_idx); + if (ep->zmii_dev == NULL) + printk(KERN_WARNING + "emac%d: ZMII %d requested but not found !\n", + ocpdev->def->index, emacdata->zmii_idx); + else if ((rc = + emac_init_zmii(ep->zmii_dev, ep->zmii_input, + emacdata->phy_mode)) != 0) + goto bail; + } + + /* Check if we need to attach to a RGMII */ + if (emacdata->rgmii_idx >= 0) { + ep->rgmii_input = emacdata->rgmii_mux; + ep->rgmii_dev = + ocp_find_device(OCP_ANY_ID, OCP_FUNC_RGMII, + emacdata->rgmii_idx); + if (ep->rgmii_dev == NULL) + printk(KERN_WARNING + "emac%d: RGMII %d requested but not found !\n", + ocpdev->def->index, emacdata->rgmii_idx); + else if ((rc = + emac_init_rgmii(ep->rgmii_dev, ep->rgmii_input, + emacdata->phy_mode)) != 0) + goto bail; + } + + /* Check if we need to attach to a TAH */ + if (emacdata->tah_idx >= 0) { + ep->tah_dev = + ocp_find_device(OCP_ANY_ID, OCP_FUNC_TAH, + emacdata->tah_idx); + if (ep->tah_dev == NULL) + printk(KERN_WARNING + "emac%d: TAH %d requested but not found !\n", + ocpdev->def->index, emacdata->tah_idx); + else if ((rc = emac_init_tah(ep)) != 0) + goto bail; + } + + if (deferred_init) { + if (!list_empty(&emac_init_list)) { + struct list_head *entry; + struct emac_def_dev *ddev; + + list_for_each(entry, &emac_init_list) { + ddev = + list_entry(entry, struct emac_def_dev, + link); + emac_init_device(ddev->ocpdev, ddev->mal); + } + } + } + + /* Init link monitoring timer */ + init_timer(&ep->link_timer); + ep->link_timer.function = emac_link_timer; + ep->link_timer.data = (unsigned long)ep; + ep->timer_ticks = 0; + + /* Fill up the mii_phy structure */ + ep->phy_mii.dev = ndev; + ep->phy_mii.mdio_read = emac_phy_read; + ep->phy_mii.mdio_write = emac_phy_write; + ep->phy_mii.mode = emacdata->phy_mode; + + /* Find PHY */ + phy_map = emacdata->phy_map | busy_phy_map; + for (i = 0; i <= 0x1f; i++, phy_map >>= 1) { + if ((phy_map & 0x1) == 0) { + int val = emac_phy_read(ndev, i, MII_BMCR); + if (val != 0xffff && val != -1) + break; + } + } + if (i == 0x20) { + printk(KERN_WARNING "emac%d: Can't find PHY.\n", + ocpdev->def->index); + rc = -ENODEV; + goto bail; + } + busy_phy_map |= 1 << i; + ep->mii_phy_addr = i; + rc = mii_phy_probe(&ep->phy_mii, i); + if (rc) { + printk(KERN_WARNING "emac%d: Failed to probe PHY type.\n", + ocpdev->def->index); + rc = -ENODEV; + goto bail; + } + + /* Setup initial PHY config & startup aneg */ + if (ep->phy_mii.def->ops->init) + ep->phy_mii.def->ops->init(&ep->phy_mii); + netif_carrier_off(ndev); + if (ep->phy_mii.def->features & SUPPORTED_Autoneg) + ep->want_autoneg = 1; + emac_start_link(ep, NULL); + + /* read the MAC Address */ + for (i = 0; i < 6; i++) + ndev->dev_addr[i] = emacdata->mac_addr[i]; + + /* Fill in the driver function table */ + ndev->open = &emac_open; + ndev->hard_start_xmit = &emac_start_xmit; + ndev->stop = &emac_close; + ndev->get_stats = &emac_stats; + if (emacdata->jumbo) + ndev->change_mtu = &emac_change_mtu; + ndev->set_mac_address = &emac_set_mac_address; + ndev->set_multicast_list = &emac_set_multicast_list; + ndev->do_ioctl = &emac_ioctl; + SET_ETHTOOL_OPS(ndev, &emac_ethtool_ops); + if (emacdata->tah_idx >= 0) + ndev->features = NETIF_F_IP_CSUM | NETIF_F_SG; + + SET_MODULE_OWNER(ndev); + + rc = register_netdev(ndev); + if (rc != 0) + goto bail; + + printk("%s: IBM emac, MAC %02x:%02x:%02x:%02x:%02x:%02x\n", + ndev->name, + ndev->dev_addr[0], ndev->dev_addr[1], ndev->dev_addr[2], + ndev->dev_addr[3], ndev->dev_addr[4], ndev->dev_addr[5]); + printk(KERN_INFO "%s: Found %s PHY (0x%02x)\n", + ndev->name, ep->phy_mii.def->name, ep->mii_phy_addr); + + bail: + if (rc && commac_reg) + mal_unregister_commac(ep->mal, &ep->commac); + if (rc && ndev) + kfree(ndev); + + return rc; +} + +static int emac_probe(struct ocp_device *ocpdev) +{ + struct ocp_device *maldev; + struct ibm_ocp_mal *mal; + struct ocp_func_emac_data *emacdata; + + emacdata = (struct ocp_func_emac_data *)ocpdev->def->additions; + if (emacdata == NULL) { + printk(KERN_ERR "emac%d: Missing additional datas !\n", + ocpdev->def->index); + return -ENODEV; + } + + /* Get the MAL device */ + maldev = ocp_find_device(OCP_ANY_ID, OCP_FUNC_MAL, emacdata->mal_idx); + if (maldev == NULL) { + printk("No maldev\n"); + return -ENODEV; + } + /* + * Get MAL driver data, it must be here due to link order. + * When the driver is modularized, symbol dependencies will + * ensure the MAL driver is already present if built as a + * module. + */ + mal = (struct ibm_ocp_mal *)ocp_get_drvdata(maldev); + if (mal == NULL) { + printk("No maldrv\n"); + return -ENODEV; + } + + /* If we depend on another EMAC for MDIO, wait for it to show up */ + if (emacdata->mdio_idx >= 0 && + (emacdata->mdio_idx != ocpdev->def->index) && !mdio_ndev) { + struct emac_def_dev *ddev; + /* Add this index to the deferred init table */ + ddev = kmalloc(sizeof(struct emac_def_dev), GFP_KERNEL); + ddev->ocpdev = ocpdev; + ddev->mal = mal; + list_add_tail(&ddev->link, &emac_init_list); + } else { + emac_init_device(ocpdev, mal); + } + + return 0; +} + +/* Structure for a device driver */ +static struct ocp_device_id emac_ids[] = { + {.vendor = OCP_ANY_ID,.function = OCP_FUNC_EMAC}, + {.vendor = OCP_VENDOR_INVALID} +}; + +static struct ocp_driver emac_driver = { + .name = "emac", + .id_table = emac_ids, + + .probe = emac_probe, + .remove = emac_remove, +}; + +static int __init emac_init(void) +{ + int rc; + + printk(KERN_INFO DRV_NAME ": " DRV_DESC ", version " DRV_VERSION "\n"); + printk(KERN_INFO "Maintained by " DRV_AUTHOR "\n"); + + if (skb_res > 2) { + printk(KERN_WARNING "Invalid skb_res: %d, cropping to 2\n", + skb_res); + skb_res = 2; + } + rc = ocp_register_driver(&emac_driver); + if (rc < 0) { + ocp_unregister_driver(&emac_driver); + return -ENODEV; + } + + return 0; +} + +static void __exit emac_exit(void) +{ + ocp_unregister_driver(&emac_driver); +} + +module_init(emac_init); +module_exit(emac_exit); diff --git a/drivers/net/ibm_emac/ibm_emac_phy.h b/drivers/net/ibm_emac/ibm_emac_phy.h new file mode 100644 index 000000000..61afbea96 --- /dev/null +++ b/drivers/net/ibm_emac/ibm_emac_phy.h @@ -0,0 +1,137 @@ + +/* + * ibm_emac_phy.h + * + * + * Benjamin Herrenschmidt + * February 2003 + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by 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. + * + * + * This file basically duplicates sungem_phy.{c,h} with different PHYs + * supported. I'm looking into merging that in a single mii layer more + * flexible than mii.c + */ + +#ifndef _IBM_EMAC_PHY_H_ +#define _IBM_EMAC_PHY_H_ + +/* + * PHY mode settings + * Used for multi-mode capable PHYs + */ +#define PHY_MODE_NA 0 +#define PHY_MODE_MII 1 +#define PHY_MODE_RMII 2 +#define PHY_MODE_SMII 3 +#define PHY_MODE_RGMII 4 +#define PHY_MODE_TBI 5 +#define PHY_MODE_GMII 6 +#define PHY_MODE_RTBI 7 +#define PHY_MODE_SGMII 8 + +/* + * PHY specific registers/values + */ + +/* CIS8201 */ +#define MII_CIS8201_EPCR 0x17 +#define EPCR_MODE_MASK 0x3000 +#define EPCR_GMII_MODE 0x0000 +#define EPCR_RGMII_MODE 0x1000 +#define EPCR_TBI_MODE 0x2000 +#define EPCR_RTBI_MODE 0x3000 + +struct mii_phy; + +/* Operations supported by any kind of PHY */ +struct mii_phy_ops { + int (*init) (struct mii_phy * phy); + int (*suspend) (struct mii_phy * phy, int wol_options); + int (*setup_aneg) (struct mii_phy * phy, u32 advertise); + int (*setup_forced) (struct mii_phy * phy, int speed, int fd); + int (*poll_link) (struct mii_phy * phy); + int (*read_link) (struct mii_phy * phy); +}; + +/* Structure used to statically define an mii/gii based PHY */ +struct mii_phy_def { + u32 phy_id; /* Concatenated ID1 << 16 | ID2 */ + u32 phy_id_mask; /* Significant bits */ + u32 features; /* Ethtool SUPPORTED_* defines */ + int magic_aneg; /* Autoneg does all speed test for us */ + const char *name; + const struct mii_phy_ops *ops; +}; + +/* An instance of a PHY, partially borrowed from mii_if_info */ +struct mii_phy { + struct mii_phy_def *def; + int advertising; + int mii_id; + + /* 1: autoneg enabled, 0: disabled */ + int autoneg; + + /* forced speed & duplex (no autoneg) + * partner speed & duplex & pause (autoneg) + */ + int speed; + int duplex; + int pause; + + /* PHY mode - if needed */ + int mode; + + /* Provided by host chip */ + struct net_device *dev; + int (*mdio_read) (struct net_device * dev, int mii_id, int reg); + void (*mdio_write) (struct net_device * dev, int mii_id, int reg, + int val); +}; + +/* Pass in a struct mii_phy with dev, mdio_read and mdio_write + * filled, the remaining fields will be filled on return + */ +extern int mii_phy_probe(struct mii_phy *phy, int mii_id); + +static inline int __phy_read(struct mii_phy *phy, int id, int reg) +{ + return phy->mdio_read(phy->dev, id, reg); +} + +static inline void __phy_write(struct mii_phy *phy, int id, int reg, int val) +{ + phy->mdio_write(phy->dev, id, reg, val); +} + +static inline int phy_read(struct mii_phy *phy, int reg) +{ + return phy->mdio_read(phy->dev, phy->mii_id, reg); +} + +static inline void phy_write(struct mii_phy *phy, int reg, int val) +{ + phy->mdio_write(phy->dev, phy->mii_id, reg, val); +} + +#endif /* _IBM_EMAC_PHY_H_ */ diff --git a/drivers/net/rcif.h b/drivers/net/rcif.h deleted file mode 100644 index 85ff8615c..000000000 --- a/drivers/net/rcif.h +++ /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 buffer reference - ** +-----------------------+ - ** | 1 | one segment buffer - ** +-----------------------+ _ - ** | | size \ - ** +-----------------------+ \ segment descriptor - ** | | 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 index 14bd88ab2..000000000 --- a/drivers/net/rclanmtl.c +++ /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 index 9488c0fd5..000000000 --- a/drivers/net/rclanmtl.h +++ /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 -#ifdef RC_LINUX_MODULE /* linux modules need non-library version of string functions */ -#include -#else -#include -#endif -#include /* for udelay() */ - -#include -#include -#include -#include - -#include - -/* 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 buffer reference -** +-----------------------+ -** | 1 | one segment buffer -** +-----------------------+ _ -** | | size \ -** +-----------------------+ \ segment descriptor -** | | 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 index 76b63f31b..000000000 --- a/drivers/net/rcpci45.c +++ /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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include /* For NR_IRQS only. */ -#include -#include - -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; -} diff --git a/drivers/net/wan/comx-hw-comx.c b/drivers/net/wan/comx-hw-comx.c deleted file mode 100644 index a62fe5514..000000000 --- a/drivers/net/wan/comx-hw-comx.c +++ /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 , - * Peter Bajan , - * Rewritten by: Tivadar Szemethy - * Currently maintained by: Gergely Madarasz - * - * Copyright (C) 1995-2000 ITConsult-Pro Co. - * - * Contributors: - * Arnaldo Carvalho de Melo - 0.86 - * Daniele Bellucci - 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 -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "comx.h" -#include "comxhw.h" - -MODULE_AUTHOR("Gergely Madarasz , Tivadar Szemethy , 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 index 52460164a..000000000 --- a/drivers/net/wan/comx-hw-locomx.c +++ /dev/null @@ -1,496 +0,0 @@ -/* - * Hardware driver for the LoCOMX card, using the generic z85230 - * functions - * - * Author: Gergely Madarasz - * - * Based on skeleton code and old LoCOMX driver by Tivadar Szemethy - * and the hostess_sv11 driver - * - * Contributors: - * Arnaldo Carvalho de Melo (0.14) - * - * Copyright (C) 1999 ITConsult-Pro Co. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the 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 -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "comx.h" -#include "z85230.h" - -MODULE_AUTHOR("Gergely Madarasz "); -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 index c6fb9ac67..000000000 --- a/drivers/net/wan/comx-hw-mixcom.c +++ /dev/null @@ -1,960 +0,0 @@ -/* - * Hardware driver for the MixCom synchronous serial board - * - * Author: Gergely Madarasz - * - * based on skeleton driver code and a preliminary hscx driver by - * Tivadar Szemethy - * - * Copyright (C) 1998-1999 ITConsult-Pro Co. - * - * Contributors: - * Arnaldo Carvalho de Melo (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 -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "comx.h" -#include "mixcom.h" -#include "hscx.h" - -MODULE_AUTHOR("Gergely Madarasz "); -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 index 195bc2d25..000000000 --- a/drivers/net/wan/comx-hw-munich.c +++ /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 - * - * Original author: Bartok Istvan - * Based on skeleton by Tivadar Szemethy - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#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 , Gergely Madarasz , Szilard Pasztor "); -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 index c9551366b..000000000 --- a/drivers/net/wan/comx-proto-fr.c +++ /dev/null @@ -1,1014 +0,0 @@ -/* - * Frame-relay protocol module for the COMX driver - * for Linux 2.2.X - * - * Original author: Tivadar Szemethy - * Maintainer: Gergely Madarasz - * - * Copyright (C) 1998-1999 ITConsult-Pro Co. - * - * Contributors: - * Arnaldo Carvalho de Melo (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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "comx.h" -#include "comxhw.h" - -MODULE_AUTHOR("Author: Tivadar Szemethy "); -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 index b203ff689..000000000 --- a/drivers/net/wan/comx-proto-lapb.c +++ /dev/null @@ -1,551 +0,0 @@ -/* - * LAPB protocol module for the COMX driver - * for Linux kernel 2.2.X - * - * Original author: Tivadar Szemethy - * Maintainer: Gergely Madarasz - * - * Copyright (C) 1997-1999 (C) ITConsult-Pro Co. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#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 index 3f4501014..000000000 --- a/drivers/net/wan/comx-proto-ppp.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Synchronous PPP / Cisco-HDLC driver for the COMX boards - * - * Author: Gergely Madarasz - * - * based on skeleton code by Tivadar Szemethy - * - * Copyright (C) 1999 ITConsult-Pro Co. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "comx.h" - -MODULE_AUTHOR("Author: Gergely Madarasz "); -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 index 6c0e3fcd2..000000000 --- a/drivers/net/wan/comx.c +++ /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 , - * Peter Bajan , - * Previous maintainer: Tivadar Szemethy - * Current maintainer: Gergely Madarasz - * - * Copyright (C) 1995-1999 ITConsult-Pro Co. - * - * Contributors: - * Arnaldo Carvalho de Melo (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 -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_KMOD -#include -#endif - -#ifndef CONFIG_PROC_FS -#error For now, COMX really needs the /proc filesystem -#endif - -#include -#include "comx.h" - -MODULE_AUTHOR("Gergely Madarasz "); -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. \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 index 0f7404f21..000000000 --- a/drivers/net/wan/comx.h +++ /dev/null @@ -1,232 +0,0 @@ -/* - * General definitions for the COMX driver - * - * Original authors: Arpad Bakay , - * Peter Bajan , - * Previous maintainer: Tivadar Szemethy - * Currently maintained by: Gergely Madarasz - * - * Copyright (C) 1995-1999 ITConsult-Pro Co. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the 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 - -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 index 15230dc1f..000000000 --- a/drivers/net/wan/comxhw.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Defines for comxhw.c - * - * Original authors: Arpad Bakay , - * Peter Bajan , - * Previous maintainer: Tivadar Szemethy - * Current maintainer: Gergely Madarasz - * - * Copyright (C) 1995-1999 ITConsult-Pro Co. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the 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 index e30726c82..000000000 --- a/drivers/net/wan/falc-lh.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Defines for comx-hw-slicecom.c - FALC-LH specific - * - * Author: Bartok Istvan - * 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 index 675b7b1f1..000000000 --- a/drivers/net/wan/hscx.h +++ /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 index 1815eef75..000000000 --- a/drivers/net/wan/mixcom.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Defines for the mixcom board - * - * Author: Gergely Madarasz - * - * Copyright (C) 1999 ITConsult-Pro Co. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the 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 index 8f151f2ed..000000000 --- a/drivers/net/wan/munich32x.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Defines for comx-hw-slicecom.c - MUNICH32X specific - * - * Author: Bartok Istvan - * 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/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c new file mode 100644 index 000000000..d595ba757 --- /dev/null +++ b/drivers/pcmcia/pxa2xx_base.c @@ -0,0 +1,333 @@ +/*====================================================================== + + Device driver for the PCMCIA control functionality of PXA2xx + microprocessors. + + The contents of this file may be used under the + terms of the GNU Public License version 2 (the "GPL") + + (c) Ian Molton (spyro@f2s.com) 2003 + (c) Stefan Eletzhofer (stefan.eletzhofer@inquant.de) 2003,4 + + derived from sa11xx_base.c + + Portions created by John G. Dorsey are + Copyright (C) 1999 John G. Dorsey. + + ======================================================================*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "cs_internal.h" +#include "soc_common.h" +#include "pxa2xx_base.h" + + +#define MCXX_SETUP_MASK (0x7f) +#define MCXX_ASST_MASK (0x1f) +#define MCXX_HOLD_MASK (0x3f) +#define MCXX_SETUP_SHIFT (0) +#define MCXX_ASST_SHIFT (7) +#define MCXX_HOLD_SHIFT (14) + +static inline u_int pxa2xx_mcxx_hold(u_int pcmcia_cycle_ns, + u_int mem_clk_10khz) +{ + u_int code = pcmcia_cycle_ns * mem_clk_10khz; + return (code / 300000) + ((code % 300000) ? 1 : 0) - 1; +} + +static inline u_int pxa2xx_mcxx_asst(u_int pcmcia_cycle_ns, + u_int mem_clk_10khz) +{ + u_int code = pcmcia_cycle_ns * mem_clk_10khz; + return (code / 300000) + ((code % 300000) ? 1 : 0) - 1; +} + +static inline u_int pxa2xx_mcxx_setup(u_int pcmcia_cycle_ns, + u_int mem_clk_10khz) +{ + u_int code = pcmcia_cycle_ns * mem_clk_10khz; + return (code / 100000) + ((code % 100000) ? 1 : 0) - 1; +} + +/* This function returns the (approximate) command assertion period, in + * nanoseconds, for a given CPU clock frequency and MCXX_ASST value: + */ +static inline u_int pxa2xx_pcmcia_cmd_time(u_int mem_clk_10khz, + u_int pcmcia_mcxx_asst) +{ + return (300000 * (pcmcia_mcxx_asst + 1) / mem_clk_10khz); +} + +static int pxa2xx_pcmcia_set_mcmem( int sock, int speed, int clock ) +{ + MCMEM(sock) = ((pxa2xx_mcxx_setup(speed, clock) + & MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT) + | ((pxa2xx_mcxx_asst(speed, clock) + & MCXX_ASST_MASK) << MCXX_ASST_SHIFT) + | ((pxa2xx_mcxx_hold(speed, clock) + & MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT); + + return 0; +} + +static int pxa2xx_pcmcia_set_mcio( int sock, int speed, int clock ) +{ + MCIO(sock) = ((pxa2xx_mcxx_setup(speed, clock) + & MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT) + | ((pxa2xx_mcxx_asst(speed, clock) + & MCXX_ASST_MASK) << MCXX_ASST_SHIFT) + | ((pxa2xx_mcxx_hold(speed, clock) + & MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT); + + return 0; +} + +static int pxa2xx_pcmcia_set_mcatt( int sock, int speed, int clock ) +{ + MCATT(sock) = ((pxa2xx_mcxx_setup(speed, clock) + & MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT) + | ((pxa2xx_mcxx_asst(speed, clock) + & MCXX_ASST_MASK) << MCXX_ASST_SHIFT) + | ((pxa2xx_mcxx_hold(speed, clock) + & MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT); + + return 0; +} + +static int pxa2xx_pcmcia_set_mcxx(struct soc_pcmcia_socket *skt, unsigned int lclk) +{ + struct soc_pcmcia_timing timing; + int sock = skt->nr; + + soc_common_pcmcia_get_timing(skt, &timing); + + pxa2xx_pcmcia_set_mcmem(sock, timing.mem, lclk); + pxa2xx_pcmcia_set_mcatt(sock, timing.attr, lclk); + pxa2xx_pcmcia_set_mcio(sock, timing.io, lclk); + + return 0; +} + +static int pxa2xx_pcmcia_set_timing(struct soc_pcmcia_socket *skt) +{ + unsigned int lclk = get_lclk_frequency_10khz(); + return pxa2xx_pcmcia_set_mcxx(skt, lclk); +} + +int pxa2xx_drv_pcmcia_probe(struct device *dev) +{ + int ret; + struct pcmcia_low_level *ops; + int first, nr; + + if (!dev || !dev->platform_data) + return -ENODEV; + + ops = (struct pcmcia_low_level *)dev->platform_data; + first = ops->first; + nr = ops->nr; + + /* Setup GPIOs for PCMCIA/CF alternate function mode. + * + * It would be nice if set_GPIO_mode included support + * for driving GPIO outputs to default high/low state + * before programming GPIOs as outputs. Setting GPIO + * outputs to default high/low state via GPSR/GPCR + * before defining them as outputs should reduce + * the possibility of glitching outputs during GPIO + * setup. This of course assumes external terminators + * are present to hold GPIOs in a defined state. + * + * In the meantime, setup default state of GPIO + * outputs before we enable them as outputs. + */ + + GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) | + GPIO_bit(GPIO49_nPWE) | + GPIO_bit(GPIO50_nPIOR) | + GPIO_bit(GPIO51_nPIOW) | + GPIO_bit(GPIO52_nPCE_1) | + GPIO_bit(GPIO53_nPCE_2); + + pxa_gpio_mode(GPIO48_nPOE_MD); + pxa_gpio_mode(GPIO49_nPWE_MD); + pxa_gpio_mode(GPIO50_nPIOR_MD); + pxa_gpio_mode(GPIO51_nPIOW_MD); + pxa_gpio_mode(GPIO52_nPCE_1_MD); + pxa_gpio_mode(GPIO53_nPCE_2_MD); + pxa_gpio_mode(GPIO54_pSKTSEL_MD); /* REVISIT: s/b dependent on num sockets */ + pxa_gpio_mode(GPIO55_nPREG_MD); + pxa_gpio_mode(GPIO56_nPWAIT_MD); + pxa_gpio_mode(GPIO57_nIOIS16_MD); + + /* Provide our PXA2xx specific timing routines. */ + ops->set_timing = pxa2xx_pcmcia_set_timing; + + ret = soc_common_drv_pcmcia_probe(dev, ops, first, nr); + + if (ret == 0) { + /* + * We have at least one socket, so set MECR:CIT + * (Card Is There) + */ + MECR |= MECR_CIT; + + /* Set MECR:NOS (Number Of Sockets) */ + if (nr > 1) + MECR |= MECR_NOS; + else + MECR &= ~MECR_NOS; + } + + return ret; +} +EXPORT_SYMBOL(pxa2xx_drv_pcmcia_probe); + +static int pxa2xx_drv_pcmcia_suspend(struct device *dev, u32 state, u32 level) +{ + int ret = 0; + if (level == SUSPEND_SAVE_STATE) + ret = pcmcia_socket_dev_suspend(dev, state); + return ret; +} + +static int pxa2xx_drv_pcmcia_resume(struct device *dev, u32 level) +{ + int ret = 0; + if (level == RESUME_RESTORE_STATE) + ret = pcmcia_socket_dev_resume(dev); + return ret; +} + +static struct device_driver pxa2xx_pcmcia_driver = { + .probe = pxa2xx_drv_pcmcia_probe, + .remove = soc_common_drv_pcmcia_remove, + .suspend = pxa2xx_drv_pcmcia_suspend, + .resume = pxa2xx_drv_pcmcia_resume, + .name = "pxa2xx-pcmcia", + .bus = &platform_bus_type, +}; + +#ifdef CONFIG_CPU_FREQ + +/* + * When pxa2xx_pcmcia_notifier() decides that a MC{IO,MEM,ATT} adjustment (due + * to a core clock frequency change) is needed, this routine establishes + * new values consistent with the clock speed `clock'. + */ +static void pxa2xx_pcmcia_update_mcxx(unsigned int clock) +{ + struct soc_pcmcia_socket *skt; + + down(&soc_sockets_lock); + list_for_each_entry(skt, &soc_sockets, node) { + pxa2xx_pcmcia_set_mcxx(skt, clock); + } + up(&soc_sockets_lock); +} + +/* + * When changing the processor L clock frequency, it is necessary + * to adjust the MCXX 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 MCXX + * values. + * + * Returns: 0 on success, -1 on error + */ +static int +pxa2xx_pcmcia_notifier(struct notifier_block *nb, unsigned long val, void *data) +{ + struct cpufreq_freqs *freqs = data; + +#warning "it's not clear if this is right since the core CPU (N) clock has no effect on the memory (L) clock" + switch (val) { + case CPUFREQ_PRECHANGE: + if (freqs->new > freqs->old) { + debug( 2, "new frequency %u.%uMHz > %u.%uMHz, " + "pre-updating\n", + freqs->new / 1000, (freqs->new / 100) % 10, + freqs->old / 1000, (freqs->old / 100) % 10); + pxa2xx_pcmcia_update_mcxx(freqs->new); + } + break; + + case CPUFREQ_POSTCHANGE: + if (freqs->new < freqs->old) { + debug( 2, "new frequency %u.%uMHz < %u.%uMHz, " + "post-updating\n", + freqs->new / 1000, (freqs->new / 100) % 10, + freqs->old / 1000, (freqs->old / 100) % 10); + pxa2xx_pcmcia_update_mcxx(freqs->new); + } + break; + } + + return 0; +} + +static struct notifier_block pxa2xx_pcmcia_notifier_block = { + .notifier_call = pxa2xx_pcmcia_notifier +}; + +static int __init pxa2xx_pcmcia_cpufreq_init(void) +{ + int ret; + + ret = cpufreq_register_notifier(&pxa2xx_pcmcia_notifier_block, + CPUFREQ_TRANSITION_NOTIFIER); + if (ret < 0) + printk(KERN_ERR "Unable to register CPU frequency change " + "notifier for PCMCIA (%d)\n", ret); + return ret; +} + +static void __exit pxa2xx_pcmcia_cpufreq_exit(void) +{ + cpufreq_unregister_notifier(&pxa2xx_pcmcia_notifier_block, CPUFREQ_TRANSITION_NOTIFIER); +} + +#else +#define pxa2xx_pcmcia_cpufreq_init() +#define pxa2xx_pcmcia_cpufreq_exit() +#endif + +static int __init pxa2xx_pcmcia_init(void) +{ + int ret = driver_register(&pxa2xx_pcmcia_driver); + if (ret == 0) + pxa2xx_pcmcia_cpufreq_init(); + return ret; +} + +static void __exit pxa2xx_pcmcia_exit(void) +{ + pxa2xx_pcmcia_cpufreq_exit(); + driver_unregister(&pxa2xx_pcmcia_driver); +} + +module_init(pxa2xx_pcmcia_init); +module_exit(pxa2xx_pcmcia_exit); + +MODULE_AUTHOR("Stefan Eletzhofer and Ian Molton "); +MODULE_DESCRIPTION("Linux PCMCIA Card Services: PXA2xx core socket driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/pcmcia/pxa2xx_lubbock.c b/drivers/pcmcia/pxa2xx_lubbock.c new file mode 100644 index 000000000..c18f28605 --- /dev/null +++ b/drivers/pcmcia/pxa2xx_lubbock.c @@ -0,0 +1,236 @@ +/* + * linux/drivers/pcmcia/pxa2xx_lubbock.c + * + * 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/drivers/pcmcia/sa1100_neponset.c + * + * Lubbock PCMCIA specific routines. + * + */ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "sa1111_generic.h" + +static int +lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, + const socket_state_t *state) +{ + unsigned int pa_dwr_mask, pa_dwr_set, misc_mask, misc_set; + int ret = 0; + + pa_dwr_mask = pa_dwr_set = misc_mask = misc_set = 0; + + /* Lubbock uses the Maxim MAX1602, with the following connections: + * + * Socket 0 (PCMCIA): + * MAX1602 Lubbock Register + * Pin Signal + * ----- ------- ---------------------- + * A0VPP S0_PWR0 SA-1111 GPIO A<0> + * A1VPP S0_PWR1 SA-1111 GPIO A<1> + * A0VCC S0_PWR2 SA-1111 GPIO A<2> + * A1VCC S0_PWR3 SA-1111 GPIO A<3> + * VX VCC + * VY +3.3V + * 12IN +12V + * CODE +3.3V Cirrus Code, CODE = High (VY) + * + * Socket 1 (CF): + * MAX1602 Lubbock Register + * Pin Signal + * ----- ------- ---------------------- + * A0VPP GND VPP is not connected + * A1VPP GND VPP is not connected + * A0VCC S1_PWR0 MISC_WR<14> + * A1VCC S1_PWR1 MISC_WR<15> + * VX VCC + * VY +3.3V + * 12IN GND VPP is not connected + * CODE +3.3V Cirrus Code, CODE = High (VY) + * + */ + + again: + switch (skt->nr) { + case 0: + pa_dwr_mask = GPIO_A0 | GPIO_A1 | GPIO_A2 | GPIO_A3; + + switch (state->Vcc) { + case 0: /* Hi-Z */ + break; + + case 33: /* VY */ + pa_dwr_set |= GPIO_A3; + break; + + case 50: /* VX */ + pa_dwr_set |= GPIO_A2; + break; + + default: + printk(KERN_ERR "%s(): unrecognized Vcc %u\n", + __FUNCTION__, state->Vcc); + ret = -1; + } + + switch (state->Vpp) { + case 0: /* Hi-Z */ + break; + + case 120: /* 12IN */ + pa_dwr_set |= GPIO_A1; + break; + + default: /* VCC */ + if (state->Vpp == state->Vcc) + pa_dwr_set |= GPIO_A0; + else { + printk(KERN_ERR "%s(): unrecognized Vpp %u\n", + __FUNCTION__, state->Vpp); + ret = -1; + break; + } + } + break; + + case 1: + misc_mask = (1 << 15) | (1 << 14); + + switch (state->Vcc) { + case 0: /* Hi-Z */ + break; + + case 33: /* VY */ + misc_set |= 1 << 15; + break; + + case 50: /* VX */ + misc_set |= 1 << 14; + break; + + default: + printk(KERN_ERR "%s(): unrecognized Vcc %u\n", + __FUNCTION__, state->Vcc); + ret = -1; + break; + } + + if (state->Vpp != state->Vcc && state->Vpp != 0) { + printk(KERN_ERR "%s(): CF slot cannot support Vpp %u\n", + __FUNCTION__, state->Vpp); + ret = -1; + break; + } + break; + + default: + ret = -1; + } + + if (ret == 0) + ret = sa1111_pcmcia_configure_socket(skt, state); + + if (ret == 0) { + lubbock_set_misc_wr(misc_mask, misc_set); + sa1111_set_io(SA1111_DEV(skt->dev), pa_dwr_mask, pa_dwr_set); + } + +#if 1 + if (ret == 0 && state->Vcc == 33) { + struct pcmcia_state new_state; + + /* + * HACK ALERT: + * We can't sense the voltage properly on Lubbock before + * actually applying some power to the socket (catch 22). + * Resense the socket Voltage Sense pins after applying + * socket power. + * + * Note: It takes about 2.5ms for the MAX1602 VCC output + * to rise. + */ + mdelay(3); + + sa1111_pcmcia_socket_state(skt, &new_state); + + if (!new_state.vs_3v && !new_state.vs_Xv) { + /* + * Switch to 5V, Configure socket with 5V voltage + */ + lubbock_set_misc_wr(misc_mask, 0); + sa1111_set_io(SA1111_DEV(skt->dev), pa_dwr_mask, 0); + + /* + * It takes about 100ms to turn off Vcc. + */ + mdelay(100); + + /* + * We need to hack around the const qualifier as + * well to keep this ugly workaround localized and + * not force it to the rest of the code. Barf bags + * avaliable in the seat pocket in front of you! + */ + ((socket_state_t *)state)->Vcc = 50; + ((socket_state_t *)state)->Vpp = 50; + goto again; + } + } +#endif + + return ret; +} + +static struct pcmcia_low_level lubbock_pcmcia_ops = { + .owner = THIS_MODULE, + .hw_init = sa1111_pcmcia_hw_init, + .hw_shutdown = sa1111_pcmcia_hw_shutdown, + .socket_state = sa1111_pcmcia_socket_state, + .configure_socket = lubbock_pcmcia_configure_socket, + .socket_init = sa1111_pcmcia_socket_init, + .socket_suspend = sa1111_pcmcia_socket_suspend, + .first = 0, + .nr = 2, +}; + +#include "pxa2xx_base.h" + +int __init pcmcia_lubbock_init(struct sa1111_dev *sadev) +{ + int ret = -ENODEV; + + if (machine_is_lubbock()) { + /* + * Set GPIO_A<3:0> to be outputs for the MAX1600, + * and switch to standby mode. + */ + sa1111_set_io_dir(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0, 0); + sa1111_set_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); + sa1111_set_sleep_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); + + /* Set CF Socket 1 power to standby mode. */ + lubbock_set_misc_wr((1 << 15) | (1 << 14), 0); + + sadev->dev.platform_data = &lubbock_pcmcia_ops; + ret = pxa2xx_drv_pcmcia_probe(&sadev->dev); + } + + return ret; +} diff --git a/drivers/pcmcia/pxa2xx_mainstone.c b/drivers/pcmcia/pxa2xx_mainstone.c new file mode 100644 index 000000000..af85842ee --- /dev/null +++ b/drivers/pcmcia/pxa2xx_mainstone.c @@ -0,0 +1,176 @@ +/* + * linux/drivers/pcmcia/pxa2xx_mainstone.c + * + * Mainstone PCMCIA specific routines. + * + * Created: May 12, 2004 + * Author: Nicolas Pitre + * 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. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "soc_common.h" + + +static struct pcmcia_irqs irqs[] = { + { 0, MAINSTONE_S0_CD_IRQ, "PCMCIA0 CD" }, + { 1, MAINSTONE_S1_CD_IRQ, "PCMCIA1 CD" }, + { 0, MAINSTONE_S0_STSCHG_IRQ, "PCMCIA0 STSCHG" }, + { 1, MAINSTONE_S1_STSCHG_IRQ, "PCMCIA1 STSCHG" }, +}; + +static int mst_pcmcia_hw_init(struct soc_pcmcia_socket *skt) +{ + skt->irq = (skt->nr == 0) ? MAINSTONE_S0_IRQ : MAINSTONE_S1_IRQ; + return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); +} + +static void mst_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) +{ + soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); +} + +static unsigned long mst_pcmcia_status[2]; + +static void mst_pcmcia_socket_state(struct soc_pcmcia_socket *skt, + struct pcmcia_state *state) +{ + unsigned long status, flip; + + status = (skt->nr == 0) ? MST_PCMCIA0 : MST_PCMCIA1; + flip = (status ^ mst_pcmcia_status[skt->nr]) & MST_PCMCIA_nSTSCHG_BVD1; + + /* + * Workaround for STSCHG which can't be deasserted: + * We therefore disable/enable corresponding IRQs + * as needed to avoid IRQ locks. + */ + if (flip) { + mst_pcmcia_status[skt->nr] = status; + if (status & MST_PCMCIA_nSTSCHG_BVD1) + enable_irq( (skt->nr == 0) ? MAINSTONE_S0_STSCHG_IRQ + : MAINSTONE_S1_STSCHG_IRQ ); + else + disable_irq( (skt->nr == 0) ? MAINSTONE_S0_STSCHG_IRQ + : MAINSTONE_S1_STSCHG_IRQ ); + } + + state->detect = (status & MST_PCMCIA_nCD) ? 0 : 1; + state->ready = (status & MST_PCMCIA_nIRQ) ? 1 : 0; + state->bvd1 = (status & MST_PCMCIA_nSTSCHG_BVD1) ? 1 : 0; + state->bvd2 = (status & MST_PCMCIA_nSPKR_BVD2) ? 1 : 0; + state->vs_3v = (status & MST_PCMCIA_nVS1) ? 0 : 1; + state->vs_Xv = (status & MST_PCMCIA_nVS2) ? 0 : 1; + state->wrprot = 0; /* not available */ +} + +static int mst_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, + const socket_state_t *state) +{ + unsigned long power = 0; + int ret = 0; + + switch (state->Vcc) { + case 0: power |= MST_PCMCIA_PWR_VCC_0; break; + case 33: power |= MST_PCMCIA_PWR_VCC_33; break; + case 50: power |= MST_PCMCIA_PWR_VCC_50; break; + default: + printk(KERN_ERR "%s(): bad Vcc %u\n", + __FUNCTION__, state->Vcc); + ret = -1; + } + + switch (state->Vpp) { + case 0: power |= MST_PCMCIA_PWR_VPP_0; break; + case 120: power |= MST_PCMCIA_PWR_VPP_120; break; + default: + if(state->Vpp == state->Vcc) { + power |= MST_PCMCIA_PWR_VPP_VCC; + } else { + printk(KERN_ERR "%s(): bad Vpp %u\n", + __FUNCTION__, state->Vpp); + ret = -1; + } + } + + if (state->flags & SS_RESET) + power |= MST_PCMCIA_RESET; + + switch (skt->nr) { + case 0: MST_PCMCIA0 = power; break; + case 1: MST_PCMCIA1 = power; break; + default: ret = -1; + } + + return ret; +} + +static void mst_pcmcia_socket_init(struct soc_pcmcia_socket *skt) +{ +} + +static void mst_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) +{ +} + +static struct pcmcia_low_level mst_pcmcia_ops = { + .owner = THIS_MODULE, + .hw_init = mst_pcmcia_hw_init, + .hw_shutdown = mst_pcmcia_hw_shutdown, + .socket_state = mst_pcmcia_socket_state, + .configure_socket = mst_pcmcia_configure_socket, + .socket_init = mst_pcmcia_socket_init, + .socket_suspend = mst_pcmcia_socket_suspend, + .nr = 2, +}; + +static struct platform_device *mst_pcmcia_device; + +static int __init mst_pcmcia_init(void) +{ + int ret; + + mst_pcmcia_device = kmalloc(sizeof(*mst_pcmcia_device), GFP_KERNEL); + if (!mst_pcmcia_device) + return -ENOMEM; + memset(mst_pcmcia_device, 0, sizeof(*mst_pcmcia_device)); + mst_pcmcia_device->name = "pxa2xx-pcmcia"; + mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops; + + ret = platform_device_register(mst_pcmcia_device); + if (ret) + kfree(mst_pcmcia_device); + + return ret; +} + +static void __exit mst_pcmcia_exit(void) +{ + /* + * This call is supposed to free our mst_pcmcia_device. + * Unfortunately platform_device don't have a free method, and + * we can't assume it's free of any reference at this point so we + * can't free it either. + */ + platform_device_unregister(mst_pcmcia_device); +} + +module_init(mst_pcmcia_init); +module_exit(mst_pcmcia_exit); + +MODULE_LICENSE("GPL"); diff --git a/drivers/pcmcia/sa11xx_base.c b/drivers/pcmcia/sa11xx_base.c new file mode 100644 index 000000000..fb634ab5d --- /dev/null +++ b/drivers/pcmcia/sa11xx_base.c @@ -0,0 +1,242 @@ +/*====================================================================== + + 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 + . 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. + +======================================================================*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "soc_common.h" +#include "sa11xx_base.h" + + +/* + * 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 soc_pcmcia_socket *skt, + unsigned int cpu_speed, + unsigned int cmd_time) +{ + return sa1100_pcmcia_mecr_bs(cmd_time, cpu_speed); +} + +/* sa1100_pcmcia_set_mecr() + * ^^^^^^^^^^^^^^^^^^^^^^^^ + * + * set MECR value for socket 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 soc_pcmcia_socket *skt, unsigned int cpu_clock) +{ + struct soc_pcmcia_timing timing; + u32 mecr, old_mecr; + unsigned long flags; + unsigned int bs_io, bs_mem, bs_attr; + + soc_common_pcmcia_get_timing(skt, &timing); + + bs_io = skt->ops->get_timing(skt, cpu_clock, timing.io); + bs_mem = skt->ops->get_timing(skt, cpu_clock, timing.mem); + bs_attr = skt->ops->get_timing(skt, cpu_clock, timing.attr); + + 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 int +sa1100_pcmcia_set_timing(struct soc_pcmcia_socket *skt) +{ + return sa1100_pcmcia_set_mecr(skt, cpufreq_get(0)); +} + +static int +sa1100_pcmcia_show_timing(struct soc_pcmcia_socket *skt, char *buf) +{ + struct soc_pcmcia_timing timing; + unsigned int clock = cpufreq_get(0); + unsigned long mecr = MECR; + char *p = buf; + + soc_common_pcmcia_get_timing(skt, &timing); + + p+=sprintf(p, "I/O : %u (%u)\n", timing.io, + sa1100_pcmcia_cmd_time(clock, MECR_BSIO_GET(mecr, skt->nr))); + + p+=sprintf(p, "attribute: %u (%u)\n", timing.attr, + sa1100_pcmcia_cmd_time(clock, MECR_BSA_GET(mecr, skt->nr))); + + p+=sprintf(p, "common : %u (%u)\n", timing.mem, + sa1100_pcmcia_cmd_time(clock, MECR_BSM_GET(mecr, skt->nr))); + + return p - buf; +} + +int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, + int first, int nr) +{ + /* + * set default MECR calculation if the board specific + * code did not specify one... + */ + if (!ops->get_timing) + ops->get_timing = sa1100_pcmcia_default_mecr_timing; + + /* Provide our SA11x0 specific timing routines. */ + ops->set_timing = sa1100_pcmcia_set_timing; + ops->show_timing = sa1100_pcmcia_show_timing; + + return soc_common_drv_pcmcia_probe(dev, ops, first, nr); +} +EXPORT_SYMBOL(sa11xx_drv_pcmcia_probe); + +#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 soc_pcmcia_socket *skt; + + down(&soc_pcmcia_sockets_lock); + list_for_each_entry(skt, &soc_pcmcia_sockets, node) + sa1100_pcmcia_set_mecr(skt, clock); + up(&soc_pcmcia_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; + case CPUFREQ_RESUMECHANGE: + 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 "); +MODULE_DESCRIPTION("Linux PCMCIA Card Services: SA-11xx core socket driver"); +MODULE_LICENSE("Dual MPL/GPL"); diff --git a/drivers/pcmcia/sa1100.h b/drivers/pcmcia/sa11xx_base.h similarity index 72% rename from drivers/pcmcia/sa1100.h rename to drivers/pcmcia/sa11xx_base.h index d2defe598..7bc208280 100644 --- a/drivers/pcmcia/sa1100.h +++ b/drivers/pcmcia/sa11xx_base.h @@ -27,23 +27,27 @@ 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 -#include -#include -#include -#include "cs_internal.h" -#include "sa1100_generic.h" +/* 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." + */ /* MECR: Expansion Memory Configuration Register * (SA-1100 Developers Manual, p.10-13; SA-1110 Developers Manual, p.10-24) * - * MECR layout is: + * MECR layout is: * * FAST1 BSM1<4:0> BSA1<4:0> BSIO1<4:0> FAST0 BSM0<4:0> BSA0<4:0> BSIO0<4:0> * @@ -105,7 +109,7 @@ static inline unsigned int sa1100_pcmcia_mecr_bs(unsigned int pcmcia_cycle_ns, return (t / 1000000) + (((t % 1000000) == 0) ? 0 : 1); } -/* This function returns the (approxmiate) command assertion period, in +/* This function returns the (approximate) 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, @@ -114,51 +118,6 @@ static inline unsigned int sa1100_pcmcia_cmd_time(unsigned int cpu_clock_khz, } -/* 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 +extern int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr); #endif /* !defined(_PCMCIA_SA1100_H) */ diff --git a/drivers/pcmcia/sa11xx_core.h b/drivers/pcmcia/sa11xx_core.h deleted file mode 100644 index aadf7c0b6..000000000 --- a/drivers/pcmcia/sa11xx_core.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * linux/include/asm/arch/pcmcia.h - * - * Copyright (C) 2000 John G Dorsey - * - * 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 -#include -#include -#include -#include -#include -#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 diff --git a/drivers/pcmcia/sa11xx_core.c b/drivers/pcmcia/soc_common.c similarity index 56% rename from drivers/pcmcia/sa11xx_core.c rename to drivers/pcmcia/soc_common.c index d7249c033..ff8b52124 100644 --- a/drivers/pcmcia/sa11xx_core.c +++ b/drivers/pcmcia/soc_common.c @@ -1,7 +1,7 @@ /*====================================================================== - Device driver for the PCMCIA control functionality of StrongARM - SA-1100 microprocessors. + Common support code for the PCMCIA control functionality of + integrated SOCs like the SA-11x0 and PXA2xx microprocessors. The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file @@ -27,23 +27,16 @@ 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 #include #include -#include -#include -#include #include #include #include -#include #include #include @@ -52,46 +45,28 @@ #include #include -#include "sa11xx_core.h" -#include "sa1100.h" +#include "soc_common.h" #ifdef DEBUG -static int pc_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) +void soc_pcmcia_debug(struct soc_pcmcia_socket *skt, const char *func, + int lvl, const char *fmt, ...) +{ + va_list args; + if (pc_debug > lvl) { + printk(KERN_DEBUG "skt%u: %s: ", skt->nr, func); + va_start(args, fmt); + printk(fmt, args); + va_end(args); + } +} -#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); -} +#define to_soc_pcmcia_socket(x) container_of(x, struct soc_pcmcia_socket, socket) static unsigned short calc_speed(unsigned short *spds, int num, unsigned short dflt) @@ -108,52 +83,15 @@ calc_speed(unsigned short *spds, int num, unsigned short dflt) return speed; } -/* sa1100_pcmcia_set_mecr() - * ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - * - * set MECR value for socket 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) +void soc_common_pcmcia_get_timing(struct soc_pcmcia_socket *skt, struct soc_pcmcia_timing *timing) { - 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; + timing->io = calc_speed(skt->spd_io, MAX_IO_WIN, SOC_PCMCIA_IO_ACCESS); + timing->mem = calc_speed(skt->spd_mem, MAX_WIN, SOC_PCMCIA_3V_MEM_ACCESS); + timing->attr = calc_speed(skt->spd_attr, MAX_WIN, SOC_PCMCIA_3V_MEM_ACCESS); } +EXPORT_SYMBOL(soc_common_pcmcia_get_timing); -static unsigned int sa1100_pcmcia_skt_state(struct sa1100_pcmcia_socket *skt) +static unsigned int soc_common_pcmcia_skt_state(struct soc_pcmcia_socket *skt) { struct pcmcia_state state; unsigned int stat; @@ -186,13 +124,13 @@ static unsigned int sa1100_pcmcia_skt_state(struct sa1100_pcmcia_socket *skt) } /* - * sa1100_pcmcia_config_skt - * ^^^^^^^^^^^^^^^^^^^^^^^^ + * soc_common_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) +soc_common_pcmcia_config_skt(struct soc_pcmcia_socket *skt, socket_state_t *state) { int ret; @@ -214,14 +152,14 @@ sa1100_pcmcia_config_skt(struct sa1100_pcmcia_socket *skt, socket_state_t *state } if (ret < 0) - printk(KERN_ERR "sa1100_pcmcia: unable to configure " + printk(KERN_ERR "soc_common_pcmcia: unable to configure " "socket %d\n", skt->nr); return ret; } -/* sa1100_pcmcia_sock_init() - * ^^^^^^^^^^^^^^^^^^^^^^^^^ +/* soc_common_pcmcia_sock_init() + * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * * (Re-)Initialise the socket, turning on status interrupts * and PCMCIA bus. This must wait for power to stabilise @@ -229,9 +167,9 @@ sa1100_pcmcia_config_skt(struct sa1100_pcmcia_socket *skt, socket_state_t *state * * Returns: 0 */ -static int sa1100_pcmcia_sock_init(struct pcmcia_socket *sock) +static int soc_common_pcmcia_sock_init(struct pcmcia_socket *sock) { - struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock); + struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock); debug(skt, 2, "initializing socket\n"); @@ -241,22 +179,22 @@ static int sa1100_pcmcia_sock_init(struct pcmcia_socket *sock) /* - * sa1100_pcmcia_suspend() - * ^^^^^^^^^^^^^^^^^^^^^^^ + * soc_common_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) +static int soc_common_pcmcia_suspend(struct pcmcia_socket *sock) { - struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock); + struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock); int ret; debug(skt, 2, "suspending socket\n"); - ret = sa1100_pcmcia_config_skt(skt, &dead_socket); + ret = soc_common_pcmcia_config_skt(skt, &dead_socket); if (ret == 0) skt->ops->socket_suspend(skt); @@ -265,10 +203,7 @@ static int sa1100_pcmcia_suspend(struct pcmcia_socket *sock) static spinlock_t status_lock = SPIN_LOCK_UNLOCKED; -/* sa1100_check_status() - * ^^^^^^^^^^^^^^^^^^^^^ - */ -static void sa1100_check_status(struct sa1100_pcmcia_socket *skt) +static void soc_common_check_status(struct soc_pcmcia_socket *skt) { unsigned int events; @@ -278,7 +213,7 @@ static void sa1100_check_status(struct sa1100_pcmcia_socket *skt) unsigned int status; unsigned long flags; - status = sa1100_pcmcia_skt_state(skt); + status = soc_common_pcmcia_skt_state(skt); spin_lock_irqsave(&status_lock, flags); events = (status ^ skt->status) & skt->cs_state.csc_mask; @@ -298,45 +233,40 @@ static void sa1100_check_status(struct sa1100_pcmcia_socket *skt) } 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) +/* Let's poll for events in addition to IRQs since IRQ only is unreliable... */ +static void soc_common_pcmcia_poll_event(unsigned long dummy) { - struct sa1100_pcmcia_socket *skt = (struct sa1100_pcmcia_socket *)dummy; + struct soc_pcmcia_socket *skt = (struct soc_pcmcia_socket *)dummy; debug(skt, 4, "polling for events\n"); - mod_timer(&skt->poll_timer, jiffies + SA1100_PCMCIA_POLL_PERIOD); + mod_timer(&skt->poll_timer, jiffies + SOC_PCMCIA_POLL_PERIOD); - sa1100_check_status(skt); + soc_common_check_status(skt); } -/* sa1100_pcmcia_interrupt() - * ^^^^^^^^^^^^^^^^^^^^^^^^^ +/* * Service routine for socket driver interrupts (requested by the - * low-level PCMCIA init() operation via sa1100_pcmcia_thread()). + * low-level PCMCIA init() operation via soc_common_pcmcia_thread()). * The actual interrupt-servicing work is performed by - * sa1100_pcmcia_thread(), largely because the Card Services event- + * soc_common_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) +static irqreturn_t soc_common_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs) { - struct sa1100_pcmcia_socket *skt = dev; + struct soc_pcmcia_socket *skt = dev; debug(skt, 3, "servicing IRQ %d\n", irq); - sa1100_check_status(skt); + soc_common_check_status(skt); return IRQ_HANDLED; } -/* sa1100_pcmcia_get_status() - * ^^^^^^^^^^^^^^^^^^^^^^^^^^ - * Implements the get_status() operation for the in-kernel PCMCIA +/* + * 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. @@ -351,39 +281,37 @@ static irqreturn_t sa1100_pcmcia_interrupt(int irq, void *dev, struct pt_regs *r * Returns: 0 */ static int -sa1100_pcmcia_get_status(struct pcmcia_socket *sock, unsigned int *status) +soc_common_pcmcia_get_status(struct pcmcia_socket *sock, unsigned int *status) { - struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock); + struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock); - skt->status = sa1100_pcmcia_skt_state(skt); + skt->status = soc_common_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 + * 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) +soc_common_pcmcia_get_socket(struct pcmcia_socket *sock, socket_state_t *state) { - struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock); + struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock); - debug(skt, 2, "\n"); + debug(skt, 2, "\n"); - *state = skt->cs_state; + *state = skt->cs_state; - return 0; + 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 @@ -393,31 +321,30 @@ sa1100_pcmcia_get_socket(struct pcmcia_socket *sock, socket_state_t *state) * Returns: 0 */ static int -sa1100_pcmcia_set_socket(struct pcmcia_socket *sock, socket_state_t *state) +soc_common_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)?" ":"", - (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)?" ":"", - (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() - * ^^^^^^^^^^^^^^^^^^^^^^^^^^ + struct soc_pcmcia_socket *skt = to_soc_pcmcia_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)?" ":"", + (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)?" ":"", + (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 soc_common_pcmcia_config_skt(skt, state); +} + + +/* * 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 @@ -426,9 +353,9 @@ sa1100_pcmcia_set_socket(struct pcmcia_socket *sock, socket_state_t *state) * Returns: 0 on success, -1 on error */ static int -sa1100_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *map) +soc_common_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *map) { - struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock); + struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock); unsigned short speed = map->speed; debug(skt, 2, "map %u speed %u start 0x%08x stop 0x%08x\n", @@ -451,13 +378,13 @@ sa1100_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *map) if (map->flags & MAP_ACTIVE) { if (speed == 0) - speed = SA1100_PCMCIA_IO_ACCESS; + speed = SOC_PCMCIA_IO_ACCESS; } else { speed = 0; } skt->spd_io[map->map] = speed; - sa1100_pcmcia_set_mecr(skt, cpufreq_get(0)); + skt->ops->set_timing(skt); if (map->stop == 1) map->stop = PAGE_SIZE-1; @@ -467,11 +394,10 @@ sa1100_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *map) 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 @@ -480,9 +406,9 @@ sa1100_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *map) * Returns: 0 on success, -1 on error */ static int -sa1100_pcmcia_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map) +soc_common_pcmcia_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map) { - struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock); + struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock); struct resource *res; unsigned short speed = map->speed; @@ -518,7 +444,7 @@ sa1100_pcmcia_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map skt->spd_mem[map->map] = speed; } - sa1100_pcmcia_set_mecr(skt, cpufreq_get(0)); + skt->ops->set_timing(skt); map->sys_stop -= map->sys_start; map->sys_stop += res->start + map->card_start; @@ -567,18 +493,15 @@ dump_bits(char **p, const char *prefix, unsigned int val, struct bittbl *bits, i *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; + struct soc_pcmcia_socket *skt = + container_of(class_dev, struct soc_pcmcia_socket, socket.dev); char *p = buf; p+=sprintf(p, "slot : %d\n", skt->nr); @@ -593,42 +516,34 @@ static ssize_t show_status(struct class_device *class_dev, char *buf) 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))); + if (skt->ops->show_timing) + p+=skt->ops->show_timing(skt, p); 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, +static struct pccard_operations soc_common_pcmcia_operations = { + .init = soc_common_pcmcia_sock_init, + .suspend = soc_common_pcmcia_suspend, + .get_status = soc_common_pcmcia_get_status, + .get_socket = soc_common_pcmcia_get_socket, + .set_socket = soc_common_pcmcia_set_socket, + .set_io_map = soc_common_pcmcia_set_io_map, + .set_mem_map = soc_common_pcmcia_set_mem_map, }; -int sa11xx_request_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr) + +int soc_pcmcia_request_irqs(struct soc_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, + res = request_irq(irqs[i].irq, soc_common_pcmcia_interrupt, SA_INTERRUPT, irqs[i].str, skt); if (res) break; @@ -645,9 +560,10 @@ int sa11xx_request_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *ir } return res; } -EXPORT_SYMBOL(sa11xx_request_irqs); +EXPORT_SYMBOL(soc_pcmcia_request_irqs); -void sa11xx_free_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr) +void soc_pcmcia_free_irqs(struct soc_pcmcia_socket *skt, + struct pcmcia_irqs *irqs, int nr) { int i; @@ -655,9 +571,10 @@ void sa11xx_free_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs if (irqs[i].sock == skt->nr) free_irq(irqs[i].irq, skt); } -EXPORT_SYMBOL(sa11xx_free_irqs); +EXPORT_SYMBOL(soc_pcmcia_free_irqs); -void sa11xx_disable_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr) +void soc_pcmcia_disable_irqs(struct soc_pcmcia_socket *skt, + struct pcmcia_irqs *irqs, int nr) { int i; @@ -665,9 +582,10 @@ void sa11xx_disable_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *i if (irqs[i].sock == skt->nr) set_irq_type(irqs[i].irq, IRQT_NOEDGE); } -EXPORT_SYMBOL(sa11xx_disable_irqs); +EXPORT_SYMBOL(soc_pcmcia_disable_irqs); -void sa11xx_enable_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr) +void soc_pcmcia_enable_irqs(struct soc_pcmcia_socket *skt, + struct pcmcia_irqs *irqs, int nr) { int i; @@ -677,10 +595,11 @@ void sa11xx_enable_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *ir set_irq_type(irqs[i].irq, IRQT_BOTHEDGE); } } -EXPORT_SYMBOL(sa11xx_enable_irqs); +EXPORT_SYMBOL(soc_pcmcia_enable_irqs); + -static LIST_HEAD(sa1100_sockets); -static DECLARE_MUTEX(sa1100_sockets_lock); +LIST_HEAD(soc_pcmcia_sockets); +DECLARE_MUTEX(soc_pcmcia_sockets_lock); static const char *skt_names[] = { "PCMCIA socket 0", @@ -689,26 +608,18 @@ static const char *skt_names[] = { struct skt_dev_info { int nskt; - struct sa1100_pcmcia_socket skt[0]; + struct soc_pcmcia_socket skt[0]; }; #define SKT_DEV_INFO_SIZE(n) \ - (sizeof(struct skt_dev_info) + (n)*sizeof(struct sa1100_pcmcia_socket)) + (sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket)) -int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr) +int soc_common_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); + down(&soc_pcmcia_sockets_lock); sinfo = kmalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL); if (!sinfo) { @@ -719,22 +630,20 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, in 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]; + struct soc_pcmcia_socket *skt = &sinfo->skt[i]; - skt->socket.ops = &sa11xx_pcmcia_operations; + skt->socket.ops = &soc_common_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.function = soc_common_pcmcia_poll_event; skt->poll_timer.data = (unsigned long)skt; - skt->poll_timer.expires = jiffies + SA1100_PCMCIA_POLL_PERIOD; + skt->poll_timer.expires = jiffies + SOC_PCMCIA_POLL_PERIOD; skt->nr = first + i; skt->irq = NO_IRQ; @@ -772,7 +681,7 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, in 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; @@ -783,14 +692,14 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, in goto out_err_5; } - list_add(&skt->node, &sa1100_sockets); + list_add(&skt->node, &soc_pcmcia_sockets); /* - * We initialize the MECR to default values here, because + * We initialize default socket timing here, because * we are not guaranteed to see a SetIOMap operation at * runtime. */ - sa1100_pcmcia_set_mecr(skt, cpu_clock); + ops->set_timing(skt); ret = ops->hw_init(skt); if (ret) @@ -802,7 +711,7 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, in skt->socket.pci_irq = skt->irq; skt->socket.io_offset = (unsigned long)skt->virt_io; - skt->status = sa1100_pcmcia_skt_state(skt); + skt->status = soc_common_pcmcia_skt_state(skt); ret = pcmcia_register_socket(&skt->socket); if (ret) @@ -820,7 +729,7 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, in goto out; do { - struct sa1100_pcmcia_socket *skt = &sinfo->skt[i]; + struct soc_pcmcia_socket *skt = &sinfo->skt[i]; del_timer_sync(&skt->poll_timer); pcmcia_unregister_socket(&skt->socket); @@ -847,21 +756,20 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, in kfree(sinfo); out: - up(&sa1100_sockets_lock); + up(&soc_pcmcia_sockets_lock); return ret; } -EXPORT_SYMBOL(sa11xx_drv_pcmcia_probe); -int sa11xx_drv_pcmcia_remove(struct device *dev) +int soc_common_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); + down(&soc_pcmcia_sockets_lock); for (i = 0; i < sinfo->nskt; i++) { - struct sa1100_pcmcia_socket *skt = &sinfo->skt[i]; + struct soc_pcmcia_socket *skt = &sinfo->skt[i]; del_timer_sync(&skt->poll_timer); @@ -871,7 +779,7 @@ int sa11xx_drv_pcmcia_remove(struct device *dev) skt->ops->hw_shutdown(skt); - sa1100_pcmcia_config_skt(skt, &dead_socket); + soc_common_pcmcia_config_skt(skt, &dead_socket); list_del(&skt->node); iounmap(skt->virt_io); @@ -881,91 +789,9 @@ int sa11xx_drv_pcmcia_remove(struct device *dev) release_resource(&skt->res_io); release_resource(&skt->res_skt); } - up(&sa1100_sockets_lock); + up(&soc_pcmcia_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 "); -MODULE_DESCRIPTION("Linux PCMCIA Card Services: SA-11xx core socket driver"); -MODULE_LICENSE("Dual MPL/GPL"); diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h new file mode 100644 index 000000000..60e30197b --- /dev/null +++ b/drivers/pcmcia/soc_common.h @@ -0,0 +1,186 @@ +/* + * linux/drivers/pcmcia/soc_common.h + * + * Copyright (C) 2000 John G Dorsey + * + * This file contains definitions for the PCMCIA support code common to + * integrated SOCs like the SA-11x0 and PXA2xx microprocessors. + */ +#ifndef _ASM_ARCH_PCMCIA +#define _ASM_ARCH_PCMCIA + +/* include the world */ +#include +#include +#include +#include +#include +#include +#include "cs_internal.h" + + +struct device; +struct pcmcia_low_level; + +/* + * This structure encapsulates per-socket state which we might need to + * use when responding to a Card Services query of some kind. + */ +struct soc_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_state { + unsigned detect: 1, + ready: 1, + bvd1: 1, + bvd2: 1, + wrprot: 1, + vs_3v: 1, + vs_Xv: 1; +}; + +struct pcmcia_low_level { + struct module *owner; + + /* first socket in system */ + int first; + /* nr of sockets */ + int nr; + + int (*hw_init)(struct soc_pcmcia_socket *); + void (*hw_shutdown)(struct soc_pcmcia_socket *); + + void (*socket_state)(struct soc_pcmcia_socket *, struct pcmcia_state *); + int (*configure_socket)(struct soc_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 soc_pcmcia_socket *); + + /* + * Disable card status IRQs and PCMCIA bus on suspend. + */ + void (*socket_suspend)(struct soc_pcmcia_socket *); + + /* + * Hardware specific timing routines. + * If provided, the get_timing routine overrides the SOC default. + */ + unsigned int (*get_timing)(struct soc_pcmcia_socket *, unsigned int, unsigned int); + int (*set_timing)(struct soc_pcmcia_socket *); + int (*show_timing)(struct soc_pcmcia_socket *, char *); +}; + + +struct pcmcia_irqs { + int sock; + int irq; + const char *str; +}; + +struct soc_pcmcia_timing { + unsigned short io; + unsigned short mem; + unsigned short attr; +}; + +extern int soc_pcmcia_request_irqs(struct soc_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr); +extern void soc_pcmcia_free_irqs(struct soc_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr); +extern void soc_pcmcia_disable_irqs(struct soc_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr); +extern void soc_pcmcia_enable_irqs(struct soc_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr); +extern void soc_common_pcmcia_get_timing(struct soc_pcmcia_socket *, struct soc_pcmcia_timing *); + + +extern struct list_head soc_pcmcia_sockets; +extern struct semaphore soc_pcmcia_sockets_lock; + +extern int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr); +extern int soc_common_drv_pcmcia_remove(struct device *dev); + + +#ifdef DEBUG + +extern void soc_pcmcia_debug(struct soc_pcmcia_socket *skt, const char *func, + int lvl, const char *fmt, ...); + +#define debug(skt, lvl, fmt, arg...) \ + soc_pcmcia_debug(skt, __func__, lvl, fmt , ## arg) + +#else +#define debug(skt, lvl, fmt, arg...) do { } while (0) +#endif + + +/* + * 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 SOC_PCMCIA_IO_ACCESS (165) +#define SOC_PCMCIA_5V_MEM_ACCESS (150) +#define SOC_PCMCIA_3V_MEM_ACCESS (300) +#define SOC_PCMCIA_ATTR_MEM_ACCESS (300) + +/* + * The socket driver actually works nicely in interrupt-driven form, + * so the (relatively infrequent) polling is "just to be sure." + */ +#define SOC_PCMCIA_POLL_PERIOD (2*HZ) + + +/* 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 diff --git a/drivers/scsi/pcmcia/qlogic_core.c b/drivers/scsi/pcmcia/qlogic_core.c deleted file mode 100644 index 78abe22b1..000000000 --- a/drivers/scsi/pcmcia/qlogic_core.c +++ /dev/null @@ -1,2 +0,0 @@ -#define PCMCIA 1 -#include "qlogicfas.c" diff --git a/drivers/scsi/qlogicfas.h b/drivers/scsi/qlogicfas.h deleted file mode 100644 index 6750e8da6..000000000 --- a/drivers/scsi/qlogicfas.h +++ /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/qlogicfas408.c b/drivers/scsi/qlogicfas408.c new file mode 100644 index 000000000..5b6ce0a88 --- /dev/null +++ b/drivers/scsi/qlogicfas408.c @@ -0,0 +1,637 @@ +/*----------------------------------------------------------------*/ +/* + Qlogic linux driver - work in progress. No Warranty express or implied. + Use at your own risk. Support Tort Reform so you won't have to read all + these silly disclaimers. + + Copyright 1994, Tom Zerucha. + tz@execpc.com + + Additional Code, and much appreciated help by + Michael A. Griffith + grif@cs.ucr.edu + + Thanks to Eric Youngdale and Dave Hinds for loadable module and PCMCIA + help respectively, and for suffering through my foolishness during the + debugging process. + + Reference Qlogic FAS408 Technical Manual, 53408-510-00A, May 10, 1994 + (you can reference it, but it is incomplete and inaccurate in places) + + Version 0.46 1/30/97 - kernel 1.2.0+ + + Functions as standalone, loadable, and PCMCIA driver, the latter from + Dave Hinds' PCMCIA package. + + Cleaned up 26/10/2002 by Alan Cox as part of the 2.5 + SCSI driver cleanup and audit. This driver still needs work on the + following + - Non terminating hardware waits + - Some layering violations with its pcmcia stub + + Redistributable under terms of the GNU General Public License + + For the avoidance of doubt the "preferred form" of this code is one which + is in an open non patent encumbered format. Where cryptographic key signing + forms part of the process of creating an executable the information + including keys needed to generate an equivalently functional executable + are deemed to be part of the source code. + +*/ + +#include +#include /* to get disk capacity */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "scsi.h" +#include +#include "qlogicfas408.h" + +/*----------------------------------------------------------------*/ +static int qlcfg5 = (XTALFREQ << 5); /* 15625/512 */ +static int qlcfg6 = SYNCXFRPD; +static int qlcfg7 = SYNCOFFST; +static int qlcfg8 = (SLOWCABLE << 7) | (QL_ENABLE_PARITY << 4); +static int qlcfg9 = ((XTALFREQ + 4) / 5); +static int qlcfgc = (FASTCLK << 3) | (FASTSCSI << 4); + +/*----------------------------------------------------------------*/ + +/*----------------------------------------------------------------*/ +/* local functions */ +/*----------------------------------------------------------------*/ + +/* error recovery - reset everything */ + +static void ql_zap(struct qlogicfas408_priv *priv) +{ + int x; + int qbase = priv->qbase; + int int_type = priv->int_type; + + x = inb(qbase + 0xd); + REG0; + outb(3, qbase + 3); /* reset SCSI */ + outb(2, qbase + 3); /* reset chip */ + if (x & 0x80) + REG1; +} + +/* + * Do a pseudo-dma tranfer + */ + +static int ql_pdma(struct qlogicfas408_priv *priv, int phase, char *request, int reqlen) +{ + int j; + int qbase = priv->qbase; + j = 0; + if (phase & 1) { /* in */ +#if QL_TURBO_PDMA + rtrc(4) + /* empty fifo in large chunks */ + if (reqlen >= 128 && (inb(qbase + 8) & 2)) { /* full */ + insl(qbase + 4, request, 32); + reqlen -= 128; + request += 128; + } + while (reqlen >= 84 && !(j & 0xc0)) /* 2/3 */ + if ((j = inb(qbase + 8)) & 4) + { + insl(qbase + 4, request, 21); + reqlen -= 84; + request += 84; + } + if (reqlen >= 44 && (inb(qbase + 8) & 8)) { /* 1/3 */ + insl(qbase + 4, request, 11); + reqlen -= 44; + request += 44; + } +#endif + /* until both empty and int (or until reclen is 0) */ + rtrc(7) + j = 0; + while (reqlen && !((j & 0x10) && (j & 0xc0))) + { + /* while bytes to receive and not empty */ + j &= 0xc0; + while (reqlen && !((j = inb(qbase + 8)) & 0x10)) + { + *request++ = inb(qbase + 4); + reqlen--; + } + if (j & 0x10) + j = inb(qbase + 8); + + } + } else { /* out */ +#if QL_TURBO_PDMA + rtrc(4) + if (reqlen >= 128 && inb(qbase + 8) & 0x10) { /* empty */ + outsl(qbase + 4, request, 32); + reqlen -= 128; + request += 128; + } + while (reqlen >= 84 && !(j & 0xc0)) /* 1/3 */ + if (!((j = inb(qbase + 8)) & 8)) { + outsl(qbase + 4, request, 21); + reqlen -= 84; + request += 84; + } + if (reqlen >= 40 && !(inb(qbase + 8) & 4)) { /* 2/3 */ + outsl(qbase + 4, request, 10); + reqlen -= 40; + request += 40; + } +#endif + /* until full and int (or until reclen is 0) */ + rtrc(7) + j = 0; + while (reqlen && !((j & 2) && (j & 0xc0))) { + /* while bytes to send and not full */ + while (reqlen && !((j = inb(qbase + 8)) & 2)) + { + outb(*request++, qbase + 4); + reqlen--; + } + if (j & 2) + j = inb(qbase + 8); + } + } + /* maybe return reqlen */ + return inb(qbase + 8) & 0xc0; +} + +/* + * Wait for interrupt flag (polled - not real hardware interrupt) + */ + +static int ql_wai(struct qlogicfas408_priv *priv) +{ + int k; + int qbase = priv->qbase; + unsigned long i; + + k = 0; + i = jiffies + WATCHDOG; + while (time_before(jiffies, i) && !priv->qabort && + !((k = inb(qbase + 4)) & 0xe0)) { + barrier(); + cpu_relax(); + } + if (time_after_eq(jiffies, i)) + return (DID_TIME_OUT); + if (priv->qabort) + return (priv->qabort == 1 ? DID_ABORT : DID_RESET); + if (k & 0x60) + ql_zap(priv); + if (k & 0x20) + return (DID_PARITY); + if (k & 0x40) + return (DID_ERROR); + return 0; +} + +/* + * Initiate scsi command - queueing handler + * caller must hold host lock + */ + +static void ql_icmd(Scsi_Cmnd * cmd) +{ + struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); + int qbase = priv->qbase; + int int_type = priv->int_type; + unsigned int i; + + priv->qabort = 0; + + REG0; + /* clearing of interrupts and the fifo is needed */ + + inb(qbase + 5); /* clear interrupts */ + if (inb(qbase + 5)) /* if still interrupting */ + outb(2, qbase + 3); /* reset chip */ + else if (inb(qbase + 7) & 0x1f) + outb(1, qbase + 3); /* clear fifo */ + while (inb(qbase + 5)); /* clear ints */ + REG1; + outb(1, qbase + 8); /* set for PIO pseudo DMA */ + outb(0, qbase + 0xb); /* disable ints */ + inb(qbase + 8); /* clear int bits */ + REG0; + outb(0x40, qbase + 0xb); /* enable features */ + + /* configurables */ + outb(qlcfgc, qbase + 0xc); + /* config: no reset interrupt, (initiator) bus id */ + outb(0x40 | qlcfg8 | priv->qinitid, qbase + 8); + outb(qlcfg7, qbase + 7); + outb(qlcfg6, qbase + 6); + /**/ outb(qlcfg5, qbase + 5); /* select timer */ + outb(qlcfg9 & 7, qbase + 9); /* prescaler */ +/* outb(0x99, qbase + 5); */ + outb(cmd->device->id, qbase + 4); + + for (i = 0; i < cmd->cmd_len; i++) + outb(cmd->cmnd[i], qbase + 2); + + priv->qlcmd = cmd; + outb(0x41, qbase + 3); /* select and send command */ +} + +/* + * Process scsi command - usually after interrupt + */ + +static unsigned int ql_pcmd(Scsi_Cmnd * cmd) +{ + unsigned int i, j; + unsigned long k; + unsigned int result; /* ultimate return result */ + unsigned int status; /* scsi returned status */ + unsigned int message; /* scsi returned message */ + unsigned int phase; /* recorded scsi phase */ + unsigned int reqlen; /* total length of transfer */ + struct scatterlist *sglist; /* scatter-gather list pointer */ + unsigned int sgcount; /* sg counter */ + char *buf; + struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); + int qbase = priv->qbase; + int int_type = priv->int_type; + + rtrc(1) + j = inb(qbase + 6); + i = inb(qbase + 5); + if (i == 0x20) { + return (DID_NO_CONNECT << 16); + } + i |= inb(qbase + 5); /* the 0x10 bit can be set after the 0x08 */ + if (i != 0x18) { + printk(KERN_ERR "Ql:Bad Interrupt status:%02x\n", i); + ql_zap(priv); + return (DID_BAD_INTR << 16); + } + j &= 7; /* j = inb( qbase + 7 ) >> 5; */ + + /* correct status is supposed to be step 4 */ + /* it sometimes returns step 3 but with 0 bytes left to send */ + /* We can try stuffing the FIFO with the max each time, but we will get a + sequence of 3 if any bytes are left (but we do flush the FIFO anyway */ + + if (j != 3 && j != 4) { + printk(KERN_ERR "Ql:Bad sequence for command %d, int %02X, cmdleft = %d\n", + j, i, inb(qbase + 7) & 0x1f); + ql_zap(priv); + return (DID_ERROR << 16); + } + result = DID_OK; + if (inb(qbase + 7) & 0x1f) /* if some bytes in fifo */ + outb(1, qbase + 3); /* clear fifo */ + /* note that request_bufflen is the total xfer size when sg is used */ + reqlen = cmd->request_bufflen; + /* note that it won't work if transfers > 16M are requested */ + if (reqlen && !((phase = inb(qbase + 4)) & 6)) { /* data phase */ + rtrc(2) + outb(reqlen, qbase); /* low-mid xfer cnt */ + outb(reqlen >> 8, qbase + 1); /* low-mid xfer cnt */ + outb(reqlen >> 16, qbase + 0xe); /* high xfer cnt */ + outb(0x90, qbase + 3); /* command do xfer */ + /* PIO pseudo DMA to buffer or sglist */ + REG1; + if (!cmd->use_sg) + ql_pdma(priv, phase, cmd->request_buffer, + cmd->request_bufflen); + else { + sgcount = cmd->use_sg; + sglist = cmd->request_buffer; + while (sgcount--) { + if (priv->qabort) { + REG0; + return ((priv->qabort == 1 ? + DID_ABORT : DID_RESET) << 16); + } + buf = page_address(sglist->page) + sglist->offset; + if (ql_pdma(priv, phase, buf, sglist->length)) + break; + sglist++; + } + } + REG0; + rtrc(2) + /* + * Wait for irq (split into second state of irq handler + * if this can take time) + */ + if ((k = ql_wai(priv))) + return (k << 16); + k = inb(qbase + 5); /* should be 0x10, bus service */ + } + + /* + * Enter Status (and Message In) Phase + */ + + k = jiffies + WATCHDOG; + + while (time_before(jiffies, k) && !priv->qabort && + !(inb(qbase + 4) & 6)) + cpu_relax(); /* wait for status phase */ + + if (time_after_eq(jiffies, k)) { + ql_zap(priv); + return (DID_TIME_OUT << 16); + } + + /* FIXME: timeout ?? */ + while (inb(qbase + 5)) + cpu_relax(); /* clear pending ints */ + + if (priv->qabort) + return ((priv->qabort == 1 ? DID_ABORT : DID_RESET) << 16); + + outb(0x11, qbase + 3); /* get status and message */ + if ((k = ql_wai(priv))) + return (k << 16); + i = inb(qbase + 5); /* get chip irq stat */ + j = inb(qbase + 7) & 0x1f; /* and bytes rec'd */ + status = inb(qbase + 2); + message = inb(qbase + 2); + + /* + * Should get function complete int if Status and message, else + * bus serv if only status + */ + if (!((i == 8 && j == 2) || (i == 0x10 && j == 1))) { + printk(KERN_ERR "Ql:Error during status phase, int=%02X, %d bytes recd\n", i, j); + result = DID_ERROR; + } + outb(0x12, qbase + 3); /* done, disconnect */ + rtrc(1) + if ((k = ql_wai(priv))) + return (k << 16); + + /* + * Should get bus service interrupt and disconnect interrupt + */ + + i = inb(qbase + 5); /* should be bus service */ + while (!priv->qabort && ((i & 0x20) != 0x20)) { + barrier(); + cpu_relax(); + i |= inb(qbase + 5); + } + rtrc(0) + + if (priv->qabort) + return ((priv->qabort == 1 ? DID_ABORT : DID_RESET) << 16); + + return (result << 16) | (message << 8) | (status & STATUS_MASK); +} + +/* + * Interrupt handler + */ + +static void ql_ihandl(int irq, void *dev_id, struct pt_regs *regs) +{ + Scsi_Cmnd *icmd; + struct Scsi_Host *host = (struct Scsi_Host *)dev_id; + struct qlogicfas408_priv *priv = get_priv_by_host(host); + int qbase = priv->qbase; + REG0; + + if (!(inb(qbase + 4) & 0x80)) /* false alarm? */ + return; + + if (priv->qlcmd == NULL) { /* no command to process? */ + int i; + i = 16; + while (i-- && inb(qbase + 5)); /* maybe also ql_zap() */ + return; + } + icmd = priv->qlcmd; + icmd->result = ql_pcmd(icmd); + priv->qlcmd = NULL; + /* + * If result is CHECK CONDITION done calls qcommand to request + * sense + */ + (icmd->scsi_done) (icmd); +} + +irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id, struct pt_regs *regs) +{ + unsigned long flags; + struct Scsi_Host *host = dev_id; + + spin_lock_irqsave(host->host_lock, flags); + ql_ihandl(irq, dev_id, regs); + spin_unlock_irqrestore(host->host_lock, flags); + return IRQ_HANDLED; +} + +/* + * Queued command + */ + +int qlogicfas408_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) +{ + struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); + if (cmd->device->id == priv->qinitid) { + cmd->result = DID_BAD_TARGET << 16; + done(cmd); + return 0; + } + + cmd->scsi_done = done; + /* wait for the last command's interrupt to finish */ + while (priv->qlcmd != NULL) { + barrier(); + cpu_relax(); + } + ql_icmd(cmd); + return 0; +} + +/* + * Return bios parameters + */ + +int qlogicfas408_biosparam(struct scsi_device * disk, + struct block_device *dev, + sector_t capacity, int ip[]) +{ +/* This should mimic the DOS Qlogic driver's behavior exactly */ + ip[0] = 0x40; + ip[1] = 0x20; + ip[2] = (unsigned long) capacity / (ip[0] * ip[1]); + if (ip[2] > 1024) { + ip[0] = 0xff; + ip[1] = 0x3f; + ip[2] = (unsigned long) capacity / (ip[0] * ip[1]); +#if 0 + if (ip[2] > 1023) + ip[2] = 1023; +#endif + } + return 0; +} + +/* + * Abort a command in progress + */ + +int qlogicfas408_abort(Scsi_Cmnd * cmd) +{ + struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); + priv->qabort = 1; + ql_zap(priv); + return SUCCESS; +} + +/* + * Reset SCSI bus + * FIXME: This function is invoked with cmd = NULL directly by + * the PCMCIA qlogic_stub code. This wants fixing + */ + +int qlogicfas408_bus_reset(Scsi_Cmnd * cmd) +{ + struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); + priv->qabort = 2; + ql_zap(priv); + return SUCCESS; +} + +/* + * Reset SCSI host controller + */ + +int qlogicfas408_host_reset(Scsi_Cmnd * cmd) +{ + return FAILED; +} + +/* + * Reset SCSI device + */ + +int qlogicfas408_device_reset(Scsi_Cmnd * cmd) +{ + return FAILED; +} + +/* + * Return info string + */ + +const char *qlogicfas408_info(struct Scsi_Host *host) +{ + struct qlogicfas408_priv *priv = get_priv_by_host(host); + return priv->qinfo; +} + +/* + * Get type of chip + */ + +int qlogicfas408_get_chip_type(int qbase, int int_type) +{ + REG1; + return inb(qbase + 0xe) & 0xf8; +} + +/* + * Perform initialization tasks + */ + +void qlogicfas408_setup(int qbase, int id, int int_type) +{ + outb(1, qbase + 8); /* set for PIO pseudo DMA */ + REG0; + outb(0x40 | qlcfg8 | id, qbase + 8); /* (ini) bus id, disable scsi rst */ + outb(qlcfg5, qbase + 5); /* select timer */ + outb(qlcfg9, qbase + 9); /* prescaler */ + +#if QL_RESET_AT_START + outb(3, qbase + 3); + + REG1; + /* FIXME: timeout */ + while (inb(qbase + 0xf) & 4) + cpu_relax(); + + REG0; +#endif +} + +/* + * Checks if this is a QLogic FAS 408 + */ + +int qlogicfas408_detect(int qbase, int int_type) +{ + REG1; + return (((inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7) && + ((inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7)); +} + +/* + * Disable interrupts + */ + +void qlogicfas408_disable_ints(struct qlogicfas408_priv *priv) +{ + int qbase = priv->qbase; + int int_type = priv->int_type; + + REG1; + outb(0, qbase + 0xb); /* disable ints */ +} + +/* + * Init and exit functions + */ + +static int __init qlogicfas408_init(void) +{ + return 0; +} + +static void __exit qlogicfas408_exit(void) +{ + +} + +MODULE_AUTHOR("Tom Zerucha, Michael Griffith"); +MODULE_DESCRIPTION("Driver for the Qlogic FAS SCSI controllers"); +MODULE_LICENSE("GPL"); +module_init(qlogicfas408_init); +module_exit(qlogicfas408_exit); + +EXPORT_SYMBOL(qlogicfas408_info); +EXPORT_SYMBOL(qlogicfas408_queuecommand); +EXPORT_SYMBOL(qlogicfas408_abort); +EXPORT_SYMBOL(qlogicfas408_bus_reset); +EXPORT_SYMBOL(qlogicfas408_device_reset); +EXPORT_SYMBOL(qlogicfas408_host_reset); +EXPORT_SYMBOL(qlogicfas408_biosparam); +EXPORT_SYMBOL(qlogicfas408_ihandl); +EXPORT_SYMBOL(qlogicfas408_get_chip_type); +EXPORT_SYMBOL(qlogicfas408_setup); +EXPORT_SYMBOL(qlogicfas408_detect); +EXPORT_SYMBOL(qlogicfas408_disable_ints); + diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c new file mode 100644 index 000000000..75013729e --- /dev/null +++ b/drivers/scsi/sata_sx4.c @@ -0,0 +1,1446 @@ +/* + * sata_sx4.c - Promise SATA + * + * Maintained by: Jeff Garzik + * Please ALWAYS copy linux-ide@vger.kernel.org + * on emails. + * + * Copyright 2003-2004 Red Hat, Inc. + * + * The contents of this file are subject to the Open + * Software License version 1.1 that can be found at + * http://www.opensource.org/licenses/osl-1.1.txt and is included herein + * by reference. + * + * Alternatively, the contents of this file may be used under the terms + * of the GNU General Public License version 2 (the "GPL") as distributed + * in the kernel source COPYING file, in which case the provisions of + * the GPL are applicable instead of the above. If you wish to allow + * the use of your version of this file only under the terms of the + * GPL and not to allow others to use your version of this file under + * the OSL, indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by the GPL. + * If you do not delete the provisions above, a recipient may use your + * version of this file under either the OSL or the GPL. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "scsi.h" +#include +#include +#include +#include "sata_promise.h" + +#define DRV_NAME "sata_sx4" +#define DRV_VERSION "0.50" + + +enum { + PDC_PRD_TBL = 0x44, /* Direct command DMA table addr */ + + PDC_PKT_SUBMIT = 0x40, /* Command packet pointer addr */ + PDC_HDMA_PKT_SUBMIT = 0x100, /* Host DMA packet pointer addr */ + PDC_INT_SEQMASK = 0x40, /* Mask of asserted SEQ INTs */ + PDC_HDMA_CTLSTAT = 0x12C, /* Host DMA control / status */ + + PDC_20621_SEQCTL = 0x400, + PDC_20621_SEQMASK = 0x480, + PDC_20621_GENERAL_CTL = 0x484, + PDC_20621_PAGE_SIZE = (32 * 1024), + + /* chosen, not constant, values; we design our own DIMM mem map */ + PDC_20621_DIMM_WINDOW = 0x0C, /* page# for 32K DIMM window */ + PDC_20621_DIMM_BASE = 0x00200000, + PDC_20621_DIMM_DATA = (64 * 1024), + PDC_DIMM_DATA_STEP = (256 * 1024), + PDC_DIMM_WINDOW_STEP = (8 * 1024), + PDC_DIMM_HOST_PRD = (6 * 1024), + PDC_DIMM_HOST_PKT = (128 * 0), + PDC_DIMM_HPKT_PRD = (128 * 1), + PDC_DIMM_ATA_PKT = (128 * 2), + PDC_DIMM_APKT_PRD = (128 * 3), + PDC_DIMM_HEADER_SZ = PDC_DIMM_APKT_PRD + 128, + PDC_PAGE_WINDOW = 0x40, + PDC_PAGE_DATA = PDC_PAGE_WINDOW + + (PDC_20621_DIMM_DATA / PDC_20621_PAGE_SIZE), + PDC_PAGE_SET = PDC_DIMM_DATA_STEP / PDC_20621_PAGE_SIZE, + + PDC_CHIP0_OFS = 0xC0000, /* offset of chip #0 */ + + PDC_20621_ERR_MASK = (1<<19) | (1<<20) | (1<<21) | (1<<22) | + (1<<23), + + board_20621 = 0, /* FastTrak S150 SX4 */ + + PDC_RESET = (1 << 11), /* HDMA reset */ + + PDC_MAX_HDMA = 32, + PDC_HDMA_Q_MASK = (PDC_MAX_HDMA - 1), + + PDC_DIMM0_SPD_DEV_ADDRESS = 0x50, + PDC_DIMM1_SPD_DEV_ADDRESS = 0x51, + PDC_MAX_DIMM_MODULE = 0x02, + PDC_I2C_CONTROL_OFFSET = 0x48, + PDC_I2C_ADDR_DATA_OFFSET = 0x4C, + PDC_DIMM0_CONTROL_OFFSET = 0x80, + PDC_DIMM1_CONTROL_OFFSET = 0x84, + PDC_SDRAM_CONTROL_OFFSET = 0x88, + PDC_I2C_WRITE = 0x00000000, + PDC_I2C_READ = 0x00000040, + PDC_I2C_START = 0x00000080, + PDC_I2C_MASK_INT = 0x00000020, + PDC_I2C_COMPLETE = 0x00010000, + PDC_I2C_NO_ACK = 0x00100000, + PDC_DIMM_SPD_SUBADDRESS_START = 0x00, + PDC_DIMM_SPD_SUBADDRESS_END = 0x7F, + PDC_DIMM_SPD_ROW_NUM = 3, + PDC_DIMM_SPD_COLUMN_NUM = 4, + PDC_DIMM_SPD_MODULE_ROW = 5, + PDC_DIMM_SPD_TYPE = 11, + PDC_DIMM_SPD_FRESH_RATE = 12, + PDC_DIMM_SPD_BANK_NUM = 17, + PDC_DIMM_SPD_CAS_LATENCY = 18, + PDC_DIMM_SPD_ATTRIBUTE = 21, + PDC_DIMM_SPD_ROW_PRE_CHARGE = 27, + PDC_DIMM_SPD_ROW_ACTIVE_DELAY = 28, + PDC_DIMM_SPD_RAS_CAS_DELAY = 29, + PDC_DIMM_SPD_ACTIVE_PRECHARGE = 30, + PDC_DIMM_SPD_SYSTEM_FREQ = 126, + PDC_CTL_STATUS = 0x08, + PDC_DIMM_WINDOW_CTLR = 0x0C, + PDC_TIME_CONTROL = 0x3C, + PDC_TIME_PERIOD = 0x40, + PDC_TIME_COUNTER = 0x44, + PDC_GENERAL_CTLR = 0x484, + PCI_PLL_INIT = 0x8A531824, + PCI_X_TCOUNT = 0xEE1E5CFF +}; + + +struct pdc_port_priv { + u8 dimm_buf[(ATA_PRD_SZ * ATA_MAX_PRD) + 512]; + u8 *pkt; + dma_addr_t pkt_dma; +}; + +struct pdc_host_priv { + void *dimm_mmio; + + unsigned int doing_hdma; + unsigned int hdma_prod; + unsigned int hdma_cons; + struct { + struct ata_queued_cmd *qc; + unsigned int seq; + unsigned long pkt_ofs; + } hdma[32]; +}; + + +static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); +static void pdc20621_dma_setup(struct ata_queued_cmd *qc); +static void pdc20621_dma_start(struct ata_queued_cmd *qc); +static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_regs *regs); +static void pdc_eng_timeout(struct ata_port *ap); +static void pdc_20621_phy_reset (struct ata_port *ap); +static int pdc_port_start(struct ata_port *ap); +static void pdc_port_stop(struct ata_port *ap); +static void pdc20621_fill_sg(struct ata_queued_cmd *qc); +static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf); +static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf); +static void pdc20621_host_stop(struct ata_host_set *host_set); +static inline void pdc_dma_complete (struct ata_port *ap, + struct ata_queued_cmd *qc, int have_err); +static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe); +static int pdc20621_detect_dimm(struct ata_probe_ent *pe); +static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, + u32 device, u32 subaddr, u32 *pdata); +static int pdc20621_prog_dimm0(struct ata_probe_ent *pe); +static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe); +#ifdef ATA_VERBOSE_DEBUG +static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, + void *psource, u32 offset, u32 size); +#endif +static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, + void *psource, u32 offset, u32 size); + + +static Scsi_Host_Template pdc_sata_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 = LIBATA_MAX_PRD, + .max_sectors = ATA_MAX_SECTORS, + .cmd_per_lun = ATA_SHT_CMD_PER_LUN, + .emulated = ATA_SHT_EMULATED, + .use_clustering = ATA_SHT_USE_CLUSTERING, + .proc_name = DRV_NAME, + .dma_boundary = ATA_DMA_BOUNDARY, + .slave_configure = ata_scsi_slave_config, + .bios_param = ata_std_bios_param, +}; + +static struct ata_port_operations pdc_20621_ops = { + .port_disable = ata_port_disable, + .tf_load = pdc_tf_load_mmio, + .tf_read = ata_tf_read_mmio, + .check_status = ata_check_status_mmio, + .exec_command = pdc_exec_command_mmio, + .phy_reset = pdc_20621_phy_reset, + .bmdma_setup = pdc20621_dma_setup, + .bmdma_start = pdc20621_dma_start, + .fill_sg = pdc20621_fill_sg, + .eng_timeout = pdc_eng_timeout, + .irq_handler = pdc20621_interrupt, + .port_start = pdc_port_start, + .port_stop = pdc_port_stop, + .host_stop = pdc20621_host_stop, +}; + +static struct ata_port_info pdc_port_info[] = { + /* board_20621 */ + { + .sht = &pdc_sata_sht, + .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | + ATA_FLAG_SRST | ATA_FLAG_MMIO, + .pio_mask = 0x03, /* pio3-4 */ + .udma_mask = 0x7f, /* udma0-6 ; FIXME */ + .port_ops = &pdc_20621_ops, + }, + +}; + +static struct pci_device_id pdc_sata_pci_tbl[] = { + { PCI_VENDOR_ID_PROMISE, 0x6622, PCI_ANY_ID, PCI_ANY_ID, 0, 0, + board_20621 }, + { } /* terminate list */ +}; + + +static struct pci_driver pdc_sata_pci_driver = { + .name = DRV_NAME, + .id_table = pdc_sata_pci_tbl, + .probe = pdc_sata_init_one, + .remove = ata_pci_remove_one, +}; + + +static void pdc20621_host_stop(struct ata_host_set *host_set) +{ + struct pdc_host_priv *hpriv = host_set->private_data; + void *dimm_mmio = hpriv->dimm_mmio; + + iounmap(dimm_mmio); + kfree(hpriv); +} + +static int pdc_port_start(struct ata_port *ap) +{ + struct pci_dev *pdev = ap->host_set->pdev; + struct pdc_port_priv *pp; + int rc; + + rc = ata_port_start(ap); + if (rc) + return rc; + + pp = kmalloc(sizeof(*pp), GFP_KERNEL); + if (!pp) { + rc = -ENOMEM; + goto err_out; + } + memset(pp, 0, sizeof(*pp)); + + pp->pkt = pci_alloc_consistent(pdev, 128, &pp->pkt_dma); + if (!pp->pkt) { + rc = -ENOMEM; + goto err_out_kfree; + } + + ap->private_data = pp; + + return 0; + +err_out_kfree: + kfree(pp); +err_out: + ata_port_stop(ap); + return rc; +} + + +static void pdc_port_stop(struct ata_port *ap) +{ + struct pci_dev *pdev = ap->host_set->pdev; + struct pdc_port_priv *pp = ap->private_data; + + ap->private_data = NULL; + pci_free_consistent(pdev, 128, pp->pkt, pp->pkt_dma); + kfree(pp); + ata_port_stop(ap); +} + + +static void pdc_20621_phy_reset (struct ata_port *ap) +{ + VPRINTK("ENTER\n"); + ap->cbl = ATA_CBL_SATA; + ata_port_probe(ap); + ata_bus_reset(ap); +} + +static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf, + unsigned int portno, + unsigned int total_len) +{ + u32 addr; + unsigned int dw = PDC_DIMM_APKT_PRD >> 2; + u32 *buf32 = (u32 *) buf; + + /* output ATA packet S/G table */ + addr = PDC_20621_DIMM_BASE + PDC_20621_DIMM_DATA + + (PDC_DIMM_DATA_STEP * portno); + VPRINTK("ATA sg addr 0x%x, %d\n", addr, addr); + buf32[dw] = cpu_to_le32(addr); + buf32[dw + 1] = cpu_to_le32(total_len | ATA_PRD_EOT); + + VPRINTK("ATA PSG @ %x == (0x%x, 0x%x)\n", + PDC_20621_DIMM_BASE + + (PDC_DIMM_WINDOW_STEP * portno) + + PDC_DIMM_APKT_PRD, + buf32[dw], buf32[dw + 1]); +} + +static inline void pdc20621_host_sg(struct ata_taskfile *tf, u8 *buf, + unsigned int portno, + unsigned int total_len) +{ + u32 addr; + unsigned int dw = PDC_DIMM_HPKT_PRD >> 2; + u32 *buf32 = (u32 *) buf; + + /* output Host DMA packet S/G table */ + addr = PDC_20621_DIMM_BASE + PDC_20621_DIMM_DATA + + (PDC_DIMM_DATA_STEP * portno); + + buf32[dw] = cpu_to_le32(addr); + buf32[dw + 1] = cpu_to_le32(total_len | ATA_PRD_EOT); + + VPRINTK("HOST PSG @ %x == (0x%x, 0x%x)\n", + PDC_20621_DIMM_BASE + + (PDC_DIMM_WINDOW_STEP * portno) + + PDC_DIMM_HPKT_PRD, + buf32[dw], buf32[dw + 1]); +} + +static inline unsigned int pdc20621_ata_pkt(struct ata_taskfile *tf, + unsigned int devno, u8 *buf, + unsigned int portno) +{ + unsigned int i, dw; + u32 *buf32 = (u32 *) buf; + u8 dev_reg; + + unsigned int dimm_sg = PDC_20621_DIMM_BASE + + (PDC_DIMM_WINDOW_STEP * portno) + + PDC_DIMM_APKT_PRD; + VPRINTK("ENTER, dimm_sg == 0x%x, %d\n", dimm_sg, dimm_sg); + + i = PDC_DIMM_ATA_PKT; + + /* + * Set up ATA packet + */ + if ((tf->protocol == ATA_PROT_DMA) && (!(tf->flags & ATA_TFLAG_WRITE))) + buf[i++] = PDC_PKT_READ; + else if (tf->protocol == ATA_PROT_NODATA) + buf[i++] = PDC_PKT_NODATA; + else + buf[i++] = 0; + buf[i++] = 0; /* reserved */ + buf[i++] = portno + 1; /* seq. id */ + buf[i++] = 0xff; /* delay seq. id */ + + /* dimm dma S/G, and next-pkt */ + dw = i >> 2; + buf32[dw] = cpu_to_le32(dimm_sg); + buf32[dw + 1] = 0; + i += 8; + + if (devno == 0) + dev_reg = ATA_DEVICE_OBS; + else + dev_reg = ATA_DEVICE_OBS | ATA_DEV1; + + /* select device */ + buf[i++] = (1 << 5) | PDC_PKT_CLEAR_BSY | ATA_REG_DEVICE; + buf[i++] = dev_reg; + + /* device control register */ + buf[i++] = (1 << 5) | PDC_REG_DEVCTL; + buf[i++] = tf->ctl; + + return i; +} + +static inline void pdc20621_host_pkt(struct ata_taskfile *tf, u8 *buf, + unsigned int portno) +{ + unsigned int dw; + u32 tmp, *buf32 = (u32 *) buf; + + unsigned int host_sg = PDC_20621_DIMM_BASE + + (PDC_DIMM_WINDOW_STEP * portno) + + PDC_DIMM_HOST_PRD; + unsigned int dimm_sg = PDC_20621_DIMM_BASE + + (PDC_DIMM_WINDOW_STEP * portno) + + PDC_DIMM_HPKT_PRD; + VPRINTK("ENTER, dimm_sg == 0x%x, %d\n", dimm_sg, dimm_sg); + VPRINTK("host_sg == 0x%x, %d\n", host_sg, host_sg); + + dw = PDC_DIMM_HOST_PKT >> 2; + + /* + * Set up Host DMA packet + */ + if ((tf->protocol == ATA_PROT_DMA) && (!(tf->flags & ATA_TFLAG_WRITE))) + tmp = PDC_PKT_READ; + else + tmp = 0; + tmp |= ((portno + 1 + 4) << 16); /* seq. id */ + tmp |= (0xff << 24); /* delay seq. id */ + buf32[dw + 0] = cpu_to_le32(tmp); + buf32[dw + 1] = cpu_to_le32(host_sg); + buf32[dw + 2] = cpu_to_le32(dimm_sg); + buf32[dw + 3] = 0; + + VPRINTK("HOST PKT @ %x == (0x%x 0x%x 0x%x 0x%x)\n", + PDC_20621_DIMM_BASE + (PDC_DIMM_WINDOW_STEP * portno) + + PDC_DIMM_HOST_PKT, + buf32[dw + 0], + buf32[dw + 1], + buf32[dw + 2], + buf32[dw + 3]); +} + +static void pdc20621_fill_sg(struct ata_queued_cmd *qc) +{ + struct scatterlist *sg = qc->sg; + struct ata_port *ap = qc->ap; + struct pdc_port_priv *pp = ap->private_data; + void *mmio = ap->host_set->mmio_base; + struct pdc_host_priv *hpriv = ap->host_set->private_data; + void *dimm_mmio = hpriv->dimm_mmio; + unsigned int portno = ap->port_no; + unsigned int i, last, idx, total_len = 0, sgt_len; + u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ]; + + VPRINTK("ata%u: ENTER\n", ap->id); + + /* hard-code chip #0 */ + mmio += PDC_CHIP0_OFS; + + /* + * Build S/G table + */ + last = qc->n_elem; + idx = 0; + for (i = 0; i < last; i++) { + buf[idx++] = cpu_to_le32(sg_dma_address(&sg[i])); + buf[idx++] = cpu_to_le32(sg_dma_len(&sg[i])); + total_len += sg[i].length; + } + buf[idx - 1] |= cpu_to_le32(ATA_PRD_EOT); + sgt_len = idx * 4; + + /* + * Build ATA, host DMA packets + */ + pdc20621_host_sg(&qc->tf, &pp->dimm_buf[0], portno, total_len); + pdc20621_host_pkt(&qc->tf, &pp->dimm_buf[0], portno); + + pdc20621_ata_sg(&qc->tf, &pp->dimm_buf[0], portno, total_len); + i = pdc20621_ata_pkt(&qc->tf, qc->dev->devno, &pp->dimm_buf[0], portno); + + if (qc->tf.flags & ATA_TFLAG_LBA48) + i = pdc_prep_lba48(&qc->tf, &pp->dimm_buf[0], i); + else + i = pdc_prep_lba28(&qc->tf, &pp->dimm_buf[0], i); + + pdc_pkt_footer(&qc->tf, &pp->dimm_buf[0], i); + + /* copy three S/G tables and two packets to DIMM MMIO window */ + memcpy_toio(dimm_mmio + (portno * PDC_DIMM_WINDOW_STEP), + &pp->dimm_buf, PDC_DIMM_HEADER_SZ); + memcpy_toio(dimm_mmio + (portno * PDC_DIMM_WINDOW_STEP) + + PDC_DIMM_HOST_PRD, + &pp->dimm_buf[PDC_DIMM_HEADER_SZ], sgt_len); + + /* force host FIFO dump */ + writel(0x00000001, mmio + PDC_20621_GENERAL_CTL); + + readl(dimm_mmio); /* MMIO PCI posting flush */ + + VPRINTK("ata pkt buf ofs %u, prd size %u, mmio copied\n", i, sgt_len); +} + +static void __pdc20621_push_hdma(struct ata_queued_cmd *qc, + unsigned int seq, + u32 pkt_ofs) +{ + struct ata_port *ap = qc->ap; + struct ata_host_set *host_set = ap->host_set; + void *mmio = host_set->mmio_base; + + /* hard-code chip #0 */ + mmio += PDC_CHIP0_OFS; + + writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4)); + readl(mmio + PDC_20621_SEQCTL + (seq * 4)); /* flush */ + + writel(pkt_ofs, mmio + PDC_HDMA_PKT_SUBMIT); + readl(mmio + PDC_HDMA_PKT_SUBMIT); /* flush */ +} + +static void pdc20621_push_hdma(struct ata_queued_cmd *qc, + unsigned int seq, + u32 pkt_ofs) +{ + struct ata_port *ap = qc->ap; + struct pdc_host_priv *pp = ap->host_set->private_data; + unsigned int idx = pp->hdma_prod & PDC_HDMA_Q_MASK; + + if (!pp->doing_hdma) { + __pdc20621_push_hdma(qc, seq, pkt_ofs); + pp->doing_hdma = 1; + return; + } + + pp->hdma[idx].qc = qc; + pp->hdma[idx].seq = seq; + pp->hdma[idx].pkt_ofs = pkt_ofs; + pp->hdma_prod++; +} + +static void pdc20621_pop_hdma(struct ata_queued_cmd *qc) +{ + struct ata_port *ap = qc->ap; + struct pdc_host_priv *pp = ap->host_set->private_data; + unsigned int idx = pp->hdma_cons & PDC_HDMA_Q_MASK; + + /* if nothing on queue, we're done */ + if (pp->hdma_prod == pp->hdma_cons) { + pp->doing_hdma = 0; + return; + } + + __pdc20621_push_hdma(pp->hdma[idx].qc, pp->hdma[idx].seq, + pp->hdma[idx].pkt_ofs); + pp->hdma_cons++; +} + +#ifdef ATA_VERBOSE_DEBUG +static void pdc20621_dump_hdma(struct ata_queued_cmd *qc) +{ + struct ata_port *ap = qc->ap; + unsigned int port_no = ap->port_no; + struct pdc_host_priv *hpriv = ap->host_set->private_data; + void *dimm_mmio = hpriv->dimm_mmio; + + dimm_mmio += (port_no * PDC_DIMM_WINDOW_STEP); + dimm_mmio += PDC_DIMM_HOST_PKT; + + printk(KERN_ERR "HDMA[0] == 0x%08X\n", readl(dimm_mmio)); + printk(KERN_ERR "HDMA[1] == 0x%08X\n", readl(dimm_mmio + 4)); + printk(KERN_ERR "HDMA[2] == 0x%08X\n", readl(dimm_mmio + 8)); + printk(KERN_ERR "HDMA[3] == 0x%08X\n", readl(dimm_mmio + 12)); +} +#else +static inline void pdc20621_dump_hdma(struct ata_queued_cmd *qc) { } +#endif /* ATA_VERBOSE_DEBUG */ + +static void pdc20621_dma_setup(struct ata_queued_cmd *qc) +{ + /* nothing for now. later, we will call standard + * code in libata-core for ATAPI here */ +} + +static void pdc20621_dma_start(struct ata_queued_cmd *qc) +{ + struct ata_port *ap = qc->ap; + struct ata_host_set *host_set = ap->host_set; + unsigned int port_no = ap->port_no; + void *mmio = host_set->mmio_base; + unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); + u8 seq = (u8) (port_no + 1); + unsigned int doing_hdma = 0, port_ofs; + + /* hard-code chip #0 */ + mmio += PDC_CHIP0_OFS; + + VPRINTK("ata%u: ENTER\n", ap->id); + + port_ofs = PDC_20621_DIMM_BASE + (PDC_DIMM_WINDOW_STEP * port_no); + + /* if writing, we (1) DMA to DIMM, then (2) do ATA command */ + if (rw) { + doing_hdma = 1; + seq += 4; + } + + wmb(); /* flush PRD, pkt writes */ + + if (doing_hdma) { + pdc20621_dump_hdma(qc); + pdc20621_push_hdma(qc, seq, port_ofs + PDC_DIMM_HOST_PKT); + VPRINTK("queued ofs 0x%x (%u), seq %u\n", + port_ofs + PDC_DIMM_HOST_PKT, + port_ofs + PDC_DIMM_HOST_PKT, + seq); + } else { + writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4)); + readl(mmio + PDC_20621_SEQCTL + (seq * 4)); /* flush */ + + writel(port_ofs + PDC_DIMM_ATA_PKT, + (void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); + readl((void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); + VPRINTK("submitted ofs 0x%x (%u), seq %u\n", + port_ofs + PDC_DIMM_ATA_PKT, + port_ofs + PDC_DIMM_ATA_PKT, + seq); + } +} + +static inline unsigned int pdc20621_host_intr( struct ata_port *ap, + struct ata_queued_cmd *qc, + unsigned int doing_hdma, + void *mmio) +{ + unsigned int port_no = ap->port_no; + unsigned int port_ofs = + PDC_20621_DIMM_BASE + (PDC_DIMM_WINDOW_STEP * port_no); + u8 status; + unsigned int handled = 0; + + VPRINTK("ENTER\n"); + + if ((qc->tf.protocol == ATA_PROT_DMA) && /* read */ + (!(qc->tf.flags & ATA_TFLAG_WRITE))) { + + /* step two - DMA from DIMM to host */ + if (doing_hdma) { + VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, + readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); + pdc_dma_complete(ap, qc, 0); + pdc20621_pop_hdma(qc); + } + + /* step one - exec ATA command */ + else { + u8 seq = (u8) (port_no + 1 + 4); + VPRINTK("ata%u: read ata, 0x%x 0x%x\n", ap->id, + readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); + + /* submit hdma pkt */ + pdc20621_dump_hdma(qc); + pdc20621_push_hdma(qc, seq, + port_ofs + PDC_DIMM_HOST_PKT); + } + handled = 1; + + } else if (qc->tf.protocol == ATA_PROT_DMA) { /* write */ + + /* step one - DMA from host to DIMM */ + if (doing_hdma) { + u8 seq = (u8) (port_no + 1); + VPRINTK("ata%u: write hdma, 0x%x 0x%x\n", ap->id, + readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); + + /* submit ata pkt */ + writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4)); + readl(mmio + PDC_20621_SEQCTL + (seq * 4)); + writel(port_ofs + PDC_DIMM_ATA_PKT, + (void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); + readl((void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); + } + + /* step two - execute ATA command */ + else { + VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, + readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); + pdc_dma_complete(ap, qc, 0); + pdc20621_pop_hdma(qc); + } + handled = 1; + + /* command completion, but no data xfer */ + } else if (qc->tf.protocol == ATA_PROT_NODATA) { + + status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); + DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status); + ata_qc_complete(qc, status); + handled = 1; + + } else { + ap->stats.idle_irq++; + } + + return handled; +} + +static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_regs *regs) +{ + struct ata_host_set *host_set = dev_instance; + struct ata_port *ap; + u32 mask = 0; + unsigned int i, tmp, port_no; + unsigned int handled = 0; + void *mmio_base; + + VPRINTK("ENTER\n"); + + if (!host_set || !host_set->mmio_base) { + VPRINTK("QUICK EXIT\n"); + return IRQ_NONE; + } + + mmio_base = host_set->mmio_base; + + /* reading should also clear interrupts */ + mmio_base += PDC_CHIP0_OFS; + mask = readl(mmio_base + PDC_20621_SEQMASK); + VPRINTK("mask == 0x%x\n", mask); + + if (mask == 0xffffffff) { + VPRINTK("QUICK EXIT 2\n"); + return IRQ_NONE; + } + mask &= 0xffff; /* only 16 tags possible */ + if (!mask) { + VPRINTK("QUICK EXIT 3\n"); + return IRQ_NONE; + } + + spin_lock(&host_set->lock); + + for (i = 1; i < 9; i++) { + port_no = i - 1; + if (port_no > 3) + port_no -= 4; + if (port_no >= host_set->n_ports) + ap = NULL; + else + ap = host_set->ports[port_no]; + tmp = mask & (1 << i); + VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp); + if (tmp && 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 += pdc20621_host_intr(ap, qc, (i > 4), + mmio_base); + } + } + + spin_unlock(&host_set->lock); + + VPRINTK("mask == 0x%x\n", mask); + + VPRINTK("EXIT\n"); + + return IRQ_RETVAL(handled); +} + +static inline void pdc_dma_complete (struct ata_port *ap, + struct ata_queued_cmd *qc, + int have_err) +{ + u8 err_bit = have_err ? ATA_ERR : 0; + + /* get drive status; clear intr; complete txn */ + ata_qc_complete(qc, ata_wait_idle(ap) | err_bit); +} + +static void pdc_eng_timeout(struct ata_port *ap) +{ + u8 drv_stat; + struct ata_queued_cmd *qc; + + DPRINTK("ENTER\n"); + + qc = ata_qc_from_tag(ap, ap->active_tag); + if (!qc) { + printk(KERN_ERR "ata%u: BUG: timeout without command\n", + ap->id); + goto out; + } + + /* hack alert! We cannot use the supplied completion + * function from inside the ->eh_strategy_handler() thread. + * libata is the only user of ->eh_strategy_handler() in + * any kernel, so the default scsi_done() assumes it is + * not being called from the SCSI EH. + */ + qc->scsidone = scsi_finish_command; + + switch (qc->tf.protocol) { + case ATA_PROT_DMA: + printk(KERN_ERR "ata%u: DMA timeout\n", ap->id); + ata_qc_complete(qc, ata_wait_idle(ap) | ATA_ERR); + break; + + case ATA_PROT_NODATA: + drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); + + printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x\n", + ap->id, qc->tf.command, drv_stat); + + ata_qc_complete(qc, drv_stat); + break; + + default: + drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); + + printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", + ap->id, qc->tf.command, drv_stat); + + ata_qc_complete(qc, drv_stat); + break; + } + +out: + DPRINTK("EXIT\n"); +} + +static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf) +{ + if (tf->protocol == ATA_PROT_PIO) + ata_tf_load_mmio(ap, tf); +} + + +static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf) +{ + if (tf->protocol == ATA_PROT_PIO) + ata_exec_command_mmio(ap, tf); +} + + +static void pdc_sata_setup_port(struct ata_ioports *port, unsigned long base) +{ + port->cmd_addr = base; + port->data_addr = base; + port->feature_addr = + port->error_addr = base + 0x4; + port->nsect_addr = base + 0x8; + port->lbal_addr = base + 0xc; + port->lbam_addr = base + 0x10; + port->lbah_addr = base + 0x14; + port->device_addr = base + 0x18; + port->command_addr = + port->status_addr = base + 0x1c; + port->altstatus_addr = + port->ctl_addr = base + 0x38; +} + + +#ifdef ATA_VERBOSE_DEBUG +static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, void *psource, + u32 offset, u32 size) +{ + u32 window_size; + u16 idx; + u8 page_mask; + long dist; + void *mmio = pe->mmio_base; + struct pdc_host_priv *hpriv = pe->private_data; + void *dimm_mmio = hpriv->dimm_mmio; + + /* hard-code chip #0 */ + mmio += PDC_CHIP0_OFS; + + page_mask = 0x00; + window_size = 0x2000 * 4; /* 32K byte uchar size */ + idx = (u16) (offset / window_size); + + writel(0x01, mmio + PDC_GENERAL_CTLR); + readl(mmio + PDC_GENERAL_CTLR); + writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); + readl(mmio + PDC_DIMM_WINDOW_CTLR); + + offset -= (idx * window_size); + idx++; + dist = ((long) (window_size - (offset + size))) >= 0 ? size : + (long) (window_size - offset); + memcpy_fromio((char *) psource, (char *) (dimm_mmio + offset / 4), + dist); + + psource += dist; + size -= dist; + for (; (long) size >= (long) window_size ;) { + writel(0x01, mmio + PDC_GENERAL_CTLR); + readl(mmio + PDC_GENERAL_CTLR); + writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); + readl(mmio + PDC_DIMM_WINDOW_CTLR); + memcpy_fromio((char *) psource, (char *) (dimm_mmio), + window_size / 4); + psource += window_size; + size -= window_size; + idx ++; + } + + if (size) { + writel(0x01, mmio + PDC_GENERAL_CTLR); + readl(mmio + PDC_GENERAL_CTLR); + writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); + readl(mmio + PDC_DIMM_WINDOW_CTLR); + memcpy_fromio((char *) psource, (char *) (dimm_mmio), + size / 4); + } +} +#endif + + +static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource, + u32 offset, u32 size) +{ + u32 window_size; + u16 idx; + u8 page_mask; + long dist; + void *mmio = pe->mmio_base; + struct pdc_host_priv *hpriv = pe->private_data; + void *dimm_mmio = hpriv->dimm_mmio; + + /* hard-code chip #0 */ + mmio += PDC_CHIP0_OFS; + + page_mask = 0x00; + window_size = 0x2000 * 4; /* 32K byte uchar size */ + idx = (u16) (offset / window_size); + + writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); + readl(mmio + PDC_DIMM_WINDOW_CTLR); + offset -= (idx * window_size); + idx++; + dist = ((long)(s32)(window_size - (offset + size))) >= 0 ? size : + (long) (window_size - offset); + memcpy_toio((char *) (dimm_mmio + offset / 4), (char *) psource, dist); + writel(0x01, mmio + PDC_GENERAL_CTLR); + readl(mmio + PDC_GENERAL_CTLR); + + psource += dist; + size -= dist; + for (; (long) size >= (long) window_size ;) { + writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); + readl(mmio + PDC_DIMM_WINDOW_CTLR); + memcpy_toio((char *) (dimm_mmio), (char *) psource, + window_size / 4); + writel(0x01, mmio + PDC_GENERAL_CTLR); + readl(mmio + PDC_GENERAL_CTLR); + psource += window_size; + size -= window_size; + idx ++; + } + + if (size) { + writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); + readl(mmio + PDC_DIMM_WINDOW_CTLR); + memcpy_toio((char *) (dimm_mmio), (char *) psource, size / 4); + writel(0x01, mmio + PDC_GENERAL_CTLR); + readl(mmio + PDC_GENERAL_CTLR); + } +} + + +static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device, + u32 subaddr, u32 *pdata) +{ + void *mmio = pe->mmio_base; + u32 i2creg = 0; + u32 status; + u32 count =0; + + /* hard-code chip #0 */ + mmio += PDC_CHIP0_OFS; + + i2creg |= device << 24; + i2creg |= subaddr << 16; + + /* Set the device and subaddress */ + writel(i2creg, mmio + PDC_I2C_ADDR_DATA_OFFSET); + readl(mmio + PDC_I2C_ADDR_DATA_OFFSET); + + /* Write Control to perform read operation, mask int */ + writel(PDC_I2C_READ | PDC_I2C_START | PDC_I2C_MASK_INT, + mmio + PDC_I2C_CONTROL_OFFSET); + + for (count = 0; count <= 1000; count ++) { + status = readl(mmio + PDC_I2C_CONTROL_OFFSET); + if (status & PDC_I2C_COMPLETE) { + status = readl(mmio + PDC_I2C_ADDR_DATA_OFFSET); + break; + } else if (count == 1000) + return 0; + } + + *pdata = (status >> 8) & 0x000000ff; + return 1; +} + + +static int pdc20621_detect_dimm(struct ata_probe_ent *pe) +{ + u32 data=0 ; + if (pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS, + PDC_DIMM_SPD_SYSTEM_FREQ, &data)) { + if (data == 100) + return 100; + } else + return 0; + + if (pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS, 9, &data)) { + if(data <= 0x75) + return 133; + } else + return 0; + + return 0; +} + + +static int pdc20621_prog_dimm0(struct ata_probe_ent *pe) +{ + u32 spd0[50]; + u32 data = 0; + int size, i; + u8 bdimmsize; + void *mmio = pe->mmio_base; + static const struct { + unsigned int reg; + unsigned int ofs; + } pdc_i2c_read_data [] = { + { PDC_DIMM_SPD_TYPE, 11 }, + { PDC_DIMM_SPD_FRESH_RATE, 12 }, + { PDC_DIMM_SPD_COLUMN_NUM, 4 }, + { PDC_DIMM_SPD_ATTRIBUTE, 21 }, + { PDC_DIMM_SPD_ROW_NUM, 3 }, + { PDC_DIMM_SPD_BANK_NUM, 17 }, + { PDC_DIMM_SPD_MODULE_ROW, 5 }, + { PDC_DIMM_SPD_ROW_PRE_CHARGE, 27 }, + { PDC_DIMM_SPD_ROW_ACTIVE_DELAY, 28 }, + { PDC_DIMM_SPD_RAS_CAS_DELAY, 29 }, + { PDC_DIMM_SPD_ACTIVE_PRECHARGE, 30 }, + { PDC_DIMM_SPD_CAS_LATENCY, 18 }, + }; + + /* hard-code chip #0 */ + mmio += PDC_CHIP0_OFS; + + for(i=0; i spd0[28]) + ? spd0[29] : spd0[28]) + 9) / 10) - 1) << 10; + data |= ((spd0[30] - spd0[29] + 9) / 10 - 2) << 12; + + if (spd0[18] & 0x08) + data |= ((0x03) << 14); + else if (spd0[18] & 0x04) + data |= ((0x02) << 14); + else if (spd0[18] & 0x01) + data |= ((0x01) << 14); + else + data |= (0 << 14); + + /* + Calculate the size of bDIMMSize (power of 2) and + merge the DIMM size by program start/end address. + */ + + bdimmsize = spd0[4] + (spd0[5] / 2) + spd0[3] + (spd0[17] / 2) + 3; + size = (1 << bdimmsize) >> 20; /* size = xxx(MB) */ + data |= (((size / 16) - 1) << 16); + data |= (0 << 23); + data |= 8; + writel(data, mmio + PDC_DIMM0_CONTROL_OFFSET); + readl(mmio + PDC_DIMM0_CONTROL_OFFSET); + return size; +} + + +static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe) +{ + u32 data, spd0; + int error, i; + void *mmio = pe->mmio_base; + + /* hard-code chip #0 */ + mmio += PDC_CHIP0_OFS; + + /* + Set To Default : DIMM Module Global Control Register (0x022259F1) + DIMM Arbitration Disable (bit 20) + DIMM Data/Control Output Driving Selection (bit12 - bit15) + Refresh Enable (bit 17) + */ + + data = 0x022259F1; + writel(data, mmio + PDC_SDRAM_CONTROL_OFFSET); + readl(mmio + PDC_SDRAM_CONTROL_OFFSET); + + /* Turn on for ECC */ + pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS, + PDC_DIMM_SPD_TYPE, &spd0); + if (spd0 == 0x02) { + data |= (0x01 << 16); + writel(data, mmio + PDC_SDRAM_CONTROL_OFFSET); + readl(mmio + PDC_SDRAM_CONTROL_OFFSET); + printk(KERN_ERR "Local DIMM ECC Enabled\n"); + } + + /* DIMM Initialization Select/Enable (bit 18/19) */ + data &= (~(1<<18)); + data |= (1<<19); + writel(data, mmio + PDC_SDRAM_CONTROL_OFFSET); + + error = 1; + for (i = 1; i <= 10; i++) { /* polling ~5 secs */ + data = readl(mmio + PDC_SDRAM_CONTROL_OFFSET); + if (!(data & (1<<19))) { + error = 0; + break; + } + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout((i * 100) * HZ / 1000 + 1); + } + return error; +} + + +static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe) +{ + int speed, size, length; + u32 addr,spd0,pci_status; + u32 tmp=0; + u32 time_period=0; + u32 tcount=0; + u32 ticks=0; + u32 clock=0; + u32 fparam=0; + void *mmio = pe->mmio_base; + + /* hard-code chip #0 */ + mmio += PDC_CHIP0_OFS; + + /* Initialize PLL based upon PCI Bus Frequency */ + + /* Initialize Time Period Register */ + writel(0xffffffff, mmio + PDC_TIME_PERIOD); + time_period = readl(mmio + PDC_TIME_PERIOD); + VPRINTK("Time Period Register (0x40): 0x%x\n", time_period); + + /* Enable timer */ + writel(0x00001a0, mmio + PDC_TIME_CONTROL); + readl(mmio + PDC_TIME_CONTROL); + + /* Wait 3 seconds */ + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(3 * HZ); + + /* + When timer is enabled, counter is decreased every internal + clock cycle. + */ + + tcount = readl(mmio + PDC_TIME_COUNTER); + VPRINTK("Time Counter Register (0x44): 0x%x\n", tcount); + + /* + If SX4 is on PCI-X bus, after 3 seconds, the timer counter + register should be >= (0xffffffff - 3x10^8). + */ + if(tcount >= PCI_X_TCOUNT) { + ticks = (time_period - tcount); + VPRINTK("Num counters 0x%x (%d)\n", ticks, ticks); + + clock = (ticks / 300000); + VPRINTK("10 * Internal clk = 0x%x (%d)\n", clock, clock); + + clock = (clock * 33); + VPRINTK("10 * Internal clk * 33 = 0x%x (%d)\n", clock, clock); + + /* PLL F Param (bit 22:16) */ + fparam = (1400000 / clock) - 2; + VPRINTK("PLL F Param: 0x%x (%d)\n", fparam, fparam); + + /* OD param = 0x2 (bit 31:30), R param = 0x5 (bit 29:25) */ + pci_status = (0x8a001824 | (fparam << 16)); + } else + pci_status = PCI_PLL_INIT; + + /* Initialize PLL. */ + VPRINTK("pci_status: 0x%x\n", pci_status); + writel(pci_status, mmio + PDC_CTL_STATUS); + readl(mmio + PDC_CTL_STATUS); + + /* + Read SPD of DIMM by I2C interface, + and program the DIMM Module Controller. + */ + if (!(speed = pdc20621_detect_dimm(pe))) { + printk(KERN_ERR "Detect Local DIMM Fail\n"); + return 1; /* DIMM error */ + } + VPRINTK("Local DIMM Speed = %d\n", speed); + + /* Programming DIMM0 Module Control Register (index_CID0:80h) */ + size = pdc20621_prog_dimm0(pe); + VPRINTK("Local DIMM Size = %dMB\n",size); + + /* Programming DIMM Module Global Control Register (index_CID0:88h) */ + if (pdc20621_prog_dimm_global(pe)) { + printk(KERN_ERR "Programming DIMM Module Global Control Register Fail\n"); + return 1; + } + +#ifdef ATA_VERBOSE_DEBUG + { + u8 test_parttern1[40] = {0x55,0xAA,'P','r','o','m','i','s','e',' ', + 'N','o','t',' ','Y','e','t',' ','D','e','f','i','n','e','d',' ', + '1','.','1','0', + '9','8','0','3','1','6','1','2',0,0}; + u8 test_parttern2[40] = {0}; + + pdc20621_put_to_dimm(pe, (void *) test_parttern2, 0x10040, 40); + pdc20621_put_to_dimm(pe, (void *) test_parttern2, 0x40, 40); + + pdc20621_put_to_dimm(pe, (void *) test_parttern1, 0x10040, 40); + pdc20621_get_from_dimm(pe, (void *) test_parttern2, 0x40, 40); + printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], + test_parttern2[1], &(test_parttern2[2])); + pdc20621_get_from_dimm(pe, (void *) test_parttern2, 0x10040, + 40); + printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], + test_parttern2[1], &(test_parttern2[2])); + + pdc20621_put_to_dimm(pe, (void *) test_parttern1, 0x40, 40); + pdc20621_get_from_dimm(pe, (void *) test_parttern2, 0x40, 40); + printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], + test_parttern2[1], &(test_parttern2[2])); + } +#endif + + /* ECC initiliazation. */ + + pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS, + PDC_DIMM_SPD_TYPE, &spd0); + if (spd0 == 0x02) { + VPRINTK("Start ECC initialization\n"); + addr = 0; + length = size * 1024 * 1024; + while (addr < length) { + pdc20621_put_to_dimm(pe, (void *) &tmp, addr, + sizeof(u32)); + addr += sizeof(u32); + } + VPRINTK("Finish ECC initialization\n"); + } + return 0; +} + + +static void pdc_20621_init(struct ata_probe_ent *pe) +{ + u32 tmp; + void *mmio = pe->mmio_base; + + /* hard-code chip #0 */ + mmio += PDC_CHIP0_OFS; + + /* + * Select page 0x40 for our 32k DIMM window + */ + tmp = readl(mmio + PDC_20621_DIMM_WINDOW) & 0xffff0000; + tmp |= PDC_PAGE_WINDOW; /* page 40h; arbitrarily selected */ + writel(tmp, mmio + PDC_20621_DIMM_WINDOW); + + /* + * Reset Host DMA + */ + tmp = readl(mmio + PDC_HDMA_CTLSTAT); + tmp |= PDC_RESET; + writel(tmp, mmio + PDC_HDMA_CTLSTAT); + readl(mmio + PDC_HDMA_CTLSTAT); /* flush */ + + udelay(10); + + tmp = readl(mmio + PDC_HDMA_CTLSTAT); + tmp &= ~PDC_RESET; + writel(tmp, mmio + PDC_HDMA_CTLSTAT); + readl(mmio + PDC_HDMA_CTLSTAT); /* flush */ +} + +static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) +{ + static int printed_version; + struct ata_probe_ent *probe_ent = NULL; + unsigned long base; + void *mmio_base, *dimm_mmio = NULL; + struct pdc_host_priv *hpriv = NULL; + unsigned int board_idx = (unsigned int) ent->driver_data; + int rc; + + if (!printed_version++) + printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); + + /* + * If this driver happens to only be useful on Apple's K2, then + * we should check that here as it has a normal Serverworks ID + */ + 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 == NULL) { + rc = -ENOMEM; + goto err_out_regions; + } + + memset(probe_ent, 0, sizeof(*probe_ent)); + probe_ent->pdev = pdev; + INIT_LIST_HEAD(&probe_ent->node); + + mmio_base = ioremap(pci_resource_start(pdev, 3), + pci_resource_len(pdev, 3)); + if (mmio_base == NULL) { + rc = -ENOMEM; + goto err_out_free_ent; + } + base = (unsigned long) mmio_base; + + hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL); + if (!hpriv) { + rc = -ENOMEM; + goto err_out_iounmap; + } + memset(hpriv, 0, sizeof(*hpriv)); + + dimm_mmio = ioremap(pci_resource_start(pdev, 4), + pci_resource_len(pdev, 4)); + if (!dimm_mmio) { + kfree(hpriv); + rc = -ENOMEM; + goto err_out_iounmap; + } + + hpriv->dimm_mmio = dimm_mmio; + + probe_ent->sht = pdc_port_info[board_idx].sht; + probe_ent->host_flags = pdc_port_info[board_idx].host_flags; + probe_ent->pio_mask = pdc_port_info[board_idx].pio_mask; + probe_ent->udma_mask = pdc_port_info[board_idx].udma_mask; + probe_ent->port_ops = pdc_port_info[board_idx].port_ops; + + probe_ent->irq = pdev->irq; + probe_ent->irq_flags = SA_SHIRQ; + probe_ent->mmio_base = mmio_base; + + probe_ent->private_data = hpriv; + base += PDC_CHIP0_OFS; + + pdc_sata_setup_port(&probe_ent->port[0], base + 0x200); + pdc_sata_setup_port(&probe_ent->port[1], base + 0x280); + + /* notice 4-port boards */ + switch (board_idx) { + case board_20621: + probe_ent->n_ports = 4; + + pdc_sata_setup_port(&probe_ent->port[2], base + 0x300); + pdc_sata_setup_port(&probe_ent->port[3], base + 0x380); + break; + default: + BUG(); + break; + } + + pci_set_master(pdev); + + /* initialize adapter */ + /* initialize local dimm */ + if (pdc20621_dimm_init(probe_ent)) { + rc = -ENOMEM; + goto err_out_iounmap_dimm; + } + pdc_20621_init(probe_ent); + + /* FIXME: check ata_device_add return value */ + ata_device_add(probe_ent); + kfree(probe_ent); + + return 0; + +err_out_iounmap_dimm: /* only get to this label if 20621 */ + kfree(hpriv); + iounmap(dimm_mmio); +err_out_iounmap: + iounmap(mmio_base); +err_out_free_ent: + kfree(probe_ent); +err_out_regions: + pci_release_regions(pdev); +err_out: + pci_disable_device(pdev); + return rc; +} + + +static int __init pdc_sata_init(void) +{ + return pci_module_init(&pdc_sata_pci_driver); +} + + +static void __exit pdc_sata_exit(void) +{ + pci_unregister_driver(&pdc_sata_pci_driver); +} + + +MODULE_AUTHOR("Jeff Garzik"); +MODULE_DESCRIPTION("Promise SATA low-level driver"); +MODULE_LICENSE("GPL"); +MODULE_DEVICE_TABLE(pci, pdc_sata_pci_tbl); + +module_init(pdc_sata_init); +module_exit(pdc_sata_exit); diff --git a/drivers/usb/core/driverfs.c b/drivers/usb/core/driverfs.c deleted file mode 100644 index 51ff9bbd6..000000000 --- a/drivers/usb/core/driverfs.c +++ /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 -#include - -#ifdef CONFIG_USB_DEBUG - #define DEBUG -#else - #undef DEBUG -#endif -#include - -#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); -} diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c new file mode 100644 index 000000000..0c86ff989 --- /dev/null +++ b/drivers/video/pxafb.c @@ -0,0 +1,1381 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +/* + * 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) { + 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: + /* + * 12 or 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; + fbi->palette_size = 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; + + /* + * Set (any) board control register to handle new color depth + */ + pxafb_set_truecolor(fbi->fb.fix.visual == FB_VISUAL_TRUECOLOR); + + 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 + * 12 and 16 bpp modes don't 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, 1, 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_lclk_frequency_10khz() * (unsigned long long)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) + 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 < 12) + { + /* assume any mode with <12 bpp is palette driven */ + 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 */ + } + else + { + /* 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; + } + +#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) * 17, 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%x\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: %u\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; + unsigned long flags; + 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 */ + local_irq_save(flags); + CKEN |= CKEN16_LCD; + local_irq_restore(flags); + + 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 = "pxafb", + .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/fs/ext3/resize.c b/fs/ext3/resize.c new file mode 100644 index 000000000..d1fe21d8f --- /dev/null +++ b/fs/ext3/resize.c @@ -0,0 +1,956 @@ +/* + * linux/fs/ext3/resize.c + * + * Support for resizing an ext3 filesystem while it is mounted. + * + * Copyright (C) 2001, 2002 Andreas Dilger + * + * This could probably be made into a module, because it is not often in use. + */ + +#include + +#define EXT3FS_DEBUG + +#include +#include +#include + +#include +#include + + +#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=" + * 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 */ diff --git a/fs/intermezzo/Makefile b/fs/intermezzo/Makefile deleted file mode 100644 index 260c7af24..000000000 --- a/fs/intermezzo/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# -# Makefile 1.00 Peter Braam -# - -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 index f97bc164d..000000000 --- a/fs/intermezzo/cache.c +++ /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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 index 8f8e2c516..000000000 --- a/fs/intermezzo/dcache.c +++ /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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 index 3ec2e696a..000000000 --- a/fs/intermezzo/dir.c +++ /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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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:: */ - *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 index be91417c1..000000000 --- a/fs/intermezzo/ext_attr.c +++ /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 - * - * 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 -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include "intermezzo_fs.h" -#include "intermezzo_psdev.h" - -#ifdef CONFIG_FS_EXT_ATTR -#include - -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 index f6256427b..000000000 --- a/fs/intermezzo/file.c +++ /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 -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#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 index 9db8cab51..000000000 --- a/fs/intermezzo/fileset.c +++ /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. - * - * 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 -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 index fda188bab..000000000 --- a/fs/intermezzo/inode.c +++ /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 and - * Michael Callahan - * Copyright (C) 1999 Carnegie Mellon University - * Rewritten for Linux 2.1. Peter 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. - * - * Super block/filesystem wide operations - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#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 index 350036517..000000000 --- a/fs/intermezzo/intermezzo_fs.h +++ /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 -#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 -# include -# include -# include -# include -# include - -/* 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 -# include -# include -# include -# include - -# 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 index 4371b161d..000000000 --- a/fs/intermezzo/intermezzo_idl.h +++ /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 -#include - -/* 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 index 99d588d48..000000000 --- a/fs/intermezzo/intermezzo_journal.h +++ /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 index ca612e615..000000000 --- a/fs/intermezzo/intermezzo_kml.h +++ /dev/null @@ -1,260 +0,0 @@ -#ifndef __INTERMEZZO_KML_H -#define __INTERMEZZO_KML_H - -#include "intermezzo_psdev.h" -#include -#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 index 21cc0b94a..000000000 --- a/fs/intermezzo/intermezzo_lib.h +++ /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. - * - * 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 -#else -# include -# include -#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 -# 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 index fff728ad8..000000000 --- a/fs/intermezzo/intermezzo_psdev.h +++ /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 - -/* 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 index 0b3e6ff74..000000000 --- a/fs/intermezzo/intermezzo_upcall.h +++ /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 index 2beda3863..000000000 --- a/fs/intermezzo/journal.c +++ /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. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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; igroup_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; igroup_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 index d1cb293c2..000000000 --- a/fs/intermezzo/journal_ext2.c +++ /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 - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 index b847b6198..000000000 --- a/fs/intermezzo/journal_ext3.c +++ /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 - * 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. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(CONFIG_EXT3_FS) || defined (CONFIG_EXT3_FS_MODULE) -#include -#include -#include -#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 index 702ee8b64..000000000 --- a/fs/intermezzo/journal_obdfs.c +++ /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 - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#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 index 93fc14845..000000000 --- a/fs/intermezzo/journal_reiserfs.c +++ /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 - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if 0 -#if defined(CONFIG_REISERFS_FS) || defined(CONFIG_REISERFS_FS_MODULE) -#include -#include -#include -#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 index 4f3c463f0..000000000 --- a/fs/intermezzo/journal_tmpfs.c +++ /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 - * 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. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(CONFIG_TMPFS) -#include -#if defined(CONFIG_EXT3) -#include -#include -#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 index 59b22a500..000000000 --- a/fs/intermezzo/journal_xfs.c +++ /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 - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if 0 -/* XFS Support not there yet */ -#ifdef CONFIG_FS_XFS -#include -#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 index e992c18f8..000000000 --- a/fs/intermezzo/kml.c +++ /dev/null @@ -1,194 +0,0 @@ -#include -#include -#include -#include -#include - -#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 index f04e7d5fd..000000000 --- a/fs/intermezzo/kml_decode.c +++ /dev/null @@ -1,1016 +0,0 @@ -/* - * KML Decoding - * - * Copryright (C) 1996 Arthur Ma - * - * Copyright (C) 2001 Mountainview Data, Inc. - */ -#include -#include -#include -#include -#include -#include -#include -#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 index e447b766e..000000000 --- a/fs/intermezzo/kml_reint.c +++ /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. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 index 8a017180f..000000000 --- a/fs/intermezzo/kml_setup.c +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include -#include -#include -#include - -#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 index d12a346b3..000000000 --- a/fs/intermezzo/kml_unpack.c +++ /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. - * - * 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 -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#else -# include -# include -# include -# include -# include -# include -# include -#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 index 5062e2d71..000000000 --- a/fs/intermezzo/kml_utils.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include -#include - -#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 index 8950efc8c..000000000 --- a/fs/intermezzo/methods.c +++ /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 -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#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 index bf1603186..000000000 --- a/fs/intermezzo/presto.c +++ /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 - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 index 40a85cc7e..000000000 --- a/fs/intermezzo/psdev.c +++ /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 - * - * 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 - * Michael Callahan - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 index e7a0c5c17..000000000 --- a/fs/intermezzo/replicator.c +++ /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. - * 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. - * - * Manage RCVD records for clients in the kernel - * - */ - -#include -#include - -#include -#include -#include - -#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 index 9993ef2bf..000000000 --- a/fs/intermezzo/super.c +++ /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 - * 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 -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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. "); -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 index 9436adf7a..000000000 --- a/fs/intermezzo/sysctl.c +++ /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 - * - * 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 /* for CONFIG_PROC_FS */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 - * 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 index 8019157dd..000000000 --- a/fs/intermezzo/upcall.c +++ /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. - * 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. - * - * Mostly platform independent upcall operations to a cache manager: - * -- upcalls - * -- upcall routines - * - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 index 84b5882a5..000000000 --- a/fs/intermezzo/vfs.c +++ /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 - * Andreas Dilger - * 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 -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "intermezzo_fs.h" -#include "intermezzo_psdev.h" - -#ifdef CONFIG_FS_EXT_ATTR -# include - -# if 0 /* was a broken check for Posix ACLs */ -# include -# 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 diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c new file mode 100644 index 000000000..eacbdca43 --- /dev/null +++ b/fs/reiserfs/xattr_security.c @@ -0,0 +1,69 @@ +#include +#include +#include +#include +#include +#include +#include + +#define XATTR_SECURITY_PREFIX "security." + +static int +security_get (struct inode *inode, const char *name, void *buffer, size_t size) +{ + if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) + return -EINVAL; + + if (is_reiserfs_priv_object(inode)) + return -EPERM; + + return reiserfs_xattr_get (inode, name, buffer, size); +} + +static int +security_set (struct inode *inode, const char *name, const void *buffer, + size_t size, int flags) +{ + if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) + return -EINVAL; + + if (is_reiserfs_priv_object(inode)) + return -EPERM; + + return reiserfs_xattr_set (inode, name, buffer, size, flags); +} + +static int +security_del (struct inode *inode, const char *name) +{ + if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) + return -EINVAL; + + if (is_reiserfs_priv_object(inode)) + return -EPERM; + + return 0; +} + +static int +security_list (struct inode *inode, const char *name, int namelen, char *out) +{ + int len = namelen; + + if (is_reiserfs_priv_object(inode)) + return 0; + + if (out) + memcpy (out, name, len); + + return len; +} + + +struct reiserfs_xattr_handler security_handler = { + prefix: XATTR_SECURITY_PREFIX, + get: security_get, + set: security_set, + del: security_del, + list: security_list, +}; diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c new file mode 100644 index 000000000..39a10ec8c --- /dev/null +++ b/fs/reiserfs/xattr_trusted.c @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include +#include +#include + +#define XATTR_TRUSTED_PREFIX "trusted." + +static int +trusted_get (struct inode *inode, const char *name, void *buffer, size_t size) +{ + if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) + return -EINVAL; + + if (!reiserfs_xattrs (inode->i_sb)) + return -EOPNOTSUPP; + + if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode))) + return -EPERM; + + return reiserfs_xattr_get (inode, name, buffer, size); +} + +static int +trusted_set (struct inode *inode, const char *name, const void *buffer, + size_t size, int flags) +{ + if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) + return -EINVAL; + + if (!reiserfs_xattrs (inode->i_sb)) + return -EOPNOTSUPP; + + if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode))) + return -EPERM; + + return reiserfs_xattr_set (inode, name, buffer, size, flags); +} + +static int +trusted_del (struct inode *inode, const char *name) +{ + if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) + return -EINVAL; + + if (!reiserfs_xattrs (inode->i_sb)) + return -EOPNOTSUPP; + + if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode))) + return -EPERM; + + return 0; +} + +static int +trusted_list (struct inode *inode, const char *name, int namelen, char *out) +{ + int len = namelen; + + if (!reiserfs_xattrs (inode->i_sb)) + return 0; + + if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode))) + return 0; + + if (out) + memcpy (out, name, len); + + return len; +} + + +struct reiserfs_xattr_handler trusted_handler = { + prefix: XATTR_TRUSTED_PREFIX, + get: trusted_get, + set: trusted_set, + del: trusted_del, + list: trusted_list, +}; diff --git a/fs/reiserfs/xattr_user.c b/fs/reiserfs/xattr_user.c new file mode 100644 index 000000000..38779f3fd --- /dev/null +++ b/fs/reiserfs/xattr_user.c @@ -0,0 +1,99 @@ +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_REISERFS_FS_POSIX_ACL +# include +#endif + +#define XATTR_USER_PREFIX "user." + +static int +user_get (struct inode *inode, const char *name, void *buffer, size_t size) +{ + + int error; + + if (strlen(name) < sizeof(XATTR_USER_PREFIX)) + return -EINVAL; + + if (!reiserfs_xattrs_user (inode->i_sb)) + return -EOPNOTSUPP; + + error = reiserfs_permission_locked (inode, MAY_READ, NULL); + if (error) + return error; + + return reiserfs_xattr_get (inode, name, buffer, size); +} + +static int +user_set (struct inode *inode, const char *name, const void *buffer, + size_t size, int flags) +{ + + int error; + + if (strlen(name) < sizeof(XATTR_USER_PREFIX)) + return -EINVAL; + + if (!reiserfs_xattrs_user (inode->i_sb)) + return -EOPNOTSUPP; + + if (!S_ISREG (inode->i_mode) && + (!S_ISDIR (inode->i_mode) || inode->i_mode & S_ISVTX)) + return -EPERM; + + error = reiserfs_permission_locked (inode, MAY_WRITE, NULL); + if (error) + return error; + + return reiserfs_xattr_set (inode, name, buffer, size, flags); +} + +static int +user_del (struct inode *inode, const char *name) +{ + int error; + + if (strlen(name) < sizeof(XATTR_USER_PREFIX)) + return -EINVAL; + + if (!reiserfs_xattrs_user (inode->i_sb)) + return -EOPNOTSUPP; + + if (!S_ISREG (inode->i_mode) && + (!S_ISDIR (inode->i_mode) || inode->i_mode & S_ISVTX)) + return -EPERM; + + error = reiserfs_permission_locked (inode, MAY_WRITE, NULL); + if (error) + return error; + + return 0; +} + +static int +user_list (struct inode *inode, const char *name, int namelen, char *out) +{ + int len = namelen; + if (!reiserfs_xattrs_user (inode->i_sb)) + return 0; + + if (out) + memcpy (out, name, len); + + return len; +} + +struct reiserfs_xattr_handler user_handler = { + prefix: XATTR_USER_PREFIX, + get: user_get, + set: user_set, + del: user_del, + list: user_list, +}; diff --git a/fs/xfs/linux/mutex.h b/fs/xfs/linux-2.6/mutex.h similarity index 100% rename from fs/xfs/linux/mutex.h rename to fs/xfs/linux-2.6/mutex.h diff --git a/fs/xfs/linux/spin.h b/fs/xfs/linux-2.6/spin.h similarity index 77% rename from fs/xfs/linux/spin.h rename to fs/xfs/linux-2.6/spin.h index 80a3a6bae..bcf60a0b8 100644 --- a/fs/xfs/linux/spin.h +++ b/fs/xfs/linux-2.6/spin.h @@ -38,37 +38,19 @@ /* * 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. + * We do not make use of lock_t from interrupt context, so we do not + * have to worry about disabling interrupts at all (unlike IRIX). */ -#define SPLDECL(s) unsigned long s - typedef spinlock_t lock_t; +#define SPLDECL(s) unsigned long s + #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); -} +#define mutex_spinlock(lock) ({ spin_lock(lock); 0; }) +#define mutex_spinunlock(lock, s) do { spin_unlock(lock); (void)s; } while (0) +#define nested_spinlock(lock) spin_lock(lock) +#define nested_spinunlock(lock) spin_unlock(lock) #endif /* __XFS_SUPPORT_SPIN_H__ */ diff --git a/fs/xfs/linux/time.h b/fs/xfs/linux-2.6/time.h similarity index 97% rename from fs/xfs/linux/time.h rename to fs/xfs/linux-2.6/time.h index 109b5c083..6c6fd0faa 100644 --- a/fs/xfs/linux/time.h +++ b/fs/xfs/linux-2.6/time.h @@ -39,7 +39,7 @@ typedef struct timespec timespec_t; static inline void delay(long ticks) { - current->state = TASK_UNINTERRUPTIBLE; + set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(ticks); } diff --git a/fs/xfs/linux/xfs_cred.h b/fs/xfs/linux-2.6/xfs_cred.h similarity index 100% rename from fs/xfs/linux/xfs_cred.h rename to fs/xfs/linux-2.6/xfs_cred.h diff --git a/fs/xfs/linux/xfs_fs_subr.h b/fs/xfs/linux-2.6/xfs_fs_subr.h similarity index 100% rename from fs/xfs/linux/xfs_fs_subr.h rename to fs/xfs/linux-2.6/xfs_fs_subr.h diff --git a/fs/xfs/linux/xfs_globals.h b/fs/xfs/linux-2.6/xfs_globals.h similarity index 100% rename from fs/xfs/linux/xfs_globals.h rename to fs/xfs/linux-2.6/xfs_globals.h diff --git a/fs/xfs/linux/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c similarity index 96% rename from fs/xfs/linux/xfs_iops.c rename to fs/xfs/linux-2.6/xfs_iops.c index 4b3e61d6c..e7d4eba4c 100644 --- a/fs/xfs/linux/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -419,13 +419,16 @@ linvfs_follow_link( ASSERT(nd); link = (char *)kmalloc(MAXNAMELEN+1, GFP_KERNEL); - if (!link) - return -ENOMEM; + if (!link) { + nd_set_link(nd, ERR_PTR(-ENOMEM)); + return 0; + } uio = (uio_t *)kmalloc(sizeof(uio_t), GFP_KERNEL); if (!uio) { kfree(link); - return -ENOMEM; + nd_set_link(nd, ERR_PTR(-ENOMEM)); + return 0; } vp = LINVFS_GET_VP(dentry->d_inode); @@ -441,18 +444,22 @@ linvfs_follow_link( VOP_READLINK(vp, uio, 0, NULL, error); if (error) { - kfree(uio); kfree(link); - return -error; + link = ERR_PTR(-error); + } else { + link[MAXNAMELEN - uio->uio_resid] = '\0'; } - - link[MAXNAMELEN - uio->uio_resid] = '\0'; kfree(uio); - /* vfs_follow_link returns (-) errors */ - error = vfs_follow_link(nd, link); - kfree(link); - return error; + nd_set_link(nd, link); + return 0; +} + +static void linvfs_put_link(struct dentry *dentry, struct nameidata *nd) +{ + char *s = nd_get_link(nd); + if (!IS_ERR(s)) + kfree(s); } #ifdef CONFIG_XFS_POSIX_ACL @@ -535,7 +542,7 @@ linvfs_setattr( } if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) - flags = ATTR_UTIME; + flags |= ATTR_UTIME; #ifdef ATTR_NO_BLOCK if ((ia_valid & ATTR_NO_BLOCK)) flags |= ATTR_NONBLOCK; @@ -543,14 +550,8 @@ linvfs_setattr( 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; + vn_revalidate(vp); return error; } @@ -698,6 +699,7 @@ struct inode_operations linvfs_dir_inode_operations = { struct inode_operations linvfs_symlink_inode_operations = { .readlink = linvfs_readlink, .follow_link = linvfs_follow_link, + .put_link = linvfs_put_link, .permission = linvfs_permission, .getattr = linvfs_getattr, .setattr = linvfs_setattr, diff --git a/fs/xfs/linux/xfs_stats.h b/fs/xfs/linux-2.6/xfs_stats.h similarity index 100% rename from fs/xfs/linux/xfs_stats.h rename to fs/xfs/linux-2.6/xfs_stats.h diff --git a/fs/xfs/linux/xfs_version.h b/fs/xfs/linux-2.6/xfs_version.h similarity index 100% rename from fs/xfs/linux/xfs_version.h rename to fs/xfs/linux-2.6/xfs_version.h diff --git a/fs/xfs/linux/kmem.h b/fs/xfs/linux/kmem.h deleted file mode 100644 index c9df16472..000000000 --- a/fs/xfs/linux/kmem.h +++ /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 -#include -#include -#include - -/* - * 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 index d2c11a098..000000000 --- a/fs/xfs/linux/mrlock.h +++ /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 - -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/sema.h b/fs/xfs/linux/sema.h deleted file mode 100644 index 30b67b4e1..000000000 --- a/fs/xfs/linux/sema.h +++ /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 -#include -#include -#include - -/* - * 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/sv.h b/fs/xfs/linux/sv.h deleted file mode 100644 index 821d3167e..000000000 --- a/fs/xfs/linux/sv.h +++ /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 -#include -#include - -/* - * 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/xfs_aops.c b/fs/xfs/linux/xfs_aops.c deleted file mode 100644 index 3afc61d10..000000000 --- a/fs/xfs/linux/xfs_aops.c +++ /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 - -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 index 69050a0de..000000000 --- a/fs/xfs/linux/xfs_buf.c +++ /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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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<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 index f97e6c0cd..000000000 --- a/fs/xfs/linux/xfs_buf.h +++ /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 -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * 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_file.c b/fs/xfs/linux/xfs_file.c deleted file mode 100644 index 8d9f3b55f..000000000 --- a/fs/xfs/linux/xfs_file.c +++ /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 - -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 index afad97018..000000000 --- a/fs/xfs/linux/xfs_fs_subr.c +++ /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_globals.c b/fs/xfs/linux/xfs_globals.c deleted file mode 100644 index 1144a8b9f..000000000 --- a/fs/xfs/linux/xfs_globals.c +++ /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_ioctl.c b/fs/xfs/linux/xfs_ioctl.c deleted file mode 100644 index d6402d746..000000000 --- a/fs/xfs/linux/xfs_ioctl.c +++ /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 -#include -#include -#include - -/* - * 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.h b/fs/xfs/linux/xfs_iops.h deleted file mode 100644 index f0f5c870f..000000000 --- a/fs/xfs/linux/xfs_iops.h +++ /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 index 70481f85f..000000000 --- a/fs/xfs/linux/xfs_linux.h +++ /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 -#include - -/* - * 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 -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * 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<>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) -#define ctob64(x) ((__uint64_t)(x)<>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 index 4bacdb76a..000000000 --- a/fs/xfs/linux/xfs_lrw.c +++ /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 - - -#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 index faf0afc70..000000000 --- a/fs/xfs/linux/xfs_lrw.h +++ /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 index b7de296e1..000000000 --- a/fs/xfs/linux/xfs_stats.c +++ /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 - -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_super.c b/fs/xfs/linux/xfs_super.c deleted file mode 100644 index bbaf61bee..000000000 --- a/fs/xfs/linux/xfs_super.c +++ /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 -#include -#include -#include - -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<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 index 557626919..000000000 --- a/fs/xfs/linux/xfs_super.h +++ /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 index b9a97c9d7..000000000 --- a/fs/xfs/linux/xfs_sysctl.c +++ /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 -#include - - -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 index 0532d4012..000000000 --- a/fs/xfs/linux/xfs_sysctl.h +++ /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 - -/* - * 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_vfs.c b/fs/xfs/linux/xfs_vfs.c deleted file mode 100644 index 2b75cccdf..000000000 --- a/fs/xfs/linux/xfs_vfs.c +++ /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 index dc1cd1973..000000000 --- a/fs/xfs/linux/xfs_vfs.h +++ /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 -#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 index 9240efb2b..000000000 --- a/fs/xfs/linux/xfs_vnode.c +++ /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 index af0b65fe5..000000000 --- a/fs/xfs/linux/xfs_vnode.h +++ /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__ */ diff --git a/include/asm-alpha/8253pit.h b/include/asm-alpha/8253pit.h new file mode 100644 index 000000000..fef5c1450 --- /dev/null +++ b/include/asm-alpha/8253pit.h @@ -0,0 +1,10 @@ +/* + * 8253/8254 Programmable Interval Timer + */ + +#ifndef _8253PIT_H +#define _8253PIT_H + +#define PIT_TICK_RATE 1193180UL + +#endif diff --git a/include/asm-alpha/rmap.h b/include/asm-alpha/rmap.h deleted file mode 100644 index 08b2236ef..000000000 --- a/include/asm-alpha/rmap.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _ALPHA_RMAP_H -#define _ALPHA_RMAP_H - -/* nothing to see, move along */ -#include - -#endif diff --git a/include/asm-arm/arch-cl7500/ide.h b/include/asm-arm/arch-cl7500/ide.h deleted file mode 100644 index 78f97a3b2..000000000 --- a/include/asm-arm/arch-cl7500/ide.h +++ /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 -#include - -/* - * 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 index 660b31a0e..000000000 --- a/include/asm-arm/arch-cl7500/keyboard.h +++ /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 -#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-clps711x/keyboard.h b/include/asm-arm/arch-clps711x/keyboard.h deleted file mode 100644 index 30ab2199f..000000000 --- a/include/asm-arm/arch-clps711x/keyboard.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * linux/include/asm-arm/arch-clps711x/keyboard.h - * - * Copyright (C) 1998-2001 Russell King - */ -#include - -#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 index 35eff5c28..000000000 --- a/include/asm-arm/arch-ebsa110/ide.h +++ /dev/null @@ -1 +0,0 @@ -/* no ide */ diff --git a/include/asm-arm/arch-ebsa285/ide.h b/include/asm-arm/arch-ebsa285/ide.h deleted file mode 100644 index 09c0310b6..000000000 --- a/include/asm-arm/arch-ebsa285/ide.h +++ /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 - -/* - * 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-iop3xx/ide.h b/include/asm-arm/arch-iop3xx/ide.h deleted file mode 100644 index c2b0265dd..000000000 --- a/include/asm-arm/arch-iop3xx/ide.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * include/asm-arm/arch-iop3xx/ide.h - * - * Generic IDE functions for IOP310 systems - * - * Author: Deepak Saxena - * - * 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-ixp4xx/coyote.h b/include/asm-arm/arch-ixp4xx/coyote.h new file mode 100644 index 000000000..dd0c2d2d8 --- /dev/null +++ b/include/asm-arm/arch-ixp4xx/coyote.h @@ -0,0 +1,36 @@ +/* + * include/asm-arm/arch-ixp4xx/coyote.h + * + * ADI Engineering platform specific definitions + * + * Author: Deepak Saxena + * + * Copyright 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. + */ + +#ifndef __ASM_ARCH_HARDWARE_H__ +#error "Do not include this directly, instead #include " +#endif + +#define COYOTE_FLASH_BASE IXP4XX_EXP_BUS_CS0_BASE_PHYS +#define COYOTE_FLASH_SIZE IXP4XX_EXP_BUS_CSX_REGION_SIZE * 2 + +/* PCI controller GPIO to IRQ pin mappings */ +#define COYOTE_PCI_SLOT0_PIN 6 +#define COYOTE_PCI_SLOT1_PIN 11 + +#define COYOTE_PCI_SLOT0_DEVID 14 +#define COYOTE_PCI_SLOT1_DEVID 15 + +#define COYOTE_IDE_BASE_PHYS IXP4XX_EXP_BUS_CS3_BASE_PHYS +#define COYOTE_IDE_BASE_VIRT 0xFFFE1000 +#define COYOTE_IDE_REGION_SIZE 0x1000 + +#define COYOTE_IDE_DATA_PORT 0xFFFE10E0 +#define COYOTE_IDE_CTRL_PORT 0xFFFE10FC +#define COYOTE_IDE_ERROR_PORT 0xFFFE10E2 + diff --git a/include/asm-arm/arch-ixp4xx/hardware.h b/include/asm-arm/arch-ixp4xx/hardware.h new file mode 100644 index 000000000..a048cbc58 --- /dev/null +++ b/include/asm-arm/arch-ixp4xx/hardware.h @@ -0,0 +1,41 @@ +/* + * include/asm-arm/arch-ixp4xx/hardware.h + * + * Copyright (C) 2002 Intel Corporation. + * 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. + * + */ + +/* + * Hardware definitions for IXP4xx based systems + */ + +#ifndef __ASM_ARCH_HARDWARE_H__ +#define __ASM_ARCH_HARDWARE_H__ + +#define PCIBIOS_MIN_IO 0x00001000 +#define PCIBIOS_MIN_MEM 0x48000000 + +/* + * We override the standard dma-mask routines for bouncing. + */ +#define HAVE_ARCH_PCI_SET_DMA_MASK + +#define pcibios_assign_all_busses() 1 + +/* Register locations and bits */ +#include "ixp4xx-regs.h" + +/* Platform helper functions and definitions */ +#include "platform.h" + +/* Platform specific details */ +#include "ixdp425.h" +#include "coyote.h" +#include "prpmc1100.h" + +#endif /* _ASM_ARCH_HARDWARE_H */ diff --git a/include/asm-arm/arch-ixp4xx/irqs.h b/include/asm-arm/arch-ixp4xx/irqs.h new file mode 100644 index 000000000..c782b560c --- /dev/null +++ b/include/asm-arm/arch-ixp4xx/irqs.h @@ -0,0 +1,78 @@ +/* + * include/asm-arm/arch-ixp4xx/irqs.h + * + * IRQ definitions for IXP4XX based systems + * + * Copyright (C) 2002 Intel Corporation. + * Copyright (C) 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 version 2 as + * published by the Free Software Foundation. + * + */ + +#ifndef _ARCH_IXP4XX_IRQS_H_ +#define _ARCH_IXP4XX_IRQS_H_ + +#define NR_IRQS 32 + +#define IRQ_IXP4XX_NPEA 0 +#define IRQ_IXP4XX_NPEB 1 +#define IRQ_IXP4XX_NPEC 2 +#define IRQ_IXP4XX_QM1 3 +#define IRQ_IXP4XX_QM2 4 +#define IRQ_IXP4XX_TIMER1 5 +#define IRQ_IXP4XX_GPIO0 6 +#define IRQ_IXP4XX_GPIO1 7 +#define IRQ_IXP4XX_PCI_INT 8 +#define IRQ_IXP4XX_PCI_DMA1 9 +#define IRQ_IXP4XX_PCI_DMA2 10 +#define IRQ_IXP4XX_TIMER2 11 +#define IRQ_IXP4XX_USB 12 +#define IRQ_IXP4XX_UART2 13 +#define IRQ_IXP4XX_TIMESTAMP 14 +#define IRQ_IXP4XX_UART1 15 +#define IRQ_IXP4XX_WDOG 16 +#define IRQ_IXP4XX_AHB_PMU 17 +#define IRQ_IXP4XX_XSCALE_PMU 18 +#define IRQ_IXP4XX_GPIO2 19 +#define IRQ_IXP4XX_GPIO3 20 +#define IRQ_IXP4XX_GPIO4 21 +#define IRQ_IXP4XX_GPIO5 22 +#define IRQ_IXP4XX_GPIO6 23 +#define IRQ_IXP4XX_GPIO7 24 +#define IRQ_IXP4XX_GPIO8 25 +#define IRQ_IXP4XX_GPIO9 26 +#define IRQ_IXP4XX_GPIO10 27 +#define IRQ_IXP4XX_GPIO11 28 +#define IRQ_IXP4XX_GPIO12 29 +#define IRQ_IXP4XX_SW_INT1 30 +#define IRQ_IXP4XX_SW_INT2 31 + +#define XSCALE_PMU_IRQ (IRQ_IXP4XX_XSCALE_PMU) + +/* + * IXDP425 board IRQs + */ +#define IRQ_IXDP425_PCI_INTA IRQ_IXP4XX_GPIO11 +#define IRQ_IXDP425_PCI_INTB IRQ_IXP4XX_GPIO10 +#define IRQ_IXDP425_PCI_INTC IRQ_IXP4XX_GPIO9 +#define IRQ_IXDP425_PCI_INTD IRQ_IXP4XX_GPIO8 + +/* + * PrPMC1100 Board IRQs + */ +#define IRQ_PRPMC1100_PCI_INTA IRQ_IXP4XX_GPIO11 +#define IRQ_PRPMC1100_PCI_INTB IRQ_IXP4XX_GPIO10 +#define IRQ_PRPMC1100_PCI_INTC IRQ_IXP4XX_GPIO9 +#define IRQ_PRPMC1100_PCI_INTD IRQ_IXP4XX_GPIO8 + +/* + * ADI Coyote Board IRQs + */ +#define IRQ_COYOTE_PCI_SLOT0 IRQ_IXP4XX_GPIO6 +#define IRQ_COYOTE_PCI_SLOT1 IRQ_IXP4XX_GPIO11 +#define IRQ_COYOTE_IDE IRQ_IXP4XX_GPIO5 + +#endif diff --git a/include/asm-arm/arch-ixp4xx/ixdp425.h b/include/asm-arm/arch-ixp4xx/ixdp425.h new file mode 100644 index 000000000..7d21bf941 --- /dev/null +++ b/include/asm-arm/arch-ixp4xx/ixdp425.h @@ -0,0 +1,38 @@ +/* + * include/asm-arm/arch-ixp4xx/ixdp425.h + * + * IXDP425 platform specific definitions + * + * Author: Deepak Saxena + * + * Copyright 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. + */ + +#ifndef __ASM_ARCH_HARDWARE_H__ +#error "Do not include this directly, instead #include " +#endif + +#define IXDP425_FLASH_BASE IXP4XX_EXP_BUS_CS0_BASE_PHYS +#define IXDP425_FLASH_SIZE IXP4XX_EXP_BUS_CSX_REGION_SIZE + +#define IXDP425_SDA_PIN 7 +#define IXDP425_SCL_PIN 6 + +/* + * IXDP425 PCI IRQs + */ +#define IXDP425_PCI_MAX_DEV 4 +#define IXDP425_PCI_IRQ_LINES 4 + + +/* PCI controller GPIO to IRQ pin mappings */ +#define IXDP425_PCI_INTA_PIN 11 +#define IXDP425_PCI_INTB_PIN 10 +#define IXDP425_PCI_INTC_PIN 9 +#define IXDP425_PCI_INTD_PIN 8 + + diff --git a/include/asm-arm/arch-ixp4xx/ixp4xx-regs.h b/include/asm-arm/arch-ixp4xx/ixp4xx-regs.h new file mode 100644 index 000000000..b5810b254 --- /dev/null +++ b/include/asm-arm/arch-ixp4xx/ixp4xx-regs.h @@ -0,0 +1,551 @@ +/* + * include/asm-arm/arch-ixp4xx/ixp4xx-regs.h + * + * Register definitions for IXP4xx chipset. This file contains + * register location and bit definitions only. Platform specific + * definitions and helper function declarations are in platform.h + * and machine-name.h. + * + * Copyright (C) 2002 Intel Corporation. + * 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. + * + */ + +#ifndef __ASM_ARCH_HARDWARE_H__ +#error "Do not include this directly, instead #include " +#endif + +#ifndef _ASM_ARM_IXP4XX_H_ +#define _ASM_ARM_IXP4XX_H_ + +/* + * IXP4xx Linux Memory Map: + * + * Phy Size Virt Description + * ========================================================================= + * + * 0x00000000 0x10000000(max) PAGE_OFFSET System RAM + * + * 0x48000000 0x04000000 ioremap'd PCI Memory Space + * + * 0x50000000 0x10000000 ioremap'd EXP BUS + * + * 0x6000000 0x00004000 ioremap'd QMgr + * + * 0xC0000000 0x00001000 0xffbfe000 PCI CFG + * + * 0xC4000000 0x00001000 0xffbfd000 EXP CFG + * + * 0xC8000000 0x0000C000 0xffbf2000 On-Chip Peripherals + */ + + +/* + * Expansion BUS Configuration registers + */ +#define IXP4XX_EXP_CFG_BASE_PHYS (0xC4000000) +#define IXP4XX_EXP_CFG_BASE_VIRT (0xFFBFD000) +#define IXP4XX_EXP_CFG_REGION_SIZE (0x00001000) + +/* + * PCI Config registers + */ +#define IXP4XX_PCI_CFG_BASE_PHYS (0xC0000000) +#define IXP4XX_PCI_CFG_BASE_VIRT (0xFFBFD000) +#define IXP4XX_PCI_CFG_REGION_SIZE (0x00001000) + +/* + * Peripheral space + */ +#define IXP4XX_PERIPHERAL_BASE_PHYS (0xC8000000) +#define IXP4XX_PERIPHERAL_BASE_VIRT (0xFFBF2000) +#define IXP4XX_PERIPHERAL_REGION_SIZE (0x0000C000) + +#define IXP4XX_EXP_CS0_OFFSET 0x00 +#define IXP4XX_EXP_CS1_OFFSET 0x04 +#define IXP4XX_EXP_CS2_OFFSET 0x08 +#define IXP4XX_EXP_CS3_OFFSET 0x0C +#define IXP4XX_EXP_CS4_OFFSET 0x10 +#define IXP4XX_EXP_CS5_OFFSET 0x14 +#define IXP4XX_EXP_CS6_OFFSET 0x18 +#define IXP4XX_EXP_CS7_OFFSET 0x1C +#define IXP4XX_EXP_CFG0_OFFSET 0x20 +#define IXP4XX_EXP_CFG1_OFFSET 0x24 +#define IXP4XX_EXP_CFG2_OFFSET 0x28 +#define IXP4XX_EXP_CFG3_OFFSET 0x2C + +/* + * Expansion Bus Controller registers. + */ +#define IXP4XX_EXP_REG(x) ((volatile u32 *)(IXP4XX_EXP_CFG_BASE_VIRT+(x))) + +#define IXP4XX_EXP_CS0 IXP4XX_EXP_REG(IXP4XX_EXP_CS0_OFFSET) +#define IXP4XX_EXP_CS1 IXP4XX_EXP_REG(IXP4XX_EXP_CS1_OFFSET) +#define IXP4XX_EXP_CS2 IXP4XX_EXP_REG(IXP4XX_EXP_CS2_OFFSET) +#define IXP4XX_EXP_CS3 IXP4XX_EXP_REG(IXP4XX_EXP_CS3_OFFSET) +#define IXP4XX_EXP_CS4 IXP4XX_EXP_REG(IXP4XX_EXP_CS4_OFFSET) +#define IXP4XX_EXP_CS5 IXP4XX_EXP_REG(IXP4XX_EXP_CS5_OFFSET) +#define IXP4XX_EXP_CS6 IXP4XX_EXP_REG(IXP4XX_EXP_CS6_OFFSET) +#define IXP4XX_EXP_CS7 IXP4XX_EXP_REG(IXP4XX_EXP_CS7_OFFSET) + +#define IXP4XX_EXP_CFG0 IXP4XX_EXP_REG(IXP4XX_EXP_CFG0_OFFSET) +#define IXP4XX_EXP_CFG1 IXP4XX_EXP_REG(IXP4XX_EXP_CFG1_OFFSET) +#define IXP4XX_EXP_CFG2 IXP4XX_EXP_REG(IXP4XX_EXP_CFG2_OFFSET) +#define IXP4XX_EXP_CFG3 IXP4XX_EXP_REG(IXP4XX_EXP_CFG3_OFFSET) + + +/* + * Peripheral Space Register Region Base Addresses + */ +#define IXP4XX_UART1_BASE_PHYS (IXP4XX_PERIPHERAL_BASE_PHYS + 0x0000) +#define IXP4XX_UART2_BASE_PHYS (IXP4XX_PERIPHERAL_BASE_PHYS + 0x1000) +#define IXP4XX_PMU_BASE_PHYS (IXP4XX_PERIPHERAL_BASE_PHYS + 0x2000) +#define IXP4XX_INTC_BASE_PHYS (IXP4XX_PERIPHERAL_BASE_PHYS + 0x3000) +#define IXP4XX_GPIO_BASE_PHYS (IXP4XX_PERIPHERAL_BASE_PHYS + 0x4000) +#define IXP4XX_TIMER_BASE_PHYS (IXP4XX_PERIPHERAL_BASE_PHYS + 0x5000) +#define IXP4XX_USB_BASE_PHYS (IXP4XX_PERIPHERAL_BASE_PHYS + 0x5000) + +#define IXP4XX_UART1_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x0000) +#define IXP4XX_UART2_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x1000) +#define IXP4XX_PMU_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x2000) +#define IXP4XX_INTC_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x3000) +#define IXP4XX_GPIO_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x4000) +#define IXP4XX_TIMER_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x5000) +#define IXP4XX_USB_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x5000) + +/* + * Constants to make it easy to access Interrupt Controller registers + */ +#define IXP4XX_ICPR_OFFSET 0x00 /* Interrupt Status */ +#define IXP4XX_ICMR_OFFSET 0x04 /* Interrupt Enable */ +#define IXP4XX_ICLR_OFFSET 0x08 /* Interrupt IRQ/FIQ Select */ +#define IXP4XX_ICIP_OFFSET 0x0C /* IRQ Status */ +#define IXP4XX_ICFP_OFFSET 0x10 /* FIQ Status */ +#define IXP4XX_ICHR_OFFSET 0x14 /* Interrupt Priority */ +#define IXP4XX_ICIH_OFFSET 0x18 /* IRQ Highest Pri Int */ +#define IXP4XX_ICFH_OFFSET 0x1C /* FIQ Highest Pri Int */ + +/* + * Interrupt Controller Register Definitions. + */ + +#define IXP4XX_INTC_REG(x) ((volatile u32 *)(IXP4XX_INTC_BASE_VIRT+(x))) + +#define IXP4XX_ICPR IXP4XX_INTC_REG(IXP4XX_ICPR_OFFSET) +#define IXP4XX_ICMR IXP4XX_INTC_REG(IXP4XX_ICMR_OFFSET) +#define IXP4XX_ICLR IXP4XX_INTC_REG(IXP4XX_ICLR_OFFSET) +#define IXP4XX_ICIP IXP4XX_INTC_REG(IXP4XX_ICIP_OFFSET) +#define IXP4XX_ICFP IXP4XX_INTC_REG(IXP4XX_ICFP_OFFSET) +#define IXP4XX_ICHR IXP4XX_INTC_REG(IXP4XX_ICHR_OFFSET) +#define IXP4XX_ICIH IXP4XX_INTC_REG(IXP4XX_ICIH_OFFSET) +#define IXP4XX_ICFH IXP4XX_INTC_REG(IXP4XX_ICFH_OFFSET) + +/* + * Constants to make it easy to access GPIO registers + */ +#define IXP4XX_GPIO_GPOUTR_OFFSET 0x00 +#define IXP4XX_GPIO_GPOER_OFFSET 0x04 +#define IXP4XX_GPIO_GPINR_OFFSET 0x08 +#define IXP4XX_GPIO_GPISR_OFFSET 0x0C +#define IXP4XX_GPIO_GPIT1R_OFFSET 0x10 +#define IXP4XX_GPIO_GPIT2R_OFFSET 0x14 +#define IXP4XX_GPIO_GPCLKR_OFFSET 0x18 +#define IXP4XX_GPIO_GPDBSELR_OFFSET 0x1C + +/* + * GPIO Register Definitions. + * [Only perform 32bit reads/writes] + */ +#define IXP4XX_GPIO_REG(x) ((volatile u32 *)(IXP4XX_GPIO_BASE_VIRT+(x))) + +#define IXP4XX_GPIO_GPOUTR IXP4XX_GPIO_REG(IXP4XX_GPIO_GPOUTR_OFFSET) +#define IXP4XX_GPIO_GPOER IXP4XX_GPIO_REG(IXP4XX_GPIO_GPOER_OFFSET) +#define IXP4XX_GPIO_GPINR IXP4XX_GPIO_REG(IXP4XX_GPIO_GPINR_OFFSET) +#define IXP4XX_GPIO_GPISR IXP4XX_GPIO_REG(IXP4XX_GPIO_GPISR_OFFSET) +#define IXP4XX_GPIO_GPIT1R IXP4XX_GPIO_REG(IXP4XX_GPIO_GPIT1R_OFFSET) +#define IXP4XX_GPIO_GPIT2R IXP4XX_GPIO_REG(IXP4XX_GPIO_GPIT2R_OFFSET) +#define IXP4XX_GPIO_GPCLKR IXP4XX_GPIO_REG(IXP4XX_GPIO_GPCLKR_OFFSET) +#define IXP4XX_GPIO_GPDBSELR IXP4XX_GPIO_REG(IXP4XX_GPIO_GPDBSELR_OFFSET) + +/* + * GPIO register bit definitions + */ + +/* Interrupt styles + */ +#define IXP4XX_GPIO_STYLE_ACTIVE_HIGH 0x0 +#define IXP4XX_GPIO_STYLE_ACTIVE_LOW 0x1 +#define IXP4XX_GPIO_STYLE_RISING_EDGE 0x2 +#define IXP4XX_GPIO_STYLE_FALLING_EDGE 0x3 +#define IXP4XX_GPIO_STYLE_TRANSITIONAL 0x4 + +/* + * Mask used to clear interrupt styles + */ +#define IXP4XX_GPIO_STYLE_CLEAR 0x7 +#define IXP4XX_GPIO_STYLE_SIZE 3 + +/* + * Constants to make it easy to access Timer Control/Status registers + */ +#define IXP4XX_OSTS_OFFSET 0x00 /* Continious TimeStamp */ +#define IXP4XX_OST1_OFFSET 0x04 /* Timer 1 Timestamp */ +#define IXP4XX_OSRT1_OFFSET 0x08 /* Timer 1 Reload */ +#define IXP4XX_OST2_OFFSET 0x0C /* Timer 2 Timestamp */ +#define IXP4XX_OSRT2_OFFSET 0x10 /* Timer 2 Reload */ +#define IXP4XX_OSWT_OFFSET 0x14 /* Watchdog Timer */ +#define IXP4XX_OSWE_OFFSET 0x18 /* Watchdog Enable */ +#define IXP4XX_OSWK_OFFSET 0x1C /* Watchdog Key */ +#define IXP4XX_OSST_OFFSET 0x20 /* Timer Status */ + +/* + * Operating System Timer Register Definitions. + */ + +#define IXP4XX_TIMER_REG(x) ((volatile u32 *)(IXP4XX_TIMER_BASE_VIRT+(x))) + +#define IXP4XX_OSTS IXP4XX_TIMER_REG(IXP4XX_OSTS_OFFSET) +#define IXP4XX_OST1 IXP4XX_TIMER_REG(IXP4XX_OST1_OFFSET) +#define IXP4XX_OSRT1 IXP4XX_TIMER_REG(IXP4XX_OSRT1_OFFSET) +#define IXP4XX_OST2 IXP4XX_TIMER_REG(IXP4XX_OST2_OFFSET) +#define IXP4XX_OSRT2 IXP4XX_TIMER_REG(IXP4XX_OSRT2_OFFSET) +#define IXP4XX_OSWT IXP4XX_TIMER_REG(IXP4XX_OSWT_OFFSET) +#define IXP4XX_OSWE IXP4XX_TIMER_REG(IXP4XX_OSWE_OFFSET) +#define IXP4XX_OSWK IXP4XX_TIMER_REG(IXP4XX_OSWK_OFFSET) +#define IXP4XX_OSST IXP4XX_TIMER_REG(IXP4XX_OSST_OFFSET) + +/* + * Timer register values and bit definitions + */ +#define IXP4XX_OST_ENABLE 0x00000001 +#define IXP4XX_OST_ONE_SHOT 0x00000002 +/* Low order bits of reload value ignored */ +#define IXP4XX_OST_RELOAD_MASK 0x00000003 +#define IXP4XX_OST_DISABLED 0x00000000 +#define IXP4XX_OSST_TIMER_1_PEND 0x00000001 +#define IXP4XX_OSST_TIMER_2_PEND 0x00000002 +#define IXP4XX_OSST_TIMER_TS_PEND 0x00000004 +#define IXP4XX_OSST_TIMER_WDOG_PEND 0x00000008 +#define IXP4XX_OSST_TIMER_WARM_RESET 0x00000010 + +#define IXP4XX_WDT_KEY 0x0000482E + +#define IXP4XX_WDT_RESET_ENABLE 0x00000001 +#define IXP4XX_WDT_IRQ_ENABLE 0x00000002 +#define IXP4XX_WDT_COUNT_ENABLE 0x00000004 + + +/* + * Constants to make it easy to access PCI Control/Status registers + */ +#define PCI_NP_AD_OFFSET 0x00 +#define PCI_NP_CBE_OFFSET 0x04 +#define PCI_NP_WDATA_OFFSET 0x08 +#define PCI_NP_RDATA_OFFSET 0x0c +#define PCI_CRP_AD_CBE_OFFSET 0x10 +#define PCI_CRP_WDATA_OFFSET 0x14 +#define PCI_CRP_RDATA_OFFSET 0x18 +#define PCI_CSR_OFFSET 0x1c +#define PCI_ISR_OFFSET 0x20 +#define PCI_INTEN_OFFSET 0x24 +#define PCI_DMACTRL_OFFSET 0x28 +#define PCI_AHBMEMBASE_OFFSET 0x2c +#define PCI_AHBIOBASE_OFFSET 0x30 +#define PCI_PCIMEMBASE_OFFSET 0x34 +#define PCI_AHBDOORBELL_OFFSET 0x38 +#define PCI_PCIDOORBELL_OFFSET 0x3C +#define PCI_ATPDMA0_AHBADDR_OFFSET 0x40 +#define PCI_ATPDMA0_PCIADDR_OFFSET 0x44 +#define PCI_ATPDMA0_LENADDR_OFFSET 0x48 +#define PCI_ATPDMA1_AHBADDR_OFFSET 0x4C +#define PCI_ATPDMA1_PCIADDR_OFFSET 0x50 +#define PCI_ATPDMA1_LENADDR_OFFSET 0x54 + +/* + * PCI Control/Status Registers + */ +#define IXP4XX_PCI_CSR(x) ((volatile u32 *)(IXP4XX_PCI_CFG_BASE_VIRT+(x))) + +#define PCI_NP_AD IXP4XX_PCI_CSR(PCI_NP_AD_OFFSET) +#define PCI_NP_CBE IXP4XX_PCI_CSR(PCI_NP_CBE_OFFSET) +#define PCI_NP_WDATA IXP4XX_PCI_CSR(PCI_NP_WDATA_OFFSET) +#define PCI_NP_RDATA IXP4XX_PCI_CSR(PCI_NP_RDATA_OFFSET) +#define PCI_CRP_AD_CBE IXP4XX_PCI_CSR(PCI_CRP_AD_CBE_OFFSET) +#define PCI_CRP_WDATA IXP4XX_PCI_CSR(PCI_CRP_WDATA_OFFSET) +#define PCI_CRP_RDATA IXP4XX_PCI_CSR(PCI_CRP_RDATA_OFFSET) +#define PCI_CSR IXP4XX_PCI_CSR(PCI_CSR_OFFSET) +#define PCI_ISR IXP4XX_PCI_CSR(PCI_ISR_OFFSET) +#define PCI_INTEN IXP4XX_PCI_CSR(PCI_INTEN_OFFSET) +#define PCI_DMACTRL IXP4XX_PCI_CSR(PCI_DMACTRL_OFFSET) +#define PCI_AHBMEMBASE IXP4XX_PCI_CSR(PCI_AHBMEMBASE_OFFSET) +#define PCI_AHBIOBASE IXP4XX_PCI_CSR(PCI_AHBIOBASE_OFFSET) +#define PCI_PCIMEMBASE IXP4XX_PCI_CSR(PCI_PCIMEMBASE_OFFSET) +#define PCI_AHBDOORBELL IXP4XX_PCI_CSR(PCI_AHBDOORBELL_OFFSET) +#define PCI_PCIDOORBELL IXP4XX_PCI_CSR(PCI_PCIDOORBELL_OFFSET) +#define PCI_ATPDMA0_AHBADDR IXP4XX_PCI_CSR(PCI_ATPDMA0_AHBADDR_OFFSET) +#define PCI_ATPDMA0_PCIADDR IXP4XX_PCI_CSR(PCI_ATPDMA0_PCIADDR_OFFSET) +#define PCI_ATPDMA0_LENADDR IXP4XX_PCI_CSR(PCI_ATPDMA0_LENADDR_OFFSET) +#define PCI_ATPDMA1_AHBADDR IXP4XX_PCI_CSR(PCI_ATPDMA1_AHBADDR_OFFSET) +#define PCI_ATPDMA1_PCIADDR IXP4XX_PCI_CSR(PCI_ATPDMA1_PCIADDR_OFFSET) +#define PCI_ATPDMA1_LENADDR IXP4XX_PCI_CSR(PCI_ATPDMA1_LENADDR_OFFSET) + +/* + * PCI register values and bit definitions + */ + +/* CSR bit definitions */ +#define PCI_CSR_HOST 0x00000001 +#define PCI_CSR_ARBEN 0x00000002 +#define PCI_CSR_ADS 0x00000004 +#define PCI_CSR_PDS 0x00000008 +#define PCI_CSR_ABE 0x00000010 +#define PCI_CSR_DBT 0x00000020 +#define PCI_CSR_ASE 0x00000100 +#define PCI_CSR_IC 0x00008000 + +/* ISR (Interrupt status) Register bit definitions */ +#define PCI_ISR_PSE 0x00000001 +#define PCI_ISR_PFE 0x00000002 +#define PCI_ISR_PPE 0x00000004 +#define PCI_ISR_AHBE 0x00000008 +#define PCI_ISR_APDC 0x00000010 +#define PCI_ISR_PADC 0x00000020 +#define PCI_ISR_ADB 0x00000040 +#define PCI_ISR_PDB 0x00000080 + +/* INTEN (Interrupt Enable) Register bit definitions */ +#define PCI_INTEN_PSE 0x00000001 +#define PCI_INTEN_PFE 0x00000002 +#define PCI_INTEN_PPE 0x00000004 +#define PCI_INTEN_AHBE 0x00000008 +#define PCI_INTEN_APDC 0x00000010 +#define PCI_INTEN_PADC 0x00000020 +#define PCI_INTEN_ADB 0x00000040 +#define PCI_INTEN_PDB 0x00000080 + +/* + * Shift value for byte enable on NP cmd/byte enable register + */ +#define IXP4XX_PCI_NP_CBE_BESL 4 + +/* + * PCI commands supported by NP access unit + */ +#define NP_CMD_IOREAD 0x2 +#define NP_CMD_IOWRITE 0x3 +#define NP_CMD_CONFIGREAD 0xa +#define NP_CMD_CONFIGWRITE 0xb +#define NP_CMD_MEMREAD 0x6 +#define NP_CMD_MEMWRITE 0x7 + +/* + * Constants for CRP access into local config space + */ +#define CRP_AD_CBE_BESL 20 +#define CRP_AD_CBE_WRITE 0x00010000 + + +/* + * USB Device Controller + * + * These are used by the USB gadget driver, so they don't follow the + * IXP4XX_ naming convetions. + * + */ +# define IXP4XX_USB_REG(x) (*((volatile u32 *)(x))) + +/* UDC Undocumented - Reserved1 */ +#define UDC_RES1 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0004) +/* UDC Undocumented - Reserved2 */ +#define UDC_RES2 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0008) +/* UDC Undocumented - Reserved3 */ +#define UDC_RES3 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x000C) +/* UDC Control Register */ +#define UDCCR IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0000) +/* UDC Endpoint 0 Control/Status Register */ +#define UDCCS0 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0010) +/* UDC Endpoint 1 (IN) Control/Status Register */ +#define UDCCS1 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0014) +/* UDC Endpoint 2 (OUT) Control/Status Register */ +#define UDCCS2 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0018) +/* UDC Endpoint 3 (IN) Control/Status Register */ +#define UDCCS3 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x001C) +/* UDC Endpoint 4 (OUT) Control/Status Register */ +#define UDCCS4 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0020) +/* UDC Endpoint 5 (Interrupt) Control/Status Register */ +#define UDCCS5 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0024) +/* UDC Endpoint 6 (IN) Control/Status Register */ +#define UDCCS6 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0028) +/* UDC Endpoint 7 (OUT) Control/Status Register */ +#define UDCCS7 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x002C) +/* UDC Endpoint 8 (IN) Control/Status Register */ +#define UDCCS8 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0030) +/* UDC Endpoint 9 (OUT) Control/Status Register */ +#define UDCCS9 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0034) +/* UDC Endpoint 10 (Interrupt) Control/Status Register */ +#define UDCCS10 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0038) +/* UDC Endpoint 11 (IN) Control/Status Register */ +#define UDCCS11 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x003C) +/* UDC Endpoint 12 (OUT) Control/Status Register */ +#define UDCCS12 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0040) +/* UDC Endpoint 13 (IN) Control/Status Register */ +#define UDCCS13 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0044) +/* UDC Endpoint 14 (OUT) Control/Status Register */ +#define UDCCS14 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0048) +/* UDC Endpoint 15 (Interrupt) Control/Status Register */ +#define UDCCS15 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x004C) +/* UDC Frame Number Register High */ +#define UFNRH IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0060) +/* UDC Frame Number Register Low */ +#define UFNRL IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0064) +/* UDC Byte Count Reg 2 */ +#define UBCR2 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0068) +/* UDC Byte Count Reg 4 */ +#define UBCR4 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x006c) +/* UDC Byte Count Reg 7 */ +#define UBCR7 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0070) +/* UDC Byte Count Reg 9 */ +#define UBCR9 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0074) +/* UDC Byte Count Reg 12 */ +#define UBCR12 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0078) +/* UDC Byte Count Reg 14 */ +#define UBCR14 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x007c) +/* UDC Endpoint 0 Data Register */ +#define UDDR0 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0080) +/* UDC Endpoint 1 Data Register */ +#define UDDR1 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0100) +/* UDC Endpoint 2 Data Register */ +#define UDDR2 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0180) +/* UDC Endpoint 3 Data Register */ +#define UDDR3 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0200) +/* UDC Endpoint 4 Data Register */ +#define UDDR4 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0400) +/* UDC Endpoint 5 Data Register */ +#define UDDR5 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x00A0) +/* UDC Endpoint 6 Data Register */ +#define UDDR6 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0600) +/* UDC Endpoint 7 Data Register */ +#define UDDR7 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0680) +/* UDC Endpoint 8 Data Register */ +#define UDDR8 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0700) +/* UDC Endpoint 9 Data Register */ +#define UDDR9 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0900) +/* UDC Endpoint 10 Data Register */ +#define UDDR10 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x00C0) +/* UDC Endpoint 11 Data Register */ +#define UDDR11 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0B00) +/* UDC Endpoint 12 Data Register */ +#define UDDR12 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0B80) +/* UDC Endpoint 13 Data Register */ +#define UDDR13 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0C00) +/* UDC Endpoint 14 Data Register */ +#define UDDR14 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0E00) +/* UDC Endpoint 15 Data Register */ +#define UDDR15 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x00E0) +/* UDC Interrupt Control Register 0 */ +#define UICR0 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0050) +/* UDC Interrupt Control Register 1 */ +#define UICR1 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0054) +/* UDC Status Interrupt Register 0 */ +#define USIR0 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x0058) +/* UDC Status Interrupt Register 1 */ +#define USIR1 IXP4XX_USB_REG(IXP4XX_USB_BASE_VIRT+0x005C) + +#define UDCCR_UDE (1 << 0) /* UDC enable */ +#define UDCCR_UDA (1 << 1) /* UDC active */ +#define UDCCR_RSM (1 << 2) /* Device resume */ +#define UDCCR_RESIR (1 << 3) /* Resume interrupt request */ +#define UDCCR_SUSIR (1 << 4) /* Suspend interrupt request */ +#define UDCCR_SRM (1 << 5) /* Suspend/resume interrupt mask */ +#define UDCCR_RSTIR (1 << 6) /* Reset interrupt request */ +#define UDCCR_REM (1 << 7) /* Reset interrupt mask */ + +#define UDCCS0_OPR (1 << 0) /* OUT packet ready */ +#define UDCCS0_IPR (1 << 1) /* IN packet ready */ +#define UDCCS0_FTF (1 << 2) /* Flush Tx FIFO */ +#define UDCCS0_DRWF (1 << 3) /* Device remote wakeup feature */ +#define UDCCS0_SST (1 << 4) /* Sent stall */ +#define UDCCS0_FST (1 << 5) /* Force stall */ +#define UDCCS0_RNE (1 << 6) /* Receive FIFO no empty */ +#define UDCCS0_SA (1 << 7) /* Setup active */ + +#define UDCCS_BI_TFS (1 << 0) /* Transmit FIFO service */ +#define UDCCS_BI_TPC (1 << 1) /* Transmit packet complete */ +#define UDCCS_BI_FTF (1 << 2) /* Flush Tx FIFO */ +#define UDCCS_BI_TUR (1 << 3) /* Transmit FIFO underrun */ +#define UDCCS_BI_SST (1 << 4) /* Sent stall */ +#define UDCCS_BI_FST (1 << 5) /* Force stall */ +#define UDCCS_BI_TSP (1 << 7) /* Transmit short packet */ + +#define UDCCS_BO_RFS (1 << 0) /* Receive FIFO service */ +#define UDCCS_BO_RPC (1 << 1) /* Receive packet complete */ +#define UDCCS_BO_DME (1 << 3) /* DMA enable */ +#define UDCCS_BO_SST (1 << 4) /* Sent stall */ +#define UDCCS_BO_FST (1 << 5) /* Force stall */ +#define UDCCS_BO_RNE (1 << 6) /* Receive FIFO not empty */ +#define UDCCS_BO_RSP (1 << 7) /* Receive short packet */ + +#define UDCCS_II_TFS (1 << 0) /* Transmit FIFO service */ +#define UDCCS_II_TPC (1 << 1) /* Transmit packet complete */ +#define UDCCS_II_FTF (1 << 2) /* Flush Tx FIFO */ +#define UDCCS_II_TUR (1 << 3) /* Transmit FIFO underrun */ +#define UDCCS_II_TSP (1 << 7) /* Transmit short packet */ + +#define UDCCS_IO_RFS (1 << 0) /* Receive FIFO service */ +#define UDCCS_IO_RPC (1 << 1) /* Receive packet complete */ +#define UDCCS_IO_ROF (1 << 3) /* Receive overflow */ +#define UDCCS_IO_DME (1 << 3) /* DMA enable */ +#define UDCCS_IO_RNE (1 << 6) /* Receive FIFO not empty */ +#define UDCCS_IO_RSP (1 << 7) /* Receive short packet */ + +#define UDCCS_INT_TFS (1 << 0) /* Transmit FIFO service */ +#define UDCCS_INT_TPC (1 << 1) /* Transmit packet complete */ +#define UDCCS_INT_FTF (1 << 2) /* Flush Tx FIFO */ +#define UDCCS_INT_TUR (1 << 3) /* Transmit FIFO underrun */ +#define UDCCS_INT_SST (1 << 4) /* Sent stall */ +#define UDCCS_INT_FST (1 << 5) /* Force stall */ +#define UDCCS_INT_TSP (1 << 7) /* Transmit short packet */ + +#define UICR0_IM0 (1 << 0) /* Interrupt mask ep 0 */ +#define UICR0_IM1 (1 << 1) /* Interrupt mask ep 1 */ +#define UICR0_IM2 (1 << 2) /* Interrupt mask ep 2 */ +#define UICR0_IM3 (1 << 3) /* Interrupt mask ep 3 */ +#define UICR0_IM4 (1 << 4) /* Interrupt mask ep 4 */ +#define UICR0_IM5 (1 << 5) /* Interrupt mask ep 5 */ +#define UICR0_IM6 (1 << 6) /* Interrupt mask ep 6 */ +#define UICR0_IM7 (1 << 7) /* Interrupt mask ep 7 */ + +#define UICR1_IM8 (1 << 0) /* Interrupt mask ep 8 */ +#define UICR1_IM9 (1 << 1) /* Interrupt mask ep 9 */ +#define UICR1_IM10 (1 << 2) /* Interrupt mask ep 10 */ +#define UICR1_IM11 (1 << 3) /* Interrupt mask ep 11 */ +#define UICR1_IM12 (1 << 4) /* Interrupt mask ep 12 */ +#define UICR1_IM13 (1 << 5) /* Interrupt mask ep 13 */ +#define UICR1_IM14 (1 << 6) /* Interrupt mask ep 14 */ +#define UICR1_IM15 (1 << 7) /* Interrupt mask ep 15 */ + +#define USIR0_IR0 (1 << 0) /* Interrup request ep 0 */ +#define USIR0_IR1 (1 << 1) /* Interrup request ep 1 */ +#define USIR0_IR2 (1 << 2) /* Interrup request ep 2 */ +#define USIR0_IR3 (1 << 3) /* Interrup request ep 3 */ +#define USIR0_IR4 (1 << 4) /* Interrup request ep 4 */ +#define USIR0_IR5 (1 << 5) /* Interrup request ep 5 */ +#define USIR0_IR6 (1 << 6) /* Interrup request ep 6 */ +#define USIR0_IR7 (1 << 7) /* Interrup request ep 7 */ + +#define USIR1_IR8 (1 << 0) /* Interrup request ep 8 */ +#define USIR1_IR9 (1 << 1) /* Interrup request ep 9 */ +#define USIR1_IR10 (1 << 2) /* Interrup request ep 10 */ +#define USIR1_IR11 (1 << 3) /* Interrup request ep 11 */ +#define USIR1_IR12 (1 << 4) /* Interrup request ep 12 */ +#define USIR1_IR13 (1 << 5) /* Interrup request ep 13 */ +#define USIR1_IR14 (1 << 6) /* Interrup request ep 14 */ +#define USIR1_IR15 (1 << 7) /* Interrup request ep 15 */ + +#define DCMD_LENGTH 0x01fff /* length mask (max = 8K - 1) */ + +#endif diff --git a/include/asm-arm/arch-ixp4xx/prpmc1100.h b/include/asm-arm/arch-ixp4xx/prpmc1100.h new file mode 100644 index 000000000..e2532ab7f --- /dev/null +++ b/include/asm-arm/arch-ixp4xx/prpmc1100.h @@ -0,0 +1,33 @@ +/* + * include/asm-arm/arch-ixp4xx/prpmc1100.h + * + * Motorolla PrPMC1100 platform specific definitions + * + * Author: Deepak Saxena + * + * Copyright 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. + */ + +#ifndef __ASM_ARCH_HARDWARE_H__ +#error "Do not include this directly, instead #include " +#endif + +#define PRPMC1100_FLASH_BASE IXP4XX_EXP_BUS_CS0_BASE_PHYS +#define PRPMC1100_FLASH_SIZE IXP4XX_EXP_BUS_CSX_REGION_SIZE + +#define PRPMC1100_PCI_MIN_DEVID 10 +#define PRPMC1100_PCI_MAX_DEVID 16 +#define PRPMC1100_PCI_IRQ_LINES 4 + + +/* PCI controller GPIO to IRQ pin mappings */ +#define PRPMC1100_PCI_INTA_PIN 11 +#define PRPMC1100_PCI_INTB_PIN 10 +#define PRPMC1100_PCI_INTC_PIN 9 +#define PRPMC1100_PCI_INTD_PIN 8 + + diff --git a/include/asm-arm/arch-ixp4xx/timex.h b/include/asm-arm/arch-ixp4xx/timex.h new file mode 100644 index 000000000..38c9d77d3 --- /dev/null +++ b/include/asm-arm/arch-ixp4xx/timex.h @@ -0,0 +1,13 @@ +/* + * linux/include/asm-arm/arch-ixp4xx/timex.h + * + */ + +#include + +/* + * We use IXP425 General purpose timer for our timer needs, it runs at + * 66.66... MHz + */ +#define CLOCK_TICK_RATE (66666666) + diff --git a/include/asm-arm/arch-ixp4xx/vmalloc.h b/include/asm-arm/arch-ixp4xx/vmalloc.h new file mode 100644 index 000000000..da46e560a --- /dev/null +++ b/include/asm-arm/arch-ixp4xx/vmalloc.h @@ -0,0 +1,17 @@ +/* + * linux/include/asm-arm/arch-ixp4xx/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_VMADDR(x) ((unsigned long)(x)) +#define VMALLOC_END (0xFF000000) + diff --git a/include/asm-arm/arch-l7200/ide.h b/include/asm-arm/arch-l7200/ide.h deleted file mode 100644 index 62ee12ada..000000000 --- a/include/asm-arm/arch-l7200/ide.h +++ /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 - -/* - * 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 index 6628bd381..000000000 --- a/include/asm-arm/arch-l7200/keyboard.h +++ /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 - -#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-nexuspci/ide.h b/include/asm-arm/arch-nexuspci/ide.h deleted file mode 100644 index 5514808d5..000000000 --- a/include/asm-arm/arch-nexuspci/ide.h +++ /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 - -/* - * 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-pxa/ide.h b/include/asm-arm/arch-pxa/ide.h deleted file mode 100644 index a9efdce2b..000000000 --- a/include/asm-arm/arch-pxa/ide.h +++ /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 -#include -#include - - -/* - * 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 index 7bec3179b..000000000 --- a/include/asm-arm/arch-pxa/keyboard.h +++ /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 -#include - -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/mainstone.h b/include/asm-arm/arch-pxa/mainstone.h new file mode 100644 index 000000000..14c862adc --- /dev/null +++ b/include/asm-arm/arch-pxa/mainstone.h @@ -0,0 +1,120 @@ +/* + * linux/include/asm-arm/arch-pxa/mainstone.h + * + * Author: Nicolas Pitre + * Created: Nov 14, 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. + */ + +#ifndef ASM_ARCH_MAINSTONE_H +#define ASM_ARCH_MAINSTONE_H + +#define MST_ETH_PHYS PXA_CS4_PHYS + +#define MST_FPGA_PHYS PXA_CS2_PHYS +#define MST_FPGA_VIRT (0xf0000000) +#define MST_P2V(x) ((x) - MST_FPGA_PHYS + MST_FPGA_VIRT) +#define MST_V2P(x) ((x) - MST_FPGA_VIRT + MST_FPGA_PHYS) + +#ifndef __ASSEMBLY__ +# define __MST_REG(x) (*((volatile unsigned long *)MST_P2V(x))) +#else +# define __MST_REG(x) MST_P2V(x) +#endif + +/* board level registers in the FPGA */ + +#define MST_LEDDAT1 __MST_REG(0x08000010) +#define MST_LEDDAT2 __MST_REG(0x08000014) +#define MST_LEDCTRL __MST_REG(0x08000040) +#define MST_GPSWR __MST_REG(0x08000060) +#define MST_MSCWR1 __MST_REG(0x08000080) +#define MST_MSCWR2 __MST_REG(0x08000084) +#define MST_MSCWR3 __MST_REG(0x08000088) +#define MST_MSCRD __MST_REG(0x08000090) +#define MST_INTMSKENA __MST_REG(0x080000c0) +#define MST_INTSETCLR __MST_REG(0x080000d0) +#define MST_PCMCIA0 __MST_REG(0x080000e0) +#define MST_PCMCIA1 __MST_REG(0x080000e4) + +#define MST_MSCWR1_CAMERA_ON (1 << 15) /* Camera interface power control */ +#define MST_MSCWR1_CAMERA_SEL (1 << 14) /* Camera interface mux control */ +#define MST_MSCWR1_LCD_CTL (1 << 13) /* General-purpose LCD control */ +#define MST_MSCWR1_MS_ON (1 << 12) /* Memory Stick power control */ +#define MST_MSCWR1_MMC_ON (1 << 11) /* MultiMediaCard* power control */ +#define MST_MSCWR1_MS_SEL (1 << 10) /* SD/MS multiplexer control */ +#define MST_MSCWR1_BB_SEL (1 << 9) /* PCMCIA/Baseband multiplexer */ +#define MST_MSCWR1_BT_ON (1 << 8) /* Bluetooth UART transceiver */ +#define MST_MSCWR1_BTDTR (1 << 7) /* Bluetooth UART DTR */ + +#define MST_MSCWR1_IRDA_MASK (3 << 5) /* IrDA transceiver mode */ +#define MST_MSCWR1_IRDA_FULL (0 << 5) /* full distance power */ +#define MST_MSCWR1_IRDA_OFF (1 << 5) /* shutdown */ +#define MST_MSCWR1_IRDA_MED (2 << 5) /* 2/3 distance power */ +#define MST_MSCWR1_IRDA_LOW (3 << 5) /* 1/3 distance power */ + +#define MST_MSCWR1_IRDA_FIR (1 << 4) /* IrDA transceiver SIR/FIR */ +#define MST_MSCWR1_GREENLED (1 << 3) /* LED D1 control */ +#define MST_MSCWR1_PDC_CTL (1 << 2) /* reserved */ +#define MST_MSCWR1_MTR_ON (1 << 1) /* Silent alert motor */ +#define MST_MSCWR1_SYSRESET (1 << 0) /* System reset */ + +#define MST_MSCWR2_USB_OTG_RST (1 << 6) /* USB On The Go reset */ +#define MST_MSCWR2_USB_OTG_SEL (1 << 5) /* USB On The Go control */ +#define MST_MSCWR2_nUSBC_SC (1 << 4) /* USB client soft connect control */ +#define MST_MSCWR2_I2S_SPKROFF (1 << 3) /* I2S CODEC amplifier control */ +#define MST_MSCWR2_AC97_SPKROFF (1 << 2) /* AC97 CODEC amplifier control */ +#define MST_MSCWR2_RADIO_PWR (1 << 1) /* Radio module power control */ +#define MST_MSCWR2_RADIO_WAKE (1 << 0) /* Radio module wake-up signal */ + +#define MST_MSCWR3_GPIO_RESET_EN (1 << 2) /* Enable GPIO Reset */ +#define MST_MSCWR3_GPIO_RESET (1 << 1) /* Initiate a GPIO Reset */ +#define MST_MSCWR3_COMMS_SW_RESET (1 << 0) /* Communications Processor Reset Control */ + +#define MST_MSCRD_nPENIRQ (1 << 9) /* ADI7873* nPENIRQ signal */ +#define MST_MSCRD_nMEMSTK_CD (1 << 8) /* Memory Stick detection signal */ +#define MST_MSCRD_nMMC_CD (1 << 7) /* SD/MMC card detection signal */ +#define MST_MSCRD_nUSIM_CD (1 << 6) /* USIM card detection signal */ +#define MST_MSCRD_USB_CBL (1 << 5) /* USB client cable status */ +#define MST_MSCRD_TS_BUSY (1 << 4) /* ADI7873 busy */ +#define MST_MSCRD_BTDSR (1 << 3) /* Bluetooth UART DSR */ +#define MST_MSCRD_BTRI (1 << 2) /* Bluetooth UART Ring Indicator */ +#define MST_MSCRD_BTDCD (1 << 1) /* Bluetooth UART DCD */ +#define MST_MSCRD_nMMC_WP (1 << 0) /* SD/MMC write-protect status */ + +#define MST_INT_S1_IRQ (1 << 15) /* PCMCIA socket 1 IRQ */ +#define MST_INT_S1_STSCHG (1 << 14) /* PCMCIA socket 1 status changed */ +#define MST_INT_S1_CD (1 << 13) /* PCMCIA socket 1 card detection */ +#define MST_INT_S0_IRQ (1 << 11) /* PCMCIA socket 0 IRQ */ +#define MST_INT_S0_STSCHG (1 << 10) /* PCMCIA socket 0 status changed */ +#define MST_INT_S0_CD (1 << 9) /* PCMCIA socket 0 card detection */ +#define MST_INT_nEXBRD_INT (1 << 7) /* Expansion board IRQ */ +#define MST_INT_MSINS (1 << 6) /* Memory Stick* detection */ +#define MST_INT_PENIRQ (1 << 5) /* ADI7873* touch-screen IRQ */ +#define MST_INT_AC97 (1 << 4) /* AC'97 CODEC IRQ */ +#define MST_INT_ETHERNET (1 << 3) /* Ethernet controller IRQ */ +#define MST_INT_USBC (1 << 2) /* USB client cable detection IRQ */ +#define MST_INT_USIM (1 << 1) /* USIM card detection IRQ */ +#define MST_INT_MMC (1 << 0) /* MMC/SD card detection IRQ */ + +#define MST_PCMCIA_nIRQ (1 << 10) /* IRQ / ready signal */ +#define MST_PCMCIA_nSPKR_BVD2 (1 << 9) /* VDD sense / digital speaker */ +#define MST_PCMCIA_nSTSCHG_BVD1 (1 << 8) /* VDD sense / card status changed */ +#define MST_PCMCIA_nVS2 (1 << 7) /* VSS voltage sense */ +#define MST_PCMCIA_nVS1 (1 << 6) /* VSS voltage sense */ +#define MST_PCMCIA_nCD (1 << 5) /* Card detection signal */ +#define MST_PCMCIA_RESET (1 << 4) /* Card reset signal */ +#define MST_PCMCIA_PWR_MASK (0x000f) /* MAX1602 power-supply controls */ + +#define MST_PCMCIA_PWR_VPP_0 0x0 /* voltage VPP = 0V */ +#define MST_PCMCIA_PWR_VPP_120 0x2 /* voltage VPP = 12V*/ +#define MST_PCMCIA_PWR_VPP_VCC 0x1 /* voltage VPP = VCC */ +#define MST_PCMCIA_PWR_VCC_0 0x0 /* voltage VCC = 0V */ +#define MST_PCMCIA_PWR_VCC_33 0x8 /* voltage VCC = 3.3V */ +#define MST_PCMCIA_PWR_VCC_50 0x4 /* voltage VCC = 5.0V */ + +#endif diff --git a/include/asm-arm/arch-rpc/ide.h b/include/asm-arm/arch-rpc/ide.h deleted file mode 100644 index 92c7030ab..000000000 --- a/include/asm-arm/arch-rpc/ide.h +++ /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 - -/* - * 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-s3c2410/ide.h b/include/asm-arm/arch-s3c2410/ide.h deleted file mode 100644 index de651e75d..000000000 --- a/include/asm-arm/arch-s3c2410/ide.h +++ /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 - -/* - * 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-sa1100/keyboard.h b/include/asm-arm/arch-sa1100/keyboard.h deleted file mode 100644 index 3dacd71d9..000000000 --- a/include/asm-arm/arch-sa1100/keyboard.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * linux/include/asm-arm/arch-sa1100/keyboard.h - * Created 16 Dec 1999 by Nicolas Pitre - * This file contains the SA1100 architecture specific keyboard definitions - */ -#ifndef _SA1100_KEYBOARD_H -#define _SA1100_KEYBOARD_H - -#include -#include - -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-shark/ide.h b/include/asm-arm/arch-shark/ide.h deleted file mode 100644 index f6a99b22f..000000000 --- a/include/asm-arm/arch-shark/ide.h +++ /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 - -/* - * 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 index 52b5ed6e1..000000000 --- a/include/asm-arm/arch-shark/keyboard.h +++ /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 -#include -#include -#include -#include - -#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-tbox/ide.h b/include/asm-arm/arch-tbox/ide.h deleted file mode 100644 index d66e67c94..000000000 --- a/include/asm-arm/arch-tbox/ide.h +++ /dev/null @@ -1,3 +0,0 @@ -/* - * linux/include/asm-arm/arch-tbox/ide.h - */ diff --git a/include/asm-arm/rmap.h b/include/asm-arm/rmap.h deleted file mode 100644 index bb9ee93c1..000000000 --- a/include/asm-arm/rmap.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _ARM_RMAP_H -#define _ARM_RMAP_H - -#include - -#endif /* _ARM_RMAP_H */ diff --git a/include/asm-arm26/rmap.h b/include/asm-arm26/rmap.h deleted file mode 100644 index 6d5b6e092..000000000 --- a/include/asm-arm26/rmap.h +++ /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 - -#endif /* _ARM_RMAP_H */ diff --git a/include/asm-cris/rmap.h b/include/asm-cris/rmap.h deleted file mode 100644 index c5bf2a811..000000000 --- a/include/asm-cris/rmap.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _CRIS_RMAP_H -#define _CRIS_RMAP_H - -/* nothing to see, move along :) */ -#include - -#endif diff --git a/include/asm-generic/rmap.h b/include/asm-generic/rmap.h deleted file mode 100644 index f743d9f80..000000000 --- a/include/asm-generic/rmap.h +++ /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 - -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 */ diff --git a/include/asm-h8300/aki3068net/machine-depend.h b/include/asm-h8300/aki3068net/machine-depend.h deleted file mode 100644 index 510b86b5d..000000000 --- a/include/asm-h8300/aki3068net/machine-depend.h +++ /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/edosk2674/machine-depend.h b/include/asm-h8300/edosk2674/machine-depend.h deleted file mode 100644 index 1e98b40e5..000000000 --- a/include/asm-h8300/edosk2674/machine-depend.h +++ /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 index 2d78096e5..000000000 --- a/include/asm-h8300/generic/machine-depend.h +++ /dev/null @@ -1,17 +0,0 @@ -/* machine depend header */ - -/* TIMER rate define */ -#ifdef H8300_TIMER_DEFINE -#include -#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 index 0f6f4190e..000000000 --- a/include/asm-h8300/generic/timer_rate.h +++ /dev/null @@ -1,15 +0,0 @@ -#include - -#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_smsc.h b/include/asm-h8300/h8300_smsc.h deleted file mode 100644 index f8fa7f9cc..000000000 --- a/include/asm-h8300/h8300_smsc.h +++ /dev/null @@ -1,20 +0,0 @@ -/****************************************************************************/ - -/* - * h8300_smsc.h -- SMSC in H8/300H and H8S Evalution Board. - * - * (C) Copyright 2003, Yoshinori Sato - */ - -/****************************************************************************/ -#ifndef h8300smsc_h -#define h8300smsc_h -/****************************************************************************/ - -/* Such a description is OK ? */ -#define H8300_SMSC_DEFINE -#include -#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 index e87d22e6d..000000000 --- a/include/asm-h8300/h8max/machine-depend.h +++ /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-i386/8253pit.h b/include/asm-i386/8253pit.h new file mode 100644 index 000000000..96c7c3592 --- /dev/null +++ b/include/asm-i386/8253pit.h @@ -0,0 +1,12 @@ +/* + * 8253/8254 Programmable Interval Timer + */ + +#ifndef _8253PIT_H +#define _8253PIT_H + +#include + +#define PIT_TICK_RATE CLOCK_TICK_RATE + +#endif diff --git a/include/asm-i386/crash.h b/include/asm-i386/crash.h new file mode 100644 index 000000000..b6ae4f36f --- /dev/null +++ b/include/asm-i386/crash.h @@ -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 +#include +#include + +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 */ diff --git a/include/asm-i386/rmap.h b/include/asm-i386/rmap.h deleted file mode 100644 index 353afee85..000000000 --- a/include/asm-i386/rmap.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _I386_RMAP_H -#define _I386_RMAP_H - -/* nothing to see, move along */ -#include - -#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 diff --git a/include/asm-ia64/cpu.h b/include/asm-ia64/cpu.h new file mode 100644 index 000000000..33c5d0fe9 --- /dev/null +++ b/include/asm-ia64/cpu.h @@ -0,0 +1,17 @@ +#ifndef _ASM_IA64_CPU_H_ +#define _ASM_IA64_CPU_H_ + +#include +#include +#include +#include + +struct ia64_cpu { + struct cpu cpu; +}; + +DECLARE_PER_CPU(struct ia64_cpu, cpu_devices); + +DECLARE_PER_CPU(int, cpu_state); + +#endif /* _ASM_IA64_CPU_H_ */ diff --git a/include/asm-ia64/crash.h b/include/asm-ia64/crash.h new file mode 100644 index 000000000..f51e828d6 --- /dev/null +++ b/include/asm-ia64/crash.h @@ -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 +#include +#include + +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 */ diff --git a/include/asm-ia64/rmap.h b/include/asm-ia64/rmap.h deleted file mode 100644 index 179c565dd..000000000 --- a/include/asm-ia64/rmap.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _ASM_IA64_RMAP_H -#define _ASM_IA64_RMAP_H - -/* nothing to see, move along */ -#include - -#endif /* _ASM_IA64_RMAP_H */ diff --git a/include/asm-m68k/rmap.h b/include/asm-m68k/rmap.h deleted file mode 100644 index 85119e414..000000000 --- a/include/asm-m68k/rmap.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _M68K_RMAP_H -#define _M68K_RMAP_H - -/* nothing to see, move along */ -#include - -#endif diff --git a/include/asm-m68knommu/rmap.h b/include/asm-m68knommu/rmap.h deleted file mode 100644 index b3664ccd5..000000000 --- a/include/asm-m68knommu/rmap.h +++ /dev/null @@ -1,2 +0,0 @@ -/* Do not need anything here */ - diff --git a/include/asm-mips/8253pit.h b/include/asm-mips/8253pit.h new file mode 100644 index 000000000..285f78488 --- /dev/null +++ b/include/asm-mips/8253pit.h @@ -0,0 +1,10 @@ +/* + * 8253/8254 Programmable Interval Timer + */ + +#ifndef _8253PIT_H +#define _8253PIT_H + +#define PIT_TICK_RATE 1193182UL + +#endif diff --git a/include/asm-mips/pmon.h b/include/asm-mips/pmon.h new file mode 100644 index 000000000..016251785 --- /dev/null +++ b/include/asm-mips/pmon.h @@ -0,0 +1,22 @@ +/* + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 2004 by Ralf Baechle + */ +#ifndef _ASM_PMON_H +#define _ASM_PMON_H + +struct callvectors { + int (*open) (char*, int, int); /* 0 */ + int (*close) (int); /* 4 */ + int (*read) (int, void*, int); /* 8 */ + int (*write) (int, void*, int); /* 12 */ + off_t (*lseek) (int, off_t, int); /* 16 */ + int (*printf) (const char*, ...); /* 20 */ + void (*cacheflush) (void); /* 24 */ + char* (*gets) (char*); /* 28 */ +}; + +#endif /* _ASM_PMON_H */ diff --git a/include/asm-mips/rmap.h b/include/asm-mips/rmap.h deleted file mode 100644 index c9efd7b98..000000000 --- a/include/asm-mips/rmap.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __ASM_RMAP_H -#define __ASM_RMAP_H - -/* nothing to see, move along */ -#include - -#endif /* __ASM_RMAP_H */ diff --git a/include/asm-parisc/rmap.h b/include/asm-parisc/rmap.h deleted file mode 100644 index 4ea8eb454..000000000 --- a/include/asm-parisc/rmap.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _PARISC_RMAP_H -#define _PARISC_RMAP_H - -/* nothing to see, move along */ -#include - -#endif diff --git a/include/asm-parisc/unwind.h b/include/asm-parisc/unwind.h new file mode 100644 index 000000000..5a52cb1f1 --- /dev/null +++ b/include/asm-parisc/unwind.h @@ -0,0 +1,72 @@ +#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 { + unsigned long sp; + unsigned long ip; + 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 prev_sp, prev_ip; +}; + +void * unwind_table_add(const char *name, unsigned long base_addr, + unsigned long gp, + const void *start, const void *end); +void unwind_frame_init(struct unwind_frame_info *info, struct task_struct *t, + struct pt_regs *regs); +void unwind_frame_init_from_blocked_task(struct unwind_frame_info *info, struct task_struct *t); +int unwind_once(struct unwind_frame_info *info); +int unwind_to_user(struct unwind_frame_info *info); + +#endif diff --git a/include/asm-ppc/ibm_ocp.h b/include/asm-ppc/ibm_ocp.h new file mode 100644 index 000000000..8c61d9304 --- /dev/null +++ b/include/asm-ppc/ibm_ocp.h @@ -0,0 +1,163 @@ +/* + * ibm_ocp.h + * + * (c) Benjamin Herrenschmidt (benh@kernel.crashing.org) + * Mipsys - France + * + * Derived from work (c) Armin Kuster akuster@pacbell.net + * + * Additional support and port to 2.6 LDM/sysfs by + * Matt Porter + * Copyright 2003-2004 MontaVista Software, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ +#ifdef __KERNEL__ +#ifndef __IBM_OCP_H__ +#define __IBM_OCP_H__ + +#include + +/* + * IBM 4xx OCP system information + */ +struct ocp_sys_info_data { + int opb_bus_freq; /* OPB Bus Frequency (Hz) */ + int ebc_bus_freq; /* EBC Bus Frequency (Hz) */ +}; + +extern struct ocp_sys_info_data ocp_sys_info; + +/* + * EMAC additional data and sysfs support + * + * Note about mdio_idx: When you have a zmii, it's usually + * not necessary, it covers the case of the 405EP which has + * the MDIO lines on EMAC0 only + * + * Note about phy_map: Per EMAC map of PHY ids which should + * be probed by emac_probe. Different EMACs can have + * overlapping maps. + * + * Note, this map uses inverse logic for bits: + * 0 - id should be probed + * 1 - id should be ignored + * + * Default value of 0x00000000 - will result in usual + * auto-detection logic. + * + */ + +struct ocp_func_emac_data { + int rgmii_idx; /* RGMII device index or -1 */ + int rgmii_mux; /* RGMII input of this EMAC */ + int zmii_idx; /* ZMII device index or -1 */ + int zmii_mux; /* ZMII input of this EMAC */ + int mal_idx; /* MAL device index */ + int mal_rx_chan; /* MAL rx channel number */ + int mal_tx_chan; /* MAL tx channel number */ + int wol_irq; /* WOL interrupt */ + int mdio_idx; /* EMAC idx of MDIO master or -1 */ + int tah_idx; /* TAH device index or -1 */ + int jumbo; /* Jumbo frames capable flag */ + int phy_mode; /* PHY type or configurable mode */ + u8 mac_addr[6]; /* EMAC mac address */ + u32 phy_map; /* EMAC phy map */ +}; + +/* Sysfs support */ +#define OCP_SYSFS_EMAC_DATA() \ +OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, zmii_idx) \ +OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, zmii_mux) \ +OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_idx) \ +OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_rx_chan) \ +OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_tx_chan) \ +OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, wol_irq) \ +OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mdio_idx) \ + \ +void ocp_show_emac_data(struct device *dev) \ +{ \ + device_create_file(dev, &dev_attr_emac_zmii_idx); \ + device_create_file(dev, &dev_attr_emac_zmii_mux); \ + device_create_file(dev, &dev_attr_emac_mal_idx); \ + device_create_file(dev, &dev_attr_emac_mal_rx_chan); \ + device_create_file(dev, &dev_attr_emac_mal_tx_chan); \ + device_create_file(dev, &dev_attr_emac_wol_irq); \ + device_create_file(dev, &dev_attr_emac_mdio_idx); \ +} + +#ifdef CONFIG_40x +/* + * Helper function to copy MAC addresses from the bd_t to OCP EMAC + * additions. + * + * The range of EMAC indices (inclusive) to be copied are the arguments. + */ +static inline void ibm_ocp_set_emac(int start, int end) +{ + int i; + struct ocp_def *def; + + /* Copy MAC addresses to EMAC additions */ + for (i=start; i<=end; i++) { + def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, i); + memcpy(((struct ocp_func_emac_data *)def->additions)->mac_addr, + &__res.bi_enetaddr[i], + 6); + } +} +#endif + +/* + * MAL additional data and sysfs support + */ +struct ocp_func_mal_data { + int num_tx_chans; /* Number of TX channels */ + int num_rx_chans; /* Number of RX channels */ + int txeob_irq; /* TX End Of Buffer IRQ */ + int rxeob_irq; /* RX End Of Buffer IRQ */ + int txde_irq; /* TX Descriptor Error IRQ */ + int rxde_irq; /* RX Descriptor Error IRQ */ + int serr_irq; /* MAL System Error IRQ */ +}; + +#define OCP_SYSFS_MAL_DATA() \ +OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, num_tx_chans) \ +OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, num_rx_chans) \ +OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, txeob_irq) \ +OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, rxeob_irq) \ +OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, txde_irq) \ +OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, rxde_irq) \ +OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, serr_irq) \ + \ +void ocp_show_mal_data(struct device *dev) \ +{ \ + device_create_file(dev, &dev_attr_mal_num_tx_chans); \ + device_create_file(dev, &dev_attr_mal_num_rx_chans); \ + device_create_file(dev, &dev_attr_mal_txeob_irq); \ + device_create_file(dev, &dev_attr_mal_rxeob_irq); \ + device_create_file(dev, &dev_attr_mal_txde_irq); \ + device_create_file(dev, &dev_attr_mal_rxde_irq); \ + device_create_file(dev, &dev_attr_mal_serr_irq); \ +} + +/* + * IIC additional data and sysfs support + */ +struct ocp_func_iic_data { + int fast_mode; /* IIC fast mode enabled */ +}; + +#define OCP_SYSFS_IIC_DATA() \ +OCP_SYSFS_ADDTL(struct ocp_func_iic_data, "%d\n", iic, fast_mode) \ + \ +void ocp_show_iic_data(struct device *dev) \ +{ \ + device_create_file(dev, &dev_attr_iic_fast_mode); \ +} +#endif /* __IBM_OCP_H__ */ +#endif /* __KERNEL__ */ diff --git a/include/asm-ppc/rmap.h b/include/asm-ppc/rmap.h deleted file mode 100644 index 50556b5ff..000000000 --- a/include/asm-ppc/rmap.h +++ /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 - -#endif diff --git a/include/asm-ppc64/rmap.h b/include/asm-ppc64/rmap.h deleted file mode 100644 index cf58a01ec..000000000 --- a/include/asm-ppc64/rmap.h +++ /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 - -#endif diff --git a/include/asm-s390/rmap.h b/include/asm-s390/rmap.h deleted file mode 100644 index 43d6a87b6..000000000 --- a/include/asm-s390/rmap.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _S390_RMAP_H -#define _S390_RMAP_H - -/* nothing to see, move along */ -#include - -#endif diff --git a/include/asm-sh/rmap.h b/include/asm-sh/rmap.h deleted file mode 100644 index 31db8cc07..000000000 --- a/include/asm-sh/rmap.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _SH_RMAP_H -#define _SH_RMAP_H - -/* nothing to see, move along */ -#include - -#endif diff --git a/include/asm-sparc/rmap.h b/include/asm-sparc/rmap.h deleted file mode 100644 index 06063cffe..000000000 --- a/include/asm-sparc/rmap.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _SPARC_RMAP_H -#define _SPARC_RMAP_H - -/* nothing to see, move along */ -#include - -#endif diff --git a/include/asm-sparc64/const.h b/include/asm-sparc64/const.h new file mode 100644 index 000000000..8ad902b2c --- /dev/null +++ b/include/asm-sparc64/const.h @@ -0,0 +1,19 @@ +/* const.h: Macros for dealing with constants. */ + +#ifndef _SPARC64_CONST_H +#define _SPARC64_CONST_H + +/* Some constant macros are used in both assembler and + * C code. Therefore we cannot annotate them always with + * 'UL' and other type specificers unilaterally. We + * use the following macros to deal with this. + */ + +#ifdef __ASSEMBLY__ +#define _AC(X,Y) X +#else +#define _AC(X,Y) (X##Y) +#endif + + +#endif /* !(_SPARC64_CONST_H) */ diff --git a/include/asm-sparc64/rmap.h b/include/asm-sparc64/rmap.h deleted file mode 100644 index 681849b2d..000000000 --- a/include/asm-sparc64/rmap.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _SPARC64_RMAP_H -#define _SPARC64_RMAP_H - -/* nothing to see, move along */ -#include - -#endif diff --git a/include/asm-um/rmap.h b/include/asm-um/rmap.h deleted file mode 100644 index a244d486b..000000000 --- a/include/asm-um/rmap.h +++ /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-v850/rmap.h b/include/asm-v850/rmap.h deleted file mode 100644 index c0ebee6f4..000000000 --- a/include/asm-v850/rmap.h +++ /dev/null @@ -1 +0,0 @@ -/* Do not need anything here */ diff --git a/include/asm-x86_64/8253pit.h b/include/asm-x86_64/8253pit.h new file mode 100644 index 000000000..285f78488 --- /dev/null +++ b/include/asm-x86_64/8253pit.h @@ -0,0 +1,10 @@ +/* + * 8253/8254 Programmable Interval Timer + */ + +#ifndef _8253PIT_H +#define _8253PIT_H + +#define PIT_TICK_RATE 1193182UL + +#endif diff --git a/include/asm-x86_64/rmap.h b/include/asm-x86_64/rmap.h deleted file mode 100644 index 24c1783ed..000000000 --- a/include/asm-x86_64/rmap.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _X8664_RMAP_H -#define _X8664_RMAP_H - -/* nothing to see, move along */ -#include - -#endif diff --git a/include/linux/autoconf.h b/include/linux/autoconf.h new file mode 100644 index 000000000..546d52177 --- /dev/null +++ b/include/linux/autoconf.h @@ -0,0 +1,2349 @@ +/* + * Automatically generated C config: don't edit + */ +#define AUTOCONF_INCLUDED +#define CONFIG_X86 1 +#define CONFIG_MMU 1 +#define CONFIG_UID16 1 +#define CONFIG_GENERIC_ISA_DMA 1 + +/* + * Code maturity level options + */ +#define CONFIG_EXPERIMENTAL 1 +#define CONFIG_CLEAN_COMPILE 1 +#define CONFIG_STANDALONE 1 + +/* + * General setup + */ +#define CONFIG_SWAP 1 +#define CONFIG_SYSVIPC 1 +#define CONFIG_POSIX_MQUEUE 1 +#define CONFIG_BSD_PROCESS_ACCT 1 +#define CONFIG_SYSCTL 1 +#undef CONFIG_AUDIT +#define CONFIG_LOG_BUF_SHIFT 17 +#define CONFIG_HOTPLUG 1 +#undef CONFIG_IKCONFIG +#undef CONFIG_EMBEDDED +#define CONFIG_KALLSYMS 1 +#undef CONFIG_KALLSYMS_ALL +#define CONFIG_FUTEX 1 +#define CONFIG_EPOLL 1 +#define CONFIG_IOSCHED_NOOP 1 +#define CONFIG_IOSCHED_AS 1 +#define CONFIG_IOSCHED_DEADLINE 1 +#define CONFIG_IOSCHED_CFQ 1 +#define CONFIG_CC_OPTIMIZE_FOR_SIZE 1 + +/* + * Loadable module support + */ +#define CONFIG_MODULES 1 +#define CONFIG_MODULE_UNLOAD 1 +#undef CONFIG_MODULE_FORCE_UNLOAD +#define CONFIG_OBSOLETE_MODPARM 1 +#undef CONFIG_MODVERSIONS +#define CONFIG_KMOD 1 +#define CONFIG_STOP_MACHINE 1 + +/* + * Processor type and features + */ +#undef CONFIG_X86_PC +#undef CONFIG_X86_ELAN +#undef CONFIG_X86_VOYAGER +#undef CONFIG_X86_NUMAQ +#undef CONFIG_X86_SUMMIT +#undef CONFIG_X86_BIGSMP +#undef CONFIG_X86_VISWS +#define CONFIG_X86_GENERICARCH 1 +#undef CONFIG_X86_ES7000 +#define CONFIG_X86_CYCLONE_TIMER 1 +#undef CONFIG_M386 +#undef CONFIG_M486 +#undef CONFIG_M586 +#undef CONFIG_M586TSC +#undef CONFIG_M586MMX +#define CONFIG_M686 1 +#undef CONFIG_MPENTIUMII +#undef CONFIG_MPENTIUMIII +#undef CONFIG_MPENTIUMM +#undef CONFIG_MPENTIUM4 +#undef CONFIG_MK6 +#undef CONFIG_MK7 +#undef CONFIG_MK8 +#undef CONFIG_MCRUSOE +#undef CONFIG_MWINCHIPC6 +#undef CONFIG_MWINCHIP2 +#undef CONFIG_MWINCHIP3D +#undef CONFIG_MCYRIXIII +#undef CONFIG_MVIAC3_2 +#define CONFIG_X86_GENERIC 1 +#define CONFIG_X86_CMPXCHG 1 +#define CONFIG_X86_XADD 1 +#define CONFIG_X86_L1_CACHE_SHIFT 7 +#define CONFIG_RWSEM_XCHGADD_ALGORITHM 1 +#define CONFIG_X86_PPRO_FENCE 1 +#define CONFIG_X86_WP_WORKS_OK 1 +#define CONFIG_X86_INVLPG 1 +#define CONFIG_X86_BSWAP 1 +#define CONFIG_X86_POPAD_OK 1 +#define CONFIG_X86_GOOD_APIC 1 +#define CONFIG_X86_INTEL_USERCOPY 1 +#define CONFIG_X86_USE_PPRO_CHECKSUM 1 +#define CONFIG_X86_4G 1 +#define CONFIG_X86_SWITCH_PAGETABLES 1 +#define CONFIG_X86_4G_VM_LAYOUT 1 +#define CONFIG_X86_UACCESS_INDIRECT 1 +#define CONFIG_X86_HIGH_ENTRY 1 +#define CONFIG_HPET_TIMER 1 +#define CONFIG_HPET_EMULATE_RTC 1 +#define CONFIG_SMP 1 +#define CONFIG_NR_CPUS 32 +#define CONFIG_SCHED_SMT 1 +#undef CONFIG_PREEMPT +#define CONFIG_X86_LOCAL_APIC 1 +#define CONFIG_X86_IO_APIC 1 +#define CONFIG_X86_TSC 1 +#define CONFIG_X86_MCE 1 +#undef CONFIG_X86_MCE_NONFATAL +#define CONFIG_X86_MCE_P4THERMAL 1 +#define CONFIG_TOSHIBA_MODULE 1 +#define CONFIG_I8K_MODULE 1 +#define CONFIG_MICROCODE_MODULE 1 +#define CONFIG_X86_MSR_MODULE 1 +#define CONFIG_X86_CPUID_MODULE 1 + +/* + * Firmware Drivers + */ +#define CONFIG_EDD_MODULE 1 +#undef CONFIG_NOHIGHMEM +#undef CONFIG_HIGHMEM4G +#define CONFIG_HIGHMEM64G 1 +#define CONFIG_HIGHMEM 1 +#define CONFIG_X86_PAE 1 +#undef CONFIG_NUMA +#define CONFIG_HIGHPTE 1 +#undef CONFIG_MATH_EMULATION +#define CONFIG_MTRR 1 +#undef CONFIG_EFI +#undef CONFIG_IRQBALANCE +#define CONFIG_HAVE_DEC_LOCK 1 +#define CONFIG_REGPARM 1 + +/* + * Power management options (ACPI, APM) + */ +#define CONFIG_PM 1 +#undef CONFIG_SOFTWARE_SUSPEND +#undef CONFIG_PM_DISK + +/* + * ACPI (Advanced Configuration and Power Interface) Support + */ +#define CONFIG_ACPI 1 +#define CONFIG_ACPI_BOOT 1 +#define CONFIG_ACPI_INTERPRETER 1 +#define CONFIG_ACPI_SLEEP 1 +#define CONFIG_ACPI_SLEEP_PROC_FS 1 +#define CONFIG_ACPI_AC_MODULE 1 +#define CONFIG_ACPI_BATTERY_MODULE 1 +#define CONFIG_ACPI_BUTTON_MODULE 1 +#define CONFIG_ACPI_FAN 1 +#define CONFIG_ACPI_PROCESSOR 1 +#define CONFIG_ACPI_THERMAL 1 +#define CONFIG_ACPI_ASUS_MODULE 1 +#define CONFIG_ACPI_TOSHIBA_MODULE 1 +#undef CONFIG_ACPI_DEBUG +#define CONFIG_ACPI_BUS 1 +#define CONFIG_ACPI_EC 1 +#define CONFIG_ACPI_POWER 1 +#define CONFIG_ACPI_PCI 1 +#define CONFIG_ACPI_SYSTEM 1 +#define CONFIG_X86_PM_TIMER 1 + +/* + * APM (Advanced Power Management) BIOS Support + */ +#define CONFIG_APM 1 +#undef CONFIG_APM_IGNORE_USER_SUSPEND +#undef CONFIG_APM_DO_ENABLE +#define CONFIG_APM_CPU_IDLE 1 +#undef CONFIG_APM_DISPLAY_BLANK +#define CONFIG_APM_RTC_IS_GMT 1 +#undef CONFIG_APM_ALLOW_INTS +#undef CONFIG_APM_REAL_MODE_POWER_OFF + +/* + * CPU Frequency scaling + */ +#define CONFIG_CPU_FREQ 1 +#undef CONFIG_CPU_FREQ_PROC_INTF +#undef CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE +#define CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE 1 +#define CONFIG_CPU_FREQ_GOV_PERFORMANCE 1 +#define CONFIG_CPU_FREQ_GOV_POWERSAVE_MODULE 1 +#define CONFIG_CPU_FREQ_GOV_USERSPACE 1 +#undef CONFIG_CPU_FREQ_24_API +#define CONFIG_CPU_FREQ_TABLE 1 + +/* + * CPUFreq processor drivers + */ +#define CONFIG_X86_ACPI_CPUFREQ_MODULE 1 +#undef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF +#define CONFIG_X86_POWERNOW_K6_MODULE 1 +#define CONFIG_X86_POWERNOW_K7 1 +#define CONFIG_X86_POWERNOW_K8_MODULE 1 +#undef CONFIG_X86_GX_SUSPMOD +#define CONFIG_X86_SPEEDSTEP_CENTRINO 1 +#define CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE 1 +#define CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI 1 +#define CONFIG_X86_SPEEDSTEP_ICH 1 +#define CONFIG_X86_SPEEDSTEP_SMI_MODULE 1 +#define CONFIG_X86_P4_CLOCKMOD_MODULE 1 +#define CONFIG_X86_SPEEDSTEP_LIB 1 +#undef CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK +#define CONFIG_X86_LONGRUN 1 +#undef CONFIG_X86_LONGHAUL + +/* + * Bus options (PCI, PCMCIA, EISA, MCA, ISA) + */ +#define CONFIG_PCI 1 +#undef CONFIG_PCI_GOBIOS +#undef CONFIG_PCI_GOMMCONFIG +#undef CONFIG_PCI_GODIRECT +#define CONFIG_PCI_GOANY 1 +#define CONFIG_PCI_BIOS 1 +#define CONFIG_PCI_DIRECT 1 +#define CONFIG_PCI_MMCONFIG 1 +#define CONFIG_PCI_USE_VECTOR 1 +#define CONFIG_PCI_LEGACY_PROC 1 +#undef CONFIG_PCI_NAMES +#define CONFIG_ISA 1 +#undef CONFIG_EISA +#undef CONFIG_MCA +#undef CONFIG_SCx200 + +/* + * PCMCIA/CardBus support + */ +#define CONFIG_PCMCIA_MODULE 1 +#undef CONFIG_PCMCIA_DEBUG +#define CONFIG_YENTA_MODULE 1 +#define CONFIG_CARDBUS 1 +#define CONFIG_I82092_MODULE 1 +#define CONFIG_I82365_MODULE 1 +#define CONFIG_TCIC_MODULE 1 +#define CONFIG_PCMCIA_PROBE 1 + +/* + * PCI Hotplug Support + */ +#define CONFIG_HOTPLUG_PCI 1 +#undef CONFIG_HOTPLUG_PCI_FAKE +#define CONFIG_HOTPLUG_PCI_COMPAQ_MODULE 1 +#undef CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM +#define CONFIG_HOTPLUG_PCI_IBM_MODULE 1 +#undef CONFIG_HOTPLUG_PCI_ACPI +#undef CONFIG_HOTPLUG_PCI_CPCI +#define CONFIG_HOTPLUG_PCI_PCIE_MODULE 1 +#define CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE 1 +#define CONFIG_HOTPLUG_PCI_SHPC_MODULE 1 +#define CONFIG_HOTPLUG_PCI_SHPC_POLL_EVENT_MODE 1 + +/* + * Executable file formats + */ +#define CONFIG_BINFMT_ELF 1 +#undef CONFIG_BINFMT_AOUT +#define CONFIG_BINFMT_MISC_MODULE 1 + +/* + * Device Drivers + */ + +/* + * Generic Driver Options + */ +#define CONFIG_FW_LOADER 1 +#undef CONFIG_DEBUG_DRIVER + +/* + * Memory Technology Devices (MTD) + */ +#define CONFIG_MTD_MODULE 1 +#undef CONFIG_MTD_DEBUG +#define CONFIG_MTD_PARTITIONS_MODULE 1 +#define CONFIG_MTD_CONCAT_MODULE 1 +#define CONFIG_MTD_REDBOOT_PARTS_MODULE 1 +#define CONFIG_MTD_CMDLINE_PARTS_MODULE 1 + +/* + * User Modules And Translation Layers + */ +#define CONFIG_MTD_CHAR_MODULE 1 +#define CONFIG_MTD_BLOCK_MODULE 1 +#define CONFIG_MTD_BLOCK_RO_MODULE 1 +#define CONFIG_FTL_MODULE 1 +#define CONFIG_NFTL_MODULE 1 +#define CONFIG_NFTL_RW 1 +#define CONFIG_INFTL_MODULE 1 + +/* + * RAM/ROM/Flash chip drivers + */ +#define CONFIG_MTD_CFI_MODULE 1 +#define CONFIG_MTD_JEDECPROBE_MODULE 1 +#define CONFIG_MTD_GEN_PROBE_MODULE 1 +#undef CONFIG_MTD_CFI_ADV_OPTIONS +#define CONFIG_MTD_CFI_INTELEXT_MODULE 1 +#define CONFIG_MTD_CFI_AMDSTD_MODULE 1 +#define CONFIG_MTD_CFI_STAA_MODULE 1 +#define CONFIG_MTD_RAM_MODULE 1 +#define CONFIG_MTD_ROM_MODULE 1 +#define CONFIG_MTD_ABSENT_MODULE 1 +#undef CONFIG_MTD_OBSOLETE_CHIPS + +/* + * Mapping drivers for chip access + */ +#define CONFIG_MTD_COMPLEX_MAPPINGS 1 +#undef CONFIG_MTD_PHYSMAP +#undef CONFIG_MTD_PNC2000 +#define CONFIG_MTD_SC520CDP_MODULE 1 +#define CONFIG_MTD_NETSC520_MODULE 1 +#define CONFIG_MTD_SBC_GXX_MODULE 1 +#define CONFIG_MTD_ELAN_104NC_MODULE 1 +#define CONFIG_MTD_SCx200_DOCFLASH_MODULE 1 +#define CONFIG_MTD_AMD76XROM_MODULE 1 +#define CONFIG_MTD_ICH2ROM_MODULE 1 +#define CONFIG_MTD_SCB2_FLASH_MODULE 1 +#undef CONFIG_MTD_NETtel +#undef CONFIG_MTD_DILNETPC +#define CONFIG_MTD_L440GX_MODULE 1 +#define CONFIG_MTD_PCI_MODULE 1 + +/* + * Self-contained MTD device drivers + */ +#define CONFIG_MTD_PMC551_MODULE 1 +#undef CONFIG_MTD_PMC551_BUGFIX +#undef CONFIG_MTD_PMC551_DEBUG +#undef CONFIG_MTD_SLRAM +#define CONFIG_MTD_MTDRAM_MODULE 1 +#define CONFIG_MTDRAM_TOTAL_SIZE 4096 +#define CONFIG_MTDRAM_ERASE_SIZE 128 +#undef CONFIG_MTD_BLKMTD + +/* + * Disk-On-Chip Device Drivers + */ +#define CONFIG_MTD_DOC2000_MODULE 1 +#undef CONFIG_MTD_DOC2001 +#define CONFIG_MTD_DOC2001PLUS_MODULE 1 +#define CONFIG_MTD_DOCPROBE_MODULE 1 +#undef CONFIG_MTD_DOCPROBE_ADVANCED +#define CONFIG_MTD_DOCPROBE_ADDRESS 0x0 + +/* + * NAND Flash Device Drivers + */ +#define CONFIG_MTD_NAND_MODULE 1 +#undef CONFIG_MTD_NAND_VERIFY_WRITE +#define CONFIG_MTD_NAND_IDS_MODULE 1 + +/* + * Parallel port support + */ +#define CONFIG_PARPORT_MODULE 1 +#define CONFIG_PARPORT_PC_MODULE 1 +#define CONFIG_PARPORT_PC_CML1_MODULE 1 +#define CONFIG_PARPORT_SERIAL_MODULE 1 +#undef CONFIG_PARPORT_PC_FIFO +#undef CONFIG_PARPORT_PC_SUPERIO +#define CONFIG_PARPORT_PC_PCMCIA_MODULE 1 +#undef CONFIG_PARPORT_OTHER +#define CONFIG_PARPORT_1284 1 + +/* + * Plug and Play support + */ +#define CONFIG_PNP 1 +#undef CONFIG_PNP_DEBUG + +/* + * Protocols + */ +#define CONFIG_ISAPNP 1 +#undef CONFIG_PNPBIOS + +/* + * Block devices + */ +#define CONFIG_BLK_DEV_FD_MODULE 1 +#undef CONFIG_BLK_DEV_XD +#undef CONFIG_PARIDE +#define CONFIG_BLK_CPQ_DA_MODULE 1 +#define CONFIG_BLK_CPQ_CISS_DA_MODULE 1 +#define CONFIG_CISS_SCSI_TAPE 1 +#define CONFIG_BLK_DEV_DAC960_MODULE 1 +#define CONFIG_BLK_DEV_UMEM_MODULE 1 +#define CONFIG_BLK_DEV_LOOP_MODULE 1 +#define CONFIG_BLK_DEV_CRYPTOLOOP_MODULE 1 +#define CONFIG_BLK_DEV_NBD_MODULE 1 +#define CONFIG_BLK_DEV_CARMEL_MODULE 1 +#define CONFIG_BLK_DEV_RAM 1 +#define CONFIG_BLK_DEV_RAM_SIZE 16384 +#define CONFIG_BLK_DEV_INITRD 1 +#define CONFIG_LBD 1 + +/* + * ATA/ATAPI/MFM/RLL support + */ +#define CONFIG_IDE 1 +#define CONFIG_BLK_DEV_IDE 1 + +/* + * Please see Documentation/ide.txt for help/info on IDE drives + */ +#undef CONFIG_BLK_DEV_HD_IDE +#define CONFIG_BLK_DEV_IDEDISK 1 +#define CONFIG_IDEDISK_MULTI_MODE 1 +#undef CONFIG_IDEDISK_STROKE +#define CONFIG_BLK_DEV_IDECS_MODULE 1 +#define CONFIG_BLK_DEV_IDECD 1 +#define CONFIG_BLK_DEV_IDETAPE_MODULE 1 +#define CONFIG_BLK_DEV_IDEFLOPPY 1 +#undef CONFIG_BLK_DEV_IDESCSI +#undef CONFIG_IDE_TASK_IOCTL +#undef CONFIG_IDE_TASKFILE_IO + +/* + * IDE chipset support/bugfixes + */ +#define CONFIG_IDE_GENERIC 1 +#undef CONFIG_BLK_DEV_CMD640 +#define CONFIG_BLK_DEV_IDEPNP 1 +#define CONFIG_BLK_DEV_IDEPCI 1 +#define CONFIG_IDEPCI_SHARE_IRQ 1 +#undef CONFIG_BLK_DEV_OFFBOARD +#define CONFIG_BLK_DEV_GENERIC 1 +#undef CONFIG_BLK_DEV_OPTI621 +#define CONFIG_BLK_DEV_RZ1000 1 +#define CONFIG_BLK_DEV_IDEDMA_PCI 1 +#undef CONFIG_BLK_DEV_IDEDMA_FORCED +#define CONFIG_IDEDMA_PCI_AUTO 1 +#undef CONFIG_IDEDMA_ONLYDISK +#define CONFIG_BLK_DEV_ADMA 1 +#define CONFIG_BLK_DEV_AEC62XX 1 +#define CONFIG_BLK_DEV_ALI15X3 1 +#undef CONFIG_WDC_ALI15X3 +#define CONFIG_BLK_DEV_AMD74XX 1 +#define CONFIG_BLK_DEV_ATIIXP 1 +#define CONFIG_BLK_DEV_CMD64X 1 +#define CONFIG_BLK_DEV_TRIFLEX 1 +#define CONFIG_BLK_DEV_CY82C693 1 +#define CONFIG_BLK_DEV_CS5520 1 +#define CONFIG_BLK_DEV_CS5530 1 +#define CONFIG_BLK_DEV_HPT34X 1 +#undef CONFIG_HPT34X_AUTODMA +#define CONFIG_BLK_DEV_HPT366 1 +#undef CONFIG_BLK_DEV_SC1200 +#define CONFIG_BLK_DEV_PIIX 1 +#undef CONFIG_BLK_DEV_NS87415 +#define CONFIG_BLK_DEV_PDC202XX_OLD 1 +#undef CONFIG_PDC202XX_BURST +#define CONFIG_BLK_DEV_PDC202XX_NEW 1 +#define CONFIG_PDC202XX_FORCE 1 +#define CONFIG_BLK_DEV_SVWKS 1 +#define CONFIG_BLK_DEV_SIIMAGE 1 +#define CONFIG_BLK_DEV_SIS5513 1 +#define CONFIG_BLK_DEV_SLC90E66 1 +#undef CONFIG_BLK_DEV_TRM290 +#define CONFIG_BLK_DEV_VIA82CXXX 1 +#undef CONFIG_IDE_ARM +#undef CONFIG_IDE_CHIPSETS +#define CONFIG_BLK_DEV_IDEDMA 1 +#undef CONFIG_IDEDMA_IVB +#define CONFIG_IDEDMA_AUTO 1 +#undef CONFIG_BLK_DEV_HD + +/* + * SCSI device support + */ +#define CONFIG_SCSI_MODULE 1 +#define CONFIG_SCSI_PROC_FS 1 + +/* + * SCSI support type (disk, tape, CD-ROM) + */ +#define CONFIG_BLK_DEV_SD_MODULE 1 +#define CONFIG_CHR_DEV_ST_MODULE 1 +#define CONFIG_CHR_DEV_OSST_MODULE 1 +#define CONFIG_BLK_DEV_SR_MODULE 1 +#define CONFIG_BLK_DEV_SR_VENDOR 1 +#define CONFIG_CHR_DEV_SG_MODULE 1 + +/* + * Some SCSI devices (e.g. CD jukebox) support multiple LUNs + */ +#undef CONFIG_SCSI_MULTI_LUN +#define CONFIG_SCSI_CONSTANTS 1 +#define CONFIG_SCSI_LOGGING 1 + +/* + * SCSI Transport Attributes + */ +#define CONFIG_SCSI_SPI_ATTRS_MODULE 1 +#define CONFIG_SCSI_FC_ATTRS_MODULE 1 + +/* + * SCSI low-level drivers + */ +#define CONFIG_BLK_DEV_3W_XXXX_RAID_MODULE 1 +#undef CONFIG_SCSI_7000FASST +#define CONFIG_SCSI_ACARD_MODULE 1 +#define CONFIG_SCSI_AHA152X_MODULE 1 +#define CONFIG_SCSI_AHA1542_MODULE 1 +#define CONFIG_SCSI_AACRAID_MODULE 1 +#define CONFIG_SCSI_AIC7XXX_MODULE 1 +#define CONFIG_AIC7XXX_CMDS_PER_DEVICE 4 +#define CONFIG_AIC7XXX_RESET_DELAY_MS 15000 +#undef CONFIG_AIC7XXX_BUILD_FIRMWARE +#undef CONFIG_AIC7XXX_DEBUG_ENABLE +#define CONFIG_AIC7XXX_DEBUG_MASK 0 +#undef CONFIG_AIC7XXX_REG_PRETTY_PRINT +#define CONFIG_SCSI_AIC7XXX_OLD_MODULE 1 +#define CONFIG_SCSI_AIC79XX_MODULE 1 +#define CONFIG_AIC79XX_CMDS_PER_DEVICE 4 +#define CONFIG_AIC79XX_RESET_DELAY_MS 15000 +#undef CONFIG_AIC79XX_BUILD_FIRMWARE +#undef CONFIG_AIC79XX_ENABLE_RD_STRM +#undef CONFIG_AIC79XX_DEBUG_ENABLE +#define CONFIG_AIC79XX_DEBUG_MASK 0 +#undef CONFIG_AIC79XX_REG_PRETTY_PRINT +#undef CONFIG_SCSI_DPT_I2O +#define CONFIG_SCSI_ADVANSYS_MODULE 1 +#define CONFIG_SCSI_IN2000_MODULE 1 +#define CONFIG_SCSI_MEGARAID_MODULE 1 +#define CONFIG_SCSI_SATA 1 +#define CONFIG_SCSI_SATA_SVW_MODULE 1 +#define CONFIG_SCSI_ATA_PIIX_MODULE 1 +#define CONFIG_SCSI_SATA_PROMISE_MODULE 1 +#define CONFIG_SCSI_SATA_SX4_MODULE 1 +#define CONFIG_SCSI_SATA_SIL_MODULE 1 +#define CONFIG_SCSI_SATA_SIS_MODULE 1 +#define CONFIG_SCSI_SATA_VIA_MODULE 1 +#define CONFIG_SCSI_SATA_VITESSE_MODULE 1 +#define CONFIG_SCSI_BUSLOGIC_MODULE 1 +#undef CONFIG_SCSI_OMIT_FLASHPOINT +#undef CONFIG_SCSI_CPQFCTS +#undef CONFIG_SCSI_DMX3191D +#undef CONFIG_SCSI_DTC3280 +#undef CONFIG_SCSI_EATA +#undef CONFIG_SCSI_EATA_PIO +#define CONFIG_SCSI_FUTURE_DOMAIN_MODULE 1 +#define CONFIG_SCSI_GDTH_MODULE 1 +#undef CONFIG_SCSI_GENERIC_NCR5380 +#undef CONFIG_SCSI_GENERIC_NCR5380_MMIO +#define CONFIG_SCSI_IPS_MODULE 1 +#define CONFIG_SCSI_INIA100_MODULE 1 +#define CONFIG_SCSI_PPA_MODULE 1 +#define CONFIG_SCSI_IMM_MODULE 1 +#undef CONFIG_SCSI_IZIP_EPP16 +#undef CONFIG_SCSI_IZIP_SLOW_CTR +#undef CONFIG_SCSI_NCR53C406A +#define CONFIG_SCSI_SYM53C8XX_2_MODULE 1 +#define CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE 1 +#define CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS 16 +#define CONFIG_SCSI_SYM53C8XX_MAX_TAGS 64 +#undef CONFIG_SCSI_SYM53C8XX_IOMAPPED +#undef CONFIG_SCSI_IPR +#undef CONFIG_SCSI_PAS16 +#undef CONFIG_SCSI_PSI240I +#define CONFIG_SCSI_QLOGIC_FAS_MODULE 1 +#define CONFIG_SCSI_QLOGIC_ISP_MODULE 1 +#undef CONFIG_SCSI_QLOGIC_FC +#define CONFIG_SCSI_QLOGIC_1280_MODULE 1 +#define CONFIG_SCSI_QLA2XXX_MODULE 1 +#define CONFIG_SCSI_QLA21XX_MODULE 1 +#define CONFIG_SCSI_QLA22XX_MODULE 1 +#define CONFIG_SCSI_QLA2300_MODULE 1 +#define CONFIG_SCSI_QLA2322_MODULE 1 +#define CONFIG_SCSI_QLA6312_MODULE 1 +#define CONFIG_SCSI_QLA6322_MODULE 1 +#undef CONFIG_SCSI_SYM53C416 +#undef CONFIG_SCSI_DC395x +#define CONFIG_SCSI_DC390T_MODULE 1 +#undef CONFIG_SCSI_T128 +#undef CONFIG_SCSI_U14_34F +#undef CONFIG_SCSI_ULTRASTOR +#undef CONFIG_SCSI_NSP32 +#undef CONFIG_SCSI_DEBUG + +/* + * PCMCIA SCSI adapter support + */ +#define CONFIG_PCMCIA_AHA152X_MODULE 1 +#define CONFIG_PCMCIA_FDOMAIN_MODULE 1 +#define CONFIG_PCMCIA_NINJA_SCSI_MODULE 1 +#define CONFIG_PCMCIA_QLOGIC_MODULE 1 +#define CONFIG_PCMCIA_SYM53C500_MODULE 1 + +/* + * Old CD-ROM drivers (not SCSI, not IDE) + */ +#undef CONFIG_CD_NO_IDESCSI + +/* + * Multi-device support (RAID and LVM) + */ +#define CONFIG_MD 1 +#define CONFIG_BLK_DEV_MD 1 +#define CONFIG_MD_LINEAR_MODULE 1 +#define CONFIG_MD_RAID0_MODULE 1 +#define CONFIG_MD_RAID1_MODULE 1 +#define CONFIG_MD_RAID5_MODULE 1 +#define CONFIG_MD_RAID6_MODULE 1 +#define CONFIG_MD_MULTIPATH_MODULE 1 +#define CONFIG_BLK_DEV_DM_MODULE 1 +#define CONFIG_DM_CRYPT_MODULE 1 + +/* + * Fusion MPT device support + */ +#define CONFIG_FUSION_MODULE 1 +#define CONFIG_FUSION_MAX_SGE 40 +#undef CONFIG_FUSION_ISENSE +#define CONFIG_FUSION_CTL_MODULE 1 +#define CONFIG_FUSION_LAN_MODULE 1 + +/* + * IEEE 1394 (FireWire) support + */ +#define CONFIG_IEEE1394_MODULE 1 + +/* + * Subsystem Options + */ +#undef CONFIG_IEEE1394_VERBOSEDEBUG +#define CONFIG_IEEE1394_OUI_DB 1 +#undef CONFIG_IEEE1394_EXTRA_CONFIG_ROMS + +/* + * Device Drivers + */ +#undef CONFIG_IEEE1394_PCILYNX +#define CONFIG_IEEE1394_OHCI1394_MODULE 1 + +/* + * Protocol Drivers + */ +#define CONFIG_IEEE1394_VIDEO1394_MODULE 1 +#define CONFIG_IEEE1394_SBP2_MODULE 1 +#undef CONFIG_IEEE1394_SBP2_PHYS_DMA +#undef CONFIG_IEEE1394_ETH1394 +#define CONFIG_IEEE1394_DV1394_MODULE 1 +#define CONFIG_IEEE1394_RAWIO_MODULE 1 +#define CONFIG_IEEE1394_CMP_MODULE 1 +#define CONFIG_IEEE1394_AMDTP_MODULE 1 + +/* + * I2O device support + */ +#define CONFIG_I2O_MODULE 1 +#define CONFIG_I2O_CONFIG_MODULE 1 +#define CONFIG_I2O_BLOCK_MODULE 1 +#define CONFIG_I2O_SCSI_MODULE 1 +#define CONFIG_I2O_PROC_MODULE 1 + +/* + * Networking support + */ +#define CONFIG_NET 1 + +/* + * Networking options + */ +#define CONFIG_PACKET 1 +#define CONFIG_PACKET_MMAP 1 +#define CONFIG_NETLINK_DEV 1 +#define CONFIG_UNIX 1 +#define CONFIG_NET_KEY_MODULE 1 +#define CONFIG_INET 1 +#define CONFIG_IP_MULTICAST 1 +#define CONFIG_IP_ADVANCED_ROUTER 1 +#define CONFIG_IP_MULTIPLE_TABLES 1 +#define CONFIG_IP_ROUTE_FWMARK 1 +#define CONFIG_IP_ROUTE_NAT 1 +#define CONFIG_IP_ROUTE_MULTIPATH 1 +#define CONFIG_IP_ROUTE_TOS 1 +#define CONFIG_IP_ROUTE_VERBOSE 1 +#undef CONFIG_IP_PNP +#define CONFIG_NET_IPIP_MODULE 1 +#define CONFIG_NET_IPGRE_MODULE 1 +#define CONFIG_NET_IPGRE_BROADCAST 1 +#define CONFIG_IP_MROUTE 1 +#define CONFIG_IP_PIMSM_V1 1 +#define CONFIG_IP_PIMSM_V2 1 +#undef CONFIG_ARPD +#define CONFIG_SYN_COOKIES 1 +#define CONFIG_INET_AH_MODULE 1 +#define CONFIG_INET_ESP_MODULE 1 +#define CONFIG_INET_IPCOMP_MODULE 1 + +/* + * IP: Virtual Server Configuration + */ +#define CONFIG_IP_VS_MODULE 1 +#undef CONFIG_IP_VS_DEBUG +#define CONFIG_IP_VS_TAB_BITS 12 + +/* + * IPVS transport protocol load balancing support + */ +#define CONFIG_IP_VS_PROTO_TCP 1 +#define CONFIG_IP_VS_PROTO_UDP 1 +#define CONFIG_IP_VS_PROTO_ESP 1 +#define CONFIG_IP_VS_PROTO_AH 1 + +/* + * IPVS scheduler + */ +#define CONFIG_IP_VS_RR_MODULE 1 +#define CONFIG_IP_VS_WRR_MODULE 1 +#define CONFIG_IP_VS_LC_MODULE 1 +#define CONFIG_IP_VS_WLC_MODULE 1 +#define CONFIG_IP_VS_LBLC_MODULE 1 +#define CONFIG_IP_VS_LBLCR_MODULE 1 +#define CONFIG_IP_VS_DH_MODULE 1 +#define CONFIG_IP_VS_SH_MODULE 1 +#define CONFIG_IP_VS_SED_MODULE 1 +#define CONFIG_IP_VS_NQ_MODULE 1 + +/* + * IPVS application helper + */ +#define CONFIG_IP_VS_FTP_MODULE 1 +#define CONFIG_IPV6_MODULE 1 +#define CONFIG_IPV6_PRIVACY 1 +#define CONFIG_INET6_AH_MODULE 1 +#define CONFIG_INET6_ESP_MODULE 1 +#define CONFIG_INET6_IPCOMP_MODULE 1 +#define CONFIG_IPV6_TUNNEL_MODULE 1 +#define CONFIG_NETFILTER 1 +#undef CONFIG_NETFILTER_DEBUG +#define CONFIG_BRIDGE_NETFILTER 1 + +/* + * IP: Netfilter Configuration + */ +#define CONFIG_IP_NF_CONNTRACK_MODULE 1 +#define CONFIG_IP_NF_FTP_MODULE 1 +#define CONFIG_IP_NF_IRC_MODULE 1 +#define CONFIG_IP_NF_TFTP_MODULE 1 +#define CONFIG_IP_NF_AMANDA_MODULE 1 +#define CONFIG_IP_NF_QUEUE_MODULE 1 +#define CONFIG_IP_NF_IPTABLES_MODULE 1 +#define CONFIG_IP_NF_MATCH_LIMIT_MODULE 1 +#define CONFIG_IP_NF_MATCH_IPRANGE_MODULE 1 +#define CONFIG_IP_NF_MATCH_MAC_MODULE 1 +#define CONFIG_IP_NF_MATCH_PKTTYPE_MODULE 1 +#define CONFIG_IP_NF_MATCH_MARK_MODULE 1 +#define CONFIG_IP_NF_MATCH_MULTIPORT_MODULE 1 +#define CONFIG_IP_NF_MATCH_TOS_MODULE 1 +#define CONFIG_IP_NF_MATCH_RECENT_MODULE 1 +#define CONFIG_IP_NF_MATCH_ECN_MODULE 1 +#define CONFIG_IP_NF_MATCH_DSCP_MODULE 1 +#define CONFIG_IP_NF_MATCH_AH_ESP_MODULE 1 +#define CONFIG_IP_NF_MATCH_LENGTH_MODULE 1 +#define CONFIG_IP_NF_MATCH_TTL_MODULE 1 +#define CONFIG_IP_NF_MATCH_TCPMSS_MODULE 1 +#define CONFIG_IP_NF_MATCH_HELPER_MODULE 1 +#define CONFIG_IP_NF_MATCH_STATE_MODULE 1 +#define CONFIG_IP_NF_MATCH_CONNTRACK_MODULE 1 +#define CONFIG_IP_NF_MATCH_OWNER_MODULE 1 +#define CONFIG_IP_NF_MATCH_PHYSDEV_MODULE 1 +#define CONFIG_IP_NF_FILTER_MODULE 1 +#define CONFIG_IP_NF_TARGET_REJECT_MODULE 1 +#define CONFIG_IP_NF_NAT_MODULE 1 +#define CONFIG_IP_NF_NAT_NEEDED 1 +#define CONFIG_IP_NF_TARGET_MASQUERADE_MODULE 1 +#define CONFIG_IP_NF_TARGET_REDIRECT_MODULE 1 +#define CONFIG_IP_NF_TARGET_NETMAP_MODULE 1 +#define CONFIG_IP_NF_TARGET_SAME_MODULE 1 +#define CONFIG_IP_NF_NAT_LOCAL 1 +#define CONFIG_IP_NF_NAT_SNMP_BASIC_MODULE 1 +#define CONFIG_IP_NF_NAT_IRC_MODULE 1 +#define CONFIG_IP_NF_NAT_FTP_MODULE 1 +#define CONFIG_IP_NF_NAT_TFTP_MODULE 1 +#define CONFIG_IP_NF_NAT_AMANDA_MODULE 1 +#define CONFIG_IP_NF_MANGLE_MODULE 1 +#define CONFIG_IP_NF_TARGET_TOS_MODULE 1 +#define CONFIG_IP_NF_TARGET_ECN_MODULE 1 +#define CONFIG_IP_NF_TARGET_DSCP_MODULE 1 +#define CONFIG_IP_NF_TARGET_MARK_MODULE 1 +#define CONFIG_IP_NF_TARGET_CLASSIFY_MODULE 1 +#define CONFIG_IP_NF_TARGET_LOG_MODULE 1 +#define CONFIG_IP_NF_TARGET_ULOG_MODULE 1 +#define CONFIG_IP_NF_TARGET_TCPMSS_MODULE 1 +#define CONFIG_IP_NF_ARPTABLES_MODULE 1 +#define CONFIG_IP_NF_ARPFILTER_MODULE 1 +#define CONFIG_IP_NF_ARP_MANGLE_MODULE 1 +#undef CONFIG_IP_NF_COMPAT_IPCHAINS +#undef CONFIG_IP_NF_COMPAT_IPFWADM +#define CONFIG_IP_NF_TARGET_NOTRACK_MODULE 1 +#define CONFIG_IP_NF_RAW_MODULE 1 + +/* + * IPv6: Netfilter Configuration + */ +#undef CONFIG_IP6_NF_QUEUE +#define CONFIG_IP6_NF_IPTABLES_MODULE 1 +#define CONFIG_IP6_NF_MATCH_LIMIT_MODULE 1 +#define CONFIG_IP6_NF_MATCH_MAC_MODULE 1 +#define CONFIG_IP6_NF_MATCH_RT_MODULE 1 +#define CONFIG_IP6_NF_MATCH_OPTS_MODULE 1 +#define CONFIG_IP6_NF_MATCH_FRAG_MODULE 1 +#define CONFIG_IP6_NF_MATCH_HL_MODULE 1 +#define CONFIG_IP6_NF_MATCH_MULTIPORT_MODULE 1 +#define CONFIG_IP6_NF_MATCH_OWNER_MODULE 1 +#define CONFIG_IP6_NF_MATCH_MARK_MODULE 1 +#define CONFIG_IP6_NF_MATCH_IPV6HEADER_MODULE 1 +#define CONFIG_IP6_NF_MATCH_AHESP_MODULE 1 +#define CONFIG_IP6_NF_MATCH_LENGTH_MODULE 1 +#define CONFIG_IP6_NF_MATCH_EUI64_MODULE 1 +#define CONFIG_IP6_NF_FILTER_MODULE 1 +#define CONFIG_IP6_NF_TARGET_LOG_MODULE 1 +#define CONFIG_IP6_NF_MANGLE_MODULE 1 +#define CONFIG_IP6_NF_TARGET_MARK_MODULE 1 +#define CONFIG_IP6_NF_RAW_MODULE 1 + +/* + * Bridge: Netfilter Configuration + */ +#define CONFIG_BRIDGE_NF_EBTABLES_MODULE 1 +#define CONFIG_BRIDGE_EBT_BROUTE_MODULE 1 +#define CONFIG_BRIDGE_EBT_T_FILTER_MODULE 1 +#define CONFIG_BRIDGE_EBT_T_NAT_MODULE 1 +#define CONFIG_BRIDGE_EBT_802_3_MODULE 1 +#define CONFIG_BRIDGE_EBT_AMONG_MODULE 1 +#define CONFIG_BRIDGE_EBT_ARP_MODULE 1 +#define CONFIG_BRIDGE_EBT_IP_MODULE 1 +#define CONFIG_BRIDGE_EBT_LIMIT_MODULE 1 +#define CONFIG_BRIDGE_EBT_MARK_MODULE 1 +#define CONFIG_BRIDGE_EBT_PKTTYPE_MODULE 1 +#define CONFIG_BRIDGE_EBT_STP_MODULE 1 +#define CONFIG_BRIDGE_EBT_VLAN_MODULE 1 +#define CONFIG_BRIDGE_EBT_ARPREPLY_MODULE 1 +#define CONFIG_BRIDGE_EBT_DNAT_MODULE 1 +#define CONFIG_BRIDGE_EBT_MARK_T_MODULE 1 +#define CONFIG_BRIDGE_EBT_REDIRECT_MODULE 1 +#define CONFIG_BRIDGE_EBT_SNAT_MODULE 1 +#define CONFIG_BRIDGE_EBT_LOG_MODULE 1 +#define CONFIG_XFRM 1 +#define CONFIG_XFRM_USER 1 + +/* + * SCTP Configuration (EXPERIMENTAL) + */ +#define CONFIG_IP_SCTP_MODULE 1 +#undef CONFIG_SCTP_DBG_MSG +#undef CONFIG_SCTP_DBG_OBJCNT +#undef CONFIG_SCTP_HMAC_NONE +#undef CONFIG_SCTP_HMAC_SHA1 +#define CONFIG_SCTP_HMAC_MD5 1 +#undef CONFIG_ATM +#define CONFIG_BRIDGE_MODULE 1 +#define CONFIG_VLAN_8021Q_MODULE 1 +#undef CONFIG_DECNET +#define CONFIG_LLC_MODULE 1 +#undef CONFIG_LLC2 +#define CONFIG_IPX_MODULE 1 +#undef CONFIG_IPX_INTERN +#define CONFIG_ATALK_MODULE 1 +#define CONFIG_DEV_APPLETALK 1 +#define CONFIG_LTPC_MODULE 1 +#define CONFIG_COPS_MODULE 1 +#define CONFIG_COPS_DAYNA 1 +#define CONFIG_COPS_TANGENT 1 +#define CONFIG_IPDDP_MODULE 1 +#define CONFIG_IPDDP_ENCAP 1 +#define CONFIG_IPDDP_DECAP 1 +#undef CONFIG_X25 +#undef CONFIG_LAPB +#define CONFIG_NET_DIVERT 1 +#undef CONFIG_ECONET +#define CONFIG_WAN_ROUTER_MODULE 1 +#undef CONFIG_NET_FASTROUTE +#undef CONFIG_NET_HW_FLOWCONTROL + +/* + * QoS and/or fair queueing + */ +#define CONFIG_NET_SCHED 1 +#define CONFIG_NET_SCH_CBQ_MODULE 1 +#define CONFIG_NET_SCH_HTB_MODULE 1 +#define CONFIG_NET_SCH_HFSC_MODULE 1 +#define CONFIG_NET_SCH_CSZ_MODULE 1 +#define CONFIG_NET_SCH_PRIO_MODULE 1 +#define CONFIG_NET_SCH_RED_MODULE 1 +#define CONFIG_NET_SCH_SFQ_MODULE 1 +#define CONFIG_NET_SCH_TEQL_MODULE 1 +#define CONFIG_NET_SCH_TBF_MODULE 1 +#define CONFIG_NET_SCH_GRED_MODULE 1 +#define CONFIG_NET_SCH_DSMARK_MODULE 1 +#define CONFIG_NET_SCH_DELAY_MODULE 1 +#define CONFIG_NET_SCH_INGRESS_MODULE 1 +#define CONFIG_NET_QOS 1 +#define CONFIG_NET_ESTIMATOR 1 +#define CONFIG_NET_CLS 1 +#define CONFIG_NET_CLS_TCINDEX_MODULE 1 +#define CONFIG_NET_CLS_ROUTE4_MODULE 1 +#define CONFIG_NET_CLS_ROUTE 1 +#define CONFIG_NET_CLS_FW_MODULE 1 +#define CONFIG_NET_CLS_U32_MODULE 1 +#define CONFIG_NET_CLS_RSVP_MODULE 1 +#define CONFIG_NET_CLS_RSVP6_MODULE 1 +#define CONFIG_NET_CLS_POLICE 1 + +/* + * Network testing + */ +#undef CONFIG_NET_PKTGEN +#define CONFIG_NETPOLL 1 +#undef CONFIG_NETPOLL_RX +#undef CONFIG_NETPOLL_TRAP +#define CONFIG_NET_POLL_CONTROLLER 1 +#undef CONFIG_HAMRADIO +#define CONFIG_IRDA_MODULE 1 + +/* + * IrDA protocols + */ +#define CONFIG_IRLAN_MODULE 1 +#define CONFIG_IRNET_MODULE 1 +#define CONFIG_IRCOMM_MODULE 1 +#undef CONFIG_IRDA_ULTRA + +/* + * IrDA options + */ +#define CONFIG_IRDA_CACHE_LAST_LSAP 1 +#define CONFIG_IRDA_FAST_RR 1 +#undef CONFIG_IRDA_DEBUG + +/* + * Infrared-port device drivers + */ + +/* + * SIR device drivers + */ +#define CONFIG_IRTTY_SIR_MODULE 1 + +/* + * Dongle support + */ +#define CONFIG_DONGLE 1 +#define CONFIG_ESI_DONGLE_MODULE 1 +#define CONFIG_ACTISYS_DONGLE_MODULE 1 +#define CONFIG_TEKRAM_DONGLE_MODULE 1 +#define CONFIG_LITELINK_DONGLE_MODULE 1 +#define CONFIG_MA600_DONGLE_MODULE 1 +#define CONFIG_GIRBIL_DONGLE_MODULE 1 +#define CONFIG_MCP2120_DONGLE_MODULE 1 +#define CONFIG_OLD_BELKIN_DONGLE_MODULE 1 +#define CONFIG_ACT200L_DONGLE_MODULE 1 + +/* + * Old SIR device drivers + */ + +/* + * Old Serial dongle support + */ + +/* + * FIR device drivers + */ +#define CONFIG_USB_IRDA_MODULE 1 +#define CONFIG_SIGMATEL_FIR_MODULE 1 +#define CONFIG_NSC_FIR_MODULE 1 +#undef CONFIG_WINBOND_FIR +#undef CONFIG_TOSHIBA_FIR +#undef CONFIG_SMC_IRCC_FIR +#undef CONFIG_ALI_FIR +#undef CONFIG_VLSI_FIR +#undef CONFIG_VIA_FIR +#define CONFIG_BT_MODULE 1 +#define CONFIG_BT_L2CAP_MODULE 1 +#define CONFIG_BT_SCO_MODULE 1 +#define CONFIG_BT_RFCOMM_MODULE 1 +#define CONFIG_BT_RFCOMM_TTY 1 +#define CONFIG_BT_BNEP_MODULE 1 +#define CONFIG_BT_BNEP_MC_FILTER 1 +#define CONFIG_BT_BNEP_PROTO_FILTER 1 +#define CONFIG_BT_CMTP_MODULE 1 + +/* + * Bluetooth device drivers + */ +#define CONFIG_BT_HCIUSB_MODULE 1 +#define CONFIG_BT_HCIUSB_SCO 1 +#define CONFIG_BT_HCIUART_MODULE 1 +#define CONFIG_BT_HCIUART_H4 1 +#define CONFIG_BT_HCIUART_BCSP 1 +#define CONFIG_BT_HCIUART_BCSP_TXCRC 1 +#define CONFIG_BT_HCIBCM203X_MODULE 1 +#define CONFIG_BT_HCIBFUSB_MODULE 1 +#define CONFIG_BT_HCIDTL1_MODULE 1 +#define CONFIG_BT_HCIBT3C_MODULE 1 +#define CONFIG_BT_HCIBLUECARD_MODULE 1 +#define CONFIG_BT_HCIBTUART_MODULE 1 +#define CONFIG_BT_HCIVHCI_MODULE 1 +#define CONFIG_TUX_MODULE 1 + +/* + * TUX options + */ +#define CONFIG_TUX_EXTCGI 1 +#undef CONFIG_TUX_EXTENDED_LOG +#undef CONFIG_TUX_DEBUG +#define CONFIG_NETDEVICES 1 +#define CONFIG_DUMMY_MODULE 1 +#define CONFIG_BONDING_MODULE 1 +#define CONFIG_EQUALIZER_MODULE 1 +#define CONFIG_TUN_MODULE 1 +#define CONFIG_ETHERTAP_MODULE 1 +#define CONFIG_NET_SB1000_MODULE 1 + +/* + * ARCnet devices + */ +#undef CONFIG_ARCNET + +/* + * Ethernet (10 or 100Mbit) + */ +#define CONFIG_NET_ETHERNET 1 +#define CONFIG_MII_MODULE 1 +#define CONFIG_HAPPYMEAL_MODULE 1 +#define CONFIG_SUNGEM_MODULE 1 +#define CONFIG_NET_VENDOR_3COM 1 +#define CONFIG_EL1_MODULE 1 +#define CONFIG_EL2_MODULE 1 +#define CONFIG_ELPLUS_MODULE 1 +#define CONFIG_EL16_MODULE 1 +#define CONFIG_EL3_MODULE 1 +#define CONFIG_3C515_MODULE 1 +#define CONFIG_VORTEX_MODULE 1 +#define CONFIG_TYPHOON_MODULE 1 +#define CONFIG_LANCE_MODULE 1 +#define CONFIG_NET_VENDOR_SMC 1 +#define CONFIG_WD80x3_MODULE 1 +#define CONFIG_ULTRA_MODULE 1 +#define CONFIG_SMC9194_MODULE 1 +#define CONFIG_NET_VENDOR_RACAL 1 +#define CONFIG_NI52_MODULE 1 +#define CONFIG_NI65_MODULE 1 + +/* + * Tulip family network device support + */ +#define CONFIG_NET_TULIP 1 +#define CONFIG_DE2104X_MODULE 1 +#define CONFIG_TULIP_MODULE 1 +#undef CONFIG_TULIP_MWI +#define CONFIG_TULIP_MMIO 1 +#undef CONFIG_TULIP_NAPI +#define CONFIG_DE4X5_MODULE 1 +#define CONFIG_WINBOND_840_MODULE 1 +#define CONFIG_DM9102_MODULE 1 +#define CONFIG_PCMCIA_XIRCOM_MODULE 1 +#undef CONFIG_AT1700 +#define CONFIG_DEPCA_MODULE 1 +#define CONFIG_HP100_MODULE 1 +#undef CONFIG_NET_ISA +#define CONFIG_NE2000_MODULE 1 +#define CONFIG_NET_PCI 1 +#define CONFIG_PCNET32_MODULE 1 +#define CONFIG_AMD8111_ETH_MODULE 1 +#define CONFIG_AMD8111E_NAPI 1 +#define CONFIG_ADAPTEC_STARFIRE_MODULE 1 +#define CONFIG_ADAPTEC_STARFIRE_NAPI 1 +#define CONFIG_AC3200_MODULE 1 +#define CONFIG_APRICOT_MODULE 1 +#define CONFIG_B44_MODULE 1 +#define CONFIG_FORCEDETH_MODULE 1 +#define CONFIG_CS89x0_MODULE 1 +#define CONFIG_DGRS_MODULE 1 +#define CONFIG_EEPRO100_MODULE 1 +#undef CONFIG_EEPRO100_PIO +#define CONFIG_E100_MODULE 1 +#define CONFIG_E100_NAPI 1 +#define CONFIG_FEALNX_MODULE 1 +#define CONFIG_NATSEMI_MODULE 1 +#define CONFIG_NE2K_PCI_MODULE 1 +#define CONFIG_8139CP_MODULE 1 +#define CONFIG_8139TOO_MODULE 1 +#define CONFIG_8139TOO_PIO 1 +#undef CONFIG_8139TOO_TUNE_TWISTER +#define CONFIG_8139TOO_8129 1 +#undef CONFIG_8139_OLD_RX_RESET +#define CONFIG_SIS900_MODULE 1 +#define CONFIG_EPIC100_MODULE 1 +#define CONFIG_SUNDANCE_MODULE 1 +#undef CONFIG_SUNDANCE_MMIO +#define CONFIG_TLAN_MODULE 1 +#define CONFIG_VIA_RHINE_MODULE 1 +#define CONFIG_VIA_RHINE_MMIO 1 +#define CONFIG_NET_POCKET 1 +#define CONFIG_ATP_MODULE 1 +#define CONFIG_DE600_MODULE 1 +#define CONFIG_DE620_MODULE 1 + +/* + * Gigabit Ethernet (1000/10000 Mbit) + */ +#define CONFIG_NET_GIGE 1 +#define CONFIG_ACENIC_MODULE 1 +#undef CONFIG_ACENIC_OMIT_TIGON_I +#define CONFIG_DL2K_MODULE 1 +#define CONFIG_E1000_MODULE 1 +#define CONFIG_E1000_NAPI 1 +#define CONFIG_NS83820_MODULE 1 +#define CONFIG_HAMACHI_MODULE 1 +#define CONFIG_YELLOWFIN_MODULE 1 +#define CONFIG_R8169_MODULE 1 +#define CONFIG_SK98LIN_MODULE 1 +#define CONFIG_TIGON3_MODULE 1 +#define CONFIG_IXGB_MODULE 1 +#define CONFIG_IXGB_NAPI 1 +#define CONFIG_S2IO_MODULE 1 +#define CONFIG_S2IO_NAPI 1 + +/* + * Token Ring devices + */ +#undef CONFIG_TR + +/* + * Wireless LAN (non-hamradio) + */ +#define CONFIG_NET_RADIO 1 + +/* + * Obsolete Wireless cards support (pre-802.11) + */ +#undef CONFIG_STRIP +#undef CONFIG_ARLAN +#define CONFIG_WAVELAN_MODULE 1 +#define CONFIG_PCMCIA_WAVELAN_MODULE 1 +#define CONFIG_PCMCIA_NETWAVE_MODULE 1 + +/* + * Wireless 802.11 Frequency Hopping cards support + */ +#undef CONFIG_PCMCIA_RAYCS + +/* + * Wireless 802.11b ISA/PCI cards support + */ +#define CONFIG_AIRO_MODULE 1 +#define CONFIG_HERMES_MODULE 1 +#define CONFIG_PLX_HERMES_MODULE 1 +#define CONFIG_TMD_HERMES_MODULE 1 +#define CONFIG_PCI_HERMES_MODULE 1 +#define CONFIG_ATMEL_MODULE 1 +#define CONFIG_PCI_ATMEL_MODULE 1 + +/* + * Wireless 802.11b Pcmcia/Cardbus cards support + */ +#define CONFIG_PCMCIA_HERMES_MODULE 1 +#define CONFIG_AIRO_CS_MODULE 1 +#define CONFIG_PCMCIA_ATMEL_MODULE 1 +#define CONFIG_PCMCIA_WL3501_MODULE 1 + +/* + * Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support + */ +#define CONFIG_PRISM54_MODULE 1 +#define CONFIG_NET_WIRELESS 1 + +/* + * PCMCIA network device support + */ +#define CONFIG_NET_PCMCIA 1 +#define CONFIG_PCMCIA_3C589_MODULE 1 +#define CONFIG_PCMCIA_3C574_MODULE 1 +#define CONFIG_PCMCIA_FMVJ18X_MODULE 1 +#define CONFIG_PCMCIA_PCNET_MODULE 1 +#define CONFIG_PCMCIA_NMCLAN_MODULE 1 +#define CONFIG_PCMCIA_SMC91C92_MODULE 1 +#define CONFIG_PCMCIA_XIRC2PS_MODULE 1 +#define CONFIG_PCMCIA_AXNET_MODULE 1 + +/* + * Wan interfaces + */ +#undef CONFIG_WAN +#define CONFIG_FDDI 1 +#undef CONFIG_DEFXX +#define CONFIG_SKFP_MODULE 1 +#undef CONFIG_HIPPI +#define CONFIG_PLIP_MODULE 1 +#define CONFIG_PPP_MODULE 1 +#define CONFIG_PPP_MULTILINK 1 +#define CONFIG_PPP_FILTER 1 +#define CONFIG_PPP_ASYNC_MODULE 1 +#define CONFIG_PPP_SYNC_TTY_MODULE 1 +#define CONFIG_PPP_DEFLATE_MODULE 1 +#undef CONFIG_PPP_BSDCOMP +#define CONFIG_PPPOE_MODULE 1 +#undef CONFIG_SLIP +#define CONFIG_NET_FC 1 +#undef CONFIG_SHAPER +#define CONFIG_NETCONSOLE_MODULE 1 + +/* + * ISDN subsystem + */ +#define CONFIG_ISDN_MODULE 1 + +/* + * Old ISDN4Linux + */ +#define CONFIG_ISDN_I4L_MODULE 1 +#define CONFIG_ISDN_PPP 1 +#define CONFIG_ISDN_PPP_VJ 1 +#define CONFIG_ISDN_MPP 1 +#define CONFIG_IPPP_FILTER 1 +#undef CONFIG_ISDN_PPP_BSDCOMP +#define CONFIG_ISDN_AUDIO 1 +#define CONFIG_ISDN_TTY_FAX 1 + +/* + * ISDN feature submodules + */ + +/* + * ISDN4Linux hardware drivers + */ + +/* + * Passive cards + */ +#define CONFIG_ISDN_DRV_HISAX_MODULE 1 + +/* + * D-channel protocol features + */ +#define CONFIG_HISAX_EURO 1 +#define CONFIG_DE_AOC 1 +#define CONFIG_HISAX_NO_SENDCOMPLETE 1 +#define CONFIG_HISAX_NO_LLC 1 +#define CONFIG_HISAX_NO_KEYPAD 1 +#define CONFIG_HISAX_1TR6 1 +#define CONFIG_HISAX_NI1 1 +#define CONFIG_HISAX_MAX_CARDS 8 + +/* + * HiSax supported cards + */ +#define CONFIG_HISAX_16_0 1 +#define CONFIG_HISAX_16_3 1 +#define CONFIG_HISAX_TELESPCI 1 +#define CONFIG_HISAX_S0BOX 1 +#define CONFIG_HISAX_AVM_A1 1 +#define CONFIG_HISAX_FRITZPCI 1 +#define CONFIG_HISAX_AVM_A1_PCMCIA 1 +#define CONFIG_HISAX_ELSA 1 +#define CONFIG_HISAX_IX1MICROR2 1 +#define CONFIG_HISAX_DIEHLDIVA 1 +#define CONFIG_HISAX_ASUSCOM 1 +#define CONFIG_HISAX_TELEINT 1 +#define CONFIG_HISAX_HFCS 1 +#define CONFIG_HISAX_SEDLBAUER 1 +#define CONFIG_HISAX_SPORTSTER 1 +#define CONFIG_HISAX_MIC 1 +#define CONFIG_HISAX_NETJET 1 +#define CONFIG_HISAX_NETJET_U 1 +#define CONFIG_HISAX_NICCY 1 +#define CONFIG_HISAX_ISURF 1 +#define CONFIG_HISAX_HSTSAPHIR 1 +#define CONFIG_HISAX_BKM_A4T 1 +#define CONFIG_HISAX_SCT_QUADRO 1 +#define CONFIG_HISAX_GAZEL 1 +#define CONFIG_HISAX_HFC_PCI 1 +#define CONFIG_HISAX_W6692 1 +#define CONFIG_HISAX_HFC_SX 1 +#define CONFIG_HISAX_ENTERNOW_PCI 1 +#undef CONFIG_HISAX_DEBUG + +/* + * HiSax PCMCIA card service modules + */ +#define CONFIG_HISAX_SEDLBAUER_CS_MODULE 1 +#define CONFIG_HISAX_ELSA_CS_MODULE 1 +#define CONFIG_HISAX_AVM_A1_CS_MODULE 1 +#define CONFIG_HISAX_TELES_CS_MODULE 1 + +/* + * HiSax sub driver modules + */ +#define CONFIG_HISAX_ST5481_MODULE 1 +#define CONFIG_HISAX_HFCUSB_MODULE 1 +#define CONFIG_HISAX_FRITZ_PCIPNP_MODULE 1 +#define CONFIG_HISAX_HDLC 1 + +/* + * Active cards + */ +#define CONFIG_ISDN_DRV_ICN_MODULE 1 +#define CONFIG_ISDN_DRV_PCBIT_MODULE 1 +#define CONFIG_ISDN_DRV_SC_MODULE 1 +#define CONFIG_ISDN_DRV_ACT2000_MODULE 1 +#define CONFIG_ISDN_DRV_TPAM_MODULE 1 + +/* + * CAPI subsystem + */ +#define CONFIG_ISDN_CAPI_MODULE 1 +#define CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON 1 +#define CONFIG_ISDN_CAPI_MIDDLEWARE 1 +#define CONFIG_ISDN_CAPI_CAPI20_MODULE 1 +#define CONFIG_ISDN_CAPI_CAPIFS_BOOL 1 +#define CONFIG_ISDN_CAPI_CAPIFS_MODULE 1 +#define CONFIG_ISDN_CAPI_CAPIDRV_MODULE 1 + +/* + * CAPI hardware drivers + */ + +/* + * Active AVM cards + */ +#define CONFIG_CAPI_AVM 1 + +/* + * Active Eicon DIVA Server cards + */ +#define CONFIG_CAPI_EICON 1 +#define CONFIG_ISDN_DIVAS_MODULE 1 +#define CONFIG_ISDN_DIVAS_BRIPCI 1 +#define CONFIG_ISDN_DIVAS_PRIPCI 1 +#define CONFIG_ISDN_DIVAS_DIVACAPI_MODULE 1 +#define CONFIG_ISDN_DIVAS_USERIDI_MODULE 1 +#define CONFIG_ISDN_DIVAS_MAINT_MODULE 1 + +/* + * Telephony Support + */ +#undef CONFIG_PHONE + +/* + * Input device support + */ +#define CONFIG_INPUT 1 + +/* + * Userland interfaces + */ +#define CONFIG_INPUT_MOUSEDEV 1 +#undef CONFIG_INPUT_MOUSEDEV_PSAUX +#define CONFIG_INPUT_MOUSEDEV_SCREEN_X 1024 +#define CONFIG_INPUT_MOUSEDEV_SCREEN_Y 768 +#define CONFIG_INPUT_JOYDEV_MODULE 1 +#undef CONFIG_INPUT_TSDEV +#define CONFIG_INPUT_EVDEV 1 +#undef CONFIG_INPUT_EVBUG + +/* + * Input I/O drivers + */ +#define CONFIG_GAMEPORT_MODULE 1 +#define CONFIG_SOUND_GAMEPORT_MODULE 1 +#define CONFIG_GAMEPORT_NS558_MODULE 1 +#define CONFIG_GAMEPORT_L4_MODULE 1 +#define CONFIG_GAMEPORT_EMU10K1_MODULE 1 +#define CONFIG_GAMEPORT_VORTEX_MODULE 1 +#define CONFIG_GAMEPORT_FM801_MODULE 1 +#define CONFIG_GAMEPORT_CS461x_MODULE 1 +#define CONFIG_SERIO 1 +#define CONFIG_SERIO_I8042 1 +#define CONFIG_SERIO_SERPORT 1 +#undef CONFIG_SERIO_CT82C710 +#undef CONFIG_SERIO_PARKBD +#undef CONFIG_SERIO_PCIPS2 + +/* + * Input Device Drivers + */ +#define CONFIG_INPUT_KEYBOARD 1 +#define CONFIG_KEYBOARD_ATKBD 1 +#undef CONFIG_KEYBOARD_SUNKBD +#undef CONFIG_KEYBOARD_LKKBD +#undef CONFIG_KEYBOARD_XTKBD +#undef CONFIG_KEYBOARD_NEWTON +#define CONFIG_INPUT_MOUSE 1 +#define CONFIG_MOUSE_PS2 1 +#define CONFIG_MOUSE_SERIAL_MODULE 1 +#define CONFIG_MOUSE_INPORT_MODULE 1 +#define CONFIG_MOUSE_ATIXL 1 +#define CONFIG_MOUSE_LOGIBM_MODULE 1 +#define CONFIG_MOUSE_PC110PAD_MODULE 1 +#define CONFIG_MOUSE_VSXXXAA_MODULE 1 +#define CONFIG_INPUT_JOYSTICK 1 +#define CONFIG_JOYSTICK_ANALOG_MODULE 1 +#define CONFIG_JOYSTICK_A3D_MODULE 1 +#define CONFIG_JOYSTICK_ADI_MODULE 1 +#define CONFIG_JOYSTICK_COBRA_MODULE 1 +#define CONFIG_JOYSTICK_GF2K_MODULE 1 +#define CONFIG_JOYSTICK_GRIP_MODULE 1 +#define CONFIG_JOYSTICK_GRIP_MP_MODULE 1 +#define CONFIG_JOYSTICK_GUILLEMOT_MODULE 1 +#define CONFIG_JOYSTICK_INTERACT_MODULE 1 +#define CONFIG_JOYSTICK_SIDEWINDER_MODULE 1 +#define CONFIG_JOYSTICK_TMDC_MODULE 1 +#define CONFIG_JOYSTICK_IFORCE_MODULE 1 +#define CONFIG_JOYSTICK_IFORCE_USB 1 +#define CONFIG_JOYSTICK_IFORCE_232 1 +#define CONFIG_JOYSTICK_WARRIOR_MODULE 1 +#define CONFIG_JOYSTICK_MAGELLAN_MODULE 1 +#define CONFIG_JOYSTICK_SPACEORB_MODULE 1 +#define CONFIG_JOYSTICK_SPACEBALL_MODULE 1 +#define CONFIG_JOYSTICK_STINGER_MODULE 1 +#define CONFIG_JOYSTICK_TWIDDLER_MODULE 1 +#define CONFIG_JOYSTICK_DB9_MODULE 1 +#define CONFIG_JOYSTICK_GAMECON_MODULE 1 +#define CONFIG_JOYSTICK_TURBOGRAFX_MODULE 1 +#undef CONFIG_INPUT_JOYDUMP +#define CONFIG_INPUT_TOUCHSCREEN 1 +#define CONFIG_TOUCHSCREEN_GUNZE_MODULE 1 +#define CONFIG_INPUT_MISC 1 +#define CONFIG_INPUT_PCSPKR_MODULE 1 +#undef CONFIG_INPUT_UINPUT + +/* + * Character devices + */ +#define CONFIG_VT 1 +#define CONFIG_VT_CONSOLE 1 +#define CONFIG_HW_CONSOLE 1 +#define CONFIG_SERIAL_NONSTANDARD 1 +#define CONFIG_ROCKETPORT_MODULE 1 +#undef CONFIG_CYCLADES +#define CONFIG_SYNCLINK_MODULE 1 +#define CONFIG_SYNCLINKMP_MODULE 1 +#define CONFIG_N_HDLC_MODULE 1 +#define CONFIG_STALDRV 1 + +/* + * Serial drivers + */ +#define CONFIG_SERIAL_8250 1 +#define CONFIG_SERIAL_8250_CONSOLE 1 +#define CONFIG_SERIAL_8250_CS_MODULE 1 +#undef CONFIG_SERIAL_8250_ACPI +#define CONFIG_SERIAL_8250_NR_UARTS 4 +#define CONFIG_SERIAL_8250_EXTENDED 1 +#undef CONFIG_SERIAL_8250_MANY_PORTS +#define CONFIG_SERIAL_8250_SHARE_IRQ 1 +#define CONFIG_SERIAL_8250_DETECT_IRQ 1 +#define CONFIG_SERIAL_8250_MULTIPORT 1 +#define CONFIG_SERIAL_8250_RSA 1 + +/* + * Non-8250 serial port support + */ +#define CONFIG_SERIAL_CORE 1 +#define CONFIG_SERIAL_CORE_CONSOLE 1 +#define CONFIG_UNIX98_PTYS 1 +#undef CONFIG_LEGACY_PTYS +#define CONFIG_CRASH_MODULE 1 +#define CONFIG_PRINTER_MODULE 1 +#define CONFIG_LP_CONSOLE 1 +#define CONFIG_PPDEV_MODULE 1 +#define CONFIG_TIPAR_MODULE 1 +#undef CONFIG_QIC02_TAPE + +/* + * IPMI + */ +#define CONFIG_IPMI_HANDLER_MODULE 1 +#undef CONFIG_IPMI_PANIC_EVENT +#define CONFIG_IPMI_DEVICE_INTERFACE_MODULE 1 +#define CONFIG_IPMI_SI_MODULE 1 +#define CONFIG_IPMI_WATCHDOG_MODULE 1 + +/* + * Watchdog Cards + */ +#define CONFIG_WATCHDOG 1 +#undef CONFIG_WATCHDOG_NOWAYOUT + +/* + * Watchdog Device Drivers + */ +#define CONFIG_SOFT_WATCHDOG_MODULE 1 +#define CONFIG_ACQUIRE_WDT_MODULE 1 +#define CONFIG_ADVANTECH_WDT_MODULE 1 +#define CONFIG_ALIM1535_WDT_MODULE 1 +#define CONFIG_ALIM7101_WDT_MODULE 1 +#define CONFIG_SC520_WDT_MODULE 1 +#define CONFIG_EUROTECH_WDT_MODULE 1 +#define CONFIG_IB700_WDT_MODULE 1 +#define CONFIG_WAFER_WDT_MODULE 1 +#define CONFIG_I8XX_TCO_MODULE 1 +#define CONFIG_SC1200_WDT_MODULE 1 +#undef CONFIG_SCx200_WDT +#undef CONFIG_60XX_WDT +#define CONFIG_CPU5_WDT_MODULE 1 +#define CONFIG_W83627HF_WDT_MODULE 1 +#define CONFIG_W83877F_WDT_MODULE 1 +#define CONFIG_MACHZ_WDT_MODULE 1 + +/* + * ISA-based Watchdog Cards + */ +#define CONFIG_PCWATCHDOG_MODULE 1 +#undef CONFIG_MIXCOMWD +#define CONFIG_WDT_MODULE 1 +#undef CONFIG_WDT_501 + +/* + * PCI-based Watchdog Cards + */ +#define CONFIG_PCIPCWATCHDOG_MODULE 1 +#define CONFIG_WDTPCI_MODULE 1 +#define CONFIG_WDT_501_PCI 1 + +/* + * USB-based Watchdog Cards + */ +#define CONFIG_USBPCWATCHDOG_MODULE 1 +#define CONFIG_HW_RANDOM_MODULE 1 +#define CONFIG_NVRAM_MODULE 1 +#define CONFIG_RTC 1 +#define CONFIG_DTLK_MODULE 1 +#define CONFIG_R3964_MODULE 1 +#undef CONFIG_APPLICOM +#define CONFIG_SONYPI_MODULE 1 + +/* + * Ftape, the floppy tape device driver + */ +#define CONFIG_AGP 1 +#define CONFIG_AGP_ALI 1 +#define CONFIG_AGP_ATI 1 +#define CONFIG_AGP_AMD 1 +#define CONFIG_AGP_AMD64 1 +#define CONFIG_AGP_INTEL 1 +#define CONFIG_AGP_INTEL_MCH 1 +#define CONFIG_AGP_NVIDIA 1 +#define CONFIG_AGP_SIS 1 +#define CONFIG_AGP_SWORKS 1 +#define CONFIG_AGP_VIA 1 +#define CONFIG_AGP_EFFICEON 1 +#define CONFIG_DRM 1 +#define CONFIG_DRM_TDFX_MODULE 1 +#define CONFIG_DRM_GAMMA_MODULE 1 +#define CONFIG_DRM_R128_MODULE 1 +#define CONFIG_DRM_RADEON_MODULE 1 +#define CONFIG_DRM_I810_MODULE 1 +#define CONFIG_DRM_I830_MODULE 1 +#define CONFIG_DRM_MGA_MODULE 1 +#define CONFIG_DRM_SIS_MODULE 1 + +/* + * PCMCIA character devices + */ +#define CONFIG_SYNCLINK_CS_MODULE 1 +#define CONFIG_MWAVE_MODULE 1 +#undef CONFIG_RAW_DRIVER +#define CONFIG_HANGCHECK_TIMER_MODULE 1 + +/* + * I2C support + */ +#define CONFIG_I2C_MODULE 1 +#define CONFIG_I2C_CHARDEV_MODULE 1 + +/* + * I2C Algorithms + */ +#define CONFIG_I2C_ALGOBIT_MODULE 1 +#define CONFIG_I2C_ALGOPCF_MODULE 1 + +/* + * I2C Hardware Bus support + */ +#define CONFIG_I2C_ALI1535_MODULE 1 +#define CONFIG_I2C_ALI1563_MODULE 1 +#define CONFIG_I2C_ALI15X3_MODULE 1 +#define CONFIG_I2C_AMD756_MODULE 1 +#define CONFIG_I2C_AMD8111_MODULE 1 +#define CONFIG_I2C_I801_MODULE 1 +#define CONFIG_I2C_I810_MODULE 1 +#define CONFIG_I2C_ISA_MODULE 1 +#define CONFIG_I2C_NFORCE2_MODULE 1 +#undef CONFIG_I2C_PARPORT +#undef CONFIG_I2C_PARPORT_LIGHT +#define CONFIG_I2C_PIIX4_MODULE 1 +#define CONFIG_I2C_PROSAVAGE_MODULE 1 +#define CONFIG_I2C_SAVAGE4_MODULE 1 +#undef CONFIG_SCx200_ACB +#define CONFIG_I2C_SIS5595_MODULE 1 +#define CONFIG_I2C_SIS630_MODULE 1 +#define CONFIG_I2C_SIS96X_MODULE 1 +#define CONFIG_I2C_VIA_MODULE 1 +#define CONFIG_I2C_VIAPRO_MODULE 1 +#define CONFIG_I2C_VOODOO3_MODULE 1 + +/* + * Hardware Sensors Chip support + */ +#define CONFIG_I2C_SENSOR_MODULE 1 +#define CONFIG_SENSORS_ADM1021_MODULE 1 +#define CONFIG_SENSORS_ASB100_MODULE 1 +#define CONFIG_SENSORS_DS1621_MODULE 1 +#define CONFIG_SENSORS_FSCHER_MODULE 1 +#define CONFIG_SENSORS_GL518SM_MODULE 1 +#define CONFIG_SENSORS_IT87_MODULE 1 +#define CONFIG_SENSORS_LM75_MODULE 1 +#define CONFIG_SENSORS_LM78_MODULE 1 +#define CONFIG_SENSORS_LM80_MODULE 1 +#define CONFIG_SENSORS_LM83_MODULE 1 +#define CONFIG_SENSORS_LM85_MODULE 1 +#define CONFIG_SENSORS_LM90_MODULE 1 +#define CONFIG_SENSORS_MAX1619_MODULE 1 +#define CONFIG_SENSORS_VIA686A_MODULE 1 +#define CONFIG_SENSORS_W83781D_MODULE 1 +#define CONFIG_SENSORS_W83L785TS_MODULE 1 +#define CONFIG_SENSORS_W83627HF_MODULE 1 + +/* + * Other I2C Chip support + */ +#define CONFIG_SENSORS_EEPROM_MODULE 1 +#define CONFIG_SENSORS_PCF8574_MODULE 1 +#define CONFIG_SENSORS_PCF8591_MODULE 1 +#define CONFIG_SENSORS_RTC8564_MODULE 1 +#undef CONFIG_I2C_DEBUG_CORE +#undef CONFIG_I2C_DEBUG_ALGO +#undef CONFIG_I2C_DEBUG_BUS +#undef CONFIG_I2C_DEBUG_CHIP + +/* + * Misc devices + */ +#define CONFIG_IBM_ASM_MODULE 1 + +/* + * Multimedia devices + */ +#define CONFIG_VIDEO_DEV_MODULE 1 + +/* + * Video For Linux + */ + +/* + * Video Adapters + */ +#define CONFIG_VIDEO_BT848_MODULE 1 +#define CONFIG_VIDEO_PMS_MODULE 1 +#define CONFIG_VIDEO_BWQCAM_MODULE 1 +#define CONFIG_VIDEO_CQCAM_MODULE 1 +#define CONFIG_VIDEO_W9966_MODULE 1 +#define CONFIG_VIDEO_CPIA_MODULE 1 +#define CONFIG_VIDEO_CPIA_PP_MODULE 1 +#define CONFIG_VIDEO_CPIA_USB_MODULE 1 +#define CONFIG_VIDEO_SAA5246A_MODULE 1 +#define CONFIG_VIDEO_SAA5249_MODULE 1 +#define CONFIG_TUNER_3036_MODULE 1 +#define CONFIG_VIDEO_STRADIS_MODULE 1 +#define CONFIG_VIDEO_ZORAN_MODULE 1 +#define CONFIG_VIDEO_ZORAN_BUZ_MODULE 1 +#define CONFIG_VIDEO_ZORAN_DC10_MODULE 1 +#define CONFIG_VIDEO_ZORAN_DC30_MODULE 1 +#define CONFIG_VIDEO_ZORAN_LML33_MODULE 1 +#define CONFIG_VIDEO_ZORAN_LML33R10_MODULE 1 +#define CONFIG_VIDEO_SAA7134_MODULE 1 +#define CONFIG_VIDEO_MXB_MODULE 1 +#define CONFIG_VIDEO_DPC_MODULE 1 +#define CONFIG_VIDEO_HEXIUM_ORION_MODULE 1 +#define CONFIG_VIDEO_HEXIUM_GEMINI_MODULE 1 +#define CONFIG_VIDEO_CX88_MODULE 1 + +/* + * Radio Adapters + */ +#define CONFIG_RADIO_CADET_MODULE 1 +#define CONFIG_RADIO_RTRACK_MODULE 1 +#define CONFIG_RADIO_RTRACK2_MODULE 1 +#define CONFIG_RADIO_AZTECH_MODULE 1 +#define CONFIG_RADIO_GEMTEK_MODULE 1 +#define CONFIG_RADIO_GEMTEK_PCI_MODULE 1 +#define CONFIG_RADIO_MAXIRADIO_MODULE 1 +#define CONFIG_RADIO_MAESTRO_MODULE 1 +#define CONFIG_RADIO_SF16FMI_MODULE 1 +#define CONFIG_RADIO_SF16FMR2_MODULE 1 +#define CONFIG_RADIO_TERRATEC_MODULE 1 +#define CONFIG_RADIO_TRUST_MODULE 1 +#define CONFIG_RADIO_TYPHOON_MODULE 1 +#define CONFIG_RADIO_TYPHOON_PROC_FS 1 +#define CONFIG_RADIO_ZOLTRIX_MODULE 1 + +/* + * Digital Video Broadcasting Devices + */ +#undef CONFIG_DVB +#define CONFIG_VIDEO_SAA7146_MODULE 1 +#define CONFIG_VIDEO_SAA7146_VV_MODULE 1 +#define CONFIG_VIDEO_VIDEOBUF_MODULE 1 +#define CONFIG_VIDEO_TUNER_MODULE 1 +#define CONFIG_VIDEO_BUF_MODULE 1 +#define CONFIG_VIDEO_BTCX_MODULE 1 +#define CONFIG_VIDEO_IR_MODULE 1 + +/* + * Graphics support + */ +#define CONFIG_FB 1 +#undef CONFIG_FB_PM2 +#undef CONFIG_FB_CYBER2000 +#undef CONFIG_FB_ASILIANT +#undef CONFIG_FB_IMSTT +#define CONFIG_FB_VGA16_MODULE 1 +#define CONFIG_FB_VESA 1 +#define CONFIG_VIDEO_SELECT 1 +#define CONFIG_FB_HGA_MODULE 1 +#define CONFIG_FB_HGA_ACCEL 1 +#define CONFIG_FB_RIVA_MODULE 1 +#define CONFIG_FB_I810_MODULE 1 +#define CONFIG_FB_I810_GTF 1 +#define CONFIG_FB_MATROX_MODULE 1 +#define CONFIG_FB_MATROX_MILLENIUM 1 +#define CONFIG_FB_MATROX_MYSTIQUE 1 +#define CONFIG_FB_MATROX_G450 1 +#define CONFIG_FB_MATROX_G100 1 +#define CONFIG_FB_MATROX_I2C_MODULE 1 +#define CONFIG_FB_MATROX_MAVEN_MODULE 1 +#define CONFIG_FB_MATROX_MULTIHEAD 1 +#undef CONFIG_FB_RADEON_OLD +#define CONFIG_FB_RADEON_MODULE 1 +#define CONFIG_FB_RADEON_I2C 1 +#undef CONFIG_FB_RADEON_DEBUG +#define CONFIG_FB_ATY128_MODULE 1 +#define CONFIG_FB_ATY_MODULE 1 +#define CONFIG_FB_ATY_CT 1 +#define CONFIG_FB_ATY_GX 1 +#undef CONFIG_FB_ATY_XL_INIT +#undef CONFIG_FB_SIS +#define CONFIG_FB_NEOMAGIC_MODULE 1 +#define CONFIG_FB_KYRO_MODULE 1 +#define CONFIG_FB_3DFX_MODULE 1 +#define CONFIG_FB_3DFX_ACCEL 1 +#define CONFIG_FB_VOODOO1_MODULE 1 +#define CONFIG_FB_TRIDENT_MODULE 1 +#define CONFIG_FB_TRIDENT_ACCEL 1 +#undef CONFIG_FB_VIRTUAL + +/* + * Console display driver support + */ +#define CONFIG_VGA_CONSOLE 1 +#define CONFIG_MDA_CONSOLE_MODULE 1 +#define CONFIG_DUMMY_CONSOLE 1 +#define CONFIG_FRAMEBUFFER_CONSOLE 1 +#define CONFIG_PCI_CONSOLE 1 +#undef CONFIG_FONTS +#define CONFIG_FONT_8x8 1 +#define CONFIG_FONT_8x16 1 + +/* + * Logo configuration + */ +#define CONFIG_LOGO 1 +#undef CONFIG_LOGO_LINUX_MONO +#undef CONFIG_LOGO_LINUX_VGA16 +#define CONFIG_LOGO_LINUX_CLUT224 1 + +/* + * Sound + */ +#define CONFIG_SOUND_MODULE 1 + +/* + * Advanced Linux Sound Architecture + */ +#define CONFIG_SND_MODULE 1 +#define CONFIG_SND_TIMER_MODULE 1 +#define CONFIG_SND_PCM_MODULE 1 +#define CONFIG_SND_HWDEP_MODULE 1 +#define CONFIG_SND_RAWMIDI_MODULE 1 +#define CONFIG_SND_SEQUENCER_MODULE 1 +#define CONFIG_SND_SEQ_DUMMY_MODULE 1 +#define CONFIG_SND_OSSEMUL 1 +#define CONFIG_SND_MIXER_OSS_MODULE 1 +#define CONFIG_SND_PCM_OSS_MODULE 1 +#define CONFIG_SND_SEQUENCER_OSS 1 +#define CONFIG_SND_RTCTIMER_MODULE 1 +#undef CONFIG_SND_VERBOSE_PRINTK +#undef CONFIG_SND_DEBUG + +/* + * Generic devices + */ +#define CONFIG_SND_MPU401_UART_MODULE 1 +#define CONFIG_SND_OPL3_LIB_MODULE 1 +#define CONFIG_SND_OPL4_LIB_MODULE 1 +#define CONFIG_SND_VX_LIB_MODULE 1 +#define CONFIG_SND_DUMMY_MODULE 1 +#define CONFIG_SND_VIRMIDI_MODULE 1 +#define CONFIG_SND_MTPAV_MODULE 1 +#undef CONFIG_SND_SERIAL_U16550 +#define CONFIG_SND_MPU401_MODULE 1 + +/* + * ISA devices + */ +#define CONFIG_SND_AD1816A_MODULE 1 +#define CONFIG_SND_AD1848_MODULE 1 +#define CONFIG_SND_CS4231_MODULE 1 +#define CONFIG_SND_CS4232_MODULE 1 +#define CONFIG_SND_CS4236_MODULE 1 +#define CONFIG_SND_ES968_MODULE 1 +#define CONFIG_SND_ES1688_MODULE 1 +#define CONFIG_SND_ES18XX_MODULE 1 +#define CONFIG_SND_GUSCLASSIC_MODULE 1 +#define CONFIG_SND_GUSEXTREME_MODULE 1 +#define CONFIG_SND_GUSMAX_MODULE 1 +#define CONFIG_SND_INTERWAVE_MODULE 1 +#define CONFIG_SND_INTERWAVE_STB_MODULE 1 +#define CONFIG_SND_OPTI92X_AD1848_MODULE 1 +#define CONFIG_SND_OPTI92X_CS4231_MODULE 1 +#define CONFIG_SND_OPTI93X_MODULE 1 +#define CONFIG_SND_SB8_MODULE 1 +#define CONFIG_SND_SB16_MODULE 1 +#define CONFIG_SND_SBAWE_MODULE 1 +#define CONFIG_SND_SB16_CSP 1 +#undef CONFIG_SND_WAVEFRONT +#define CONFIG_SND_ALS100_MODULE 1 +#define CONFIG_SND_AZT2320_MODULE 1 +#define CONFIG_SND_CMI8330_MODULE 1 +#define CONFIG_SND_DT019X_MODULE 1 +#define CONFIG_SND_OPL3SA2_MODULE 1 +#define CONFIG_SND_SGALAXY_MODULE 1 +#define CONFIG_SND_SSCAPE_MODULE 1 + +/* + * PCI devices + */ +#define CONFIG_SND_AC97_CODEC_MODULE 1 +#define CONFIG_SND_ALI5451_MODULE 1 +#define CONFIG_SND_ATIIXP_MODULE 1 +#define CONFIG_SND_AU8810_MODULE 1 +#define CONFIG_SND_AU8820_MODULE 1 +#define CONFIG_SND_AU8830_MODULE 1 +#define CONFIG_SND_AZT3328_MODULE 1 +#define CONFIG_SND_BT87X_MODULE 1 +#define CONFIG_SND_CS46XX_MODULE 1 +#define CONFIG_SND_CS46XX_NEW_DSP 1 +#define CONFIG_SND_CS4281_MODULE 1 +#define CONFIG_SND_EMU10K1_MODULE 1 +#define CONFIG_SND_KORG1212_MODULE 1 +#define CONFIG_SND_MIXART_MODULE 1 +#define CONFIG_SND_NM256_MODULE 1 +#define CONFIG_SND_RME32_MODULE 1 +#define CONFIG_SND_RME96_MODULE 1 +#define CONFIG_SND_RME9652_MODULE 1 +#define CONFIG_SND_HDSP_MODULE 1 +#define CONFIG_SND_TRIDENT_MODULE 1 +#define CONFIG_SND_YMFPCI_MODULE 1 +#define CONFIG_SND_ALS4000_MODULE 1 +#define CONFIG_SND_CMIPCI_MODULE 1 +#define CONFIG_SND_ENS1370_MODULE 1 +#define CONFIG_SND_ENS1371_MODULE 1 +#define CONFIG_SND_ES1938_MODULE 1 +#define CONFIG_SND_ES1968_MODULE 1 +#define CONFIG_SND_MAESTRO3_MODULE 1 +#define CONFIG_SND_FM801_MODULE 1 +#define CONFIG_SND_FM801_TEA575X_MODULE 1 +#define CONFIG_SND_ICE1712_MODULE 1 +#define CONFIG_SND_ICE1724_MODULE 1 +#define CONFIG_SND_INTEL8X0_MODULE 1 +#define CONFIG_SND_INTEL8X0M_MODULE 1 +#define CONFIG_SND_SONICVIBES_MODULE 1 +#define CONFIG_SND_VIA82XX_MODULE 1 +#define CONFIG_SND_VX222_MODULE 1 + +/* + * ALSA USB devices + */ +#define CONFIG_SND_USB_AUDIO_MODULE 1 + +/* + * PCMCIA devices + */ +#undef CONFIG_SND_VXPOCKET +#undef CONFIG_SND_VXP440 +#define CONFIG_SND_PDAUDIOCF_MODULE 1 + +/* + * Open Sound System + */ +#undef CONFIG_SOUND_PRIME + +/* + * USB support + */ +#define CONFIG_USB 1 +#undef CONFIG_USB_DEBUG + +/* + * Miscellaneous USB options + */ +#define CONFIG_USB_DEVICEFS 1 +#undef CONFIG_USB_BANDWIDTH +#undef CONFIG_USB_DYNAMIC_MINORS + +/* + * USB Host Controller Drivers + */ +#define CONFIG_USB_EHCI_HCD_MODULE 1 +#define CONFIG_USB_EHCI_SPLIT_ISO 1 +#define CONFIG_USB_EHCI_ROOT_HUB_TT 1 +#define CONFIG_USB_OHCI_HCD_MODULE 1 +#define CONFIG_USB_UHCI_HCD_MODULE 1 + +/* + * USB Device Class drivers + */ +#define CONFIG_USB_AUDIO_MODULE 1 + +/* + * USB Bluetooth TTY can only be used with disabled Bluetooth subsystem + */ +#define CONFIG_USB_MIDI_MODULE 1 +#define CONFIG_USB_ACM_MODULE 1 +#define CONFIG_USB_PRINTER_MODULE 1 +#define CONFIG_USB_STORAGE_MODULE 1 +#undef CONFIG_USB_STORAGE_DEBUG +#define CONFIG_USB_STORAGE_DATAFAB 1 +#define CONFIG_USB_STORAGE_FREECOM 1 +#define CONFIG_USB_STORAGE_ISD200 1 +#define CONFIG_USB_STORAGE_DPCM 1 +#define CONFIG_USB_STORAGE_HP8200e 1 +#define CONFIG_USB_STORAGE_SDDR09 1 +#define CONFIG_USB_STORAGE_SDDR55 1 +#define CONFIG_USB_STORAGE_JUMPSHOT 1 + +/* + * USB Human Interface Devices (HID) + */ +#define CONFIG_USB_HID 1 +#define CONFIG_USB_HIDINPUT 1 +#define CONFIG_HID_FF 1 +#define CONFIG_HID_PID 1 +#define CONFIG_LOGITECH_FF 1 +#define CONFIG_THRUSTMASTER_FF 1 +#define CONFIG_USB_HIDDEV 1 +#define CONFIG_USB_AIPTEK_MODULE 1 +#define CONFIG_USB_WACOM_MODULE 1 +#define CONFIG_USB_KBTAB_MODULE 1 +#define CONFIG_USB_POWERMATE_MODULE 1 +#define CONFIG_USB_MTOUCH_MODULE 1 +#define CONFIG_USB_EGALAX_MODULE 1 +#define CONFIG_USB_XPAD_MODULE 1 +#define CONFIG_USB_ATI_REMOTE_MODULE 1 + +/* + * USB Imaging devices + */ +#define CONFIG_USB_MDC800_MODULE 1 +#define CONFIG_USB_MICROTEK_MODULE 1 +#define CONFIG_USB_HPUSBSCSI_MODULE 1 + +/* + * USB Multimedia devices + */ +#define CONFIG_USB_DABUSB_MODULE 1 +#define CONFIG_USB_VICAM_MODULE 1 +#define CONFIG_USB_DSBR_MODULE 1 +#define CONFIG_USB_IBMCAM_MODULE 1 +#define CONFIG_USB_KONICAWC_MODULE 1 +#define CONFIG_USB_OV511_MODULE 1 +#define CONFIG_USB_SE401_MODULE 1 +#define CONFIG_USB_STV680_MODULE 1 +#define CONFIG_USB_W9968CF_MODULE 1 + +/* + * USB Network adaptors + */ +#define CONFIG_USB_CATC_MODULE 1 +#define CONFIG_USB_KAWETH_MODULE 1 +#define CONFIG_USB_PEGASUS_MODULE 1 +#define CONFIG_USB_RTL8150_MODULE 1 +#define CONFIG_USB_USBNET_MODULE 1 + +/* + * USB Host-to-Host Cables + */ +#define CONFIG_USB_ALI_M5632 1 +#define CONFIG_USB_AN2720 1 +#define CONFIG_USB_BELKIN 1 +#define CONFIG_USB_GENESYS 1 +#define CONFIG_USB_NET1080 1 +#define CONFIG_USB_PL2301 1 + +/* + * Intelligent USB Devices/Gadgets + */ +#define CONFIG_USB_ARMLINUX 1 +#define CONFIG_USB_EPSON2888 1 +#define CONFIG_USB_ZAURUS 1 +#define CONFIG_USB_CDCETHER 1 + +/* + * USB Network Adapters + */ +#define CONFIG_USB_AX8817X 1 + +/* + * USB port drivers + */ +#define CONFIG_USB_USS720_MODULE 1 + +/* + * USB Serial Converter support + */ +#define CONFIG_USB_SERIAL_MODULE 1 +#define CONFIG_USB_SERIAL_GENERIC 1 +#define CONFIG_USB_SERIAL_BELKIN_MODULE 1 +#define CONFIG_USB_SERIAL_DIGI_ACCELEPORT_MODULE 1 +#define CONFIG_USB_SERIAL_EMPEG_MODULE 1 +#define CONFIG_USB_SERIAL_FTDI_SIO_MODULE 1 +#define CONFIG_USB_SERIAL_VISOR_MODULE 1 +#define CONFIG_USB_SERIAL_IPAQ_MODULE 1 +#define CONFIG_USB_SERIAL_IR_MODULE 1 +#define CONFIG_USB_SERIAL_EDGEPORT_MODULE 1 +#define CONFIG_USB_SERIAL_EDGEPORT_TI_MODULE 1 +#define CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE 1 +#define CONFIG_USB_SERIAL_KEYSPAN_MODULE 1 +#define CONFIG_USB_SERIAL_KEYSPAN_MPR 1 +#define CONFIG_USB_SERIAL_KEYSPAN_USA28 1 +#define CONFIG_USB_SERIAL_KEYSPAN_USA28X 1 +#define CONFIG_USB_SERIAL_KEYSPAN_USA28XA 1 +#define CONFIG_USB_SERIAL_KEYSPAN_USA28XB 1 +#define CONFIG_USB_SERIAL_KEYSPAN_USA19 1 +#define CONFIG_USB_SERIAL_KEYSPAN_USA18X 1 +#define CONFIG_USB_SERIAL_KEYSPAN_USA19W 1 +#define CONFIG_USB_SERIAL_KEYSPAN_USA19QW 1 +#define CONFIG_USB_SERIAL_KEYSPAN_USA19QI 1 +#define CONFIG_USB_SERIAL_KEYSPAN_USA49W 1 +#define CONFIG_USB_SERIAL_KEYSPAN_USA49WLC 1 +#define CONFIG_USB_SERIAL_KLSI_MODULE 1 +#define CONFIG_USB_SERIAL_KOBIL_SCT_MODULE 1 +#define CONFIG_USB_SERIAL_MCT_U232_MODULE 1 +#define CONFIG_USB_SERIAL_PL2303_MODULE 1 +#define CONFIG_USB_SERIAL_SAFE_MODULE 1 +#define CONFIG_USB_SERIAL_SAFE_PADDED 1 +#define CONFIG_USB_SERIAL_CYBERJACK_MODULE 1 +#define CONFIG_USB_SERIAL_XIRCOM_MODULE 1 +#define CONFIG_USB_SERIAL_OMNINET_MODULE 1 +#define CONFIG_USB_EZUSB 1 + +/* + * USB Miscellaneous drivers + */ +#define CONFIG_USB_EMI62_MODULE 1 +#undef CONFIG_USB_EMI26 +#define CONFIG_USB_TIGL_MODULE 1 +#define CONFIG_USB_AUERSWALD_MODULE 1 +#define CONFIG_USB_RIO500_MODULE 1 +#define CONFIG_USB_LEGOTOWER_MODULE 1 +#define CONFIG_USB_LCD_MODULE 1 +#define CONFIG_USB_LED_MODULE 1 +#undef CONFIG_USB_CYTHERM +#define CONFIG_USB_PHIDGETSERVO_MODULE 1 +#define CONFIG_USB_TEST_MODULE 1 + +/* + * USB Gadget Support + */ +#undef CONFIG_USB_GADGET + +/* + * File systems + */ +#define CONFIG_EXT2_FS 1 +#define CONFIG_EXT2_FS_XATTR 1 +#define CONFIG_EXT2_FS_POSIX_ACL 1 +#define CONFIG_EXT2_FS_SECURITY 1 +#define CONFIG_EXT3_FS_MODULE 1 +#define CONFIG_EXT3_FS_XATTR 1 +#define CONFIG_EXT3_FS_POSIX_ACL 1 +#define CONFIG_EXT3_FS_SECURITY 1 +#define CONFIG_JBD_MODULE 1 +#undef CONFIG_JBD_DEBUG +#define CONFIG_FS_MBCACHE 1 +#define CONFIG_REISERFS_FS_MODULE 1 +#undef CONFIG_REISERFS_CHECK +#define CONFIG_REISERFS_PROC_INFO 1 +#define CONFIG_REISERFS_FS_XATTR 1 +#define CONFIG_REISERFS_FS_POSIX_ACL 1 +#define CONFIG_REISERFS_FS_SECURITY 1 +#define CONFIG_JFS_FS_MODULE 1 +#define CONFIG_JFS_POSIX_ACL 1 +#undef CONFIG_JFS_DEBUG +#undef CONFIG_JFS_STATISTICS +#define CONFIG_FS_POSIX_ACL 1 +#define CONFIG_XFS_FS_MODULE 1 +#undef CONFIG_XFS_RT +#define CONFIG_XFS_QUOTA 1 +#define CONFIG_XFS_SECURITY 1 +#define CONFIG_XFS_POSIX_ACL 1 +#define CONFIG_MINIX_FS_MODULE 1 +#define CONFIG_ROMFS_FS_MODULE 1 +#define CONFIG_QUOTA 1 +#undef CONFIG_QFMT_V1 +#define CONFIG_QFMT_V2 1 +#define CONFIG_QUOTACTL 1 +#define CONFIG_AUTOFS_FS_MODULE 1 +#define CONFIG_AUTOFS4_FS_MODULE 1 + +/* + * CD-ROM/DVD Filesystems + */ +#define CONFIG_ISO9660_FS 1 +#define CONFIG_JOLIET 1 +#define CONFIG_ZISOFS 1 +#define CONFIG_ZISOFS_FS 1 +#define CONFIG_UDF_FS_MODULE 1 + +/* + * DOS/FAT/NT Filesystems + */ +#define CONFIG_FAT_FS_MODULE 1 +#define CONFIG_MSDOS_FS_MODULE 1 +#define CONFIG_VFAT_FS_MODULE 1 +#undef CONFIG_NTFS_FS + +/* + * Pseudo filesystems + */ +#define CONFIG_PROC_FS 1 +#define CONFIG_PROC_KCORE 1 +#define CONFIG_SYSFS 1 +#undef CONFIG_DEVFS_FS +#define CONFIG_DEVPTS_FS_XATTR 1 +#define CONFIG_DEVPTS_FS_SECURITY 1 +#define CONFIG_TMPFS 1 +#define CONFIG_HUGETLBFS 1 +#define CONFIG_HUGETLB_PAGE 1 +#define CONFIG_RAMFS 1 + +/* + * Miscellaneous filesystems + */ +#undef CONFIG_ADFS_FS +#define CONFIG_AFFS_FS_MODULE 1 +#define CONFIG_HFS_FS_MODULE 1 +#define CONFIG_HFSPLUS_FS_MODULE 1 +#define CONFIG_BEFS_FS_MODULE 1 +#undef CONFIG_BEFS_DEBUG +#define CONFIG_BFS_FS_MODULE 1 +#define CONFIG_EFS_FS_MODULE 1 +#undef CONFIG_JFFS_FS +#define CONFIG_JFFS2_FS_MODULE 1 +#define CONFIG_JFFS2_FS_DEBUG 0 +#define CONFIG_JFFS2_FS_NAND 1 +#define CONFIG_CRAMFS_MODULE 1 +#define CONFIG_VXFS_FS_MODULE 1 +#undef CONFIG_HPFS_FS +#define CONFIG_QNX4FS_FS_MODULE 1 +#undef CONFIG_QNX4FS_RW +#define CONFIG_SYSV_FS_MODULE 1 +#define CONFIG_UFS_FS_MODULE 1 +#undef CONFIG_UFS_FS_WRITE + +/* + * Network File Systems + */ +#define CONFIG_NFS_FS_MODULE 1 +#define CONFIG_NFS_V3 1 +#define CONFIG_NFS_V4 1 +#define CONFIG_NFS_DIRECTIO 1 +#define CONFIG_NFSD_MODULE 1 +#define CONFIG_NFSD_V3 1 +#define CONFIG_NFSD_V4 1 +#define CONFIG_NFSD_TCP 1 +#define CONFIG_LOCKD_MODULE 1 +#define CONFIG_LOCKD_V4 1 +#define CONFIG_EXPORTFS_MODULE 1 +#define CONFIG_SUNRPC_MODULE 1 +#define CONFIG_SUNRPC_GSS_MODULE 1 +#define CONFIG_RPCSEC_GSS_KRB5_MODULE 1 +#define CONFIG_SMB_FS_MODULE 1 +#undef CONFIG_SMB_NLS_DEFAULT +#define CONFIG_CIFS_MODULE 1 +#undef CONFIG_CIFS_STATS +#define CONFIG_NCP_FS_MODULE 1 +#define CONFIG_NCPFS_PACKET_SIGNING 1 +#define CONFIG_NCPFS_IOCTL_LOCKING 1 +#define CONFIG_NCPFS_STRONG 1 +#define CONFIG_NCPFS_NFS_NS 1 +#define CONFIG_NCPFS_OS2_NS 1 +#define CONFIG_NCPFS_SMALLDOS 1 +#define CONFIG_NCPFS_NLS 1 +#define CONFIG_NCPFS_EXTRAS 1 +#undef CONFIG_CODA_FS +#undef CONFIG_AFS_FS + +/* + * Partition Types + */ +#define CONFIG_PARTITION_ADVANCED 1 +#undef CONFIG_ACORN_PARTITION +#define CONFIG_OSF_PARTITION 1 +#undef CONFIG_AMIGA_PARTITION +#undef CONFIG_ATARI_PARTITION +#define CONFIG_MAC_PARTITION 1 +#define CONFIG_MSDOS_PARTITION 1 +#define CONFIG_BSD_DISKLABEL 1 +#define CONFIG_MINIX_SUBPARTITION 1 +#define CONFIG_SOLARIS_X86_PARTITION 1 +#define CONFIG_UNIXWARE_DISKLABEL 1 +#undef CONFIG_LDM_PARTITION +#undef CONFIG_NEC98_PARTITION +#define CONFIG_SGI_PARTITION 1 +#undef CONFIG_ULTRIX_PARTITION +#define CONFIG_SUN_PARTITION 1 +#define CONFIG_EFI_PARTITION 1 + +/* + * Native Language Support + */ +#define CONFIG_NLS 1 +#define CONFIG_NLS_DEFAULT "utf8" +#define CONFIG_NLS_CODEPAGE_437_MODULE 1 +#define CONFIG_NLS_CODEPAGE_737_MODULE 1 +#define CONFIG_NLS_CODEPAGE_775_MODULE 1 +#define CONFIG_NLS_CODEPAGE_850_MODULE 1 +#define CONFIG_NLS_CODEPAGE_852_MODULE 1 +#define CONFIG_NLS_CODEPAGE_855_MODULE 1 +#define CONFIG_NLS_CODEPAGE_857_MODULE 1 +#define CONFIG_NLS_CODEPAGE_860_MODULE 1 +#define CONFIG_NLS_CODEPAGE_861_MODULE 1 +#define CONFIG_NLS_CODEPAGE_862_MODULE 1 +#define CONFIG_NLS_CODEPAGE_863_MODULE 1 +#define CONFIG_NLS_CODEPAGE_864_MODULE 1 +#define CONFIG_NLS_CODEPAGE_865_MODULE 1 +#define CONFIG_NLS_CODEPAGE_866_MODULE 1 +#define CONFIG_NLS_CODEPAGE_869_MODULE 1 +#define CONFIG_NLS_CODEPAGE_936_MODULE 1 +#define CONFIG_NLS_CODEPAGE_950_MODULE 1 +#define CONFIG_NLS_CODEPAGE_932_MODULE 1 +#define CONFIG_NLS_CODEPAGE_949_MODULE 1 +#define CONFIG_NLS_CODEPAGE_874_MODULE 1 +#define CONFIG_NLS_ISO8859_8_MODULE 1 +#define CONFIG_NLS_CODEPAGE_1250_MODULE 1 +#define CONFIG_NLS_CODEPAGE_1251_MODULE 1 +#define CONFIG_NLS_ISO8859_1_MODULE 1 +#define CONFIG_NLS_ISO8859_2_MODULE 1 +#define CONFIG_NLS_ISO8859_3_MODULE 1 +#define CONFIG_NLS_ISO8859_4_MODULE 1 +#define CONFIG_NLS_ISO8859_5_MODULE 1 +#define CONFIG_NLS_ISO8859_6_MODULE 1 +#define CONFIG_NLS_ISO8859_7_MODULE 1 +#define CONFIG_NLS_ISO8859_9_MODULE 1 +#define CONFIG_NLS_ISO8859_13_MODULE 1 +#define CONFIG_NLS_ISO8859_14_MODULE 1 +#define CONFIG_NLS_ISO8859_15_MODULE 1 +#define CONFIG_NLS_KOI8_R_MODULE 1 +#define CONFIG_NLS_KOI8_U_MODULE 1 +#define CONFIG_NLS_UTF8_MODULE 1 + +/* + * Profiling support + */ +#define CONFIG_PROFILING 1 +#define CONFIG_OPROFILE_MODULE 1 + +/* + * Kernel hacking + */ +#define CONFIG_DEBUG_KERNEL 1 +#define CONFIG_EARLY_PRINTK 1 +#define CONFIG_DEBUG_STACKOVERFLOW 1 +#undef CONFIG_DEBUG_STACK_USAGE +#undef CONFIG_DEBUG_SLAB +#define CONFIG_MAGIC_SYSRQ 1 +#undef CONFIG_DEBUG_SPINLOCK +#undef CONFIG_DEBUG_PAGEALLOC +#undef CONFIG_DEBUG_HIGHMEM +#define CONFIG_DEBUG_INFO 1 +#define CONFIG_DEBUG_SPINLOCK_SLEEP 1 +#undef CONFIG_FRAME_POINTER +#define CONFIG_X86_FIND_SMP_CONFIG 1 +#define CONFIG_X86_MPPARSE 1 + +/* + * Security options + */ +#define CONFIG_SECURITY 1 +#define CONFIG_SECURITY_NETWORK 1 +#define CONFIG_SECURITY_CAPABILITIES 1 +#undef CONFIG_SECURITY_ROOTPLUG +#define CONFIG_SECURITY_SELINUX 1 +#define CONFIG_SECURITY_SELINUX_BOOTPARAM 1 +#define CONFIG_SECURITY_SELINUX_DISABLE 1 +#define CONFIG_SECURITY_SELINUX_DEVELOP 1 +#undef CONFIG_SECURITY_SELINUX_MLS + +/* + * Cryptographic options + */ +#define CONFIG_CRYPTO 1 +#define CONFIG_CRYPTO_HMAC 1 +#define CONFIG_CRYPTO_NULL_MODULE 1 +#define CONFIG_CRYPTO_MD4_MODULE 1 +#define CONFIG_CRYPTO_MD5 1 +#define CONFIG_CRYPTO_SHA1_MODULE 1 +#define CONFIG_CRYPTO_SHA256_MODULE 1 +#define CONFIG_CRYPTO_SHA512_MODULE 1 +#define CONFIG_CRYPTO_DES_MODULE 1 +#define CONFIG_CRYPTO_BLOWFISH_MODULE 1 +#define CONFIG_CRYPTO_TWOFISH_MODULE 1 +#define CONFIG_CRYPTO_SERPENT_MODULE 1 +#define CONFIG_CRYPTO_AES_MODULE 1 +#define CONFIG_CRYPTO_CAST5_MODULE 1 +#define CONFIG_CRYPTO_CAST6_MODULE 1 +#define CONFIG_CRYPTO_ARC4_MODULE 1 +#define CONFIG_CRYPTO_DEFLATE_MODULE 1 +#define CONFIG_CRYPTO_MICHAEL_MIC_MODULE 1 +#define CONFIG_CRYPTO_CRC32C_MODULE 1 +#undef CONFIG_CRYPTO_TEST + +/* + * Library routines + */ +#define CONFIG_CRC32 1 +#define CONFIG_LIBCRC32C_MODULE 1 +#define CONFIG_ZLIB_INFLATE 1 +#define CONFIG_ZLIB_DEFLATE_MODULE 1 +#define CONFIG_X86_SMP 1 +#define CONFIG_X86_HT 1 +#define CONFIG_X86_BIOS_REBOOT 1 +#define CONFIG_X86_TRAMPOLINE 1 +#define CONFIG_X86_STD_RESOURCES 1 +#define CONFIG_PC 1 diff --git a/include/linux/prio_tree.h b/include/linux/prio_tree.h new file mode 100644 index 000000000..4ac5c6269 --- /dev/null +++ b/include/linux/prio_tree.h @@ -0,0 +1,64 @@ +#ifndef _LINUX_PRIO_TREE_H +#define _LINUX_PRIO_TREE_H + +struct prio_tree_node { + struct prio_tree_node *left; + struct prio_tree_node *right; + struct prio_tree_node *parent; +}; + +struct prio_tree_root { + struct prio_tree_node *prio_tree_node; + unsigned int index_bits; +}; + +struct prio_tree_iter { + struct prio_tree_node *cur; + unsigned long mask; + unsigned long value; + int size_level; +}; + +#define INIT_PRIO_TREE_ROOT(ptr) \ +do { \ + (ptr)->prio_tree_node = NULL; \ + (ptr)->index_bits = 1; \ +} while (0) + +#define INIT_PRIO_TREE_NODE(ptr) \ +do { \ + (ptr)->left = (ptr)->right = (ptr)->parent = (ptr); \ +} while (0) + +#define INIT_PRIO_TREE_ITER(ptr) \ +do { \ + (ptr)->cur = NULL; \ + (ptr)->mask = 0UL; \ + (ptr)->value = 0UL; \ + (ptr)->size_level = 0; \ +} while (0) + +#define prio_tree_entry(ptr, type, member) \ + ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) + +static inline int prio_tree_empty(const struct prio_tree_root *root) +{ + return root->prio_tree_node == NULL; +} + +static inline int prio_tree_root(const struct prio_tree_node *node) +{ + return node->parent == node; +} + +static inline int prio_tree_left_empty(const struct prio_tree_node *node) +{ + return node->left == node; +} + +static inline int prio_tree_right_empty(const struct prio_tree_node *node) +{ + return node->right == node; +} + +#endif /* _LINUX_PRIO_TREE_H */ diff --git a/include/net/tux.h b/include/net/tux.h new file mode 100644 index 000000000..188c58ee3 --- /dev/null +++ b/include/net/tux.h @@ -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 + * + * tux.h: main structure definitions and function prototypes + */ + +#define __KERNEL_SYSCALLS__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* 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 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) (tcp_wspace(sk) >= tcp_min_write_space(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 index 000000000..24ba401b5 --- /dev/null +++ b/include/net/tux_u.h @@ -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 + * + * 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 diff --git a/include/video/gbe.h b/include/video/gbe.h new file mode 100644 index 000000000..ad510284f --- /dev/null +++ b/include/video/gbe.h @@ -0,0 +1,317 @@ +/* + * include/video/gbe.h -- SGI GBE (Graphics Back End) + * + * Copyright (C) 1999 Silicon Graphics, Inc. (Jeffrey Newquist) + * + * This file is subject to the terms and conditions of the GNU General Public + * License version 2 as published by the Free Software Foundation. + */ + +#ifndef __GBE_H__ +#define __GBE_H__ + +struct sgi_gbe { + volatile uint32_t ctrlstat; /* general control */ + volatile uint32_t dotclock; /* dot clock PLL control */ + volatile uint32_t i2c; /* crt I2C control */ + volatile uint32_t sysclk; /* system clock PLL control */ + volatile uint32_t i2cfp; /* flat panel I2C control */ + volatile uint32_t id; /* device id/chip revision */ + volatile uint32_t config; /* power on configuration [1] */ + volatile uint32_t bist; /* internal bist status [1] */ + uint32_t _pad0[0x010000/4 - 8]; + volatile uint32_t vt_xy; /* current dot coords */ + volatile uint32_t vt_xymax; /* maximum dot coords */ + volatile uint32_t vt_vsync; /* vsync on/off */ + volatile uint32_t vt_hsync; /* hsync on/off */ + volatile uint32_t vt_vblank; /* vblank on/off */ + volatile uint32_t vt_hblank; /* hblank on/off */ + volatile uint32_t vt_flags; /* polarity of vt signals */ + volatile uint32_t vt_f2rf_lock; /* f2rf & framelck y coord */ + volatile uint32_t vt_intr01; /* intr 0,1 y coords */ + volatile uint32_t vt_intr23; /* intr 2,3 y coords */ + volatile uint32_t fp_hdrv; /* flat panel hdrv on/off */ + volatile uint32_t fp_vdrv; /* flat panel vdrv on/off */ + volatile uint32_t fp_de; /* flat panel de on/off */ + volatile uint32_t vt_hpixen; /* intrnl horiz pixel on/off */ + volatile uint32_t vt_vpixen; /* intrnl vert pixel on/off */ + volatile uint32_t vt_hcmap; /* cmap write (horiz) */ + volatile uint32_t vt_vcmap; /* cmap write (vert) */ + volatile uint32_t did_start_xy; /* eol/f did/xy reset val */ + volatile uint32_t crs_start_xy; /* eol/f crs/xy reset val */ + volatile uint32_t vc_start_xy; /* eol/f vc/xy reset val */ + uint32_t _pad1[0xffb0/4]; + volatile uint32_t ovr_width_tile;/*overlay plane ctrl 0 */ + volatile uint32_t ovr_inhwctrl; /* overlay plane ctrl 1 */ + volatile uint32_t ovr_control; /* overlay plane ctrl 1 */ + uint32_t _pad2[0xfff4/4]; + volatile uint32_t frm_size_tile;/* normal plane ctrl 0 */ + volatile uint32_t frm_size_pixel;/*normal plane ctrl 1 */ + volatile uint32_t frm_inhwctrl; /* normal plane ctrl 2 */ + volatile uint32_t frm_control; /* normal plane ctrl 3 */ + uint32_t _pad3[0xfff0/4]; + volatile uint32_t did_inhwctrl; /* DID control */ + volatile uint32_t did_control; /* DID shadow */ + uint32_t _pad4[0x7ff8/4]; + volatile uint32_t mode_regs[32];/* WID table */ + uint32_t _pad5[0x7f80/4]; + volatile uint32_t cmap[6144]; /* color map */ + uint32_t _pad6[0x2000/4]; + volatile uint32_t cm_fifo; /* color map fifo status */ + uint32_t _pad7[0x7ffc/4]; + volatile uint32_t gmap[256]; /* gamma map */ + uint32_t _pad8[0x7c00/4]; + volatile uint32_t gmap10[1024]; /* gamma map */ + uint32_t _pad9[0x7000/4]; + volatile uint32_t crs_pos; /* cusror control 0 */ + volatile uint32_t crs_ctl; /* cusror control 1 */ + volatile uint32_t crs_cmap[3]; /* crs cmap */ + uint32_t _pad10[0x7fec/4]; + volatile uint32_t crs_glyph[64];/* crs glyph */ + uint32_t _pad11[0x7f00/4]; + volatile uint32_t vc_0; /* video capture crtl 0 */ + volatile uint32_t vc_1; /* video capture crtl 1 */ + volatile uint32_t vc_2; /* video capture crtl 2 */ + volatile uint32_t vc_3; /* video capture crtl 3 */ + volatile uint32_t vc_4; /* video capture crtl 4 */ + volatile uint32_t vc_5; /* video capture crtl 5 */ + volatile uint32_t vc_6; /* video capture crtl 6 */ + volatile uint32_t vc_7; /* video capture crtl 7 */ + volatile uint32_t vc_8; /* video capture crtl 8 */ +}; + +#define MASK(msb, lsb) \ + ( (((u32)1<<((msb)-(lsb)+1))-1) << (lsb) ) +#define GET(v, msb, lsb) \ + ( ((u32)(v) & MASK(msb,lsb)) >> (lsb) ) +#define SET(v, f, msb, lsb) \ + ( (v) = ((v)&~MASK(msb,lsb)) | (( (u32)(f)<<(lsb) ) & MASK(msb,lsb)) ) + +#define GET_GBE_FIELD(reg, field, v) \ + GET((v), GBE_##reg##_##field##_MSB, GBE_##reg##_##field##_LSB) +#define SET_GBE_FIELD(reg, field, v, f) \ + SET((v), (f), GBE_##reg##_##field##_MSB, GBE_##reg##_##field##_LSB) + +/* + * Bit mask information + */ +#define GBE_CTRLSTAT_CHIPID_MSB 3 +#define GBE_CTRLSTAT_CHIPID_LSB 0 +#define GBE_CTRLSTAT_SENSE_N_MSB 4 +#define GBE_CTRLSTAT_SENSE_N_LSB 4 +#define GBE_CTRLSTAT_PCLKSEL_MSB 29 +#define GBE_CTRLSTAT_PCLKSEL_LSB 28 + +#define GBE_DOTCLK_M_MSB 7 +#define GBE_DOTCLK_M_LSB 0 +#define GBE_DOTCLK_N_MSB 13 +#define GBE_DOTCLK_N_LSB 8 +#define GBE_DOTCLK_P_MSB 15 +#define GBE_DOTCLK_P_LSB 14 +#define GBE_DOTCLK_RUN_MSB 20 +#define GBE_DOTCLK_RUN_LSB 20 + +#define GBE_VT_XY_Y_MSB 23 +#define GBE_VT_XY_Y_LSB 12 +#define GBE_VT_XY_X_MSB 11 +#define GBE_VT_XY_X_LSB 0 +#define GBE_VT_XY_FREEZE_MSB 31 +#define GBE_VT_XY_FREEZE_LSB 31 + +#define GBE_FP_VDRV_ON_MSB 23 +#define GBE_FP_VDRV_ON_LSB 12 +#define GBE_FP_VDRV_OFF_MSB 11 +#define GBE_FP_VDRV_OFF_LSB 0 + +#define GBE_FP_HDRV_ON_MSB 23 +#define GBE_FP_HDRV_ON_LSB 12 +#define GBE_FP_HDRV_OFF_MSB 11 +#define GBE_FP_HDRV_OFF_LSB 0 + +#define GBE_FP_DE_ON_MSB 23 +#define GBE_FP_DE_ON_LSB 12 +#define GBE_FP_DE_OFF_MSB 11 +#define GBE_FP_DE_OFF_LSB 0 + +#define GBE_VT_VSYNC_VSYNC_ON_MSB 23 +#define GBE_VT_VSYNC_VSYNC_ON_LSB 12 +#define GBE_VT_VSYNC_VSYNC_OFF_MSB 11 +#define GBE_VT_VSYNC_VSYNC_OFF_LSB 0 + +#define GBE_VT_HSYNC_HSYNC_ON_MSB 23 +#define GBE_VT_HSYNC_HSYNC_ON_LSB 12 +#define GBE_VT_HSYNC_HSYNC_OFF_MSB 11 +#define GBE_VT_HSYNC_HSYNC_OFF_LSB 0 + +#define GBE_VT_VBLANK_VBLANK_ON_MSB 23 +#define GBE_VT_VBLANK_VBLANK_ON_LSB 12 +#define GBE_VT_VBLANK_VBLANK_OFF_MSB 11 +#define GBE_VT_VBLANK_VBLANK_OFF_LSB 0 + +#define GBE_VT_HBLANK_HBLANK_ON_MSB 23 +#define GBE_VT_HBLANK_HBLANK_ON_LSB 12 +#define GBE_VT_HBLANK_HBLANK_OFF_MSB 11 +#define GBE_VT_HBLANK_HBLANK_OFF_LSB 0 + +#define GBE_VT_FLAGS_F2RF_HIGH_MSB 6 +#define GBE_VT_FLAGS_F2RF_HIGH_LSB 6 +#define GBE_VT_FLAGS_SYNC_LOW_MSB 5 +#define GBE_VT_FLAGS_SYNC_LOW_LSB 5 +#define GBE_VT_FLAGS_SYNC_HIGH_MSB 4 +#define GBE_VT_FLAGS_SYNC_HIGH_LSB 4 +#define GBE_VT_FLAGS_HDRV_LOW_MSB 3 +#define GBE_VT_FLAGS_HDRV_LOW_LSB 3 +#define GBE_VT_FLAGS_HDRV_INVERT_MSB 2 +#define GBE_VT_FLAGS_HDRV_INVERT_LSB 2 +#define GBE_VT_FLAGS_VDRV_LOW_MSB 1 +#define GBE_VT_FLAGS_VDRV_LOW_LSB 1 +#define GBE_VT_FLAGS_VDRV_INVERT_MSB 0 +#define GBE_VT_FLAGS_VDRV_INVERT_LSB 0 + +#define GBE_VT_VCMAP_VCMAP_ON_MSB 23 +#define GBE_VT_VCMAP_VCMAP_ON_LSB 12 +#define GBE_VT_VCMAP_VCMAP_OFF_MSB 11 +#define GBE_VT_VCMAP_VCMAP_OFF_LSB 0 + +#define GBE_VT_HCMAP_HCMAP_ON_MSB 23 +#define GBE_VT_HCMAP_HCMAP_ON_LSB 12 +#define GBE_VT_HCMAP_HCMAP_OFF_MSB 11 +#define GBE_VT_HCMAP_HCMAP_OFF_LSB 0 + +#define GBE_VT_XYMAX_MAXX_MSB 11 +#define GBE_VT_XYMAX_MAXX_LSB 0 +#define GBE_VT_XYMAX_MAXY_MSB 23 +#define GBE_VT_XYMAX_MAXY_LSB 12 + +#define GBE_VT_HPIXEN_HPIXEN_ON_MSB 23 +#define GBE_VT_HPIXEN_HPIXEN_ON_LSB 12 +#define GBE_VT_HPIXEN_HPIXEN_OFF_MSB 11 +#define GBE_VT_HPIXEN_HPIXEN_OFF_LSB 0 + +#define GBE_VT_VPIXEN_VPIXEN_ON_MSB 23 +#define GBE_VT_VPIXEN_VPIXEN_ON_LSB 12 +#define GBE_VT_VPIXEN_VPIXEN_OFF_MSB 11 +#define GBE_VT_VPIXEN_VPIXEN_OFF_LSB 0 + +#define GBE_OVR_CONTROL_OVR_DMA_ENABLE_MSB 0 +#define GBE_OVR_CONTROL_OVR_DMA_ENABLE_LSB 0 + +#define GBE_OVR_INHWCTRL_OVR_DMA_ENABLE_MSB 0 +#define GBE_OVR_INHWCTRL_OVR_DMA_ENABLE_LSB 0 + +#define GBE_OVR_WIDTH_TILE_OVR_FIFO_RESET_MSB 13 +#define GBE_OVR_WIDTH_TILE_OVR_FIFO_RESET_LSB 13 + +#define GBE_FRM_CONTROL_FRM_DMA_ENABLE_MSB 0 +#define GBE_FRM_CONTROL_FRM_DMA_ENABLE_LSB 0 +#define GBE_FRM_CONTROL_FRM_TILE_PTR_MSB 31 +#define GBE_FRM_CONTROL_FRM_TILE_PTR_LSB 9 +#define GBE_FRM_CONTROL_FRM_LINEAR_MSB 1 +#define GBE_FRM_CONTROL_FRM_LINEAR_LSB 1 + +#define GBE_FRM_INHWCTRL_FRM_DMA_ENABLE_MSB 0 +#define GBE_FRM_INHWCTRL_FRM_DMA_ENABLE_LSB 0 + +#define GBE_FRM_SIZE_TILE_FRM_WIDTH_TILE_MSB 12 +#define GBE_FRM_SIZE_TILE_FRM_WIDTH_TILE_LSB 5 +#define GBE_FRM_SIZE_TILE_FRM_RHS_MSB 4 +#define GBE_FRM_SIZE_TILE_FRM_RHS_LSB 0 +#define GBE_FRM_SIZE_TILE_FRM_DEPTH_MSB 14 +#define GBE_FRM_SIZE_TILE_FRM_DEPTH_LSB 13 +#define GBE_FRM_SIZE_TILE_FRM_FIFO_RESET_MSB 15 +#define GBE_FRM_SIZE_TILE_FRM_FIFO_RESET_LSB 15 + +#define GBE_FRM_SIZE_PIXEL_FB_HEIGHT_PIX_MSB 31 +#define GBE_FRM_SIZE_PIXEL_FB_HEIGHT_PIX_LSB 16 + +#define GBE_DID_CONTROL_DID_DMA_ENABLE_MSB 0 +#define GBE_DID_CONTROL_DID_DMA_ENABLE_LSB 0 +#define GBE_DID_INHWCTRL_DID_DMA_ENABLE_MSB 0 +#define GBE_DID_INHWCTRL_DID_DMA_ENABLE_LSB 0 + +#define GBE_DID_START_XY_DID_STARTY_MSB 23 +#define GBE_DID_START_XY_DID_STARTY_LSB 12 +#define GBE_DID_START_XY_DID_STARTX_MSB 11 +#define GBE_DID_START_XY_DID_STARTX_LSB 0 + +#define GBE_CRS_START_XY_CRS_STARTY_MSB 23 +#define GBE_CRS_START_XY_CRS_STARTY_LSB 12 +#define GBE_CRS_START_XY_CRS_STARTX_MSB 11 +#define GBE_CRS_START_XY_CRS_STARTX_LSB 0 + +#define GBE_WID_AUX_MSB 12 +#define GBE_WID_AUX_LSB 11 +#define GBE_WID_GAMMA_MSB 10 +#define GBE_WID_GAMMA_LSB 10 +#define GBE_WID_CM_MSB 9 +#define GBE_WID_CM_LSB 5 +#define GBE_WID_TYP_MSB 4 +#define GBE_WID_TYP_LSB 2 +#define GBE_WID_BUF_MSB 1 +#define GBE_WID_BUF_LSB 0 + +#define GBE_VC_START_XY_VC_STARTY_MSB 23 +#define GBE_VC_START_XY_VC_STARTY_LSB 12 +#define GBE_VC_START_XY_VC_STARTX_MSB 11 +#define GBE_VC_START_XY_VC_STARTX_LSB 0 + +/* Constants */ + +#define GBE_FRM_DEPTH_8 0 +#define GBE_FRM_DEPTH_16 1 +#define GBE_FRM_DEPTH_32 2 + +#define GBE_CMODE_I8 0 +#define GBE_CMODE_I12 1 +#define GBE_CMODE_RG3B2 2 +#define GBE_CMODE_RGB4 3 +#define GBE_CMODE_ARGB5 4 +#define GBE_CMODE_RGB8 5 +#define GBE_CMODE_RGBA5 6 +#define GBE_CMODE_RGB10 7 + +#define GBE_BMODE_BOTH 3 + +#define GBE_CRS_MAGIC 54 +#define GBE_PIXEN_MAGIC_ON 19 +#define GBE_PIXEN_MAGIC_OFF 2 + +#define GBE_TLB_SIZE 128 + +/* [1] - only GBE revision 2 and later */ + +/* + * Video Timing Data Structure + */ + +struct gbe_timing_info { + int flags; + short width; /* Monitor resolution */ + short height; + int fields_sec; /* fields/sec (Hz -3 dec. places */ + int cfreq; /* pixel clock frequency (MHz -3 dec. places) */ + short htotal; /* Horizontal total pixels */ + short hblank_start; /* Horizontal blank start */ + short hblank_end; /* Horizontal blank end */ + short hsync_start; /* Horizontal sync start */ + short hsync_end; /* Horizontal sync end */ + short vtotal; /* Vertical total lines */ + short vblank_start; /* Vertical blank start */ + short vblank_end; /* Vertical blank end */ + short vsync_start; /* Vertical sync start */ + short vsync_end; /* Vertical sync end */ + short pll_m; /* PLL M parameter */ + short pll_n; /* PLL P parameter */ + short pll_p; /* PLL N parameter */ +}; + +/* Defines for gbe_vof_info_t flags */ + +#define GBE_VOF_UNKNOWNMON 1 +#define GBE_VOF_STEREO 2 +#define GBE_VOF_DO_GENSYNC 4 /* enable incoming sync */ +#define GBE_VOF_SYNC_ON_GREEN 8 /* sync on green */ +#define GBE_VOF_FLATPANEL 0x1000 /* FLATPANEL Timing */ +#define GBE_VOF_MAGICKEY 0x2000 /* Backdoor key */ + +#endif /* ! __GBE_H__ */ diff --git a/mm/mempolicy.c b/mm/mempolicy.c new file mode 100644 index 000000000..a62a65c2e --- /dev/null +++ b/mm/mempolicy.c @@ -0,0 +1,1015 @@ +/* + * Simple NUMA memory policy for the Linux kernel. + * + * Copyright 2003,2004 Andi Kleen, SuSE Labs. + * Subject to the GNU Public License, version 2. + * + * NUMA policy allows the user to give hints in which node(s) memory should + * be allocated. + * + * Support four policies per VMA and per process: + * + * The VMA policy has priority over the process policy for a page fault. + * + * interleave Allocate memory interleaved over a set of nodes, + * with normal fallback if it fails. + * For VMA based allocations this interleaves based on the + * offset into the backing object or offset into the mapping + * for anonymous memory. For process policy an process counter + * is used. + * bind Only allocate memory on a specific set of nodes, + * no fallback. + * preferred Try a specific node first before normal fallback. + * As a special case node -1 here means do the allocation + * on the local CPU. This is normally identical to default, + * but useful to set in a VMA when you have a non default + * process policy. + * default Allocate on the local node first, or when on a VMA + * use the process policy. This is what Linux always did + * in a NUMA aware kernel and still does by, ahem, default. + * + * The process policy is applied for most non interrupt memory allocations + * in that process' context. Interrupts ignore the policies and always + * try to allocate on the local CPU. The VMA policy is only applied for memory + * allocations for a VMA in the VM. + * + * Currently there are a few corner cases in swapping where the policy + * is not applied, but the majority should be handled. When process policy + * is used it is not remembered over swap outs/swap ins. + * + * Only the highest zone in the zone hierarchy gets policied. Allocations + * requesting a lower zone just use default policy. This implies that + * on systems with highmem kernel lowmem allocation don't get policied. + * Same with GFP_DMA allocations. + * + * For shmfs/tmpfs/hugetlbfs shared memory the policy is shared between + * all users and remembered even when nobody has memory mapped. + */ + +/* Notebook: + fix mmap readahead to honour policy and enable policy for any page cache + object + statistics for bigpages + global policy for page cache? currently it uses process policy. Requires + first item above. + handle mremap for shared memory (currently ignored for the policy) + grows down? + make bind policy root only? It can trigger oom much faster and the + kernel is not always grateful with that. + could replace all the switch()es with a mempolicy_ops structure. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static kmem_cache_t *policy_cache; +static kmem_cache_t *sn_cache; + +#define PDprintk(fmt...) + +/* Highest zone. An specific allocation for a zone below that is not + policied. */ +static int policy_zone; + +static struct mempolicy default_policy = { + .refcnt = ATOMIC_INIT(1), /* never free it */ + .policy = MPOL_DEFAULT, +}; + +/* Check if all specified nodes are online */ +static int nodes_online(unsigned long *nodes) +{ + DECLARE_BITMAP(offline, MAX_NUMNODES); + + bitmap_copy(offline, node_online_map, MAX_NUMNODES); + if (bitmap_empty(offline, MAX_NUMNODES)) + set_bit(0, offline); + bitmap_complement(offline, MAX_NUMNODES); + bitmap_and(offline, offline, nodes, MAX_NUMNODES); + if (!bitmap_empty(offline, MAX_NUMNODES)) + return -EINVAL; + return 0; +} + +/* Do sanity checking on a policy */ +static int mpol_check_policy(int mode, unsigned long *nodes) +{ + int empty = bitmap_empty(nodes, MAX_NUMNODES); + + switch (mode) { + case MPOL_DEFAULT: + if (!empty) + return -EINVAL; + break; + case MPOL_BIND: + case MPOL_INTERLEAVE: + /* Preferred will only use the first bit, but allow + more for now. */ + if (empty) + return -EINVAL; + break; + } + return nodes_online(nodes); +} + +/* Copy a node mask from user space. */ +static int get_nodes(unsigned long *nodes, unsigned long __user *nmask, + unsigned long maxnode, int mode) +{ + unsigned long k; + unsigned long nlongs; + unsigned long endmask; + + --maxnode; + nlongs = BITS_TO_LONGS(maxnode); + if ((maxnode % BITS_PER_LONG) == 0) + endmask = ~0UL; + else + endmask = (1UL << (maxnode % BITS_PER_LONG)) - 1; + + /* When the user specified more nodes than supported just check + if the non supported part is all zero. */ + if (nmask && nlongs > BITS_TO_LONGS(MAX_NUMNODES)) { + for (k = BITS_TO_LONGS(MAX_NUMNODES); k < nlongs; k++) { + unsigned long t; + if (get_user(t, nmask + k)) + return -EFAULT; + if (k == nlongs - 1) { + if (t & endmask) + return -EINVAL; + } else if (t) + return -EINVAL; + } + nlongs = BITS_TO_LONGS(MAX_NUMNODES); + endmask = ~0UL; + } + + bitmap_zero(nodes, MAX_NUMNODES); + if (nmask && copy_from_user(nodes, nmask, nlongs*sizeof(unsigned long))) + return -EFAULT; + nodes[nlongs-1] &= endmask; + return mpol_check_policy(mode, nodes); +} + +/* Generate a custom zonelist for the BIND policy. */ +static struct zonelist *bind_zonelist(unsigned long *nodes) +{ + struct zonelist *zl; + int num, max, nd; + + max = 1 + MAX_NR_ZONES * bitmap_weight(nodes, MAX_NUMNODES); + zl = kmalloc(sizeof(void *) * max, GFP_KERNEL); + if (!zl) + return NULL; + num = 0; + for (nd = find_first_bit(nodes, MAX_NUMNODES); + nd < MAX_NUMNODES; + nd = find_next_bit(nodes, MAX_NUMNODES, 1+nd)) { + int k; + for (k = MAX_NR_ZONES-1; k >= 0; k--) { + struct zone *z = &NODE_DATA(nd)->node_zones[k]; + if (!z->present_pages) + continue; + zl->zones[num++] = z; + if (k > policy_zone) + policy_zone = k; + } + } + BUG_ON(num >= max); + zl->zones[num] = NULL; + return zl; +} + +/* Create a new policy */ +static struct mempolicy *mpol_new(int mode, unsigned long *nodes) +{ + struct mempolicy *policy; + + PDprintk("setting mode %d nodes[0] %lx\n", mode, nodes[0]); + if (mode == MPOL_DEFAULT) + return NULL; + policy = kmem_cache_alloc(policy_cache, GFP_KERNEL); + if (!policy) + return ERR_PTR(-ENOMEM); + atomic_set(&policy->refcnt, 1); + switch (mode) { + case MPOL_INTERLEAVE: + bitmap_copy(policy->v.nodes, nodes, MAX_NUMNODES); + break; + case MPOL_PREFERRED: + policy->v.preferred_node = find_first_bit(nodes, MAX_NUMNODES); + if (policy->v.preferred_node >= MAX_NUMNODES) + policy->v.preferred_node = -1; + break; + case MPOL_BIND: + policy->v.zonelist = bind_zonelist(nodes); + if (policy->v.zonelist == NULL) { + kmem_cache_free(policy_cache, policy); + return ERR_PTR(-ENOMEM); + } + break; + } + policy->policy = mode; + return policy; +} + +/* Ensure all existing pages follow the policy. */ +static int +verify_pages(unsigned long addr, unsigned long end, unsigned long *nodes) +{ + while (addr < end) { + struct page *p; + pte_t *pte; + pmd_t *pmd; + pgd_t *pgd = pgd_offset_k(addr); + if (pgd_none(*pgd)) { + addr = (addr + PGDIR_SIZE) & PGDIR_MASK; + continue; + } + pmd = pmd_offset(pgd, addr); + if (pmd_none(*pmd)) { + addr = (addr + PMD_SIZE) & PMD_MASK; + continue; + } + p = NULL; + pte = pte_offset_map(pmd, addr); + if (pte_present(*pte)) + p = pte_page(*pte); + pte_unmap(pte); + if (p) { + unsigned nid = page_to_nid(p); + if (!test_bit(nid, nodes)) + return -EIO; + } + addr += PAGE_SIZE; + } + return 0; +} + +/* Step 1: check the range */ +static struct vm_area_struct * +check_range(struct mm_struct *mm, unsigned long start, unsigned long end, + unsigned long *nodes, unsigned long flags) +{ + int err; + struct vm_area_struct *first, *vma, *prev; + + first = find_vma(mm, start); + if (!first) + return ERR_PTR(-EFAULT); + prev = NULL; + for (vma = first; vma && vma->vm_start < end; vma = vma->vm_next) { + if (!vma->vm_next && vma->vm_end < end) + return ERR_PTR(-EFAULT); + if (prev && prev->vm_end < vma->vm_start) + return ERR_PTR(-EFAULT); + if ((flags & MPOL_MF_STRICT) && !is_vm_hugetlb_page(vma)) { + err = verify_pages(vma->vm_start, vma->vm_end, nodes); + if (err) { + first = ERR_PTR(err); + break; + } + } + prev = vma; + } + return first; +} + +/* Apply policy to a single VMA */ +static int policy_vma(struct vm_area_struct *vma, struct mempolicy *new) +{ + int err = 0; + struct mempolicy *old = vma->vm_policy; + + PDprintk("vma %lx-%lx/%lx vm_ops %p vm_file %p set_policy %p\n", + vma->vm_start, vma->vm_end, vma->vm_pgoff, + vma->vm_ops, vma->vm_file, + vma->vm_ops ? vma->vm_ops->set_policy : NULL); + + if (vma->vm_ops && vma->vm_ops->set_policy) + err = vma->vm_ops->set_policy(vma, new); + if (!err) { + mpol_get(new); + vma->vm_policy = new; + mpol_free(old); + } + return err; +} + +/* Step 2: apply policy to a range and do splits. */ +static int mbind_range(struct vm_area_struct *vma, unsigned long start, + unsigned long end, struct mempolicy *new) +{ + struct vm_area_struct *next; + int err; + + err = 0; + for (; vma && vma->vm_start < end; vma = next) { + next = vma->vm_next; + if (vma->vm_start < start) + err = split_vma(vma->vm_mm, vma, start, 1); + if (!err && vma->vm_end > end) + err = split_vma(vma->vm_mm, vma, end, 0); + if (!err) + err = policy_vma(vma, new); + if (err) + break; + } + return err; +} + +/* Change policy for a memory range */ +asmlinkage long sys_mbind(unsigned long start, unsigned long len, + unsigned long mode, + unsigned long __user *nmask, unsigned long maxnode, + unsigned flags) +{ + struct vm_area_struct *vma; + struct mm_struct *mm = current->mm; + struct mempolicy *new; + unsigned long end; + DECLARE_BITMAP(nodes, MAX_NUMNODES); + int err; + + if ((flags & ~(unsigned long)(MPOL_MF_STRICT)) || mode > MPOL_MAX) + return -EINVAL; + if (start & ~PAGE_MASK) + return -EINVAL; + if (mode == MPOL_DEFAULT) + flags &= ~MPOL_MF_STRICT; + len = (len + PAGE_SIZE - 1) & PAGE_MASK; + end = start + len; + if (end < start) + return -EINVAL; + if (end == start) + return 0; + + err = get_nodes(nodes, nmask, maxnode, mode); + if (err) + return err; + + new = mpol_new(mode, nodes); + if (IS_ERR(new)) + return PTR_ERR(new); + + PDprintk("mbind %lx-%lx mode:%ld nodes:%lx\n",start,start+len, + mode,nodes[0]); + + down_write(&mm->mmap_sem); + vma = check_range(mm, start, end, nodes, flags); + err = PTR_ERR(vma); + if (!IS_ERR(vma)) + err = mbind_range(vma, start, end, new); + up_write(&mm->mmap_sem); + mpol_free(new); + return err; +} + +/* Set the process memory policy */ +asmlinkage long sys_set_mempolicy(int mode, unsigned long __user *nmask, + unsigned long maxnode) +{ + int err; + struct mempolicy *new; + DECLARE_BITMAP(nodes, MAX_NUMNODES); + + if (mode > MPOL_MAX) + return -EINVAL; + err = get_nodes(nodes, nmask, maxnode, mode); + if (err) + return err; + new = mpol_new(mode, nodes); + if (IS_ERR(new)) + return PTR_ERR(new); + mpol_free(current->mempolicy); + current->mempolicy = new; + if (new && new->policy == MPOL_INTERLEAVE) + current->il_next = find_first_bit(new->v.nodes, MAX_NUMNODES); + return 0; +} + +/* Fill a zone bitmap for a policy */ +static void get_zonemask(struct mempolicy *p, unsigned long *nodes) +{ + int i; + + bitmap_zero(nodes, MAX_NUMNODES); + switch (p->policy) { + case MPOL_BIND: + for (i = 0; p->v.zonelist->zones[i]; i++) + __set_bit(p->v.zonelist->zones[i]->zone_pgdat->node_id, nodes); + break; + case MPOL_DEFAULT: + break; + case MPOL_INTERLEAVE: + bitmap_copy(nodes, p->v.nodes, MAX_NUMNODES); + break; + case MPOL_PREFERRED: + /* or use current node instead of online map? */ + if (p->v.preferred_node < 0) + bitmap_copy(nodes, node_online_map, MAX_NUMNODES); + else + __set_bit(p->v.preferred_node, nodes); + break; + default: + BUG(); + } +} + +static int lookup_node(struct mm_struct *mm, unsigned long addr) +{ + struct page *p; + int err; + + err = get_user_pages(current, mm, addr & PAGE_MASK, 1, 0, 0, &p, NULL); + if (err >= 0) { + err = page_zone(p)->zone_pgdat->node_id; + put_page(p); + } + return err; +} + +/* Copy a kernel node mask to user space */ +static int copy_nodes_to_user(unsigned long __user *mask, unsigned long maxnode, + void *nodes, unsigned nbytes) +{ + unsigned long copy = ALIGN(maxnode-1, 64) / 8; + + if (copy > nbytes) { + if (copy > PAGE_SIZE) + return -EINVAL; + if (clear_user((char __user *)mask + nbytes, copy - nbytes)) + return -EFAULT; + copy = nbytes; + } + return copy_to_user(mask, nodes, copy) ? -EFAULT : 0; +} + +/* Retrieve NUMA policy */ +asmlinkage long sys_get_mempolicy(int __user *policy, + unsigned long __user *nmask, + unsigned long maxnode, + unsigned long addr, unsigned long flags) +{ + int err, pval; + struct mm_struct *mm = current->mm; + struct vm_area_struct *vma = NULL; + struct mempolicy *pol = current->mempolicy; + + if (flags & ~(unsigned long)(MPOL_F_NODE|MPOL_F_ADDR)) + return -EINVAL; + if (nmask != NULL && maxnode < numnodes) + return -EINVAL; + if (flags & MPOL_F_ADDR) { + down_read(&mm->mmap_sem); + vma = find_vma_intersection(mm, addr, addr+1); + if (!vma) { + up_read(&mm->mmap_sem); + return -EFAULT; + } + if (vma->vm_ops && vma->vm_ops->get_policy) + pol = vma->vm_ops->get_policy(vma, addr); + else + pol = vma->vm_policy; + } else if (addr) + return -EINVAL; + + if (!pol) + pol = &default_policy; + + if (flags & MPOL_F_NODE) { + if (flags & MPOL_F_ADDR) { + err = lookup_node(mm, addr); + if (err < 0) + goto out; + pval = err; + } else if (pol == current->mempolicy && + pol->policy == MPOL_INTERLEAVE) { + pval = current->il_next; + } else { + err = -EINVAL; + goto out; + } + } else + pval = pol->policy; + + err = -EFAULT; + if (policy && put_user(pval, policy)) + goto out; + + err = 0; + if (nmask) { + DECLARE_BITMAP(nodes, MAX_NUMNODES); + get_zonemask(pol, nodes); + err = copy_nodes_to_user(nmask, maxnode, nodes, sizeof(nodes)); + } + + out: + if (vma) + up_read(¤t->mm->mmap_sem); + return err; +} + +#ifdef CONFIG_COMPAT +/* The other functions are compatible */ +asmlinkage long compat_get_mempolicy(int __user *policy, + unsigned __user *nmask, unsigned maxnode, + unsigned addr, unsigned flags) +{ + long err; + unsigned long __user *nm = NULL; + if (nmask) + nm = compat_alloc_user_space(ALIGN(maxnode-1, 64) / 8); + err = sys_get_mempolicy(policy, nm, maxnode, addr, flags); + if (!err && copy_in_user(nmask, nm, ALIGN(maxnode-1, 32)/8)) + err = -EFAULT; + return err; +} +#endif + +/* Return effective policy for a VMA */ +static struct mempolicy * +get_vma_policy(struct vm_area_struct *vma, unsigned long addr) +{ + struct mempolicy *pol = current->mempolicy; + + if (vma) { + if (vma->vm_ops && vma->vm_ops->get_policy) + pol = vma->vm_ops->get_policy(vma, addr); + else if (vma->vm_policy && + vma->vm_policy->policy != MPOL_DEFAULT) + pol = vma->vm_policy; + } + if (!pol) + pol = &default_policy; + return pol; +} + +/* Return a zonelist representing a mempolicy */ +static struct zonelist *zonelist_policy(unsigned gfp, struct mempolicy *policy) +{ + int nd; + + switch (policy->policy) { + case MPOL_PREFERRED: + nd = policy->v.preferred_node; + if (nd < 0) + nd = numa_node_id(); + break; + case MPOL_BIND: + /* Lower zones don't get a policy applied */ + if (gfp >= policy_zone) + return policy->v.zonelist; + /*FALL THROUGH*/ + case MPOL_INTERLEAVE: /* should not happen */ + case MPOL_DEFAULT: + nd = numa_node_id(); + break; + default: + nd = 0; + BUG(); + } + return NODE_DATA(nd)->node_zonelists + (gfp & GFP_ZONEMASK); +} + +/* Do dynamic interleaving for a process */ +static unsigned interleave_nodes(struct mempolicy *policy) +{ + unsigned nid, next; + struct task_struct *me = current; + + nid = me->il_next; + BUG_ON(nid >= MAX_NUMNODES); + next = find_next_bit(policy->v.nodes, MAX_NUMNODES, 1+nid); + if (next >= MAX_NUMNODES) + next = find_first_bit(policy->v.nodes, MAX_NUMNODES); + me->il_next = next; + return nid; +} + +/* Do static interleaving for a VMA with known offset. */ +static unsigned offset_il_node(struct mempolicy *pol, + struct vm_area_struct *vma, unsigned long off) +{ + unsigned nnodes = bitmap_weight(pol->v.nodes, MAX_NUMNODES); + unsigned target = (unsigned)off % nnodes; + int c; + int nid = -1; + + c = 0; + do { + nid = find_next_bit(pol->v.nodes, MAX_NUMNODES, nid+1); + c++; + } while (c <= target); + BUG_ON(nid >= MAX_NUMNODES); + BUG_ON(!test_bit(nid, pol->v.nodes)); + return nid; +} + +/* Allocate a page in interleaved policy. + Own path because it needs to do special accounting. */ +static struct page *alloc_page_interleave(unsigned gfp, unsigned nid) +{ + struct zonelist *zl; + struct page *page; + + BUG_ON(!test_bit(nid, node_online_map)); + zl = NODE_DATA(nid)->node_zonelists + (gfp & GFP_ZONEMASK); + page = __alloc_pages(gfp, 0, zl); + if (page && page_zone(page) == zl->zones[0]) { + zl->zones[0]->pageset[get_cpu()].interleave_hit++; + put_cpu(); + } + return page; +} + +/** + * alloc_page_vma - Allocate a page for a VMA. + * + * @gfp: + * %GFP_USER user allocation. + * %GFP_KERNEL kernel allocations, + * %GFP_HIGHMEM highmem/user allocations, + * %GFP_FS allocation should not call back into a file system. + * %GFP_ATOMIC don't sleep. + * + * @vma: Pointer to VMA or NULL if not available. + * @addr: Virtual Address of the allocation. Must be inside the VMA. + * + * This function allocates a page from the kernel page pool and applies + * a NUMA policy associated with the VMA or the current process. + * When VMA is not NULL caller must hold down_read on the mmap_sem of the + * mm_struct of the VMA to prevent it from going away. Should be used for + * all allocations for pages that will be mapped into + * user space. Returns NULL when no page can be allocated. + * + * Should be called with the mm_sem of the vma hold. + */ +struct page * +alloc_page_vma(unsigned gfp, struct vm_area_struct *vma, unsigned long addr) +{ + struct mempolicy *pol = get_vma_policy(vma, addr); + + if (unlikely(pol->policy == MPOL_INTERLEAVE)) { + unsigned nid; + if (vma) { + unsigned long off; + BUG_ON(addr >= vma->vm_end); + BUG_ON(addr < vma->vm_start); + off = vma->vm_pgoff; + off += (addr - vma->vm_start) >> PAGE_SHIFT; + nid = offset_il_node(pol, vma, off); + } else { + /* fall back to process interleaving */ + nid = interleave_nodes(pol); + } + return alloc_page_interleave(gfp, nid); + } + return __alloc_pages(gfp, 0, zonelist_policy(gfp, pol)); +} + +/** + * alloc_pages_current - Allocate pages. + * + * @gfp: + * %GFP_USER user allocation, + * %GFP_KERNEL kernel allocation, + * %GFP_HIGHMEM highmem allocation, + * %GFP_FS don't call back into a file system. + * %GFP_ATOMIC don't sleep. + * @order: Power of two of allocation size in pages. 0 is a single page. + * + * Allocate a page from the kernel page pool. When not in + * interrupt context and apply the current process NUMA policy. + * Returns NULL when no page can be allocated. + */ +struct page *alloc_pages_current(unsigned gfp, unsigned order) +{ + struct mempolicy *pol = current->mempolicy; + + if (!pol || in_interrupt()) + pol = &default_policy; + if (pol->policy == MPOL_INTERLEAVE && order == 0) + return alloc_page_interleave(gfp, interleave_nodes(pol)); + return __alloc_pages(gfp, order, zonelist_policy(gfp, pol)); +} +EXPORT_SYMBOL(alloc_pages_current); + +/* Slow path of a mempolicy copy */ +struct mempolicy *__mpol_copy(struct mempolicy *old) +{ + struct mempolicy *new = kmem_cache_alloc(policy_cache, GFP_KERNEL); + + if (!new) + return ERR_PTR(-ENOMEM); + *new = *old; + atomic_set(&new->refcnt, 1); + if (new->policy == MPOL_BIND) { + int sz = ksize(old->v.zonelist); + new->v.zonelist = kmalloc(sz, SLAB_KERNEL); + if (!new->v.zonelist) { + kmem_cache_free(policy_cache, new); + return ERR_PTR(-ENOMEM); + } + memcpy(new->v.zonelist, old->v.zonelist, sz); + } + return new; +} + +/* Slow path of a mempolicy comparison */ +int __mpol_equal(struct mempolicy *a, struct mempolicy *b) +{ + if (!a || !b) + return 0; + if (a->policy != b->policy) + return 0; + switch (a->policy) { + case MPOL_DEFAULT: + return 1; + case MPOL_INTERLEAVE: + return bitmap_equal(a->v.nodes, b->v.nodes, MAX_NUMNODES); + case MPOL_PREFERRED: + return a->v.preferred_node == b->v.preferred_node; + case MPOL_BIND: { + int i; + for (i = 0; a->v.zonelist->zones[i]; i++) + if (a->v.zonelist->zones[i] != b->v.zonelist->zones[i]) + return 0; + return b->v.zonelist->zones[i] == NULL; + } + default: + BUG(); + return 0; + } +} + +/* Slow path of a mpol destructor. */ +void __mpol_free(struct mempolicy *p) +{ + if (!atomic_dec_and_test(&p->refcnt)) + return; + if (p->policy == MPOL_BIND) + kfree(p->v.zonelist); + p->policy = MPOL_DEFAULT; + kmem_cache_free(policy_cache, p); +} + +/* + * Hugetlb policy. Same as above, just works with node numbers instead of + * zonelists. + */ + +/* Find first node suitable for an allocation */ +int mpol_first_node(struct vm_area_struct *vma, unsigned long addr) +{ + struct mempolicy *pol = get_vma_policy(vma, addr); + + switch (pol->policy) { + case MPOL_DEFAULT: + return numa_node_id(); + case MPOL_BIND: + return pol->v.zonelist->zones[0]->zone_pgdat->node_id; + case MPOL_INTERLEAVE: + return interleave_nodes(pol); + case MPOL_PREFERRED: + return pol->v.preferred_node >= 0 ? + pol->v.preferred_node : numa_node_id(); + } + BUG(); + return 0; +} + +/* Find secondary valid nodes for an allocation */ +int mpol_node_valid(int nid, struct vm_area_struct *vma, unsigned long addr) +{ + struct mempolicy *pol = get_vma_policy(vma, addr); + + switch (pol->policy) { + case MPOL_PREFERRED: + case MPOL_DEFAULT: + case MPOL_INTERLEAVE: + return 1; + case MPOL_BIND: { + struct zone **z; + for (z = pol->v.zonelist->zones; *z; z++) + if ((*z)->zone_pgdat->node_id == nid) + return 1; + return 0; + } + default: + BUG(); + return 0; + } +} + +/* + * Shared memory backing store policy support. + * + * Remember policies even when nobody has shared memory mapped. + * The policies are kept in Red-Black tree linked from the inode. + * They are protected by the sp->sem semaphore, which should be held + * for any accesses to the tree. + */ + +/* lookup first element intersecting start-end */ +/* Caller holds sp->sem */ +static struct sp_node * +sp_lookup(struct shared_policy *sp, unsigned long start, unsigned long end) +{ + struct rb_node *n = sp->root.rb_node; + + while (n) { + struct sp_node *p = rb_entry(n, struct sp_node, nd); + if (start >= p->end) { + n = n->rb_right; + } else if (end < p->start) { + n = n->rb_left; + } else { + break; + } + } + if (!n) + return NULL; + for (;;) { + struct sp_node *w = NULL; + struct rb_node *prev = rb_prev(n); + if (!prev) + break; + w = rb_entry(prev, struct sp_node, nd); + if (w->end <= start) + break; + n = prev; + } + return rb_entry(n, struct sp_node, nd); +} + +/* Insert a new shared policy into the list. */ +/* Caller holds sp->sem */ +static void sp_insert(struct shared_policy *sp, struct sp_node *new) +{ + struct rb_node **p = &sp->root.rb_node; + struct rb_node *parent = NULL; + struct sp_node *nd; + + while (*p) { + parent = *p; + nd = rb_entry(parent, struct sp_node, nd); + if (new->start < nd->start) + p = &(*p)->rb_left; + else if (new->end > nd->end) + p = &(*p)->rb_right; + else + BUG(); + } + rb_link_node(&new->nd, parent, p); + rb_insert_color(&new->nd, &sp->root); + PDprintk("inserting %lx-%lx: %d\n", new->start, new->end, + new->policy ? new->policy->policy : 0); +} + +/* Find shared policy intersecting idx */ +struct mempolicy * +mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx) +{ + struct mempolicy *pol = NULL; + struct sp_node *sn; + + down(&sp->sem); + sn = sp_lookup(sp, idx, idx+1); + if (sn) { + mpol_get(sn->policy); + pol = sn->policy; + } + up(&sp->sem); + return pol; +} + +static void sp_delete(struct shared_policy *sp, struct sp_node *n) +{ + PDprintk("deleting %lx-l%x\n", n->start, n->end); + rb_erase(&n->nd, &sp->root); + mpol_free(n->policy); + kmem_cache_free(sn_cache, n); +} + +struct sp_node * +sp_alloc(unsigned long start, unsigned long end, struct mempolicy *pol) +{ + struct sp_node *n = kmem_cache_alloc(sn_cache, GFP_KERNEL); + + if (!n) + return NULL; + n->start = start; + n->end = end; + mpol_get(pol); + n->policy = pol; + return n; +} + +/* Replace a policy range. */ +static int shared_policy_replace(struct shared_policy *sp, unsigned long start, + unsigned long end, struct sp_node *new) +{ + struct sp_node *n, *new2; + + down(&sp->sem); + n = sp_lookup(sp, start, end); + /* Take care of old policies in the same range. */ + while (n && n->start < end) { + struct rb_node *next = rb_next(&n->nd); + if (n->start >= start) { + if (n->end <= end) + sp_delete(sp, n); + else + n->start = end; + } else { + /* Old policy spanning whole new range. */ + if (n->end > end) { + new2 = sp_alloc(end, n->end, n->policy); + if (!new2) { + up(&sp->sem); + return -ENOMEM; + } + n->end = end; + sp_insert(sp, new2); + } + /* Old crossing beginning, but not end (easy) */ + if (n->start < start && n->end > start) + n->end = start; + } + if (!next) + break; + n = rb_entry(next, struct sp_node, nd); + } + if (new) + sp_insert(sp, new); + up(&sp->sem); + return 0; +} + +int mpol_set_shared_policy(struct shared_policy *info, + struct vm_area_struct *vma, struct mempolicy *npol) +{ + int err; + struct sp_node *new = NULL; + unsigned long sz = vma_pages(vma); + + PDprintk("set_shared_policy %lx sz %lu %d %lx\n", + vma->vm_pgoff, + sz, npol? npol->policy : -1, + npol ? npol->v.nodes[0] : -1); + + if (npol) { + new = sp_alloc(vma->vm_pgoff, vma->vm_pgoff + sz, npol); + if (!new) + return -ENOMEM; + } + err = shared_policy_replace(info, vma->vm_pgoff, vma->vm_pgoff+sz, new); + if (err && new) + kmem_cache_free(sn_cache, new); + return err; +} + +/* Free a backing policy store on inode delete. */ +void mpol_free_shared_policy(struct shared_policy *p) +{ + struct sp_node *n; + struct rb_node *next; + + down(&p->sem); + next = rb_first(&p->root); + while (next) { + n = rb_entry(next, struct sp_node, nd); + next = rb_next(&n->nd); + rb_erase(&n->nd, &p->root); + mpol_free(n->policy); + kmem_cache_free(sn_cache, n); + } + up(&p->sem); +} + +static __init int numa_policy_init(void) +{ + policy_cache = kmem_cache_create("numa_policy", + sizeof(struct mempolicy), + 0, SLAB_PANIC, NULL, NULL); + + sn_cache = kmem_cache_create("shared_policy_node", + sizeof(struct sp_node), + 0, SLAB_PANIC, NULL, NULL); + return 0; +} +module_init(numa_policy_init); diff --git a/mm/prio_tree.c b/mm/prio_tree.c new file mode 100644 index 000000000..6cd41a831 --- /dev/null +++ b/mm/prio_tree.c @@ -0,0 +1,663 @@ +/* + * mm/prio_tree.c - priority search tree for mapping->i_mmap + * + * Copyright (C) 2004, Rajesh Venkatasubramanian + * + * This file is released under the GPL v2. + * + * Based on the radix priority search tree proposed by Edward M. McCreight + * SIAM Journal of Computing, vol. 14, no.2, pages 257-276, May 1985 + * + * 02Feb2004 Initial version + */ + +#include +#include +#include +#include + +/* + * A clever mix of heap and radix trees forms a radix priority search tree (PST) + * which is useful for storing intervals, e.g, we can consider a vma as a closed + * interval of file pages [offset_begin, offset_end], and store all vmas that + * map a file in a PST. Then, using the PST, we can answer a stabbing query, + * i.e., selecting a set of stored intervals (vmas) that overlap with (map) a + * given input interval X (a set of consecutive file pages), in "O(log n + m)" + * time where 'log n' is the height of the PST, and 'm' is the number of stored + * intervals (vmas) that overlap (map) with the input interval X (the set of + * consecutive file pages). + * + * In our implementation, we store closed intervals of the form [radix_index, + * heap_index]. We assume that always radix_index <= heap_index. McCreight's PST + * is designed for storing intervals with unique radix indices, i.e., each + * interval have different radix_index. However, this limitation can be easily + * overcome by using the size, i.e., heap_index - radix_index, as part of the + * index, so we index the tree using [(radix_index,size), heap_index]. + * + * When the above-mentioned indexing scheme is used, theoretically, in a 32 bit + * machine, the maximum height of a PST can be 64. We can use a balanced version + * of the priority search tree to optimize the tree height, but the balanced + * tree proposed by McCreight is too complex and memory-hungry for our purpose. + */ + +/* + * The following macros are used for implementing prio_tree for i_mmap + */ + +#define RADIX_INDEX(vma) ((vma)->vm_pgoff) +#define VMA_SIZE(vma) (((vma)->vm_end - (vma)->vm_start) >> PAGE_SHIFT) +/* avoid overflow */ +#define HEAP_INDEX(vma) ((vma)->vm_pgoff + (VMA_SIZE(vma) - 1)) + +#define GET_INDEX_VMA(vma, radix, heap) \ +do { \ + radix = RADIX_INDEX(vma); \ + heap = HEAP_INDEX(vma); \ +} while (0) + +#define GET_INDEX(node, radix, heap) \ +do { \ + struct vm_area_struct *__tmp = \ + prio_tree_entry(node, struct vm_area_struct, shared.prio_tree_node);\ + GET_INDEX_VMA(__tmp, radix, heap); \ +} while (0) + +static unsigned long index_bits_to_maxindex[BITS_PER_LONG]; + +void __init prio_tree_init(void) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(index_bits_to_maxindex) - 1; i++) + index_bits_to_maxindex[i] = (1UL << (i + 1)) - 1; + index_bits_to_maxindex[ARRAY_SIZE(index_bits_to_maxindex) - 1] = ~0UL; +} + +/* + * Maximum heap_index that can be stored in a PST with index_bits bits + */ +static inline unsigned long prio_tree_maxindex(unsigned int bits) +{ + return index_bits_to_maxindex[bits - 1]; +} + +/* + * Extend a priority search tree so that it can store a node with heap_index + * max_heap_index. In the worst case, this algorithm takes O((log n)^2). + * However, this function is used rarely and the common case performance is + * not bad. + */ +static struct prio_tree_node *prio_tree_expand(struct prio_tree_root *root, + struct prio_tree_node *node, unsigned long max_heap_index) +{ + static void prio_tree_remove(struct prio_tree_root *, + struct prio_tree_node *); + struct prio_tree_node *first = NULL, *prev, *last = NULL; + + if (max_heap_index > prio_tree_maxindex(root->index_bits)) + root->index_bits++; + + while (max_heap_index > prio_tree_maxindex(root->index_bits)) { + root->index_bits++; + + if (prio_tree_empty(root)) + continue; + + if (first == NULL) { + first = root->prio_tree_node; + prio_tree_remove(root, root->prio_tree_node); + INIT_PRIO_TREE_NODE(first); + last = first; + } else { + prev = last; + last = root->prio_tree_node; + prio_tree_remove(root, root->prio_tree_node); + INIT_PRIO_TREE_NODE(last); + prev->left = last; + last->parent = prev; + } + } + + INIT_PRIO_TREE_NODE(node); + + if (first) { + node->left = first; + first->parent = node; + } else + last = node; + + if (!prio_tree_empty(root)) { + last->left = root->prio_tree_node; + last->left->parent = last; + } + + root->prio_tree_node = node; + return node; +} + +/* + * Replace a prio_tree_node with a new node and return the old node + */ +static struct prio_tree_node *prio_tree_replace(struct prio_tree_root *root, + struct prio_tree_node *old, struct prio_tree_node *node) +{ + INIT_PRIO_TREE_NODE(node); + + if (prio_tree_root(old)) { + BUG_ON(root->prio_tree_node != old); + /* + * We can reduce root->index_bits here. However, it is complex + * and does not help much to improve performance (IMO). + */ + node->parent = node; + root->prio_tree_node = node; + } else { + node->parent = old->parent; + if (old->parent->left == old) + old->parent->left = node; + else + old->parent->right = node; + } + + if (!prio_tree_left_empty(old)) { + node->left = old->left; + old->left->parent = node; + } + + if (!prio_tree_right_empty(old)) { + node->right = old->right; + old->right->parent = node; + } + + return old; +} + +/* + * Insert a prio_tree_node @node into a radix priority search tree @root. The + * algorithm typically takes O(log n) time where 'log n' is the number of bits + * required to represent the maximum heap_index. In the worst case, the algo + * can take O((log n)^2) - check prio_tree_expand. + * + * If a prior node with same radix_index and heap_index is already found in + * the tree, then returns the address of the prior node. Otherwise, inserts + * @node into the tree and returns @node. + */ +static struct prio_tree_node *prio_tree_insert(struct prio_tree_root *root, + struct prio_tree_node *node) +{ + struct prio_tree_node *cur, *res = node; + unsigned long radix_index, heap_index; + unsigned long r_index, h_index, index, mask; + int size_flag = 0; + + GET_INDEX(node, radix_index, heap_index); + + if (prio_tree_empty(root) || + heap_index > prio_tree_maxindex(root->index_bits)) + return prio_tree_expand(root, node, heap_index); + + cur = root->prio_tree_node; + mask = 1UL << (root->index_bits - 1); + + while (mask) { + GET_INDEX(cur, r_index, h_index); + + if (r_index == radix_index && h_index == heap_index) + return cur; + + if (h_index < heap_index || + (h_index == heap_index && r_index > radix_index)) { + struct prio_tree_node *tmp = node; + node = prio_tree_replace(root, cur, node); + cur = tmp; + /* swap indices */ + index = r_index; + r_index = radix_index; + radix_index = index; + index = h_index; + h_index = heap_index; + heap_index = index; + } + + if (size_flag) + index = heap_index - radix_index; + else + index = radix_index; + + if (index & mask) { + if (prio_tree_right_empty(cur)) { + INIT_PRIO_TREE_NODE(node); + cur->right = node; + node->parent = cur; + return res; + } else + cur = cur->right; + } else { + if (prio_tree_left_empty(cur)) { + INIT_PRIO_TREE_NODE(node); + cur->left = node; + node->parent = cur; + return res; + } else + cur = cur->left; + } + + mask >>= 1; + + if (!mask) { + mask = 1UL << (root->index_bits - 1); + size_flag = 1; + } + } + /* Should not reach here */ + BUG(); + return NULL; +} + +/* + * Remove a prio_tree_node @node from a radix priority search tree @root. The + * algorithm takes O(log n) time where 'log n' is the number of bits required + * to represent the maximum heap_index. + */ +static void prio_tree_remove(struct prio_tree_root *root, + struct prio_tree_node *node) +{ + struct prio_tree_node *cur; + unsigned long r_index, h_index_right, h_index_left; + + cur = node; + + while (!prio_tree_left_empty(cur) || !prio_tree_right_empty(cur)) { + if (!prio_tree_left_empty(cur)) + GET_INDEX(cur->left, r_index, h_index_left); + else { + cur = cur->right; + continue; + } + + if (!prio_tree_right_empty(cur)) + GET_INDEX(cur->right, r_index, h_index_right); + else { + cur = cur->left; + continue; + } + + /* both h_index_left and h_index_right cannot be 0 */ + if (h_index_left >= h_index_right) + cur = cur->left; + else + cur = cur->right; + } + + if (prio_tree_root(cur)) { + BUG_ON(root->prio_tree_node != cur); + INIT_PRIO_TREE_ROOT(root); + return; + } + + if (cur->parent->right == cur) + cur->parent->right = cur->parent; + else + cur->parent->left = cur->parent; + + while (cur != node) + cur = prio_tree_replace(root, cur->parent, cur); +} + +/* + * Following functions help to enumerate all prio_tree_nodes in the tree that + * overlap with the input interval X [radix_index, heap_index]. The enumeration + * takes O(log n + m) time where 'log n' is the height of the tree (which is + * proportional to # of bits required to represent the maximum heap_index) and + * 'm' is the number of prio_tree_nodes that overlap the interval X. + */ + +static struct prio_tree_node *prio_tree_left( + struct prio_tree_root *root, struct prio_tree_iter *iter, + unsigned long radix_index, unsigned long heap_index, + unsigned long *r_index, unsigned long *h_index) +{ + if (prio_tree_left_empty(iter->cur)) + return NULL; + + GET_INDEX(iter->cur->left, *r_index, *h_index); + + if (radix_index <= *h_index) { + iter->cur = iter->cur->left; + iter->mask >>= 1; + if (iter->mask) { + if (iter->size_level) + iter->size_level++; + } else { + if (iter->size_level) { + BUG_ON(!prio_tree_left_empty(iter->cur)); + BUG_ON(!prio_tree_right_empty(iter->cur)); + iter->size_level++; + iter->mask = ULONG_MAX; + } else { + iter->size_level = 1; + iter->mask = 1UL << (root->index_bits - 1); + } + } + return iter->cur; + } + + return NULL; +} + +static struct prio_tree_node *prio_tree_right( + struct prio_tree_root *root, struct prio_tree_iter *iter, + unsigned long radix_index, unsigned long heap_index, + unsigned long *r_index, unsigned long *h_index) +{ + unsigned long value; + + if (prio_tree_right_empty(iter->cur)) + return NULL; + + if (iter->size_level) + value = iter->value; + else + value = iter->value | iter->mask; + + if (heap_index < value) + return NULL; + + GET_INDEX(iter->cur->right, *r_index, *h_index); + + if (radix_index <= *h_index) { + iter->cur = iter->cur->right; + iter->mask >>= 1; + iter->value = value; + if (iter->mask) { + if (iter->size_level) + iter->size_level++; + } else { + if (iter->size_level) { + BUG_ON(!prio_tree_left_empty(iter->cur)); + BUG_ON(!prio_tree_right_empty(iter->cur)); + iter->size_level++; + iter->mask = ULONG_MAX; + } else { + iter->size_level = 1; + iter->mask = 1UL << (root->index_bits - 1); + } + } + return iter->cur; + } + + return NULL; +} + +static struct prio_tree_node *prio_tree_parent(struct prio_tree_iter *iter) +{ + iter->cur = iter->cur->parent; + if (iter->mask == ULONG_MAX) + iter->mask = 1UL; + else if (iter->size_level == 1) + iter->mask = 1UL; + else + iter->mask <<= 1; + if (iter->size_level) + iter->size_level--; + if (!iter->size_level && (iter->value & iter->mask)) + iter->value ^= iter->mask; + return iter->cur; +} + +static inline int overlap(unsigned long radix_index, unsigned long heap_index, + unsigned long r_index, unsigned long h_index) +{ + return heap_index >= r_index && radix_index <= h_index; +} + +/* + * prio_tree_first: + * + * Get the first prio_tree_node that overlaps with the interval [radix_index, + * heap_index]. Note that always radix_index <= heap_index. We do a pre-order + * traversal of the tree. + */ +static struct prio_tree_node *prio_tree_first(struct prio_tree_root *root, + struct prio_tree_iter *iter, unsigned long radix_index, + unsigned long heap_index) +{ + unsigned long r_index, h_index; + + INIT_PRIO_TREE_ITER(iter); + + if (prio_tree_empty(root)) + return NULL; + + GET_INDEX(root->prio_tree_node, r_index, h_index); + + if (radix_index > h_index) + return NULL; + + iter->mask = 1UL << (root->index_bits - 1); + iter->cur = root->prio_tree_node; + + while (1) { + if (overlap(radix_index, heap_index, r_index, h_index)) + return iter->cur; + + if (prio_tree_left(root, iter, radix_index, heap_index, + &r_index, &h_index)) + continue; + + if (prio_tree_right(root, iter, radix_index, heap_index, + &r_index, &h_index)) + continue; + + break; + } + return NULL; +} + +/* + * prio_tree_next: + * + * Get the next prio_tree_node that overlaps with the input interval in iter + */ +static struct prio_tree_node *prio_tree_next(struct prio_tree_root *root, + struct prio_tree_iter *iter, unsigned long radix_index, + unsigned long heap_index) +{ + unsigned long r_index, h_index; + +repeat: + while (prio_tree_left(root, iter, radix_index, + heap_index, &r_index, &h_index)) { + if (overlap(radix_index, heap_index, r_index, h_index)) + return iter->cur; + } + + while (!prio_tree_right(root, iter, radix_index, + heap_index, &r_index, &h_index)) { + while (!prio_tree_root(iter->cur) && + iter->cur->parent->right == iter->cur) + prio_tree_parent(iter); + + if (prio_tree_root(iter->cur)) + return NULL; + + prio_tree_parent(iter); + } + + if (overlap(radix_index, heap_index, r_index, h_index)) + return iter->cur; + + goto repeat; +} + +/* + * Radix priority search tree for address_space->i_mmap + * + * For each vma that map a unique set of file pages i.e., unique [radix_index, + * heap_index] value, we have a corresponing priority search tree node. If + * multiple vmas have identical [radix_index, heap_index] value, then one of + * them is used as a tree node and others are stored in a vm_set list. The tree + * node points to the first vma (head) of the list using vm_set.head. + * + * prio_tree_root + * | + * A vm_set.head + * / \ / + * L R -> H-I-J-K-M-N-O-P-Q-S + * ^ ^ <-- vm_set.list --> + * tree nodes + * + * We need some way to identify whether a vma is a tree node, head of a vm_set + * list, or just a member of a vm_set list. We cannot use vm_flags to store + * such information. The reason is, in the above figure, it is possible that + * vm_flags' of R and H are covered by the different mmap_sems. When R is + * removed under R->mmap_sem, H replaces R as a tree node. Since we do not hold + * H->mmap_sem, we cannot use H->vm_flags for marking that H is a tree node now. + * That's why some trick involving shared.vm_set.parent is used for identifying + * tree nodes and list head nodes. + * + * vma radix priority search tree node rules: + * + * vma->shared.vm_set.parent != NULL ==> a tree node + * vma->shared.vm_set.head != NULL ==> list of others mapping same range + * vma->shared.vm_set.head == NULL ==> no others map the same range + * + * vma->shared.vm_set.parent == NULL + * vma->shared.vm_set.head != NULL ==> list head of vmas mapping same range + * vma->shared.vm_set.head == NULL ==> a list node + */ + +/* + * Add a new vma known to map the same set of pages as the old vma: + * useful for fork's dup_mmap as well as vma_prio_tree_insert below. + * Note that it just happens to work correctly on i_mmap_nonlinear too. + */ +void vma_prio_tree_add(struct vm_area_struct *vma, struct vm_area_struct *old) +{ + /* Leave these BUG_ONs till prio_tree patch stabilizes */ + BUG_ON(RADIX_INDEX(vma) != RADIX_INDEX(old)); + BUG_ON(HEAP_INDEX(vma) != HEAP_INDEX(old)); + + if (!old->shared.vm_set.parent) + list_add(&vma->shared.vm_set.list, + &old->shared.vm_set.list); + else if (old->shared.vm_set.head) + list_add_tail(&vma->shared.vm_set.list, + &old->shared.vm_set.head->shared.vm_set.list); + else { + INIT_LIST_HEAD(&vma->shared.vm_set.list); + vma->shared.vm_set.head = old; + old->shared.vm_set.head = vma; + } +} + +void vma_prio_tree_insert(struct vm_area_struct *vma, + struct prio_tree_root *root) +{ + struct prio_tree_node *ptr; + struct vm_area_struct *old; + + ptr = prio_tree_insert(root, &vma->shared.prio_tree_node); + if (ptr != &vma->shared.prio_tree_node) { + old = prio_tree_entry(ptr, struct vm_area_struct, + shared.prio_tree_node); + vma_prio_tree_add(vma, old); + } +} + +void vma_prio_tree_remove(struct vm_area_struct *vma, + struct prio_tree_root *root) +{ + struct vm_area_struct *node, *head, *new_head; + + if (!vma->shared.vm_set.head) { + if (!vma->shared.vm_set.parent) + list_del_init(&vma->shared.vm_set.list); + else + prio_tree_remove(root, &vma->shared.prio_tree_node); + } else { + /* Leave this BUG_ON till prio_tree patch stabilizes */ + BUG_ON(vma->shared.vm_set.head->shared.vm_set.head != vma); + if (vma->shared.vm_set.parent) { + head = vma->shared.vm_set.head; + if (!list_empty(&head->shared.vm_set.list)) { + new_head = list_entry( + head->shared.vm_set.list.next, + struct vm_area_struct, + shared.vm_set.list); + list_del_init(&head->shared.vm_set.list); + } else + new_head = NULL; + + prio_tree_replace(root, &vma->shared.prio_tree_node, + &head->shared.prio_tree_node); + head->shared.vm_set.head = new_head; + if (new_head) + new_head->shared.vm_set.head = head; + + } else { + node = vma->shared.vm_set.head; + if (!list_empty(&vma->shared.vm_set.list)) { + new_head = list_entry( + vma->shared.vm_set.list.next, + struct vm_area_struct, + shared.vm_set.list); + list_del_init(&vma->shared.vm_set.list); + node->shared.vm_set.head = new_head; + new_head->shared.vm_set.head = node; + } else + node->shared.vm_set.head = NULL; + } + } +} + +/* + * Helper function to enumerate vmas that map a given file page or a set of + * contiguous file pages. The function returns vmas that at least map a single + * page in the given range of contiguous file pages. + */ +struct vm_area_struct *vma_prio_tree_next(struct vm_area_struct *vma, + struct prio_tree_root *root, struct prio_tree_iter *iter, + pgoff_t begin, pgoff_t end) +{ + struct prio_tree_node *ptr; + struct vm_area_struct *next; + + if (!vma) { + /* + * First call is with NULL vma + */ + ptr = prio_tree_first(root, iter, begin, end); + if (ptr) { + next = prio_tree_entry(ptr, struct vm_area_struct, + shared.prio_tree_node); + prefetch(next->shared.vm_set.head); + return next; + } else + return NULL; + } + + if (vma->shared.vm_set.parent) { + if (vma->shared.vm_set.head) { + next = vma->shared.vm_set.head; + prefetch(next->shared.vm_set.list.next); + return next; + } + } else { + next = list_entry(vma->shared.vm_set.list.next, + struct vm_area_struct, shared.vm_set.list); + if (!next->shared.vm_set.head) { + prefetch(next->shared.vm_set.list.next); + return next; + } + } + + ptr = prio_tree_next(root, iter, begin, end); + if (ptr) { + next = prio_tree_entry(ptr, struct vm_area_struct, + shared.prio_tree_node); + prefetch(next->shared.vm_set.head); + return next; + } else + return NULL; +} diff --git a/net/bluetooth/syms.c b/net/bluetooth/syms.c deleted file mode 100644 index 20d81017f..000000000 --- a/net/bluetooth/syms.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - BlueZ - Bluetooth protocol stack for Linux - Copyright (C) 2000-2001 Qualcomm Incorporated - - Written 2000,2001 by Maxim Krasnyansky - - 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 -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -/* 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); diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c new file mode 100644 index 000000000..178822116 --- /dev/null +++ b/net/bridge/br_sysfs_if.c @@ -0,0 +1,269 @@ +/* + * Sysfs attributes of bridge ports + * Linux ethernet bridge + * + * Authors: + * Stephen Hemminger + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the 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 +#include +#include +#include +#include + +#include "br_private.h" + +struct brport_attribute { + struct attribute attr; + ssize_t (*show)(struct net_bridge_port *, char *); + ssize_t (*store)(struct net_bridge_port *, unsigned long); +}; + +#define BRPORT_ATTR(_name,_mode,_show,_store) \ +struct brport_attribute brport_attr_##_name = { \ + .attr = {.name = __stringify(_name), \ + .mode = _mode, \ + .owner = THIS_MODULE, }, \ + .show = _show, \ + .store = _store, \ +}; + +static ssize_t show_path_cost(struct net_bridge_port *p, char *buf) +{ + return sprintf(buf, "%d\n", p->path_cost); +} +static ssize_t store_path_cost(struct net_bridge_port *p, unsigned long v) +{ + br_stp_set_path_cost(p, v); + return 0; +} +static BRPORT_ATTR(path_cost, S_IRUGO | S_IWUSR, + show_path_cost, store_path_cost); + +static ssize_t show_priority(struct net_bridge_port *p, char *buf) +{ + return sprintf(buf, "%d\n", p->priority); +} +static ssize_t store_priority(struct net_bridge_port *p, unsigned long v) +{ + if (v >= (1<<(16-BR_PORT_BITS))) + return -ERANGE; + br_stp_set_port_priority(p, v); + return 0; +} +static BRPORT_ATTR(priority, S_IRUGO | S_IWUSR, + show_priority, store_priority); + +static ssize_t show_designated_root(struct net_bridge_port *p, char *buf) +{ + return br_show_bridge_id(buf, &p->designated_root); +} +static BRPORT_ATTR(designated_root, S_IRUGO, show_designated_root, NULL); + +static ssize_t show_designated_bridge(struct net_bridge_port *p, char *buf) +{ + return br_show_bridge_id(buf, &p->designated_bridge); +} +static BRPORT_ATTR(designated_bridge, S_IRUGO, show_designated_bridge, NULL); + +static ssize_t show_designated_port(struct net_bridge_port *p, char *buf) +{ + return sprintf(buf, "%d\n", p->designated_port); +} +static BRPORT_ATTR(designated_port, S_IRUGO, show_designated_port, NULL); + +static ssize_t show_designated_cost(struct net_bridge_port *p, char *buf) +{ + return sprintf(buf, "%d\n", p->designated_cost); +} +static BRPORT_ATTR(designated_cost, S_IRUGO, show_designated_cost, NULL); + +static ssize_t show_port_id(struct net_bridge_port *p, char *buf) +{ + return sprintf(buf, "0x%x\n", p->port_id); +} +static BRPORT_ATTR(port_id, S_IRUGO, show_port_id, NULL); + +static ssize_t show_port_no(struct net_bridge_port *p, char *buf) +{ + return sprintf(buf, "0x%x\n", p->port_no); +} + +static BRPORT_ATTR(port_no, S_IRUGO, show_port_no, NULL); + +static ssize_t show_change_ack(struct net_bridge_port *p, char *buf) +{ + return sprintf(buf, "%d\n", p->topology_change_ack); +} +static BRPORT_ATTR(change_ack, S_IRUGO, show_change_ack, NULL); + +static ssize_t show_config_pending(struct net_bridge_port *p, char *buf) +{ + return sprintf(buf, "%d\n", p->config_pending); +} +static BRPORT_ATTR(config_pending, S_IRUGO, show_config_pending, NULL); + +static ssize_t show_port_state(struct net_bridge_port *p, char *buf) +{ + return sprintf(buf, "%d\n", p->state); +} +static BRPORT_ATTR(state, S_IRUGO, show_port_state, NULL); + +static ssize_t show_message_age_timer(struct net_bridge_port *p, + char *buf) +{ + return sprintf(buf, "%ld\n", br_timer_value(&p->message_age_timer)); +} +static BRPORT_ATTR(message_age_timer, S_IRUGO, show_message_age_timer, NULL); + +static ssize_t show_forward_delay_timer(struct net_bridge_port *p, + char *buf) +{ + return sprintf(buf, "%ld\n", br_timer_value(&p->forward_delay_timer)); +} +static BRPORT_ATTR(forward_delay_timer, S_IRUGO, show_forward_delay_timer, NULL); + +static ssize_t show_hold_timer(struct net_bridge_port *p, + char *buf) +{ + return sprintf(buf, "%ld\n", br_timer_value(&p->hold_timer)); +} +static BRPORT_ATTR(hold_timer, S_IRUGO, show_hold_timer, NULL); + +static struct brport_attribute *brport_attrs[] = { + &brport_attr_path_cost, + &brport_attr_priority, + &brport_attr_port_id, + &brport_attr_port_no, + &brport_attr_designated_root, + &brport_attr_designated_bridge, + &brport_attr_designated_port, + &brport_attr_designated_cost, + &brport_attr_state, + &brport_attr_change_ack, + &brport_attr_config_pending, + &brport_attr_message_age_timer, + &brport_attr_forward_delay_timer, + &brport_attr_hold_timer, + NULL +}; + +#define to_brport_attr(_at) container_of(_at, struct brport_attribute, attr) +#define to_brport(obj) container_of(obj, struct net_bridge_port, kobj) + +static ssize_t brport_show(struct kobject * kobj, + struct attribute * attr, char * buf) +{ + struct brport_attribute * brport_attr = to_brport_attr(attr); + struct net_bridge_port * p = to_brport(kobj); + + return brport_attr->show(p, buf); +} + +static ssize_t brport_store(struct kobject * kobj, + struct attribute * attr, + const char * buf, size_t count) +{ + struct brport_attribute * brport_attr = to_brport_attr(attr); + struct net_bridge_port * p = to_brport(kobj); + ssize_t ret = -EINVAL; + char *endp; + unsigned long val; + + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + + val = simple_strtoul(buf, &endp, 0); + if (endp != buf) { + rtnl_lock(); + if (p->dev && p->br && brport_attr->store) { + spin_lock_bh(&p->br->lock); + ret = brport_attr->store(p, val); + spin_unlock_bh(&p->br->lock); + if (ret == 0) + ret = count; + } + rtnl_unlock(); + } + return ret; +} + +/* called from kobject_put when port ref count goes to zero. */ +static void brport_release(struct kobject *kobj) +{ + kfree(container_of(kobj, struct net_bridge_port, kobj)); +} + +static struct sysfs_ops brport_sysfs_ops = { + .show = brport_show, + .store = brport_store, +}; + +static struct kobj_type brport_ktype = { + .sysfs_ops = &brport_sysfs_ops, + .release = brport_release, +}; + + +/* + * Add sysfs entries to ethernet device added to a bridge. + * Creates a brport subdirectory with bridge attributes. + * Puts symlink in bridge's brport subdirectory + */ +int br_sysfs_addif(struct net_bridge_port *p) +{ + struct net_bridge *br = p->br; + struct brport_attribute **a; + int err; + + ASSERT_RTNL(); + + kobject_set_name(&p->kobj, SYSFS_BRIDGE_PORT_ATTR); + p->kobj.ktype = &brport_ktype; + p->kobj.parent = &(p->dev->class_dev.kobj); + p->kobj.kset = &bridge_subsys.kset; + + err = kobject_add(&p->kobj); + if(err) + goto out1; + + err = sysfs_create_link(&p->kobj, &br->dev->class_dev.kobj, + SYSFS_BRIDGE_PORT_LINK); + if (err) + goto out2; + + for (a = brport_attrs; *a; ++a) { + err = sysfs_create_file(&p->kobj, &((*a)->attr)); + if (err) + goto out2; + } + + err = sysfs_create_link(&br->ifobj, &p->kobj, p->dev->name); + if (err) + goto out2; + + return 0; + out2: + kobject_del(&p->kobj); + out1: + return err; +} + +void br_sysfs_removeif(struct net_bridge_port *p) +{ + pr_debug("br_sysfs_removeif\n"); + sysfs_remove_link(&p->br->ifobj, p->dev->name); + kobject_del(&p->kobj); +} + +void br_sysfs_freeif(struct net_bridge_port *p) +{ + pr_debug("br_sysfs_freeif\n"); + kobject_put(&p->kobj); +} diff --git a/net/tux/Kconfig b/net/tux/Kconfig new file mode 100644 index 000000000..8b6d62420 --- /dev/null +++ b/net/tux/Kconfig @@ -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 index 000000000..fc0bbd0a5 --- /dev/null +++ b/net/tux/Makefile @@ -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 index 000000000..7447e698c --- /dev/null +++ b/net/tux/abuf.c @@ -0,0 +1,186 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * abuf.c: async buffer-sending + */ + +#include + +/**************************************************************** + * This program is free software; you can redistribute 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 index 000000000..16f611cf1 --- /dev/null +++ b/net/tux/accept.c @@ -0,0 +1,859 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * accept.c: accept new connections, allocate requests + */ + +#include + +/**************************************************************** + * This program is free software; you can redistribute 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 (tcp_wspace(sk) >= tcp_min_write_space(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 (tcp_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 index 000000000..f840583bb --- /dev/null +++ b/net/tux/cachemiss.c @@ -0,0 +1,264 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * 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 +#include + +/**************************************************************** + * This program is free software; you can redistribute 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(¤t->sighand->siglock); + ka = current->sighand->action + SIGCHLD-1; + ka->sa.sa_handler = SIG_IGN; + siginitsetinv(¤t->blocked, sigmask(SIGCHLD)); + recalc_sigpending(); + spin_unlock_irq(¤t->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 index 000000000..fda4d3825 --- /dev/null +++ b/net/tux/cgi.c @@ -0,0 +1,173 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * cgi.c: user-space CGI (and other) code execution. + */ + +#define __KERNEL_SYSCALLS__ +#define __KERNEL_SYSCALLS_NO_ERRNO__ + +#include + +/**************************************************************** + * This program is free software; you can redistribute 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(¤t->sighand->siglock); + flush_signal_handlers(current, 1); + spin_unlock_irq(¤t->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(¤t->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(¤t->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 = ¶m_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 index 000000000..714800e7b --- /dev/null +++ b/net/tux/directory.c @@ -0,0 +1,297 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * directory.c: directory listing support + */ + +#define __KERNEL_SYSCALLS__ +#include + +/**************************************************************** + * This program is free software; you can redistribute 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 index 000000000..1d1d1d5cd --- /dev/null +++ b/net/tux/extcgi.c @@ -0,0 +1,329 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * extcgi.c: dynamic TUX module which forks and starts an external CGI + */ + +#define __KERNEL_SYSCALLS__ +#define __KERNEL_SYSCALLS_NO_ERRNO__ + +#include +#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(¤t->sighand->siglock); + ka = current->sighand->action + SIGPIPE-1; + ka->sa.sa_handler = SIG_IGN; + siginitsetinv(¤t->blocked, sigmask(SIGCHLD)); + recalc_sigpending(); + spin_unlock_irq(¤t->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, ¶m, 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 index 000000000..5476dff52 --- /dev/null +++ b/net/tux/gzip.c @@ -0,0 +1,40 @@ +/* $Id: zlib.h,v 1.2 1997/12/23 10:47:44 paulus Exp $ */ + +#include +#include +#include +#include + +#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 index 000000000..054c3edb1 --- /dev/null +++ b/net/tux/input.c @@ -0,0 +1,641 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * input.c: handle requests arriving on accepted connections + */ + +#include +#include + +/**************************************************************** + * This program is free software; you can redistribute 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", tcp_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 : "", req->uri_str ? req->uri_str : "", req->query_str ? req->query_str : "", req->version_str ? req->version_str : ""); + 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 index 000000000..5ce80c17e --- /dev/null +++ b/net/tux/logger.c @@ -0,0 +1,855 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * 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 + +/**************************************************************** + * This program is free software; you can redistribute 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 "" + 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(¤t->sighand->siglock); + siginitsetinv(¤t->blocked, 0); + recalc_sigpending(); + spin_unlock_irq(¤t->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 index 000000000..e33241fec --- /dev/null +++ b/net/tux/main.c @@ -0,0 +1,1413 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * main.c: main management and initialization routines + */ + +#define __KERNEL_SYSCALLS__ +#define __KERNEL_SYSCALLS_NO_ERRNO__ + +#include + +/**************************************************************** + * This program is free software; you can redistribute 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(¤t->sighand->siglock); + flush_signals(current); + recalc_sigpending(); + spin_unlock_irq(¤t->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(¤t->sighand->siglock); + siginitsetinv(¤t->blocked, sigmask(SIGKILL) | + sigmask(SIGSTOP)| sigmask(SIGHUP) | sigmask(SIGCHLD)); + recalc_sigpending(); + spin_unlock_irq(¤t->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 index 000000000..14891140e --- /dev/null +++ b/net/tux/mod.c @@ -0,0 +1,262 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * mod.c: loading/registering of dynamic TUX modules + */ + +#include +#include + +/**************************************************************** + * This program is free software; you can redistribute 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 index 000000000..2d0f073fe --- /dev/null +++ b/net/tux/output.c @@ -0,0 +1,352 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * output.c: Send data to clients + */ + +#include + +/**************************************************************** + * This program is free software; you can redistribute 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->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.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.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 index 000000000..f355c1e14 --- /dev/null +++ b/net/tux/parser.h @@ -0,0 +1,102 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, Ingo Molnar + * + * 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 index 000000000..d4a693b93 --- /dev/null +++ b/net/tux/postpone.c @@ -0,0 +1,77 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * postpone.c: postpone/continue userspace requests + */ + +#include + +/**************************************************************** + * This program is free software; you can redistribute 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 index 000000000..2973a482b --- /dev/null +++ b/net/tux/proc.c @@ -0,0 +1,1190 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * proc.c: /proc/sys/tux handling + */ + +#include + +/**************************************************************** + * This program is free software; you can redistribute 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"); + 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 index 000000000..fbb9d8eef --- /dev/null +++ b/net/tux/proto_ftp.c @@ -0,0 +1,1549 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * ftp_proto.c: FTP application protocol support + */ + +#define __KERNEL_SYSCALLS__ +#include + +/**************************************************************** + * This program is free software; you can redistribute 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 index 000000000..192dd4f08 --- /dev/null +++ b/net/tux/proto_http.c @@ -0,0 +1,2199 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * proto_http.c: HTTP application protocol support + * + * Right now we detect simple GET headers, anything more + * subtle gets redirected to secondary server port. + */ + +#include +#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" + " Forbidden "; + +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" + " Page Not Found "; + +#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" \ + " 301 Moved Permanently " + +#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 "\ +\ +Index of %s\ +

Index of %s


\n%s" + +#define DIRLIST_HEAD_2 "\ + Parent Directory\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 "\ +

Powered by Linux/TUX 3.0
\n" + +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("\"[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("\"["); + 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("\"["); + 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("\"["); + 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("\"["); + 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("\"["); + else + COPY_STR("\"["); + break; + case DT_LNK: + COPY_STR("\"[LNK]\""); + break; + default: + if (tux_hide_unreadable) + goto out_dput; + COPY_STR("\"["); + break; + } + +#define LIST_1 " " +#define LIST_2_DIR "/\">" +#define LIST_3 " " + + 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 index 000000000..86b5300fb --- /dev/null +++ b/net/tux/redirect.c @@ -0,0 +1,154 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * redirect.c: redirect requests to other server sockets (such as Apache). + */ + +#include + +/**************************************************************** + * This program is free software; you can redistribute 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 index 000000000..3388f6387 --- /dev/null +++ b/net/tux/times.c @@ -0,0 +1,392 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * 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 +#include +#include +#include + + +#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 (Izulu) + 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 (YTUX_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 index 000000000..09c389f92 --- /dev/null +++ b/net/tux/times.h @@ -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 index 000000000..effd45d3a --- /dev/null +++ b/net/tux/userspace.c @@ -0,0 +1,27 @@ +/* + * TUX - Integrated Application Protocols Layer and Object Cache + * + * Copyright (C) 2000, 2001, Ingo Molnar + * + * userspace.c: handle userspace-module requests + */ + +#include + +/**************************************************************** + * This program is free software; you can redistribute 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. + * + ****************************************************************/ + diff --git a/scripts/basic/.docproc.cmd b/scripts/basic/.docproc.cmd new file mode 100644 index 000000000..e725e6b22 --- /dev/null +++ b/scripts/basic/.docproc.cmd @@ -0,0 +1,69 @@ +cmd_scripts/basic/docproc := gcc -Wp,-MD,scripts/basic/.docproc.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/basic/docproc scripts/basic/docproc.c + +deps_scripts/basic/docproc := \ + scripts/basic/docproc.c \ + /usr/include/stdio.h \ + /usr/include/features.h \ + /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.2/include/stddef.h \ + /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h \ + /usr/include/libio.h \ + /usr/include/_G_config.h \ + /usr/include/wchar.h \ + /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h \ + /usr/include/stdlib.h \ + /usr/include/sys/types.h \ + /usr/include/time.h \ + /usr/include/endian.h \ + /usr/include/bits/endian.h \ + /usr/include/sys/select.h \ + /usr/include/bits/select.h \ + /usr/include/bits/sigset.h \ + /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h \ + /usr/include/alloca.h \ + /usr/include/string.h \ + /usr/include/bits/string.h \ + /usr/include/bits/string2.h \ + /usr/include/ctype.h \ + /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h \ + /usr/include/getopt.h \ + /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.2/include/limits.h \ + /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.2/include/syslimits.h \ + /usr/include/limits.h \ + /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h \ + /usr/include/sys/wait.h \ + /usr/include/signal.h \ + /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h \ + /usr/include/linux/compiler.h \ + /usr/include/linux/compiler-gcc3.h \ + /usr/include/linux/compiler-gcc.h \ + /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h \ + /usr/include/sys/resource.h \ + /usr/include/bits/resource.h \ + /usr/include/bits/waitflags.h \ + /usr/include/bits/waitstatus.h \ + +scripts/basic/docproc: $(deps_scripts/basic/docproc) + +$(deps_scripts/basic/docproc): diff --git a/scripts/basic/.fixdep.cmd b/scripts/basic/.fixdep.cmd new file mode 100644 index 000000000..1c463aa74 --- /dev/null +++ b/scripts/basic/.fixdep.cmd @@ -0,0 +1,74 @@ +cmd_scripts/basic/fixdep := gcc -Wp,-MD,scripts/basic/.fixdep.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/basic/fixdep scripts/basic/fixdep.c + +deps_scripts/basic/fixdep := \ + scripts/basic/fixdep.c \ + $(wildcard include/config/his/driver.h) \ + $(wildcard include/config/my/option.h) \ + $(wildcard include/config/.h) \ + $(wildcard include/config/foo.h) \ + /usr/include/sys/types.h \ + /usr/include/features.h \ + /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h \ + /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.2/include/stddef.h \ + /usr/include/bits/typesizes.h \ + /usr/include/time.h \ + /usr/include/endian.h \ + /usr/include/bits/endian.h \ + /usr/include/sys/select.h \ + /usr/include/bits/select.h \ + /usr/include/bits/sigset.h \ + /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h \ + /usr/include/sys/stat.h \ + /usr/include/bits/stat.h \ + /usr/include/sys/mman.h \ + /usr/include/bits/mman.h \ + /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h \ + /usr/include/getopt.h \ + /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h \ + /usr/include/string.h \ + /usr/include/bits/string.h \ + /usr/include/bits/string2.h \ + /usr/include/stdlib.h \ + /usr/include/alloca.h \ + /usr/include/stdio.h \ + /usr/include/libio.h \ + /usr/include/_G_config.h \ + /usr/include/wchar.h \ + /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h \ + /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.2/include/limits.h \ + /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.2/include/syslimits.h \ + /usr/include/limits.h \ + /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h \ + /usr/include/ctype.h \ + /usr/include/netinet/in.h \ + /usr/include/stdint.h \ + /usr/include/sys/socket.h \ + /usr/include/sys/uio.h \ + /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h \ + /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h \ + +scripts/basic/fixdep: $(deps_scripts/basic/fixdep) + +$(deps_scripts/basic/fixdep): diff --git a/scripts/basic/.split-include.cmd b/scripts/basic/.split-include.cmd new file mode 100644 index 000000000..e596a8729 --- /dev/null +++ b/scripts/basic/.split-include.cmd @@ -0,0 +1,57 @@ +cmd_scripts/basic/split-include := gcc -Wp,-MD,scripts/basic/.split-include.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/basic/split-include scripts/basic/split-include.c + +deps_scripts/basic/split-include := \ + scripts/basic/split-include.c \ + $(wildcard include/config/.h) \ + /usr/include/sys/stat.h \ + /usr/include/features.h \ + /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h \ + /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.2/include/stddef.h \ + /usr/include/bits/typesizes.h \ + /usr/include/time.h \ + /usr/include/bits/stat.h \ + /usr/include/sys/types.h \ + /usr/include/endian.h \ + /usr/include/bits/endian.h \ + /usr/include/sys/select.h \ + /usr/include/bits/select.h \ + /usr/include/bits/sigset.h \ + /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h \ + /usr/include/ctype.h \ + /usr/include/errno.h \ + /usr/include/bits/errno.h \ + /usr/include/linux/errno.h \ + /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h \ + /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h \ + /usr/include/stdio.h \ + /usr/include/libio.h \ + /usr/include/_G_config.h \ + /usr/include/wchar.h \ + /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h \ + /usr/include/stdlib.h \ + /usr/include/alloca.h \ + /usr/include/string.h \ + /usr/include/bits/string.h \ + /usr/include/bits/string2.h \ + /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h \ + /usr/include/getopt.h \ + +scripts/basic/split-include: $(deps_scripts/basic/split-include) + +$(deps_scripts/basic/split-include): diff --git a/scripts/basic/docproc b/scripts/basic/docproc new file mode 100755 index 0000000000000000000000000000000000000000..51640ad93660a5e29ce19452befa76d58d827f84 GIT binary patch literal 19832 zcmeHvdwf&Jnf6FJ5^@l>z(Am(L;;bK7Rxrb040gRHpGp=@&!YhW`!)tmOz$NUASyQ zVrpn2RBv38ZPRYrg{GU*ZMvb|Cgqppqb8=I?QXj?y>63c+1>Q3sL6&l38785-shP) zM?QA5rI-D_-~Pd|=gd6wzVpsI@4PcQXXc!9cVqK9i^U?0!zyfoD0PqKT#ERC6^gP{ zc*G>JP+TMC3J0=CTiOR6gfmDp*by`Y8^Ux5nZ8$ZGE@RHkVe@I@<3TZ8Pg#Pf#ro; zr+bh-1UiBr1^iQlte12vNG{M_pfP+6n1On+4u*v&vk-MNcz_uUTI)};VZh%yjPlj- zSXXsCTosQca=Uz)q;Ih*i>jsW>o;zaWvK@P^`44w6#~?hM;Xp+vvJHuqCy8(AfAO# zjxYn^N(2|e+Yo-&LAx3U+rqkeP;VYi6-gZ@>FH^RC+lhI2s4YB2yBbAH)8V<1#o{* zb2cDm*@Xxm;A5~S@eK$yz?4B8LZ}1YsN>~`{lG8in00Rj9?@|%;uP?Gx;)x!>tW5w z_DqFlI}nFWxDmJy{KJS@A8k4ae5a1*AwC4WM3;99@KNA-IzA3O1bhU>V);iAP6PiG zF>xEh8Q>P3ek1UC;CJctBw~TF5Y*+p7tjs7MyDS{>;XQZ{x*sJ4D zAl`S-Xm7bF0Q*7r=<@dfZw20pnEFwUad?=3Z-(fT%S9@e4Ml@#u`?LUrea}{$%d1; ztmy8EWHTZaNvD%((Ho4%lOfUF9nWQ=qC1t2C9>V3I}?d)2Y(v>A{|jYfdEiAmlEB{ zv?PXlkq*U^nFvKgo(Kd&+1;r~perDS?o7wB5fRxHL#4@7Bq0J#Ef5lpB?7rjBn);c zi=1FO8|V$j65x%5c0g)65&^ZRH<{3>0kOWhX>EOAv2RH!Ra;8cu;JEA{@HX6&R|wK z+Bsg;d`5rgQ5lP2h-%`Wk!IdhiEZNFb?lbdDqaTW(F|X7U|`Zm?HFM6O*;nnYnXQ? zq0cTdhVT5EF$XBFiV+=|+V@v?k8BfMMz!-yn4r6HMVT_5v%NP^J zLdH;Z5n~MC8pd#prHnBcRxrk(Udf|5^TD`(HZm?`Vsj{xB$gIJI_0Q}=1k z;!UXkwZTF3ReKQy#BF{{`gh0+u6hEAzgFy#AAmh6l3OivDx64sWIW;ursux$fe}5$B)jzc`v*1I0R9 zw~2uUuiM{N{I+5!GV;t@rB2iSntnGn>%YqA;eXvVxg6<>{)u8MQWcPcmlcz z*^q_)f|TPgR{dHUG5-sgZp!-pVORgNu9dIc`Ome_!5sP1(CGGIRdC?xcd$IvQ z4~-}9Jvj$iQcEi(gMeHyxR;7<6)rYNt4HW$D0 zrY@;s-xtxg&d%tQD7CrxWtE?QmZcs8rML-l3hoi>;JO2ID~=Ce(AGM0ul2nd$i7ls zrATGUOgg<`t;LgjweQV^xr4>oU|5I3mUR`!9Tz0!^`eH%{Hq1$h^78OWySGlE@*2g z@mG-etWC7Gb{0Ckv)YQESI$w=cuGm*{Tpe9bFNLrTUDOP7VYiPf0PaRk6)?oWkdE~ zj{J1J)jo$FsC}LuHAVU*oOb0uz{pPc zffuoM_l#rrLf)D|c6(uA|B%b_v!>hylo-&y=Z5wC#cNG^?E4t9PH7K*7BxSGUm9_$ zPJ0Py>D2p&?z#cvjvkvoA?0b_+UE*U=gOb$nN`@O4Wd#luYIzrsRpl$vkhW5ErWPEt#Y7I>>J9xtFX`Omt0Tt0$t=Ap5_dUi4IDf zg?4*SHiIk&!o9=A&#+-9MrLDJKCAgkvezBZeD@CT8_Is6;`nz8mJ1DjIO&UMi3?-t z-%dd$H6PG?>#2=V&-#&5rtz%CqYJ|)|I?AH^B4LrHdO5UI(SR=acv%*ar5Unue<$F z+Y45|KHgd`N_XU_dKE?bR(r3>eXHVlgV!>U^;-KcHs)W?`Vrmr+5U^`D)xN}JpC7& za-SQSR{SoCQfr~Ko`i9>@A+I2MtIgCHjU1xLyaRJ%3mmc?h=g6V3b!5YP=TjxCDO# z`FZ7_^WXB;{LrFU1JcBS-qzL$?N(682%P~xkLu^^)eG#k()2ZGjJNzxFy6q1Yk>Ye zPFuzPPr@wXYJ5|HMTc?I7kV+I61}}!sBlA|E~*s&gW0O`bfq8+aVdh7mcn$ zozow^613uvp*3cTQ+D=n-2wQiotAgY6iusAG@44WCUEc)gBJYVRH=fV`V08M?LgV>$D}R%I9lzt!n&bSd zi0XOuI7La*1wADNT|9Box_@XOHJYm|wt=lAKwdwLPXBWL{Kox5xeLW*CSvIth}WiV zPkk3xhKG6LWtppgL>oO_upym$ZOd)950l5xpn!WBf3Xv0yA>C%RBQZ!Sxw%pjn5rJ zn=-+k$SO}b8A_#-ADGW;49U(;bUP=x@L4XiDHV*%QlnaGM+Ubf=TOvY0R1 zn~M89ExD{t&O{PfPd4dMH_>BKQQs;SOJq@{XJ<5$@bp9yk#sN{OZ0fQN79K%oZ97j zApn`l#8_GCrF30o6pDD_u}s#J?3P+ktL{iTk_bg0JC=>c5_+TLJvi@{J(*BCmda+T zRaI4}N|Y_gh_qwwBKd+%e2cDxNL#T7PxGI z%NDq7fy)-SY=O%bxNL#{#TGb&n>nseF>q<9xLFd zoV*=)0|DDuaxaa0**thpSA;y?1Rq7+9=Rc^2Z4f$Ka=d`o5mVfKdw=%^6bUgDheh3ZMt9oC-_x8ikW4sB98Mz=+Au!6E?NU z7L`m)amzs|cMui&eASuV8Qel=s$)x5EU%8lyQ}5yx367PN0Ysg>YlFZbgH*{?WU&Y zhUy+}k5^&K+qa}Tl*tJ=iDyl_XR)t#sc$8`!gsx}^gRd_ta1oxmiMDBHjKfCnx9A8 z;~0$=>puZmzgGjgZ3%{-HpzMnt+LHq%bZW)WN}(=V$S>y=G=#qb&~Z_l(KnQ%KBas z7q9}GPYGC#;ci>l&zw)=WN}#epo#4|inM-=$#)(i@nw{>+N~`pWqTK;TR+c|i~bLi z8Xh+gn%(+0lwKt(`VDlpE&dTpjw07-x1OOEOU^OpItambdMnxAO&)8IVpo%BeS^98 z%48jL^HSc&SlI!YoJ@uS+hCo+T0SIs+nF4Y3|-{?3z@8BrT6iv4x0vH&~YY-gR;`= zDd@v&fc-DQ;j|red=tQSkjOe;h)I8g1nEvD@Qi_O^biXkyo+3)VYTBaXYNNO?@=Znl(~G2!1ghjdlPm0D^_TYGx?C>Wo@63xrdp1NG1oF z`>;%YgH=2tc_U1IPA0FX+(%_Yn^^2IsaXSak4nv!k@xRq?t7U0lFYq|$tR@T5PSd0 zC^D??W3i_`i#p3RuK8OxkoNSGGGmCUd=9yAo?p`lUy;RcrKD%r#w)HyaciT6dR_5e za9F!6%%40RX-#W)U0~dL7IIuSGucLhnB>Ko!ln6b!rlbz)H)nZ$kR5;O6Cj4cfhK( zzm7cXd`(yf&{(a5MeVzBa@prPx>3D-PA3}z{uSW2zn!uq|03|)=W_GL{#l&d_W6qc z8rg7zf1cuZ3hM_U#y)=^Sf~6FC(Utfc@-pz@=9o6DgQW|TFxI)Tlp`*s+Gr)Z!iB6 z(vEWeMoud4!P!~913YD7N;wK>juqwaKx`@hAu{m@%oQ-N%r!JlBXe_{(+|-@FZDyLcuNIoJ!6U&|tOWCdaoBJ93X;kAQX2?(DCBmWBIh2eZJj^e;emX|T|dUzI)9eq7-imVlQQQx z{)4nWuS6clJj&dsYVbN$#Ug*3+ph#pj;oQ`=E{E$K}M*-y>YHZDSI~K6X zpL$f9YPxh8$HU46W;rghS)cj1q2FF!c(al7+s>LUbxs zHB;_i@I?1S!(K*u8V7Zmb`i-kO*-IVc1*YoCN0w{aIWy;q$DuqCKE`q+vDVoER($N z#<_AmdEKOmsqB?0V3_V$>-bkPZljIp?%yQZevd?&<01A){GH&YyGy6)mD1tvY?LFR z`qzzGDSt)^1uSLSA*9PRdcxGRNPYlyIvt;PJdfD%cMEW4Rck5yF%DFYEGhgbxlxsv zbP)+U?M(ir2q|^te~7sV!oEWK`(}z;DSyU0A=AE!)A5yeLSxJ9kD!>v zZsX&N)5t9DMzD%mP*k(9X_vUh>B`0MRBde8iskCjT3+;2htk>DpKy7kRN<n&rhm zUWLS;pn_$pa66`2rde#xtDFm*l`xyIOtrWj({Q$xUsb-Kyb_nB)|r_2S51ERR2Ka&xIqxq^H~xjD@PZVtDix`8z|I-Y%Ik?gvnu zgjgt<*datL5zG2QP=rs`h9lj+C>zFSYcohet0!)?cs#epoIG0w(%BQmkR zzGY))plM@$%LadQV@D&B{!Ja=P=uCSkc5+E<%7wzF@(gjf$k8bK%mT_z;ry;yL_ox zWOH-l`ZdjghQ{{#wkCf^OB=XkFF`_gQe>jZbk>tgWMVxDZ1eJts08Hm+W|f;4f)}W zlp0Fru-VLqt!3ST9lKyHtHwHn}sT zOG$QjOWsT-_UFnVvau<{6;WFT`{|)XRAGS$b{16D`$spX(K)E3q;NJFNCbOngdB?Kf@5K+ zj4Iu@!QXLfsbfQY0zH;Uniw{=&k~bHSeFip3L;U_+&>+Q= zi5}#1XU5gMZc}q}pk-5saw$`XWRqZ~6Q-qTY4q+Kdz6jPopgI-w_dUC5XxNaYA|M^ zn3DogOh<7xz88%9%(%Da>a!;u{jLj^tZq;hrBOS6ZA*&syVHG!^Nw~4dlkg7;d zZyRQzE?raUYCA#J6)joBEPkw4yW_zgc&T0!@{tZDd%I#70!W$*jSVx?hzs;4!+K|D zrREqP*~l(^JO)&r8Xp{xQYmN)(NHm!)r~!FT)`8h&&a7&7SLU;J&M^*dRprK(hP42Aw<5G%YBJW}0lkaN z7J7d!lHM(c%OxguE+R<_=xs1++t9cH`IrLqeAC3RKEP2bm4K=%WFlN@qG1GPuQz*a z0`EpC)iXO`Cs|B4=f;l4wvCt%8{69CREQr!POFloM|UjQay^Y|^VMybUD-9Vyzpgq_hy4#h_h)GM~#&9n3V7(lG%uF&Dy4_Y_Lc8qCvdB;|uRjprDHJ z>W&Xr6}}yjbcWCHm_Y!vbRlr?*9`ztQZ~{TiQ<=obE{8blneI8 zLc$lyCeyf%39D#Zh;=4WyeorT3}`;}1ahP+*Aob0p!P(_EnzCx#SvV>^2g9%?dnQL zb{L%SCDtrU@r|V4_u#u@yd>cLi+tA*09T@=LtZWb%}2nEkmQr^1cKlJHV#}>$)gr$ zURF^a_d9L|-!Y^OI%9_G5pV@8`M3|l#8L3d3xA!5*Pk~b-~vwaao^-90QXCb14ZPq z9%t@(uwL$W96=?^kv8gOJ_GN{xJSY?_esuxp$=(ty?`QwfQ4>ZhWjiYFmRv6kjI#J zgK-3dkNYw!z;{&VWBUxg9MaSkw}x_koy!&6%P|f^ZVDL&pTJ%T3-IpPILOCv2ZF)J z3;7f}=Oxp#WwafSy$A*$uSYwuVe~dhQ75C`dvre9r4M|4;CsweuSc;9u6i?@d^LC$ zvj&T9h77V8X+FSCKK32oKNTLeCq~G_;QMQ&X%q6vcTqj+JyiAw5AxB@M-U8od}#8! z9+i)5c^L8@12Xtt0N)Fqx8{4o#K(7ZUIL#X1Ef;=DH9*}Ye$@}0uA$A#s5VI~GKSnU~x#tV9KvLAn zpuIeSZyES-zgRj9zF$t@tH<)|3WI2(@x47$wz$J5#1=Y*ei$_F5inh&=YI!@huPu! zK^ntU1lrCxc3^^-OM-qFNyesX#M3w6T~-W05Axd(*cbGDj!Cn;W=s%^Ce#a-w>&rx zlAzvtRPR75tZL@Grm$WE=P${xJc#p@!pe({{a2gxbT#iNItDEc&MykfNbc_{%vPxR zLSenbI4|I^>2D=-{40#51RNaa3Qv)k<5^)mNQ{HyR^bYX<@iL(CM~DNp`x=_gy48n z7?T1Hjw^-LF9pYs!d!uez9p=7vpF6VeWs)vC)>Cgko9wh9Xo6SFYcKR+qjvF{QUJA zJ8XhGo@0kiynPHHWy5>-=EEkgHbc-o(ie?PP5gY+m`9mMZ1|ypn+#^1&fgc~Ab-FB zh>0iCC(55lpIF~S{)zNU>GO#R`h0o<{+9{(ZKevS|3rQhS+?&F)o-FaZVhljglbsv z6b1LujDz*p0UQ2k!Q0&%fenAO;L7EFz=l6su;m*A=DVAeVS#`50?QXSC7vmE0}q+% zyAN30``_39SD^o}ByXBH0?g+=l>AEZIIuCkEcjZ%FtAx4ZZg;CWOKm2eOFft7qAxL;KV%mq8nMt=+J z2Yx}vPXinCnH&0lllViLvkZn}eLn)`t1GI$nc`=_d<)0W|L4G(-k(#gZt)vnzGJ*u z%6Ex!O!=!#<>vrzMg1ds{nfyHamJ9p2AFT#u%B4}Ex=p?1O&c9v;wD4o_@#ngn;=j z5Pvzyza5zKry*|-FyEaq@O{8_CixEnH<;@GG;kl}4@-GMJPteve5a1T25kI(u)co+ zu0j9S>Gi(|d-$F9#_GSOP z84AV%xYM>hlWy>332KsxuzPea~MCBG26fz9#`0G|Qf_!h+{Omq(< z9sxcN`n&YxdKK41^zozUgo2+Y^5jQae*`K+f4gwaB}G7cF1IN-Q6Gs0`*uu4>UKmcLV}J4dc*z>Pw`QuSUSssdywC z3Hxfn8cqg!;>j+ov&p53KrpupUm3yjLm-^%?cHsNZrs=~CfNY%+SY8qa*|GBHAZ?& zs$2(=QvXN;a{EGmBMU9XA`V|(n9b>o^1P4(CzO5;l` zb#=xEQffqw@5Bi#+y$aL^$)$6$@*7b#%1A?F5|HL9*j8$E86HEtl^}CySbu9WsR4@ zG9rVQ-Qtlkj3qHV5Lc1LZ;5szv*M<;liFSP<;i+OjJFlKK3(~UyHXFyMwuSR<^_VKF}Dw z2EL1ZoXD;ecDQsiW#l)00_tr=49k#61=E=bD!}H2VNnVA-5|3pIKEsdA9II5L@mLt zZ*EzO1?84?>)IPT0v&7CHa7<3H-yZ^rPIpK5RK(>W-wVsH}&`>`fm9Zqp>nI@`FZP xvd(dN-(Q5-v+NxK2>ur5qZzKrXTU)fx+j~{|yY_au_^gWJEBF7OIcIYcZPoVP zd-gYH=0D#z-+c4UH?wDE&bg+pahb(p5yoW|HbJ!btD3V4@qy`zQYGACl$a(?7gK}- zS)^6m3|iA4(;>i*T}JuJShTG&7MdB0#xt9} zsf71jRTfoC-RoDZl4Yp}1NDYFVgf=D0xu^5?Jyc)6aw2{j8KX|J;osz7t2ycxsfp< zW*wjP8Usc&on{hc2qg&8Zivm-ZUE0V&G`hFsY?Yy74Qbc#NR`x1-?SZCnIhJen{u9 z1`YvF)ah=-Y2bM}W?Q!cFVJxV;$7d-oNW78F;R39gMOwiZx`@gz>gwk{nsHp2>d4< zFF||&cqNQMI_3Tf_#B2nRr*ATXcoHg56t0cQ~0$Bt;jq{Qh8iOLy3xPQ((M z!byKD5fts+$!I*?E|TFuj5w7Jp+teTO)+gsM$=&t-W*MX(!M#B4j|F6(hu%v+@DE> zL&&EJ$O$CV{;ohY4pGTiI4%<1xFH>kBtfrDm7hg&u<1;}Owz}Q$48@ZJDYe+&vQv^6$eSgwFCX`fOE6|?HCx1h(|$yk1_hQ zl`#g(TE=jY^^7qfHZX?sh8SZIMHpj%#Ta8?bu)&er5VG~H#3GNS24yw>tT#Ru$3_e z#CFE$%o`bFK(5OEvG-+X{!*xtKfs$GLZ2QGgL7-aF<5aS?$m#c(=rCS!5dV4vE>q2s`0ukHlfryWIvBb1QWG(S5iD{9@24c6wv`mBzI_i>`7K(He3yEo|$Y$c# zKSD+YEf(n^J_3xmaLs<@vg{vvUwYlw+8l9VJVpAyra7BdN4gQ^TTu3`9Xnv>mOM+W zyLRB0rwGxU>!q&S`qS3I!)w<)J+Ncw0_Wb;^PEmg0{Ead1&3*bpveE9@d`wa7g1yYMegP(0A3E)h%nJ*xX#|lpV;$ zJd-VNE}niYt9hz_msQ zca>+-n|GIeYk%3!{)cIq`TNtQL&cI$&we`l)FtaK^Itlkca(0gmfn}kVGws;jm4LL zQMRi@HD?T4*J61p*Xo(n?8~n~8zjLpAl1#DN_7uvw$U z%sFqESoZk-%I>{TA^*nNF9A0FEacdzx7Oh4GS?1T?a zQobgCgL2-Ze%LU39L>TKAvPY>qiUo$4|&X$%nW6ZOBt@ zYx2hj&HmWAAp7=e%ZK?LC`GFr+SZTmhGnt?)8A}rS=|RK_ie%$s)VS6wUb?9?H*1* zm-r$-XRS_T=U-F)RsCvN?;ccpLut*L5rN0#+6@o|RC zfA*Xhoqi$v4p^@HE?BBxQ)RO6Pk+;=)bQo+g_2T-rl!b$pmr!X*_R(HJKl})G`YDs z^0vw^@#RloWTQ!F(6$^Tq7@WQ_wdOk==aEbY{z1V&MjigE?v7OQu1|V%|zC<2hd_Q zK%rpS)@nKzmF!)IRL}YDvaQX`I$jTjd+V8ZfjjeOfNe_w^3@dUT3Pn^sN>pFXZm>k z(Q}ZEnYY&C^hHi)H3#2CuhY!F{I`_GN1MQtJC*(0(pirFJ)L|nfY11Q*pKw^`A+)h zo_kQFQ~2^bL1%BmLCdz^jK*h=G)pHvSrK$6Jv( zXsz_(Ur_}9FW2M$SIssW=9++kCx%#6=Bqe}|{(Jnze^F zPCO;O$F#x2IUCZMx7Mz^bbvg@^U_{Culn-;h1Oh*2PH@xadC~w=kdREtx5$t!VBE( z(aoW7w|gOO?a^5HeD^{u8#=;iB!XQbEOf)?ThF+|hV2mI;L` zgNb;1w4<^j<&8{tum9wtQktrGfjbqwGMs3ihNaJR_vwq=RqjO6y(yW9ceumxP&5z^ zr&1TVE2eH9EufFTBIRDN$X$^dJzD4jy3}e(@J|l^e@3=juCt6v1e%x93qvVGS-Fm{ z3}n&?s_l&k@5XRajIKy6K-2Uh(^1tBSTI_+Q9WB`$nFj#Q(?DU+zn-dC7N=FySmd` zM%Z9JI+wcA2>gFz;9C5Ht(uc-^j-Se^Fr)TV5uYK_hOBNI1fxwhY^YqFzd;E1w?W` zVKL;gx3?p3zkquOCn2OEm+25To=mAXMZDR zVeY>eLe9o|djY~l2$vvqB3y}Z1Hx?xKR|c{;im|{NBD1q_Yg*7o&5!bvk|1M`kI;r z?rGR&neLwBo#Q>%J#Bd)9!dr-54#(=C*z(y%R5VvW>$5DE}t&M|8bFdpTCy>pCWqm z#bg*x%>vwE5pw_T44G258HlXHiPf{B)Bor%^hf$x2(~|6vC6v#cdN)1_sa)c zdA4C0tBB!#JNj-b!ia4ON{dJ)rZoDWRIUvbdcBpYEh&z`%IKW=^D4u!_DZ>*;cXF> zkwjOxvZJjs+1*vSbX7xRZDj{HJZ56w!aJujn92w^hu^xOg! zta4~*7H$TyVGLf>{O@Rc45Q3q{RNQq*Rw#k&A}9^jj}$3R@u&2%AD`uW^r0CV9wN5 z=G=svb(Hl!l(KnP%6bWj6|BJKRRZQ=7~7`xGUqPbEDkF--fYt;(t0bCXYVHQ6_m8v ztt(N=b`GUm?`O#w|BR%D`B7+g>vt)ArmW~A=xjUp_bfSxT&LZ7gj&pbnK{!T1Y0Og zWd9<0tO1H$NTT%}=5CkC#mvo0dAG8%8)UMW3^}&JI)Sy^D0y3$?2`;_<;DBuIBMVJR3r$bvhsCfD~^ z?ai#f`Ur!W$r$y*U@$<)l6Kh|K7xD)%B6&hr6{@Gr9X#gw$4Z5(|X zid*X})NAx5;IOt?m|t9uw5GL`9B15g6mm)~WU`qAG0KBGg-i3>guMaSskJ&9kf*JX zl}r_mUxHO@c^i4wshY6%p|M&ki`uu~R$`yxXh-$-$*b8A@N1}LkDgPX8rGEyi zRvJUTz4Sq(9i{y58&%qYyR&p7c#6cBQWVe}^GnY{Y$^R6GO?XG8s>FecrvnzG#an0 znN+se#gywju(=-Lt)I7lLy<_8_ zP!sInU>V0|-mO!ej)|=QN_MYxYKh}F)cwl}xg3Yc`4y^dom%d2L%!qc=W(}Ao#c3k zGOw{onUfu_lGfvq$n7|TGPkN4JdW2WWt&3N9M4m;uPQXd(L;2-LbDvV5#69rm17yD z+_+83oR3B>LLFmii625Ck7KdJO%-l_Rw{&YM7tEy9M=)uqC`0zXHf9%3Y9o=DDO~X zYpTmp!6tv_K543Q=`xPJ$^|Al-et4CcblZSp#r<0NIQu8xTR=Sk;dwZG?lKPMJ<%} zrM%3hQOal`3;kVnCs~DcF>a0(r63h)<+zv8azmYtNr5V^tdtCMaUZ{g3{r%!Rw3$C2>(9K=J<+gNkRHcDU8KE>WRWHva1T2sR0NY2X=S*Vd2mw_m~xQ`B-!mT z@`mS1-Y?=lzMi};(!^Ny$`~+|JC-{BK*mnmi0=Lj(dE}mq&aS9kHpRfH{D%2RhN_w zcW0v3MVr0qt!NTVl=J&NRYsMG1V-|_E=9sf{)JF8ks;SX@2a%4&2 z`^b%|#He?Xpwmv|e~Pf~B<~Mx`1>!?{t+a*7s(m+DhK|Eh5cM+Q6z=f=dc`w6fc)d zb4w&sC7DXT37za!MIZ=k6K?jolw^I0$@6wI7eUzPOMhQOanm+-=TtKtZ+HTTEsQ92%vq}GX;_!ks^ zvA6;27@G&6xcGeJYe+g((mvi|8DCsXCiMN70{?uhphn?TdpwKcv9@7+B^ZjzM6nb$ zT9<4mx%ecLjFKT4@P5riDV+xClOd&S0&>qPVNsVIlHtG9g4!uP#+@m1$16SzAXW>% z9}fWwOW>~52R>3&Q1^loE0=uIF2igBJDG5c^qxv`THY@mjXP&UVflooXo2%T91Eh8 z$RX@j9_QP7rfw5>5H)%#L`bQZC*q^<}s)>DdvEhm+A@Wm`0zV*aLJs;f<=jP(GD zlMuy#z5#-3dSp!wyP7l3sQT zf>o@*eME!)`dZ_Y#-R}UK-3M)^^|RnWy*{xYo>&xU14=Du5440xxi{imB`^r#8#}c zO$p7IF>}h4DUuzn{9o0LBUIOoYd70Ci%}EQ;402mWKlK4U|4p{IoHp#=5(|R=haBm zWA|dUzhOnq%H_Vsy4E@*eXCjvgq2@HlE>2WbeT4WkZ9W99zj77WVRhdOL zHrCZIY4q3DwbV2>_*z#sgG=@jB(x_)Dw0U1-I;hQ+7S zRl07uul3?W#|HUMK{TE)F|1fgFObM(U_SCSNm#u1S^sijis$9y{A?XB|>4Zt$t}uFghCRwg=uUchc#EWF{JKLZbFr(z zn2KOd@<%Wo#n|{RyfC5nHiRqhQYH+AH$n^*bjzE{)lDzW9txxb5Ru5F+cNDY&Voa# zA{o7Hn1$MOO{J@C0$EqIU=g$Upc$p=5xzuE+zx{d_ znJsihCY;owG`SlL{sOB)2ig#)lPZoFDd{oY!W&Pd!`>xJ8)l{h9l{$4q_EE)+7d@W z6{nNJi>C_i{iiUG4Fi7AlHnNnRiZnV7G91t;pH$A-gW?x60(ura0LGxoLjvLqg#d^``C4{#XR zxX8<^9)V{Wte58)e5vqkq>Xx+&%jj~&pw#u`9~EPxI8o03n+pJ*yxsJczzNBAN4Wh zG3IJ8hG6jVyd@37cAbyyGx#z{Q&%hv<^K8yAn=UFxX8z=8^Pc!#}ipO6muJm1dV(Q zUpDdaL4Gj=w^9-PqOQEIMKI*?d30Bq5MPiKbu;R{Ugx7-`oY%^zMQFEw_+DJnfMxU zB;7c6$R=blO=i_ zV!sP~ZlsONkoP1qSg&!B?_5)ck^DIrj5K+l!l2~KcgAJ3{dr`V`4+>-6$X=u_KGP@ zau|GAFBUFC#tGyYX%bUYa1Lq8Fp_*%(@2x=-qY}|CY?vW3>wb}nC2McWjjNNz3g!P zB8>svE^Vi0i@T=@F@*&EGLno<)rgn9LL7lH+{ou*n0BV`b11McjO%BZaIP_&3YmsH zgKmyF4-%`l-qn1ku&SB!n!>6E&R+_vUgkWdu&U5FSG7q`SM!ddb4G>VW8P3$M)KTN zVKtz+WK>vn80Q6rIl~Bfbfz%25^!;xD?CPGj%S7O0xT|$TZJ*madCVqtY!`4{MIIW zMU6K_hqL11xKddCQ*it!tVTG;iNbvQU5y8YxvwyE*@n%4wD+VTB2qTNH_V4F+pw97 zbpCq{T{d~*X~w4x0inD2Ec`Qybu0UP7Xg0C$GfX({wkhxnQk8Ix`fsKpp`!xHH!<3#zee)z8&%(fbhkcFC zKNXm-7At)x3Lf+y*{(V7)alj0{lJ`g#-V?g0UPu8IDGlj2s{h=ou<=yV7nFdEsz+` zlfWBLp8sVme^{AO-Wi{#uqlm0&jHvX^1;;pKm0Y7M>KMTCuWWVQu&HBGi+^4>GqkY~7zTL#{ zz`!woQ#1kC{7unWz(ev}q6*l!+(=vq?1BCpkY@h`fbTQOj{@_>NK}jQGf{MpC@&Ur zg^7JHH&=+~fBxeo`BESD$`^9SJ3TWRKVJmeqBG^n`cvP?`J`R)N*2d@95T6>#uomk z?8tngkk5AH^@&AsR=^ViR?ZbX6bRx)Leu9^+{RC(Gwtml`TaH6jrKP-w6yyDK()ir zMKuLdw|AC+sk>w0bU5Ul4c1V?-w{i+Vc$wF{r!Q=W+8V7{Gm)&*A_!`-HO^F$p%=~ zykt4HXLJ&)G15a)<-UTH`ZpSo#{ue9Ml>`XPNmTV^^Mr##m4twvxL9);uTAlH`GAi zkA1l|#5YG|_*SXp2A`d&{*xSO(rUKSbDOCd6Cxczw@C~IB#&$1X2Q}BCem4Mrmw zjD-V91IS%fA-~e|>+iLWfg9UEgfc2JEpYpp)Qt80CdAQ4^3s;{n znu*G?>hni)KEFdWV}8wO#{RI{F|2P~xfJ`KE0-;6scZGOE?L@GhtWqLkVhGMcX2bY zpr*2c>Lb2BNLMa2cKDWZyZn@LSiN%3SZ|L1qK*FMa7Pqp2g#aPAeF)foZ{I}5TGDPM;?`SVG>Aql+qRmAw)wMCgEjUFOzv>rc7qic|fq$ zrY32L)7aS8(h4iJ59_bhqIQ+G?rxASZLL+*uKKg1@zzn2OHiNuSRv`413&Fth!ma2s@9#iE zXhwlH1lCKshG+=tI+2{)MQU!2`@-(zd*k2?4(2GRs%TW9`-P(BgP3 zk?r=TlisDOEUK2eH@0k*WvK@P^{zyii9jA+P*1j*`MfSbm?Be(f0~hIG#z0w!VH3O z7n&h2+I0Li0U4~H7j>V6P=-)~P=Ua!R7GMU;;9Ie+%Y0vs^# zBE;fmN69V&Uyaxeyxzdn-2;3S3bXtggc@MBjhJ>=13bsTw;=Wb*BbaD#Jhl*PyP!L zx`1ypR$=hHA42Q~o^Rm$5j#F@>RT?Z1NMNv%b@=l zv3YrzfX@Z#Ys*EXBb-T#u3$Ww4vVgEDwRx$&Okh#42rH~S2!VbJ($_o71lG!cyezz zrIQlrO2rbHhzLeQv6P6YQt3%@Z*>pGrR;rAgKq{km24V@;6Nh?{t}OKL+)YJvy`wXkFqm}F z*xa>FIOW$(BiMkO_Kp)@07=x>aF$P~BV>sV_#u)IoGRB}AVvK=! zCu0n}1B@}~4l>4|JIok^@&U%s>|w^393EwiL3)HS6n&gA2FX#zaKLXe#-usS7z6id z#+WpoWsJ#W>%c3$ub1RM16A|qc>8xK@!WASx~vNvqYE;)vwfor*rF(tr%#RITELb? zNjrT~Vzw|!Q=J}`m@SQRIG;WuFY1a#1$uv|D0YFxo{dB&H>!-NYk* zK*j=EG}=RaN@7|zx}W%@#I$g9hVP~V$FL+G2RnLYS8r$o^^?6{wqqdzFnvS&^>$!~k^_`q3|-?Ak)EeecM zGmo+iDsuO}UKV9$epdI}zwLe6ZB`2Y?b}*!di@|}zdVv_DC_-riM^u#HTZhYo!jBa zb(aim?Hg>^KX6UYHec(t_WVvX8xs15v+HsVk3;ZapB!7hf&OkZIDfH8AL!2jXJ&&X zcZj6c{Ny5y-jH39f9bzRM|0CoLbcqczJcSpn(bSnC73Av`TIZ_sNIok=<((Ik$%Q8 zAC4_l{SY}wkz4Xlf+W=$=#R6yFQI_nADs*tzWn9I`fea`XmIO(pMN`AafewfGsEYL zz5&VG^FRN+A*!O^hW116?fIO^SJ6+V+#yzS!alKn;7}APU#_2m5m6gNY_c!kP$<=R z8+2CLJuByBzqe&ev_h)pS1bc3&^=G&A0Rq0Vaez~e+UxJR2u!AyNk8#pM61N?hpx| zDqB(UkH>OVXVpx<%Wo8Zb_Mo_3T%lss{PYBkT~RcK-LpCSM0z<@#CO3H%oOqy?iM=$da-OassK4_EZH(lhR2 zGY3<)6WT=8wZ84G+wz+W!uqPfn1(>ZRryf(wg6i+}t6id!H^lv3|y= zfVcU!p^tv~w$UHi>fENs`=86)fsVZZ8g0vmOi`Js5ar9)nYf~FHzeizP?X-}%Qf`* z?xTB2ukz(TOai=0cGT(5!|b`sN%rT2FS-k|x91mv<@BdP$zSouq&TINfz|U*2Pi>V z%`w5-c)~Fu%A4@}8x0?P0=#h0f#c}tjfSJNBIW?_Xj)u zA1*mtn6GvG_Co3W!E^BU-Wd=-cn9wnf9u%qv`c@Kb`La+4E%U>>XBT-$c9V*kopaL zShmL)ziNIpXa7ni%@FjI6m;&`Ijw(quxm71mG{%8rhu;lh|#Iv7#L~6TzfXZ%t9<^ z4f(D9r*^=B@8hla+-Rn(_l#roWX_Is_RSqvU2~i~rUtj+nZlR98+O=#UF;Q+SRw=(BhMwC#eCrOL_CWVfzGgJ?j_#nT+d?p$T?Qr zI}qjWO(hc@oyz>JyZT9q-cS5fy_1Q*s6(-AI0SdOp(VH-jO zVGqL12zMhqgz$BQ69_*-copF+f(y?b(-AI0kb)cQ>sNUeVu^aOr`B8RUFuo5DUb-I z0=vVWX0B&FOKQ9|inO?{Gqn3+A^wkxEPwB{{Qnd&nlH^Z8+ZDOxkBdt$6Sfkjq6`c zl;Fvpo~V41K13g-@3n#d10)#Ne8if_75M+d@ZlH0uj)~ZETf4y?g!C-eF*y4Wfs|@ zl8Gt0y4sxaqe8E@I=wF)3U{TeW3?-nSBK+~YPlZswua1S3wW)c1 zbq5!0izMO-+-xPQbxPTSd zy-L7x3~l?uUgkW2o6V(hQ^S5SMQZmjdC6fC-#|&tscl9n``=Ky_9d2F^bbfnum%oxGox$tqTQ8+Q-v4hVye(@7kXm9C(m&#(c` zyTDOmzuol$fccwpu`(0A6 zGa%XTR*EzCZzb;$CJ)G5E^qDk$lNQb+h}zWbS>;JuH($%)MVGzs)Kh zlDuIiACbuwl>4Y`XcLP)CN*2n+#^!6W#s*u%>59PkIURyOnzO;4YK#2j3Pt3n#G>_ zBI+!4{1^4xMA|o>lo`WR%6Y?A_vXXhi^+T{aT7QE)Z604fm-}!#ZlKhLn@0`;{{x9O@cFt4$ACL_<`R6MB z5~1A;G0u5?V4eIHZVuN)<%=Ovl=E5KR(>y=TFxI#d-<=y>L`yR-&y`R(yns;9!@Cl zz`dk=4|qz&elzF3F%AD=`PttnkOXP9Q zrOZB6!+h5-DWzYbg|44bvzrxK+GFPIJm!pnKTH-5E zXufNW%R?3J_`XyK<%sT7$l>}V(E%l@#5I?K4=PmV%AveVjjefZ*8(>A^N&hXO_eU= zx?j1#4A(g}>kIcvng=Sd3rZa)aG$acttxe}x>AQqFQ7$jl=k7g%%)K)XdxT@U3Di} zg|-GaS4%larH-k%SI~0BPRFD`6*pH)hGn={ttEpLA+$QAT|1g3(T{rtZB#6+T!wkd zWzOR~VyZ*?2DEcsbGwvsfKt9$kWwrweU6QE^Cq<8)GP3eEc5~k(Wz9`Ou2u}8{HEP zdjshy9Mq+bb4Zptqyyf^jtP~*q@|7u+$-kerX(=sCKE`q+vDU7FO$5N;a=59UN>o? zlD#q+3{zd}T)!aWwX_l4{RN`kw@Bo09b}KhF9A2*T{=~#ln!@iqg)Bqzi!k@`O~^k zz*g!wjC84ko=|xj$xour64#epFClh)c>(UMY8{0?#(~O_C50a$H>wg7&LKgkozCAB zq1{g2uh{YPU+VZONKP-3i=1^X{16N0Qf5&kg*aLr--um5Kcok4HRr(B$co!}f1~xeAHDLIqo; zaJwpPQ*8E34K4gz`qi!stGt1tYT3-);3jDgQ2uSOp?MT8j_tPPrAS&qpTRwrGR7vblLfcRuH%lF&GvTrMBF(W3fp;}q6N+}aIAq&B8PBlTn^a1wwgIh zR?WT8KJ)$Cw$Hh6=MK#VAw1#IM7wt5b zY06g@cO>zE#eHuxO$GyR5AcZ7`uHLAlP$bp?h+)`42}sh*xGS#7qrq_v z`qOKT^Nm9xjDctvm}`7{t!>VtIos!iq+MZkF0SnJkhw~8!iLDr1A{|YpGM;QA9qUMhLmsY(3V^)~Zk*piekd)a29w!DCd_PEx4tJ3 zM;iAmRZFBZSYAq%5}75-Wr@x}x1I=xL*bAfNhLeMr5ezlN$w3AQj(E~4r_dww;BJ4f0Gh zhQrgM_?FG|0-3$XI8nvmGVR@E2+QiS&%h>Wh_A~AR6SXo#3nkB6G@M$dBfJ`W_|P4 zHsw;54#_0JOeahkc7=yUvg}bd!f?{v;eC>t)eVPG=3-ZaF&)L6q(?Cw#o72y9QYc& z4dKeWlnFy&x+oR&$eYSFOfStI3SGUD{kWXS03jMNQBs~T~A2n>Q3xq;SJiNQm zltRnLZWc*(!l^_c&M^*dRb|WO_3Hp|{vX^eH7WMDZgi2=Lf2)(seN*|yvqX?H<4tO zMjOo9HZ^QQKBfR8-!d^Y>Kvs~30Q8WOoR$eG>yRQMytmr@Gg#0J-ruplEn;jwzM_) zTQDCs`2BJ!#1A2-Rmsv}IF@X=kw&$~FtE0HY=0-v^#$uSHMVT_Hz@h7$Sv4jxdn1K zv{X}+NaZM;8_gNSGKj`ZnO4U#dLn3ALm9xBbK`14<(6IjpS!UuyGE85-t@lCOrRZc zCZ*!2nS$=&RG083l9{k~?YgGLnLvl|Mg!@n@P_s!P*BBqk;IFq3h$n9D$O@TtUw1X z6^@f%CA#7n;pIpZUJfJS#W_L@q@--5Hyp(;2j^C=!YCK$j0J@^m`SGa91~K}wL#XI zMDg}CaxtKJYyfh&J=>uNFi<duO+ziv5N9|wy_a>N02t@ zj2TuS;0ajr@yvtodki7S2Y-Xdjrd9gJitjlo{{VaP#ea`#DyaAYQ&xA8?2XS8@Hm8 zrAV9gGM|B~GMwkKMFpc+nARrw+k62-$}?j3BFxsBS9k{!}S(EKFHUga~_~@N%dypm{ z`;PBB^4&))bPAWr_c`QHZSu)?AHnx5(rC84$VWRrj9|*+A>ob+l`olaGvz&I;oAki zU4Mj+2a~2ezEctfpDBYf&Gb_iKAyeB!51QfagmQ<7=e1S9XyIZ`A6#gXV6)%d693a zCBsa97Yt^aygc0NHVY9O>7OCC^7VjkfrZbcy)lmOLGWR{Sh!5Sx5n{(4HLvllW3vw zeKJe7ID^Bc9nyJ}NR!4h0;X$Jwy3{Qi2E&mN*V*yk+w6~#H(n;91@JnOft4qBNi%`+~mDG0DC#ud+HJ-XzhuOnD}@#+(O<)mwP#om+)f&79X1RyA<`Qdm{M zc}ijB#pYS7U3xlv#W;Jl%NZ4%oL_L+jb7zEqA**b<_m>YhjCs|m@|wzI#XDUFphJD zG1z%=Jma#X(A!M`7;3t21ha z)yXx-gTmZbC|>q4Ga&VwQ6wT|mv0{zv+QGLF4FnyRlMwiC!WR2F5X`RNZIk8xAn5i zH*$+Pc6gE1FC5}mqvkwHF5>a@rebkP=kJSokzY3fV&d`i@$$#h$JaNWe?0x&^f@$6 zp9jX_pO3@uvs6I+$MajrvVHGWzwz>TG{6lJs-fW*gXd`G#roF(oBn9STg@%Nra#*7 z5n!sRm6b#t|4XEFf()l%NGqLo-XzQ_gL!VyV=7QJih+Vf_}B(&#eDpV7}v_ zKIU~|55L%)9o-f#48rREkq_Tf9M+hzGO@fI=4*BbJsVanzf z93bRR6tjSLfzIb2*0%__3z&XDd<8J)FQxBv;REgg-F!zs2+Zd%u!6r#TnjwJ`i%0| z10M!nF6r<^;3L51JNt)#hk@rB{Eq>j1m<%G>puo;ZSRY~d_9-rob|m-e#8H0j}hPz z=wriA59z-FJ_UKN8StyhP-XS z*7~mj=5rFr=-+7~4g3>}e%-)sl%H>u9{{%Ma}e12jlm;h=x%Wo*t|SQdAD4K3@7 zl1;F|zjhP0Ckzs+G1En0-@N-^vtoXi;_-wg^&zecZ62 ziPOpArl$OK1>0AW4aBiuy%Z%u5B9zK@TQo(#P}emm{Y@(6-cq>7$4P)$&%+v>JuMp zzWi**njt@;v1VYS0{`Q3us3ea8PjT2lkt@fn<^WEUB`4;)e8w|YAPZT{ z$n6@Vv@)IgsHj+GiTq-yh+)96+SqDr-n};>NHii$cngRU2;rd+h9m?Kb(mx(nF+~EoClBAYIG7M zj;yJ#`rL+skN#V?SgUoVt5K-b?Z+)^t?O31#kShXq86>j6k7BDe$Tmgauadwy8r#( z&*$88zUTKlzw>~J=?aS$@@2D^)HEHE8uluaiuq!n;olZBvTdf`#@Zs6|6?Jl|# zNRYJ(nJ?)G3eOa{AJ|=VuLILjFXlm4f;1(_n@$6!GidAIP6h!#a~bJNn;HJaz%2!_Q&iuV_W8lW;VudJ0_-wdo zdffT&H8?k19$X2Wah-|4IdIg4Hf6q(;m(7b3O5dJ1l)yiFp;t;{NWet$b7+E|K-JU z@^UFJcOR{XXglL7Kwtvg8G1w^{7G6qR~xFQo~a3b6VaOV=>`U>1A85(+{U5<6y zT_3^lv?b-90Iq;fOdE?^?5^8%d?|dk6Go2~9}KJ{2K{3AQNB?k3%U>V=XLt8;6DoaCGc6kNyGAc5Byuf|2v(Z{$EV>I}7}~ ze>kY${oro}|16#Vap0pSd;J;lZJ@JXQNKLUyMTS@B*cBd?a)`*yHFeg?gqVD=l^%$ z1Hc-5@}CL62e?e97XurYhQQB&kAl7xVe&5=MqdSd40QUW3yeqG>SNJ{NFzog!H_>5 z3Is)BSBt+fl=LT(@kq4Mzdg{L3W=6bH06&Z{M#dmNL_PC_?K_4T)K93xgwCgH4qO) zlYTNv5n!$l2cnGuvPMv_uY0-R7Jkqjh5 zx-L{O7qugj3`e5=IC4U=2BZ`5SS%^k@UL96ZrRc`{&g!>R9DpaYnCosQ{gvh9FMiM zs$A*=&GjbfR4=)!6#_5Y?ym|pBKuIhyg86agc8EG$W99AYlmww`1B ze9@Xp!VGbdNCso6Br`$TUIrgoq>p$>c84(9oPpghfLu z>LJ-c36ZEsMqnufLvhGNse`c=2&<>I{yKkitX?$eCiL&5(L`t`Ea_jp&QDEbKnn7w z5}_bcQd7MwEdj`fTFs%T@P~qdWB~NKL_(1f6%C4_bycfZuC5d-*Q{Pv?w{?QlM8X4 zQkQCYRym7tE#Y(I1@{xH+ylFsX1nbD;5a9B^PlV1IRBvU9;70l5YADT_Wb9Y-JY!I|_i zu1=(n@k*nQk*bJ3Cesr7n3$*2$0Rh9J|?WW^r7Jb`k1g5(}$vE^f56kr;o{X6@5(J zYv^Nw@X^OaS3@6@^CtS3xUQs+NqsAQOl(2=m;}T0C!oAP zTKae(XrqsTvz`77jBE7qz_6k7?ex2@?0T3W`!sL$Q1YciVql&C$3U?iciMHJ*o9D- z!QNv7xQc1HFloI4^~BQBGeH4)xKJX2!UNO&u;CNXO!%mVd#BrYRvB^DAd zC*DbX;!{KvuOe%(k zB{^}=50O%cbdP->BL`l|(Nf1>bdcZj(xJ{iq+h>2Grk|wH&UHNyD=kA`rU#sBePo) zr#?v^_86INtgX&mTja@(gQ}gUGM?j>a`&^gzU9j-TIypYs?JV>6_B9w#f7JmZr`32 z7GL$o>`zd1M0WJ0>|3t(AIkm`Ona`pbfEM36b%61=(J7W>pu_b-d z;covX(2?au<0u!t=igBPl(%=Dp&yj0&EAZBhUN_gm04Ko+gWNGQXsZ>11chYazwH* zebSZM{~X8v?Dktn_4773}Rn zi(9omyq~&+AELeQK$=aN74|E9;qMWrfjj3GWiLb~@H-D>C(G(^J;X1@V# z+|SA;go;Y{=O-tp`<;OIUl1=>(}e;@lP-Y ztAUl&2o6&v^@B86NgZ2|E;C+sk@ZzgYmevqe6m7)O_kY~m6YDqlr8OnTn{nVJ9Nr6 zU6mIZd7U1~QB?JxbbqD0;}Nucy?otlo3mbF8~z2DiU(Mc*;s1Cte$R;6dgUiPf}w4 zE_X*Ol1ct&&}amcbPpy8rC!yOq_c_CPZ72u`SIs+%5UzyG}lS?Y!~|cu>lP}{qC8W zHMB)V(U#m;f9LX|Gd5)J>dV#NLDt`fap{w2&v!wQr&-lRHy%L<_MO#7 zX};|9pU5;mHCX6<=Ovn@5tPi=J*W;f;?2}&kW5XHhEbpIu_AMYtK*H7yZ0LmpUr-M zGxOmLn*CT;CizaLya3I={WXwQEbMo;uYn4_CQWAP3m;`>C!u=h#G>qMsZN2fHvB51 ze}`zKh7K8@z2g;k$IqBinQ4-HNafd*pZ$Z%P^!_f3szJ`+NhW5P0G7NSqKw{yS))+ zsjjXKzeB=TnbBGoGU|BA-SHzOH2f|}evtOcd6MIw%YE}b}zyF&Jns_+0KPwL8-7xbQ^m@{jNrmxSA!9dVCy(l{k ziCCY9J+pdPjU5-Vy&W#VV0zUdOdob%)1|%NW!$?3O-r(Gd?by}JY^Z~hj?=tZd!~? z&;Yc|CRKs|iB_vBkk5Cr!jgZK^{6RPcwG2RW$H~<@w4EdWI0kuqI+M5qx94xA`U4No!3ifh3^_iyAGm+F7 ze&2*Xx17WB!QgGDFx@eic9i|6Fmd+RV0AzHi;Up2p3B|-7#{sa?>po_j*@6a? z93y!;*r?8CA9^G8K1C_ctm3?S%hi0`ttiwl_B9W!`=l(Z);k}(3(sjo^(CL~#B=iIEmt4cpN#fAhf)e< zpJdU*+U(K~bo(TmGFKO%D2+1b%W~1>nd+j>qsB;^x@d0}4X11$@2iptFxO^BDdv65 zQ9a$;lFLBxWfSa?sH5tl^lv@Mg7nu=PG@J|7MLP)H4XQ%F+Wvj8_m`u$7dcVe{uqb zI{?99jm14rW!t+G3H5=+7`@6mSiUWJ-hN^ zjDfPew?OpZ0Ab&;1_Ru!7~tH`mRZu-B?mc|rTZ7{ID+_Y#AhyPM`1e#-0dDEA~TN> zwb_6DqbxBWcPxhHHEVDY|;M)?FH|%r7 zL5m|osI&`VSy>fqZaqo;t;&{q75OxY?8!kjIPA!W@I9fAJ83^Ahy$9 zlxwXYe&zX)`8U6Y!z&k z6TmlRF);2&ohK^Mr2De-OhiLnxi(UDFpHImy}YIS2QW4qw+|f6V8k6reY9!IRfnKM zPJ?e@t&C%zR+Yg@E}tZ2lK%K@+{Kxbsh%AwESsWRYetKuPDr&K(UjKree(`Z0tD`T3z!=dvlwG*wO z`ba}01mk@El|OCTG_4{YkHxiMin}lx*YxSf8nk3Mq;12VL8y7SA~}&rE=6pPrL=Hh zdq|7MlG?6NGM69})ON*Eab3=2GRp+M=1?FJ(&8w8BGzIqDO4#5c^kdjl%aN+qQ&Ae zsfy>mi!vAqI`d9F<^t65v}q_d?lMhzAbNfhc8Lau*-E#qHl;W*MQJD2-)47B*InP= zVai2#@7;FSUAns#{&2SqasPaua{r+FA7V{1e81iG1NdgQ_cU>4`u|q=c0J$pu>4P_ z<7MEv7;dwP_Y8!Oqim)0ZZd(zkj8mX8R0I^a14o*m$$@PXZS7sI>ZbHB3$4!arhtO17p z*e1kd%HX!Q!2BEQyZQ9C0Qqw-r01)@+#)cTj57hm?_j^Z56+2w@Ck6|!Oe$T0apvx z0Jk0PCb+xd9)^1g?nSuQ;NF4jgL7ivb^_daaP#3-z}3Pvz-@=S3GQyVhvA-rdlBw6 zxOd&6T1?@ zP-~(zGH1d3(ol0lshoPf)uJ?vQNFaXt~B1-Qo3xz>NU$t8@VGq13SCkIi>Z9lt3fV zmR4)Cy|dc8z@0DdalL#b0F(4XM%2c25%esUyQ)?J=8*bJS*6$&et%#|tSCClD3~XK{U_OQhTS=NR`*E{4 ztvsM*yMQ9C_cA!Go5c5!((16TLn_;alx}^DDX0Gvf_7}D3%kSm5T(zM8GQlWe zI-a@QDtW6J+#?z4$oqFP$oB=?Z2{ix5C$D5kk}zVL&p0}|+!ffwg2G;ke?VVDuD=FqKsn>CkYFpxLu)gG4=7&d_MnX2%h+xi>|*Rb8T@Bv@v!9OO0?~}GI$Z?eoq#3 zHIsc`YPOuQ2c%~6$oqthy^O&h%Gk3Rd`il#XYD@|MuhcBCOh~YWd^)1A5qDSNcJSnhQH4lg zcP=PAAHJpVbwuJgM?TE!Ty++r^6WI8yNXnn*u#+LBCvU$;jM?apYir@yh#?`kZ=wb;9b?TYUrz!J#o0K`x`95iFMG|SwDU{i+awu~Cky1Jo zDsldrn%$((bY~mU%?izQ-bZwcLUWxfDCO1;DRTh|c?t3uO-noug^HYIPK_$u@vl-L zq$9dhA-nTNqI;AmmvagQKcG;7GlTR_)wia4oW(5ix4$P%HBL4e=RVa0&UE&(SdZK% zX&T!L* zyJ@+>O2?o;71xzYhIzP;T}lQiLRjY_?A)|Q602}`(?)}-Rg+tqWGZ7n=%9EaoBj2atxWp^>9{sT+(h~(Z1jr zr!E!2sqDzS1@qO>Y(Dgq*2j~P|H0#tQlSKy+b#d`79Qtl%NUEzb+)V6 zH5O(QmeCfEa}4gb!m|sD3&-M-)H(qJ|Dur>k6ev+BU=%`$dQ*K9xI79mkK(@S}bEn zjwBQ6epHTs0p7|+;FSMZCdFgz>anF@$a9O4Qdqt&*+KHiGfXlH24$f2+f9_h5=fs2 zDem!zJ->iSJq}1l`=u7tPU$h`JQ+Jy@u34TTeSPJ5U{ua&6WC~jm*udyQIL%*GOrX zAvS@XOt@OMo>FpJP8H_k&e2dJu$>GGx3DAUO#Utj}y0f@f~M^-zT8 zOR;w4l?S|dvNVAp`r{6sWJM5N*S}Jp+r`=8FyD0=DFH#YvU}jHq7wI^Mg0=}Pzb#v z>IUZflx>b>()39iCk3TlVRgP-*`^|Lk=21L5yLkT+en>lQgHh88IvYWlI$qu|5M%A zLv`Kw?q(ZfF>-<$e2cT?Syaw27+yQ(%=Y6juAhf^Wnd*1WNZDaE6dld^{uI>sX)-T zp#~g^u!a*jA${BDVw< zd+TwooMzK=$wlfVPQ>cB;mopRscYV5a4UN?#{yI#R@a1eUuxLU8cXO26$d3JagsX0 z1J1f)IO`6J7}c;^H>OcJ$Rww5GUk_u*I_Rt(FI3>QW;f=6>EJpn{yRg&qLRdXw1Y= zxsI(sMsJVR%SB~$F2mlfy0DaA)*09&4gNK$fXXL@bKlWM#55#^P%7noXnngfkIzprxQadsNBr7nUlfS@@M$3nd=n1U^_pkCRk!JvO6Lpu#d6{q?KJET+! z+Cnr`Y)$IM9@4MS5@ef^L#s@n4++)&HA|~&kW{s3y&_J= zSMs5YMN%F4(Ey|GAsK+-1+oUFg_3hWI$ZVl&Qla=RX`(L}*tv)#v((FA zFC$ zQB@^}LQI76ixPJ7M!jLllIvk)t9Ju)nTOVQ6jhJpdJZcq*Hu+0`PGQc*J4is1L$LJvl>vjWLN&TF6_#xk?DmOU)Cf8b@1_R ziuA)q2)c*jt-_0qq>y*%veh$^fkxpC2k?E0H@GW`gvw9Gg%?j1-tD1y0viBBfFHDY zsG0mK(Au07UUo0xWj7LD`T34F9+QRihQgRR_+gM&VWbPRMC!3in2g2o91~PtQ$6#H zAvwNP;TB>GHlcump}JI~KOnyhBDaLCsXF%H9F9aW85*p0b@9-41EDQ3XPF9Cz=Olz zcH#33`AER`7x}F!o)7ROn!DuV0?<@Aya@5RN_|rbf`+hh;i*bqvvB8Q75TU~vI=}x z!Wne>bQi(l30U&&$DYZ4Cg4jJJg`e1K7TGz(TWdyEc?O0y%pmkFRztw+#ex{dn0{N zb}Pb0zKo~iTN(FL80MbJCcKaF^~{_vps0t#LbpuAJ(=C$D*-m-(MObA@ZhjRdt zF1@@gpTU>KFOwz6NLT@j?CsG7FB@ znc&fOyl#Lq`1m|pbB_9^R1$GB^1WH-V^(e8YXe__K}4Je$BV1plt;c>_u5^zP9Btj zsGPie5hfq1RDHt?K9-JT)#-8W7DPW zjO(d|_+FX>{W5~|P1%UQV1PKrK7#nIaI6cqefCMSyf;@1amTQH!E)M*;~)v@F92%1 zQ&{E9aZO>B1II6gnLGA?F-|G$kl5I(waJ#Q#vMiHh^qE{6_&~5Ua-O}g&HpuRu#r^ zL1B(CYU@m4EG6J#KUa8^#O%)s9WZ$@CPGoxv%V1oDHqWXlIPE%&dvnR_42}l>AHCf4Dr&G`Lcq z^MQG6nIjwR=LO~oQ3EdmJ_d|wLef_N^J6hZpCGD%55S&{ptHQ2fwet$*X2460k;Ad z!Y4fepC{Mb;92nBgPo*z;cSRbzXAT%JM6BR$bkHNfV;kl?R*%5_;z3((>3yc0QkT? zcGoL2-PhPs5)` z2mi%7zY9}@2F#I?>CXb@c+C7qi$b9R&jg(#Bk4SOPzL;_jw^t>^!CgDOwt{$ z2Y~nM^wCz2hywGQ){T;0Ag%-63jP+I{~q90;Nv>}E^r&L;>U(Oa2K%gUyh#wcLQ&Q zeW~B;z~=vQ{0Hy>(9hE8ACTW<4;u=~PYP9eCkP%Y=mEd+Uyc%B9*i~U+*m&fI>$NY zw-T7ow+I3kh)UpNpd0_~@RJUFK;X3Z+wl-^8_weWLDCE4#-`c6 zhe?P1IF2&ESAn~rKOkEF2Ls25`JFK8ne?}THORkF^5Y!@cqXutk8kkt2w;{!1K5~v zHAq|lTn7FN_4Jnk8}s)V{Q1QP>;wIIoxT;Ar_W1(+1?_+X8l@$w}St7I)6K``M)6d z0h|8|@-5(2@bkTm_Iezc-ZwHz&*faI-NVOhJ8G+&oW@+(h#TxJ_`P=2veWfF#2`C$3W+MC+T7_ z->|Xnr|}K>(*OSUn)>BPSS;qwTXIGudMVB+M`p;Cg)cmjblTlICdYaN_8;^uj4xP` zI<1huZOiYpNwHVL9TH~F6%6d5;C~{`rr(5c8zYfSH8gu;BPLiqCOnL!lPoP5Pu-CO>Hp9r5G8-btW0mkDxOw|MyZ6O~!ZWB4niEf(A11 zC4Oup&yM@K!fN_s%zyQd8|*Cj!#j-MwUm_^zet&>|H#E0gQa>j6f91~1H0sZRiu{c z2RW$cL~L+noyYO~SVL9+wvl|N{d*37?}BxDb1v%lFyT#g{0TEj?kpMqr!f;y zBUmsW7K7iMuB-|BIpFf6Osw%e7SO8w^$}7cTXZ zs=xRQ;g-vt{6CL5cJS{-`Y(9&U-y`KPXA*g*^tz~gUrmbN0}pdMqmEnsr9r!KpIjA u-CjdC5cK~JnPsY<4w++Ek%RwHk~;{xB~JfSCDSjA2F1)l)qL^ami{j|Pd0)8 literal 0 HcmV?d00001 diff --git a/scripts/kconfig/conf.o b/scripts/kconfig/conf.o new file mode 100644 index 0000000000000000000000000000000000000000..c191a8a72cd7dc86b00872d436f45203e92698f7 GIT binary patch literal 10348 zcmcIpdvIITnLm~tFpfb6!lNWCH;J4$CQ;&qg%HT2II%+$f^6q)h^koEmi&-h=_-kL z32`f_AcR|5U>7Juli}UKl-<VCm?}Yf6m7XUPvLTeKv3xGHnx$`h8`H_%YxYuV&5)1!&9 z)@}Y*G(B*`vhmDIBV|WQ)f)G~bF(F*D}Au?5fw6{124{|Lzv8-SB6IV^~4#;rDVCR zvgF~)S0D+I)V7AoJcaEQ1$>T9>)bJ5%~Fj222WMi@=VD`n;Am9*?P}Q!;_OAl{{AB zPW==5KzwA9fkwrVNz(x;KeW`KwK=QvlssOx^UQJ2-4qY}oBnP5GCAgQe?JJf$>XQF zQ{RRA&G9Mh@egV&8Z+KIjqpq&1vI^gCupl9;< z=~hSbczNQXL#2)^^YTl_FKPPQcvI&0&4rP_ll-d0+JT=~L-H$EVzuq3Z)Ca8*Xb%y zOuU~QcUf0&+BA{-+QyBY6EZPi8;ICRLat^Y0+qV}VZmZafko@Et=cp4Mq#qkGpU-b zFZ1nV&(IY7`1J7hao$%v$lu(Fug1pWl`tchw@S_E}$6+xuD)pS*S!vH-wy`R^x>857x+!!Cw0$T0Y|b{6ZS{p%nA%3> zGLM59yQVQC>A^&6Q&Y>v;U6Iy_d#7kU?;~atm(jqf@K3_{{9yA^4$esO5S)LV%N3)HU&CS^r<-X9O0)^Zh^v$oQ zQ;m1CjJKtDycn(?kUM=h%h@T-%{o0>eVwg3i0rm09N!77n}?}}#`hlA4VOE0qe~Ae zJ;#<<=dmaXhnD`it*Rxi36g$DvJK_wL3jEs42Y$_*cq6U`mI}h8;55jQ`i9v3R_R; zq&bNn+u}|=Mh|0K_RLInFJ!pLsQ{qmKq83KJ#r+{U7ICKgO2^9Jn$sx3n}*oRM45P3o6}x{7hj zWarM;v)`!-ZKhsE2Wl=W)O?aLH8mB~Bd6j2oTPLs`q^uusj0d1x{(T>z4CmW>+(@t zOWQgh@cPX{uU!(#%0lMVVA|^^IkwK7eiW52H`oQc%F~+P>+f3Wxxi-IOD+8Z=WoN5LIj{ z-?~v+v$rVpv6Hu2)=ndoZ6~{{AhdV91#*I9*Lw`?{@l=1c58Y1PYHMKM{G~!y1xZ2 zm@nKh-_O=pqWn|8hp6GoF?VV$LhyAO`#@u3T8CflEHlmCh;T0YHinuVHhLq5tgkHn zx;y>v;AU489C8nX0e_tp&aCS&(%gQu{neXfOj{j$FouJ}o$5eZT3R-Sf{q}2T{&dw zU%AuI+D1d2j!2tg$FXwvEr-D!_oTVSpRE7rmo`5fszhW+&XQDMEYD(#Nh8UJL&A)is&* zo-$m5%6zDoWI;5!=@?%BO`gfhIySs#REH}EsQ9uE3t!Q3>TJJne>OgT+r=CoeD|Ng zaYrvHjQv%lSetMkd?TxP*DH6Yp2W7-sX8k#7IBO>zptGVQZzIh5aHpso`D0e!8DSf;r3Z~DUx*vMk`l@W4lY1T<^NyFglfB1E-Kp=Qksh_YqYa*_L?GKxnH(;K#?Ccx zo3{gnGwsDN=z0(xRJIibWSygR(k!Z}NE!Bo4{6HQ9JV#LwQl2ew`F+Q7|y9*=;loO zoJ-z3rNnwjE6C+|#RR9=Jhs!ez5{jEHs{xvcEGjv1B4<|YveA6?v)qs1$VZO84Vl)SK0ZoJktu!C#y5NtrA1ⅅe~ug|u4GOsy1ZQ_c39Q*oKG#o9fjGW#wo9p zBTvC_=mB_=;a25#p`&a>&Uuk}PoEgwJO)(q-H)<~%H;0ylAFtM8R}m=&#K8zdw@&% zYV3je@!GS+O|ER`T5NELW~R(J$e)H}G7O1tCl92w>!_ay9TMeQc{7yGd2EYUnYS?<&y5E3)(DrCL_<{>@Q z=WKC^1)w!@om?CGgQ%sYDYO^-Tr*hkd&-Aa_d&Yz~L9#8_h!Mtc~E=n2Q;;Yi0R#?DmKM6g}P+*6NO0rlh`3`2#=!+&|VrM#)bq8O!8Hk%k4C9YSdkRO2P-;wXhu4@fF)uTW zXiRst`8{SNVJD0NQQjq-Ihf_zS_~V%x=(!|GTTC4BEh0uNp6i9)$tj2bZQ?qw43B@ z0N#Q3<1>_cPu|}Ei{BT(yXY+Y{R+#I?Q4JsfG%L+`|&Awh4TNe_B-PDjUxZ2it#?^ zWbr;;pxc4=RRwfmoO8ifjrH|QjGD%E8|D~`yo@w;Wco*2B zd6)MDyXGk6jra9ff$cymW@E@{#msK6W$v<+7fT_ayxZe(<&8y2P`l1sH<4Vl5H$MO zD$0vWG`$FB9@c+b7uS3bYR3BdwNNbKJ)V0f&mcZ4@V@G1%YLc^rvfqk`RDM(N-f4g zR|yXL^Q7UqS1mNp8$JdMTyHmRTH2Qasqg6ZL+>Gx5e#WB0MhBwGYg?)q7OF2+%y$8qps%!T9q0t4$sCytlLw=>>Wv2&mn&KRf{3=DrpDUtyYjhs!|I#6Vq<>vRA1$JXi|D@=(PtDC2<=rB z(H9ocmlV;nis-pT^g__DVJ`j~w$DL6mlerdis(=g{hcEE)*||zBAS11bsmoAsUlim zRYigF-xbN<2Yn3lKa7|e??{n+6g217p5IT#Cqd77XwO|lUsy!XETS(hq8Ap?R}|69 zi)fzt&O`r-mkMv2!sUVI$BsaEIOvaC!Ei)HqP#Zy^)VGQtwb#1hd5y>98lq2)fO__ zx@a69?EkC>CQiboaJE zcboX~(~A}D_9G9t%m%vcj?6=EAch(B(~#;3Abg!-aO0-Jm6}wz!_UtETM{z^K|MFR zhgRlwnbWX~`BLF{z_R+374AW{B%kfJiq@u6xvTrhhyz0mayrDhN>QtApK4uMAD zCx9i`fAB&m{lr-)hj|jbAx-|w+Z#GC&C~9dqRI*!jB22M9#k&(Er24=}J9I#Gu{)(#|oVx!%b? z9qWuZ1xWc+!5M;Fx0G{zQqKQ9mCRIXI}!1OfG&?xJtB__K0?Hu{C5R&K=$KC$$2~t$Z@(!&qW->8A=5N_fQUhDbnb7 zI}!2UPd?uLg04w6eF4xlPpMkc@U@tT{!7V6|Mfy|5xR>Ae>V$1Dg3*HzE|jniHLVU z`PE82O&an3O6a44e-{3yq~Z5-((ro*?i!@e0+OyHjo8-;1_bvAW(DseR%70Q^na9y zI-h(x(2KeQa-0_tVc!s}rks9A!_Q*DAo;kI-9j4u28ihQWAdSY9}#vR68_`De~Y*P z^+rDWeJJuz1wW@8{m;ZkKzru^N!JKHPw0iDu|8K3u|7AD4}aT8!)`kf{kzCV|6M}w z7J5MF9}E4j#5$$^LPUHYi2P%bkCKMJxw!0e+zmkHV-0E4_j;j2q)|6_5E0M43 z8Xr3rX}o=;v2Wc;8gbn#{0GQKJiieBpx}Q99u*t`a{P<1$GYZVKLXNDqhMI@JA(HU zk+;Wy%*S)We_8O?g0B-{`zVlcyhj@2oQ%5?{mmevUY7#NuNS`M$g13wOUcm>6$kQ`K=pQ6P|5c&iBEsG~K-ZN@eIop_v%p9ElYy=!SeHcj_mU6& z6@u51e--MVH2ic6e<%4@{707;bNF(oyguj^lWjHrU!~S~G&SO9OBDES<2(A=dEx1Zx_5n z@Gil71n(EzEBKJ$V}efzJ|+0H-~quG1qTHW3%)A&8^PBE-xU0V;M;=71m6`L7W_c) yBf(Dv#{|C+RHz5$wM?*Fuu_oUos{#toXGD^;xs`+&?8tQ$nQ<+EfBm+@P7d&TLYf} literal 0 HcmV?d00001 diff --git a/scripts/kconfig/lex.zconf.c b/scripts/kconfig/lex.zconf.c new file mode 100644 index 000000000..22dda11f7 --- /dev/null +++ b/scripts/kconfig/lex.zconf.c @@ -0,0 +1,3688 @@ + +#line 3 "lex.zconf.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 31 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE zconfrestart(zconfin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int zconfleng; + +extern FILE *zconfin, *zconfout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up zconftext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up zconftext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef unsigned int yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via zconfrestart()), so that the user can continue scanning by + * just pointing zconfin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when zconftext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int zconfleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow zconfwrap()'s to do buffer switches + * instead of setting up a fresh zconfin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void zconfrestart (FILE *input_file ); +void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size ); +void zconf_delete_buffer (YY_BUFFER_STATE b ); +void zconf_flush_buffer (YY_BUFFER_STATE b ); +void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ); +void zconfpop_buffer_state (void ); + +static void zconfensure_buffer_stack (void ); +static void zconf_load_buffer_state (void ); +static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,int len ); + +void *zconfalloc (yy_size_t ); +void *zconfrealloc (void *,yy_size_t ); +void zconffree (void * ); + +#define yy_new_buffer zconf_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + zconfensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + zconfensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define zconfwrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0; + +typedef int yy_state_type; + +extern int zconflineno; + +int zconflineno = 1; + +extern char *zconftext; +#define yytext_ptr zconftext +static yyconst flex_int16_t yy_nxt[][38] = + { + { + 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 + }, + + { + 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12 + }, + + { + 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12 + }, + + { + 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 18, 16, 16, 18, 18, 19, 20, + 21, 22, 18, 18, 23, 24, 18, 25, 18, 26, + 27, 18, 28, 29, 30, 18, 18, 16 + }, + + { + 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 18, 16, 16, 18, 18, 19, 20, + 21, 22, 18, 18, 23, 24, 18, 25, 18, 26, + 27, 18, 28, 29, 30, 18, 18, 16 + + }, + + { + 11, 31, 32, 33, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31 + }, + + { + 11, 31, 32, 33, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31 + }, + + { + 11, 34, 34, 35, 34, 36, 34, 34, 36, 34, + 34, 34, 34, 34, 34, 37, 34, 34, 34, 34, + + 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34 + }, + + { + 11, 34, 34, 35, 34, 36, 34, 34, 36, 34, + 34, 34, 34, 34, 34, 37, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34 + }, + + { + 11, 38, 38, 39, 40, 41, 42, 43, 41, 44, + 45, 46, 47, 47, 48, 49, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 50, 47, 47, 47, 51, + 47, 47, 47, 47, 47, 47, 47, 52 + + }, + + { + 11, 38, 38, 39, 40, 41, 42, 43, 41, 44, + 45, 46, 47, 47, 48, 49, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 50, 47, 47, 47, 51, + 47, 47, 47, 47, 47, 47, 47, 52 + }, + + { + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11 + }, + + { + 11, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12 + }, + + { + 11, -13, 53, 54, -13, -13, 55, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13 + }, + + { + 11, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14 + + }, + + { + 11, 56, 56, 57, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56 + }, + + { + 11, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16 + }, + + { + 11, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17 + }, + + { + 11, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, 58, -18, -18, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -18 + }, + + { + 11, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, 58, -19, -19, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 59, + 58, 58, 58, 58, 58, 58, 58, -19 + + }, + + { + 11, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, 58, -20, -20, 58, 58, 58, 58, + 58, 58, 58, 58, 60, 58, 58, 58, 58, 61, + 58, 58, 58, 58, 58, 58, 58, -20 + }, + + { + 11, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, 58, -21, -21, 58, 58, 58, 58, + 58, 62, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -21 + }, + + { + 11, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, 58, -22, -22, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 63, 58, + 58, 58, 58, 58, 58, 58, 58, -22 + }, + + { + 11, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, 58, -23, -23, 58, 58, 58, 58, + 58, 64, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -23 + }, + + { + 11, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, 58, -24, -24, 58, 58, 58, 58, + 58, 58, 65, 58, 58, 58, 58, 58, 66, 58, + 58, 58, 58, 58, 58, 58, 58, -24 + + }, + + { + 11, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, 58, -25, -25, 58, 67, 58, 58, + 58, 68, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -25 + }, + + { + 11, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, 58, -26, -26, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 69, 58, 58, 58, 58, 58, 58, -26 + }, + + { + 11, -27, -27, -27, -27, -27, -27, -27, -27, -27, + -27, -27, -27, 58, -27, -27, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 70, 58, 58, 58, 58, -27 + }, + + { + 11, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, 58, -28, -28, 58, 71, 58, 58, + 58, 72, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -28 + }, + + { + 11, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, 58, -29, -29, 58, 58, 58, 58, + 58, 73, 58, 58, 58, 58, 58, 58, 58, 74, + 58, 58, 58, 58, 75, 58, 58, -29 + + }, + + { + 11, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, 58, -30, -30, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 76, 58, 58, 58, 58, -30 + }, + + { + 11, 77, 77, -31, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77 + }, + + { + 11, -32, 78, 79, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32 + }, + + { + 11, 80, -33, -33, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80 + }, + + { + 11, 81, 81, 82, 81, -34, 81, 81, -34, 81, + 81, 81, 81, 81, 81, -34, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81 + + }, + + { + 11, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35 + }, + + { + 11, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36 + }, + + { + 11, 83, 83, 84, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83 + }, + + { + 11, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38 + }, + + { + 11, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39 + + }, + + { + 11, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, 85, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40 + }, + + { + 11, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41 + }, + + { + 11, 86, 86, -42, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86 + }, + + { + 11, -43, -43, -43, -43, -43, -43, 87, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43 + }, + + { + 11, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44 + + }, + + { + 11, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45 + }, + + { + 11, -46, -46, -46, -46, -46, -46, -46, -46, -46, + -46, 88, 89, 89, -46, -46, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -46 + }, + + { + 11, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, 89, 89, 89, -47, -47, 89, 89, 89, 89, + + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -47 + }, + + { + 11, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48 + }, + + { + 11, -49, -49, 90, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49 + + }, + + { + 11, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, 89, 89, 89, -50, -50, 89, 89, 89, 89, + 89, 89, 91, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -50 + }, + + { + 11, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, 89, 89, 89, -51, -51, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 92, 89, + 89, 89, 89, 89, 89, 89, 89, -51 + }, + + { + 11, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, 93 + }, + + { + 11, -53, 53, 54, -53, -53, 55, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53 + }, + + { + 11, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54 + + }, + + { + 11, 56, 56, 57, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56 + }, + + { + 11, 56, 56, 57, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56 + }, + + { + 11, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57 + }, + + { + 11, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, 58, -58, -58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -58 + }, + + { + 11, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, 58, -59, -59, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 94, + 58, 58, 58, 58, 58, 58, 58, -59 + + }, + + { + 11, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, 58, -60, -60, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 95, + 58, 58, 58, 58, 58, 58, 58, -60 + }, + + { + 11, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, 58, -61, -61, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 96, 97, 58, + 58, 58, 58, 58, 58, 58, 58, -61 + }, + + { + 11, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, 58, -62, -62, 58, 58, 58, 58, + + 58, 58, 98, 58, 58, 58, 58, 58, 58, 58, + 99, 58, 58, 58, 58, 58, 58, -62 + }, + + { + 11, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, 58, -63, -63, 58, 100, 58, 58, + 101, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -63 + }, + + { + 11, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, 58, -64, -64, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 102, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 103, -64 + + }, + + { + 11, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, 58, -65, -65, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -65 + }, + + { + 11, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, 58, -66, -66, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 104, 58, 58, -66 + }, + + { + 11, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, 58, -67, -67, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 105, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -67 + }, + + { + 11, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, 58, -68, -68, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 106, 58, + 58, 58, 58, 58, 58, 58, 58, -68 + }, + + { + 11, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, 58, -69, -69, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 107, 58, 58, -69 + + }, + + { + 11, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, 58, -70, -70, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 108, + 58, 58, 58, 58, 58, 58, 58, -70 + }, + + { + 11, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, 58, -71, -71, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 109, 58, + 58, 58, 58, 58, 58, 58, 58, -71 + }, + + { + 11, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, 58, -72, -72, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 110, 58, 58, 58, 58, 58, -72 + }, + + { + 11, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, 58, -73, -73, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 111, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -73 + }, + + { + 11, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, 58, -74, -74, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 112, 58, -74 + + }, + + { + 11, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, 58, -75, -75, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 113, 58, 58, 58, 58, -75 + }, + + { + 11, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, 58, -76, -76, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 114, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -76 + }, + + { + 11, 77, 77, -77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77 + }, + + { + 11, -78, 78, 79, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78 + }, + + { + 11, 80, -79, -79, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80 + + }, + + { + 11, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80 + }, + + { + 11, 81, 81, 82, 81, -81, 81, 81, -81, 81, + 81, 81, 81, 81, 81, -81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81 + }, + + { + 11, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82 + }, + + { + 11, -83, -83, 84, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83 + }, + + { + 11, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84 + + }, + + { + 11, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85 + }, + + { + 11, 86, 86, -86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86 + }, + + { + 11, -87, -87, -87, -87, -87, -87, -87, -87, -87, + -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, + + -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, + -87, -87, -87, -87, -87, -87, -87, -87 + }, + + { + 11, -88, -88, -88, -88, -88, -88, -88, -88, -88, + -88, 115, 89, 89, -88, -88, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -88 + }, + + { + 11, -89, -89, -89, -89, -89, -89, -89, -89, -89, + -89, 89, 89, 89, -89, -89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -89 + + }, + + { + 11, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, -90, -90, -90, -90, -90, -90, -90 + }, + + { + 11, -91, -91, -91, -91, -91, -91, -91, -91, -91, + -91, 89, 89, 89, -91, -91, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -91 + }, + + { + 11, -92, -92, -92, -92, -92, -92, -92, -92, -92, + -92, 89, 89, 89, -92, -92, 89, 89, 89, 89, + + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -92 + }, + + { + 11, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, -93, -93 + }, + + { + 11, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, 58, -94, -94, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 116, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -94 + + }, + + { + 11, -95, -95, -95, -95, -95, -95, -95, -95, -95, + -95, -95, -95, 58, -95, -95, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 117, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -95 + }, + + { + 11, -96, -96, -96, -96, -96, -96, -96, -96, -96, + -96, -96, -96, 58, -96, -96, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 118, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -96 + }, + + { + 11, -97, -97, -97, -97, -97, -97, -97, -97, -97, + -97, -97, -97, 58, -97, -97, 58, 58, 58, 58, + + 58, 58, 119, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -97 + }, + + { + 11, -98, -98, -98, -98, -98, -98, -98, -98, -98, + -98, -98, -98, 58, -98, -98, 120, 121, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -98 + }, + + { + 11, -99, -99, -99, -99, -99, -99, -99, -99, -99, + -99, -99, -99, 58, -99, -99, 58, 58, 58, 58, + 58, 122, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -99 + + }, + + { + 11, -100, -100, -100, -100, -100, -100, -100, -100, -100, + -100, -100, -100, 58, -100, -100, 58, 58, 123, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -100 + }, + + { + 11, -101, -101, -101, -101, -101, -101, -101, -101, -101, + -101, -101, -101, 58, -101, -101, 58, 58, 58, 124, + 58, 58, 58, 58, 58, 125, 58, 126, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -101 + }, + + { + 11, -102, -102, -102, -102, -102, -102, -102, -102, -102, + -102, -102, -102, 58, -102, -102, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 127, 58, 58, 58, 58, 58, 58, -102 + }, + + { + 11, -103, -103, -103, -103, -103, -103, -103, -103, -103, + -103, -103, -103, 58, -103, -103, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -103 + }, + + { + 11, -104, -104, -104, -104, -104, -104, -104, -104, -104, + -104, -104, -104, 58, -104, -104, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -104 + + }, + + { + 11, -105, -105, -105, -105, -105, -105, -105, -105, -105, + -105, -105, -105, 58, -105, -105, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 128, 58, + 58, 58, 58, 58, 58, 58, 58, -105 + }, + + { + 11, -106, -106, -106, -106, -106, -106, -106, -106, -106, + -106, -106, -106, 58, -106, -106, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 129, 58, -106 + }, + + { + 11, -107, -107, -107, -107, -107, -107, -107, -107, -107, + -107, -107, -107, 58, -107, -107, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 130, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -107 + }, + + { + 11, -108, -108, -108, -108, -108, -108, -108, -108, -108, + -108, -108, -108, 58, -108, -108, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 131, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -108 + }, + + { + 11, -109, -109, -109, -109, -109, -109, -109, -109, -109, + -109, -109, -109, 58, -109, -109, 58, 58, 58, 58, + 58, 58, 58, 132, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -109 + + }, + + { + 11, -110, -110, -110, -110, -110, -110, -110, -110, -110, + -110, -110, -110, 58, -110, -110, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 133, 58, -110 + }, + + { + 11, -111, -111, -111, -111, -111, -111, -111, -111, -111, + -111, -111, -111, 58, -111, -111, 58, 58, 58, 58, + 58, 134, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -111 + }, + + { + 11, -112, -112, -112, -112, -112, -112, -112, -112, -112, + -112, -112, -112, 58, -112, -112, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 135, 58, 58, 58, 58, -112 + }, + + { + 11, -113, -113, -113, -113, -113, -113, -113, -113, -113, + -113, -113, -113, 58, -113, -113, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 136, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -113 + }, + + { + 11, -114, -114, -114, -114, -114, -114, -114, -114, -114, + -114, -114, -114, 58, -114, -114, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 137, 58, 58, 58, -114 + + }, + + { + 11, -115, -115, -115, -115, -115, -115, -115, -115, -115, + -115, 89, 89, 89, -115, -115, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -115 + }, + + { + 11, -116, -116, -116, -116, -116, -116, -116, -116, -116, + -116, -116, -116, 58, -116, -116, 58, 58, 58, 58, + 58, 138, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -116 + }, + + { + 11, -117, -117, -117, -117, -117, -117, -117, -117, -117, + -117, -117, -117, 58, -117, -117, 58, 58, 58, 139, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -117 + }, + + { + 11, -118, -118, -118, -118, -118, -118, -118, -118, -118, + -118, -118, -118, 58, -118, -118, 58, 58, 58, 58, + 58, 140, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -118 + }, + + { + 11, -119, -119, -119, -119, -119, -119, -119, -119, -119, + -119, -119, -119, 58, -119, -119, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 141, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -119 + + }, + + { + 11, -120, -120, -120, -120, -120, -120, -120, -120, -120, + -120, -120, -120, 58, -120, -120, 58, 58, 142, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 143, 58, 58, -120 + }, + + { + 11, -121, -121, -121, -121, -121, -121, -121, -121, -121, + -121, -121, -121, 58, -121, -121, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 144, 58, -121 + }, + + { + 11, -122, -122, -122, -122, -122, -122, -122, -122, -122, + -122, -122, -122, 58, -122, -122, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 145, 58, + 58, 58, 58, 58, 58, 58, 58, -122 + }, + + { + 11, -123, -123, -123, -123, -123, -123, -123, -123, -123, + -123, -123, -123, 58, -123, -123, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 146, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -123 + }, + + { + 11, -124, -124, -124, -124, -124, -124, -124, -124, -124, + -124, -124, -124, 58, -124, -124, 58, 58, 58, 58, + 58, 58, 58, 58, 147, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -124 + + }, + + { + 11, -125, -125, -125, -125, -125, -125, -125, -125, -125, + -125, -125, -125, 58, -125, -125, 58, 58, 58, 58, + 58, 58, 148, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -125 + }, + + { + 11, -126, -126, -126, -126, -126, -126, -126, -126, -126, + -126, -126, -126, 58, -126, -126, 58, 58, 58, 58, + 58, 149, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -126 + }, + + { + 11, -127, -127, -127, -127, -127, -127, -127, -127, -127, + -127, -127, -127, 58, -127, -127, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -127 + }, + + { + 11, -128, -128, -128, -128, -128, -128, -128, -128, -128, + -128, -128, -128, 58, -128, -128, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 150, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -128 + }, + + { + 11, -129, -129, -129, -129, -129, -129, -129, -129, -129, + -129, -129, -129, 58, -129, -129, 58, 58, 58, 151, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -129 + + }, + + { + 11, -130, -130, -130, -130, -130, -130, -130, -130, -130, + -130, -130, -130, 58, -130, -130, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 152, + 58, 58, 58, 58, 58, 58, 58, -130 + }, + + { + 11, -131, -131, -131, -131, -131, -131, -131, -131, -131, + -131, -131, -131, 58, -131, -131, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 153, 58, 58, 58, 58, 58, 58, -131 + }, + + { + 11, -132, -132, -132, -132, -132, -132, -132, -132, -132, + -132, -132, -132, 58, -132, -132, 58, 58, 58, 58, + + 58, 154, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -132 + }, + + { + 11, -133, -133, -133, -133, -133, -133, -133, -133, -133, + -133, -133, -133, 58, -133, -133, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 155, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -133 + }, + + { + 11, -134, -134, -134, -134, -134, -134, -134, -134, -134, + -134, -134, -134, 58, -134, -134, 58, 58, 58, 156, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -134 + + }, + + { + 11, -135, -135, -135, -135, -135, -135, -135, -135, -135, + -135, -135, -135, 58, -135, -135, 58, 58, 58, 157, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -135 + }, + + { + 11, -136, -136, -136, -136, -136, -136, -136, -136, -136, + -136, -136, -136, 58, -136, -136, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 158, 58, + 58, 58, 58, 58, 58, 58, 58, -136 + }, + + { + 11, -137, -137, -137, -137, -137, -137, -137, -137, -137, + -137, -137, -137, 58, -137, -137, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 159, 58, 58, -137 + }, + + { + 11, -138, -138, -138, -138, -138, -138, -138, -138, -138, + -138, -138, -138, 58, -138, -138, 58, 160, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -138 + }, + + { + 11, -139, -139, -139, -139, -139, -139, -139, -139, -139, + -139, -139, -139, 58, -139, -139, 58, 58, 58, 58, + 58, 161, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -139 + + }, + + { + 11, -140, -140, -140, -140, -140, -140, -140, -140, -140, + -140, -140, -140, 58, -140, -140, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 162, 58, + 58, 58, 58, 58, 58, 58, 58, -140 + }, + + { + 11, -141, -141, -141, -141, -141, -141, -141, -141, -141, + -141, -141, -141, 58, -141, -141, 58, 58, 58, 58, + 58, 58, 58, 163, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -141 + }, + + { + 11, -142, -142, -142, -142, -142, -142, -142, -142, -142, + -142, -142, -142, 58, -142, -142, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 164, + 58, 58, 58, 58, 58, 58, 58, -142 + }, + + { + 11, -143, -143, -143, -143, -143, -143, -143, -143, -143, + -143, -143, -143, 58, -143, -143, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 165, 58, 58, 58, 58, -143 + }, + + { + 11, -144, -144, -144, -144, -144, -144, -144, -144, -144, + -144, -144, -144, 58, -144, -144, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 166, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -144 + + }, + + { + 11, -145, -145, -145, -145, -145, -145, -145, -145, -145, + -145, -145, -145, 58, -145, -145, 58, 58, 58, 58, + 167, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -145 + }, + + { + 11, -146, -146, -146, -146, -146, -146, -146, -146, -146, + -146, -146, -146, 58, -146, -146, 58, 58, 58, 58, + 58, 168, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -146 + }, + + { + 11, -147, -147, -147, -147, -147, -147, -147, -147, -147, + -147, -147, -147, 58, -147, -147, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 169, + 58, 58, 58, 58, 58, 58, 58, -147 + }, + + { + 11, -148, -148, -148, -148, -148, -148, -148, -148, -148, + -148, -148, -148, 58, -148, -148, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -148 + }, + + { + 11, -149, -149, -149, -149, -149, -149, -149, -149, -149, + -149, -149, -149, 58, -149, -149, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 170, 58, + 58, 58, 58, 58, 58, 58, 58, -149 + + }, + + { + 11, -150, -150, -150, -150, -150, -150, -150, -150, -150, + -150, -150, -150, 58, -150, -150, 58, 58, 58, 58, + 58, 171, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -150 + }, + + { + 11, -151, -151, -151, -151, -151, -151, -151, -151, -151, + -151, -151, -151, 58, -151, -151, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 172, + 58, 58, 58, 58, 58, 58, 58, -151 + }, + + { + 11, -152, -152, -152, -152, -152, -152, -152, -152, -152, + -152, -152, -152, 58, -152, -152, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 173, 58, + 58, 58, 58, 58, 58, 58, 58, -152 + }, + + { + 11, -153, -153, -153, -153, -153, -153, -153, -153, -153, + -153, -153, -153, 58, -153, -153, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 174, 58, 58, -153 + }, + + { + 11, -154, -154, -154, -154, -154, -154, -154, -154, -154, + -154, -154, -154, 58, -154, -154, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -154 + + }, + + { + 11, -155, -155, -155, -155, -155, -155, -155, -155, -155, + -155, -155, -155, 58, -155, -155, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 175, 58, 58, 58, 58, -155 + }, + + { + 11, -156, -156, -156, -156, -156, -156, -156, -156, -156, + -156, -156, -156, 58, -156, -156, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 176, 58, 58, -156 + }, + + { + 11, -157, -157, -157, -157, -157, -157, -157, -157, -157, + -157, -157, -157, 58, -157, -157, 58, 58, 58, 58, + + 58, 177, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -157 + }, + + { + 11, -158, -158, -158, -158, -158, -158, -158, -158, -158, + -158, -158, -158, 58, -158, -158, 58, 58, 58, 58, + 58, 58, 58, 178, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -158 + }, + + { + 11, -159, -159, -159, -159, -159, -159, -159, -159, -159, + -159, -159, -159, 58, -159, -159, 58, 179, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -159 + + }, + + { + 11, -160, -160, -160, -160, -160, -160, -160, -160, -160, + -160, -160, -160, 58, -160, -160, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 180, 58, + 58, 58, 58, 58, 58, 58, 58, -160 + }, + + { + 11, -161, -161, -161, -161, -161, -161, -161, -161, -161, + -161, -161, -161, 58, -161, -161, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -161 + }, + + { + 11, -162, -162, -162, -162, -162, -162, -162, -162, -162, + -162, -162, -162, 58, -162, -162, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 181, 58, 58, -162 + }, + + { + 11, -163, -163, -163, -163, -163, -163, -163, -163, -163, + -163, -163, -163, 58, -163, -163, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -163 + }, + + { + 11, -164, -164, -164, -164, -164, -164, -164, -164, -164, + -164, -164, -164, 58, -164, -164, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 182, + 58, 58, 58, 58, 58, 58, 58, -164 + + }, + + { + 11, -165, -165, -165, -165, -165, -165, -165, -165, -165, + -165, -165, -165, 58, -165, -165, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 183, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -165 + }, + + { + 11, -166, -166, -166, -166, -166, -166, -166, -166, -166, + -166, -166, -166, 58, -166, -166, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 184, 58, 58, -166 + }, + + { + 11, -167, -167, -167, -167, -167, -167, -167, -167, -167, + -167, -167, -167, 58, -167, -167, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 185, 58, 58, 58, -167 + }, + + { + 11, -168, -168, -168, -168, -168, -168, -168, -168, -168, + -168, -168, -168, 58, -168, -168, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -168 + }, + + { + 11, -169, -169, -169, -169, -169, -169, -169, -169, -169, + -169, -169, -169, 58, -169, -169, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 186, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -169 + + }, + + { + 11, -170, -170, -170, -170, -170, -170, -170, -170, -170, + -170, -170, -170, 58, -170, -170, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 187, 58, -170 + }, + + { + 11, -171, -171, -171, -171, -171, -171, -171, -171, -171, + -171, -171, -171, 58, -171, -171, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 188, 58, + 58, 58, 58, 58, 58, 58, 58, -171 + }, + + { + 11, -172, -172, -172, -172, -172, -172, -172, -172, -172, + -172, -172, -172, 58, -172, -172, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 189, 58, + 58, 58, 58, 58, 58, 58, 58, -172 + }, + + { + 11, -173, -173, -173, -173, -173, -173, -173, -173, -173, + -173, -173, -173, 58, -173, -173, 58, 190, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -173 + }, + + { + 11, -174, -174, -174, -174, -174, -174, -174, -174, -174, + -174, -174, -174, 58, -174, -174, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -174 + + }, + + { + 11, -175, -175, -175, -175, -175, -175, -175, -175, -175, + -175, -175, -175, 58, -175, -175, 58, 58, 58, 58, + 58, 191, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -175 + }, + + { + 11, -176, -176, -176, -176, -176, -176, -176, -176, -176, + -176, -176, -176, 58, -176, -176, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -176 + }, + + { + 11, -177, -177, -177, -177, -177, -177, -177, -177, -177, + -177, -177, -177, 58, -177, -177, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -177 + }, + + { + 11, -178, -178, -178, -178, -178, -178, -178, -178, -178, + -178, -178, -178, 58, -178, -178, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -178 + }, + + { + 11, -179, -179, -179, -179, -179, -179, -179, -179, -179, + -179, -179, -179, 58, -179, -179, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 192, 58, 58, -179 + + }, + + { + 11, -180, -180, -180, -180, -180, -180, -180, -180, -180, + -180, -180, -180, 58, -180, -180, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -180 + }, + + { + 11, -181, -181, -181, -181, -181, -181, -181, -181, -181, + -181, -181, -181, 58, -181, -181, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -181 + }, + + { + 11, -182, -182, -182, -182, -182, -182, -182, -182, -182, + -182, -182, -182, 58, -182, -182, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 193, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -182 + }, + + { + 11, -183, -183, -183, -183, -183, -183, -183, -183, -183, + -183, -183, -183, 58, -183, -183, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 194, 58, 58, 58, -183 + }, + + { + 11, -184, -184, -184, -184, -184, -184, -184, -184, -184, + -184, -184, -184, 58, -184, -184, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -184 + + }, + + { + 11, -185, -185, -185, -185, -185, -185, -185, -185, -185, + -185, -185, -185, 58, -185, -185, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -185 + }, + + { + 11, -186, -186, -186, -186, -186, -186, -186, -186, -186, + -186, -186, -186, 58, -186, -186, 58, 58, 58, 195, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -186 + }, + + { + 11, -187, -187, -187, -187, -187, -187, -187, -187, -187, + -187, -187, -187, 58, -187, -187, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -187 + }, + + { + 11, -188, -188, -188, -188, -188, -188, -188, -188, -188, + -188, -188, -188, 58, -188, -188, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 196, 58, -188 + }, + + { + 11, -189, -189, -189, -189, -189, -189, -189, -189, -189, + -189, -189, -189, 58, -189, -189, 58, 58, 58, 58, + 58, 58, 197, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -189 + + }, + + { + 11, -190, -190, -190, -190, -190, -190, -190, -190, -190, + -190, -190, -190, 58, -190, -190, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 198, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -190 + }, + + { + 11, -191, -191, -191, -191, -191, -191, -191, -191, -191, + -191, -191, -191, 58, -191, -191, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 199, 58, 58, 58, -191 + }, + + { + 11, -192, -192, -192, -192, -192, -192, -192, -192, -192, + -192, -192, -192, 58, -192, -192, 58, 58, 58, 58, + + 58, 200, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -192 + }, + + { + 11, -193, -193, -193, -193, -193, -193, -193, -193, -193, + -193, -193, -193, 58, -193, -193, 58, 58, 58, 58, + 58, 201, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -193 + }, + + { + 11, -194, -194, -194, -194, -194, -194, -194, -194, -194, + -194, -194, -194, 58, -194, -194, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 202, 58, 58, -194 + + }, + + { + 11, -195, -195, -195, -195, -195, -195, -195, -195, -195, + -195, -195, -195, 58, -195, -195, 58, 58, 58, 58, + 58, 203, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -195 + }, + + { + 11, -196, -196, -196, -196, -196, -196, -196, -196, -196, + -196, -196, -196, 58, -196, -196, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -196 + }, + + { + 11, -197, -197, -197, -197, -197, -197, -197, -197, -197, + -197, -197, -197, 58, -197, -197, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 204, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -197 + }, + + { + 11, -198, -198, -198, -198, -198, -198, -198, -198, -198, + -198, -198, -198, 58, -198, -198, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -198 + }, + + { + 11, -199, -199, -199, -199, -199, -199, -199, -199, -199, + -199, -199, -199, 58, -199, -199, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -199 + + }, + + { + 11, -200, -200, -200, -200, -200, -200, -200, -200, -200, + -200, -200, -200, 58, -200, -200, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -200 + }, + + { + 11, -201, -201, -201, -201, -201, -201, -201, -201, -201, + -201, -201, -201, 58, -201, -201, 58, 205, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -201 + }, + + { + 11, -202, -202, -202, -202, -202, -202, -202, -202, -202, + -202, -202, -202, 58, -202, -202, 58, 206, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -202 + }, + + { + 11, -203, -203, -203, -203, -203, -203, -203, -203, -203, + -203, -203, -203, 58, -203, -203, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -203 + }, + + { + 11, -204, -204, -204, -204, -204, -204, -204, -204, -204, + -204, -204, -204, 58, -204, -204, 58, 58, 58, 58, + 58, 58, 58, 207, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -204 + + }, + + { + 11, -205, -205, -205, -205, -205, -205, -205, -205, -205, + -205, -205, -205, 58, -205, -205, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 208, 58, + 58, 58, 58, 58, 58, 58, 58, -205 + }, + + { + 11, -206, -206, -206, -206, -206, -206, -206, -206, -206, + -206, -206, -206, 58, -206, -206, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 209, 58, 58, -206 + }, + + { + 11, -207, -207, -207, -207, -207, -207, -207, -207, -207, + -207, -207, -207, 58, -207, -207, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -207 + }, + + { + 11, -208, -208, -208, -208, -208, -208, -208, -208, -208, + -208, -208, -208, 58, -208, -208, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -208 + }, + + { + 11, -209, -209, -209, -209, -209, -209, -209, -209, -209, + -209, -209, -209, 58, -209, -209, 58, 58, 58, 58, + 58, 210, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -209 + + }, + + { + 11, -210, -210, -210, -210, -210, -210, -210, -210, -210, + -210, -210, -210, 58, -210, -210, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -210 + }, + + } ; + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up zconftext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + zconfleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 64 +#define YY_END_OF_BUFFER 65 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[211] = + { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 65, 5, 4, 3, 2, 36, 37, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 63, 60, 62, 55, 59, 58, 57, 53, 48, 42, + 47, 51, 53, 40, 41, 50, 50, 43, 53, 50, + 50, 53, 4, 3, 2, 2, 1, 35, 35, 35, + 35, 35, 35, 35, 16, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 63, 60, 62, 61, + 55, 54, 57, 56, 44, 51, 38, 50, 50, 52, + 45, 46, 39, 35, 35, 35, 35, 35, 35, 35, + + 35, 35, 30, 29, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 49, 25, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 15, 35, 7, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 17, 35, 35, + 35, 35, 35, 34, 35, 35, 35, 35, 35, 35, + 10, 35, 13, 35, 35, 35, 35, 33, 35, 35, + 35, 35, 35, 22, 35, 32, 9, 31, 35, 26, + 12, 35, 35, 21, 18, 35, 8, 35, 35, 35, + 35, 35, 27, 35, 35, 6, 35, 20, 19, 23, + + 35, 35, 11, 35, 35, 35, 14, 28, 35, 24 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 5, 6, 1, 1, 7, 8, 9, + 10, 1, 1, 1, 11, 12, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, + 14, 1, 1, 1, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 1, 15, 1, 1, 16, 1, 17, 18, 19, 20, + + 21, 22, 23, 24, 25, 13, 13, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 13, 13, 36, + 13, 13, 1, 37, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +extern int zconf_flex_debug; +int zconf_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *zconftext; + +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +#define START_STRSIZE 16 + +char *text; +static char *text_ptr; +static int text_size, text_asize; + +struct buffer { + struct buffer *parent; + YY_BUFFER_STATE state; +}; + +struct buffer *current_buf; + +static int last_ts, first_ts; + +static void zconf_endhelp(void); +static struct buffer *zconf_endfile(void); + +void new_string(void) +{ + text = malloc(START_STRSIZE); + text_asize = START_STRSIZE; + text_ptr = text; + text_size = 0; + *text_ptr = 0; +} + +void append_string(const char *str, int size) +{ + int new_size = text_size + size + 1; + if (new_size > text_asize) { + text = realloc(text, new_size); + text_asize = new_size; + text_ptr = text + text_size; + } + memcpy(text_ptr, str, size); + text_ptr += size; + text_size += size; + *text_ptr = 0; +} + +void alloc_string(const char *str, int size) +{ + text = malloc(size + 1); + memcpy(text, str, size); + text[size] = 0; +} + +#define INITIAL 0 +#define COMMAND 1 +#define HELP 2 +#define STRING 3 +#define PARAM 4 + +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int zconfwrap (void ); +#else +extern int zconfwrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( zconftext, zconfleng, 1, zconfout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + errno=0; \ + while ( (result = read( fileno(zconfin), (char *) buf, max_size )) < 0 ) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(zconfin); \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int zconflex (void); + +#define YY_DECL int zconflex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after zconftext and zconfleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + + int str = 0; + int ts, i; + + if ( (yy_init) ) + { + (yy_init) = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! zconfin ) + zconfin = stdin; + + if ( ! zconfout ) + zconfout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + zconfensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + zconf_create_buffer(zconfin,YY_BUF_SIZE ); + } + + zconf_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of zconftext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 ) + ++yy_cp; + + yy_current_state = -yy_current_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +current_file->lineno++; + YY_BREAK +case 2: +YY_RULE_SETUP + + YY_BREAK +case 3: +/* rule 3 can match eol */ +YY_RULE_SETUP +current_file->lineno++; return T_EOL; + YY_BREAK +case 4: +YY_RULE_SETUP +{ + BEGIN(COMMAND); +} + YY_BREAK +case 5: +YY_RULE_SETUP +{ + unput(zconftext[0]); + BEGIN(COMMAND); +} + YY_BREAK + +case 6: +YY_RULE_SETUP +BEGIN(PARAM); return T_MAINMENU; + YY_BREAK +case 7: +YY_RULE_SETUP +BEGIN(PARAM); return T_MENU; + YY_BREAK +case 8: +YY_RULE_SETUP +BEGIN(PARAM); return T_ENDMENU; + YY_BREAK +case 9: +YY_RULE_SETUP +BEGIN(PARAM); return T_SOURCE; + YY_BREAK +case 10: +YY_RULE_SETUP +BEGIN(PARAM); return T_CHOICE; + YY_BREAK +case 11: +YY_RULE_SETUP +BEGIN(PARAM); return T_ENDCHOICE; + YY_BREAK +case 12: +YY_RULE_SETUP +BEGIN(PARAM); return T_COMMENT; + YY_BREAK +case 13: +YY_RULE_SETUP +BEGIN(PARAM); return T_CONFIG; + YY_BREAK +case 14: +YY_RULE_SETUP +BEGIN(PARAM); return T_MENUCONFIG; + YY_BREAK +case 15: +YY_RULE_SETUP +BEGIN(PARAM); return T_HELP; + YY_BREAK +case 16: +YY_RULE_SETUP +BEGIN(PARAM); return T_IF; + YY_BREAK +case 17: +YY_RULE_SETUP +BEGIN(PARAM); return T_ENDIF; + YY_BREAK +case 18: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEPENDS; + YY_BREAK +case 19: +YY_RULE_SETUP +BEGIN(PARAM); return T_REQUIRES; + YY_BREAK +case 20: +YY_RULE_SETUP +BEGIN(PARAM); return T_OPTIONAL; + YY_BREAK +case 21: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEFAULT; + YY_BREAK +case 22: +YY_RULE_SETUP +BEGIN(PARAM); return T_PROMPT; + YY_BREAK +case 23: +YY_RULE_SETUP +BEGIN(PARAM); return T_TRISTATE; + YY_BREAK +case 24: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEF_TRISTATE; + YY_BREAK +case 25: +YY_RULE_SETUP +BEGIN(PARAM); return T_BOOLEAN; + YY_BREAK +case 26: +YY_RULE_SETUP +BEGIN(PARAM); return T_BOOLEAN; + YY_BREAK +case 27: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEF_BOOLEAN; + YY_BREAK +case 28: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEF_BOOLEAN; + YY_BREAK +case 29: +YY_RULE_SETUP +BEGIN(PARAM); return T_INT; + YY_BREAK +case 30: +YY_RULE_SETUP +BEGIN(PARAM); return T_HEX; + YY_BREAK +case 31: +YY_RULE_SETUP +BEGIN(PARAM); return T_STRING; + YY_BREAK +case 32: +YY_RULE_SETUP +BEGIN(PARAM); return T_SELECT; + YY_BREAK +case 33: +YY_RULE_SETUP +BEGIN(PARAM); return T_SELECT; + YY_BREAK +case 34: +YY_RULE_SETUP +BEGIN(PARAM); return T_RANGE; + YY_BREAK +case 35: +YY_RULE_SETUP +{ + alloc_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD; + } + YY_BREAK +case 36: +YY_RULE_SETUP + + YY_BREAK +case 37: +/* rule 37 can match eol */ +YY_RULE_SETUP +current_file->lineno++; BEGIN(INITIAL); + YY_BREAK + +case 38: +YY_RULE_SETUP +return T_AND; + YY_BREAK +case 39: +YY_RULE_SETUP +return T_OR; + YY_BREAK +case 40: +YY_RULE_SETUP +return T_OPEN_PAREN; + YY_BREAK +case 41: +YY_RULE_SETUP +return T_CLOSE_PAREN; + YY_BREAK +case 42: +YY_RULE_SETUP +return T_NOT; + YY_BREAK +case 43: +YY_RULE_SETUP +return T_EQUAL; + YY_BREAK +case 44: +YY_RULE_SETUP +return T_UNEQUAL; + YY_BREAK +case 45: +YY_RULE_SETUP +return T_IF; + YY_BREAK +case 46: +YY_RULE_SETUP +return T_ON; + YY_BREAK +case 47: +YY_RULE_SETUP +{ + str = zconftext[0]; + new_string(); + BEGIN(STRING); + } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +BEGIN(INITIAL); current_file->lineno++; return T_EOL; + YY_BREAK +case 49: +YY_RULE_SETUP +/* ignore */ + YY_BREAK +case 50: +YY_RULE_SETUP +{ + alloc_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD; + } + YY_BREAK +case 51: +YY_RULE_SETUP +/* comment */ + YY_BREAK +case 52: +/* rule 52 can match eol */ +YY_RULE_SETUP +current_file->lineno++; + YY_BREAK +case 53: +YY_RULE_SETUP + + YY_BREAK +case YY_STATE_EOF(PARAM): +{ + BEGIN(INITIAL); + } + YY_BREAK + +case 54: +/* rule 54 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + append_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD_QUOTE; + } + YY_BREAK +case 55: +YY_RULE_SETUP +{ + append_string(zconftext, zconfleng); + } + YY_BREAK +case 56: +/* rule 56 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + append_string(zconftext + 1, zconfleng - 1); + zconflval.string = text; + return T_WORD_QUOTE; + } + YY_BREAK +case 57: +YY_RULE_SETUP +{ + append_string(zconftext + 1, zconfleng - 1); + } + YY_BREAK +case 58: +YY_RULE_SETUP +{ + if (str == zconftext[0]) { + BEGIN(PARAM); + zconflval.string = text; + return T_WORD_QUOTE; + } else + append_string(zconftext, 1); + } + YY_BREAK +case 59: +/* rule 59 can match eol */ +YY_RULE_SETUP +{ + printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); + current_file->lineno++; + BEGIN(INITIAL); + return T_EOL; + } + YY_BREAK +case YY_STATE_EOF(STRING): +{ + BEGIN(INITIAL); + } + YY_BREAK + +case 60: +YY_RULE_SETUP +{ + ts = 0; + for (i = 0; i < zconfleng; i++) { + if (zconftext[i] == '\t') + ts = (ts & ~7) + 8; + else + ts++; + } + last_ts = ts; + if (first_ts) { + if (ts < first_ts) { + zconf_endhelp(); + return T_HELPTEXT; + } + ts -= first_ts; + while (ts > 8) { + append_string(" ", 8); + ts -= 8; + } + append_string(" ", ts); + } + } + YY_BREAK +case 61: +/* rule 61 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + current_file->lineno++; + zconf_endhelp(); + return T_HELPTEXT; + } + YY_BREAK +case 62: +/* rule 62 can match eol */ +YY_RULE_SETUP +{ + current_file->lineno++; + append_string("\n", 1); + } + YY_BREAK +case 63: +YY_RULE_SETUP +{ + append_string(zconftext, zconfleng); + if (!first_ts) + first_ts = last_ts; + } + YY_BREAK +case YY_STATE_EOF(HELP): +{ + zconf_endhelp(); + return T_HELPTEXT; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMAND): +{ + if (current_buf) { + zconf_endfile(); + return T_EOF; + } + fclose(zconfin); + yyterminate(); +} + YY_BREAK +case 64: +YY_RULE_SETUP +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed zconfin at a new source and called + * zconflex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = zconfin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( zconfwrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * zconftext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of zconflex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + zconfrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + zconfrestart(zconfin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + register int yy_is_jam; + + yy_current_state = yy_nxt[yy_current_state][1]; + yy_is_jam = (yy_current_state <= 0); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up zconftext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + zconfrestart(zconfin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( zconfwrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve zconftext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void zconfrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + zconfensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + zconf_create_buffer(zconfin,YY_BUF_SIZE ); + } + + zconf_init_buffer(YY_CURRENT_BUFFER,input_file ); + zconf_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * zconfpop_buffer_state(); + * zconfpush_buffer_state(new_buffer); + */ + zconfensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + zconf_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (zconfwrap()) processing, but the only time this flag + * is looked at is after zconfwrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void zconf_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + zconfin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE zconf_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) zconfalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + zconf_init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with zconf_create_buffer() + * + */ + void zconf_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + zconffree((void *) b->yy_ch_buf ); + + zconffree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a zconfrestart() or at EOF. + */ + static void zconf_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + zconf_flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then zconf_init_buffer was _probably_ + * called from zconfrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void zconf_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + zconf_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + zconfensure_buffer_stack(); + + /* This block is copied from zconf_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from zconf_switch_to_buffer. */ + zconf_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void zconfpop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + zconf_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + zconf_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void zconfensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)zconfrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + zconf_switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to zconflex() will + * scan from a @e copy of @a str. + * @param str a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * zconf_scan_bytes() instead. + */ +YY_BUFFER_STATE zconf_scan_string (yyconst char * str ) +{ + + return zconf_scan_bytes(str,strlen(str) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE zconf_scan_bytes (yyconst char * bytes, int len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) zconfalloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = zconf_scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in zconf_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up zconftext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + zconftext[zconfleng] = (yy_hold_char); \ + (yy_c_buf_p) = zconftext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + zconfleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int zconfget_lineno (void) +{ + + return zconflineno; +} + +/** Get the input stream. + * + */ +FILE *zconfget_in (void) +{ + return zconfin; +} + +/** Get the output stream. + * + */ +FILE *zconfget_out (void) +{ + return zconfout; +} + +/** Get the length of the current token. + * + */ +int zconfget_leng (void) +{ + return zconfleng; +} + +/** Get the current token. + * + */ + +char *zconfget_text (void) +{ + return zconftext; +} + +/** Set the current line number. + * @param line_number + * + */ +void zconfset_lineno (int line_number ) +{ + + zconflineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see zconf_switch_to_buffer + */ +void zconfset_in (FILE * in_str ) +{ + zconfin = in_str ; +} + +void zconfset_out (FILE * out_str ) +{ + zconfout = out_str ; +} + +int zconfget_debug (void) +{ + return zconf_flex_debug; +} + +void zconfset_debug (int bdebug ) +{ + zconf_flex_debug = bdebug ; +} + +/* zconflex_destroy is for both reentrant and non-reentrant scanners. */ +int zconflex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + zconf_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + zconfpop_buffer_state(); + } + + /* Destroy the stack itself. */ + zconffree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *zconfalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *zconfrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void zconffree (void * ptr ) +{ + free( (char *) ptr ); /* see zconfrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#undef YY_NEW_FILE +#undef YY_FLUSH_BUFFER +#undef yy_set_bol +#undef yy_new_buffer +#undef yy_set_interactive +#undef yytext_ptr +#undef YY_DO_BEFORE_ACTION + +#ifdef YY_DECL_IS_OURS +#undef YY_DECL_IS_OURS +#undef YY_DECL +#endif + +void zconf_starthelp(void) +{ + new_string(); + last_ts = first_ts = 0; + BEGIN(HELP); +} + +static void zconf_endhelp(void) +{ + zconflval.string = text; + BEGIN(INITIAL); +} + +/* + * Try to open specified file with following names: + * ./name + * $(srctree)/name + * The latter is used when srctree is separate from objtree + * when compiling the kernel. + * Return NULL if file is not found. + */ +FILE *zconf_fopen(const char *name) +{ + char *env, fullname[PATH_MAX+1]; + FILE *f; + + f = fopen(name, "r"); + if (!f && name[0] != '/') { + env = getenv(SRCTREE); + if (env) { + sprintf(fullname, "%s/%s", env, name); + f = fopen(fullname, "r"); + } + } + return f; +} + +void zconf_initscan(const char *name) +{ + zconfin = zconf_fopen(name); + if (!zconfin) { + printf("can't find file %s\n", name); + exit(1); + } + + current_buf = malloc(sizeof(*current_buf)); + memset(current_buf, 0, sizeof(*current_buf)); + + current_file = file_lookup(name); + current_file->lineno = 1; + current_file->flags = FILE_BUSY; +} + +void zconf_nextfile(const char *name) +{ + struct file *file = file_lookup(name); + struct buffer *buf = malloc(sizeof(*buf)); + memset(buf, 0, sizeof(*buf)); + + current_buf->state = YY_CURRENT_BUFFER; + zconfin = zconf_fopen(name); + if (!zconfin) { + printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); + exit(1); + } + zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE)); + buf->parent = current_buf; + current_buf = buf; + + if (file->flags & FILE_BUSY) { + printf("recursive scan (%s)?\n", name); + exit(1); + } + if (file->flags & FILE_SCANNED) { + printf("file %s already scanned?\n", name); + exit(1); + } + file->flags |= FILE_BUSY; + file->lineno = 1; + file->parent = current_file; + current_file = file; +} + +static struct buffer *zconf_endfile(void) +{ + struct buffer *parent; + + current_file->flags |= FILE_SCANNED; + current_file->flags &= ~FILE_BUSY; + current_file = current_file->parent; + + parent = current_buf->parent; + if (parent) { + fclose(zconfin); + zconf_delete_buffer(YY_CURRENT_BUFFER); + zconf_switch_to_buffer(parent->state); + } + free(current_buf); + current_buf = parent; + + return parent; +} + +int zconf_lineno(void) +{ + if (current_buf) + return current_file->lineno - 1; + else + return 0; +} + +char *zconf_curname(void) +{ + if (current_buf) + return current_file->name; + else + return ""; +} + diff --git a/scripts/kconfig/mconf.o b/scripts/kconfig/mconf.o new file mode 100644 index 0000000000000000000000000000000000000000..61fe000c02c6b0f4616655879d4e953705e48b32 GIT binary patch literal 20532 zcmeHPeRN#KbssH~F|wQ$Ac%8t%A;B14=iD04A|I;{2^lp*wZS?An0_O5--6IBgsbAu9yINvLu8Qh&dh z`=r&Y-JUk5|Md8s^Y%BtnLBsx+_^Jv=4n@Z8=F>@m6a*?DpTjFai-MJLQ`_BhFQw5 zs$5Zxx!0-(RtCz0v5Pk-)mc`2cXV_#ceuL2-}gC`7it0>g_Qx{oiB}!Dm8;2`AgoN zr_}vwzEb@^^!GgusRNn}IeQMUD0ljzJEjyaVP5X-^?Mf}iL0fvwzDk8ly2exQ^C%; z$ZK%(a))bN1B&JMQ`NxocXUI!!&Qd{9=eisj#jW>nohBaAW|cDd>eK%IX7qF9@%$;)oD3bV*qLgwMcuXjA%DLg6~~PjR-gk9LxCFj zEy76=SY$>S%f31IRyGF$m?nj#iYTJG_eb;sfP#nEri} zwwT_BkKEzuhbFdHRk(!h6)O9m&YrLRn)hKyYg*7*TtSTAv|zJt)C@)0Q+YikRJC7M zIKnZ+)o?#Q4^UlhsQiB7p^>TkOE36Kmm5|2YRH*(w6t#b>@6PgDN}FxxCLj>Kbf&L zp;Hzv^scLBHRIQ!Ubv^Bmqq@NL zS{of>t{*ODis5x|KT>xzkg!n@rV_ziaJOo25%zw{-gS_-o;|aXm~gSZd?_;L*F{ATGbGJ=C&)@fbK=3}$TBo$It3g0W99 zZ-X|?+Rtb!EM?OehqBY~{Pg?9#@3=ArWG!Oo8anSY6Teg^4TYigjncW_695{T%t!b zRI~g6E3ebe1v&Vy?{8=}hs59a3S$CEpL2V2^QKsi)*N|zbTq#tpa+`nyo;I3kcqbQ zhjh!cUl?dB&%cm6Ir_cRmtS!Rf%LuNl-$X(2cYt0h(E?B0X*9>VMsfz*4O}*z4`A{ zW)G1h@C~e&M1fzUY?2lO7XxhrXQ|9<-@I6DTb0<#ahUVn|7Wzu#tM5CI&%f$_ z@~PI=VC;`s`CjN2dk|4H$;q7Aobd?LMum(~g;mwL-5A9F9k2_{#dHKM*M(e483@A} z(h^f1`!brwjO(9_O2h9nh|W~Hhovde`=_WfycQ%sJurNbvjL-zJT?4p?~RT!UbHiA zkd|eV~?@s z+i#&IjQlm!FqInmpZ53N2m1<}0^Fi~7Rli^@o^@5j$xjRO{B}ALKcwWNidZ0t7q6G z6u_9VSs5H2fIe;8X1$<1MN4|LCDp^XqVM})KYAk6(-yT&toe0PeCRBleK)@&p*}w zdUjdynSU$k@R!j0u@39K=A&<+`f!DIsdJ@yYWbf$R#2x_2FtAMlvQ_snacW(XJ5{} zKeM;u$(fKp@_Wov!THC7F{aS1>9UDI3MJe+A+tIdW9bHhJ|Uih`D z&{j3_`P|_q{TRr-=lJ^;qe||*Zh!wN31pgGHlI)2kJFr{ zz_jM#K^QsQ#PY_6a;Inc@A??hqk;a1;HOh70@co>+-)^JXK!Hxy0}~xzAGUE4K2fU zkTui1A9H*f8Rb3^z;5E6p&1O7{PMu?Db7~3$bDjQ5tgvw7m-uki}Qp@Eu4hZ^UV7@ z+H=Inix>V^j|6$l`Chb2XqiySEGf{s4f>CGThp72+a72)9 z<(o)v*(Q_neqC#$nW3LIwTg9bLif<_FJc|HSjBxG=j& zUAu)wT?tXh4fHB4%BNEmm-sF==|%+vutWdX;l0Q-tMcnu%4qvhV6bF4<&x{pkJbME z2Uv^~EObwU8E))U>($__^_&aQa%=HsE*)4lBT#}2vj|;>OlX^4*j+X95^`fv^kR6S zu{PFCG7AL#;c2EC!#%xZxQm+jByX$b3R27Bx9E2(1{Zc zJ$Sl&*N)t2Y|!~orzN+s!jI4ZD&N8MGf0nD9vhwSAiKB@iqSbe&%I;Vy!@UU| z*s^WMq1@?;?4MCH-fXG;#oK5*&T)Te=8GAK)$AS*7LfS{`l zn8wAQn)IFQ_A!(0WBMr4ZChg&>@ySSVPq7WO;6ByXAM5?n4&wL9psF~3HaW9OZ7wC zd4u+qh7{JS;xxk+pLFE(jy|M^Hyu>TY^6hDhxGkE_S`evt#z)qjMD}?XI9$82;3}xzJ>F-q=^FMD5=3YKoXskll3k~Hah9L<-BZ-$oD)u9` z#}zw&C@<^%_(QHL7~?Xb2T%*4`pa$wxBvt4J1s4-H<2|qMKFSuM=Q7;N3KFRYOBo) zR#g9HjkH(%#H%`hv^me=c?W&Pheyl^DMV#4|C$!q#|A%X(vz8gt4UWfZ6jS&99LSi z`$@Du5B-&wT*k!uf?jW1J9px(>yT^yqcpFu{oSYKRaa3 z&K~&%?Zq{yKhOSA7fB^M;yceSaIWN>2hMrmoCnT%;G74}dElG}&UxUR2hMrmoCnT% z;G74}dEozr2L`RPcVk&Po!Vt}*?TfpGTa;A8Fp;TiP=`Soy^u*){@4gW2ft_jGeF} zPR7b)+gXyaYHMrjQNB99GnT;Z*ikECJCMy-;k0eVQVw-OBAB)_nRs%iwPZ`Z6;DPI z*{GeFYb{w1IG;|ZrWp0uoO)^@j@D7xdeV0xKJ|BM5yREK79$L_ZFq_Pmr#MlGlPne%bq;|n~ z?R&J`lGfm|6^+*NWi4>7_S{%6!_jEmiKmj`1iXlDcZbQWaC<82pf1cv^)RPyVlRRT zJB%*a97Zc_MeRtu8!CFkiL6~`txAU@ti(Pf5>_(hSnakIjzsJpj3}Jyc7Mr+Wy|Xs zCN#b~)oWWF=~TDrTe1fhbj0mMl!XkQ_N?PjX}gWyS#if>Q>ld>`(pO)u*b&#TN6C( zXPh)+RowG`+q8DW29BJBJ4UAmA&im4xMD0~7_wclcqC@U!gQvcw9MN)OpU08tgx9h zc3tH%5(Hm1fr+7`!PTh;7K5s%#Dq%HzK!V$8(wT2+^wPTC1K zzA8(HPwDkR4|+1(ZM*UAnrULRBMxn)(Vs|#8C=VBoQ+q`#8SJGj3IQyNx>|}(nM9% zk_cxUh+w4bULB-Ob{GNKo(LzqSQ}F!Jr;76t1vBlv8<%9Xr(b15SMe|V61TAJ!8|c z%eH$kCwuKQ=0-H$(E+C<9mG33UOB-8IC{)O94Cv58~WEBj>O_g3`OOd4&B)pjmqEy zL&b%mSDP?F7iKcbw0q2GJFzev5VI>y%QG_wiH@)yR6T(&Fok?IRN#Z#% z(J#6iT(GyGGDb4X<$z{!iN+!XXXs$^4AaDDnh;u=nD{bI(!EBn%$(5LCc0CaMYN0G zF<9`hYcP!auR`TNH;$bDLHzu-aihD+5tfk9-95v=GR70|e|l^Z%;h?OfvyZEqZ}kU z-ilrXqJzWh8Bg;#$&3esd1f&J_`u;uyt^dcCj^pK3eP9Zpm*D0 zJPyWUOUB8Ku1ars)K#j*Q}M?}1cwFuA-*#I818T2z6k7bAR z2mxZed%PmKJnL81z75a}t*|b@oS7CiVLsgx{ z`mLP26RW`Z2@21uf~$dEO1kk}XPtNw57&5F8pT*|KCmQhxn zFrG?DZ1yq^q~XOh_Mj=&8o!$2$?R_HX7hyVospSnr&23ZI)KOaUF-^$w=`BXZhQ5E zZNd!s=(ujCDk~eY^TQBk^~PXV8k;aoQQ6m>NkLtu9`iF5SrM%7J27y(xLmJWzrn0i zSd1q&TEZ%SOKp{vbLPyk8nG_GWaF$eSypGncH5CG#$jf6xXYf&2<5Ipuj8(-;0lbJ zkzg*NUDv9b)~su6RdrWqBI$UKles#vI~orsQai^Isni&2DxDanB7LL&)T z2RTb-MCws#UE}826jj@1M7FDLU9VnUbydBZkrBm~r4ypsHM|ZzNjTkX$Jh+LwY59} zsTonV7Eeq)e-$(?W&@ULQg8q_Qgu?z-tDxfcEd&MR;{@yG$XUPvJy&M54AKdTe-He zZhR4dmUK88PbCoaYW_lX{XBJ@TEA+QYHe(4T(O~XrCPrZGI4IYsdxT7bv?daIbSVY zs5l9&XbSPgjl7;WS13LC&oc9sp4n$Byt%PuU1L)V+FjP#sMa>F+bEq_yMAS(GTWYz z_C;;&9y^mvsfFq~d^O;v6)P57vu;|qakjOfZb98O)~vO7E~ODt5`gpP)y*?Swbyk= zyJjm@m)XItNZvbxcLWPFU5oXEKJSQzpY8YtOG+a1F|IzTxv# z9o%8p!JyiVgXmNEn|L?uc1ot%f1A7<68uX&zNVqC27E5M)TH@|Zyf3CGJIYjX~OL* zl$td~DLxWdAKwj8{Jj%8t@(LCUi+YHma7EZVkWK`xJ&hYb)9L8`dHW1cQw+~>*^c2 z5_0(RgL_$$xB*Bz@I?ZBQLe3|0Za0)1(sy1htTdmRAjsKf!l5a($seiZeA7w;ODM# za@;Hr3c7L?3!tk+jxxMMf&hJ8q<@#-G9yFAudq|zy(kBjW0zZYA#z-wu&@zwyT_!) zbx^*<95s!O!WUsa0Jsh}`^({>PfGPo!}B7{Lb=>_UG8FOe!2S9sGCom_=`dE(iX@o zO2xq^jg1Yz=355NxU-PvuLsEK=M&&}32y@O+asOAJAiD44}Qw$fcwC27ybu8cA9a( z@-G4#z`r2;LEs7SuSok(fDa-tTz$`h^NU2grTnMhyyzd%5d&vM+fXD|35`tJ5W4_=M1SdE+I_kimLB;m!DkzZSY&L&A1z5 zO!-H^Phv7ZgF57g$r0=vU-IX`Ph1H7K=K!X^DZ{=Mb58Zoh;$M1mEw+_j{%O+bjov z9Z2~}=*JNB|E`qRfb%<8wZgApIsCl@oc=4l&QmbF-_j&l;9{za`|B{D)&BGt`@NaqeBOd;^hd=A# zKlJbyJp5lhymXDH|6li%pZ4%_#GQLleu{@zd${G{wH{vY;p;p+;^Cbhp7HQIJ^a%i z{s$iZXC6M};YU3DSr0$v;V*jlOCJ6U4}aIgCovG^qJJ;+@XNqYV7_g^e7p!V%<`09 z<>A+Pc%z30J$$Q&t8SjE>LQ98#85nmty$K*YF1*_7DM4E} zqp6JT;I&9dZyu8=?#WG>Zy!VE%=e!&D5m)KXo5s(hL&j0cJw%D1yDS+@>Purr*|?B zkbz-wC$uYrKV~TWeI=uCM#o1F>~hehIQtak4ixVU6Er5vv@SLd8$TtP-1%<2uw)5fX4SB2QFlS(iW_}(!A2X$j;Rc}W7t3&m~qpAykzQB=Wr`_G- z>|rU=_=}08@S-Ww9nN$yml{~8gAsLmY=t+JT`H1DW#mj63c;3SDwIe?^a~Od&GuZQ zoeOicZ9Nc3rPZ!*++pj`#~1fH=;Ax$8CckkfpP82IvJS;nNV*$6X&0raNr4{haqPV z3?PYTLi+81{zH_WG%SYY=+T(88G?}h^MuMK@fN5H@s)D)DJ&F-hQp)jNY5UX z$wa~&SF`|UgfKI326Ajs!E7hB6YsCRCHjpFl_0p485O>@qGIV*N7^=)Q||=B^f>F& zy-u0hP6Tpc2NR?l$7T~HJ>fKbP9qYjR2PDR$w)X6am_;?@Ykyd4&Y7%?$Fg?J;MVR z*Et_H=L>*kSby}{2G}Tko!}P1DDirwl0=-hGC&_H@jSr%Pf0%a%*_8RagkE|5ia!~ z5abU*$sZTw9;)nvO8q_1w^*r{h&L*|r={FUkt@gAOF90MhjRSa29yghA9Aw=uNT}% z#5&J4o8=+l5#cF82k67bi9h|I{yQbVAoxYe|C(_AG@g2&7yK8&VW4lRQf~-`#I=ojQ3j``CCuN7P@*eJ-~lv9p-D(Vjlj|-*+_XyrYM1Q|RtjGIapbs1Azn1)$ z$QzV;jkpZ^dg5{%*U*M<1)gs}+B}mSavvqG#JfP|<8Be$&U^$*J8>1xM$AWhw-M3) zKIY$~6!!w;pCjV_g5WoRzST+{B(714&v=&eSx$S3#E&WU8zS_)FIWLx)Hg+t&uZVz zN`07!gW3${V;tv@uf^G#9Ceopt`J6ONcmd@`=$JAL>vV8?^js= znBdFI--Nv)IqIE~{L67}Wd2MbgdY?B zitslDr<`xvxl}M9I8ShiV3-JfNuY1DQoX|arTpu{A7MG{IVAig!SnHghJLvmNIi=L zS1}**>&emIHp$Nlevaj+_XXkK6#l62X9eF7T!5Dp)ZZYu7RdTt!m~uQbDLmJ@;@W| zfZ#VI{}I6_1fQ4kcZ5&I@r>=&2=WgZSuzd1S@e) zr@l3USt8o|d!TOz_WC$i)Ba0=zK~KMA>M*@gBVt7G4Up))&VKEO|VOFmtddZX9d45 zc$kRxo)Nqd=X&bDOmHT#9rG4Q{fo#WO06Jb{B6NIS&n|(M}*u1g5M!R|3TqLgg-0% zT_E**2oHSLnVSFdA@mn!LJHFAo!plpEs1}zgQsZ=MM03;X{Il1-~!&1HtD7|55M-!Ji185PVs%DEOM- zNx?S-PYb>)$d}=?t6XrhV3lCCV2$83!RdmQU_fw|;9S9Zg4YV(Ah<+OKWEYYO5v*o Ln*@V`8wCFYs} + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include +#include + +#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) + +#define PRINTD 0x0001 +#define DEBUG_PARSE 0x0002 + +int cdebug = PRINTD; + +extern int zconflex(void); +static void zconfprint(const char *err, ...); +static void zconferror(const char *err); +static bool zconf_endtoken(int token, int starttoken, int endtoken); + +struct symbol *symbol_hash[257]; + +#define YYERROR_VERBOSE + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) + +typedef union YYSTYPE { + int token; + char *string; + struct symbol *symbol; + struct expr *expr; + struct menu *menu; +} YYSTYPE; +/* Line 191 of yacc.c. */ + +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +#define LKC_DIRECT_LINK +#include "lkc.h" + + +/* Line 214 of yacc.c. */ + + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# else +# ifndef YYSTACK_USE_ALLOCA +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC malloc +# define YYSTACK_FREE free +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 2 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 201 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 41 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 104 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 182 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 296 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned short yyprhs[] = +{ + 0, 0, 3, 4, 7, 9, 11, 13, 17, 19, + 21, 23, 26, 28, 30, 32, 34, 36, 38, 42, + 45, 49, 52, 53, 56, 59, 62, 65, 69, 74, + 78, 83, 87, 91, 95, 100, 105, 110, 116, 119, + 122, 124, 128, 131, 132, 135, 138, 141, 144, 149, + 153, 157, 160, 165, 166, 169, 173, 175, 179, 182, + 183, 186, 189, 192, 196, 199, 201, 205, 208, 209, + 212, 215, 218, 222, 226, 228, 232, 235, 238, 241, + 242, 245, 248, 253, 257, 261, 262, 265, 267, 269, + 272, 275, 278, 280, 282, 283, 286, 288, 292, 296, + 300, 303, 307, 311, 313 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 43, 0, -1, -1, 43, 44, -1, 45, -1, 55, + -1, 66, -1, 3, 77, 79, -1, 5, -1, 15, + -1, 8, -1, 1, 79, -1, 61, -1, 71, -1, + 47, -1, 49, -1, 69, -1, 79, -1, 10, 28, + 32, -1, 46, 50, -1, 11, 28, 32, -1, 48, + 50, -1, -1, 50, 51, -1, 50, 75, -1, 50, + 73, -1, 50, 32, -1, 21, 76, 32, -1, 22, + 81, 80, 32, -1, 23, 76, 32, -1, 24, 81, + 80, 32, -1, 26, 76, 32, -1, 27, 76, 32, + -1, 25, 76, 32, -1, 19, 77, 80, 32, -1, + 20, 81, 80, 32, -1, 36, 28, 80, 32, -1, + 37, 82, 82, 80, 32, -1, 7, 32, -1, 52, + 56, -1, 78, -1, 53, 58, 54, -1, 53, 58, + -1, -1, 56, 57, -1, 56, 75, -1, 56, 73, + -1, 56, 32, -1, 19, 77, 80, 32, -1, 21, + 76, 32, -1, 23, 76, 32, -1, 18, 32, -1, + 20, 28, 80, 32, -1, -1, 58, 45, -1, 14, + 81, 32, -1, 78, -1, 59, 62, 60, -1, 59, + 62, -1, -1, 62, 45, -1, 62, 66, -1, 62, + 55, -1, 4, 77, 32, -1, 63, 74, -1, 78, + -1, 64, 67, 65, -1, 64, 67, -1, -1, 67, + 45, -1, 67, 66, -1, 67, 55, -1, 67, 1, + 32, -1, 6, 77, 32, -1, 68, -1, 9, 77, + 32, -1, 70, 74, -1, 12, 32, -1, 72, 13, + -1, -1, 74, 75, -1, 74, 32, -1, 16, 35, + 81, 32, -1, 16, 81, 32, -1, 17, 81, 32, + -1, -1, 77, 80, -1, 28, -1, 29, -1, 5, + 79, -1, 8, 79, -1, 15, 79, -1, 32, -1, + 31, -1, -1, 14, 81, -1, 82, -1, 82, 40, + 82, -1, 82, 30, 82, -1, 34, 81, 33, -1, + 41, 81, -1, 81, 38, 81, -1, 81, 39, 81, + -1, 28, -1, 29, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short yyrline[] = +{ + 0, 94, 94, 95, 98, 99, 100, 101, 102, 103, + 104, 105, 109, 110, 111, 112, 113, 114, 120, 128, + 134, 142, 152, 154, 155, 156, 157, 160, 166, 173, + 179, 186, 192, 198, 204, 210, 216, 222, 230, 239, + 245, 254, 255, 261, 263, 264, 265, 266, 269, 275, + 281, 287, 293, 299, 301, 306, 315, 324, 325, 331, + 333, 334, 335, 340, 347, 353, 362, 363, 369, 371, + 372, 373, 374, 377, 383, 390, 397, 404, 410, 417, + 418, 419, 422, 427, 432, 440, 442, 447, 448, 451, + 452, 453, 457, 457, 459, 460, 463, 464, 465, 466, + 467, 468, 469, 472, 473 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU", + "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", + "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", + "T_REQUIRES", "T_OPTIONAL", "T_PROMPT", "T_DEFAULT", "T_TRISTATE", + "T_DEF_TRISTATE", "T_BOOLEAN", "T_DEF_BOOLEAN", "T_STRING", "T_INT", + "T_HEX", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", "T_EOF", "T_EOL", + "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_ON", "T_SELECT", "T_RANGE", "T_OR", + "T_AND", "T_EQUAL", "T_NOT", "$accept", "input", "block", + "common_block", "config_entry_start", "config_stmt", + "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", + "config_option", "choice", "choice_entry", "choice_end", "choice_stmt", + "choice_option_list", "choice_option", "choice_block", "if", "if_end", + "if_stmt", "if_block", "menu", "menu_entry", "menu_end", "menu_stmt", + "menu_block", "source", "source_stmt", "comment", "comment_stmt", + "help_start", "help", "depends_list", "depends", "prompt_stmt_opt", + "prompt", "end", "nl_or_eof", "if_expr", "expr", "symbol", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 42, 43, 43, 44, 44, 44, 44, 44, 44, + 44, 44, 45, 45, 45, 45, 45, 45, 46, 47, + 48, 49, 50, 50, 50, 50, 50, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 52, 53, + 54, 55, 55, 56, 56, 56, 56, 56, 57, 57, + 57, 57, 57, 58, 58, 59, 60, 61, 61, 62, + 62, 62, 62, 63, 64, 65, 66, 66, 67, 67, + 67, 67, 67, 68, 69, 70, 71, 72, 73, 74, + 74, 74, 75, 75, 75, 76, 76, 77, 77, 78, + 78, 78, 79, 79, 80, 80, 81, 81, 81, 81, + 81, 81, 81, 82, 82 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 0, 2, 1, 1, 1, 3, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 3, 2, + 3, 2, 0, 2, 2, 2, 2, 3, 4, 3, + 4, 3, 3, 3, 4, 4, 4, 5, 2, 2, + 1, 3, 2, 0, 2, 2, 2, 2, 4, 3, + 3, 2, 4, 0, 2, 3, 1, 3, 2, 0, + 2, 2, 2, 3, 2, 1, 3, 2, 0, 2, + 2, 2, 3, 3, 1, 3, 2, 2, 2, 0, + 2, 2, 4, 3, 3, 0, 2, 1, 1, 2, + 2, 2, 1, 1, 0, 2, 1, 3, 3, 3, + 2, 3, 3, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 2, 0, 1, 0, 0, 0, 8, 0, 0, 10, + 0, 0, 0, 0, 9, 93, 92, 3, 4, 22, + 14, 22, 15, 43, 53, 5, 59, 12, 79, 68, + 6, 74, 16, 79, 13, 17, 11, 87, 88, 0, + 0, 0, 38, 0, 0, 0, 103, 104, 0, 0, + 0, 96, 19, 21, 39, 42, 58, 64, 0, 76, + 7, 63, 73, 75, 18, 20, 0, 100, 55, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 85, 0, + 85, 0, 85, 85, 85, 26, 0, 0, 23, 0, + 25, 24, 0, 0, 0, 85, 85, 47, 44, 46, + 45, 0, 0, 0, 54, 41, 40, 60, 62, 57, + 61, 56, 81, 80, 0, 69, 71, 66, 70, 65, + 99, 101, 102, 98, 97, 77, 0, 0, 0, 94, + 94, 0, 94, 94, 0, 94, 0, 0, 0, 94, + 0, 78, 51, 94, 94, 0, 0, 89, 90, 91, + 72, 0, 83, 84, 0, 0, 0, 27, 86, 0, + 29, 0, 33, 31, 32, 0, 94, 0, 0, 49, + 50, 82, 95, 34, 35, 28, 30, 36, 0, 48, + 52, 37 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const short yydefgoto[] = +{ + -1, 1, 17, 18, 19, 20, 21, 22, 52, 88, + 23, 24, 105, 25, 54, 98, 55, 26, 109, 27, + 56, 28, 29, 117, 30, 58, 31, 32, 33, 34, + 89, 90, 57, 91, 131, 132, 106, 35, 155, 50, + 51 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -99 +static const short yypact[] = +{ + -99, 48, -99, 38, 46, 46, -99, 46, -29, -99, + 46, -17, -3, -11, -99, -99, -99, -99, -99, -99, + -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, + -99, -99, -99, -99, -99, -99, -99, -99, -99, 38, + 12, 15, -99, 18, 51, 62, -99, -99, -11, -11, + 4, -24, 138, 138, 160, 121, 110, -4, 81, -4, + -99, -99, -99, -99, -99, -99, -19, -99, -99, -11, + -11, 70, 70, 73, 32, -11, 46, -11, 46, -11, + 46, -11, 46, 46, 46, -99, 36, 70, -99, 95, + -99, -99, 96, 46, 106, 46, 46, -99, -99, -99, + -99, 38, 38, 38, -99, -99, -99, -99, -99, -99, + -99, -99, -99, -99, 112, -99, -99, -99, -99, -99, + -99, 117, -99, -99, -99, -99, -11, 33, 65, 131, + 1, 119, 131, 1, 136, 1, 153, 154, 155, 131, + 70, -99, -99, 131, 131, 156, 157, -99, -99, -99, + -99, 101, -99, -99, -11, 158, 159, -99, -99, 161, + -99, 162, -99, -99, -99, 163, 131, 164, 165, -99, + -99, -99, 99, -99, -99, -99, -99, -99, 166, -99, + -99, -99 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const short yypgoto[] = +{ + -99, -99, -99, 111, -99, -99, -99, -99, 178, -99, + -99, -99, -99, 91, -99, -99, -99, -99, -99, -99, + -99, -99, -99, -99, 115, -99, -99, -99, -99, -99, + -99, 146, 168, 89, 27, 0, 126, -1, -98, -48, + -63 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -68 +static const short yytable[] = +{ + 66, 67, 36, 42, 39, 40, 71, 41, 123, 124, + 43, 44, 74, 75, 120, 154, 72, 46, 47, 69, + 70, 121, 122, 48, 140, 45, 127, 128, 112, 130, + 49, 133, 156, 135, 158, 159, 68, 161, 60, 69, + 70, 165, 69, 70, 61, 167, 168, 62, 2, 3, + 63, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 46, 47, 13, 14, 139, 152, 48, 126, 178, 15, + 16, 69, 70, 49, 37, 38, 129, 166, 151, 15, + 16, -67, 114, 64, -67, 5, 101, 7, 8, 102, + 10, 11, 12, 143, 65, 13, 103, 153, 46, 47, + 147, 148, 149, 69, 70, 125, 172, 134, 141, 136, + 137, 138, 15, 16, 5, 101, 7, 8, 102, 10, + 11, 12, 145, 146, 13, 103, 101, 7, 142, 102, + 10, 11, 12, 171, 144, 13, 103, 69, 70, 69, + 70, 15, 16, 100, 150, 154, 113, 108, 113, 116, + 73, 157, 15, 16, 74, 75, 70, 76, 77, 78, + 79, 80, 81, 82, 83, 84, 104, 107, 160, 115, + 85, 110, 73, 118, 86, 87, 74, 75, 92, 93, + 94, 95, 111, 96, 119, 162, 163, 164, 169, 170, + 173, 174, 97, 175, 176, 177, 179, 180, 181, 53, + 99, 59 +}; + +static const unsigned char yycheck[] = +{ + 48, 49, 3, 32, 4, 5, 30, 7, 71, 72, + 10, 28, 16, 17, 33, 14, 40, 28, 29, 38, + 39, 69, 70, 34, 87, 28, 74, 75, 32, 77, + 41, 79, 130, 81, 132, 133, 32, 135, 39, 38, + 39, 139, 38, 39, 32, 143, 144, 32, 0, 1, + 32, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 28, 29, 14, 15, 28, 32, 34, 35, 166, 31, + 32, 38, 39, 41, 28, 29, 76, 140, 126, 31, + 32, 0, 1, 32, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 93, 32, 14, 15, 32, 28, 29, + 101, 102, 103, 38, 39, 32, 154, 80, 13, 82, + 83, 84, 31, 32, 4, 5, 6, 7, 8, 9, + 10, 11, 95, 96, 14, 15, 5, 6, 32, 8, + 9, 10, 11, 32, 28, 14, 15, 38, 39, 38, + 39, 31, 32, 54, 32, 14, 57, 56, 59, 58, + 12, 32, 31, 32, 16, 17, 39, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 55, 56, 32, 58, + 32, 56, 12, 58, 36, 37, 16, 17, 18, 19, + 20, 21, 56, 23, 58, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 21, + 54, 33 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 43, 0, 1, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 14, 15, 31, 32, 44, 45, 46, + 47, 48, 49, 52, 53, 55, 59, 61, 63, 64, + 66, 68, 69, 70, 71, 79, 79, 28, 29, 77, + 77, 77, 32, 77, 28, 28, 28, 29, 34, 41, + 81, 82, 50, 50, 56, 58, 62, 74, 67, 74, + 79, 32, 32, 32, 32, 32, 81, 81, 32, 38, + 39, 30, 40, 12, 16, 17, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 32, 36, 37, 51, 72, + 73, 75, 18, 19, 20, 21, 23, 32, 57, 73, + 75, 5, 8, 15, 45, 54, 78, 45, 55, 60, + 66, 78, 32, 75, 1, 45, 55, 65, 66, 78, + 33, 81, 81, 82, 82, 32, 35, 81, 81, 77, + 81, 76, 77, 81, 76, 81, 76, 76, 76, 28, + 82, 13, 32, 77, 28, 76, 76, 79, 79, 79, + 32, 81, 32, 32, 14, 80, 80, 32, 80, 80, + 32, 80, 32, 32, 32, 80, 82, 80, 80, 32, + 32, 32, 81, 32, 32, 32, 32, 32, 80, 32, + 32, 32 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + Current.first_line = Rhs[1].first_line; \ + Current.first_column = Rhs[1].first_column; \ + Current.last_line = Rhs[N].last_line; \ + Current.last_column = Rhs[N].last_column; +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (cinluded). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylineno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylineno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + yystate = yyn; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 8: + + { zconfprint("unexpected 'endmenu' statement"); ;} + break; + + case 9: + + { zconfprint("unexpected 'endif' statement"); ;} + break; + + case 10: + + { zconfprint("unexpected 'endchoice' statement"); ;} + break; + + case 11: + + { zconfprint("syntax error"); yyerrok; ;} + break; + + case 18: + + { + struct symbol *sym = sym_lookup(yyvsp[-1].string, 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); +;} + break; + + case 19: + + { + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 20: + + { + struct symbol *sym = sym_lookup(yyvsp[-1].string, 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); +;} + break; + + case 21: + + { + if (current_entry->prompt) + current_entry->prompt->type = P_MENU; + else + zconfprint("warning: menuconfig statement without prompt"); + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 27: + + { + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 28: + + { + menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 29: + + { + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 30: + + { + menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 31: + + { + menu_set_type(S_INT); + printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 32: + + { + menu_set_type(S_HEX); + printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 33: + + { + menu_set_type(S_STRING); + printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 34: + + { + menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 35: + + { + menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 36: + + { + menu_add_symbol(P_SELECT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 37: + + { + menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,yyvsp[-3].symbol, yyvsp[-2].symbol), yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 38: + + { + struct symbol *sym = sym_lookup(NULL, 0); + sym->flags |= SYMBOL_CHOICE; + menu_add_entry(sym); + menu_add_expr(P_CHOICE, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 39: + + { + menu_end_entry(); + menu_add_menu(); +;} + break; + + case 40: + + { + if (zconf_endtoken(yyvsp[0].token, T_CHOICE, T_ENDCHOICE)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); + } +;} + break; + + case 42: + + { + printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +;} + break; + + case 48: + + { + menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 49: + + { + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 50: + + { + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 51: + + { + current_entry->sym->flags |= SYMBOL_OPTIONAL; + printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 52: + + { + menu_add_symbol(P_DEFAULT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 55: + + { + printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); + menu_add_entry(NULL); + menu_add_dep(yyvsp[-1].expr); + menu_end_entry(); + menu_add_menu(); +;} + break; + + case 56: + + { + if (zconf_endtoken(yyvsp[0].token, T_IF, T_ENDIF)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); + } +;} + break; + + case 58: + + { + printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +;} + break; + + case 63: + + { + menu_add_entry(NULL); + menu_add_prop(P_MENU, yyvsp[-1].string, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 64: + + { + menu_end_entry(); + menu_add_menu(); +;} + break; + + case 65: + + { + if (zconf_endtoken(yyvsp[0].token, T_MENU, T_ENDMENU)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); + } +;} + break; + + case 67: + + { + printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +;} + break; + + case 72: + + { zconfprint("invalid menu option"); yyerrok; ;} + break; + + case 73: + + { + yyval.string = yyvsp[-1].string; + printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); +;} + break; + + case 74: + + { + zconf_nextfile(yyvsp[0].string); +;} + break; + + case 75: + + { + menu_add_entry(NULL); + menu_add_prop(P_COMMENT, yyvsp[-1].string, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 76: + + { + menu_end_entry(); +;} + break; + + case 77: + + { + printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); + zconf_starthelp(); +;} + break; + + case 78: + + { + current_entry->sym->help = yyvsp[0].string; +;} + break; + + case 82: + + { + menu_add_dep(yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 83: + + { + menu_add_dep(yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 84: + + { + menu_add_dep(yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 86: + + { + menu_add_prop(P_PROMPT, yyvsp[-1].string, NULL, yyvsp[0].expr); +;} + break; + + case 89: + + { yyval.token = T_ENDMENU; ;} + break; + + case 90: + + { yyval.token = T_ENDCHOICE; ;} + break; + + case 91: + + { yyval.token = T_ENDIF; ;} + break; + + case 94: + + { yyval.expr = NULL; ;} + break; + + case 95: + + { yyval.expr = yyvsp[0].expr; ;} + break; + + case 96: + + { yyval.expr = expr_alloc_symbol(yyvsp[0].symbol); ;} + break; + + case 97: + + { yyval.expr = expr_alloc_comp(E_EQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;} + break; + + case 98: + + { yyval.expr = expr_alloc_comp(E_UNEQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;} + break; + + case 99: + + { yyval.expr = yyvsp[-1].expr; ;} + break; + + case 100: + + { yyval.expr = expr_alloc_one(E_NOT, yyvsp[0].expr); ;} + break; + + case 101: + + { yyval.expr = expr_alloc_two(E_OR, yyvsp[-2].expr, yyvsp[0].expr); ;} + break; + + case 102: + + { yyval.expr = expr_alloc_two(E_AND, yyvsp[-2].expr, yyvsp[0].expr); ;} + break; + + case 103: + + { yyval.symbol = sym_lookup(yyvsp[0].string, 0); free(yyvsp[0].string); ;} + break; + + case 104: + + { yyval.symbol = sym_lookup(yyvsp[0].string, 1); free(yyvsp[0].string); ;} + break; + + + } + +/* Line 999 of yacc.c. */ + + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + char *yymsg; + int yyx, yycount; + + yycount = 0; + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + yysize += yystrlen (yytname[yyx]) + 15, yycount++; + yysize += yystrlen ("syntax error, unexpected ") + 1; + yysize += yystrlen (yytname[yytype]); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yycount = 0; + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); + yyx++) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + const char *yyq = ! yycount ? ", expecting " : " or "; + yyp = yystpcpy (yyp, yyq); + yyp = yystpcpy (yyp, yytname[yyx]); + yycount++; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + /* Return failure if at end of input. */ + if (yychar == YYEOF) + { + /* Pop the error token. */ + YYPOPSTACK; + /* Pop the rest of the stack. */ + while (yyss < yyssp) + { + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + YYPOPSTACK; + } + YYABORT; + } + + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*----------------------------------------------------. +| yyerrlab1 -- error raised explicitly by an action. | +`----------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + yyvsp--; + yystate = *--yyssp; + + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + + + + +void conf_parse(const char *name) +{ + struct symbol *sym; + int i; + + zconf_initscan(name); + + sym_init(); + menu_init(); + modules_sym = sym_lookup("MODULES", 0); + rootmenu.prompt = menu_add_prop(P_MENU, "Linux Kernel Configuration", NULL, NULL); + + //zconfdebug = 1; + zconfparse(); + if (zconfnerrs) + exit(1); + menu_finalize(&rootmenu); + for_all_symbols(i, sym) { + if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym)) + printf("\n"); + else + sym->flags |= SYMBOL_CHECK_DONE; + } + + sym_change_count = 1; +} + +const char *zconf_tokenname(int token) +{ + switch (token) { + case T_MENU: return "menu"; + case T_ENDMENU: return "endmenu"; + case T_CHOICE: return "choice"; + case T_ENDCHOICE: return "endchoice"; + case T_IF: return "if"; + case T_ENDIF: return "endif"; + } + return ""; +} + +static bool zconf_endtoken(int token, int starttoken, int endtoken) +{ + if (token != endtoken) { + zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + if (current_menu->file != current_file) { + zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); + zconfprint("location of the '%s'", zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + return true; +} + +static void zconfprint(const char *err, ...) +{ + va_list ap; + + fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1); + va_start(ap, err); + vfprintf(stderr, err, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +static void zconferror(const char *err) +{ + fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); +} + +void print_quoted_string(FILE *out, const char *str) +{ + const char *p; + int len; + + putc('"', out); + while ((p = strchr(str, '"'))) { + len = p - str; + if (len) + fprintf(out, "%.*s", len, str); + fputs("\\\"", out); + str = p + 1; + } + fputs(str, out); + putc('"', out); +} + +void print_symbol(FILE *out, struct menu *menu) +{ + struct symbol *sym = menu->sym; + struct property *prop; + + if (sym_is_choice(sym)) + fprintf(out, "choice\n"); + else + fprintf(out, "config %s\n", sym->name); + switch (sym->type) { + case S_BOOLEAN: + fputs(" boolean\n", out); + break; + case S_TRISTATE: + fputs(" tristate\n", out); + break; + case S_STRING: + fputs(" string\n", out); + break; + case S_INT: + fputs(" integer\n", out); + break; + case S_HEX: + fputs(" hex\n", out); + break; + default: + fputs(" ???\n", out); + break; + } + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + switch (prop->type) { + case P_PROMPT: + fputs(" prompt ", out); + print_quoted_string(out, prop->text); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_DEFAULT: + fputs( " default ", out); + expr_fprint(prop->expr, out); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_CHOICE: + fputs(" #choice value\n", out); + break; + default: + fprintf(out, " unknown prop %d!\n", prop->type); + break; + } + } + if (sym->help) { + int len = strlen(sym->help); + while (sym->help[--len] == '\n') + sym->help[len] = 0; + fprintf(out, " help\n%s\n", sym->help); + } + fputc('\n', out); +} + +void zconfdump(FILE *out) +{ + struct property *prop; + struct symbol *sym; + struct menu *menu; + + menu = rootmenu.list; + while (menu) { + if ((sym = menu->sym)) + print_symbol(out, menu); + else if ((prop = menu->prompt)) { + switch (prop->type) { + case P_COMMENT: + fputs("\ncomment ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + case P_MENU: + fputs("\nmenu ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + default: + ; + } + if (!expr_is_yes(prop->visible.expr)) { + fputs(" depends ", out); + expr_fprint(prop->visible.expr, out); + fputc('\n', out); + } + fputs("\n", out); + } + + if (menu->list) + menu = menu->list; + else if (menu->next) + menu = menu->next; + else while ((menu = menu->parent)) { + if (menu->prompt && menu->prompt->type == P_MENU) + fputs("\nendmenu\n", out); + if (menu->next) { + menu = menu->next; + break; + } + } + } +} + +#include "lex.zconf.c" +#include "confdata.c" +#include "expr.c" +#include "symbol.c" +#include "menu.c" + + diff --git a/scripts/kconfig/zconf.tab.o b/scripts/kconfig/zconf.tab.o new file mode 100644 index 0000000000000000000000000000000000000000..3d1d070f08e892bfbf6ad208776f231e4c1108b7 GIT binary patch literal 95696 zcmeFa3wTu3)i=H;8InjMGhkHIs0SPbEVm#k8Bvo!55fmpH-&c7m(cIi?0DVrk?=oDu=q49R(y)(6Uf5U z69K&I_m$w=xR2sXyq-hG;{-9Dq?CzSLyxV}FE2adyFC{?82`erk5%iB`vKYUB&G48 zM84bS_$hyS-*MEBkPSm61>`p#XWR_+^cqi6TK$N}^c>WmEF%BohmTS|Vnp=tk@5TW zZ@-4ukin&HG@j(Q#-0yBadf}mh|{}diGC#7nQJ^wyoetD&~wCioEV^U3?ok2>^Ynx z5$Jn9+>^}t=eLc=DMwjO<32)VJjuDw8+J_bkMSjD`9IX-#2Lw@#H>q>l|Adb?VmoB zhdJtd`iYs>qk5v|{o$p?qf`M#UbOF+FP4iq@lM~JuMZ>cQyt|1c-c5`Z=XS zUB+YaF<8i=dvYWnllOdt%6hY?*~1kovqZJ_ik$G6=$n33%|)TwTJ~PGG?d`%Lumov z;&J9wz4wu*j^AU%DOl%VPv`i(U`jbLMb;rligtQ;{DnCv17DOJ^F1BA@(wTfI#r6j z@9EPZnOw)0ai#e5Jyb1cP_>jD44+I4{4Q!Ec_u{C_w-{|5;yh7sh*N2Bgke*{9U3z zakWy1>{1*{a1u2)Ty_B>_-_9_kjZG>aW7(^z92XPJ`x$A0hB4sSl!5nA)Td!xrZsIyTAAM%8!ph}Dw3$bLh zksv})F^PEvK7;cq*Evk*mulp+^&x}FH6AB&fFas>rY=J=P~B&tn&tPY7XBeMyaauR ztop6(>7u~LmgqzZJu?6R35p|25pn@Sm=cQ@X)fGHyo+;LdiGI!+V77(NlhX*GRe{l z)MBeZW+)`<8QP87eW>T14;XKE9x3E*R?xX9V(NP1K2mFCEV#bdEl6u5NP1+GWO?k& z7oxGTA=L9dAd&4rw#n!lInkt7mqHJf`8YKZ*))7lUo0gxQx-{yC2Eusifw;_RglLQ z-@p={))%Yr&ibNnC5ApPcToj5gc91C;1kr<%#AYF>VC~T? znuSsEVW>GbgEWmv+j=~Vi-|PZtqG`pF@-Wc4uUl+`Db=E({5jHb4+-yehg?SlwAO2nl6fW+FNb^CET zPA#D~O? zRL$ItF;kD1RRKpRaut^M-ak&!f5{PwvRbiJFuRYJ_)bJ{@QoFWEM&Jg0GU!^z%9_K z=M~38T1H4+IR~WF)2IF`tvUSEW$c4t(Oq6ZJ%XdESY+SpJzn_{K@}l{dY}8DG^lKa zWQnfK(kjGPDHW?hYP1kV&KKex>L**xcGM7MFz4fCa2cgyCXmt?G=q~66%nM;3-#oq zyOTX6*ddbtcrOE*gvpcqvokF9hMhR|vWq%RtBvnM@mOlZOKO7#I;1vU1OJuUhy!(Y z9o)>>`3GiE4I(7M=Q|XpEIM~FD1KJ&C%c%lj)(Oh?^<<)0vaCKo|Au}P}%v)j-l;C z7L;EhykSs2e*-aWRweI2BYujwko+uRlvU-gLk$zb(rizL3B+PTBtTLetg%FC5u;6W zr=LklDwSQVf5)!K)$`tAYh~rf6{g8Z(kVvjc*%w9#oYgA} zk_j6`+>Ga=oidrpFaXlmOi>=EP6rLaW8}$l=v`Ll2tgvdCwT?MeeH zwkP$Hr5^ls#`?YnB_4WL(woi#_>B#Kc~Y+^T^oW7C^eV*jS_*j50k%n$Kp(_0eqyV zr4~+oUr}qJ@}~Zlu1qCQDP3Wjn(P3g(%xhgKTnZyk=#r^>R*$s@L^iRF%yAii10E0 zP|VTulK(h@(V4f6@#y`3jvyy1)g0SVuKIT=Je{n-2elbneHvgbmsaJ$jBLHF$@ z-3X~lG`)NEb<3{ZXU$F!$D?oOME~y9rG@(>g~$PC8PAZk*QmJ6b>Gu@wTRyl8%dUP zEf0k1LOrc-TYN$u(H;vK3w{|-2DJT*$Jti?rJc!}$qsfH4A~MTYaIBJFUs+*rNk;x z77Ctt99t)i;4WxEOb$6GghlgV@ViEJ zpm)C(c^!%Er18$k5QL|Gjlkxi7D7rDc@AR@no-;OZHc;@r`J%s`zWqdGL*5JFEeHZ zyv%^BcI<&bh>4`2qkV-N3ys*04`Gpdo;43Ac97`p`xk!f`M50p8sUK7xFt}0X*e)4 zTn37)*{7mVqb!|06bbdLN2an6r3b(-V@kC?MSqrxB13-$Qib7HEEHvxCE>#vC_@tE zRo7V~;hwXRLZ2Zm%VpLCNb277{9&dzNLeYjJ5yQj)MqQHvs6-IRvm`}MAPXZTG0$oRhSZyK$#)mw6vdb+l@ zUdCOr)WRCwU&1OQd%l(FDaxP+ya7#`v8kxHCgAtQeof?a!RnjyEqaWaBGhrTZwN_V zbOJ^dG^19p+E$(&ZR0pZgPa$o=5qU?mQoHb2Fj{SBL6U|3!;5qU+e>9L7v+wui3uX zEQm@7z9^D?ySltn#avLJcWs}MGcNqSlNBBbAj}?I#9yVoq>+et3Zu*P9X7FXJL&U7c0XdH9}aZ15uPIYu?nJ`_`~xxUyPs9c8n7#ev6Er*4Y<@p`P8~L8G)erPP1{0%w zIpJ`$4=KMyDQgJTWMV^^Rjv${EmUkEp|_Q6W25zwyb3jtF7Xqo*DNeHcfi2p)#>_d zwgF2Z?n{-NT(!i)NYQB?$P${o)Qj2rqFMDS-1T%vr(tyj>jOfMPJpjFItAbK(Q~?} zHyn9&zx5E8_Q|QxLIa+j#3s+BzaXUBf`&mT8|$I6$6>;d>@4FR!f$Y1o;N%_I={=j zIX~GHq?QbY8ZAXA)9H*@&qFCO3(QDTU+UjK6dS*w5}++6s+F!nwd(l|SoRqSqk;$l z3M0SEn;tvgCE`as5pc5@i_Dm+)pvNhD| zU-Ud{f`sDQp*hAqgc$RjC#x{;t%z`b&tJf+P-wL%Cn1$|8wO=16QB&bx1;AK%xlVY zx;J3_0yE8`BRU#M^^bPu8;=r^rJaf5-j4i4aRW5t;ki(r#UV_NFS;H|GTys&RL$TK zw!QrR|0v3e0=}p3ZP(@i`#8OCe2?zw$luAib>$14Gmjpv-nhny-E(+>)WFufDh6!| z$vD|S)tl;mb^q?Oz&I4jYJVFneH#5xcP$%DsON@LIJxAp zUK~jNo#s4L|7WZ&s?t{%B@ZEN_gG5$h26C3le&AiMn4_9N6}Ao_Za*nH$y~rpHIG4 zl3EML?4k;Nc2T;LlQF_ZlMcznj(EPOgbrb0L6ebT(~9H@LOPlvpGm&6$>)bJjnB>~ zR8*;liguq%QQo3FMw0Ic`OYNY>*PCwe19U}2=Z~sP9fj36gHfEPm#}0zQ@StBj3a1 z zyvkBFHX2hJ3<2JRdUiwJWyTZzS$aj=-;StRd^3k+m@^$hJ zA>W_K$3x;nF8qmU*U8>DQwHG_mf=3CK_(H=s1Fcnme>dOgpUMX5#lZfgM% zJw7OlXdlK{g+!84!Q+64K1PntaSc`?v-Q1u-ZKEvJk~dj8G8B@*h6gxv6gEY1S`(HKqy7QpX%cJ-lAm^#aZ^!^zNsjABMSbn5z-*( zXfRHy#dJq9%t%Qr^k0yO&=ltnF!^29?YrX&$iVpS1al*57HmB=`u74bt3Wm+(%5Ff zwp2ZO&g9dG+LNTZK8K1>N=4whPU{(Kyak2N#XK2ts7>5?H<%3r%NL(SlkQP&cCwy| zcNyshB^yc4eriFoH{@IpA0D4!bCl3u#rUv=? z-gu`mKC)0Hkm%5V6aWeM5FbjiAhRm-98<_<0U7d?d2kVB-;0jN7?Z9RQgM}E!DDp55z(yNLnvn{?e`soQ+@4Jo= zqlrY1n0j~ar;EZ%lg}Yfqp>LA9RcRtc?=Qs8Ym7Le|6@Bj8?C0f9o|~qs9vxc>y+n zI0~iooJ4CB-^rLGkx~-|dag0!P9!q8%EosYHN_~=uI?H(vlv_C$Bs^aT_I~i08(Fe z1UDd9vJ3U=%o-YrnT8J9n|uz^ipdTQdt!z>O+V5|eFOzm`*u>}rMWoW>x+|tKpjX# z!EEt2B+FO`Y8wsjZ7?+buV{_gS#?2}?QFHqol4xu`yL%vj*8R}4%FI&Sd$Z_i6kAxmCUMgtmux8M2lw>kCcOUSd+1Lcb#RE5BN1Ox zsl@6wNrqnOPZmSv=)KwYyQ3)?2Jyp~Qg*CuQfi(xZQ(tz;}zOik?>X+_uj+SthdtB zS?zoJj*(>0mK|%?I!=oniu^9&J%C6FZ=9IrfVUl%lR$F*Y;orNRl<8H;jM&~yW<8R z(+|cEZObX`#Kg-W;{(~yAP1W=XYoV!NXUc| zO_ylUq66tEfV}Q%8pzW8L7`;wrPFQ=59_X`ajodC4iM_@YTnq$*!1bdn_a3}GwTxy zfhDTa+bugI%*q&*-mY>FjdchU-sF%7veaEk7MzG5uyZcn5ze`K-_^;N&=m|+zciV4 za}SN#q)dZ-&604V=r-Ug{g(w97={_ew}J9}7+XXoNp&4)$dqc<9}G|Z%C-Dx&D>~# zDPt~X=#r(DyrLdt%_)+tMjr3%_TEZahx2Dk8i3?kt6aCDT)*h)gq5DADD^PWlPym? z+(hit4W4yMRGMW>ar;;j9laO%t4$aB9(}LQW-|A(MIkxgl4yf*p71_Sv|x7}kBAr* zv}mGumrT*DH4C}MN&4wgGOh@HH&v%d)Ox$A%M{VQ*&e-DPI$3sFZi>7lZtTM9e87wq&- ztt>lw%X?k3F7b#i?tkFnwN_~CAifw_7)-Ax{yznWZ76Bf{noNs27R9t ze!TL#;LqScSsw*pA?meJ8TCcGpgiWHVoDDnG}kEFrF4K}K&|>4sT(W}g4m}xa73Pv z^-WdGQKZ;)v!AMsniiG^GU&lVBIH4>M>2R<7TnM9tVlAa#M6W}EB@g4)V`H&p3kDx z-8{b~eKdGL7cN+L+v~|0^~e10-a#=*qhV@-Lr~ip_Wq7H1Bk*YRU=NY6>2;Ym=1ti z+O%5O$vgI!AXGnsZuZ)J+pm}$e%sNUNFO66xcvuvp)?T=C<|fPl6p%ept+_V*Lw%i zAF{R>nVu7#iA>a{LN4vo@sIfDuLbQG#Q5-Y&1KJiAy#|_gT|_*tkq| zIycl={iW2unfeL3NsjrEfW%SnR^1N2bb&%if}%&MiGtEjbde{iH}9>WU$0P;2bo2y zkG?rl8rZh|r?j9Q50j^PSdY`EKIDniKa>->MnRtS=r#WC8ZIp2)OhuvrT2g}y@js9 zR>_tw%w~YaoBGtNmN)g!{^M6^cJm69F&q=c(Pwj_hmT>r3&TnG82QE&SS#hS&>+AX zok+W5Nft|FH7s#ji}vCc=6jjT`Xw3mu2a5C4_O)(;#Oq&F<6|dA9U4cEd7bQQH9XT zNK=?jQ$R_erm6mM8VXY5Y!6*gjS^uOgCC7z3ZS$ClHgGIFg?^9$k;64i^UN?L^}qs z%!f@6*jXUUgZ^r8!Cvrz5Rn_;Uor(_4U}Q6%G{3 zs?)o4HOFE}I{H__EYSjGeF^VgFIl_VDT3X*U4Ywj=&TI zVGWW-Q}oL%8z*~WPr$e$LAp0E17Xsr1ItT*9Y#YDZ;y(<<%`{nc%{9VNhJivj32@Z zzZ~5%P22V5g(n(~foMw1pVLDnw1fBc_p$kW5LU$BgWOPsrDcw* z1lXy~`QoENP^sG2&-D~JHTgwihdeI?*85^Q-lN;FyXy!rNkXXtVdG&kt}uGUgM&k3 zdiQD(&8X2Z2F=_4LIJ9jD!V6_CfRSJ8AK%66@A4YCUehjoknOR)bbY$Ocl)5U`t>^ zDPXh)#t10$lb+FA14f+}QPdZ1?Tz-0_Ql>MDd@Y#7fZoY(cz(^BtKyI!RS%I z?QKYb3w zY~LbAhk0BU@mOuPD3spNqaR7Wi`KLAVCtC+IeK0e03t1Tn-mHIeIt^SAO~GlsB_sK zZ5fYshOZ(aa#osNGt#IDY=7;2y(W-ML8=g;o-sg~c%_q~BqL}oQ!C1udS#WV^lZZsZajx<;)3#=VdT57-3{+0b}5sH$b|6>6SL0z%Hb}ASI z%nue*(Dv!V7q5p$8axRZ1F};L(Uj*R z@PG`zR_(scX!$Tzfkm$P5Uo#e(MY$JQjs7TiN^xeugU#r;VEeepaUUb;bQ@^DrE~N z_Qe9EQ=Oy~li1mN|76T%*ET?&M%s#jd5xkBlcg^`Bu(WV`$+`YD!{JleCij5l6KwZ zB@&0gtMsXay^U7Eu*lz&J+gn1?Z>F1UZHnCIxAY6-TvA~dR4%vDnjjIuOvdhj@~AU zX#!}ZuM!ekx{BSiNol1777yw}V9q#D)2J*LAOyiQGMh3+9KrEvQ4XCHivbf<;pA*a zpr%Y%CnT(iOzHH+t|8raZ2U|5-s(^T#EY`2mlD|(o3;!5rHPd7*c=cpu7Sx=oV)-j zr0Ra2)DMdc3R9dMF7=PCHjH|&-X$xoj_RSGkeq?lIjfyg1SKuVuVYy0Td@P-3w%%Q zfu0SIhK>!Nt@vHlG3z1${c*DIsZIh80Wk6gL^XaMX!pF`F>Lz>*XYk(6gtVn5I zCT9a`XN0wPC$@Qk>9!iQC>@!JE%igAs+bJ5*dvez^4xkgd$3X9EokWseEnT>zObXcvOg>DZT(P9ntZjg_2hx~bjAZdEfD;;- z$MMOj#60Sys3FxRpyk0UXnEC7S;r8hd~wy=Er|3)@>kgMQ0J^6H;!&VQ5TuNguS$5|Dvx&>csau%BXC~5!w?agwGj-z&zLARiR0l1{;A#c=e z{wXs)$D|ws$BCa25ijHPP{CmM2aX?d_S;l)%Dxy2$p^xx=+B}*JULW{HfpuIrB_)i z3u^xBUolDpTv`ThwOEd(nhZuhE{vAPq{#LiO3`MJkBdS z@=SH|dIoKIm#C|~sfV-917xp{$n~}|y3Zqj;|P%ZLyO$U&L;`!M=#0>nrwx59cJ3G z**o>~^mxRcUcp3*A~tm(bG|Ec|2g^!T5lkA4o;6tX_(gWm%S0W0tfE7ukmAN_CC_e zS46uZMkE0R#!#cQ?Cr>J6BXWuM!>&CaA;)1AKhC(hFI#Q=&}6Bkm%9;@CK9u+xgI~ zS@T0cf<70x>^XZQT8;(VauzQ38dGHk$aOgwzHF^)ck+e`XtmFpT{vygJfT1_#owzjT{b3d+f9f&NY@N13RcqHFM@JPU7;#*OQdn_;yQtzW7yAv?L`)gEw_`I?^mF z(pqPvbldFCqdq|2>g}%PJ|T5UI_*J4@OBVvAur&$Va&cl)m4(J(~E7XPacGHso|H} z|54hRu>=7DF9L(lWCphl$Kj6+_!<(PsQ63F&REeWj@WvH1RQ$rkHqFpMLCgQ%kCC+ z9_fwu5KD{mvJo zjrek#RvAKk@mz`oW|xKV(rcSU4e0FU+1}*Yh_Q?4g>vx4|3P{UwGmh2H7OZVXp=Oz zOtZJqEdnuKq^PLgco#f4M_gr*f({6`9!*g~g*RV(3XwrP;E_>TC4wklHSG{ewkR@X zVL)tT4^AuBTl;g+QI+ilMmFcl@aButu>%$a8AiqXGX=4VsBcV`War2j*V-ghA;E8u zAeq9~E-Bxcnj13>)Y(n26%)z#OH%$cci}C>iB78W2PqcJJ0s}c5Dsud*iKbSLj6^W zj;`CN_p(erCEqb3_Ld$f+Z$PGG#4eRXg~7Cg;Y7*3W)Ww-!Te!Xs(SzX!Or)g-HuM%YY!`Jh#u_hnxAhnJ0}%M#iu8CD z*iQ5J^H6wnWd}&kzl;tec_9ESzq6=f2rNaR0`)*5T_37bJ4lk-C@NY(e6)~>d5NHz6zxNh z5>7rL6FmkjKb7&EViUOP92#W;7gLT&Trf7ub*6kbs)gF;C>M zG@-5i*9hh9FE5ZdSb<9npS0(eDhaWT;VMi)%T0elRoaAL96>z#E*H6|5rv9&79iluiU-z6 zfrcbtbPT~5L{Q`PtieYNc7e;>Sb0P2#w)Qeg3kF5hv?f+i?KwZSya79)_&SSk zWE8Lk>?aG@Z|iRyjKJ0vIw`r2NJe)TBRM40NG_vYOM_HtI$Fb!Bxx)~%5NcACz6!# zt=#L9p{<%gCE9AUDsWmNxCNv}JK|Kk$4M79Ei5c5$y1TQ-ajJ8E9mr{79GY)Hygho z0mEXaALB<(h>7c3$s#pm!2Uj{Qi!gR)6Fr!LqX%IjW2{S%L9SG6Z1W&Q@miDL1V@H z(Q+w)LKyjh&e;IWJ7V?T`qIvX8StT*-`Jtv!X}Q zcm5G?dT;uKfHa$x(oYtWW9Exk@x+o9cuiaO+)#ey0{L)T@gol)EEr`6#TO3kvvFcq9b(<*wB_@?)8at5op9tnOu^)in)>Pru0wGWG0(02;a=M8@fUmJ(fSi2D? z7-{DQj5>@7r$T%pZ%I;15AEEWdR6bmTLi;Dt4CMAk#3$NPVFV|FC-H=ghqysq#h}K zs}?7T8q_=*D8!0`PZr<}dHf}HdsZ0`rce*t*~f zxS<@dL>@usz&Zl;=$xv##GX3S^C_l^W%XwtKR#STued5rE1}n;caF*2sSY+$iV76<8V_|AQMxZDRohL5jws zW5a|3*fkaqdI7s|?l(;}*(D_l!sSrQ(lmi7k6k~OX_5LR@t1Xo3`6U;8abEQN@qt) z{a#H_@cu}*@>2yX`wB}9u_X|664Zi?*bxz(rW%sshin)2vX7nHN6`1LqJgN6uUlS$ zqNZYEF;aFs;Pb_r;dkt-{>Y2zRBKu-vD(XL!a|MBUc3E~m4JLGXn|VxMo=+IYoYvK zWNi6qb3*hZnB@;pbG3IVGe&zND~++CK=mU|jNxq(TjVEHs|B)Z)tq~(%F5{*j$D6~ z_Q%hKfPnk5deSCP@_D7@xhi=QJ-G-`vFu|TNiZ^#vQ`Opf zz*3>8OQXCv^;Z%~D=as9odAPDZ-)&>SY`rge4t|_5A(n`2n;D21{a>&*^;?Xu7nOE$ zlb;vJ&^cw#h37<%=54H?#d5_=?mxIQihhtAzCihM!kY4V!lx-;URdqRI}pyrp){-j z+53}a`<~#m7NNY$(Y|NX%K!6dd~ysD4k$jOy5gN%hs%Du7MBN^ivx=hNGm!88-1wl zdo2}!`D3+g2@5`y-gb=b3sx#1zoY@0GR=-Oa;QTqT6F&e)saes5^x=sd%VVMZ!Jf& zR~z|_VAxWY1=|%$#VJiWjtTo>AEFi3)umFfZV)%*t>ctr;_;kkY#A!f+I%Z>Y|g7k zNxi`GV&#;QJAV*`%Z z{=8qG9dPuFWWqrJZI#l{AXEQaiB&6Tuc(nOy`&`3^8ti`|q&38e{b^ zZI|Zy#r%#I&Wmo+a?(4nVLcpXYY&l7C0=gq>P!qa{Qj@{H||DCJzver)tzY!XT z5$7pPkA5)v>4G8Q0%HU=alV6-%~|m?<&DObeq;SOzAtSW6`OAsydb)@z#Dm&bm)Tg zRbTo$Iv;o(#&@FqNy;x7$V*93l>PCs@#p`0_@O^b&5RWsqLL=wB2Z8R7o{4yj=D zZXG-9zf9N`Dr^U^Xx_&D?Q7fd!gjP-qu#H-Z_MX?L$@A90B?Dwi-maW zEg_S3E-fu#KDXGwx%t_}c%#|fqW8Nr#PG$*9^Ub~i76F565xV;l_o}^Akih4=n=oZ zrC6U}FD9ZMeYf7inP7u84bwR{vX_l2?83(K19|JQV>SotXY~PVt2QRAInGEP!Gw8N zK@m1)%N)Wd@wNU*M4`R${=^pl&k8^p?Nh!Rzsh1C=ZpP>u>>CSN2XyFjr-?a1{U?U z1oSGuVzUL1sgh*p0B)H?diRdMi9GDVvxX~Ng^`m|Kj6v=KLm@)SRFX&BYkz?{ceHH znPIwD)VAv(H9X;9r%zr7nMINHgAZxpn~eEd^aCsu))JwS>H0fmFVN0;D5rXTZ-1`P zUS?xU3HJRJ>Ca(7v1kMR>z*S0NZCtBb`abu!g3=fe`1FbQ;H4pO8$%lZN8TJ3OGUH zYg2<3{{kW)2$>n>BT)yk9Rd|?@8_23jQt}-O}A7!KlwGh>xgjqrTT%_iY;}dA$_*rf3CU5!p(qLf(J0pa$snlb)T4NE&yTuG=2~Gictu9D zeeqM^qai&_@+9*p*eWQsQWdXkwci?=c{-E71eOfdh-(QB$t45Bdp8PqD%STm;Z#BX zj_U*4fRfZs-On)XikFbh*il-^9ZmqO8^&`~*@O($V%JV~_G*nYw4almJY-dQ0}LHH}%ZwdH-_)Z|^T&$#xyBHI= ztVnn&FWNId+Bd;>JI_zYqHiivJF01;?Y*?oR$aUu<4rMLIY5|PfX1h2NPY%>S<`-$ z&p|ovE%T@2f$&#TJD3_eoIyJfctJJGzH_TjOa7|qWXeXGANYEmWT@Ut8#OG6vL%xO z{X6%jA(*Yql-cKO0Ygk_>yq|-v{{tC)$DH;YT<`wwTnWdYXsAnkIRbivTk2u zH`Sb)@#JBZO#&iN6mhTGImSS#m^3 zNBjJiHzzy<_IHIJ(=(3o9-YaroL*L``93eV5~_xk;$InvbNy5DR!nXt4hcQ+#fYiE=U)hi#(TV%dN>zBL7etB+-q;`vw_LEHVgU6ZN5 zX70z7HTxS>8O-$5e=|PX>wG7NK+(}{wldQ9F;mM8Z@~3nob2oEDvy-(?kym8V4f^< z8+acHhqcMz&7vL86=;!ZVkqCK>27xO)pUh6zQW@J=!IsT>iG+q_< z{7^p650#V9{5$hQi5-N^o{!10uaKQTfu&iwu3&^TtQMCT_W$Fd#RA1`Y&pRo*uJ7W z^M4iisXeg#9S45^__cxX(`==cp)qXPlG^kw>Nb8SZwwj^3xf-YH93C6)fSxv`i@z{ z>HklV{>W^Qq~2uJlX|1G<7xE_a6$x1mXg38 zo?pwLmnl_L(u*_OzXA zDFGT9W^7W1a8tuOaurR}(Gs@OVAvcVNy;KoT6MJ1G2iURHCkC%Q;%oaGyVCkL<`h4_RHy@@VOMxzOCgg!mCZ z^*gBs7S*u?sC#ELM#YM^&ti5L4 zN#OC_PMa5zH;)I%Ft_bem_RT@r9qtqh(2^lkY%koj38Vie}9}J-p z{Rg>fv=uoi`T_P4@t_QA8FU1q5$(d!&82?eKzy-8%(GdLDrw5|c6E@?M)@eCk|vZd zpcmh5g}^1ds9J1BuS;H^iJNz#Lg_oQOI}7vQOT|2 zxD81J%7LPCMaSv?3_yyky|uiL8=3-B3icQlb*#TFS%9SFz@S%onWggdxlu(0iqr5L z$5WG3-CRQzTu!>xQ?j8*{~hgu#Refu(8U(3 zp)y|es$$eIh(S?i8=J<#==GJgmiS^nrHZ9HS^gob{YzBKMsoqpl0SgbB2!fuY-~aD zw<2#bxwQqU8O9cW>L)?+$?gk`w2pYsyybX%~MfKg9pk?6ECxPBV8o#upTkgCX# z5W;|tH@dAL534xTr&^O7^w0ck9YJ|jSt(Uk6jqH93=;8hqn?< z&}0*hNl*gnxrEe4*TR@t9GC&!YHU(#Y1ntb%&DCwO%qj3dZoQglZF09h5lTi&$6fb z?@y%sc}AAZzQx8C`d>(N+E+GUh$R{}xTPj;B2xi|A%n`p<+Rvo9w|Vwvk>1_ejF3? z3(bzoPx*|oH-e}J#Mr2f~ocIChv~LtqHGDC(h2HQe)-W#*7$Neq zmBUOc2VLzlzUsPq)T6S$dBVXOKg){_lNX^iV7v(`tp{HBPtO0pKc1Xi?~uIwf|G_8 z7M(oI=N~@el;TrQJALFCXP#AZ_BrQjqeh<>7<2yEapT>&C&UGx`qTvVnaH0>lc$tU zrO$=w&$Np!zT}eW^eLlHFnH;V%PzYdpDW5MDl2EwXI52p&FndI=gz(I$}8v1n?HZS zf&~i~hC;RSQ-?`v_fL+<@pwGBc<2|O+?-s5;gjoy%gyzAy+d+x5X^xH$?=MuT=kx7 z0dgrMhvFaxp~MTOIRQoj07;JAJ~=F51wznRT%2_6HM!o?hMng7)I~!sEm}A$Z?1pg z$-@g9mjFiQ)Qzk0b^R%)j=dmQF6QN5G3Uw=#bV_p2$Y|C0asstrVyu#Gw9Ny`ufQe zCQXFr;_>5VTwZqB^xBZ9s;R85SkbiVhUN1Cxb8asBcE7sA>PDQORt_S7Gb_coYf%C z7NgG901~BB>z0i^ujHJ7m@;h)VCrL<9x+^u5T}S@ajG~?OcP6x_eiluoFOh2H;7Bb znPQzdOH3Cfz!eeah@d!EXkwHYEv^zvMVYu-L`4k$3-mnkWieG;Xdza=_nTA1{pR^% z65RdfB=M?A-+#v@h4#Mg&1H=DdeGafsFt|SM-86OFeh&Eug?gL*l+KdqeKO` z;}IMAdnbHf6kh_LqMXzHW)!}!i2LmnP3(Km{HpjG`@VtiZz|}w5cdJ`ZS}T7{Zjr9 zDt{L1`Bl=|YRCSu?Yr9cIm^?Y5&Bv25Ni1>VA?87^Q-1Ta}Q1BJ3f_SrU-}@#- z)QIuoGvXHUDKSCJ6<3N)DC=zSaI&aEc{htsiz(s`F;Q%Tt+!s>DoRBhrN3QJX=jOV zh#4I3+x&f*_zv>ET;$-W$Q9VQF$CK@@^Po%NoZ(=kOIPbvKWSYKfeI1Tg8td7k*Az zD#oCmc8CYX=Q-?2vrUwXC(R+Ei7~8F816#doGflcjS#MT#J%D^PQOKbSKKBNVyDm{ zQ-n1;<=x`5oRaX}DJ*=Ch+P~?Wu=Ewt`wgG4{jD~@q{6H_j4%mrdrGs^Th(OP=rLS zs1u9CVzFA>1Q~9J4roDK+{G;#nUB|qYte$2iB@qvBQAOZ>w}4I5W-_W5J0sz*1L%)L^ZKYrn@ zwXwK%``Gix8t0GI?%JgZk7joWC1(%wm1v{Sd+=QC{ITOp&YpM2R_GE(gln~7KCR^J zrd2m0@s~m;*DYFnE^?FI$+GK*`G(|a)U#+M!+hr>k8`z)wP9t`FAWxH=W71pW9_cy zlIdDdn_d(QjFBDC^wWb{#^=svQCo}Boinb;Kinoq3yisNHgq!rPS?uj zTsfq`H}T>H6EB%jxj?(pGx3s&$_1lpYwPN?^J;77*UrOV?Yw#OO6pEV9`oicT)0rH z)wE%ukVb#VB!np{{2-8C@TAHAkMBPm__!P(y+=B)ht8;&R2jo^?G z4*P=qWM7PceK7*I#aZ|!%iF86uu{*x2E24GWyt3{w06fO;!F29bp8WhBBTw zTx7YOC|4-nHBXc)6#q0Yf|dMF^PlD={7t@p&lQSy%oF7bVXaSxWlrCp)D?;&=81BJ zu=`JxD->^=?k>oXAjT;l&%JFHinmO67i7r5crMM#<1OHN({y)1hGgTKVPm+=_Q^PJ z0$0j(cR_}vab2F3HVu)!6mY#^y1O7lvQt>^SMI$dGipIa#>o+V5Ag z?^WP>#dLQ;hNN-1`{vmgUjeT9aDOrB`;)ptaoD6$)?xFLyF!fBUN&DgL-_rqt`MU> z8u!(T|G|8P^-aG1Z&v6)zlGw@=81BJ;!oy@a)lVx(zuqsKdCDee>6{&D-{37JW;Mt z{J|W^)ei!5OH(L*Z=NVuh}nY%@sdg3pVSqK-^-C>({__5VLM4#ubVe%@@t3{7t@3;tItJ zW`8G3M&ZsfUOg!1UO*Y2H~Tw@fx?}*oc?S2;e8&ser28*cP+*+zhwLVm*y{F-_!TM z?+V3p=81AA*1kWHV})+>M7cuIWxBf{L)@(hx6m%g#51P53o^tll?=Piwo2stGr+aq zbaz3942)}87Owrkwa;{SL58^Fx*l`B*^qs}wbyiaL54U}+>n)iMaKJH;M#+Eem56n zND%Ydgs&+hoihi^zX!NFO?MY$h!xZMyUGRcjfh<+o;KZGkReVSgZrNbuBS|Q7i7rb z=_PbE)AHpIerCG6AVV_Kr{C6PVWQZDVz=q;f(%KgcJsA3FzyDf zpPKG2$PhOStqu%n_)mfBC#Jg#G9(>$FyDG${|RtCZo0c5Lk7b@u$yff9|x|-Om`P# zNPk>ycIr&nW57kDvqw+RIPJ$gPW!R>$sLW;eq{dW1dY>vXr3sS9`pTx$9(eJ8r5aK zS)l{{7K-niC(0Fy@0s5-7xOpyK8Y(7-!)H^D-@5IC(6n3(8DKaJoI1YiE@SFA+x`0 zXUmqto%ZhF{)f;Wzhm}yG8Kgnp56)l4sbnao+wu+zHRn*GCvA;<~+Fn+o0cNb(x ze_Rx@!3E#ff$M9gy9+YJiEE<^hBW+Z!1Yz^CvkH@hHS!qk#zjQd|w4F=MEO9Kgf`D z>Q5gB=l#I-71P}X8A7-|a~v!(zpnt-mrZvUWQdG+iv!yh__sRVWekd4D86L6yC6fX zm~Ow@GBAD#xV~t*yC6f{aJYwk5xBl!y1O7l+|#**egU{XZ@Rl6L)=nP*!GO_QOM_k z>vN{N3o>LNT$$lJfa`O>b)V_(f(*$_LvOeCqe#ZN54i3%-Cd9&{c%x9)CJ$Yz;%!5 z?t%=-#1(VFVa2!yxISyTyC6fXn1lbuk;i9&>u%HC1sRgYaoZp?QLMXxYnSQnf(%LH za`)YC=dcU7?lRq7kRkms?6gy7!tMgDJ56^NWJqRww>Mqkz7x0-W`8I9DhhY@T7&x& zz;%b|?t%S2EeHU*G|*j1sOsZ?i?Vsh5asu?*y*fO?MY$h!ubE-(A3VJ8<1*y1O7l2EuW7 zKU!}CuDI#$f(&uP_1S)SC{`S}Vy3$bG9(+UHD4jK>PPF(j6h=*cD zf$LV&-9Z}zlE!u4pqMCjq1a)%yC6f-xQ^%B0bJWncZYrp5O)lpbD?oNaBVZ)U63IX z*XLc*X6LdExVD<^4i*R?*(uWRU&zA06}YyT?k>oXblU#DFJ@rd0$jJ4?k>oXG=?u_ zq)dlfzFUCnGp4(P4F`x7GyVJJ0dRf>xIS&VyC6d(j;{=mKAi)_E)<(hcNb)cjD7#d zz_l5;Hks}&$Pj1FPXAZ?Vc!H?8%=i?WQa5UK>n{W-i^Su!E|>RT>yg7M?VVOac%&v zi0STv3`wW^#&K{)fGcdeyC6f-xH5g;?1woFTm>EB1F> z(_2vbZ3V6t)7=Fbl8*h*aj>-j*E-YP1sRgYmF@elEZpmWYpv<-f(*&VF!1|Y;JV3l zcR_{>l=k5)swj4$Xg1wlkRfSYkMv8OhLNusxYn5NF36C~_|CWQX5n4~T&qoY7i5St zwbTE-EKC%;P~2#`yC6fH=?C(EpYh%ZT&qlX7i7pl>HCMT0wxQ8)7=Fb(m&-uA=d)eHKw}@GGw5XSf|S3*fqd)wdwAH4C#;Sr&&0x z7*_+=Qq$c98Dhm8>~}X~UkY4TneHygkil?B*v}N5R{_@&)7=Fba(rA?j3vO;Xu7)~ zL#&wT-=7b_uSVc%Fx_2{A!!_g`F;WX4Zu}zy1O7l2Ey<}KkDj%Yq9C>f(#i5*OUEl zEe5Vdrn?I=1S|RdQn}+_1YC8dy9+YJJ)K)<9dOl}?k>oXbgHM1Ltia$g-mxBWJns< z@q8iRT4=hvAVZFaAq`&$TnkKh7i35}?(uvJfNQ?#?t%j zaLG9Hfa^-r-31x)@o`-VTysr#7i5SVu05{OF&DVznC>pf5I0qaEy1O7lvU4B!{UYF+X1co|Lo(C8I0%i?fa^lj-31wvi7Wkfupib7forPi z?t%9mLXaVQNV z-(=vLWV*W`Lo(wJ_BJW&Mvsqk8odH{Vt8>gM-I*|kHJaif!r0i)8lg7Aw%aR%Wylz z6r3xbjJsPd;xoomabL`*;HTe<6h697Cli}L>)nD%+?N6S#eCLv0`Q*CxTf)`<*_d5 z&cR7@E4}l#6sOUh@0Q<((0o^j6~p=+?ubQayVGtc{3qM*qio-KxNYY=+(mN|PK2L_ zlki0hITfei&%-?@>GWr@KM&u4zbW^Zn!E_@wbDPr7m5 z%G!HCaq{~S+(XyvAk`?>dAqMx|y>luWVYS0{<`O z`ybT*;lO`5@c%vs0!=L|MN?Z_Ynuo}TA&)%v^1?0in6qGh)q;BR%AcwQvy^Yq z!uqJeD0JHrw7tTk##ROispn6V?!eGD5u9_D@82v1+T0-&WRO1UM_;*%S z2woh^UshLDTR*3+io6R$i{~s{P%#hQP~F1$Axed-(<t?B+WwrGS8DISZ5W)FYEo3Se5)CuwEnHN! zEL2ffMW`2o;PeZHEUKDUHIpc-t5{G&WG$@2SH%KCZ{b_8aIpw1U$LTTeORn%Ssw|D z8`ie2xJj&NUAL~aWtsIt%6nN;OSoy6l8`6aiP zueIJm>6%s63)<}R$l9>=3Ye@;DwQ1vYmS0u1g-c2SBVW_9VforM zD>aI(DQT7{+L~^TtZ8eq2~d@9;ZUzyE9!Cm^0xM-HX>rhOELxrYYam5w%6KT1rrFCPA27y_xjafO0 z!kA7<4Rhk&eRU%fcZQ7)@uUOvF0uDDXN0VKN`%N|Vk(v)wX&LcWEnl-1 z@u)axdu=PiZB0#hn>+^0Sl%)=tf7}$iLbRy8pV+nu1QcU8oUIJ9@9P=2%1(z+S=D_ zXksd~abw!YgNZ7wwtQ_{)AE&@6@@DSnbFeP(sa47?B>Z$;T4l_;%c5KSt}-kTj9y_ zWn!RyLB;$k^i}9*7F7w^%PkXY+O?L}u-4ubwy3itRaS|%sujKMP+XTfrhQU)-Fk^_ z(ikYpmKAFwE1M>-B>|hfJQ8jt*re6M5p6Z4YF$el0!vh$W7;pn#E$I2H9JfjEv^}} zLVyu=&}GE4{t>5aau27_blS~sNlQ`j=M6niL)7!&oqWMi?E-qyE|@$N^J(Wf$VoE> zh}hsr1D*M-bIE6!Yvu0K8n?x={d z2pUO=E34`jRL!&MK2s9VR)wrjwZ2O zwdSE>k`j25GU_$kmr0S-f|qI63>7DhX;(jps)TjLx|PztrMWYj6Qen!QFzATnTm&Q z`kjR*gl8$96?oR;*@)*>Jh$Va|E%~$JP+Xc0iNA>_TqUS&!6zTj^|xGAK}TxgwaWO z{CLjBGZxQ8JQw1rz_S3)B0SgNS&3&2o>n{?@od4v{}mj+cjKXd9sVOc^bbgXi{~{w z@8cPQ2|@ZF&}ZNY;F*GFCZ1Y6*Wp=?XEmPncsAqNibu!uSv+6C^Bp|j$MbVMd-1%8 z=Z|<^#`7kgcky^JnOTU(hvy7Dqwt)M$L*tZ+qyOF?PN??9p)<76yepV+Oca^Il522 zIhr4JiL5uX75I-psfX=Y&cGw*wU&kUqP0G>=Yb{;mvC0>tN}vnTWmt-5K}o zs-KChU*FmW(=(GfNH6o}oV1B{N6Z5b?S=@IDQ)p&<}BYn2L0&#$&^vps3y^OTc3=6 zeSM^T^~4)8tSqV>Bwo3>W%;@_D`3a1Yi-+12EnJPGMBAD_Z)6oCULv{lZWG^C(C1y z)X)!u=P%Q54mY*CWsXALuzaOea+~PmCbF1=U-a`gOkUTzGP1U*eR8HTG1;;~9MSuE zsoRaPYEb<`yObhgq3n+PCCLa-?GNKiQZMK}mqXFq*aGVX4Fls7l6X1#A#@o@`9-By zQMilcc4757tYutNN?b&L1&o|^Fp1GiuidQO*aTA%l@6nR`AtolY|}w)Wh)teO)J-g z$;Plh($*LV!%Vm2WR+OvPeuLWg=E}dB4Fmc`dL-89H==D)lH{)pg|UhIMPpJ*Nwe` z-|1}y0>QtrEn}TH{`K^mGtxK8{(Y2IO$H-+cgvcU#&=W8ip?--+HHPhd)T@`17kgA z+XgU_TGz=iA{mO$NwX7&k}58)rCxb3j8tQ#C2<4U5hQ{z$JIbNjls4-T3b-JsNmL( zig{3jG%|*9q*A#Sg6Uqpyj|Pa)=B~jV{ei+R+>U%F?u7UJc*($Z@V#qP9WUQ%1DmU zwdLTMWpZ)iG-cA4T_$t^k@lu`Snf15o`AL;CJTy;d8;a^+f+k$*dP`uNCi!>SqYpa zFN*D?X2EECg3SrerYQ4WcDQmh)~=!QsSiS-x#aCq?Wfr<$7W6p4z19pWg_DNiq&yA z(>VRkBrb-dHQZF~UzwhEzf09MkYveRhAJfoec?Xt32K3H4tsR`(4m>{!J%R#7Hbc~ ze$w!JA)f5dI9kM2AM(Ql%lPcbc|8kKdz0+^Sj9H!melKyP zclxd9+bvJ_Z_Uh^L2X>kg8K2=g_ACvG*ufn9}S|7)T*4nD4jBCiUdu(c-_jI#tShC zH5p!h1AfD8@^`i6Yin9NDcrOvEGDglQ6nbZ(B3X4QD9rE43NK+vUF0Z1Q9^RnMCs* zYZ1(`WvmOQW=6|=vr<4%n+M)fuht)2AFyFiJl8p>=Tj z(EpKfuv+Y%<`JEf<=Qx<_u`>F0oEEeM2a)c2+ z+OJ^YyBB^38^oX9LV)9A!5%=E%%q40rN|QU6@@{FEFolV>{-jcg=EY26|!&t=j-!%-{xcfzx$x) zeSWs{+0N(QbM853lrHc8NT(ss)J@T?{ulALaT;HlGDNy{+iS!3QIx|Z+L@5wiB$bG zSJj5Fygxg}qK9;`hP^W7Wjw<$JUjaSU)NP-{i`J^Kiq;`TW@@2G2_%{dL2N)F*gIf z>)$M{OA23E%oJTmqL=1a4Bw0Q#k?uQ!*Lh8WIs8v{=V03_i?f(B zu!go#)CVg4d2l6zb&L7su#|ZIx|xf=7V4#*jPdV1_CDj!;FI|1_Wg?I97TPs{c*VQXrDpx&G9soGn0R3ynEnGt0*_{{qTj| z34?0yVX*jsh`#~l{X~3k(gXg_cIRMtOWnU3^U*2CI_|eieNr}Dno zSKg%`hrbxaSMYvA;MKhUD)2LS|4ZO?yx&ecmwPpf&c}BS{33jhz%R!S2z)W#EAZ>^ zV*+1>j|u#Cyw0|!_O8UMgZKyVh9F*T-x&B)_`)Fl3;6Yczlz@#_&fNTz(2xY5Bzid zlfb{le+Yalp3VB~U(KRF@D73VhcMm#PAS6?ivX z`(S4KNqlq=Ux@2`a3=mxd~y)qAJ;kHO#DE+R6C!0wTOjEE%R|ok^@%e#Iz!wHS z6<-o~Eq-0#v+$b&KM!9K_=WhrfnSC{8~9@U)xb5@8v?%t|2*(J@oxiPh5s7(BY5`q znf5n}p2S-P{yd%&_Y&2M7KmJ~Hs%@rI!PW7M@Yh;NS9 z1l~$***2anqFwOmL3}5?IEe3z*9G1UpBFiDV~}azZMf!q##iEFg7gpK^+EjO`0OD58T_2UU&1#A>0ifl_&-zrd%V9aNdGZ@ zd*GY#2Lt~Oe?0J?@uvd+3ttzw=K3dr?|^?1_)hp&f$xU@8h8%gT3`6wt68)^zF*)y z@VvnD@d1JN!iNRk7atS&(Rf+lL-ARGkH9YpyaZno_;~!mz^C9Z2CjXljz00P7SWk_ zL*VD)9|!3#z<&vRA^uz7SK&M8;Kse0Mc3i~3H)ZfRp58vZ34d!-#PGy@m&Ld0`Cy` zTD)W6>+n4Se+%Cy@DK3Db4ksjPw}on{MUG4;6LEK1OE*l7T09v+&|z`{&^=1o0Q*8v@t9UKgZaj5h>+ zJ+40YuNKiQye|#>PTtoCzDn=6&CeFmBY1J(PvUifKabZ3z8?QJsNdUobB@pat6B6R z-Y)RZ@WvDI&7yDc9zpz%_{O08-|@U4K1STU%t3h+i?+vS1-=75F>tLtM+e>xKY81D z#G(%PmpTA-uUNDvJ}mIg`24^Rz>5O!f$vWpGx@cabqL}M@jZj>^~Rski5>TfMSbx3 zfggzv415s2W8g#aKeqKpEII+-82Bjs;=oJsRN&+AH@A&fESiMt+;XNqRrstRz7`)9 z_!)RvkbXA)PvCR#=0W-k@b&zkDgRR5tIUjF$@{*6Yi-sX&BWh;-xrMEt@!1E--+ML z`N2&3`|ufoKZK77d=1_@@MrMNts3)d?Ozx8tN5zG-^MEg{{ZhA_$T;hLHS?eF9iM_ z-Vpdt_$NBS;a;)m5B%N0WAx=~fj7gS30$8Y_Xe)dhWfyF!!HPYPyEcl_r)g!-VGlf zcoHuPT<7LH1g^FJhoJp^@#}Rm&)RbozBur~cx~Xr@yi0&T)Qyv(fE0RPrzpdJ_Y}- zUE}tu@y~T~%e`Xmv*Mk=XA}QI;B)cE17Coz4E!>Dolcrtc~{}z1%565ao{)MOLgOz zrN0dy+o{p-#-{~-KRz<>NAM2D?4i2n!g6ZFS+e6|)J*toqN@T&uFgFh7bu6T9eo$$iI_rVti zegM8Q@PqJ4f#>4~1%3!VFYv?hTLV85A07BH_yD|Oc_`QcW`qg-C;PrURz;DGrIIJ=K zU3hN)M!z2~4g67jVc<{Ub%DQtbJvT#V$rMk#=zgfTOZLF{}G-Y_~-c6ApN)ak4HA9 z-->q|(CB~Qy9OTTyI~^m1pZr)zcpSwyfOc-_*W-1`X2Zbf$xhi3A{T#J@7m{75KsU z$`c#QI~@Nk@B#S7zz5^c1%3klVBn|VM~rGLuMA%u_+)&1;M4FSfzQNu4ZIF_C+A&} zv1lIN`jp1ec@zNl^7SEm1m|w?&L#8(RdH9+j{zCkOz%Rpl1-=+x5ahoepBwls`1HW< z#5YwoZf_O7A@E1=jY0Y+@t1=5=ka=epYpF*v>yK{@VD_Tfq#gv5BxK{A@FY$U(;CL zk9dsVw=(7bj{hFS$981>3cNY~P2jEY&jQ~C|1j`Q_}hVJwj^fpOMYkK_0lQKHiUG; zb9tY$ldegKMLjKEX>?dI2v=I4{)c}~Y~rJvq@UO%ej2{=bj}%3hRUzQH>UZHW_~f= zI-lQw&6nVrm$rXn6Tc0wn(lvZRC%lMI($FU%Adto@*{ay^S6|r_;Pa{3+51iq4|$^ z*uGe+fBTO3O7iDe`i^)N?dfHH0A5Ptbp5}!pT=9yBr#3 zd8{Fp|1`WI>3_dg{5g2$rT#cy9^}6gU*ET}yk&TO;1A$A9cVwtu_|v3K7_IUiDKk0 z;44$CiRSMresp8}CVV~fH8Vcn;5nr2!vAfeAO86X|5yJ}$@(*h;~bdEZ-py;Hi?ve zcf57AzsExHUDYUi>1~RC!t(kyi64Lu;dt`|(klOmCh5mDNng>#Ynu33P5eB(bvw>s zTKQKsiEliXCmm^SZ4!T16JLebQ{E17U*9M2jirtK`LdF?kxcV$k*eELmz zTjJCwZTR;qynWz5;tZ|DXGQiQ3-i+e6;>9d3`idfN&c0M1#P5W+ z?&j}3QvAMn6~5Tg_fkAN(=7Aj@XSl?8;Lg@=&#jM{>jSUqj5bu3$MqoA+6#s!Rrq4 z&(D!xr})5c#~T8F5Z@U1Gq^qgn4+${*YO-&*G;LsPw?Wvzr#xd{}ZnZ^6$XDSs%oA zz#H&|R$ezeH^p~2^8!5cYR#M8O}t+dAB3-G=VVEB^&5c~5Apjzn`pae5mo)LE_{wpNd6qAK1-_+{-+)Q4{%B~D{y99iXXLKiQvAnF;=jb} ziQl@N&;MhS_}}n`(>Nz&<;U6CxA6UJFY{gSx*Gp{BbC3O7K17Nelq!?a(k)&j=)#) z{Y>|!DgMMJ@wzswp2g;GTc0O4iJ#WQXW~Q7<(P-ERo?t2@eAdAxK6P6Wq3oKzsFAL zS1CW^)yd+YZj%2+ytE(JgjxK1czxiT@s0Qs7XJgjlEKJ~|DSjR$7_FDd^Q7L$9tN{ zc>gEb5icg5k0e+B9K2zGzh_VNOW`?3^Bb1M_rdFN-8-lF!OBluro5Bzx??y8Z1ZCx z9u4Oh#L}ORZydofgq61dA2PDhufwa3=QmJ`zZb9L_-%>#b9fH<*OJ6dr|<^iGVMDIZ#|l8cP;&3 zJgRa3x%?-|?WOWd@gZY;AF2E)csAksU!V6g@rA?>#T7pf&l$@(5A&sXUEp`)Rm>-r zOqYHQUXN$?zt{0C__-GUt@2M|PMBx&*_q4yr^+t>9(d-Z`sU*GQ&}Udzxw0FRsMQc z)$as+C7CnzE63MQXMZEF;%DGPm@Jw8o`+YR)0qDnd?9{_rN0{w`y+DqnDyW?_a0-T znKNs+SEagwJCF39+tI{nN&S=JAKgeXw#L7iP+3#SyDA@0WlA{}%HwX{h1E5c)eco- zt7h`1j2nlh)l!DrtbgW;zsrp~=-e{{d`uPh>}x}I-p7dB-ye}?kk z>EvUTv&1DYpIYvUq70rLLfllY-v{>K5#Eg(8|k9{lF`-WXN>c2t7@kCH!jH6c4~F) zw9I{YzDB;XB^8yU%YvG^-Yc2N&FLj$Cyt(`ZMjl=7*%VR77P-0979;x6i12D3?QS#4Ey^8X4<`9L=VO4Nc9HEP^6YFN%q zXFXC8w`bVh?B&(vW6CSaYi2fv`I~jT>ke{XE8RWgpR}TzWp$r;Rf&7&dXU?R=nD;b zk3oHl^7L;qS?E#ZkjfPbd+OgJ?(5*+0vD0%ljWwpS)fm6QNBFBWT@C&mpPg1$}4h( z7x~oru2fe}kxN_X@)x=^g|6U2m!{CADYR<3f|9wunn?@v+e-RvC4HrmZZpZGD=L^j970?|nG(FEJ$@5#u^Tp@+ zTBUtl+HWjvrTB`cePL-|O4`b_B$mNaT48<*X}<-lX1?D-zAr4_my++Z=lksWK6}39 z^QH8(41Rk(eZHQ)F4pLtK0{B-;7jT0%k1g5(9>rx@P!rlQVM)21-@nlzLWxAN}*3u z=#v!sd^YBO8YKN}O!^6u^s^=DCuh>npp?zdB9}eoCrK)4=C+XX^D>p|Dv|Q@IF;)v zk>ZOa1DDG6P4Tle<)?1ac9SAsYd=4eMZWTWMkj3-DRNzq^0P6ObS+9HU5BLnew9l3 zy7(!V@-rmmr$)-po|KvgDCMVA z%1^gc+BGwk_NAnK7x+n(^7Aw0=VvO0n zewL;DEK9i>xpupjxsGtnah>2=dAEJHJ-0Qt5m&ZrWr2pk&15%o zlWsb?Y3nAfo0e{_xGCZn#iW~%NjC$NZUXwnE$Jps(yegGq-I^xt!PQNyd~XyO1kOf z*S2Iz1D|x`o^%r=>1IUIO^>9TKuI^Z{KAxUGb`!lUeZmyq#Nd>8|7r4nv!(WC+TKS z(oLSEn;3q;{0RA>^uy$b&X1!X+mzdhQm*e(Zf{Asy(Hy&AmutE-|Y=)*P?t^+k7_* z({9a9yLP4Bu99}GOS^fWc5O_%JtFN|ns#~9uBB<$(zM%&(ypax*V43WY1*|k?OK|4 zEls2|1?8d5rgddQqs6M+wO zoy#=U`T<;Ao}ZC9m*tjrR2FGU}C#{#!o9Y;L1$9&jO~kD>LmrAd)>@ zFDHBY&GvK)eX^%p;ep#iPd9;+zAu0lyQFVBaGUjgkSy?}6!<;7z!z5N_whov9wZC> z9$e__S?JqW=%!n;(9N!7p<9%I+oubCYYW}jCkx%81Kef{-D1RNqia#2n<{)ndh>ND zv`V;7Oybo4z-RXjEA+!r=m((44@Z$-6^i__P~_KzBH!gjejJM2v`D4gyh!;^H~v+v z`HWMS6R5iIueQfWmWLb7l>eMarQBx^aT;Qvj~Srx;}g%Dt2JhUE@hq%%yZ35<@x0$ z&#y0ee&O+ZaVqV%koKGPyEB2V=(Ou{>Y#oB$!KiZxG}X8?7&RViHk~(95lGk;e$#B zA92L6{ycp0@IHh3m-qxcxMEthf9no@c$$e0{oH{?1<%It-@NAPa>rLh zTwPPftcb?jh)&PE8Lu)q7~@#KS3O@gr#RYGk| zwPmobaEFz?z)bCDjuzETqjj#c++zeX-Nea?X#CiUO7<-mnb`sd z)zhX;t>g@Ye_moVmd9>RbDhbNF}sW&-IvMYPjL8=sP-oeYAQ3w@h;d`+ovew=^oo2 zE98rCbJ53+ui!aF|H`We7g>OvLvSgpIFj~{CbCd=cs=sZ7ZW^tC=9VK3)ATNLOzMk zgoMK*&y1hmZ|h%|a9e-MT%Wp9wZMdh$TNlL{l5wc);Glk>L&)(t+XYqWV{}(82NwM z!zS zBW_#%p|478o7LmQ%BPmNXWFoM@Sxu5ZrRAhv&5H|(GZezipOu(@57W=MHCNj(RoGJ zSuTP)v%J(>3Gg{77J6rA52Ykf1mB8i+e}^@e=hOI#>w}49 z#L5b$7(L07X`SWL_>XB9;--0~iQ{+xsz2@KKOy}C8QqCBzsl6QVb*wRsN9FWJ>yHm z>ZYBW>;FoYnZ9loX7akZ<|n3tw2S%=AU}EKnk->h=HWyo|C+9u+}mQQNUfi}HI);1 zb`$49{qu-z?{d?)rm}*i!#}UiRa+ahy`iyya?W$=Q_-COcioU_c8P1Do3!q2LvryFHPktkSS%1acZY_evnZ8_kv27FK4@>%SBK@O#!xDqI{72qA9_ijLrCTT`-4c;> z%V2`v^zM`MK!&v{vBq#WH7li&xm*P!A*Q#ke1y(-x| z#-raw`sE*ye$oAg**r)>&%w!V9e4K&D&L`U%GEs}D)%^;IF9?#q3Wl5H4?-8{dTI) ztqLdKYN&iqiR61p>5ljJ!D&0X-%R!SLu|uSA6oc)x|cxtazyeS029NxpGv+{JUT%n zJB>mekaU%D>$SJq&4v_iL z0V;hDIq8c;()WQ0e&`!2C*6rq>2%Gt(oGjhHybAS4fYZ_=@vnyTP`QveIn^}t#g9k zX5W^x{ZB;Fe+iZTFFEO(xAf`Tzy#OY>Kb9CKLlz%9WQ4*Pm-%Xa@9vvePDv$e6Nzz zFUv*x|1PNXFUd*&wn+MoFu?^YzsgCU_>WKD3M&19a?%%yq(2-c_>Fk5IFQQ?M6OXi zM=a&pCgNzGaRW7PZkLaVqIaO?jjoAQx!=htSJybI+^ii*HdlJ>BhsvM4sm>C*65a>8_HK?naSxD`29WXZt9gaeP%I z-A9UV%RCSnS6z6bacCp9i$`6|j}~`{N44Uv@#q?n{bY^E5B}S?fjlHw&qGN};&*J3 zwN=+BsUBNJ>hYJtC$nv?&Cxp37A7jVhDc7je35jADtro;6Us?93hMK1qI~ywG)3$f zkEV&8;?Yc)m>Nar%BlZ+n6*dTU4xXhXFU3^;w!mkQ}Oiwo#G#{=su-moqJl&hvIAU zy;!g0d$WFW4NUevtmiPRGxJZrFY5wSeWpOQ^K`L_YlpQ)?%>#f6U}6@ZGx8pMFAxu6-YWbo_Fp;q&J=Uw(Oi*ycSDu) z0!(m0)|(0^{}*!l`v-A0*Vb5gpIz{}C^`zNyfGr*19Xi?;vBBSu<(mT+Omt zh2JMXk863vIXrJ$oEt^&i{~?s#d+)=Tr-iF&$ID#?F9ANPkuoZCCz(_DL%gxej(T5 zS-7s%Q22C_?VqFg1oN&JoYQ7_CF(M9)G6zBdr`iJC~@Eiy8bt2n+S0w*t#b3&OCQ#eY+KupoS(jnfA$;F~ z3BGgfX57;_7%Kg6^D<+FaVFIF(Anm5jh7m)G~NQWoqJ$*?|Af}g+FF|!T3JZ_CAA3 z|2!nj? z`_OoFk(_>5B=WuV9;p0phzq%ISmEURUS$2q@95bNy6wm*Z!*j-ibtne_#)$ViYH$i zE|ydJB4b~ua>tq1$SLPS^DpK7SRX|CIeQPv?@u{U>2jdT>tak9k20PBm2ZOiG~-1I zC;#Q<*BO@?*NB&Ke+pFnJ`_p+In3@AkG@kp+tnXy6t_3FfokX8^2_;Lf=Zun@x2vK zIRiw>9b(}p8A}yT{&Mqqa?)KVlJ9A#b#$GW6_4J5i7U8ILeA&hr%?HSRXFu(mgDp7 z4ONc=<&;-s;e9N87*zU^7Cu@eU4@0uFrH^z2vy#Hq2|qXBJ*aYNWMoz>bq8?J{zFQ z-(=xmiKP3m(At4^;h&EWEGz5Q{&-!ucaJE?tGO)_9iUDd&2qb>(IYUtzq* z_!w0EUNP^uk1ua;<2aao1naeVo$-9*ZN}%tE4hAB{4e*}K$ZKG#s6W<>g>zk17;t| zaTV15k~AMA4v0s?q1r#nSgr7*_}mqbW*xEcD~!vGtBo%kHyFP(erNo{xc$Cs`#O=8M)A*OM<9U z#!HP$jW-+bGCm32{4)PaPQU&H)vqnP`1*8(+J4gfFyk<&^rcXrW8*En!ngt|-^1q5 z8aEg>8NV`aG5&0fA7K4q>~1^?s@%cm!;NLe3aEBXGe1L4J?EG&fy#dy%swU_Jz@Mw z@mF)tMOV+Gq0)_%GcIF|Ghp^$KG%&apwg|Bv)`-{hwyzDD&I%Ozb$^ZZa#f~sQ8h_ zGcEiQ^To!SjVp}z86PsPF}`TrWZYtmclX=b4XU1dnRhexhuO!*qk-l_jpL0~#&eC= zK$UZY`3mDI5UcMkQkJl@l^k0c=w^f?(IOp@kEWU5R#EslbDyJS?apUUITj4ixjlZ~z z&ts^1jfN^`f=IdZMYekd)c579q3U^y@ot4PKOPdP&y!I3UY0YCo1x0xV&Q*^l;1wz zhwlNEzB5eR%)JM4;*YcV5ejE}Q;oBrj@z#lCoylt$?@n-u~j_!NUY%aT%5vwD^BHn zYfnhN-9`KmsCxB-SrgeF)O7Vc4zv)$L_xAL4ld38MMUI=TL7h-KZI$b2+r6T=&CDi$%+eONKQ{l9$ zLlGq37^w3=bLI5&74mY9&*ju7`(U=WoH{~{`|fh;la^DTQ;bz2^;xKR*4g4i@aY`S z!^CZzPl8&{W-FZaY=yX8JbFMpopBba*Wcm{)`MPfCdUOZaXafHRQ{m~C;zG9zVT?1 z;#Wk`c^1FG;_rp(*Y_1Zf#V~EpUL+Mn7D)UEaIKqOVXQg#v?~$KOG4ZcX2*K-h=&H zes>hjF~1n9zpfQIkMXv`>F4i^zre&w?)eh$A?{HApB0ZR!fr)#0mbt>& z{uq&TwFwR z$9XQPNPm|qoN-(rQqSea2cY(YC*<_sZ{oRecXMrG4d*fX;_S~mLG{-GFwwv~S2)`_ zR{jLvlPtbc{v^*6v-m6JPesvfQ1k9Sg|i;NYyOFOqMwi787jWWys!Br^9$s=u-}?L zZ~ndcKXUT#-Jk6;4+_Mm`F#*-KjqI7yZw2hIG1^4Tx@(8s-CYx<^Mu_CW^j=%Kw|l zdeHs|cs|=P9tK_eQR6TM< z>N&u|hZ|>De4WK#s&M+{S_{9~!dEGr?LKaN*Wy36_-_zc899ZDe?uZW5#o! z>T|cnKdx~4dGSCpz3$gvA%vkL6y^du&+-JlpiKi?ofqOuX6KwBK5jT zB;DQSKU=)+FIM~rk^IX=(ycUaFkdHPP+!mY1fHR z?K;(X4phAtm|taF4z>S0WWL$>gK@{06E@{7S}4q@UBqQBd)-EdFW>UuIlq@$r*<{=JO(BKzk_BJ*LU$mhyDsCr#2 zXFL`g?@~DRTL-nh@1fe)d=%+eU-pK|mn+hqULxr$75`t_X}nb7q+4R~PgwXH#*Z!j zON;+Y;nZuplYPE6BIS1yDZe|^{O>6;e*Hx1J;J<3B>#=Z`$f_}C6ew{sB*SKwQKuR ze7klP*Yf=bY96FSz8@T69AZ34oWeXaR*H-1Ka0Q0c!R~?X?#E=-Am$C9OoH-Ft$F` zhj%pgg{t2$sD8iO{1wGt9gp5u`19POZt?LF`~~j+hWZ}aO(b2R!e5M{Vd6_1_lPe? z(S_nGQS^+sj^FQL_BEWJm#^pNgHre^zY~bB@jE9}{2=-3Jg?4tmi!H_OAz1W_h0d? zD0&#G{x3s)zkf^Qd)QYN{wqxIwJU41FSip^`UB+G@_k5b#qqYtxQ(*-2~g|PS;qN_ zzmD}){&o~CmXq&Zv5ezKaVf_YihqaSTP^-Oi~q;sn~x#>UG6uB%AXd=cQRDH&W2g_ z@o1^}a;R~+SA37>BZ}{HU%$A4=f#O1MA0kahiq5;h<+9~(ywEExyM7zhYQVDng7px z*D@d9M_k75QN{}`{95sP+6z^`kD%(?d7RHzAl8ykbFMD_C69R{|k|P zx`spb+8OHj^iZ)gpNk^(IvJ|mJE79ur*P7}sBr4{w}rQwgj4>dQ0Z=!-@^EdvpH^t zD(??D`C3kf)T6CPJ-UiF^F0MB|4H&&#{-AlQDZZTj zpu!J_I<6gMoFd-D_g(Qe&J!7*w)pof{&x#+JJqMlHI9KQcb1%X-VIgn*DU-eg-?%1 zyHrBo-oB?nj^lfZly?kN{3Rlv4@*Vn-7=B&ejQXf9jEzp2SJrHOiub! zMACE5yi0!uRQfBR`eT{+3D-qJt>$Ps`2SM zK-K#YsPjqv<#Db*v-q`8+kH)B|9)5eob!v~7aUiK{Qp03a}@m~PUrYr{E{+j;a6OL z0o9HJpw4p~tnjZnJcT;`JYMX|_Z_ht->0C`UjUW<8mRO)DW3GJMAA2iq<;r0{fAK3 z-Fzx?{^A>Phj{c0)cU#ubyK=_Q0>lxN`I(G`v)kT_780VWM z3qI$}V>7+)4i(>BPQ80s_$Uj%OFo0|^TxMe;(zQ{XTa~Mhqxt*j)YpLD&*gDeW3UQ zpTFXdd{2PdPNy@eFZ)MVsPAKkhg&Z zF7rjafb(1;-y>VjA|LzXo=|?En8Wys?=spKlb-=UK;dU>);VRvA|tA2l`@pBDMUh-<|JpI0J(uy4J%Lo9kjY#EE*5&sj5 zHi$dM+~4I$w2DQa%3E{)f!K!e6nElx32|qhStqvTJd@Zi7X2wwFa1%^#4h}mKoQs9 zi4a>FTN~RN+l#yMIVe)!9FcnJI`c$({!Xg68|#WlIl0EP*dgZrPEBI>Sk%kHi^Y!o zPGLU4ILJ7}c)Zw&XFZCv<79D!cVt1~K z6%S0Aizj!#$L>2om{$gLo zU+fo)ipBo4<5+kE?GTTo9pV7mAs$6L#G`44IFNRTgJ_3%4DA>UkEI>rVA>%Lp&jB- z+94hni`t6AVo`gMn|3;i!k9XoonGc8Dj@4sjIi5KpEZ;wiL4Je7GY zmc*g~#zA6fEE-}wUL4Il7RNA;#j(s|u`Cvq87GS4Vo`-Sp6iN5`lCjiz%$6iiOgfM zoOvuxVjhc=na5%U^H`k1JQk-ikHt#nu~-$0mWrpvqIz)}^H^j%%SE<(hxtment5!# zTC9mhkBYU-V{tn3SUjD1EY4sZ6KArHiDxj6#WR`5;w)pwkntB6F#h62jK6p><1b#q z_=}e^{^CN$U%ZU*7cXc0#VZ(paS`JuUdi~0|79H#uVVbf#f+b^M!cHw6R%0 z`>*&2`>*&Y`>%13Ncth-W8CLwK0FFwimi%&8BBI#?yrx}0o z8OC3Hmhl&#WB(P`GXCQ8jK6WA_yXfEzR38CFR}lMFEjq)D~!Lmj{R3$&;BdE%J_?~ zG5+G~jKBB>`>*&W<1fC&_=|6||BCN0{^Gmrzv6q0zxY1mFK%G}HEt9?VEn}o*?+~4 z7=Pmy<5rRUzZ(BEM#uT^Y@>efP`Z}J*2cC*{r;i&jw0L1G4E{bV(f0rHKvV)#$Lu^ zV?W~n;~?V@Yu#xmnXV}(fls*E)jKEpW6SZADLoNv6yxX`%BxY)Qsx|Vm#hB!g#W=)L3SmDAN84aWmsDe#!nXe#QQ8oMo&t&N0q6USwQoTx48qTq=Ie z_?s^?E;rs`TxncoTy1>R*kF9xxYqcRalP>k<2%L;#*M~Ljhl_%h_ru;Nc*>1_^-x4 zjnVPGU$TwOjV+C>jctwXjU7eWpCf+5`Y(RV`fuzm{*U!v{EqeCSSXUdm$-%T7r$ry z7k^;=7k`XJgT$?@|Kd-q|KiVle-nRU{TF}b^NUxk8ONGN4zHZIG`2RjHMTc)H0BsP z8@m|08*`0mW1+E^vDnzpIKVi_$j7X!57l)XVLaJbYAiEOG*%d^j5Wp?##zQX;~e9B z<3+}W#zn@(#-+x3<1*uN;~mD8##P4E#z&0}#;1*IjV~G38{aU#W87feX#CW;+4zld zi*c**SL2_?h$-O4-`L#P(%9PA*4W +# +# Released under GPL V2. +# +# List dangling references to vmlinux discarded sections. + +use strict; +die($0 . " takes no arguments\n") if($#ARGV >= 0); + +my %object; +my $object; +my $line; +my $ignore; +my $errorcount; + +$| = 1; + +# printf("Finding objects, "); +open(OBJDUMP_LIST, "find . -name '*.o' | xargs objdump -h |") || die "getting objdump list failed"; +while (defined($line = )) { + chomp($line); + if ($line =~ /:\s+file format/) { + ($object = $line) =~ s/:.*//; + $object{$object}->{'module'} = 0; + $object{$object}->{'size'} = 0; + $object{$object}->{'off'} = 0; + } + if ($line =~ /^\s*\d+\s+\.modinfo\s+/) { + $object{$object}->{'module'} = 1; + } + if ($line =~ /^\s*\d+\s+\.comment\s+/) { + ($object{$object}->{'size'}, $object{$object}->{'off'}) = (split(' ', $line))[2,5]; + } +} +close(OBJDUMP_LIST); +# printf("%d objects, ", scalar keys(%object)); +$ignore = 0; +foreach $object (keys(%object)) { + if ($object{$object}->{'module'}) { + ++$ignore; + delete($object{$object}); + } +} +# printf("ignoring %d module(s)\n", $ignore); + +# Ignore conglomerate objects, they have been built from multiple objects and we +# only care about the individual objects. If an object has more than one GCC: +# string in the comment section then it is conglomerate. This does not filter +# out conglomerates that consist of exactly one object, can't be helped. + +# printf("Finding conglomerates, "); +$ignore = 0; +foreach $object (keys(%object)) { + if (exists($object{$object}->{'off'})) { + my ($off, $size, $comment, $l); + $off = hex($object{$object}->{'off'}); + $size = hex($object{$object}->{'size'}); + open(OBJECT, "<$object") || die "cannot read $object"; + seek(OBJECT, $off, 0) || die "seek to $off in $object failed"; + $l = read(OBJECT, $comment, $size); + die "read $size bytes from $object .comment failed" if ($l != $size); + close(OBJECT); + if ($comment =~ /GCC\:.*GCC\:/m) { + ++$ignore; + delete($object{$object}); + } + } +} +# printf("ignoring %d conglomerate(s)\n", $ignore); + +# printf("Scanning objects\n"); +$errorcount = 0; +foreach $object (keys(%object)) { + my $from; + open(OBJDUMP, "objdump -r $object|") || die "cannot objdump -r $object"; + while (defined($line = )) { + chomp($line); + if ($line =~ /RELOCATION RECORDS FOR /) { + ($from = $line) =~ s/.*\[([^]]*).*/$1/; + } + if (($line =~ /\.text\.exit$/ || + $line =~ /\.exit\.text$/ || + $line =~ /\.data\.exit$/ || + $line =~ /\.exit\.data$/ || + $line =~ /\.exitcall\.exit$/) && + ($from !~ /\.text\.exit$/ && + $from !~ /\.exit\.text$/ && + $from !~ /\.data\.exit$/ && + $from !~ /\.exit\.data$/ && + $from !~ /\.altinstructions$/ && + $from !~ /\.debug_info$/ && + $from !~ /\.debug_aranges$/ && + $from !~ /\.debug_ranges$/ && + $from !~ /\.debug_line$/ && + $from !~ /\.debug_frame$/ && + $from !~ /\.exitcall\.exit$/ && + $from !~ /\.eh_frame$/ && + $from !~ /\.stab$/)) { + printf("Error: %s %s refers to %s\n", $object, $from, $line); + $errorcount = $errorcount + 1; + } + } + close(OBJDUMP); +} +# printf("Done\n"); + +exit($errorcount); diff --git a/sound/pci/ice1712/prodigy.c b/sound/pci/ice1712/prodigy.c deleted file mode 100644 index eee13e644..000000000 --- a/sound/pci/ice1712/prodigy.c +++ /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 - * based on the aureon.c code (c) 2003 by Takashi Iwai - * - * 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 -#include -#include -#include -#include -#include -#include - -#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 \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 index 1ff29fee2..000000000 --- a/sound/pci/ice1712/prodigy.h +++ /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 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public 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 */ -- 2.43.0