From 5f303c69ac469f566cba0c1bd56a4061a22eb599 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 23 Nov 2007 15:12:09 -0500 Subject: [PATCH] Linux 2.0.37pre2 o ACard SCSI driver (ACard) o Initio SCSI update (Initio) o Tulip driver update (Don Becker) o Add new SMC card to PCI (Andrew Pam) o DVD may have >800Mb files (Ulrich Habel) o Readv/writev mand lock fix (Jamie Lokier) o Support for 2Gig/3Gig machines (Ingo/Leonard) | Im not sure quite if Ingo's patch is based on Leonards or whatever | Also if you use 2Gig or 3Gig you are shrinking the per process | address space. So dont do it casually. o Fix protocol bug in IGMP2 code (Julian Highfield) o Floppy diver update (Alain Knaff) --- CREDITS | 21 +- Documentation/Changes | 2 +- Documentation/CodingStyle | 5 +- Documentation/Configure.help | 541 +- Documentation/ide.txt | 135 - Documentation/isdn/README | 6 +- Documentation/modules.txt | 2 +- Documentation/networking/net-modules.txt | 2 +- Documentation/paride.txt | 44 +- Documentation/udma.txt | 663 -- MAINTAINERS | 14 +- Makefile | 12 +- README | 16 +- arch/alpha/Makefile | 4 +- arch/alpha/defconfig | 3 +- arch/i386/boot/setup.S | 4 +- arch/i386/config.in | 25 +- arch/i386/kernel/Makefile | 5 - arch/i386/kernel/bios32.c | 2 +- arch/i386/kernel/head.S | 2 +- arch/i386/kernel/hexify.c | 6 +- arch/i386/kernel/setup.c | 6 +- arch/i386/kernel/time.c | 1 - arch/i386/mm/init.c | 28 +- arch/mips/defconfig | 1 + drivers/block/Config.in | 12 - drivers/block/Makefile | 8 - drivers/block/README.smart2 | 85 - drivers/block/TODO.smart2 | 20 - drivers/block/cpqarray.c | 1662 ---- drivers/block/cpqarray.h | 98 - drivers/block/floppy.c | 48 +- drivers/block/genhd.c | 25 +- drivers/block/hd.c | 1 - drivers/block/ida_cmd.h | 338 - drivers/block/ida_ioctl.h | 80 - drivers/block/ide.c | 210 +- drivers/block/ide.h | 3 +- drivers/block/ll_rw_blk.c | 20 +- drivers/block/paride/Config.in | 1 - drivers/block/paride/Makefile | 9 - drivers/block/paride/friq.c | 282 - drivers/block/paride/frpw.c | 11 +- drivers/block/paride/jumbo | 8 +- drivers/block/paride/on26.c | 21 +- drivers/block/paride/paride.c | 9 +- drivers/block/paride/pseudo.h | 20 +- drivers/block/paride/pt.c | 2 +- drivers/block/proc_array.c | 119 - drivers/block/triton.c | 562 +- drivers/cdrom/sbpcd.c | 9 +- drivers/char/Config.in | 9 + drivers/char/Makefile | 1 + .../kernel/apm.c => drivers/char/apm_bios.c | 8 +- drivers/char/cyclades.c | 119 +- drivers/char/isicom.c | 2 - drivers/char/random.c | 10 - drivers/char/selection.h | 7 +- drivers/char/serial.c | 36 +- drivers/char/tga.c | 6 +- drivers/char/tty_io.c | 15 +- drivers/isdn/isdn_net.c | 29 +- drivers/isdn/isdn_ppp.c | 10 +- drivers/net/Makefile | 4 +- drivers/net/README.rcpci | 79 - drivers/net/Space.c | 1 - drivers/net/at1700.c | 9 + drivers/net/de4x5.c | 28 +- drivers/net/de4x5.h | 1 - drivers/net/dgrs.c | 3 +- drivers/net/dummy.c | 5 - drivers/net/epic100.c | 112 +- drivers/net/eql.c | 4 +- drivers/net/eth16i.c | 2 +- drivers/net/lance.c | 24 +- drivers/net/ne.c | 7 +- drivers/net/ni52.c | 3 +- drivers/net/pi2.c | 2 +- drivers/net/ppp.c | 2 +- drivers/net/pt.c | 2 +- drivers/net/rcif.h | 68 +- drivers/net/{rclanmtl.c => rcmtl.c} | 1459 ++-- drivers/net/{rclanmtl.h => rcmtl.h} | 177 +- drivers/net/rcpci45.c | 1745 ++--- drivers/net/sdla.c | 11 +- drivers/net/wavelan.c | 129 +- drivers/net/wavelan.h | 3 - drivers/net/wavelan.p.h | 59 +- drivers/pci/pci.c | 45 +- drivers/scsi/ChangeLog.ncr53c8xx | 1393 +++- drivers/scsi/Config.in | 22 +- drivers/{block => scsi}/DAC960.c | 1 - drivers/{block => scsi}/DAC960.h | 0 drivers/scsi/Makefile | 57 +- drivers/scsi/README.aic7xxx | 82 +- drivers/scsi/README.ncr53c8xx | 302 +- drivers/scsi/README.tmscsim | 72 +- drivers/scsi/TRIPACE.REL | 21 - drivers/scsi/aha1542.c | 8 +- drivers/scsi/aic7xxx.c | 691 +- drivers/scsi/aic7xxx_proc.c | 170 +- drivers/scsi/dc390.h | 4 +- drivers/scsi/hosts.c | 39 - drivers/scsi/i60uscsi.c | 956 --- drivers/scsi/i60uscsi.h | 572 -- drivers/scsi/i91uscsi.c | 4456 ++++++----- drivers/scsi/i91uscsi.h | 901 +-- drivers/scsi/ini9100u.c | 1274 +-- drivers/scsi/ini9100u.h | 148 +- drivers/scsi/inia100.c | 953 --- drivers/scsi/inia100.h | 503 -- drivers/scsi/megaraid.c | 1290 ++-- drivers/scsi/megaraid.h | 236 +- drivers/scsi/ncr53c8xx.c | 6805 ++++++++--------- drivers/scsi/ncr53c8xx.h | 271 +- drivers/scsi/pci2000.c | 716 -- drivers/scsi/pci2000.h | 226 - drivers/scsi/pci2220i.c | 819 -- drivers/scsi/pci2220i.h | 345 - drivers/scsi/psi240i.c | 717 -- drivers/scsi/psi240i.h | 344 - drivers/scsi/psi_chip.h | 194 - drivers/scsi/psi_dale.h | 187 - drivers/scsi/psi_roy.h | 337 - drivers/scsi/scsi.c | 1 - drivers/scsi/scsi_syms.c | 5 +- drivers/scsi/scsicam.c | 9 +- drivers/scsi/scsiiom.c | 566 +- drivers/scsi/seagate.c | 2 +- drivers/scsi/sym53c416.c | 805 -- drivers/scsi/sym53c416.h | 91 - drivers/scsi/tmscsim.c | 41 +- drivers/scsi/tmscsim.h | 14 +- drivers/scsi/tripace.c | 1562 ---- drivers/scsi/tripace.h | 57 - drivers/scsi/tripace_mcode.h | 483 -- drivers/sound/Config.in | 258 +- drivers/sound/audio.c | 3 - fs/Config.in | 7 - fs/Makefile | 8 - fs/autofs/root.c | 10 - fs/ext2/fsync.c | 9 - fs/ioctl.c | 62 +- fs/isofs/inode.c | 24 +- fs/locks.c | 92 +- fs/ncpfs/Config.in | 9 - fs/ncpfs/Makefile | 3 +- fs/ncpfs/dir.c | 198 +- fs/ncpfs/inode.c | 73 +- fs/ncpfs/ioctl.c | 239 - fs/ncpfs/ncplib_kernel.c | 268 +- fs/ncpfs/ncplib_kernel.h | 22 - fs/ncpfs/ncpsign_kernel.c | 125 - fs/ncpfs/ncpsign_kernel.h | 16 - fs/ncpfs/sock.c | 10 +- fs/nls.c | 3 - fs/nls_iso8859_15.c | 268 - fs/open.c | 4 - fs/proc/array.c | 50 +- fs/select.c | 4 +- include/asm-alpha/ioctls.h | 2 - include/asm-i386/bugs.h | 39 - include/asm-i386/ioctls.h | 2 - include/asm-i386/pgtable.h | 2 +- include/linux/apm_bios.h | 5 +- include/linux/blk.h | 12 +- include/linux/cyclades.h | 35 +- include/linux/fd.h | 2 +- include/linux/hdreg.h | 49 +- include/linux/in.h | 3 - include/linux/major.h | 9 - include/linux/ncp_fs.h | 42 +- include/linux/ncp_fs_sb.h | 7 - include/linux/ncp_mount.h | 13 +- include/linux/nls.h | 2 - include/linux/pci.h | 38 +- include/linux/proc_fs.h | 5 - include/linux/tasks.h | 2 +- include/linux/via_ide_dma.h | 162 - include/linux/wireless.h | 18 +- include/net/ip_masq.h | 7 - include/scsi/scsicam.h | 2 - init/main.c | 21 +- kernel/ksyms.c | 2 - kernel/sched.c | 51 +- kernel/sys.c | 3 - net/appletalk/ddp.c | 13 +- net/bridge/br.c | 21 +- net/ipv4/Config.in | 15 +- net/ipv4/arp.c | 6 +- net/ipv4/ip_masq.c | 1645 +--- net/ipv4/ip_sockglue.c | 28 +- net/ipv4/rarp.c | 4 - net/netlink.c | 2 - net/netrom/af_netrom.c | 8 - net/netsyms.c | 8 - scripts/Menuconfig | 15 - scripts/tkgen.c | 24 +- scripts/tkparse.c | 9 - scripts/tkparse.h | 1 - 200 files changed, 12625 insertions(+), 29671 deletions(-) delete mode 100644 Documentation/udma.txt delete mode 100644 drivers/block/README.smart2 delete mode 100644 drivers/block/TODO.smart2 delete mode 100644 drivers/block/cpqarray.c delete mode 100644 drivers/block/cpqarray.h delete mode 100644 drivers/block/ida_cmd.h delete mode 100644 drivers/block/ida_ioctl.h delete mode 100644 drivers/block/paride/friq.c delete mode 100644 drivers/block/proc_array.c rename arch/i386/kernel/apm.c => drivers/char/apm_bios.c (99%) delete mode 100644 drivers/net/README.rcpci rename drivers/net/{rclanmtl.c => rcmtl.c} (52%) rename drivers/net/{rclanmtl.h => rcmtl.h} (78%) rename drivers/{block => scsi}/DAC960.c (99%) rename drivers/{block => scsi}/DAC960.h (100%) delete mode 100644 drivers/scsi/TRIPACE.REL delete mode 100644 drivers/scsi/i60uscsi.c delete mode 100644 drivers/scsi/i60uscsi.h delete mode 100644 drivers/scsi/inia100.c delete mode 100644 drivers/scsi/inia100.h delete mode 100644 drivers/scsi/pci2000.c delete mode 100644 drivers/scsi/pci2000.h delete mode 100644 drivers/scsi/pci2220i.c delete mode 100644 drivers/scsi/pci2220i.h delete mode 100644 drivers/scsi/psi240i.c delete mode 100644 drivers/scsi/psi240i.h delete mode 100644 drivers/scsi/psi_chip.h delete mode 100644 drivers/scsi/psi_dale.h delete mode 100644 drivers/scsi/psi_roy.h delete mode 100644 drivers/scsi/sym53c416.c delete mode 100644 drivers/scsi/sym53c416.h delete mode 100644 drivers/scsi/tripace.c delete mode 100644 drivers/scsi/tripace.h delete mode 100644 drivers/scsi/tripace_mcode.h delete mode 100644 fs/ncpfs/Config.in delete mode 100644 fs/ncpfs/ncpsign_kernel.c delete mode 100644 fs/ncpfs/ncpsign_kernel.h delete mode 100644 fs/nls_iso8859_15.c delete mode 100644 include/linux/via_ide_dma.h diff --git a/CREDITS b/CREDITS index d9d016f362ce..a63491ea910d 100644 --- a/CREDITS +++ b/CREDITS @@ -557,14 +557,6 @@ S: 25360 Georgia Tech Station S: Atlanta, Georgia 30332 S: USA -N: John Hardin -E: jhardin@wolfenet.com -W: http://www.wolfenet.com/~jhardin/ -D: IPSec and PPTP masquerade -S: 17014 Broadway ave. -S: Snohomish, WA 98296-8031 -S: USA - N: Angelo Haritsis E: ah@doc.ic.ac.uk D: kernel patches (serial, watchdog) @@ -804,11 +796,11 @@ D: Author of the dialog utility, foundation D: for Menuconfig's lxdialog. N: Volker Lendecke -E: vl@kki.org +E: lendecke@namu01.Num.Math.Uni-Goettingen.de D: Kernel smbfs (to mount WfW, NT and OS/2 network drives.) D: NCP filesystem support (to mount NetWare volumes) -S: Von Ossietzky Str. 12 -S: 37085 Goettingen +S: Innersteweg 11 +S: 37081 Goettingen S: Germany N: Kevin Lentin @@ -1200,12 +1192,10 @@ S: Germany N: Stephen Rothwell E: Stephen.Rothwell@canb.auug.org.au -W: http://www.canb.auug.org.au/~sfr -P: 1024/BD8C7805 CD A4 9D 01 10 6E 7E 3B 91 88 FA D9 C8 40 AA 02 D: Boot/setup/build work for setup > 2K D: Author, APM driver -S: 66 Maltby Circuit -S: Wanniassa ACT 2903 +S: 59 Bugden Avenue +S: Gowrie ACT 2904 S: Australia N: Gerard Roudier @@ -1656,7 +1646,6 @@ N: Leonard N. Zubkoff E: lnz@dandelion.com W: http://www.dandelion.com/Linux/ D: BusLogic SCSI driver -D: Mylex DAC960 PCI RAID driver D: Miscellaneous kernel fixes S: 3078 Sulphur Spring Court S: San Jose, California 95148 diff --git a/Documentation/Changes b/Documentation/Changes index 18b566e83f19..d2cde64a9d70 100644 --- a/Documentation/Changes +++ b/Documentation/Changes @@ -513,7 +513,7 @@ APM support as well. APM, which is primarily of use in laptops, provides access to battery status information and may help to conserve battery power. The support files can be found in -http://www.worldvisions.ca/~apenwarr/apmd/ +ftp://tsx-11.mit.edu/pub/linux/packages/laptops/apm/apmd-2.4.tar.gz iBCS and Dosemu =============== diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle index 1690b69dd32d..3f4f09f39579 100644 --- a/Documentation/CodingStyle +++ b/Documentation/CodingStyle @@ -8,7 +8,7 @@ able to maintain, and I'd prefer it for most other things too. Please at least consider the points made here. First off, I'd suggest printing out a copy of the GNU coding standards, -and NOT reading it. Burn them, it's a great symbolic gesture. +and NOT read it. Burn them, it's a great symbolic gesture. Anyway, here goes: @@ -59,8 +59,7 @@ opening brace at the beginning of the next line, thus: Heretic people all over the world have claimed that this inconsistency is ... well ... inconsistent, but all right-thinking people know that (a) K&R are _right_ and (b) K&R are right. Besides, functions are -special anyway (you can't nest them in C (well, you can in gcc, actually, -but this is horribly nonstandard, so we will ignore it)). +special anyway (you can't nest them in C). Note that the closing brace is empty on a line of its own, _except_ in the cases where it is followed by a continuation of the same statement, diff --git a/Documentation/Configure.help b/Documentation/Configure.help index 8a98910f0f5c..24521648eeae 100644 --- a/Documentation/Configure.help +++ b/Documentation/Configure.help @@ -58,29 +58,6 @@ CONFIG_EXPERIMENTAL you say Y here, you will be offered the choice of using features or drivers that are currently considered to be in the alpha-test phase. -Symmetric Multi Processing -CONFIG_SMP - This enables support for systems with more than one CPU. If you have a - system with only one CPU, like most personal computers, say N. If you - have a system with more than one CPU, say Y. - - A non-SMP kernel will run on any machine, but will use only one CPU of - a multi-CPU machine. An SMP kernel will run on many, but not all, - single-CPU machines. On a single-CPU machine, a non-SMP kernel - will run faster than an SMP kernel. - - People using multiprocessor machines should also say Y to "Enhanced - Real Time Clock Support", below. The "Advanced Power Management" - code will be disabled in an SMP kernel. - - If you don't know what to do here, say N. - - See also: Documentation/SMP.txt, Documentation/smp.tex, - Documentation/smp.txt, and Documentation/IO-APIC.txt. Also see the - SMP-FAQ on the WWW at http://www.irisa.fr/prive/mentre/smp-faq/ (to - browse the WWW, you need to have access to a machine on the Internet - that has a program like lynx or netscape). - Kernel math emulation CONFIG_MATH_EMULATION Linux can emulate a math coprocessor (used for floating point @@ -196,15 +173,6 @@ CONFIG_BLK_DEV_HD_IDE addresses. Normally, just say N here; you will then use the new driver for all 4 interfaces. -Use multi-mode by default -CONFIG_IDEDISK_MULTI_MODE - If you get this error, try to enable this option. - - hda: set_multmode: status=0x51 { DriveReady SeekComplete Error } - hda: set_multmode: error=0x04 { DriveStatusError } - - If in doubt, say N. - Include IDE/ATAPI CDROM support CONFIG_BLK_DEV_IDECD If you have a CDROM drive using the ATAPI protocol, say Y. ATAPI is @@ -360,12 +328,6 @@ CONFIG_BLK_DEV_XD Documentation/modules.txt. It's pretty unlikely that you have one of these: say N. -Mylex DAC960/DAC1100 PCI RAID Controller support -CONFIG_BLK_DEV_DAC960 - This driver adds support for the Mylex DAC960, AcceleRAID, and - eXtremeRAID PCI RAID controllers. See README.DAC960 for further - information about this driver. - Parallel port IDE device support CONFIG_PARIDE There are many external CD-ROM and disk devices that connect through @@ -529,16 +491,6 @@ CONFIG_PARIDE_FIT3 be called fit3.o. You must also have a high-level driver for the type of device that you want to support. -Freecom IQ ASIC-2 protocol -CONFIG_PARIDE_FRIQ - This option enables support for version 2 of the Freecom IQ parallel - port IDE adapter. This adapter is used by the Maxell Superdisk - drive. If you chose to build PARIDE support into your kernel, you - may answer Y here to build in the protocol driver, otherwise you - should answer M to build it as a loadable module. The module will be - called friq.o. You must also have a high-level driver for the type - of device that you want to support. - FreeCom power protocol CONFIG_PARIDE_FRPW This option enables support for the Freecom power parallel port IDE @@ -884,33 +836,15 @@ CONFIG_PCI_OPTIMIZE certain BIOSes if your computer uses a PCI bus system. This is recommended; say Y. -Generic IDE (U)DMA support +Intel 82371 PIIX (Triton I/II) DMA support CONFIG_BLK_DEV_TRITON - If your PCI system uses an EIDE hard disk (as opposed to SCSI, say) - and includes one of the Intel (U)DMA IDE Southbridge ICs (i82371FB, + If your PCI system uses an IDE hard drive (as opposed to SCSI, say) + and includes the Intel Triton I/II IDE interface chipset (i82371FB, i82371SB or i82371AB), you will want to enable this option to allow - use of bus-mastering DMA data transfers. This increases transfer - rates and reduces latencies and CPU utilization. Read the comments in - Documentation/ide.txt and Documentation/udma.txt. + use of bus-mastering DMA data transfers. Read the comments at the + beginning of drivers/block/triton.c and Documentation/ide.txt. Check the file Documentation/Changes for location and latest version - of the hdparm utility. There are now several more chipsets added, to - include offboard PCI-IDE-UDMA cards and newer SiS and VIA chipsets. - It is safe to say Y to this question, as long as your PCI bus is - operating within specs (33MHz recommended). - -Boot off-board chipsets first support -CONFIG_BLK_DEV_OFFBOARD - Normally, IDE controllers built into the motherboard (on-board - controllers) are assigned to ide0 and ide1 while those on add-in - PCI cards (off-board controllers) are relegated to ide2 and ide3. - Saying Y to here will reverse the situation, with off-board - controllers on ide0/1 and on-board controllers on ide2/3. This - can improve the usability of some boot managers such as LILO - when booting from a drive on an off-board controller. - Note that this will rearrange the order of the hd* devices and - may require modification of fstab and other files. - Check the file Documentation/udma.txt - If in doubt, say N. + of the hdparm utility. It is safe to say Y to this question. System V IPC CONFIG_SYSVIPC @@ -1030,7 +964,6 @@ CONFIG_M386 the other hand, if you use a compiler before gcc 2.7 (say "gcc -v" to find out), then you have to say "386" or "486" here even if running on a Pentium or PPro machine. - If you don't know what to do, say "386". Compile the kernel into the ELF object format @@ -1274,65 +1207,6 @@ CONFIG_IP_MASQUERADE IP always defragment. If you want this, say Y. -IP: MS PPTP masq support (EXPERIMENTAL) -CONFIG_IP_MASQUERADE_PPTP - Support for masquerading of the GRE data channel portion of the PPTP - Virtual Private Network protocol. - If you are masquerading a PPTP client or server you need to enable - this in addition to regular IP Masquerade. - See http://www.wolfenet.com/~jhardin/ip_masq_pptp.html for more details. - -IP: MS PPTP Call ID masq support (EXPERIMENTAL) -CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT - Enabling this adds code to masquerade PPTP Call IDs, which allows - more than one masqueraded client to access the same server. - This only needs to be enabled if you are masquerading more than one - client, and if those clients will try to access the same PPTP server - at the same time. - You do NOT need to enable this if you are masquerading a PPTP - server, regardless of how many clients will be accessing it. - -IP: MS PPTP masq debugging -DEBUG_IP_MASQUERADE_PPTP - Enables PPTP Masquerade debugging messages. This should be disabled - for normal use once you have PPTP masq working, as it will cause - your system logs to quickly grow rather large. Enable verbose - debugging for more detailed information. - -IP: IPSEC ESP & ISAKMP masq support (EXPERIMENTAL) -CONFIG_IP_MASQUERADE_IPSEC - Support for limited masquerading of the IPSEC ESP network encryption - and ISAKMP key-exchange protocols. - If you are masquerading an IPSEC client you need to enable this in - addition to regular IP Masquerade. - Note that this may not successfully masquerade all types of - IPSEC-based encryption, as some options in the protocol offer a - cryptographic checksum across the IP addresses, which prevents the - masqueraded packets from being accepted. - -IP: IPSEC masq table lifetime (minutes) -CONFIG_IP_MASQUERADE_IPSEC_EXPIRE - After a period of inactivity IPSEC masq table entries expire and are - removed. When this happens inbound traffic can no longer be routed - to the masqueraded host until new outbound traffic creates a new - masq table entry. - For greatest reliability, your IPSEC rekey interval should be less - than the table entry lifetime. If your rekey interval is greater - than thirty minutes you will improve security by reducing it to - thirty minutes. If you don't want to do that, then increase the masq - table entry lifetime. Note that doing this will increase the clutter - in the IPSEC masq table, as old table entries will persist for this - many minutes after a rekey. - The minimum lifetime is 15 minutes. Decreasing the lifetime will - interfere with sessions that are idle for long periods of time. - -IP: IPSEC masq debugging -DEBUG_IP_MASQUERADE_IPSEC - Enables IPSEC Masquerade debugging messages. This should be disabled - for normal use once you have IPSEC masq working, as it will cause - your system logs to quickly grow rather large. Enable verbose - debugging for more detailed information. - IP: ipautofw masquerading (EXPERIMENTAL) CONFIG_IP_MASQUERADE_IPAUTOFW Richard Lynch's ipautofw allows masquerading to work with protocols @@ -1756,102 +1630,66 @@ CONFIG_SCSI_AHA1740 Adaptec AIC7xxx chipset SCSI controller support CONFIG_SCSI_AIC7XXX This is support for the various aic7xxx based Adaptec SCSI - controllers. These include the 274x EISA cards; 284x VLB cards; 2902, - 2910, 293x, 294x, 394x, 3985 and several other PCI and motherboard based - SCSI controllers from Adaptec. It does not support the AAA-13x RAID - controllers from Adaptec, nor will it likely ever support them. It - does not support the 2920 cards from Adaptec that use the Future Domain - SCSI controller chip. For those cards, you need the "Future Domain - 16xx SCSI support" driver. - - In general, if the controller is based on an Adaptec SCSI controller - chip from the aic777x series or the aic78xx series, it should work. The - only exception is the 7810 which is specifically not supported (that's the - RAID controller chip on the AAA-13x cards). - + controllers. These include the 274x EISA cards, 284x VLB cards, + 294x PCI cards, 394x PCI cards, 3985 PCI card, and several versions + of the Adaptec built-in SCSI controllers on various PC motherboards. Information on the configuration options for this controller can be - found by checking the help file for each of the available - configuration options. You should read drivers/scsi/README.aic7xxx - at a minimum before contacting the maintainer with any questions. - The SCSI-HOWTO, available via FTP (user: anonymous) at - ftp://metalab.unc.edu/pub/Linux/docs/HOWTO can also be of great help. - - If you want to compile this driver as a module ( = code which can be - inserted in and removed from the running kernel whenever you want), - say M here and read Documentation/modules.txt. The module will be - called aic7xxx.o. - -Enable or Disable Tagged Command Queueing by default -CONFIG_AIC7XXX_TCQ_ON_BY_DEFAULT - This option causes the aic7xxx driver to attempt to use tagged command - queueing on any devices that claim to support it. If this is set to yes, - you can still turn off TCQ on troublesome devices with the use of the - tag_info boot parameter. See /usr/src/linux/drivers/scsi/README.aic7xxx - for more information on that and other aic7xxx setup commands. If this - option is turned off, you may still enable TCQ on known good devices by - use of the tag_info boot parameter. - - If you are unsure about your devices then it is safest to say N here. - - However, TCQ can increase performance on some hard drives by as much - as 50% or more, so I would recommend that if you say N here, that you - at least read the README.aic7xxx file so you will know how to enable - this option manually should your drives prove to be safe in regards - to TCQ. - - Conversely, certain drives are known to lock up or cause bus resets when - TCQ is enabled on them. If you have a Western Digital Enterprise SCSI - drive for instance, then don't even bother to enable TCQ on it as the - drive will become unreliable, and it will actually reduce performance. - -Default number of TCQ commands per device -CONFIG_AIC7XXX_CMDS_PER_DEVICE - Specify the number of commands you would like to allocate per SCSI - device when Tagged Command Queueing (TCQ) is enabled on that device. - - Reasonable figures are in the range of 8 to 24 commands per device, - but depending on hardware could be increased or decreased from that - figure. If the number is too high for any particular device, the - driver will automatically compensate usually after only 10 minutes - of uptime. It will not hinder performance if some of your devices - eventually have their command depth reduced, but is a waste of memory - if all of your devices end up reducing this number down to a more - reasonable figure. - - NOTE: Certain very broken drives are known to lock up when given more - commands than they like to deal with. Quantum Fireball drives are the - most common in this category. For the Quantum Fireball drives I would - suggest no more than 8 commands per device. - - Default: 8 + found by checking the README.aic7xxx file, usually in + /usr/src/linux/drivers/scsi. + +Override driver defaults for commands per LUN +CONFIG_OVERRIDE_CMDS + Use this option to allow you to override the default maximum number + of commands that a single device on the aic7xxx controller is + allowed to have active at one time. This option only effects tagged + queueing capable devices. The driver uses a "failsafe" value of 8 + by default. This is much lower than many devices can handle, but + left in place for safety sake. + NOTE: This does not actually enabled tagged queueing on any + particular device. The driver has changed in this respect. Please + see the file README.aic7xxx in /usr/src/linux/drivers/scsi for more + information on how to get particular devices to use tagged command + queueing. + Default: N + +Maximum number of commands per LUN +CONFIG_AIC7XXX_CMDS_PER_LUN + Specify the maximum number of commands per lun you would like to + allocate per device. Reasonable figures are in the range of 14 to + 32 commands per device, but depending on hardware could be increased + or decreased from that figure. If the number is too high for any + particular device, the driver will automatically compensate usually + after only 10 minutes of uptime and will issue a message to alert + you to the fact that the number of commands for that device has been + reduced. It will not hinder performance if a portion of your + devices eventually have their commands per lun reduced, but is a + waste of memory if all of your devices end up reducing this number + down to a more reasonable figure. Default: 24 Collect statistics to report in /proc CONFIG_AIC7XXX_PROC_STATS This option tells the driver to keep track of how many commands have been sent to each particular device and report that information to - the user via the /proc/scsi/aic7xxx/n file, where n is the number of - the aic7xxx controller you want the information on. This adds a - small amount of overhead to each and every SCSI command the aic7xxx - driver handles, so if you aren't really interested in this - information, it is best to leave it disabled. This will only work if - you also say Y to "/proc filesystem support", below. - - If unsure, say N. + the user via the /proc/scsi/aic7xxx/x file, where x is the number + of the aic7xxx controller you want the information on. This adds + a small amount of overhead to each and every SCSI command the + aic7xxx driver handles, so if you aren't really interested in this + information, it is best to leave it disabled. Default: N Delay in seconds after SCSI bus reset CONFIG_AIC7XXX_RESET_DELAY This sets how long the driver will wait after resetting the SCSI bus before attempting to communicate with the devices on the SCSI bus - again. This delay will be used during the reset phase at bootup time - as well as after any reset that might occur during normal operation. - Reasonable numbers range anywhere from 5 to 15 seconds depending on - your devices. DAT tape drives are notorious for needing more time - after a bus reset to be ready for the next command, but most hard - drives and CD-ROM devices are ready in only a few seconds. This - option has a maximum upper limit of 20 seconds to avoid bad - interactions between the aic7xxx driver and the rest of the linux - kernel. The default value has been reduced to 5 seconds. If this - doesn't work with your hardware, try increasing this value. + again. This delay will be used during the reset phase at bootup + time as well as after any reset that might occur during normal + operation. Reasonable numbers range anywhere from 5 to 15 seconds + depending on your devices. DAT tape drives are notorious for needing + more time after a bus reset to be ready for the next command, but + most hard drives and CD-ROM devices are ready in only a few seconds. + This option has a maximum upper limit of 20 seconds to avoid bad + interactions between the aic7xxx driver and the rest of the Linux + kernel. The default value has been reduced. If this doesn't work + with your hardware, try increasing this value. Default: 5 BusLogic SCSI support CONFIG_SCSI_BUSLOGIC @@ -2003,50 +1841,43 @@ NCR53C8XX SCSI support CONFIG_SCSI_NCR53C8XX This is the BSD ncr driver adapted to Linux for the NCR53C8XX family of PCI-SCSI controllers. This driver supports parity checking, - tagged command queuing and fast synchronous data transfers up to 80 - MB/s with wide FAST-40 LVD devices and controllers. - The NCR53C860 and NCR53C875 support FAST-20 transfers. The NCR53C895 - supports FAST-40 transfers with Ultra2 LVD devices. - If you have a SYM53C896 PCI-SCSI controller, you may want to use the new - improved driver available at ftp://ftp.tux.org/pub/roudier/896/. + tagged command queuing, fast SCSI II transfer up to 10 MB/s with + narrow SCSI devices and 20 MB/s with wide SCSI devices. + Support of Ultra SCSI data transfers with NCR53C860 and NCR53C875 + controllers has been recently added to the driver. Please read drivers/scsi/README.ncr53c8xx for more information. - + Linux/i386 and Linux/Alpha are supported by this driver. + Synchronous data transfers frequency CONFIG_SCSI_NCR53C8XX_SYNC - The SCSI Parallel Interface-2 Standard defines 4 classes of transfer - rates: FAST-5, FAST-10, FAST-20 and FAST-40. The numbers are - respectively the maximum data transfer rates in mega-transfers per - second for each class. For example, a FAST-20 Wide 16 device is able - to transfer data at 20 million 16 bit packets per second for a total - rate of 40 MB/s. - You may specify 0 if you want to only use asynchronous data - transfers. This is the safest and slowest option. Otherwise, specify - a value between 5 and 40, depending on the capability of your SCSI - controller. The higher the number, the faster the data transfer. - Note that 40 should normally be ok since the driver decreases the - value automatically according to the controller's capabilities. - Your answer to this question is ignored for controllers with NVRAM, - since the driver will get this information from the user set-up. It - also can be overridden using a boot setup option, as follows - (example): 'ncr53c8xx=sync:12' will allow the driver to negotiate - for FAST-20 synchronous data transfer (20 mega-transfers per - second). - The normal answer therefore is not to go with the default but to - select the maximum value 40 allowing the driver to use the maximum - value supported by each controller. If this causes problems with - your SCSI devices, you should come back and decrease the value. - There is no safe option other than using good cabling, right - terminations and SCSI conformant devices. + SCSI-2 specifications allow SCSI devices to negotiate a synchronous + transfer period of 25 nano-seconds or more. + The transfer period value is 4 times the agreed transfer period. + So, data can be transferred at a 10 MHz frequency, allowing 10 + MB/second throughput with 8 bits SCSI-2 devices and 20 MB/second + with wide16 devices. This frequency can be used safely with + differential devices but may cause problems with singled-ended + devices. + Specify 0 if you want to only use asynchronous data transfers. + Otherwise, specify a value between 5 and 10. Commercial O/Ses + generally use 5 Mhz frequency for synchronous transfers. It is a + reasonable default value. + However, a flawless singled-ended SCSI bus supports 10 MHz data + transfers. Regardless the value chosen in the Linux configuration, + the synchronous period can be changed after boot-up through the + /proc/scsi file system. The generic command is: + echo "setsync #target period" >/proc/scsi/ncr53c8xx/0 + Use a 25 ns period for 10 Mhz synchronous data transfers. + If you don't know what to do now, go with the default. Use normal IO CONFIG_SCSI_NCR53C8XX_IOMAPPED - If you say Y here, the driver will use normal IO, as opposed to - memory mapped IO. Memory mapped IO has less latency than normal IO - and works for most Intel-based hardware. Under Linux/Alpha only - normal IO is currently supported by the driver and so, this option - has no effect on those systems. - The normal answer therefore is N; try Y only if you encounter SCSI - related problems. + This option allows you to force the driver to use normal IO. + Memory mapped IO has less latency than normal IO and works for most + Intel-based hardware. + Under Linux/Alpha only normal IO is currently supported by the + driver and so, this option has no effect. + The normal answer therefore is N. Not allow targets to disconnect CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT @@ -2054,61 +1885,70 @@ CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT device of yours to not support properly the target-disconnect feature. In that case, you would say Y here. In general however, to not allow targets to disconnect is not reasonable if there is more - than 1 device on a SCSI bus. The normal answer therefore is N. - -Default tagged command queue depth -CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS - "Tagged command queuing" is a feature of SCSI-2 which improves - performance: the host adapter can send several SCSI commands to a - device's queue even if previous commands haven't finished yet. Some - SCSI devices don't implement this properly; if you want to disable - this feature, enter 0 or 1 here (it doesn't matter which). - The default value is 8 and should be supported by most hard disks. - This value can be overridden from the boot command line using the - 'tags' option as follows (example): - 'ncr53c8xx=tags:4/t2t3q16/t0u2q10' will set default queue depth to - 4, set queue depth to 16 for target 2 and target 3 on controller 0 - and set queue depth to 10 for target 0 / lun 2 on controller 1. - The normal answer therefore is to go with the default 8 and to use - a boot command line option for devices that need to use a different - command queue depth. - There is no safe option other than using good SCSI devices. + than 1 device on a SCSI bus. The normal answer therefore is N. + +Enable tagged command queuing +CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE + This option allows you to enable tagged command queuing support at + Linux start-up. Some SCSI devices do not properly support this + feature. The suggested method is to say N here and to use the + "settags" control command after boot-up to enable this feature: + echo "settags 2 4" >/proc/scsi/ncr53c8xx/0 + asks the driver to use up to 4 concurrent tagged commands for target + 2 of controller 0. + See the file drivers/scsi/README.ncr53c8xx for more information. + WARNING! If you say Y here, then you have to say N to "not allow + targets to disconnect", above. + The safe answer therefore is N. + The normal answer therefore is Y. Maximum number of queued commands CONFIG_SCSI_NCR53C8XX_MAX_TAGS This option allows you to specify the maximum number of commands - that can be queued to any device, when tagged command queuing is - possible. The default value is 32. Minimum is 2, maximum is 64. - Modern hard disks are able to support 64 tags and even more, but - donnot seem to be faster when more than 32 tags are being used. - So, the normal answer here is to go with the default value 32 unless - you are using very large hard disks with large cache (>= 1 MB) that - are able to take advantage of more than 32 tagged commands. - There is no safe option and the default answer is recommended. + that can be queued to a device, when tagged command queuing is + possible. The default value is 4. Minimum is 2, maximum is 12. The + normal answer therefore is the default one. + +Detect and read serial NVRAM +CONFIG_SCSI_NCR53C8XX_NVRAM_DETECT + Enable support for reading the serial NVRAM data on Symbios and + some Symbios compatible cards, and Tekram DC390W/U/F cards. Useful + for systems with more than one Symbios compatible controller where + at least one has a serial NVRAM, or for a system with a mixture of + Symbios and Tekram cards. Enables setting the boot order of host + adaptors to something other than the default order or "reverse + probe" order. Also enables Symbios and Tekram cards to be + distinguished so CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT may be set in + a system with a mixture of Symbios and Tekram cards so the Symbios + cards can make use of the full range of Symbios features, + differential, led pin, without causing problems for the Tekram + card(s). + (added by Richard Waltham: dormouse@farsrobt.demon.co.uk) + Also enables setting host and targets SCSI features as defined in + the user setup for each host using a serial NVRAM (added by the + maintainer). + The default answer is N, the normal answer should be Y. + Read drivers/scsi/README.ncr53c8xx for more information. Assume boards are SYMBIOS compatible CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT This option allows you to enable some features depending on GPIO - wiring. These General Purpose Input/Output pins can be used for + wiring. These General Purpose Input/Output pins can be used for vendor specific features or implementation of the standard SYMBIOS - features. Genuine SYMBIOS controllers use GPIO0 in output for - controller LED and GPIO3 bit as a flag indicating - singled-ended/differential interface. The Tekram DC-390U/F boards - uses a different GPIO wiring. - Your answer to this question is ignored if all your controllers have - NVRAM, since the driver is able to detect the board type from the - NVRAM format. - If all the controllers in your system are genuine SYMBIOS boards or - use BIOS and drivers from SYMBIOS, you would want to say Y here, - otherwise N. N is the safe answer. - -Enable profiling statistics gathering -CONFIG_SCSI_NCR53C8XX_PROFILE - This option allows you to enable profiling information gathering. - These statistics are not very accurate due to the low frequency - of the kernel clock (100 Hz on i386) and have performance impact - on systems that use very fast devices. - The normal answer therefore is N. + features. Genuine SYMBIOS boards use GPIO0 in output for controller + LED and GPIO3 bit as a flag indicating singled-ended/differential + interface. + If all the boards of your system are genuine SYMBIOS boards or use + BIOS and drivers from SYMBIOS, you would want to enable this option. + The driver behaves correctly on my system with this option enabled. + (SDMS 4.0 + Promise SCSI ULTRA 875 rev 0x3 + ASUS SC200 810A rev + 0x12). This option must be set to N if your system has at least one + 53C8XX based SCSI board with a vendor-specific BIOS (example: Tekram + DC-390/U/W/F). If unsure, say N. + However, if all your non Symbios compatible boards have NVRAM, + setting option CONFIG_SCSI_NCR53C8XX_NVRAM_DETECT allows the driver + to distinguish Symbios compatible boards from other ones. So, + you can answer Y if all non Symbios compatible boards have NVRAM. Always IN2000 SCSI support CONFIG_SCSI_IN2000 @@ -2250,22 +2090,6 @@ CONFIG_SCSI_DC390T_NOGENSUPP some reason, you want to drive with the other AM53C974 driver. If unsure, say N. -Symbios Logic sym53c416 support -CONFIG_SCSI_SYM53C416 - This is support for the sym53c416 SCSI host adapter. This is the - SCSI adapter that comes with some hp scanners. This driver requires that - the sym53c416 is configured first using some sort of pnp configuration - program (e.g. isapnp). After doing so it should be loaded as a module - using insmod. The parameters of the configured card(s) should be passed - to the driver. The format is: - - insmod sym53c416 sym53c416=, [sym53c416_1=,] - - There is support for up to four adapters. If you want to compile this - driver as a module ( = code which can be inserted in and removed from - the running kernel whenever you want), say M here and read - Documentation/modules.txt. - AM53/79C974 PCI SCSI support CONFIG_SCSI_AM53C974 This is support for the AM53/79C974 SCSI host adapters. Please read @@ -2312,17 +2136,6 @@ CONFIG_SCSI_PPA_HAVE_PEDANTIC Winbond xxx837 National Semiconductor PC87306 (early revisions) -Initio INI-A100U2W SCSI support -CONFIG_SCSI_INIA100 - This is support for the Initio INI-A100U2W SCSI host adapter. - Please read the SCSI-HOWTO, available via FTP (user anonymous) at - ftp://metalab.unc.edu/pub/Linux/docs/HOWTO. - - If you want to compile this as a module ( = code which can be - inserted in and removed from the running kernel whenever you want), - say M here and read Documenation/modules.txt. The module will be - called a100u2w.o - Network device support? CONFIG_NETDEVICES You can say N here in case you don't intend to connect to any other @@ -4057,61 +3870,15 @@ CONFIG_SMB_WIN95 NCP filesystem support (to mount NetWare volumes) CONFIG_NCP_FS NCP (NetWare Core Protocol) is a protocol that runs over IPX and is - used by Novell NetWare clients to talk to file servers. It is to IPX - what NFS is to TCP/IP, if that helps. Saying Y here allows you to - mount NetWare file server volumes and to access them just like any - other Unix directory. For details, please read the file + used by Novel NetWare clients to talk to file servers. It is to IPX + what NFS is to TCP/IP, if that helps. Enabling this option allows + you to mount NetWare file server volumes and to access them just + like any other Unix directory. For details, please read the file Documentation/filesystems/ncpfs.txt in the kernel source and the - IPX-HOWTO on ftp://sunsite.unc.edu:/pub/Linux/docs/howto. - You do not have to say Y here if you want your Linux box to act as a - file *server* for Novell NetWare clients. - General information about how to connect Linux, Windows machines and - Macs is on the WWW at http://www.eats.com/linux_mac_win.html (to - browse the WWW, you need to have access to a machine on the Internet - that has a program like lynx or netscape). - If you want to compile this as a module ( = code which can be - inserted in and removed from the running kernel whenever you want), - say M here and read Documentation/modules.txt. The module will be - called ncpfs.o. Say N unless you are connected to a Novell network. - -Packet signatures -CONFIG_NCPFS_PACKET_SIGNING - NCP allows packets to be signed for stronger security. If you want - security, say Y. Normal users can leave it off. To be able to use - packet signing you must use ncpfs > 2.0.12. - -Proprietary file locking -CONFIG_NCPFS_IOCTL_LOCKING - Allows locking of records on remote volumes. Say N unless you have - special applications which are able to utilize this locking scheme. - -Clear remove/delete inhibit when needed -CONFIG_NCPFS_STRONG - Allows manipulation of files flagged as Delete or Rename Inhibit. To - use this feature you must mount volumes with the ncpmount parameter - "-s" (ncpfs-2.0.12 and newer). Say Y unless you are not mounting - volumes with -f 444. - -Use NFS namespace when available -CONFIG_NCPFS_NFS_NS - Allows you to utilize NFS namespace on NetWare servers. It brings - you case sensitive filenames. Say Y. You can disable it at - mount-time with the `-N nfs' parameter of ncpmount. - -Use OS2/LONG namespace when available -CONFIG_NCPFS_OS2_NS - Allows you to utilize OS2/LONG namespace on NetWare servers. - Filenames in this namespace are limited to 255 characters, they are - case insensitive, and case in names is preserved. Say Y. You can - disable it at mount time with the -N os2 parameter of ncpmount. - -Allow mounting of volume subdirectories -CONFIG_NCPFS_MOUNT_SUBDIR - Allows you to mount not only whole servers or whole volumes, but - also subdirectories from a volume. It can be used to reexport data - and so on. There is no reason to say N, so Y is recommended unless - you count every byte. - To utilize this feature you must use ncpfs-2.0.12 or newer. + IPX-HOWTO on sunsite.unc.edu:/pub/Linux/docs/howto. If you want to + compile this as a module ( = code which can be inserted in and + removed from the running kernel whenever you want), say M here and + read Documentation/modules.txt. Amiga FFS filesystem support (EXPERIMENTAL) CONFIG_AFFS_FS @@ -4957,16 +4724,6 @@ CONFIG_MTRR rules require. If you have a PPro or later SMP and one or more CPU's report a value of about 2-3 bogomips enable this. -Nemory configuration -CONFIG_MEM_STD - There are three memory configurations available. The standard - configuration allows use of just under 1GB of RAM with 3GB of - virtual space per process. The enterprise configuration allows - 2Gigabytes of physical memory but limits the per process address - space to 2Gigabytes. The custom option allows you to specify the - split subject to kernel constraints. If you don't know how it works - don't pick it. - # need an empty line after last entry, for sed script in Configure. # diff --git a/Documentation/ide.txt b/Documentation/ide.txt index 5d277b3784ad..b724f7ae560b 100644 --- a/Documentation/ide.txt +++ b/Documentation/ide.txt @@ -5,9 +5,6 @@ Supported by: Gadi Oxman -- tapes, disks, whatever Scott Snyder -- cdroms, ATAPI, audio -UDMA support was added for various chipsets, from kernel 2.0.35 on. Check -the udma.txt file in this directory for details. - +-----------------------------------------------------------------+ | The hdparm utility for controlling various IDE features is | | packaged separately. Look for it on popular linux FTP sites. | @@ -486,135 +483,3 @@ The new WD1.6GB models are also cheap screamers. For really high end systems, go for fast/wide 7200rpm SCSI. But it'll cost ya! mlord@pobox.com -================================================================================ - -DMA Bus Master transfer ------------------------ -The triton.c driver provides support for the DMA Bus Mastering functions of -the Intel PCI Triton I/II chipsets (i82371FB or i82371SB). - -Pretty much the same code will work for the OPTi "Viper" chipset. Look for -DMA support for this in linux kernel 2.1.xx, when it appears. - -DMA is currently supported only for hard disk drives (not cdroms). - -Support for cdroms will likely be added at a later date, after broader -experience has been obtained with hard disks. - -Up to four drives may be enabled for DMA, and the motherboard chipset will -(hopefully) arbitrate the PCI bus among them. Note that the i82371 chip -provides a single "line buffer" for the BM IDE function, so performance of -multiple (two) drives doing DMA simultaneously will suffer somewhat, as they -contest for that resource bottleneck. This is handled transparently inside -the i82371 chip. - -The SiS 5513 controller has two completely independent IDE controller units, -each with a 64-byte line buffer (same size as the Intel); there is no -bottleneck in simultaneous (U)DMA transfers for this resource. The 5513 is -built-in the SiS 5571, 5598 and 5591 chipsets. - -The VIA chipsets like the Intel have a single 64 byte line buffer, but it -can be split 1/2-1/2 or 1/4-3/4 between both channels. - -By default, DMA support is prepared for use, but is currently enabled only -for drives which support multi-word DMA mode2 (mword2), or which are -recognized as "good" (see table below). Drives with only mode0 or mode1 -(single or multi) DMA should also work with this chipset/driver (eg. -MC2112A) but are not enabled by default. Use "hdparm -i" to view modes -supported by a given drive. - -The hdparm-3.3 (patched) utility can be used to manually enable /disable DMA -support, but must be (re-)compiled against this kernel version or later. - -Michel Aubry has produced a patch against hdparm-3.3 to support UDMA. - -To enable DMA, use "hdparm -d1 /dev/hd?" on a per-drive basis after booting. -If problems arise, ide.c will disable DMA operation after a few retries. -This error recovery mechanism works and has been extremely well exercised. - -IDE drives, depending on their vintage, may support several different modes -of DMA operation. The boot-time modes are indicated with a "*" in the -"hdparm -I" listing, and can be changed with *knowledgeable* use of the -"hdparm -X" feature (X32 for DMA 0, X33 for DMA 1, X34 for DMA 2, X64 for -UDMA 0, X65 for UDMA 1 and X66 for UDMA 2). - -Testing was done with an ASUS P55TP4XE/100 system and the following drives: - - Quantum Fireball 1080A (1Gig w/83kB buffer), DMA mode2, PIO mode4. - - DMA mode2 works well (7.4MB/sec), despite the tiny on-drive buffer. - - This drive also does PIO mode4, at about the same speed as DMA mode2. - An awesome drive for the price! - - Fujitsu M1606TA (1Gig w/256kB buffer), DMA mode2, PIO mode4. - - DMA mode2 gives horrible performance (1.6MB/sec), despite the good - size of the on-drive buffer and a boasted 10ms average access time. - - PIO mode4 was better, but peaked at a mere 4.5MB/sec. - - Micropolis MC2112A (1Gig w/508kB buffer), drive pre-dates EIDE and ATA2. - - DMA works fine (2.2MB/sec), probably due to the large on-drive buffer. - - This older drive can also be tweaked for fastPIO (3.7MB/sec) by using - maximum clock settings (5,4) and setting all flags except prefetch. - - Western Digital AC31000H (1Gig w/128kB buffer), DMA mode1, PIO mode3. - - DMA does not work reliably. The drive appears to be somewhat tardy - in deasserting DMARQ at the end of a sector. This is evident in - the observation that WRITEs work most of the time, depending on - cache-buffer occupancy, but multi-sector reads seldom work. - -Testing was done with a Gigabyte GA-586 ATE system and the following drive: -(Uwe Bonnes - bon@elektron.ikp.physik.th-darmstadt.de) - - Western Digital AC31600H (1.6Gig w/128kB buffer), DMA mode2, PIO mode4. - - much better than its 1Gig cousin, this drive is reported to work - very well with DMA (7.3MB/sec). - -Other drives: - - Maxtor 7540AV (515Meg w/32kB buffer), DMA modes mword0/sword2, PIO mode3. - - a budget drive, with budget performance, around 3MB/sec. - - Western Digital AC2850F (814Meg w/64kB buffer), DMA mode1, PIO mode3. - - another "caviar" drive, similar to the AC31000, except that this one - worked with DMA in at least one system. Throughput is about 3.8MB/sec - for both DMA and PIO. - - Conner CFS850A (812Meg w/64kB buffer), DMA mode2, PIO mode4. - - like most Conner models, this drive proves that even a fast interface - cannot improve slow media. Both DMA and PIO peak around 3.5MB/sec. - - Maxtor 71260AT (1204Meg w/256kB buffer), DMA mword0/sword2, PIO mode3. - - works with DMA, on some systems (but not always on others, eg. Dell), - giving 3-4MB/sec performance, about the same as mode3. - - IBM DHEA 36480 (6197Meg w/476kB buffer), DMA mode2, PIO mode4, UDMA mode2 - - works with DMA and UDMA on systems that support it. This drive and its - larger 8.4GB cousin provide throughput of 9.8MB/sec under UDMA. - -If you have any drive models to add, email your results to: mlord@pobox.com -Keep an eye on /var/adm/messages for "DMA disabled" messages. - -Some people have reported trouble with Intel Zappa motherboards. -This can be fixed by upgrading the AMI BIOS to version 1.00.04.BS0, -available from ftp://ftp.intel.com/pub/bios/10004bs0.exe -(thanks to Glen Morrell for researching this). - -And, yes, Intel Zappa boards really *do* use the Triton IDE ports. - -Changes by Michel Aubry, Andre Hedrick and Andrew D. Balsa, June 1998: - a) Added support for non-Intel chipsets that support Bus Mastering DMA. - b) Added support for UDMA (33Mb/s) drives and controllers. Note that UDMA - support must be enabled in the BIOS, and that both the hard disk drive - _and_ the chipset must support UDMA. - On the IBM DHEA-36480 drive, transfer rates go from 7.76Mb/s to 9.76Mb/s, - a 25% improvement with zero cost (DMA mode2 to UDMA mode2). - -Extra UDMA PCI controller card support by Andre M. Hedrick, June 1998: - - PDC20246 Promise Ultra33 UDMA. - - AEC6210 Artop Electronics Corp. ACARD - sold under SIIG CN2449 UltraIDE Pro. - - HPT343 Triones Technologies (HighPoint Technologies) Inc. - future support -- nonbooting cards, need MNDA approval for - information release. - sold under Digital Research DRIDEUDMA. - -For more information on UDMA support, check /Documentation/udma.txt. diff --git a/Documentation/isdn/README b/Documentation/isdn/README index 0a13a0688311..0dd8fcbbc43b 100644 --- a/Documentation/isdn/README +++ b/Documentation/isdn/README @@ -335,9 +335,9 @@ README for the ISDN-subsystem "manual" is a dial mode created to prevent the unexpected dialouts. In this mode, the interface will never make any connections on its own. You must explicitly initiate a connection with "isdnctrl dial - sdn0". However, after an idle time of no traffic as configured for - the huptimeout value with isdnctrl, the connection _will_ be ended. - If you don't want any automatic hangup, set the huptimeout value to 0. + isdn0". You _must_ also hangup the line explicitly as well! There + is NO timeout in this mode. Use "isdnctrl hangup isdn0" to end the + connection. "manual" is the default. j) Setup the interface with ifconfig as usual, and set a route to it. diff --git a/Documentation/modules.txt b/Documentation/modules.txt index 3b57122e7adc..9fb147ecce7c 100644 --- a/Documentation/modules.txt +++ b/Documentation/modules.txt @@ -22,7 +22,7 @@ file linux/README. It generally goes like: make config make dep make clean - make zImage or make bzImage or make zlilo + make zImage or make zlilo In "make config", you select what you want to include in the "resident" kernel and what features you want to have available as loadable modules. diff --git a/Documentation/networking/net-modules.txt b/Documentation/networking/net-modules.txt index 13b2f735f4e8..372c22ceca8a 100644 --- a/Documentation/networking/net-modules.txt +++ b/Documentation/networking/net-modules.txt @@ -15,7 +15,7 @@ Wed 2-Aug-95 the less user needs to know, the better. (There are things that driver developer can use, others should not confuse themselves.) - In many cases it is highly preferred that insmoding is done + In many cases it is highly preferred that insmod:ing is done ONLY with defining an explicit address for the card, AND BY NOT USING AUTO-PROBING! diff --git a/Documentation/paride.txt b/Documentation/paride.txt index 9df34810d3f3..fe5018f81122 100644 --- a/Documentation/paride.txt +++ b/Documentation/paride.txt @@ -64,7 +64,6 @@ parallel port IDE subsystem, including: SyQuest EZ-135, EZ-230 & SparQ drives Avatar Shark Imation Superdisk LS-120 - Maxell Superdisk LS-120 FreeCom Power CD Hewlett-Packard 5GB and 8GB tape drives Hewlett-Packard 7100 and 7200 CD-RW drives @@ -99,7 +98,6 @@ support is available for almost all known adapter protocols: epia Shuttle EPIA (UK) fit2 FIT TD-2000 (US) fit3 FIT TD-3000 (US) - friq Freecom IQ cable (DE) frpw Freecom Power (DE) kbic KingByte KBIC-951A and KBIC-971A (TW) ktti KT Technology PHd adapter (SG) @@ -135,12 +133,10 @@ and high-level drivers that you would use: MicroSolutions 8000t tape pt bpck SyQuest EZ, SparQ pd epat Imation Superdisk pf epat - Maxell Superdisk pf friq Avatar Shark pd epat FreeCom CD-ROM pcd frpw Hewlett-Packard 5GB Tape pt epat - Hewlett-Packard 7200e (CD) pcd epat - Hewlett-Packard 7200e (CD-R) pg epat + Hewlett-Packard 7100/7200 pg epat 2.1 Configuring built-in drivers @@ -319,6 +315,7 @@ and LS-120 drives. Traditionally, media for these devices are not partitioned. Consequently, the pf driver does not support partitioned media. This may be changed in a future version of the driver. + 2.5 Using the pt driver The pt driver for parallel port ATAPI tape drives is a minimal driver. @@ -326,29 +323,27 @@ It does not yet support many of the standard tape ioctl operations. For best performance, a block size of 32KB should be used. You will probably want to set the parallel port delay to 0, if you can. + 2.6 Using the pg driver The pg driver can be used in conjunction with the cdrecord program -to create CD-ROMs. Please get cdrecord version 1.6.1 or later -from ftp://ftp.fokus.gmd.de/pub/unix/cdrecord/ . To record CD-R media -your parallel port should ideally be set to EPP mode, and the "port delay" -should be set to 0. With those settings it is possible to record at 2x -speed without any buffer underruns. If you cannot get the driver to work +to create CD-ROMs. Please get cdrecord version 1.6.1a3 or later +from ftp://ftp.fokus.gmd.de/pub/unix/cdrecord/ (you may have to look +in the alpha subdirectory). To record CD-R media your parallel port +should ideally be set to EPP mode, and the "port delay" should be +set to 0. With those settings it is possible to record at 2x speed +without any buffer underruns. If you cannot get the driver to work in EPP mode, try to use "bidirectional" or "PS/2" mode and 1x speeds only. 3. Troubleshooting -3.1 Use EPP mode if you can - The most common problems that people report with the PARIDE drivers concern the parallel port CMOS settings. At this time, none of the PARIDE protocol modules support ECP mode, or any ECP combination modes. If you are able to do so, please set your parallel port into EPP mode using your CMOS setup procedure. -3.2 Check the port delay - Some parallel ports cannot reliably transfer data at full speed. To offset the errors, the PARIDE protocol modules introduce a "port delay" between each access to the i/o ports. Each protocol sets @@ -362,25 +357,6 @@ to each of the high-level drivers. Please see the notes above, or read the comments at the beginning of the driver source files in linux/drivers/block/paride. -3.3 Some drives need a printer reset - -There appear to be a number of "noname" external drives on the market -that do not always power up correctly. We have noticed this with some -drives based on OnSpec and older Freecom adapters. In these rare cases, -the adapter can often be reinitialised by issuing a "printer reset" on -the parallel port. As the reset operation is potentially disruptive in -multiple device environments, the PARIDE drivers will not do it -automatically. You can however, force a printer reset by doing: - - insmod lp - rmmod lp - -If you have one of these marginal cases, you should probably build -your paride drivers as modules, and arrange to do the printer reset -before loading the PARIDE drivers. - -3.4 Use the verbose option and dmesg if you need help - While a lot of testing has gone into these drivers to make them work as smoothly as possible, problems will arise. If you do have problems, please check all the obvious things first: does the drive work in @@ -408,8 +384,6 @@ of two ways. Either send it directly to the author of the PARIDE suite, by e-mail to grant@torque.net, or join the linux-parport mailing list and post your report there. -3.5 For more information or help - You can join the linux-parport mailing list by sending a mail message to linux-parport-request@torque.net diff --git a/Documentation/udma.txt b/Documentation/udma.txt deleted file mode 100644 index 23a446b94cc6..000000000000 --- a/Documentation/udma.txt +++ /dev/null @@ -1,663 +0,0 @@ -UDMA information for kernels 2.0.35+ - -Version 0.4 - July 98 -by Andrew D. Balsa - -If you are in a hurry, skip to the "How does one use UDMA support?" section. - -If you need troubleshooting advice, check the "Unreliable drive + -motherboard + driver combination" section. - -Support for UDMA is based on previous work by Kim-Hoe Pang and Christian -Brunner, posted on the Linux Kernel mailing list around September 1997. -Additional code was provided by Michel Aubry (VIA support) and Andre Hedrick -(support for various PCI UDMA controller cards). The code base is Mark -Lord's triton.c driver. - -Check the Linux UDMA mini-HOWTO by Brion Vibber first! It is the only Linux -specific document available on the subject. - -Technical references: -a) The Intel 82371AB data sheet, available in PDF format. -b) The SiS 5598 and 5591 data sheets, available in Microsoft Word format. :( -c) The VIA 82C586, 82C586A and 82C586B data sheets, in PDF format. -d) Small Form Factor document SFF 8038I v1.0. This is the original document - that describes the DMA mode 2 protocol. Available in PDF format. -e) The ATA/ATAPI-4 Working Draft, revision 17. This is document - d1153r17.pdf (in PDF format), available from the main IDE technical - reference site, ftp://fission.dt.wdc.com/pub/standards. This draft - describes the Ultra DMA protocol and timings. - -A somewhat less technical, but still very informative document is the -Enhanced IDE/Fast-ATA/ATA-2 FAQ, by John Wehman and Peter den Haan. Check -the Web page at http://come.to/eide. - -************************************************************************** - -Files changed -------------- - -Here is the set of files from Linux kernels 2.0.32/2.0.34 modified to enable -UDMA transfers on motherboard chipsets that support it. For each file, there -is a small explanation of the changes. - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -The following changes do not affect performance or stability of the IDE -driver in any way. -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -/drivers/block/triton.c - - - removed some Intel specific timing stuff. This should not affect -driver operation or performance. This is the only file that is heavily -modified; the Promise and Artop code is by Andre Hedrick, the VIA code -by Michel Aubry. - -/drivers/block/ide.c - - - added UDMA drive reporting during driver initialization, at the end -of routine do_identify (single line mod). - - - added data for SiS 5513 and VIA VP-1 chipset in routine probe_for_hwifs -(single line mods). Each new UDMA capable chipset will have to be added to -this list (a single line is needed each time). Notice that you don't even -need the motherboard chipset's data sheets to find the needed information. -You just have to identify the IDE controller. You can do this by checking -/proc/pci, and then comparing the IDE controller signature with that -available from the Linux kernel. - -As it stands in this patched version, routine probe_for_hwifs supports the -following chipsets: Intel FX, HX, VX, TX, LX and SiS 5513 (which is -integrated in the SiS 5571, 5598 and 5591 chips). The VIA-VP1 -chipset is supported for DMA mode 2 transfers, but compatibility has not -been tested with this driver. The VIA MVP-3 is reported OK with UDMA. - -/drivers/block/ide.h - - - added flag using_udma in struct ide_drive_s (single line mod). - -Small changes to the tape and ide-floppy code, and additions to pci.h and -pci.c for the extra PCI UDMA controller devices. - - -Tested configurations ---------------------- - -UDMA support has been thoroughly tested on the following configurations: - -Intel TX motherboard, PCI bus at 33 and 37.5MHz. (ASUS TX-97E) - -SiS 5598 motherboards, PCI bus at 33 and 37.5MHz. (Chaintech P5-SDA; ASUS -SP-97V at 33MHz only) - -IBM DeskStar 6.4Gb and 8.4Gb drives. Samsung UDMA hard disk proved -unreliable under Linux _and_ Windows95 (so it was not a driver problem). -Other UDMA drives not tested. - -libc5 and gcc2.7.2. Also tested under libc6 (RedHat 5.0). - -6x86MX processor running at 166MHz or 187.5MHz. - -DANGER: EIDE drives do not accept a PCI bus at 41.5MHz (83MHz / 2). Trying -to run DMA Mode 2 or UDMA at these PCI bus clocks will result in crashes and -loss of data. If your FSB runs at > 75MHz you MUST set the PCI bus for -asynchronous 33MHz operation. YOU HAVE BEEN WARNED. - -Andre Hedrick Tests [IMPORTANT: those are SMP configurations] -------------------------------------------------------------- - -Test I ------- - -Tyan Tomcat III bios v4.01 SMP Dual P5 200 w/ Artop AEC6210 w/ DMA2 drives - -Intel MultiProcessor Specification v1.4 - Virtual Wire compatibility mode. -OEM ID: OEM00000 Product ID: PROD00000000 APIC at: 0xFEE00000 -Processor #0 Pentium(tm) APIC version 17 -Processor #1 Pentium(tm) APIC version 17 -I/O APIC #2 Version 17 at 0xFEC00000. -Processors: 2 - -Linux version 2.0.34 (root@Zosma) (gcc version 2.8.1) #1 Mon Jun 8 16:40:25 CDT -Booting processor 1 stack 00002000: Calibrating delay loop.. ok - 79.67 -BogoMIPSTotal of 2 processors activated (159.33 BogoMIPS). -Starting kswapd v 1.4.2.2 - -ide: DMA Bus Mastering IDE controller on PCI bus 0 function 57 -ide: ports are not enabled (BIOS) -ide: AEC6210 ROM enabled but no address -ide: UDMA Bus Mastering IDE controller on PCI bus 0 function 160 -ide: timings == 04010401 - ide0: BM-DMA at 0x6700-0x6707 - ide1: BM-DMA at 0x6708-0x670f -hda: Maxtor 72004 AP, 1916MB w/128kB Cache, CHS=973/64/63, DMA -hdb: Maxtor 71626 A, 1554MB w/64kB Cache, CHS=789/64/63, DMA -hdc: IOMEGA ZIP 100 ATAPI, ATAPI FLOPPY drive -hdd: HP COLORADO 5GB, ATAPI TAPE drive -ide-tape: Sorry, DRQ types other than Accelerated DRQ -ide-tape: are still not supported by the driver -ide-tape: the tape is not supported by this version of the driver -ide2: ports already in use, skipping probe -ide0 at 0x6300-0x6307,0x6402 on irq 11 -ide1 at 0x6500-0x6507,0x6602 on irq 11 (shared with ide0) -scsi0 : ncr53c8xx - revision 2.5f.1 - -Test II -------- - -SuperMicro P6DNF SMP Dual P6 233 w/ Artop AEC6210 and Promise Ultra33 - -Intel MultiProcessor Specification v1.4 - Virtual Wire compatibility mode. -OEM ID: INTEL Product ID: 440FX APIC at: 0xFEE00000 -Processor #0 Pentium(tm) Pro APIC version 17 -Processor #1 Pentium(tm) Pro APIC version 17 -I/O APIC #2 Version 17 at 0xFEC00000. -Processors: 2 - -Linux version 2.0.34 (root@Orion) (gcc version 2.8.1) #1 Wed Jun 17 01:13:15 CDT 1998 -Booting processor 1 stack 00002000: Calibrating delay loop.. ok - 232.65 BogoMIPS -Total of 2 processors activated (464.49 BogoMIPS). - -ide: Intel 82371 (single FIFO) DMA Bus Mastering IDE - Controller on PCI bus 0 function 57 -ide: ports are not enabled (BIOS) -ide: AEC6210 ROM enabled at 0xfebf8000 -ide: PCI UDMA Bus Mastering IDE - Controller on PCI bus 0 function 160 -ide: timings == 04010401 - ide0: BM-DMA at 0xef90-0xef97 - ide1: BM-DMA at 0xef98-0xef9f -hda: QUANTUM FIREBALL ST3.2A, 3079MB w/81kB Cache, CHS=782/128/63, UDMA -hdb: QUANTUM FIREBALL ST6.4A, 6149MB w/81kB Cache, CHS=784/255/63, UDMA -hdc: IOMEGA ZIP 100 ATAPI, ATAPI FLOPPY drive -hdd: CD-ROM CDU611, ATAPI CDROM drive -ide2: ports already in use, skipping probe -ide0 at 0xeff0-0xeff7,0xefe6 on irq 10 -ide1 at 0xefa8-0xefaf,0xefe2 on irq 10 (shared with ide0) - -Test III --------- - -Same kernel above but with Promise Ultra33 - -ide: Intel 82371 (single FIFO) DMA Bus Mastering IDE - Controller on PCI bus 0 function 57 -ide: ports are not enabled (BIOS) -ide: PDC20246 ROM enabled at 0xfebd0000 -ide: PCI UDMA Bus Mastering IDE - Controller on PCI bus 0 function 160 -ide: timings == 000003ee - ide0: BM-DMA at 0xef80-0xef87 - ide1: BM-DMA at 0xef88-0xef8f -hda: QUANTUM FIREBALL ST3.2A, 3079MB w/81kB Cache, CHS=782/128/63, UDMA -hdb: QUANTUM FIREBALL ST6.4A, 6149MB w/81kB Cache, CHS=784/255/63, UDMA -hdc: IOMEGA ZIP 100 ATAPI, ATAPI FLOPPY drive -hdd: CD-ROM CDU611, ATAPI CDROM drive -ide2: ports already in use, skipping probe -ide0 at 0xeff0-0xeff7,0xefe6 on irq 10 -ide1 at 0xefa8-0xefaf,0xebe6 on irq 10 (shared with ide0) - -All tests cases yield this problem, IOMEGA ZIP 100 ATAPI FW 23.D -I have a patch fix for 2.1.99->106 similar for FW 21.D drives. - -ide-floppy: hdc: I/O error, pc = 5a, key = 5, asc = 24, ascq = 0 -ide-floppy: Can't get drive capabilities - -Note that both AEC6210 and PDC20246 have onboard bios that auto-config. - - -What UDMA support does ----------------------- - - - It enables UDMA transfers on the Intel TX chipset. - - It enables DMA mode2 transfers on the SiS 5571 and VIA VP-1 - (82C586) chipsets. - - It enables DMA mode2 and UDMA mode2 transfers on the SiS 5598 and - SiS 5591 chipsets, and the VIA VP3 and MVP-3. - - With single line mods for each new chipset, it will support any DMA - mode2 and/or UDMA capable chipset compatible with document - SFF 8038I v1.0. - - Supports a variety of PCI UDMA controller cards. - - -Support for other chipsets --------------------------- - -It is relatively easy to add support for other chipsets. Some chipsets are -entirely integrated (e.g. the SiS 5598 chipset has various devices in a -single chip), others are divided into a Northbridge (CPU to PCI circuitry, -L2 cache control, etc) and Southbridge (PCI to IDE bus mastering interface, -USB, etc). We are dealing here with the Southbridge, specifically with the -IDE bus master PCI device. If the data sheet says the device is SFF 8038I -v1.0 compatible, then the registers have a more or less standard layout and -this driver should work with the below changes: - -1) Check that the chipset is correctly identified by /proc/pci. Search for -the line that identifies a bus-mastering IDE controller device. - -2) If the chipset is not correctly identified (new chipsets are not in -kernels up to 2.0.33), you will need to edit /include/linux/pci.h and -/drivers/pci/pci.c. This is actually quite easy, requiring a single line in -each of these files. - -3) Now add a single line to ide.c, in routine probe_for_hwifs. - -4) Test and report results; when troubleshooting, please check first that -you have the latest BIOS for your motherboard. - - -HOW does UDMA mode2 work? -------------------------- - -Well, actually, the excellent triton.c driver written by Mark Lord is a -generic DMA transfer hard disk driver. It does not depend on any chipset -feature or transfer mode (i.e. it will work with DMA mode 2, UDMA and other -future DMA modes with little or no changes). BTW in late 2.1.x kernels the -driver was renamed ide-dma.c, to indicate that it is independent of the -chipset used. - -(Note: triton is the "old" name for the Intel FX chipset, for which Mark -Lord wrote the driver initially.) - -The Intel chipset specific parts were slightly changed in the triton.c -driver. These are only used to gather information for driver testing, and -actually do not affect the operation or performance of the driver, so the -changes are (well, should be) relatively inocuous. - -The real work involved in setting up the chips for DMA transfers is done -mostly by the BIOS of each motherboard. Now of course one hopes that the -BIOS has been correctly programmed... - -For example, the ASUS SP-97V motherboard with its original BIOS (Rev. 1.03) -would malfunction with the modified Linux driver in both DMA mode 2 and UDMA -modes; it would work well using PIO mode 4, or under Windows 95 in all -modes. I downloaded the latest BIOS image (Rev. 1.06) from the ASUS Web site -and flashed the BIOS EPROM with the latest BIOS revision. It has been -working perfectly ever since (at 66 MHz bus speeds). - -What this tells us is that the BIOS sets up the DMA controller with specific -timing parameters (active pulse and recovery clock cycles). My initial BIOS -revision probably had bad timings. Since the Windows 95 driver sets up those -timings by itself (i.e. it does not depend on the BIOS to setup the hard -disk controller timing parameters), I initially had problems only with the -Linux driver, while Windows 95 worked well. - -So, let me state this again: this Linux (U)DMA driver depends on the BIOS for -correct (U)DMA controller setup. If you have problems, first check that you -have the latest BIOS revision for your specific motherboard. - -OTOH Michel Aubry's code for the VIA Apollo chipset has complete support for -setting up the timing parameters. Check the triton.c source code for -details. - -New BIOS revisions can be downloaded from your motherboard manufacturer's -Web site. Flashing a new BIOS image is a simple operation but one must -strictly follow the steps explained on the motherboard manual. - -Late Award BIOS revisions seem stable with respect to UDMA. Anything with a -date of 1998 should be fine. - - -Features missing from the present UDMA support code ---------------------------------------------------- - -It does not set UDMA transfer parameters (the driver assumes the BIOS has -correctly setup all timing parameters) in the various chipsets. This -requires access to a complete set of data sheets for the various chipsets, -and testing on a variety of configurations, so it's not exactly within the -reach of a humble Linux hacker. IMHO this is best left to the guys at Award -and AMI (the BIOS guys), and to the motherboard engineers. - -Basically, UDMA transfers depend on two timing parameters: - 1) The pulse width of the active strobe signal for data transfers -(usually described as the active pulse width). - 2) The delay between the negation of the DMA READY signal to the -assertion of STOP when the IDE controller wants to stop a read operation -(usually described as the recovery time). - -Both timing parameters can be set individually for each hard disk (up to two -hard disks per channel). - -Knowing which registers must hold this data and the appropriate values, one -could program the Linux triton.c driver to setup the IDE controller device, -without relying on BIOS settings. However, some chipsets allow setting other -timing parameters, and the required code would quickly increase to a -not-so-easy-to-manage size. Better keep it simple, IMHO. - -It seems Mark Lord has devised a neat way to do this in the ide-dma driver -included in late kernels 2.1.x: each chipset has an entry in a table, with -safe timing values. The chipset is also identified when the driver is -loaded. - - -How does one use UDMA support? ------------------------------- - -1) Backup your data or you will be sorry. Now do "hdparm -t -T -/dev/hda". Write a small note with the transfer rates you see. - -2) Reboot. Press [Del] to launch the CMOS SETUP routine, go to the -CHIPSET SPECIFIC or PERIPHERALS SETUP menus, and enable UDMA transfers -for your hard disk drives which are UDMA capable, or leave the fields in -the default "AUTO" value. Enable both IDE channels even if you have just -one IDE drive (default setting). - -3) Boot Linux, compile the kernel with the TRITON support enabled. Install -the new kernel (the lilo thingy). Reboot Linux. - -4) Watch for the drive parameters message when the kernel loads (or type -"dmesg | more" after login). After the Cyl, Heads, Sect parameters you -should see "DMA" or "UDMA" depending on your hard disk drive and chipset -capabilities. - -Here is what I get with UDMA enabled in the BIOS of my SiS 5598 based -configuration, with an IBM UDMA capable hard disk as hda: - -... -ide: DMA Bus Mastering IDE controller on PCI bus 0 function 9 - ide0: BM-DMA at 0x4000-0x4007 - ide1: BM-DMA at 0x4008-0x400f -hda: IBM-DHEA-36480, 6197MB w/476kB Cache, LBA, CHS=790/255/63, UDMA -... - -If I disable UDMA in the BIOS, I get: - -... -ide: DMA Bus Mastering IDE controller on PCI bus 0 function 9 - ide0: BM-DMA at 0x4000-0x4007 - ide1: BM-DMA at 0x4008-0x400f -hda: IBM-DHEA-36480, 6197MB w/476kB Cache, LBA, CHS=790/255/63, DMA -... - -5) Again, do "hdparm -t -T /dev/hda". Smile. Test your setup by copying -a few large files around or doing some large compilation (e.g. the Linux -kernel itself). - - -Performance issues ------------------- - -1) Sustained transfer rates. - -Here is some data gathered after extensive testing, using the hdparm utility -(also written by Mark Lord): - -PIO mode 4 transfer rates under Linux: +/- 5.2MB/s - -DMA mode 2 transfer rates under Linux: +/- 7.2MB/s - -UDMA mode 2 transfer rates under Linux: +/- 9.8MB/s - -Data gathered on a Chaintech SiS 5598 motherboard, 6x86MX @ 187.5MHz, Linux -2.0.32/2.0.33 with patched triton.c driver as explained above, IBM DeskStar -6.4GB hard disk (IBM-DHEA-36480). - -The integrated video hardware in the SiS 5598 chip was disabled (a standard -PCI video board was used); enabling the integrated SVGA controller will -cause a 20% performance hit in processing performance, due to limited main -memory bandwidth. - -The TX motherboard under the same test conditions will be slightly -slower (0.1 - 0.2 MB/s slower). - -Burst (instantaneous) transfer rates are supposed to go from 16.6MB/s (PIO -mode 4) to 16.6MB/s (DMA mode 2) up to 33MB/s (UDMA). In his patch against -kernel 2.1.55, Kim-Hoe Pang actually checked the UDMA burst transfer rate -with a logic analiser: 60ns/word, which translates into 33MB/s. - -Note that burst transfer rates only affect data transfers to/from the EIDE -drive cache (476kB for the IBM 6.4GB drive), and IMHO are not particularly -relevant for most Linux users. - -The Linux kernel uses as much RAM as possible to cache hard disk data -accesses, and so if data is not in the kernel cache there is little chance -that it will be in the (much smaller) hard disk cache. - -2) Processor utilization - -Unfortunately, it is very difficult to gather data about processor -utilization during data transfers, but this is exactly the biggest advantage -of DMA transfers over PIO transfers. My estimate is that CPU utilization -during UDMA transfers will be as low as 3-4%, while being somewhere around -30% for PIO transfers and 6-8% for DMA mode 2. - -3) UDMA vs SCSI - -The main advantage of DMA mode 2 and UDMA over SCSI is that the controller -is already on your motherboard, so why not use it? - -Mark Lord's triton.c driver has a very small latency and so UDMA drives -may beat their Ultra-Wide SCSI-2 counterparts in some cases (at equal -spindle speeds) e.g. lots of small files (loaded news servers) being -read/written at irregular intervals. - -Note however that SCSI drives are available at spindle speeds of 7,200, -10,000 and even a recently announced 12,030 rpm. IBM is planning some 7,200 -rpm UDMA EIDE drives, but those are not yet available. Seagate has just -released its EIDE 7,200 rpm drives, but they have special cooling -requirements just like their SCSI counterparts. Expect this technology to -become commonplace by the end of 98, though. - -The UDMA burst data transfer rates exceed maximum head transfer rates -(maximum head transfer rates in the industry have reached 160 Mbits/s in -1998) and so for large files neither Ultra-Wide SCSI-2 nor UDMA will have an -advantage over the other technology. - -It used to be that high-capacity drives were only available with SCSI -interfaces, but this isn't true anymore. Right now top capacity for an EIDE -drive is Maxtor's 11.3Gb monster, which is quite affordable in fact. One can -drive four of these with a standard motherboard: 45Gb for < $2k. - -SCSI drives can chain, overlap and re-order commands, EIDE drives cannot. -However, Linux already has an intelligent "elevator" algorithm for hard disk -accesses. - -At present, EIDE top speed is 33MB/s burst. Ultra-Wide II SCSI is 80MB/s -burst. The cost of an Ultra-Wide II SCSI controller + 9Gb hard disk is > 4 x -the cost of an 8GB UDMA drive. IMHO the price/performance ratio of UDMA -beats SCSI. - -A new standard is emerging called ATA-66, which will double the burst -transfer speed of EIDE drives to 66Mb/s. I don't have any technical info -about it, unfortunately. The first ATA-66 drives will be shipped by Quantum -in 1999, but VIA has already announced two ATA-66 capable chipsets (in fact -based on the same Southbridge chip); as I write this, data sheets are not -available to the general public. Probably Intel will come out with a chipset -of its own with ATA-66 capabilities. - -4) What is the best UDMA chipset/hard disk? - -Intel designed the first DMA mode 2 capable chipset, the FX (Triton I) a few -years ago. The Linux DMA mode 2 driver was initially written by Mark Lord -for the original Intel FX chipset and appeared around kernel 1.3.20 if I -remember well. The later HX and VX chipsets had exactly the same DMA mode 2 -capabilities and the triton.c driver was for a long time Intel-only. Mark -planned to support the Opti Viper chipset but Opti went out of the -motherboard chipset business so fast that Mark didn't even have the time to -get his hands on an Opti motherboard, I guess. - -Intel later introduced a UDMA compatible motherboard chipset with its TX -chipset. Kernel 2.0.31 was the first Linux kernel to support the TX chipset, -however only DMA mode 2 (16.6MB/s) was supported. - -The TX chipset has a proven record of reliability. But DMA mode 2 and UDMA -transfers on the TX suffer from a flaw common to previous Intel DMA mode 2 -only chipsets: a single data buffer is shared between the two IDE channels. -This buffer (64 bytes deep) is used to hold data on its way from the PCI bus -to/from the hard disk's small cache. A hardware arbitration mechanism -prevents data loss when the OS tries to simultaneously use both IDE -channels. - -VIA chips also have a single FIFO, with the same 64 bytes deep buffer. -However, VIA chips can have the buffer split 1:1 or 3:1 between both IDE -channels; an interesting feature, but difficult to use. - -How is this FIFO buffer used? Remember that the PCI bus can transfer data at -a maximum rate of 132MB/s when clocked at 33MHz, 150MB/s when clocked at -37.5MHz (maximum safe clock speed for PCI is 33MHz, after that well..). So the -PCI bus mastering IDE controller will be transfering data from main memory -DRAM to this FIFO buffer in small bursts of < 64 bytes, then from the buffer -to the IDE disk drive cache (when writing; the other way around for reads). - -I recently managed to get hold of the SiS 5598 data sheet and studied the -IDE controller part of this highly integrated chip, a device identified by -the number 5513. The 5598 even includes an SVGA controller, which should be -disabled if one wants to get decent performance from this chipset: it -severely limits CPU/memory bandwidth. The SiS5597 is the same part with -a different pinout. - -It appears the 5513 has two completely independent IDE channels, each with -its own 64 bytes deep data buffer. On disk-to-disk or CD-to-disk transfers, -the 5598 and 5591 chipsets will easily beat the Intel TX and VIA. On -simultaneous (U)DMA transfers to two disks (for example, when the Linux md -driver is used to create a RAID-0 array with data striping), the 5513 device -will be faster than the TX Southbridge device since there will be no -contention for the data buffer, assuming each drive is connected to a -different IDE channel. Other PCI bus related features will also improve its -performance of the SiS devices. So, compared to the Intel TX and various VIA -chipsets, the 5598 and 5591 win hands down in terms of UDMA implementation. - -Unfortunately, it is very difficult to get data sheets for the ALi Aladdin -IV+ and Aladdin V chipsets. These newer chipsets support up to 1 MB of L2 -SRAM cache, the AGP bus (2X), 100 MHz CPU bus and of course, UDMA data -transfers. The newest VIA chipset for Socket 7 motherboards beats them all -in terms of features, as it sports ATA-66 compatibility. - -On the UDMA hard drive front, the present performance leaders are the IBM -Deskstar drives. These drives have relatively large data caches (476kB -available), a 5,400 rpm rotational speed and < 10ms random access times. -They run very cool and although they can't be called silent, their noise -level is acceptable. They are also reliable. - -Seagate has just begun shipping 7,200 rpm EIDE drives which will obviously -benefit from the lower data latency. They are reported as particularly -silent due to the use of Fluid Dynamic Bearing motors, but running quite -hot. IMHO if one has to add a fan to cool them, this defeats any advantage -these drives will have in terms of noise level. Another advantage of this -technology is the lower vibration levels compared to ball bearings. - -IBM has pre-announced very large capacity (14GB), 7,200 rpm EIDE UDMA drives -a month ago, but those are not shipping yet. They are based on a new head -technology called Giant Magneto-Resistive Heads, which is supposed to -increase the data density on the disks by a factor of 4 or more. More details -when I get my hands on one. IBM licensed Western Digital to use this -technology. - -Quantum has always shipped among the best and fastest EIDE drives, and they -worked with Intel to create the UDMA standard. They used to have the fastest -drives for Linux DMA mode 2 transfers (see the comments in -/Documentation/ide.txt). - -Well, I just got an email from Denny de Jonge that proves -Quantum drives will keep their reputation: - -"Andre, - - After I applied the UDMA-patch for Linux 2.0.33 hdparm showed up with the - following benchmarks: - - /dev/hda: - - Timing buffer-cache reads: 64 MB in 1.02 seconds =62.75 MB/sec - Timing buffered disk reads: 32 MB in 3.02 seconds =10.60 MB/sec - - Not bad, don't you think ? - - These results have been obtained using the Intel 82371 Chipset and a - Quantum Fireball 4.3SE harddisk." - -I later asked what kind of processor Denny was using: it's a 266MHz PII. - -BTW I have been collecting hard disk/file subsystem benchmarking information -based on bonnie, a popular benchmark available for Linux. I have come to the -conclusion that bonnie is not a reliable benchmark when it comes to -comparing different systems, basically because it depends so much on how -much RAM one has installed and how much of it is free, as well as system -load, CPU speed, etc. For this reason I will not quote bonnie results -anymore. For comparative benchmarking between two hard disk drives on -exactly the same hardware it may be acceptable, but otherwise it's too -unreliable as an indicator of performance. - - -Unreliable drive + motherboard + driver combination ---------------------------------------------------- - -Quoting Kim-Hoe Pang: - -"The UDMA mode of an UDMA drive would NOT be enabled on a non-UDMA capable -chipset mobo. On power-up or after a hardware reset, the drive is in normal -PIO/DMA mode. To enable the UDMA mode in the drive, the host, BIOS or OS, -needs to send a SET FEATURE ("enable UDMA mode subcommand") AT command to -the drive. A non-UDMA capable mobo will not send this command to the drive. - -UDMA mode is dis/enabled via BIOS setup. The patch does not attempt to -override user's BIOS setting." - -There may be some combinations of drives, motherboards (BIOS) and Linux -driver which may prove unreliable. Remember we are transfering data at -33MB/s over unshielded ribbon cable in a very noisy (electromagnetically -speaking) environment. - -In the future it would be nice if hard disk manufacturers would publish the -timings required by their drives, and chipset manufacturers would follow a -single standard for registers and controller architecture. Right now UDMA is -extremely timing sensitive. - -A few recommendations for troubleshooting: - -1) Make sure you have the latest BIOS for your motherboard. Connect to the -motherboard manufacturer's Web site and download the latest BIOS image file -and EEPROM flashing utilities. Check your BIOS version, and only flash your -EEPROM if needed. - -2) Keep the IDE cable going from the motherboard to the drive short, and do -not loop it around another cable. I recommend < 30 cm (12") total cable -length. - -3) If you have just a single UDMA hard disk drive per channel (which I -recommend), use the connectors at both ends of the cable to connect -motherboard and drive, do _not_ use the middle connector. If you have a UDMA -hard disk drive and a CD-ROM drive on the same cable, plug the hard disk -drive at the end of the cable (use the middle connector for the CD-ROM -drive). Also the hard disk must be the master EIDE device, the CD-ROM drive -the slave EIDE device, never the other way around (this is not determined by -cable position, but by small jumpers on the drive and at the back of the -CD-ROM). The same rules apply to CD-RW, ZIP and tape EIDE drives. - -4) If you have (shudder) Windows 95 installed in your system, and have been -able to use UDMA, you should be able to use UDMA with Linux. - -5) DON'T OVERCLOCK the PCI bus. 33MHz is the maximum supported speed for -the PCI bus. Some (supposedly compatible) UDMA drives will not even take -37.5MHz, but should be OK at 33.3MHz. - -In any case, NEVER, NEVER set the PCI bus to 41.5MHz. - -The RECOMMENDED safe setting is 33MHz. - -Adequate testing is needed in each case. The golden rule here, as always: -backup, backup, backup. - - -Aknowledgments --------------- - -Mark Lord for his excellent, reliable and very readable triton.c driver code -and all his (E)IDE Linux programming. - -Kim-Hoe Pang for the first UDMA patch against kernel 2.1.55. - -Christian Brunner for his patch converting triton.c into a generic DMA mode -2 EIDE driver. - -Brion Vibber for his neat Linux UDMA mini-HOWTO, for his help and -contributions to this package, and for bearing with my various documentation -changes and suggestions. - -Michel Aubry for his complete VIA support and neat diagnostics code, as well -as the patch to hdparm to support UDMA. - -Andre Hedrick for his great code for the various PCI UDMA controller cards. - diff --git a/MAINTAINERS b/MAINTAINERS index 46e139694df6..0459c41fb849 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -123,8 +123,8 @@ L: linux-net@vger.rutgers.edu S: Maintained APM DRIVER -P: Stephen Rothwell -M: Stephen.Rothwell@canb.auug.org.au +P: Rik Faith & Stephen Rothwell +M: faith@cs.unc.edu, Stephen.Rothwell@canb.auug.org.au L: linux-laptop@vger.rutgers.edu S: Maintained @@ -172,8 +172,8 @@ S: Supported DC390/AM53C974 SCSI driver P: Kurt Garloff -M: kurt@garloff.de -W: http://www.garloff.de/kurt/linux/dc390/ +M: K.Garloff@ping.de +W: ftp://student.physik.uni-dortmund.de/pub/linux/kernel/dc390/ S: Maintained DAC960 RAID DRIVER @@ -291,9 +291,9 @@ S: Maintained NCP FILESYSTEM: P: Volker Lendecke -M: vl@kki.org +M: lendecke@namu01.Num.Math.Uni-Goettingen.de L: linware@sh.cvut.cz -S: Odd Fixes +S: Maintained NETROM NETWORK LAYER P: Jon Naylor @@ -327,7 +327,7 @@ S: Maintained SMB FILESYSTEM: P: Volker Lendecke -M: vl@kki.org +M: lendecke@namu01.Num.Math.Uni-Goettingen.de L: samba@listproc.anu.edu.au S: Odd Fixes diff --git a/Makefile b/Makefile index 9d0963147027..f88e7d9bc4cf 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ VERSION = 2 PATCHLEVEL = 0 -SUBLEVEL = 37 +SUBLEVEL = 36 -ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/) +ARCH = i386 # # For SMP kernels, set this. We don't want to have this in the config file @@ -360,14 +360,6 @@ dep-files: scripts/mkdep archdep include/linux/version.h set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i fastdep; done mv .tmpdepend .depend -# Prepare source tree for RCS version control using Emacs VC; -# make all needed RCS directories and write-lock nearly everything. -vc: - chmod a-w COPYING CREDITS MAINTAINERS Makefile README Rules.make - find . -type d ! -name "*RCS" -exec mkdir {}/RCS \; - find . -type f \( -name *.[chS] -o -name "*Makefile" -o -name "*README*" -o -name "*Config.in" -o -name "*.txt" \) -exec chmod a-w {} \; - find Documentation scripts -type f -exec chmod a-w {} \; - MODVERFILE := ifdef CONFIG_MODVERSIONS diff --git a/README b/README index 32f0851daef5..1414fd7229ad 100644 --- a/README +++ b/README @@ -47,12 +47,7 @@ INSTALLING the kernel: gzip -cd linux-2.0.XX.tar.gz | tar xfv - to get it all put in place. Replace "XX" with the version number of the - latest kernel. If you use GNU tar, - - cd /usr/src - tar -xzvf linux-2.1.XX.tar.gz - - is equivalent. + latest kernel. - You can also upgrade between 2.0.xx releases by patching. Each patch that is released for 2.0.xx contains only bugfixes. No @@ -81,6 +76,15 @@ INSTALLING the kernel: the current directory, but an alternative directory can be specified as the second argument. + - make sure your /usr/include/asm, /usr/include/linux, and /usr/include/scsi + directories are just symlinks to the kernel sources: + + cd /usr/include + rm -rf asm linux scsi + ln -s /usr/src/linux/include/asm-i386 asm + ln -s /usr/src/linux/include/linux linux + ln -s /usr/src/linux/include/scsi scsi + - make sure you have no stale .o files and dependencies lying around: cd /usr/src/linux diff --git a/arch/alpha/Makefile b/arch/alpha/Makefile index f30bd0b652d6..2467ba8ebb90 100644 --- a/arch/alpha/Makefile +++ b/arch/alpha/Makefile @@ -27,9 +27,9 @@ endif CFLAGS := $(CFLAGS) -mno-fp-regs # determine if we can use the BWX instructions with GAS -dummy:=$(shell rm -f /tmp/GAS_VER) +$(shell rm -f /tmp/GAS_VER) #$(shell $(AS) --version >& /tmp/GAS_VER) -dummy:=$(shell $(AS) --version > /tmp/GAS_VER 2>&1) +$(shell $(AS) --version > /tmp/GAS_VER 2>&1) OLD_GAS := $(shell if cat /tmp/GAS_VER | grep 'version 2.7' > /dev/null; then echo yes; else echo no; fi) ifneq ($(OLD_GAS),yes) diff --git a/arch/alpha/defconfig b/arch/alpha/defconfig index 99bb631ef86e..4f758e5b64fd 100644 --- a/arch/alpha/defconfig +++ b/arch/alpha/defconfig @@ -159,7 +159,7 @@ CONFIG_NET_ETHERNET=y # CONFIG_LANCE is not set # CONFIG_NET_VENDOR_SMC is not set # CONFIG_NET_ISA is not set -CONFIG_NET_PCI=y +CONFIG_NET_EISA=y # CONFIG_APRICOT is not set CONFIG_DE4X5=y # CONFIG_DEC_ELCP is not set @@ -220,6 +220,7 @@ CONFIG_PSMOUSE=y # CONFIG_UMISC is not set # CONFIG_QIC02_TAPE is not set # CONFIG_FTAPE is not set +# CONFIG_APM is not set # CONFIG_WATCHDOG is not set # CONFIG_RTC is not set diff --git a/arch/i386/boot/setup.S b/arch/i386/boot/setup.S index b845adf36d67..8672440d962f 100644 --- a/arch/i386/boot/setup.S +++ b/arch/i386/boot/setup.S @@ -18,7 +18,7 @@ ! March 1993/June 1994 (Christoph.Niemann@linux.org) ! ! add APM BIOS checking by Stephen Rothwell, May 1994 -! (Stephen.Rothwell@canb.auug.org.au) +! (Stephen.Rothwell@pd.necisa.oz.au) ! ! High load stuff, initrd support and position independency ! by Hans Lermen & Werner Almesberger, February 1996 @@ -331,7 +331,7 @@ no_psmouse: #ifdef CONFIG_APM ! check for APM BIOS - ! NOTE: DS is pointing to the boot sector + ! NOTE: DS is pointing to the bootsector ! mov [64],#0 ! version == 0 means no APM BIOS diff --git a/arch/i386/config.in b/arch/i386/config.in index 8ccfa0f41983..8fc6ce50679c 100644 --- a/arch/i386/config.in +++ b/arch/i386/config.in @@ -22,20 +22,7 @@ mainmenu_option next_comment comment 'General setup' bool 'Kernel math emulation' CONFIG_MATH_EMULATION -choice 'Memory configuration' \ - "Standard CONFIG_MEM_STD \ - Enterprise CONFIG_MEM_ENT \ - Custom CONFIG_MEM_SPECIAL" Standard - -if [ "$CONFIG_MEM_SPECIAL" = "y" ]; then - int ' Max physical memory in MB' CONFIG_MAX_MEMSIZE 1024 -fi -if [ "$CONFIG_MEM_ENT" = "y" ]; then - define_int CONFIG_MAX_MEMSIZE 2048 -fi -if [ "$CONFIG_MEM_STD" = "y" ]; then - define_int CONFIG_MAX_MEMSIZE 1024 -fi +int ' Max physical memory in MB' CONFIG_MAX_MEMSIZE 1024 bool 'Networking support' CONFIG_NET bool 'Limit memory to low 16MB' CONFIG_MAX_16M bool 'PCI bios support' CONFIG_PCI @@ -63,16 +50,6 @@ if [ "$CONFIG_M686" = "y" -o "$CONFIG_M586" = "y" ]; then bool 'Handle buggy SMP BIOSes with bad MTRR setup' CONFIG_MTRR fi -bool 'Advanced Power Management BIOS support' CONFIG_APM -if [ "$CONFIG_APM" = "y" ]; then - bool ' Ignore USER SUSPEND' CONFIG_APM_IGNORE_USER_SUSPEND - bool ' Enable PM at boot time' CONFIG_APM_DO_ENABLE - bool ' Make CPU Idle calls when idle' CONFIG_APM_CPU_IDLE - bool ' Enable console blanking using APM' CONFIG_APM_DISPLAY_BLANK - bool ' Power off on shutdown' CONFIG_APM_POWER_OFF - bool ' Ignore multiple suspend' CONFIG_APM_IGNORE_MULTIPLE_SUSPEND -fi - endmenu source drivers/block/Config.in diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile index ba82b17fa1fd..af0ea9187e8a 100644 --- a/arch/i386/kernel/Makefile +++ b/arch/i386/kernel/Makefile @@ -23,11 +23,6 @@ all: kernel.o head.o O_TARGET := kernel.o O_OBJS := process.o signal.o entry.o traps.o irq.o vm86.o bios32.o \ ptrace.o ioport.o ldt.o setup.o time.o sys_i386.o ksyms.o -OX_OBJS := - -ifdef CONFIG_APM -OX_OBJS += apm.o -endif ifdef SMP diff --git a/arch/i386/kernel/bios32.c b/arch/i386/kernel/bios32.c index a5adda85435e..d4dbe3bcf45f 100644 --- a/arch/i386/kernel/bios32.c +++ b/arch/i386/kernel/bios32.c @@ -730,7 +730,7 @@ static struct pci_access *check_direct_pci(void) outb (0x00, 0xCFB); outb (0x00, 0xCF8); outb (0x00, 0xCFA); - if (inb (0xCF8) == 0x00 && inb (0xCFA) == 0x00) { + if (inb (0xCF8) == 0x00 && inb (0xCFB) == 0x00) { restore_flags(flags); printk("pcibios_init: Using configuration type 2\n"); return &pci_direct_conf2; diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S index 6cd3e73062b3..106e63bb7cd0 100644 --- a/arch/i386/kernel/head.S +++ b/arch/i386/kernel/head.S @@ -484,7 +484,7 @@ gdt_descr: #define upper_seg(type,dpl,base,limit) \ ((base) & 0xff000000) | \ (((base) & 0x00ff0000)>>16) | \ - (((limit)>>12) & 0xf0000) | \ + ((limit) & 0xf0000) | \ ((dpl)<<13) | \ (0x00c09000) | \ ((type)<<8) diff --git a/arch/i386/kernel/hexify.c b/arch/i386/kernel/hexify.c index 29d6338fe7eb..daa331fec26b 100644 --- a/arch/i386/kernel/hexify.c +++ b/arch/i386/kernel/hexify.c @@ -1,7 +1,7 @@ #include -int main() +void main() { int c; int comma=0; @@ -25,5 +25,7 @@ int main() } if(count) printf("\n"); - return 0; + exit(0); } + + diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c index bc3bbc4006d5..2c4dd0da5fae 100644 --- a/arch/i386/kernel/setup.c +++ b/arch/i386/kernel/setup.c @@ -98,7 +98,9 @@ extern char empty_zero_page[PAGE_SIZE]; #ifndef STANDARD_MEMORY_BIOS_CALL #define ALT_MEM_K (*(unsigned long *) (PARAM+0x1e0)) #endif -#define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+0x40)) +#ifdef CONFIG_APM +#define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+64)) +#endif #define DRIVE_INFO (*(struct drive_info_struct *) (PARAM+0x80)) #define SCREEN_INFO (*(struct screen_info *) (PARAM+0)) #define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2)) @@ -461,7 +463,7 @@ int get_cpuinfo(char * buffer) static const char *x86_ext_cap_flags[] = { "fpu","vme", "de", "pse", "tsc", "msr", "6", "mce", "cx8", "9", "10", "syscr", "12", "pge", "14", "cmov", - "fpcmov", "17", "psn", "19", "20", "21", "22", "mmx", + "fpcmov", "17", "18", "19", "20", "21", "22", "mmx", "emmx", "25", "26", "27", "28", "29", "30", "3dnow" }; diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c index fe9e053bc870..da411cebc229 100644 --- a/arch/i386/kernel/time.c +++ b/arch/i386/kernel/time.c @@ -424,7 +424,6 @@ static inline unsigned long mktime(unsigned int year, unsigned int mon, )*60 + sec; /* finally seconds */ } -/* not static: needed by APM */ unsigned long get_cmos_time(void) { unsigned int year, mon, day, hour, min, sec; diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c index d7c7a8c0cc80..bd3e854901b8 100644 --- a/arch/i386/mm/init.c +++ b/arch/i386/mm/init.c @@ -139,22 +139,18 @@ unsigned long paging_init(unsigned long start_mem, unsigned long end_mem) * the error... */ if (!smp_scan_config(639*0x400,0x400)) /* Scan the top 1K of base RAM */ - { - if(!smp_scan_config(0xF0000,0x10000)) /* Scan the 64K of bios */ - { - /* - * If it is an SMP machine we should know now, unless the - * configuration is in an EISA/MCA bus machine with an - * extended bios data area. - * - * there is a real-mode segmented pointer pointing to the - * 4K EBDA area at 0x40E, calculate and scan it here: - */ - address = *(unsigned short *)phys_to_virt(0x40E); - address<<=4; - smp_scan_config(address, 0x1000); - } - } + smp_scan_config(0xF0000,0x10000); /* Scan the 64K of bios */ + /* + * If it is an SMP machine we should know now, unless the + * configuration is in an EISA/MCA bus machine with an + * extended bios data area. + * + * there is a real-mode segmented pointer pointing to the + * 4K EBDA area at 0x40E, calculate and scan it here: + */ + address = *(unsigned short *)phys_to_virt(0x40E); + address<<=4; + smp_scan_config(address, 0x1000); } /* * If it is an SMP machine we should know now, unless the configuration diff --git a/arch/mips/defconfig b/arch/mips/defconfig index 1a0d72523377..199060456d26 100644 --- a/arch/mips/defconfig +++ b/arch/mips/defconfig @@ -75,6 +75,7 @@ CONFIG_PROC_FS=y # CONFIG_MS_BUSMOUSE is not set # CONFIG_ATIXL_BUSMOUSE is not set # CONFIG_QIC02_TAPE is not set +# CONFIG_APM is not set # CONFIG_SERIAL is not set # diff --git a/drivers/block/Config.in b/drivers/block/Config.in index 4f66a3da4de9..32a1637f387a 100644 --- a/drivers/block/Config.in +++ b/drivers/block/Config.in @@ -11,9 +11,6 @@ if [ "$CONFIG_BLK_DEV_IDE" = "n" ]; then bool 'Old harddisk (MFM/RLL/IDE) driver' CONFIG_BLK_DEV_HD_ONLY else bool ' Use old disk-only driver on primary interface' CONFIG_BLK_DEV_HD_IDE - if [ "$CONFIG_BLK_DEV_HD_IDE" != "n" ]; then - bool ' Use multi-mode by default' CONFIG_IDEDISK_MULTI_MODE - fi bool ' Include IDE/ATAPI CDROM support' CONFIG_BLK_DEV_IDECD bool ' Include IDE/ATAPI TAPE support' CONFIG_BLK_DEV_IDETAPE bool ' Include IDE/ATAPI FLOPPY support (new)' CONFIG_BLK_DEV_IDEFLOPPY @@ -26,9 +23,6 @@ else if [ "$CONFIG_PCI" = "y" ]; then bool ' RZ1000 chipset bugfix/support' CONFIG_BLK_DEV_RZ1000 bool ' Intel 82371 PIIX (Triton I/II) DMA support' CONFIG_BLK_DEV_TRITON - if [ "$CONFIG_BLK_DEV_TRITON" = "y" ]; then - bool ' Boot off-board chipsets first support' CONFIG_BLK_DEV_OFFBOARD - fi fi bool ' Other IDE chipset support' CONFIG_IDE_CHIPSETS if [ "$CONFIG_IDE_CHIPSETS" = "y" ]; then @@ -63,12 +57,6 @@ if [ "$CONFIG_PCI" = "y" ]; then bool 'Mylex DAC960 PCI RAID Controller support' CONFIG_BLK_DEV_DAC960 fi -tristate 'Compaq SMART2 support' CONFIG_BLK_CPQ_DA -if [ "$CONFIG_BLK_CPQ_DA" = "y" -o "$CONFIG_BLK_CPQ_DA" = "m" ]; then - bool ' Support for PCI SMART-2 Controllers' CONFIG_BLK_CPQ_DA_PCI - bool ' Support for EISA SMART-2 Controllers' CONFIG_BLK_CPQ_DA_EISA -fi - tristate 'Parallel port IDE device support' CONFIG_PARIDE if [ "$CONFIG_PARIDE" = "y" -o "$CONFIG_PARIDE" = "m" ]; then source drivers/block/paride/Config.in diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 1ae09feb2da1..c584ea51d31a 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -156,15 +156,7 @@ else M_OBJS += raid5.o endif endif -endif -ifeq ($(CONFIG_BLK_CPQ_DA),y) -L_OBJS += cpqarray.o proc_array.o -else - ifeq ($(CONFIG_BLK_CPQ_DA),m) - M_OBJS += cpqarray.o - endif endif - include $(TOPDIR)/Rules.make diff --git a/drivers/block/README.smart2 b/drivers/block/README.smart2 deleted file mode 100644 index d2d72f0ba301..000000000000 --- a/drivers/block/README.smart2 +++ /dev/null @@ -1,85 +0,0 @@ -This driver is for Compaq's SMART2 Intellegent Disk Array Controllers. - -WARNING: --------- - -This code is distributed without warranty. Use at your own risk. - -Installing: ------------ - -You need to build a new kernel to use this device, even if you want to -use a loadable module. This driver requires Leonard N. Zubkoff's excellent -patches to ll_rw_blk.c (to controll the number of scatter/gather elements -sent to lower disk drivers). Visit http://www.dandelion.com/Linux/DAC960.html -to get his patches. - -Apply the patch to a 2.0.36 kernel after applying Leonard's patch: - -# cd linux -# patch -p1 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef MODULE -#include -#include -#else -#define MOD_INC_USE_COUNT -#define MOD_DEC_USE_COUNT -#endif - -#define DRIVER_NAME "Compaq SMART2 Driver (v 1.0)" - -#define MAJOR_NR COMPAQ_SMART2_MAJOR -#include -#include -#include - -#include "cpqarray.h" -#include "ida_cmd.h" -#include "ida_ioctl.h" - -#define READ_AHEAD 128 -#define NR_CMDS 128 /* This can probably go as high as ~400 */ - -#define MAX_CTLR 8 -#define CTLR_SHIFT 8 - -static int nr_ctlr = 0; -static ctlr_info_t *hba[MAX_CTLR] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - -#ifdef CONFIG_BLK_CPQ_DA_EISA -#ifndef MODULE -static -#endif -int eisa[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -#endif - -static char *product_names[] = { - "Unknown", - "SMART-2/E", - "SMART-2/P", /* or SMART-2DH */ - "SMART-2SL", - "SMART-3200", - "SMART-3100ES", - "SMART-221", -}; - -static struct hd_struct * ida; -static int * ida_sizes; -static int * ida_blocksizes; -static int * ida_hardsizes; -static int * ida_maxsectors; -static int * ida_maxsegments; -static struct gendisk ida_gendisk[MAX_CTLR]; - - -/* Debug... */ -#define DBG(s) s -/* Debug (general info)... */ -#define DBGINFO(s) -/* Debug Paranoid... */ -#define DBGP(s) s -/* Debug Extra Paranoid... */ -#define DBGPX(s) - -void cpqarray_init(void); -#ifdef CONFIG_BLK_CPQ_DA_PCI -static int cpqarray_pci_detect(void); -static void cpqarray_pci_init(ctlr_info_t *c, unchar bus, unchar device_fn); -static ulong remap_pci_mem(ulong base, ulong size); -#endif -#ifdef CONFIG_BLK_CPQ_DA_EISA -static int cpqarray_eisa_detect(void); -#endif -static void flushcomplete(int ctlr); -static int pollcomplete(int ctlr); -static void getgeometry(int ctlr); - -static cmdlist_t * cmd_alloc(ctlr_info_t *h); -static void cmd_free(ctlr_info_t *h, cmdlist_t *c); - -static int sendcmd( - __u8 cmd, - int ctlr, - void *buff, - size_t size, - unsigned int blk, - unsigned int blkcnt, - unsigned int log_unit ); - -static int ida_open(struct inode *inode, struct file *filep); -static void ida_release(struct inode *inode, struct file *filep); -static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg); -static int ida_ctlr_ioctl(int ctlr, int dsk, ida_ioctl_t *io); - -static void do_ida_request(int i); -/* - * This is a hack. This driver eats a major number for each controller, and - * sets blkdev[xxx].request_fn to each one of these so the real request - * function knows what controller its working with. - */ -#define DO_IDA_REQUEST(x) { \ - int flags; save_flags(flags); cli(); \ - do_ida_request(x); restore_flags(flags); } - -static void do_ida_request0(void) DO_IDA_REQUEST(0); -static void do_ida_request1(void) DO_IDA_REQUEST(1); -static void do_ida_request2(void) DO_IDA_REQUEST(2); -static void do_ida_request3(void) DO_IDA_REQUEST(3); -static void do_ida_request4(void) DO_IDA_REQUEST(4); -static void do_ida_request5(void) DO_IDA_REQUEST(5); -static void do_ida_request6(void) DO_IDA_REQUEST(6); -static void do_ida_request7(void) DO_IDA_REQUEST(7); - -static void start_io(ctlr_info_t *h); - -static inline cmdlist_t *removeQ(cmdlist_t **Qptr, cmdlist_t *c); -static inline void addQ(cmdlist_t **Qptr, cmdlist_t *c); -static inline void complete_buffers(struct buffer_head *bh, int ok); -static inline void complete_command(cmdlist_t *cmd, int timeout); - -static void do_ida_intr(int irq, void *dev_id, struct pt_regs * regs); -static void ida_timer(unsigned long tdata); -static int frevalidate_logvol(kdev_t dev); -static int revalidate_logvol(kdev_t dev, int maxusage); -static int revalidate_allvol(kdev_t dev); - -static void ida_procinit(int i); -static int ida_proc_get_info(char *buffer, char **start, off_t offset, int length, int dp); - -/* - * These macros control what happens when the driver tries to write to or - * read from a card. If the driver is configured for EISA only or PCI only, - * the macros expand to inl/outl or readl/writel. If the drive is configured - * for both EISA and PCI, the macro expands to a conditional which uses - * memory mapped IO if the card has it (PCI) or io ports if it doesn't (EISA). - */ -#ifdef CONFIG_BLK_CPQ_DA_PCI -# ifdef CONFIG_BLK_CPQ_DA_EISA -# define smart2_read(h, offset) ( ((h)->vaddr) ? readl((h)->vaddr+(offset)) : inl((h)->ioaddr+(offset)) ) -# define smart2_write(p, h, offset) ( ((h)->vaddr) ? writel((p), (h)->vaddr+(offset)) : outl((p), (h)->ioaddr+(offset)) ) -# else -# define smart2_read(h, offset) readl((h)->vaddr+(offset)) -# define smart2_write(p, h, offset) writel((p), (h)->vaddr+(offset)) -# endif -#else -# ifdef CONFIG_BLK_CPQ_DA_EISA -# define smart2_read(h, offset) inl((h)->vaddr+(offset)) -# define smart2_write(p, h, offset) outl((p), (h)->vaddr+(offset)) -# else -# error "You must enable either SMART2 PCI support or SMART2 EISA support or both!" -# endif -#endif - -void ida_geninit(struct gendisk *g) -{ - int ctlr = g-ida_gendisk; - int i,j; - drv_info_t *drv; - - for(i=0; idrv[i]; - if (!drv->nr_blks) - continue; - ida[(ctlr<nr_blks; - - for(j=0; j<16; j++) { - ida_blocksizes[(ctlr<blk_size; - } - ida_gendisk[ctlr].nr_real++; - } - -} - -struct file_operations ida_fops = { - NULL, /* lseek - default */ - block_read, /* read - general block-dev read */ - block_write, /* write - general block-dev write */ - NULL, /* readdir - bad */ - NULL, /* select */ - ida_ioctl, /* ioctl */ - NULL, /* mmap */ - ida_open, /* open code */ - ida_release, /* release */ - block_fsync, /* fsync */ - NULL, /* fasync */ - NULL, /* Disk change */ - frevalidate_logvol, /* revalidate */ -}; - - -/* - * Get us a file in /proc that says something about each controller. Right - * now, we add entries to /proc, but in the future we should probably get - * our own subdir in /proc (/proc/array/ida) and put our stuff in there. - */ -extern struct inode_operations proc_diskarray_inode_operations; -struct proc_dir_entry *proc_array = NULL; -static void ida_procinit(int i) -{ - struct proc_dir_entry *pd; - - if (proc_array == NULL) { - proc_array = kmalloc(sizeof(struct proc_dir_entry), GFP_KERNEL); - if (!proc_array) return; - memset(proc_array, 0, sizeof(struct proc_dir_entry)); - proc_array->namelen = 5; - proc_array->name = "array"; - proc_array->mode = S_IFDIR | S_IRUGO | S_IXUGO; - proc_array->nlink = 2; - proc_array->uid = 0; - proc_array->gid = 0; - proc_array->size = 0; - proc_array->ops = &proc_dir_inode_operations; - proc_register_dynamic(&proc_root, proc_array); - } - - pd = kmalloc(sizeof(struct proc_dir_entry), GFP_KERNEL); - if (!pd) return; - memset(pd, 0, sizeof(struct proc_dir_entry)); - pd->namelen = 4; - pd->name = hba[i]->devname; - pd->mode = S_IFREG | S_IRUGO; - pd->nlink = 1; - pd->uid = 0; - pd->gid = 0; - pd->size = 0; - pd->ops = &proc_diskarray_inode_operations; - pd->get_info = ida_proc_get_info; - - hba[i]->proc = (int)pd; - proc_register_dynamic(proc_array, pd); -} - -/* - * Report information about this controller. - */ -static int ida_proc_get_info(char *buffer, char **start, off_t offset, int length, int pd) -{ - off_t pos = 0; - off_t len = 0; - int size, i, ctlr; - ctlr_info_t *h; - drv_info_t *drv; -#ifdef CPQ_PROC_PRINT_QUEUES - cmdlist_t *c; -#endif - - for(ctlr=0; ctlrproc == pd) break; - - - if ((h = hba[ctlr]) == NULL) - return 0; - - size = sprintf(buffer, "%s: Compaq %s Disk Array Controller\n" - " Board ID: %08lx\n" - " Firmware Revision: %c%c%c%c\n" - " Controller Sig: %08lx\n" - " Memory Address: %08lx\n" - " I/O Port: %04x\n" - " IRQ: %x\n" - " Logical drives: %d\n" - " Physical drives: %d\n\n" - " Current Q depth: %d\n" - " Max Q depth since init: %d\n\n", - h->devname, - product_names[h->product], - (unsigned long)h->board_id, - h->firm_rev[0], h->firm_rev[1], h->firm_rev[2], h->firm_rev[3], - (unsigned long)h->ctlr_sig, (unsigned long)h->vaddr, - (unsigned int) h->ioaddr, (unsigned int)h->intr, - h->log_drives, h->phys_drives, - h->Qdepth, h->maxQsinceinit); - - pos += size; len += size; - - size = sprintf(buffer+len, "Logical Drive Info:\n"); - pos += size; len += size; - - for(i=0; ilog_drives; i++) { - drv = &h->drv[i]; - size = sprintf(buffer+len, "ida/c%dd%d: blksz=%d nr_blks=%d\n", - ctlr, i, drv->blk_size, drv->nr_blks); - pos += size; len += size; - } - -#ifdef CPQ_PROC_PRINT_QUEUES - size = sprintf(buffer+len, "\nCurrent Queues:\n"); - pos += size; len += size; - - c = h->reqQ; - size = sprintf(buffer+len, "reqQ = %p", c); pos += size; len += size; - if (c) c=c->next; - while(c && c != h->reqQ) { - size = sprintf(buffer+len, "->%p", c); - pos += size; len += size; - c=c->next; - } - - c = h->cmpQ; - size = sprintf(buffer+len, "\ncmpQ = %p", c); pos += size; len += size; - if (c) c=c->next; - while(c && c != h->cmpQ) { - size = sprintf(buffer+len, "->%p", c); - pos += size; len += size; - c=c->next; - } - - size = sprintf(buffer+len, "\n"); pos += size; len += size; -#endif - size = sprintf(buffer+len,"nr_allocs = %d\nnr_frees = %d\n", - h->nr_allocs, h->nr_frees); - pos += size; len += size; - - *start = buffer+offset; - len -= offset; - if (len>length) - len = length; - return len; -} - -#ifdef MODULE -/* This is a hack... */ -#include "proc_array.c" -int init_module(void) -{ - int i, j; - cpqarray_init(); - if (nr_ctlr == 0) - return -EIO; - - for(i=0; iintr, hba[i]); - vfree((void*)hba[i]->vaddr); - unregister_blkdev(MAJOR_NR+i, hba[i]->devname); - del_timer(&hba[i]->timer); - proc_unregister(proc_array, - ((struct proc_dir_entry*)hba[i]->proc)->low_ino); - kfree(hba[i]->cmd_pool); - kfree(hba[i]->cmd_pool_bits); - - if (gendisk_head == &ida_gendisk[i]) { - gendisk_head = ida_gendisk[i].next; - } else { - for(g=gendisk_head; g; g=g->next) { - if (g->next == &ida_gendisk[i]) { - g->next = ida_gendisk[i].next; - break; - } - } - } - - blk_dev[MAJOR_NR+i].request_fn = NULL; - blksize_size[MAJOR_NR+i] = NULL; - hardsect_size[MAJOR_NR+i] = NULL; - max_sectors[MAJOR_NR+i] = NULL; - max_segments[MAJOR_NR+i] = NULL; - } - proc_unregister(&proc_root, proc_array->low_ino); - kfree(ida); - kfree(ida_sizes); - kfree(ida_hardsizes); - kfree(ida_blocksizes); - - kfree(ida_maxsectors); - kfree(ida_maxsegments); - -} -#endif /* MODULE */ - -/* - * This is it. Find all the controllers and register them. I really hate - * stealing all these major device numbers. - */ -void cpqarray_init(void) -{ - void (*request_fns[MAX_CTLR])(void) = { - do_ida_request0, do_ida_request1, - do_ida_request2, do_ida_request3, - do_ida_request4, do_ida_request5, - do_ida_request6, do_ida_request7, - }; - int i; - - /* detect controllers */ -#ifdef CONFIG_BLK_CPQ_DA_PCI - cpqarray_pci_detect(); -#endif -#ifdef CONFIG_BLK_CPQ_DA_EISA - cpqarray_eisa_detect(); -#endif - - if (nr_ctlr == 0) - return; - - printk(DRIVER_NAME "\n"); - printk("Found %d controller(s)\n", nr_ctlr); - - /* allocate space for disk structs */ - ida = kmalloc(sizeof(struct hd_struct)*nr_ctlr*NWD*16, GFP_KERNEL); - ida_sizes = kmalloc(sizeof(int)*nr_ctlr*NWD*16, GFP_KERNEL); - ida_blocksizes = kmalloc(sizeof(int)*nr_ctlr*NWD*16, GFP_KERNEL); - ida_hardsizes = kmalloc(sizeof(int)*nr_ctlr*NWD*16, GFP_KERNEL); - - ida_maxsegments = kmalloc(sizeof(int)*nr_ctlr*NWD*16, GFP_KERNEL); - ida_maxsectors = kmalloc(sizeof(int)*nr_ctlr*NWD*16, GFP_KERNEL); - - memset(ida, 0, sizeof(struct hd_struct)*nr_ctlr*NWD*16); - memset(ida_sizes, 0, sizeof(int)*nr_ctlr*NWD*16); - memset(ida_blocksizes, 0, sizeof(int)*nr_ctlr*NWD*16); - memset(ida_hardsizes, 0, sizeof(int)*nr_ctlr*NWD*16); - memset(ida_maxsegments, 0, sizeof(int)*nr_ctlr*NWD*16); - memset(ida_maxsectors, 0, sizeof(int)*nr_ctlr*NWD*16); - memset(ida_gendisk, 0, sizeof(struct gendisk)*MAX_CTLR); - - for(i=0; iintr, do_ida_intr, - SA_INTERRUPT | SA_SHIRQ, hba[i]->devname, hba[i])) { - - printk("Unable to get irq %d for %s\n", - hba[i]->intr, hba[i]->devname); - continue; - } - if (register_blkdev(MAJOR_NR+i, hba[i]->devname, &ida_fops)) { - printk("Unable to get major number %d for %s\n", - MAJOR_NR+i, hba[i]->devname); - continue; - } - - hba[i]->cmd_pool = (cmdlist_t*)kmalloc( - NR_CMDS*sizeof(cmdlist_t), GFP_KERNEL); - hba[i]->cmd_pool_bits = (__u32*)kmalloc( - ((NR_CMDS+31)/32)*sizeof(__u32), GFP_KERNEL); - memset(hba[i]->cmd_pool, 0, NR_CMDS*sizeof(cmdlist_t)); - memset(hba[i]->cmd_pool_bits, 0, ((NR_CMDS+31)/32)*sizeof(__u32)); - - printk("Finding drives on %s", hba[i]->devname); - getgeometry(i); - - smart2_write(FIFO_NOT_EMPTY, hba[i], INTR_MASK); - - ida_procinit(i); - - ida_gendisk[i].major = MAJOR_NR + i; - ida_gendisk[i].major_name = "ida"; - ida_gendisk[i].minor_shift = NWD_SHIFT; - ida_gendisk[i].max_p = 16; - ida_gendisk[i].max_nr = 16; - ida_gendisk[i].init = ida_geninit; - ida_gendisk[i].part = ida + (i*256); - ida_gendisk[i].sizes = ida_sizes + (i*256); - /* ida_gendisk[i].nr_real is handled by getgeometry */ - - blk_dev[MAJOR_NR+i].request_fn = request_fns[i]; - blksize_size[MAJOR_NR+i] = ida_blocksizes + (i*256); - hardsect_size[MAJOR_NR+i] = ida_hardsizes + (i*256); - read_ahead[MAJOR_NR+i] = READ_AHEAD; - max_sectors[MAJOR_NR+i] = ida_maxsectors + (i*256); - max_segments[MAJOR_NR+i] = ida_maxsegments + (i*256); - - /* Get on the disk list */ - ida_gendisk[i].next = gendisk_head; - gendisk_head = &ida_gendisk[i]; - - init_timer(&hba[i]->timer); - hba[i]->timer.expires = jiffies + IDA_TIMER; - hba[i]->timer.data = (unsigned long)hba[i]; - hba[i]->timer.function = ida_timer; - add_timer(&hba[i]->timer); - - } - /* done ! */ -} - -#ifdef CONFIG_BLK_CPQ_DA_PCI -/* - * Find the controller and initialize it - */ -static int cpqarray_pci_detect(void) -{ - int index; - unchar bus=0, dev_fn=0; - - for(index=0; ; index++) { - if (pcibios_find_device(PCI_VENDOR_ID_COMPAQ, - PCI_DEVICE_ID_COMPAQ_SMART2P, index, &bus, &dev_fn)) - break; - - if (index == 1000000) break; - if (nr_ctlr == 8) { - printk("This driver supports a maximum of " - "8 controllers.\n"); - break; - } - - hba[nr_ctlr] = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL); - memset(hba[nr_ctlr], 0, sizeof(ctlr_info_t)); - cpqarray_pci_init(hba[nr_ctlr], bus, dev_fn); - sprintf(hba[nr_ctlr]->devname, "ida%d", nr_ctlr); - hba[nr_ctlr]->ctlr = nr_ctlr; - nr_ctlr++; - } - - return nr_ctlr; -} - -/* - * Find the IO address of the controller, its IRQ and so forth. Fill - * in some basic stuff into the ctlr_info_t structure. - */ -static void cpqarray_pci_init(ctlr_info_t *c, unchar bus, unchar device_fn) -{ - ushort vendor_id, device_id, command; - unchar cache_line_size, latency_timer; - unchar irq, revision; - uint addr[6]; - - int i; - - (void) pcibios_read_config_word(bus, device_fn, - PCI_VENDOR_ID, &vendor_id); - (void) pcibios_read_config_word(bus, device_fn, - PCI_DEVICE_ID, &device_id); - (void) pcibios_read_config_word(bus, device_fn, - PCI_COMMAND, &command); - for(i=0; i<6; i++) - (void) pcibios_read_config_dword(bus, device_fn, - PCI_BASE_ADDRESS_0 + i*4, addr+i); - - (void) pcibios_read_config_byte(bus, device_fn, - PCI_CLASS_REVISION,&revision); - (void) pcibios_read_config_byte(bus, device_fn, - PCI_INTERRUPT_LINE, &irq); - (void) pcibios_read_config_byte(bus, device_fn, - PCI_CACHE_LINE_SIZE, &cache_line_size); - (void) pcibios_read_config_byte(bus, device_fn, - PCI_LATENCY_TIMER, &latency_timer); - -DBGINFO( - printk("vendor_id = %x\n", vendor_id); - printk("device_id = %x\n", device_id); - printk("command = %x\n", command); - for(i=0; i<6; i++) - printk("addr[%d] = %x\n", i, addr[i]); - printk("revision = %x\n", revision); - printk("irq = %x\n", irq); - printk("cache_line_size = %x\n", cache_line_size); - printk("latency_timer = %x\n", latency_timer); -); - - c->intr = irq; - c->ioaddr = addr[0] & ~0x1; - - /* - * Memory base addr is first addr with the first bit _not_ set - */ - for(i=0; i<6; i++) - if (!(addr[i] & 0x1)) { - c->paddr = addr[i]; - break; - } - c->vaddr = remap_pci_mem(c->paddr, 128); -} - -/* - * Map (physical) PCI mem into (virtual) kernel space - */ -static ulong remap_pci_mem(ulong base, ulong size) -{ - ulong page_base = ((ulong) base) & PAGE_MASK; - ulong page_offs = ((ulong) base) - page_base; - ulong page_remapped = (ulong) vremap(page_base, page_offs+size); - - return (ulong) (page_remapped ? (page_remapped + page_offs) : 0UL); -} -#endif /* CONFIG_BLK_CPQ_DA_PCI */ - -#ifdef CONFIG_BLK_CPQ_DA_EISA -/* - * Copy the contents of the ints[] array passed to us by init. - */ -void cpqarray_setup(char *str, int *ints) -{ - int i; - if (ints[0] & 1) { - printk( "SMART2 Parameter Usage:\n" - " smart2=io,irq,io,irq,...\n"); - return; - } - for(i=0; iioaddr = eisa[i]; - hba[nr_ctlr]->intr = eisa[i+1]; - sprintf(hba[nr_ctlr]->devname, "ida%d", nr_ctlr); - hba[nr_ctlr]->ctlr = nr_ctlr; - nr_ctlr++; - } else { - printk("SMART2: Could not find a controller at io=0x%04x irq=0x%x\n", eisa[i], eisa[i+1]); - } - i+=2; - } - return nr_ctlr; -} -#endif /* CONFIG_BLK_CPQ_DA_EISA */ - -/* - * Open. Make sure the device is really there. - */ -static int ida_open(struct inode *inode, struct file *filep) -{ - int ctlr = MAJOR(inode->i_rdev) - MAJOR_NR; - int dsk = MINOR(inode->i_rdev) >> NWD_SHIFT; - - DBGINFO(printk("ida_open %x (%x:%x)\n", inode->i_rdev, ctlr, dsk) ); - if (ctlr > MAX_CTLR || hba[ctlr] == NULL) - return -ENXIO; - - if (!suser() && ida_sizes[(ctlr << CTLR_SHIFT) + - MINOR(inode->i_rdev)] == 0) - return -ENXIO; - - /* - * Root is allowed to open raw volume zero even if its not configured - * so array config can still work. I don't think I really like this, - * but I'm already using way to many device nodes to claim another one - * for "raw controller". - */ - if (suser() - && ida_sizes[(ctlr << CTLR_SHIFT) + MINOR(inode->i_rdev)] == 0 - && MINOR(inode->i_rdev) != 0) - return -ENXIO; - - hba[ctlr]->drv[dsk].usage_count++; - hba[ctlr]->usage_count++; - MOD_INC_USE_COUNT; - return 0; -} - -/* - * Close. Sync first. - */ -void ida_release(struct inode *inode, struct file *filep) -{ - int ctlr = MAJOR(inode->i_rdev) - MAJOR_NR; - int dsk = MINOR(inode->i_rdev) >> NWD_SHIFT; - - DBGINFO(printk("ida_release %x (%x:%x)\n", inode->i_rdev, ctlr, dsk) ); - fsync_dev(inode->i_rdev); - - hba[ctlr]->drv[dsk].usage_count--; - hba[ctlr]->usage_count--; - MOD_DEC_USE_COUNT; -} - -/* - * Enqueuing and dequeuing functions for cmdlists. - */ -static inline void addQ(cmdlist_t **Qptr, cmdlist_t *c) -{ - if (*Qptr == NULL) { - *Qptr = c; - c->next = c->prev = c; - } else { - c->prev = (*Qptr)->prev; - c->next = (*Qptr); - (*Qptr)->prev->next = c; - (*Qptr)->prev = c; - } -} - -static inline cmdlist_t *removeQ(cmdlist_t **Qptr, cmdlist_t *c) -{ - if (c && c->next != c) { - if (*Qptr == c) *Qptr = c->next; - c->prev->next = c->next; - c->next->prev = c->prev; - } else { - *Qptr = NULL; - } - return c; -} - -/* - * Get a request and submit it to the controller. - * This routine needs to grab all the requests it possibly can from the - * req Q and submit them. Interrupts are off (and need to be off) when you - * are in here (either via the dummy do_ida_request functions or by being - * called from the interrupt handler - */ -void do_ida_request(int ctlr) -{ - ctlr_info_t *h = hba[ctlr]; - cmdlist_t *c; - int seg; - char *lastdataend; - struct buffer_head *bh; - struct request *creq; - - creq = blk_dev[MAJOR_NR+ctlr].current_request; - if (creq == NULL || creq->rq_status == RQ_INACTIVE) - goto doreq_done; - - if (ctlr != MAJOR(creq->rq_dev)-MAJOR_NR || - ctlr > nr_ctlr || h == NULL) { - printk("doreq cmd for %d, %x at %p\n", - ctlr, creq->rq_dev, creq); - complete_buffers(creq->bh, 0); - goto doreq_done; - } - - if ((c = cmd_alloc(h)) == NULL) - goto doreq_done; - - blk_dev[MAJOR_NR+ctlr].current_request = creq->next; - creq->rq_status = RQ_INACTIVE; - - bh = creq->bh; - - c->ctlr = ctlr; - c->hdr.unit = MINOR(creq->rq_dev) >> NWD_SHIFT; - c->hdr.size = sizeof(rblk_t) >> 2; - c->size += sizeof(rblk_t); - - c->req.hdr.sg_cnt = creq->nr_segments; - c->req.hdr.blk = ida[(ctlr<rq_dev)].start_sect + creq->sector; - c->req.hdr.blk_cnt = creq->nr_sectors; - c->bh = bh; - - seg = 0; lastdataend = NULL; - while(bh) { - if (bh->b_data == lastdataend) { - c->req.sg[seg-1].size += bh->b_size; - lastdataend += bh->b_size; - } else { - c->req.sg[seg].size = bh->b_size; - c->req.sg[seg].addr = (__u32) virt_to_bus(bh->b_data); - lastdataend = bh->b_data + bh->b_size; - if (seg++ > SG_MAX) - panic("SG list overflow\n"); - } - bh = bh->b_reqnext; - } - if (seg != creq->nr_segments) - panic("seg != nr_segments\n"); - - c->req.hdr.cmd = (creq->cmd == READ) ? IDA_READ : IDA_WRITE; - c->type = CMD_RWREQ; - - /* Put the request on the tail of the request queue */ - addQ(&h->reqQ, c); - h->Qdepth++; - if (h->Qdepth > h->maxQsinceinit) h->maxQsinceinit = h->Qdepth; - - wake_up(&wait_for_request); -doreq_done: - start_io(h); -} - -/* - * start_io submits everything on a controller's request queue - * and moves it to the completion queue. - * - * Interrupts had better be off if you're in here - */ -static void start_io(ctlr_info_t *h) -{ - cmdlist_t *c; - - while((c = h->reqQ) != NULL) { - /* Can't do anything if we're busy */ - if (smart2_read(h, COMMAND_FIFO) == 0) - return; - - /* Get the first entry from the request Q */ - removeQ(&h->reqQ, c); - h->Qdepth--; - - /* Tell the controller to do our bidding */ - smart2_write(c->busaddr, h, COMMAND_FIFO); - - /* Get onto the completion Q */ - addQ(&h->cmpQ, c); - } -} - - -static inline void complete_buffers(struct buffer_head *bh, int ok) -{ - struct buffer_head *xbh; - while(bh) { - xbh = bh->b_reqnext; - bh->b_reqnext = NULL; - mark_buffer_uptodate(bh, ok); - unlock_buffer(bh); - bh = xbh; - } -} - -/* - * Mark all buffers that cmd was responsible for - */ -static inline void complete_command(cmdlist_t *cmd, int timeout) -{ - char buf[80]; - int ok=1; - - if (cmd->req.hdr.rcode & RCODE_NONFATAL && - (hba[cmd->ctlr]->misc_tflags & MISC_NONFATAL_WARN) == 0) { - sprintf(buf, "Non Fatal error on ida/c%dd%d\n", - cmd->ctlr, cmd->hdr.unit); - console_print(buf); - hba[cmd->ctlr]->misc_tflags |= MISC_NONFATAL_WARN; - } - if (cmd->req.hdr.rcode & RCODE_FATAL) { - sprintf(buf, "Fatal error on ida/c%dd%d\n", - cmd->ctlr, cmd->hdr.unit); - console_print(buf); - ok = 0; - } - if (cmd->req.hdr.rcode & RCODE_INVREQ) { -sprintf(buf, "Invalid request on ida/c%dd%d = (cmd=%x sect=%d cnt=%d sg=%d ret=%x)\n", - cmd->ctlr, cmd->hdr.unit, cmd->req.hdr.cmd, - cmd->req.hdr.blk, cmd->req.hdr.blk_cnt, - cmd->req.hdr.sg_cnt, cmd->req.hdr.rcode); - console_print(buf); - ok = 0; - } - if (timeout) { - sprintf(buf, "Request timeout on ida/c%dd%d\n", - cmd->ctlr, cmd->hdr.unit); - console_print(buf); - ok = 0; - } - complete_buffers(cmd->bh, ok); -} - -/* - * The controller will interrupt us upon completion of commands. - * Find the command on the completion queue, remove it, tell the OS and - * try to queue up more IO - */ -void do_ida_intr(int irq, void *dev_id, struct pt_regs *regs) -{ - ctlr_info_t *h = dev_id; - cmdlist_t *c; - unsigned long istat; - __u32 a,a1; - - istat = smart2_read(h, INTR_PENDING); - /* Is this interrupt for us? */ - if (istat == 0) - return; - - /* - * If there are completed commands in the completion queue, - * we had better do something about it. - */ - if (istat & FIFO_NOT_EMPTY) { - while((a = smart2_read(h, COMMAND_COMPLETE_FIFO))) { - a1 = a; a &= ~3; - if ((c = h->cmpQ) == NULL) goto bad_completion; - while(c->busaddr != a) { - c = c->next; - if (c == h->cmpQ) break; - } - /* - * If we've found the command, take it off the - * completion Q and free it - */ - if (c->busaddr == a) { - removeQ(&h->cmpQ, c); - if (c->type == CMD_RWREQ) { - complete_command(c, 0); - cmd_free(h, c); - } else if (c->type == CMD_IOCTL_PEND) { - c->type = CMD_IOCTL_DONE; - } - continue; - } -bad_completion: - printk("Completion of %08lx ignored\n", (unsigned long)a1); - } - } - - /* - * See if we can queue up some more IO (Is this safe?) - */ - do_ida_request(h->ctlr); -} - -/* - * This timer is for timing out requests that haven't happened after - * IDA_TIMEOUT, or rather it _WAS_ for timing out "dead" requests. - * That didn't work quite like I expected and would cause crashes - * and other nonsense. - */ -static void ida_timer(unsigned long tdata) -{ - ctlr_info_t *h = (ctlr_info_t*)tdata; - - h->timer.expires = jiffies + IDA_TIMER; - add_timer(&h->timer); - h->misc_tflags = 0; -} - -/* - * ida_ioctl does some miscellaneous stuff like reporting drive geometry, - * setting readahead and submitting commands from userspace to the controller. - */ -int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg) -{ - int ctlr = MAJOR(inode->i_rdev) - MAJOR_NR; - int dsk = MINOR(inode->i_rdev) >> NWD_SHIFT; - int error; - int diskinfo[4]; - struct hd_geometry *geo = (struct hd_geometry *)arg; - ida_ioctl_t *io = (ida_ioctl_t*)arg; - ida_ioctl_t my_io; - - DBGINFO(printk("ida_ioctl %x %x %x\n", inode->i_rdev, cmd, arg)); - switch(cmd) { - case HDIO_GETGEO: - error = verify_area(VERIFY_WRITE, geo, sizeof(*geo)); - if (error) return error; - if (hba[ctlr]->drv[dsk].cylinders) { - diskinfo[0] = hba[ctlr]->drv[dsk].heads; - diskinfo[1] = hba[ctlr]->drv[dsk].sectors; - diskinfo[2] = hba[ctlr]->drv[dsk].cylinders; - } else { - diskinfo[0] = 0xff; - diskinfo[1] = 0x3f; - diskinfo[2] = hba[ctlr]->drv[dsk].nr_blks / (0xff*0x3f); - } - put_user(diskinfo[0], &geo->heads); - put_user(diskinfo[1], &geo->sectors); - put_user(diskinfo[2], &geo->cylinders); - put_user(ida[(ctlr<i_rdev)].start_sect, &geo->start); - return 0; - case IDAGETDRVINFO: - error = verify_area(VERIFY_WRITE, io, sizeof(*io)); - if (error) return error; - memcpy_tofs(&io->c.drv,&hba[ctlr]->drv[dsk],sizeof(drv_info_t)); - return 0; - case BLKGETSIZE: - if (!arg) return -EINVAL; - error = verify_area(VERIFY_WRITE, (long*)arg, sizeof(long)); - if (error) return error; - put_user(ida[(ctlr<i_rdev)].nr_sects, (long*)arg); - return 0; - case BLKRASET: - if (!suser()) return -EACCES; - if (!(inode->i_rdev)) return -EINVAL; - if (arg>0xff) return -EINVAL; - read_ahead[MAJOR(inode->i_rdev)] = arg; - return 0; - case BLKRAGET: - if (!arg) return -EINVAL; - error=verify_area(VERIFY_WRITE, (int*)arg, sizeof(int)); - if (error) return error; - put_user(read_ahead[MAJOR(inode->i_rdev)], (int*)arg); - return 0; - case BLKRRPART: - return revalidate_logvol(inode->i_rdev, 1); - case IDAPASSTHRU: - if (!suser()) return -EPERM; - error = verify_area(VERIFY_READ|VERIFY_WRITE, io, sizeof(*io)); - if (error) return error; - memcpy_fromfs(&my_io, io, sizeof(my_io)); - error = ida_ctlr_ioctl(ctlr, dsk, &my_io); - if (error) return error; - memcpy_tofs(io, &my_io, sizeof(my_io)); - return 0; - case IDAGETCTLRSIG: - if (!arg) return -EINVAL; - error=verify_area(VERIFY_WRITE, (int*)arg, sizeof(int)); - if (error) return error; - put_user(hba[ctlr]->ctlr_sig, (int*)arg); - return 0; - case IDAREVALIDATEVOLS: - return revalidate_allvol(inode->i_rdev); - - RO_IOCTLS(inode->i_rdev, arg); - - default: - return -EBADRQC; - } - -} -/* - * ida_ctlr_ioctl is for passing commands to the controller from userspace. - * The command block (io) has already been copied to kernel space for us, - * however, any elements in the sglist need to be copied to kernel space - * or copied back to userspace. - * - * Only root may perform a controller passthru command, however I'm not doing - * any serious sanity checking on the arguments. Doing an IDA_WRITE_MEDIA and - * putting a 64M buffer in the sglist is probably a *bad* idea. - */ -int ida_ctlr_ioctl(int ctlr, int dsk, ida_ioctl_t *io) -{ - ctlr_info_t *h = hba[ctlr]; - cmdlist_t *c; - void *p = NULL; - unsigned long flags; - int error; - - DBGINFO(printk("ida_ctlr_ioctl %d %x %p\n", ctlr, dsk, io)); - if ((c = cmd_alloc(NULL)) == NULL) - return -ENOMEM; - c->ctlr = ctlr; - c->hdr.unit = (io->unit & UNITVALID) ? io->unit &0x7f : dsk; - c->hdr.size = sizeof(rblk_t) >> 2; - c->size += sizeof(rblk_t); - c->req.hdr.cmd = io->cmd; - c->type = CMD_IOCTL_PEND; - - /* Pre submit processing */ - switch(io->cmd) { - case PASSTHRU_A: - error = verify_area(VERIFY_READ|VERIFY_WRITE, - (void*)io->sg[0].addr, io->sg[0].size); - if (error) goto ioctl_err_exit; - - p = kmalloc(io->sg[0].size, GFP_KERNEL); - if (!p) { error = -ENOMEM; goto ioctl_err_exit; } - memcpy_fromfs(p, (void*)io->sg[0].addr, io->sg[0].size); - c->req.bp = virt_to_bus(&(io->c)); - c->req.sg[0].size = io->sg[0].size; - c->req.sg[0].addr = virt_to_bus(p); - c->req.hdr.sg_cnt = 1; - break; - case IDA_READ: - error = verify_area(VERIFY_WRITE, - (void*)io->sg[0].addr, io->sg[0].size); - if (error) goto ioctl_err_exit; - p = kmalloc(io->sg[0].size, GFP_KERNEL); - if (!p) { error = -ENOMEM; goto ioctl_err_exit; } - c->req.sg[0].size = io->sg[0].size; - c->req.sg[0].addr = virt_to_bus(p); - c->req.hdr.sg_cnt = 1; - break; - case IDA_WRITE: - case IDA_WRITE_MEDIA: - case DIAG_PASS_THRU: - error = verify_area(VERIFY_READ, - (void*)io->sg[0].addr, io->sg[0].size); - if (error) goto ioctl_err_exit; - p = kmalloc(io->sg[0].size, GFP_KERNEL); - if (!p) { error = -ENOMEM; goto ioctl_err_exit; } - memcpy_fromfs(p, (void*)io->sg[0].addr, io->sg[0].size); - c->req.sg[0].size = io->sg[0].size; - c->req.sg[0].addr = virt_to_bus(p); - c->req.hdr.sg_cnt = 1; - break; - default: - c->req.sg[0].size = sizeof(io->c); - c->req.sg[0].addr = virt_to_bus(&io->c); - c->req.hdr.sg_cnt = 1; - } - - /* Put the request on the tail of the request queue */ - save_flags(flags); - cli(); - addQ(&h->reqQ, c); - h->Qdepth++; - start_io(h); - restore_flags(flags); - - /* Wait for completion */ - while(c->type != CMD_IOCTL_DONE) - schedule(); - - /* Post submit processing */ - switch(io->cmd) { - case PASSTHRU_A: - case IDA_READ: - case DIAG_PASS_THRU: - memcpy_tofs((void*)io->sg[0].addr, p, io->sg[0].size); - /* fall through and free p */ - case IDA_WRITE: - case IDA_WRITE_MEDIA: - kfree(p); - break; - default: - /* Nothing to do */ - } - - io->rcode = c->req.hdr.rcode; - error = 0; -ioctl_err_exit: - cmd_free(NULL, c); - return error; -} - -/* - * Commands are pre-allocated in a large block. Here we use a simple bitmap - * scheme to suballocte them to the driver. Operations that are not time - * critical (and can wait for kmalloc and possibly sleep) can pass in NULL - * as the first argument to get a new command. - */ -cmdlist_t * cmd_alloc(ctlr_info_t *h) -{ - cmdlist_t * c; - int i; - - if (h == NULL) { - c = (cmdlist_t*)kmalloc(sizeof(cmdlist_t), GFP_KERNEL); - } else { - do { - i = find_first_zero_bit(h->cmd_pool_bits, NR_CMDS); - if (i == NR_CMDS) - return NULL; - } while(set_bit(i%32, h->cmd_pool_bits+(i/32)) != 0); - c = h->cmd_pool + i; - h->nr_allocs++; - } - - memset(c, 0, sizeof(cmdlist_t)); - c->busaddr = virt_to_bus(c); - return c; -} - -void cmd_free(ctlr_info_t *h, cmdlist_t *c) -{ - int i; - - if (h == NULL) { - kfree(c); - } else { - i = c - h->cmd_pool; - clear_bit(i%32, h->cmd_pool_bits+(i/32)); - h->nr_frees++; - } -} - -/*********************************************************************** - name: sendcmd - Send a command to an IDA using the memory mapped FIFO interface - and wait for it to complete. - This routine should only be called at init time. -***********************************************************************/ -int sendcmd( - __u8 cmd, - int ctlr, - void *buff, - size_t size, - unsigned int blk, - unsigned int blkcnt, - unsigned int log_unit ) -{ - cmdlist_t *c; - int complete; - __u32 base_ptr; - unsigned long temp; - unsigned long i; - ctlr_info_t *info_p = hba[ctlr]; - - c = cmd_alloc(info_p); - c->ctlr = ctlr; - c->hdr.unit = log_unit; - c->hdr.prio = 0; - c->hdr.size = sizeof(rblk_t) >> 2; - c->size += sizeof(rblk_t); - - /* The request information. */ - c->req.hdr.next = 0; - c->req.hdr.rcode = 0; - c->req.bp = 0; - c->req.hdr.sg_cnt = 1; - c->req.hdr.reserved = 0; - - if (size == 0) - c->req.sg[0].size = 512; - else - c->req.sg[0].size = size; - - c->req.hdr.blk = blk; - c->req.hdr.blk_cnt = blkcnt; - c->req.hdr.cmd = (unsigned char) cmd; - c->req.sg[0].addr = (__u32) virt_to_bus(buff); - flushcomplete(ctlr); - /* - * Disable interrupt - */ - base_ptr = info_p->vaddr; - smart2_write(0, info_p, INTR_MASK); - /* Make sure there is room in the command FIFO */ - /* Actually it should be completely empty at this time. */ - for (i = 200000; i > 0; i--) { - temp = smart2_read(info_p, COMMAND_FIFO); - if (temp != 0) { - break; - } - udelay(10); -DBG( - printk("ida%d: idaSendPciCmd FIFO full, waiting!\n", - ctlr); -); - } - /* - * Send the cmd - */ - smart2_write(c->busaddr, info_p, COMMAND_FIFO); - complete = pollcomplete(ctlr); - if (complete != 1) { - if (complete != c->busaddr) { - printk( - "ida%d: idaSendPciCmd " - "Invalid command list address returned! (%08lx)\n", - ctlr, (unsigned long)complete); - cmd_free(info_p, c); - return (IO_ERROR); - } - } else { - printk( - "ida%d: idaSendPciCmd Timeout out, " - "No command list address returned!\n", - ctlr); - cmd_free(info_p, c); - return (IO_ERROR); - } - - if (c->req.hdr.rcode & 0x00FE) { - if (!(c->req.hdr.rcode & BIG_PROBLEM)) { - printk( - "ida%d: idaSendPciCmd, error: Controller failed " - "at init time " - "cmd: 0x%x, return code = 0x%x\n", - ctlr, c->req.hdr.cmd, c->req.hdr.rcode); - - cmd_free(info_p, c); - return (IO_ERROR); - } - } - cmd_free(info_p, c); - return (IO_OK); -} - -int frevalidate_logvol(kdev_t dev) -{ - return revalidate_logvol(dev, 0); -} - -/* - * revalidate_allvol is for online array config utilities. After a - * utility reconfigures the drives in the array, it can use this function - * (through an ioctl) to make the driver zap any previous disk structs for - * that controller and get new ones. - * - * Right now I'm using the getgeometry() function to do this, but this - * function should probably be finer grained and allow you to revalidate one - * particualar logical volume (instead of all of them on a particular - * controller). - */ -static int revalidate_allvol(kdev_t dev) -{ - int ctlr, i; - unsigned long flags; - - ctlr = MAJOR(dev) - MAJOR_NR; - if (MINOR(dev) != 0) - return -ENXIO; - - save_flags(flags); - cli(); - if (hba[ctlr]->usage_count > 1) { - restore_flags(flags); - printk("Device busy for volume revalidation (usage=%d)\n", - hba[ctlr]->usage_count); - return -EBUSY; - } - - hba[ctlr]->usage_count++; - restore_flags(flags); - - /* - * Set the partition and block size structures for all volumes - * on this controller to zero. We will reread all of this data - */ - memset(ida+(ctlr*256), 0, sizeof(struct hd_struct)*NWD*16); - memset(ida_sizes+(ctlr*256), 0, sizeof(int)*NWD*16); - memset(ida_blocksizes+(ctlr*256), 0, sizeof(int)*NWD*16); - memset(ida_hardsizes+(ctlr*256), 0, sizeof(int)*NWD*16); - ida_gendisk[ctlr].nr_real = 0; - - /* - * Tell the array controller not to give us any interupts while - * we check the new geometry. Then turn interrupts back on when - * we're done. - */ - smart2_write(0, hba[ctlr], INTR_MASK); - getgeometry(ctlr); - smart2_write(FIFO_NOT_EMPTY, hba[ctlr], INTR_MASK); - - ida_geninit(&ida_gendisk[ctlr]); - for(i=0; iusage_count--; - return 0; -} - -/* Borrowed and adapted from sd.c */ -int revalidate_logvol(kdev_t dev, int maxusage) -{ - int ctlr, target; - struct gendisk *gdev; - unsigned long flags; - int max_p; - int start; - int i; - - target = DEVICE_NR(dev); - ctlr = MAJOR(dev) - MAJOR_NR; - gdev = &ida_gendisk[ctlr]; - - save_flags(flags); - cli(); - if (hba[ctlr]->drv[target].usage_count > maxusage) { - restore_flags(flags); - printk("Device busy for revalidation (usage=%d)\n", - hba[ctlr]->drv[target].usage_count); - return -EBUSY; - } - - hba[ctlr]->drv[target].usage_count++; - restore_flags(flags); - - max_p = gdev->max_p; - start = target << gdev->minor_shift; - - for(i=max_p; i>=0; i--) { - int minor = start+i; - kdev_t devi = MKDEV(MAJOR_NR + ctlr, minor); - sync_dev(devi); - invalidate_inodes(devi); - invalidate_buffers(devi); - gdev->part[minor].start_sect = 0; - gdev->part[minor].nr_sects = 0; - - /* reset the blocksize so we can read the partition table */ - blksize_size[MAJOR_NR+ctlr][minor] = 1024; - } - - gdev->part[start].nr_sects = hba[ctlr]->drv[target].nr_blks; - resetup_one_dev(gdev, target); - hba[ctlr]->drv[target].usage_count--; - return 0; -} - - -/******************************************************************** - name: pollcomplete - Wait polling for a command to complete. - The memory mapped FIFO is polled for the completion. - Used only at init time, interrupts disabled. - ********************************************************************/ -int pollcomplete(int ctlr) -{ - int done; - int i; - - /* Wait (up to 2 seconds) for a command to complete */ - - for (i = 200000; i > 0; i--) { - done = smart2_read(hba[ctlr], COMMAND_COMPLETE_FIFO); - if (done == 0) { - udelay(10); /* a short fixed delay */ - } else - return (done); - } - /* Invalid address to tell caller we ran out of time */ - return 1; -} - -/* - * Clear the complete FIFO - - Polling routine. - This should only be used at init time. - Any commands unexpectedly found in the completed command fifo - will be discarded. There should be none. - Called in only one place. - Note this reads and discards any completed commands but does not - wait for any uncompleted commands. - This is kinda goofy. - - */ -void flushcomplete(int ctlr) -{ - unsigned long ret_addr; - unsigned int i; - - for (i = 200000; i > 0; i--) { - ret_addr = smart2_read(hba[ctlr], COMMAND_COMPLETE_FIFO); - if (ret_addr == 0) { - break; - } - udelay(10); -DBG( - printk("ida%d: flushcomplete " - "Discarding completion %x!\n", - ctlr, (unsigned int)ret_addr); -); - } -} - - - -/***************************************************************** - idaGetGeometry - Get ida logical volume geometry from the controller - This is a large bit of code which once existed in two flavors, - for EISA and PCI. It is used only at init time. -**************************************************************** -*/ -void getgeometry(int ctlr) -{ - id_log_drv_t *id_ldrive; - id_ctlr_t *id_ctlr_buf; - sense_log_drv_stat_t *id_lstatus_buf; - config_t *sense_config_buf; - unsigned int log_unit, log_index; - int ret_code, size; - drv_info_t *drv; - ctlr_info_t *info_p = hba[ctlr]; - - id_ldrive = (id_log_drv_t *)kmalloc(sizeof(id_log_drv_t), GFP_KERNEL); - id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); - id_lstatus_buf = (sense_log_drv_stat_t *)kmalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL); - sense_config_buf = (config_t *)kmalloc(sizeof(config_t), GFP_KERNEL); - - memset(id_ldrive, 0, sizeof(id_log_drv_t)); - memset(id_ctlr_buf, 0, sizeof(id_ctlr_t)); - memset(id_lstatus_buf, 0, sizeof(sense_log_drv_stat_t)); - memset(sense_config_buf, 0, sizeof(config_t)); - - info_p->phys_drives = 0; - info_p->log_drv_map = 0; - info_p->drv_assign_map = 0; - info_p->drv_spare_map = 0; - info_p->mp_failed_drv_map = 0; /* only initialized here */ - /* Get controllers info for this logical drive */ - ret_code = sendcmd(ID_CTLR, ctlr, id_ctlr_buf, 0, 0, 0, 0); - if (ret_code == IO_ERROR) { - /* - * If can't get controller info, set the logical drive map to 0, - * so the idastubopen will fail on all logical drives - * on the controller. - */ - goto geo_ret; /* release the buf and return */ - } - info_p->log_drives = id_ctlr_buf->nr_drvs;; - *(__u32*)(info_p->firm_rev) = *(__u32*)(id_ctlr_buf->firm_rev); - info_p->ctlr_sig = id_ctlr_buf->cfg_sig; - info_p->board_id = id_ctlr_buf->board_id; - - switch(info_p->board_id) { - case 0x0E114030: /* SMART-2/E */ - info_p->product = 1; - break; - case 0x40300E11: /* SMART-2/P or SMART-2DH */ - info_p->product = 2; - break; - case 0x40310E11: /* SMART-2SL */ - info_p->product = 3; - break; - case 0x40320E11: /* SMART-3200 */ - info_p->product = 4; - break; - case 0x40330E11: /* SMART-3100ES */ - info_p->product = 5; - break; - case 0x40340E11: /* SMART-221 */ - info_p->product = 6; - break; - default: - /* - * Well, its a SMART-2 or better, don't know which - * kind. - */ - info_p->product = 0; - } - printk(" (%s)\n", product_names[info_p->product]); - /* - * Initialize logical drive map to zero - */ -#ifdef REDUNDANT - info_p->log_drive_map = 0; -#endif /* #ifdef REDUNDANT */ - log_index = 0; - /* - * Get drive geometry for all logical drives - */ - if (id_ctlr_buf->nr_drvs > 16) - printk("ida%d: This driver supports 16 logical drives " - "per controller. Additional drives will not be " - "detected.\n", ctlr); - - for (log_unit = 0; - (log_index < id_ctlr_buf->nr_drvs) - && (log_unit < NWD); - log_unit++) { - - size = sizeof(sense_log_drv_stat_t); - - /* - Send "Identify logical drive status" cmd - */ - ret_code = sendcmd(SENSE_LOG_DRV_STAT, - ctlr, id_lstatus_buf, size, 0, 0, log_unit); - if (ret_code == IO_ERROR) { - /* - If can't get logical drive status, set - the logical drive map to 0, so the - idastubopen will fail for all logical drives - on the controller. - */ - info_p->log_drv_map = 0; - printk( - "ida%d: idaGetGeometry - Controller failed " - "to report status of logical drive %d\n" - "Access to this controller has been disabled\n", - ctlr, log_unit); - goto geo_ret; /* release the buf and return */ - - } - /* - Make sure the logical drive is configured - */ - if (id_lstatus_buf->status != LOG_NOT_CONF) { - ret_code = sendcmd(ID_LOG_DRV, ctlr, id_ldrive, - sizeof(id_log_drv_t), 0, 0, log_unit); - /* - If error, the bit for this - logical drive won't be set and - idastubopen will return error. - */ - if (ret_code != IO_ERROR) { - drv = &info_p->drv[log_unit]; - drv->blk_size = id_ldrive->blk_size; - drv->nr_blks = id_ldrive->nr_blks; - drv->cylinders = id_ldrive->drv.cyl; - drv->heads = id_ldrive->drv.heads; - drv->sectors = id_ldrive->drv.sect_per_track; - info_p->log_drv_map |= (1 << log_unit); - - printk("ida/c%dd%d: blksz=%d nr_blks=%d\n", - ctlr, log_unit, drv->blk_size, - drv->nr_blks); - ret_code = sendcmd(SENSE_CONFIG, - ctlr, sense_config_buf, - sizeof(config_t), 0, 0, log_unit); - if (ret_code == IO_ERROR) { - info_p->log_drv_map = 0; - goto geo_ret; /* release the buf and return */ - } - info_p->phys_drives = - sense_config_buf->ctlr_phys_drv; - info_p->drv_assign_map - |= sense_config_buf->drv_asgn_map; - info_p->drv_assign_map - |= sense_config_buf->spare_asgn_map; - info_p->drv_spare_map - |= sense_config_buf->spare_asgn_map; - } /* end of if no error on id_ldrive */ - log_index = log_index + 1; - } /* end of if logical drive configured */ - } /* end of for log_unit */ - geo_ret: - kfree(id_ctlr_buf); - kfree(id_ldrive); - kfree(id_lstatus_buf); - kfree(sense_config_buf); -} diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h deleted file mode 100644 index 50e359b51443..000000000000 --- a/drivers/block/cpqarray.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Disk Array driver for Compaq SMART2 Controllers - * Copyright 1998 Compaq Computer 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, 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. - * - * Questions/Comments/Bugfixes to arrays@compaq.com - * - * If you want to make changes, improve or add functionality to this - * driver, you'll probably need the Compaq Array Controller Interface - * Specificiation (Document number ECG086/1198) - */ -#ifndef CPQARRAY_H -#define CPQARRAY_H - -#ifdef __KERNEL__ -#include -#include -#include -#include -#include -#include -#endif - -#include "ida_cmd.h" - -#define IO_OK 0 -#define IO_ERROR 1 -#define NWD 16 -#define NWD_SHIFT 4 - -#define IDA_TIMER (5*HZ) -#define IDA_TIMEOUT (10*HZ) - -#define MISC_NONFATAL_WARN 0x01 - -typedef struct { - unsigned blk_size; - unsigned nr_blks; - unsigned cylinders; - unsigned heads; - unsigned sectors; - int usage_count; -} drv_info_t; - -#ifdef __KERNEL__ -typedef struct { - int ctlr; - char devname[8]; - __u32 log_drv_map; - __u32 drv_assign_map; - __u32 drv_spare_map; - __u32 mp_failed_drv_map; - - char firm_rev[4]; - int product; - int ctlr_sig; - - int log_drives; - int phys_drives; - - __u32 board_id; - __u32 vaddr; - __u32 paddr; - __u32 ioaddr; - int intr; - int usage_count; - drv_info_t drv[NWD]; - int proc; - - cmdlist_t *reqQ; - cmdlist_t *cmpQ; - cmdlist_t *cmd_pool; - __u32 *cmd_pool_bits; - unsigned int Qdepth; - unsigned int maxQsinceinit; - - unsigned int nr_requests; - unsigned int nr_allocs; - unsigned int nr_frees; - struct timer_list timer; - unsigned int misc_tflags; -} ctlr_info_t; -#endif - -#endif /* CPQARRAY_H */ diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 331abc5c25d0..b0b02bd8e935 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -96,11 +96,6 @@ * features to asm/floppy.h. */ -/* - * 1999/02/23 -- Paul Slootman -- floppy stopped working on Alpha after 24 - * days, 6 hours, 32 minutes and 32 seconds (i.e. MAXINT jiffies; ints were - * being used to store jiffies, which are unsigned longs). - */ #define FLOPPY_SANITY_CHECK #undef FLOPPY_SILENT_DCL_CLEAR @@ -527,7 +522,7 @@ static unsigned char current_drive = 0; static long current_count_sectors = 0; static unsigned char sector_t; /* sector in track */ static unsigned char in_sector_offset; /* offset within physical sector, - * expressed in units of 512 bytes */ + * expressed in units of 512 bytes */ #ifndef fd_eject #define fd_eject(x) -EINVAL @@ -578,10 +573,10 @@ static void is_alive(const char *message) #define OLOGSIZE 20 static void (*lasthandler)(void) = NULL; -static unsigned long interruptjiffies=0; -static unsigned long resultjiffies=0; +static int interruptjiffies=0; +static int resultjiffies=0; static int resultsize=0; -static unsigned long lastredo=0; +static int lastredo=0; static struct output_log { unsigned char data; @@ -601,7 +596,7 @@ static void reschedule_timeout(int drive, const char *message, int marg) drive = current_drive; del_timer(&fd_timeout); if (drive < 0 || drive > N_DRIVE) { - fd_timeout.expires = jiffies + 20UL*HZ; + fd_timeout.expires = jiffies + 20*HZ; drive=0; } else fd_timeout.expires = jiffies + UDP->timeout; @@ -684,7 +679,7 @@ static int disk_change(int drive) #ifdef DCL_DEBUG if (UDP->flags & FD_DEBUG){ DPRINT("checking disk change line for drive %d\n",drive); - DPRINT("jiffies=%lu\n", jiffies); + DPRINT("jiffies=%ld\n", jiffies); DPRINT("disk change line=%x\n",fd_inb(FD_DIR)&0x80); DPRINT("flags=%x\n",UDRS->flags); } @@ -969,7 +964,7 @@ static void main_command_interrupt(void) } /* waits for a delay (spinup or select) to pass */ -static int wait_for_completion(unsigned long delay, timeout_fn function) +static int wait_for_completion(int delay, timeout_fn function) { if (FDCS->reset){ reset_fdc(); /* do the reset during sleep to win time @@ -1231,7 +1226,7 @@ static int fdc_configure(void) static void fdc_specify(void) { unsigned char spec1, spec2; - unsigned long srt, hlt, hut; + int srt, hlt, hut; unsigned long dtr = NOMINAL_DTR; unsigned long scale_dtr = NOMINAL_DTR; int hlt_max_code = 0x7f; @@ -1318,7 +1313,7 @@ static int fdc_dtr(void) * Pause 5 msec to avoid trouble. (Needs to be 2 jiffies) */ FDCS->dtr = raw_cmd->rate & 3; - return(wait_for_completion(jiffies+2UL*HZ/100, + return(wait_for_completion(jiffies+2*HZ/100, (timeout_fn) floppy_ready)); } /* fdc_dtr */ @@ -1414,8 +1409,7 @@ static int interpret_errors(void) */ static void setup_rw_floppy(void) { - int i,r, flags,dflags; - unsigned long ready_date; + int i,ready_date,r, flags,dflags; timeout_fn function; flags = raw_cmd->flags; @@ -1488,7 +1482,7 @@ static void seek_interrupt(void) #ifdef DCL_DEBUG if (DP->flags & FD_DEBUG){ DPRINT("clearing NEWCHANGE flag because of effective seek\n"); - DPRINT("jiffies=%lu\n", jiffies); + DPRINT("jiffies=%ld\n", jiffies); } #endif CLEARF(FD_DISK_NEWCHANGE); /* effective seek */ @@ -1768,20 +1762,20 @@ void show_floppy(void) printk("\n"); printk("floppy driver state\n"); printk("-------------------\n"); - printk("now=%lu last interrupt=%lu diff=%lu last called handler=%p\n", - jiffies, interruptjiffies, jiffies-interruptjiffies, lasthandler); + printk("now=%ld last interrupt=%d last called handler=%p\n", + jiffies, interruptjiffies, lasthandler); #ifdef FLOPPY_SANITY_CHECK printk("timeout_message=%s\n", timeout_message); printk("last output bytes:\n"); for (i=0; i < OLOGSIZE; i++) - printk("%2x %2x %lu\n", + printk("%2x %2x %ld\n", output_log[(i+output_log_pos) % OLOGSIZE].data, output_log[(i+output_log_pos) % OLOGSIZE].status, output_log[(i+output_log_pos) % OLOGSIZE].jiffies); - printk("last result at %lu\n", resultjiffies); - printk("last redo_fd_request at %lu\n", lastredo); + printk("last result at %d\n", resultjiffies); + printk("last redo_fd_request at %d\n", lastredo); for (i=0; icheckfreq < (int)(jiffies - UDRS->last_checked)) { + if (UDP->checkfreq < jiffies - UDRS->last_checked){ lock_fdc(drive,0); poll_drive(0,0); process_fd_request(); diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c index 3337424f670f..9a06577f5c63 100644 --- a/drivers/block/genhd.c +++ b/drivers/block/genhd.c @@ -86,6 +86,7 @@ char *disk_name (struct gendisk *hd, int minor, char *buf) maj = "hd"; } #endif +#ifdef CONFIG_BLK_DEV_DAC960 if (hd->major >= DAC960_MAJOR+0 && hd->major <= DAC960_MAJOR+7) { int controller = hd->major - DAC960_MAJOR; @@ -97,17 +98,6 @@ char *disk_name (struct gendisk *hd, int minor, char *buf) maj, controller, minor >> hd->minor_shift, partition); return buf; } -#if defined(CONFIG_BLK_CPQ_DA) || defined(CONFIG_BLK_CPQ_DA_MODULE) - if (hd->major >= COMPAQ_SMART2_MAJOR && hd->major <= COMPAQ_SMART2_MAJOR+7) { - int ctlr = hd->major - COMPAQ_SMART2_MAJOR; - int disk = minor >> hd->minor_shift; - int part = minor & (( 1 << hd->minor_shift) - 1); - if (part == 0) - sprintf(buf, "%s/c%dd%d", maj, ctlr, disk); - else - sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, disk, part); - return buf; - } #endif part = minor & ((1 << hd->minor_shift) - 1); if (part) @@ -122,13 +112,10 @@ static void add_partition (struct gendisk *hd, int minor, int start, int size) char buf[40]; hd->part[minor].start_sect = start; hd->part[minor].nr_sects = size; +#ifdef CONFIG_BLK_DEV_DAC960 if (hd->major >= DAC960_MAJOR+0 && hd->major <= DAC960_MAJOR+7) printk(" p%d", (minor & ((1 << hd->minor_shift) - 1))); else -#if defined(CONFIG_BLK_CPQ_DA) || defined(CONFIG_BLK_CPQ_DA_MODULE) - if (hd->major >= COMPAQ_SMART2_MAJOR && hd->major <= COMPAQ_SMART2_MAJOR+7) - printk(" p%d", (minor & ((1 << hd->minor_shift) - 1))); - else #endif printk(" %s", disk_name(hd, minor, buf)); } @@ -366,9 +353,7 @@ check_table: && (q->sector & 63) == 1 && (q->end_sector & 63) == 63) { unsigned int heads = q->end_head + 1; - if (heads == 32 || heads == 64 || - heads == 128 || heads == 240 || - heads == 255) { + if (heads == 32 || heads == 64 || heads == 128 || heads == 255) { (void) ide_xlate_1024(dev, heads, " [PTBL]"); break; @@ -769,7 +754,6 @@ static void setup_dev(struct gendisk *dev) void device_setup(void) { extern void console_map_init(void); - extern void cpqarray_init(void); struct gendisk *p; int nr=0; @@ -782,9 +766,6 @@ void device_setup(void) #ifdef CONFIG_SCSI scsi_dev_init(); #endif -#ifdef CONFIG_BLK_CPQ_DA - cpqarray_init(); -#endif #ifdef CONFIG_INET net_dev_init(); #endif diff --git a/drivers/block/hd.c b/drivers/block/hd.c index d5e432179bb2..605d63361a08 100644 --- a/drivers/block/hd.c +++ b/drivers/block/hd.c @@ -871,7 +871,6 @@ static int hd_ioctl(struct inode * inode, struct file * file, restore_flags(flags); return err; - case HDIO_OBSOLETE_IDENTITY: case HDIO_GET_IDENTITY: if (!arg) return -EINVAL; if (MINOR(inode->i_rdev) & 0x3F) return -EINVAL; diff --git a/drivers/block/ida_cmd.h b/drivers/block/ida_cmd.h deleted file mode 100644 index 87c2a9f60a5c..000000000000 --- a/drivers/block/ida_cmd.h +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Disk Array driver for Compaq SMART2 Controllers - * Copyright 1998 Compaq Computer 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, 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. - * - * Questions/Comments/Bugfixes to arrays@compaq.com - * - * If you want to make changes, improve or add functionality to this - * driver, you'll probably need the Compaq Array Controller Interface - * Specificiation (Document number ECG086/1198) - */ -#ifndef ARRAYCMD_H -#define ARRAYCMD_H - -#include -#if 0 -#include -#endif - - -#define COMMAND_FIFO 0x04 -#define COMMAND_COMPLETE_FIFO 0x08 -#define INTR_MASK 0x0C -#define INTR_STATUS 0x10 -#define INTR_PENDING 0x14 - -#define FIFO_NOT_EMPTY 0x01 -#define FIFO_NOT_FULL 0x02 - -#define BIG_PROBLEM 0x40 -#define LOG_NOT_CONF 2 - -#pragma pack(1) -typedef struct { - __u32 size; - __u32 addr; -} sg_t; - -#define RCODE_NONFATAL 0x02 -#define RCODE_FATAL 0x04 -#define RCODE_INVREQ 0x10 -typedef struct { - __u16 next; - __u8 cmd; - __u8 rcode; - __u32 blk; - __u16 blk_cnt; - __u8 sg_cnt; - __u8 reserved; -} rhdr_t; - -#define SG_MAX 32 -typedef struct { - rhdr_t hdr; - sg_t sg[SG_MAX]; - __u32 bp; -} rblk_t; - -typedef struct { - __u8 unit; - __u8 prio; - __u16 size; -} chdr_t; - -#define CMD_RWREQ 0x00 -#define CMD_IOCTL_PEND 0x01 -#define CMD_IOCTL_DONE 0x02 - -typedef struct cmdlist { - chdr_t hdr; - rblk_t req; - __u32 size; - int retry_cnt; - __u32 busaddr; - int ctlr; - struct cmdlist *prev; - struct cmdlist *next; - struct buffer_head *bh; - int type; -} cmdlist_t; - -#define ID_CTLR 0x11 -typedef struct { - __u8 nr_drvs; - __u32 cfg_sig; - __u8 firm_rev[4]; - __u8 rom_rev[4]; - __u8 hw_rev; - __u32 bb_rev; - __u32 drv_present_map; - __u32 ext_drv_map; - __u32 board_id; - __u8 cfg_error; - __u32 non_disk_bits; - __u8 bad_ram_addr; - __u8 cpu_rev; - __u8 pdpi_rev; - __u8 epic_rev; - __u8 wcxc_rev; - __u8 marketing_rev; - __u8 ctlr_flags; - __u8 host_flags; - __u8 expand_dis; - __u8 scsi_chips; - __u32 max_req_blocks; - __u32 ctlr_clock; - __u8 drvs_per_bus; - __u16 big_drv_present_map[8]; - __u16 big_ext_drv_map[8]; - __u16 big_non_disk_map[8]; - __u16 task_flags; - __u8 icl_bus; - __u8 red_modes; - __u8 cur_red_mode; - __u8 red_ctlr_stat; - __u8 red_fail_reason; - __u8 reserved[403]; -} id_ctlr_t; - -typedef struct { - __u16 cyl; - __u8 heads; - __u8 xsig; - __u8 psectors; - __u16 wpre; - __u8 maxecc; - __u8 drv_ctrl; - __u16 pcyls; - __u8 pheads; - __u16 landz; - __u8 sect_per_track; - __u8 cksum; -} drv_param_t; - -#define ID_LOG_DRV 0x10 -typedef struct { - __u16 blk_size; - __u32 nr_blks; - drv_param_t drv; - __u8 fault_tol; - __u8 reserved; - __u8 bios_disable; -} id_log_drv_t; - -#define ID_LOG_DRV_EXT 0x18 -typedef struct { - __u32 log_drv_id; - __u8 log_drv_label[64]; - __u8 reserved[418]; -} id_log_drv_ext_t; - -#define SENSE_LOG_DRV_STAT 0x12 -typedef struct { - __u8 status; - __u32 fail_map; - __u16 read_err[32]; - __u16 write_err[32]; - __u8 drv_err_data[256]; - __u8 drq_timeout[32]; - __u32 blks_to_recover; - __u8 drv_recovering; - __u16 remap_cnt[32]; - __u32 replace_drv_map; - __u32 act_spare_map; - __u8 spare_stat; - __u8 spare_repl_map[32]; - __u32 repl_ok_map; - __u8 media_exch; - __u8 cache_fail; - __u8 expn_fail; - __u8 unit_flags; - __u16 big_fail_map[8]; - __u16 big_remap_map[8]; - __u16 big_repl_map[8]; - __u16 big_act_spare_map[8]; - __u8 big_spar_repl_map[128]; - __u16 big_repl_ok_map[8]; - __u8 big_drv_rebuild; - __u8 reserved[36]; -} sense_log_drv_stat_t; - -#define START_RECOVER 0x13 - -#define ID_PHYS_DRV 0x15 -typedef struct { - __u8 scsi_bus; - __u8 scsi_id; - __u16 blk_size; - __u32 nr_blks; - __u32 rsvd_blks; - __u8 drv_model[40]; - __u8 drv_sn[40]; - __u8 drv_fw[8]; - __u8 scsi_iq_bits; - __u8 compaq_drv_stmp; - __u8 last_fail; - __u8 phys_drv_flags; - __u8 phys_drv_flags1; - __u8 scsi_lun; - __u8 phys_drv_flags2; - __u8 reserved; - __u32 spi_speed_rules; - __u8 phys_connector[2]; - __u8 phys_box_on_bus; - __u8 phys_bay_in_box; -} id_phys_drv_t; - -#define BLINK_DRV_LEDS 0x16 -typedef struct { - __u32 blink_duration; - __u32 reserved; - __u8 blink[256]; - __u8 reserved1[248]; -} blink_drv_leds_t; - -#define SENSE_BLINK_LEDS 0x17 -typedef struct { - __u32 blink_duration; - __u32 btime_elap; - __u8 blink[256]; - __u8 reserved1[248]; -} sense_blink_leds_t; - -#define IDA_READ 0x20 -#define IDA_WRITE 0x30 -#define IDA_WRITE_MEDIA 0x31 -#define RESET_TO_DIAG 0x40 -#define DIAG_PASS_THRU 0x41 - -#define SENSE_CONFIG 0x50 -#define SET_CONFIG 0x51 -typedef struct { - __u32 cfg_sig; - __u16 compat_port; - __u8 data_dist_mode; - __u8 surf_an_ctrl; - __u16 ctlr_phys_drv; - __u16 log_unit_phys_drv; - __u16 fault_tol_mode; - __u8 phys_drv_param[16]; - drv_param_t drv; - __u32 drv_asgn_map; - __u16 dist_factor; - __u32 spare_asgn_map; - __u8 reserved[6]; - __u16 os; - __u8 ctlr_order; - __u8 extra_info; - __u32 data_offs; - __u8 parity_backedout_write_drvs; - __u8 parity_dist_mode; - __u8 parity_shift_fact; - __u8 bios_disable_flag; - __u32 blks_on_vol; - __u32 blks_per_drv; - __u8 scratch[16]; - __u16 big_drv_map[8]; - __u16 big_spare_map[8]; - __u8 ss_source_vol; - __u8 mix_drv_cap_range; - struct { - __u16 big_drv_map[8]; - __u32 blks_per_drv; - __u16 fault_tol_mode; - __u16 dist_factor; - } MDC_range[4]; - __u8 reserved1[248]; -} config_t; - -#define BYPASS_VOL_STATE 0x52 -#define SS_CREATE_VOL 0x53 -#define CHANGE_CONFIG 0x54 -#define SENSE_ORIG_CONF 0x55 -#define REORDER_LOG_DRV 0x56 -typedef struct { - __u8 old_units[32]; -} reorder_log_drv_t; - -#define LABEL_LOG_DRV 0x57 -typedef struct { - __u8 log_drv_label[64]; -} label_log_drv_t; - -#define SS_TO_VOL 0x58 - -#define SET_SURF_DELAY 0x60 -typedef struct { - __u16 delay; - __u8 reserved[510]; -} surf_delay_t; - -#define SET_OVERHEAT_DELAY 0x61 -typedef struct { - __u16 delay; -} overhead_delay_t; - -#define SET_MP_DELAY -typedef struct { - __u16 delay; - __u8 reserved[510]; -} mp_delay_t; - -#define PASSTHRU_A 0x91 -typedef struct { - __u8 target; - __u8 bus; - __u8 lun; - __u32 timeout; - __u32 flags; - __u8 status; - __u8 error; - __u8 cdb_len; - __u8 sense_error; - __u8 sense_key; - __u32 sense_info; - __u8 sense_code; - __u8 sense_qual; - __u8 residual; - __u8 reserved[4]; - __u8 cdb[12]; -} scsi_param_t; - -#pragma pack() - -#endif /* ARRAYCMD_H */ diff --git a/drivers/block/ida_ioctl.h b/drivers/block/ida_ioctl.h deleted file mode 100644 index 633d69036eb8..000000000000 --- a/drivers/block/ida_ioctl.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Disk Array driver for Compaq SMART2 Controllers - * Copyright 1998 Compaq Computer 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, 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. - * - * Questions/Comments/Bugfixes to arrays@compaq.com - * - * If you want to make changes, improve or add functionality to this - * driver, you'll probably need the Compaq Array Controller Interface - * Specificiation (Document number ECG086/1198) - */ -#ifndef IDA_IOCTL_H -#define IDA_IOCTL_H - -#include "ida_cmd.h" -#include "cpqarray.h" - -#define IDAGETDRVINFO 0x27272828 -#define IDAPASSTHRU 0x28282929 -#define IDAGETCTLRSIG 0x29293030 -#define IDAREVALIDATEVOLS 0x30303131 - -/* - * Normally, the ioctl determines the logical unit for this command by - * the major,minor number of the fd passed to ioctl. If you need to send - * a command to a different/nonexistant unit (such as during config), you - * can override the normal behavior by setting the unit valid bit. (Normally, - * it should be zero) The controller to which the command is sent is still - * determined by the major number of the open device. - */ - -#define UNITVALID 0x80 -typedef struct { - __u8 cmd; - __u8 rcode; - __u8 unit; - -/* currently, sg_cnt is assumed to be 1: only the 0th element of sg is used */ - struct { - void *addr; - size_t size; - } sg[SG_MAX]; - int sg_cnt; - - union ctlr_cmds { - drv_info_t drv; - unsigned char buf[512]; - - id_ctlr_t id_ctlr; - drv_param_t drv_param; - id_log_drv_t id_log_drv; - id_log_drv_ext_t id_log_drv_ext; - sense_log_drv_stat_t sense_log_drv_stat; - id_phys_drv_t id_phys_drv; - blink_drv_leds_t blink_drv_leds; - sense_blink_leds_t sense_blink_leds; - config_t config; - reorder_log_drv_t reorder_log_drv; - label_log_drv_t label_log_drv; - surf_delay_t surf_delay; - overhead_delay_t overhead_delay; - mp_delay_t mp_delay; - scsi_param_t scsi_param; - } c; -} ida_ioctl_t; - -#endif /* IDA_IOCTL_H */ diff --git a/drivers/block/ide.c b/drivers/block/ide.c index f33f9e31c12e..90f21b48e330 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -277,12 +277,6 @@ * fix MC_ERR handling * fix mis-detection of NEC cdrom as floppy * issue ATAPI reset and re-probe after "no response" - * Version 5.53.3 changes by Andrew D. Balsa to enable DMA mode 2 and - * UDMA on SiS and TX chipsets. - * Version 5.53.4 moved Promise/33 auto-detection and DMA support - * to trition.c and added UDMA to current DMA support. - * update Promise Ultra33 and added AEC6210U/UF UDMA cards. - * add configuration flag to allow booting of either card. * * Some additional driver compile-time options are in ide.h * @@ -613,12 +607,8 @@ static int lba_capacity_is_ok (struct hd_driveid *id) unsigned long chs_sects = id->cyls * id->heads * id->sectors; unsigned long _10_percent = chs_sects / 10; - /* - * very large drives (8GB+) may lie about the number of cylinders - * This is a split test for drives 8 Gig and Bigger only. - */ - if ((id->lba_capacity >= 16514064) && (id->cyls == 0x3fff) && - (id->heads == 16) && (id->sectors == 63)) { + /* very large drives (8GB+) may lie about the number of cylinders */ + if (id->cyls == 16383 && id->heads == 16 && id->sectors == 63 && lba_sects > chs_sects) { id->cyls = lba_sects / (16 * 63); /* correct cyls */ return 1; /* lba_capacity is our only option */ } @@ -659,15 +649,6 @@ static unsigned long current_capacity (ide_drive_t *drive) drive->cyl = id->lba_capacity / (drive->head * drive->sect); capacity = id->lba_capacity; drive->select.b.lba = 1; -#if 0 - /* - * This is the correct place to perform this task; - * however, we do this later for reporting. - */ - if (*(int *)&id->cur_capacity0 != id->lba_capacity) { - *(int *)&id->cur_capacity0 = id->lba_capacity; - } -#endif } } return (capacity - drive->sect0); @@ -2211,18 +2192,17 @@ static int ide_ioctl (struct inode *inode, struct file *file, case HDIO_GET_MULTCOUNT: return write_fs_long(arg, drive->mult_count); - case HDIO_OBSOLETE_IDENTITY: case HDIO_GET_IDENTITY: if (!arg || (MINOR(inode->i_rdev) & PARTN_MASK)) return -EINVAL; if (drive->id == NULL) return -ENOMSG; - err = verify_area(VERIFY_WRITE, (char *)arg, (cmd == HDIO_GET_IDENTITY) ? sizeof(*drive->id) : 142); + err = verify_area(VERIFY_WRITE, (char *)arg, sizeof(*drive->id)); if (!err) - memcpy_tofs((char *)arg, (char *)drive->id, (cmd == HDIO_GET_IDENTITY) ? sizeof(*drive->id) : 142); + memcpy_tofs((char *)arg, (char *)drive->id, sizeof(*drive->id)); return err; - case HDIO_GET_NOWERR: + case HDIO_GET_NOWERR: return write_fs_long(arg, drive->bad_wstat == BAD_R_STAT); case HDIO_SET_DMA: @@ -2565,8 +2545,9 @@ static inline void do_identify (ide_drive_t *drive, byte cmd) drive->sect = drive->bios_sect = id->sectors; } /* Handle logical geometry translation by the drive */ - if ((id->field_valid & 1) && id->cur_cyls && - id->cur_heads && (id->cur_heads <= 16) && id->cur_sectors) { + if ((id->field_valid & 1) && id->cur_cyls && id->cur_heads + && (id->cur_heads <= 16) && id->cur_sectors) + { /* * Extract the physical drive geometry for our use. * Note that we purposely do *not* update the bios info. @@ -2591,38 +2572,19 @@ static inline void do_identify (ide_drive_t *drive, byte cmd) } } /* Use physical geometry if what we have still makes no sense */ - if ((!drive->head || drive->head > 16) && - id->heads && id->heads <= 16) { - if ((id->lba_capacity > 16514064) || (id->cyls == 0x3fff)) { - id->cyls = ((int)(id->lba_capacity/(id->heads * id->sectors))); - } - drive->cyl = id->cur_cyls = id->cyls; - drive->head = id->cur_heads = id->heads; - drive->sect = id->cur_sectors = id->sectors; + if ((!drive->head || drive->head > 16) && id->heads && id->heads <= 16) { + drive->cyl = id->cyls; + drive->head = id->heads; + drive->sect = id->sectors; } /* calculate drive capacity, and select LBA if possible */ - capacity = current_capacity (drive); + (void) current_capacity (drive); - /* - * if possible, give fdisk access to more of the drive, - * by correcting bios_cyls: - */ - if ((capacity >= (id->cyls * id->heads * id->sectors)) && - (!drive->forced_geom) && drive->bios_sect && drive->bios_head) { - drive->bios_cyl = (capacity / drive->bios_sect) / drive->bios_head; -#ifdef DEBUG - printk("FDISK Fixing Geometry :: CHS=%d/%d/%d to CHS=%d/%d/%d\n", - drive->id->cur_cyls, - drive->id->cur_heads, - drive->id->cur_sectors, - drive->bios_cyl, - drive->bios_head, - drive->bios_sect); -#endif - drive->id->cur_cyls = drive->bios_cyl; - drive->id->cur_heads = drive->bios_head; - drive->id->cur_sectors = drive->bios_sect; + /* Correct the number of cyls if the bios value is too small */ + if (drive->sect == drive->bios_sect && drive->head == drive->bios_head) { + if (drive->cyl > drive->bios_cyl) + drive->bios_cyl = drive->cyl; } if (!strncmp(id->model, "BMI ", 4) && @@ -2630,54 +2592,27 @@ static inline void do_identify (ide_drive_t *drive, byte cmd) drive->select.b.lba) drive->no_geom = 1; + printk ("%s: %.40s, %ldMB w/%dkB Cache, CHS=%d/%d/%d", + drive->name, id->model, current_capacity(drive)/2048L, id->buf_size/2, + drive->bios_cyl, drive->bios_head, drive->bios_sect); + drive->mult_count = 0; if (id->max_multsect) { -#ifdef CONFIG_IDEDISK_MULTI_MODE - id->multsect = ((id->max_multsect/2) > 1) ? id->max_multsect : 0; - id->multsect_valid = id->multsect ? 1 : 0; - drive->mult_req = id->multsect_valid ? id->max_multsect : INITIAL_MULT_COUNT; - drive->special.b.set_multmode = drive->mult_req ? 1 : 0; -#else /* original, pre IDE-NFG, per request of AC */ drive->mult_req = INITIAL_MULT_COUNT; if (drive->mult_req > id->max_multsect) drive->mult_req = id->max_multsect; if (drive->mult_req || ((id->multsect_valid & 1) && id->multsect)) drive->special.b.set_multmode = 1; -#endif } - - drive->no_io_32bit = id->dword_io ? 1 : 0; - if (drive->autotune != 2 && HWIF(drive)->dmaproc != NULL) { - (void) HWIF(drive)->dmaproc(ide_dma_check, drive); - } - - printk ("%s: %.40s, %ldMB w/%dkB Cache, CHS=%d/%d/%d", - drive->name, id->model, - capacity/2048L, id->buf_size/2, - drive->bios_cyl, drive->bios_head, drive->bios_sect); - if (drive->using_dma) { - if ((id->field_valid & 4) && (id->dma_ultra & (id->dma_ultra >> 8) & 7)) { - printk(", UDMA"); /* UDMA BIOS-enabled! */ - } else if (id->field_valid & 4) { - printk(", (U)DMA"); /* Can be BIOS-enabled! */ - } else { - printk(", DMA"); + if (!(HWIF(drive)->dmaproc(ide_dma_check, drive))) { + if ((id->field_valid & 4) && (id->dma_ultra & (id->dma_ultra >> 8) & 7)) + printk(", UDMA"); + else + printk(", DMA"); } } printk("\n"); - if (drive->select.b.lba) { - if (*(int *)&id->cur_capacity0 != id->lba_capacity) { -#ifdef DEBUG - printk(" CurSects=%d, LBASects=%d, ", - *(int *)&id->cur_capacity0, id->lba_capacity); -#endif - *(int *)&id->cur_capacity0 = id->lba_capacity; -#ifdef DEBUG - printk( "Fixed CurSects=%d\n", *(int *)&id->cur_capacity0); -#endif - } - } } /* @@ -3379,13 +3314,6 @@ done: * an IDE disk drive, or if a geometry was "forced" on the commandline. * Returns 1 if the geometry translation was successful. */ - -/* - * We update the values if the current CHS as determined by the kernel. - * This now allows for the hdparm tool to read the actual settings of the - * being used by the kernel. This removes the need for doing guess - * translations based on the raw values of the drive. - */ int ide_xlate_1024 (kdev_t i_rdev, int xparm, const char *msg) { ide_drive_t *drive; @@ -3393,42 +3321,14 @@ int ide_xlate_1024 (kdev_t i_rdev, int xparm, const char *msg) const byte *heads = head_vals; unsigned long tracks; - drive = get_info_ptr(i_rdev); - if (!drive) - return 0; - - if (drive->forced_geom) { - /* - * Update the current 3D drive values. - */ - drive->id->cur_cyls = drive->bios_cyl; - drive->id->cur_heads = drive->bios_head; - drive->id->cur_sectors = drive->bios_sect; + if ((drive = get_info_ptr(i_rdev)) == NULL || drive->forced_geom) return 0; - } - if (xparm > 1 && xparm <= drive->bios_head && drive->bios_sect == 63) { - /* - * Update the current 3D drive values. - */ - drive->id->cur_cyls = drive->bios_cyl; - drive->id->cur_heads = drive->bios_head; - drive->id->cur_sectors = drive->bios_sect; + if (xparm > 1 && xparm <= drive->bios_head && drive->bios_sect == 63) return 0; /* we already have a translation */ - } printk("%s ", msg); - if (xparm < 0 && (drive->bios_cyl * drive->bios_head * drive->bios_sect) < (1024 * 16 * 63)) { - /* - * Update the current 3D drive values. - */ - drive->id->cur_cyls = drive->bios_cyl; - drive->id->cur_heads = drive->bios_head; - drive->id->cur_sectors = drive->bios_sect; - return 0; /* small disk: no translation needed */ - } - if (drive->id) { drive->cyl = drive->id->cyls; drive->head = drive->id->heads; @@ -3466,12 +3366,6 @@ int ide_xlate_1024 (kdev_t i_rdev, int xparm, const char *msg) } drive->part[0].nr_sects = current_capacity(drive); printk("[%d/%d/%d]", drive->bios_cyl, drive->bios_head, drive->bios_sect); - /* - * Update the current 3D drive values. - */ - drive->id->cur_cyls = drive->bios_cyl; - drive->id->cur_heads = drive->bios_head; - drive->id->cur_sectors = drive->bios_sect; return 1; } @@ -3641,6 +3535,43 @@ static void ide_probe_pci (unsigned short vendor, unsigned short device, ide_pci } #endif /* defined(CONFIG_BLK_DEV_RZ1000) || defined(CONFIG_BLK_DEV_TRITON) */ + +static void ide_probe_promise_20246(void) +{ + byte fn, bus; + unsigned short io[6], count = 0; + unsigned int reg, tmp, i; + ide_hwif_t *hwif; + + memset(io, 0, 6 * sizeof(unsigned short)); + if (pcibios_find_device(PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20246, 0, &bus, &fn)) + return; + printk("ide: Promise Technology IDE Ultra-DMA 33 on PCI bus %d function %d\n", bus, fn); + for (reg = PCI_BASE_ADDRESS_0; reg <= PCI_BASE_ADDRESS_5; reg += 4) { + pcibios_read_config_dword(bus, fn, reg, &tmp); + if (tmp & PCI_BASE_ADDRESS_SPACE_IO) + io[count++] = tmp & PCI_BASE_ADDRESS_IO_MASK; + } + for (i = 2; i < 4; i++) { + hwif = ide_hwifs + i; + if (hwif->chipset == ide_generic) { + printk("ide%d: overridden with command line parameter\n", i); + return; + } + tmp = (i - 2) * 2; + if (!io[tmp] || !io[tmp + 1]) { + printk("ide%d: invalid port address %x, %x -- aborting\n", i, io[tmp], io[tmp + 1]); + return; + } + hwif->io_base = io[tmp]; + hwif->ctl_port = io[tmp + 1] + 2; + hwif->noprobe = 0; + } +#ifdef CONFIG_BLK_DEV_TRITON + ide_init_promise (bus, fn, &ide_hwifs[2], &ide_hwifs[3], io[4]); +#endif /* CONFIG_BLK_DEV_TRITON */ +} + #endif /* CONFIG_PCI */ /* @@ -3668,20 +3599,11 @@ static void probe_for_hwifs (void) * So instead, we search for PCI_DEVICE_ID_INTEL_82371_0, * and then add 1. */ -#ifdef CONFIG_BLK_DEV_OFFBOARD - ide_probe_pci (PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20246, &ide_init_triton, 0); - ide_probe_pci (PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP850UF, &ide_init_triton, 0); -#endif /* CONFIG_BLK_DEV_OFFBOARD */ ide_probe_pci (PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371_0, &ide_init_triton, 1); ide_probe_pci (PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_1, &ide_init_triton, 0); ide_probe_pci (PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB, &ide_init_triton, 0); - ide_probe_pci (PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_5513, &ide_init_triton, 0); - ide_probe_pci (PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, &ide_init_triton, 0); -#ifndef CONFIG_BLK_DEV_OFFBOARD - ide_probe_pci (PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20246, &ide_init_triton, 0); - ide_probe_pci (PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP850UF, &ide_init_triton, 0); -#endif /* CONFIG_BLK_DEV_OFFBOARD */ #endif /* CONFIG_BLK_DEV_TRITON */ + ide_probe_promise_20246(); } #endif /* CONFIG_PCI */ #ifdef CONFIG_BLK_DEV_CMD640 diff --git a/drivers/block/ide.h b/drivers/block/ide.h index fcdd70977eb2..5310ac8f92b9 100644 --- a/drivers/block/ide.h +++ b/drivers/block/ide.h @@ -429,7 +429,7 @@ typedef void (ide_selectproc_t) (ide_drive_t *); typedef enum { ide_unknown, ide_generic, ide_triton, ide_cmd640, ide_dtc2278, ide_ali14xx, ide_qd6580, ide_umc8672, ide_ht6560b, - ide_promise, ide_udma } + ide_promise, ide_promise_udma } hwif_chipset_t; typedef struct hwif_s { @@ -743,4 +743,5 @@ void idescsi_ide_release (struct inode *inode, struct file *filp, ide_drive_t *d #ifdef CONFIG_BLK_DEV_TRITON void ide_init_triton (byte, byte); +void ide_init_promise (byte bus, byte fn, ide_hwif_t *hwif0, ide_hwif_t *hwif1, unsigned short dma); #endif /* CONFIG_BLK_DEV_TRITON */ diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c index 7be11b300acd..1fb526b04b75 100644 --- a/drivers/block/ll_rw_blk.c +++ b/drivers/block/ll_rw_blk.c @@ -263,11 +263,6 @@ void add_request(struct blk_dev_struct * dev, struct request * req) short disk_index; switch (major) { - case DAC960_MAJOR+0: - disk_index = (minor & 0x00f8) >> 3; - if (disk_index < 4) - drive_stat_acct(req->cmd, req->nr_sectors, disk_index); - break; case SCSI_DISK_MAJOR: disk_index = (minor & 0x0070) >> 4; if (disk_index < 4) @@ -308,9 +303,10 @@ void add_request(struct blk_dev_struct * dev, struct request * req) if (scsi_blk_major(major)) (dev->request_fn)(); - if ( (major >= DAC960_MAJOR+0 && major <= DAC960_MAJOR+7) || - (major >= COMPAQ_SMART2_MAJOR+0 && major <= COMPAQ_SMART2_MAJOR+7)) +#ifdef CONFIG_BLK_DEV_DAC960 + if (major >= DAC960_MAJOR+0 && major <= DAC960_MAJOR+7) (dev->request_fn)(); +#endif sti(); } @@ -364,7 +360,7 @@ void make_request(int major,int rw, struct buffer_head * bh) lock_buffer(bh); if (blk_size[major]) - if (blk_size[major][MINOR(bh->b_rdev)] < (sector + count)>>1) { + if (blk_size[major][MINOR(bh->b_rdev)] < (sector + count)>>1) { bh->b_state &= (1 << BH_Lock) | (1 << BH_FreeOnIO); /* This may well happen - the kernel calls bread() without checking the size of the device, e.g., @@ -469,14 +465,6 @@ void make_request(int major,int rw, struct buffer_head * bh) case DAC960_MAJOR+5: case DAC960_MAJOR+6: case DAC960_MAJOR+7: - case COMPAQ_SMART2_MAJOR+0: - case COMPAQ_SMART2_MAJOR+1: - case COMPAQ_SMART2_MAJOR+2: - case COMPAQ_SMART2_MAJOR+3: - case COMPAQ_SMART2_MAJOR+4: - case COMPAQ_SMART2_MAJOR+5: - case COMPAQ_SMART2_MAJOR+6: - case COMPAQ_SMART2_MAJOR+7: do { if (req->sem) continue; diff --git a/drivers/block/paride/Config.in b/drivers/block/paride/Config.in index 8d4dc17426e6..00dd9c8e4b78 100644 --- a/drivers/block/paride/Config.in +++ b/drivers/block/paride/Config.in @@ -16,7 +16,6 @@ dep_tristate ' FIT TD-2000 protocol' CONFIG_PARIDE_FIT2 $CONFIG_PARIDE dep_tristate ' FIT TD-3000 protocol' CONFIG_PARIDE_FIT3 $CONFIG_PARIDE dep_tristate ' Shuttle EPAT/EPEZ protocol' CONFIG_PARIDE_EPAT $CONFIG_PARIDE dep_tristate ' Shuttle EPIA protocol' CONFIG_PARIDE_EPIA $CONFIG_PARIDE -dep_tristate ' Freecom IQ ASIC-2 protocol' CONFIG_PARIDE_FRIQ $CONFIG_PARIDE dep_tristate ' FreeCom power protocol' CONFIG_PARIDE_FRPW $CONFIG_PARIDE dep_tristate ' KingByte KBIC-951A/971A protocols' CONFIG_PARIDE_KBIC $CONFIG_PARIDE dep_tristate ' KT PHd protocol' CONFIG_PARIDE_KTTI $CONFIG_PARIDE diff --git a/drivers/block/paride/Makefile b/drivers/block/paride/Makefile index 32e85670409d..ae2d54dd9f56 100644 --- a/drivers/block/paride/Makefile +++ b/drivers/block/paride/Makefile @@ -147,15 +147,6 @@ else endif endif - -ifeq ($(CONFIG_PARIDE_FRIQ),y) - LX_OBJS += friq.o -else - ifeq ($(CONFIG_PARIDE_FRIQ),m) - M_OBJS += friq.o - endif -endif - ifeq ($(CONFIG_PARIDE_ON20),y) LX_OBJS += on20.o else diff --git a/drivers/block/paride/friq.c b/drivers/block/paride/friq.c deleted file mode 100644 index 37ebaa047976..000000000000 --- a/drivers/block/paride/friq.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - friq.c (c) 1998 Grant R. Guenther - Under the terms of the GNU public license - - friq.c is a low-level protocol driver for the Freecom "IQ" - parallel port IDE adapter. Early versions of this adapter - use the 'frpw' protocol. - - Freecom uses this adapter in a battery powered external - CD-ROM drive. It is also used in LS-120 drives by - Maxell and Panasonic, and other devices. - - The battery powered drive requires software support to - control the power to the drive. This module enables the - drive power when the high level driver (pcd) is loaded - and disables it when the module is unloaded. Note, if - the friq module is built in to the kernel, the power - will never be switched off, so other means should be - used to conserve battery power. - -*/ - -/* Changes: - - 1.01 GRG 1998.12.20 Added support for soft power switch -*/ - -#define FRIQ_VERSION "1.01" - -#include -#include -#include -#include -#include - -#include "paride.h" - -#define CMD(x) w2(4);w0(0xff);w0(0xff);w0(0x73);w0(0x73);\ - w0(0xc9);w0(0xc9);w0(0x26);w0(0x26);w0(x);w0(x); - -#define j44(l,h) (((l>>4)&0x0f)|(h&0xf0)) - -/* cont = 0 - access the IDE register file - cont = 1 - access the IDE command set -*/ - -static int cont_map[2] = { 0x08, 0x10 }; - -static int friq_read_regr( PIA *pi, int cont, int regr ) - -{ int h,l,r; - - r = regr + cont_map[cont]; - - CMD(r); - w2(6); l = r1(); - w2(4); h = r1(); - w2(4); - - return j44(l,h); - -} - -static void friq_write_regr( PIA *pi, int cont, int regr, int val) - -{ int r; - - r = regr + cont_map[cont]; - - CMD(r); - w0(val); - w2(5);w2(7);w2(5);w2(4); -} - -static void friq_read_block_int( PIA *pi, char * buf, int count, int regr ) - -{ int h, l, k, ph; - - switch(pi->mode) { - - case 0: CMD(regr); - for (k=0;kmode) { - - case 0: - case 1: CMD(8); w2(5); - for (k=0;ksaved_r0 = r0(); - pi->saved_r2 = r2(); - w2(4); -} - -static void friq_disconnect ( PIA *pi ) - -{ CMD(0x20); - w0(pi->saved_r0); - w2(pi->saved_r2); -} - -static int friq_test_proto( PIA *pi, char * scratch, int verbose ) - -{ int j, k, r; - int e[2] = {0,0}; - - pi->saved_r0 = r0(); - w0(0xff); udelay(20); CMD(0x3d); /* turn the power on */ - udelay(500); - w0(pi->saved_r0); - - friq_connect(pi); - for (j=0;j<2;j++) { - friq_write_regr(pi,0,6,0xa0+j*0x10); - for (k=0;k<256;k++) { - friq_write_regr(pi,0,2,k^0xaa); - friq_write_regr(pi,0,3,k^0x55); - if (friq_read_regr(pi,0,2) != (k^0xaa)) e[j]++; - } - } - friq_disconnect(pi); - - friq_connect(pi); - friq_read_block_int(pi,scratch,512,0x10); - r = 0; - for (k=0;k<128;k++) if (scratch[k] != k) r++; - friq_disconnect(pi); - - if (verbose) { - printk("%s: friq: port 0x%x, mode %d, test=(%d,%d,%d)\n", - pi->device,pi->port,pi->mode,e[0],e[1],r); - } - - return (r || (e[0] && e[1])); -} - - -static void friq_log_adapter( PIA *pi, char * scratch, int verbose ) - -{ char *mode_string[6] = {"4-bit","8-bit", - "EPP-8","EPP-16","EPP-32"}; - - printk("%s: friq %s, Freecom IQ ASIC-2 adapter at 0x%x, ", pi->device, - FRIQ_VERSION,pi->port); - printk("mode %d (%s), delay %d\n",pi->mode, - mode_string[pi->mode],pi->delay); - - pi->private = 1; - friq_connect(pi); - CMD(0x9e); /* disable sleep timer */ - friq_disconnect(pi); - -} - -static void friq_init_proto( PIA *pi) - -{ MOD_INC_USE_COUNT; - pi->private = 0; -} - -static void friq_release_proto( PIA *pi) - -{ if (pi->private) { /* turn off the power */ - friq_connect(pi); - CMD(0x1d); CMD(0x1e); - friq_disconnect(pi); - pi->private = 0; - } - - MOD_DEC_USE_COUNT; -} - -struct pi_protocol friq = {"friq",0,5,2,1,1, - friq_write_regr, - friq_read_regr, - friq_write_block, - friq_read_block, - friq_connect, - friq_disconnect, - 0, - 0, - friq_test_proto, - friq_log_adapter, - friq_init_proto, - friq_release_proto - }; - - -#ifdef MODULE - -int init_module(void) - -{ return pi_register( &friq ) - 1; -} - -void cleanup_module(void) - -{ pi_unregister( &friq ); -} - -#endif - -/* end of friq.c */ diff --git a/drivers/block/paride/frpw.c b/drivers/block/paride/frpw.c index 5e87ad045f11..b838a8e0b6c9 100644 --- a/drivers/block/paride/frpw.c +++ b/drivers/block/paride/frpw.c @@ -5,12 +5,6 @@ frpw.c is a low-level protocol driver for the Freecom "Power" parallel port IDE adapter. - Some applications of this adapter may require a "printer" reset - prior to loading the driver. This can be done by loading and - unloading the "lp" driver, or it can be done by this driver - if you define FRPW_HARD_RESET. The latter is not recommended - as it may upset devices on other ports. - */ /* Changes: @@ -19,11 +13,10 @@ fix chip detect added EPP-16 and EPP-32 1.02 GRG 1998.09.23 added hard reset to initialisation process - 1.03 GRG 1998.12.14 made hard reset conditional */ -#define FRPW_VERSION "1.03" +#define FRPW_VERSION "1.02" #include #include @@ -192,10 +185,8 @@ static int frpw_test_pnp ( PIA *pi ) { int olddelay, a, b; -#ifdef FRPW_HARD_RESET w0(0); w2(8); udelay(50); w2(0xc); /* parallel bus reset */ udelay(1500000); -#endif olddelay = pi->delay; pi->delay = 10; diff --git a/drivers/block/paride/jumbo b/drivers/block/paride/jumbo index f4b8ebf75ef1..b952fde92b32 100644 --- a/drivers/block/paride/jumbo +++ b/drivers/block/paride/jumbo @@ -53,11 +53,11 @@ FPROTO=-DCONFIG_PARIDE_`echo "$PROTO" | tr [a-z] [A-Z]` FK="-D__KERNEL__ -I ../../../include" FLCH=-D_LINUX_CONFIG_H # -echo cc $FK $FSMP $FLCH $FPARP $FPROTO $FMODV -Wall -O2 -o Jb.o -c paride.c -cc $FK $FSMP $FLCH $FPARP $FPROTO $FMODV -Wall -O2 -o Jb.o -c paride.c +echo cc $FK $FSMP $FLCH $FPARP $FPROTO -Wall -O2 -o Jb.o -c paride.c +cc $FK $FSMP $FLCH $FPARP $FPROTO -Wall -O2 -o Jb.o -c paride.c # -echo cc $FK $FSMP $FMODV -Wall -O2 -o Jp.o -c $PROTO.c -cc $FK $FSMP $FMODV -Wall -O2 -o Jp.o -c $PROTO.c +echo cc $FK $FSMP -Wall -O2 -o Jp.o -c $PROTO.c +cc $FK $FSMP -Wall -O2 -o Jp.o -c $PROTO.c # echo cc $FK $FSMP $FMODV -DMODULE -DPARIDE_JUMBO -Wall -O2 -o Jd.o -c $HLD.c cc $FK $FSMP $FMODV -DMODULE -DPARIDE_JUMBO -Wall -O2 -o Jd.o -c $HLD.c diff --git a/drivers/block/paride/on26.c b/drivers/block/paride/on26.c index d1e85cd28edb..78477593e545 100644 --- a/drivers/block/paride/on26.c +++ b/drivers/block/paride/on26.c @@ -11,12 +11,10 @@ 1.01 GRG 1998.05.06 init_proto, release_proto 1.02 GRG 1998.09.23 updates for the -E rev chip - 1.03 GRG 1998.12.14 fix for slave drives - 1.04 GRG 1998.12.20 yet another bug fix */ -#define ON26_VERSION "1.04" +#define ON26_VERSION "1.02" #include #include @@ -120,11 +118,9 @@ static void on26_disconnect ( PIA *pi ) w2(pi->saved_r2); } -#define RESET_WAIT 200 - static int on26_test_port( PIA *pi) /* hard reset */ -{ int i, m, d, x, y; +{ int i, m, d; pi->saved_r0 = r0(); pi->saved_r2 = r2(); @@ -155,18 +151,11 @@ static int on26_test_port( PIA *pi) /* hard reset */ on26_write_regr(pi,0,6,0xa0); - for (i=0;i #include @@ -451,11 +449,6 @@ void paride_init( void ) pi_register(&frpw); }; #endif -#ifdef CONFIG_PARIDE_FRIQ - { extern struct pi_protocol friq; - pi_register(&friq); - }; -#endif #ifdef CONFIG_PARIDE_FIT2 { extern struct pi_protocol fit2; pi_register(&fit2); diff --git a/drivers/block/paride/pseudo.h b/drivers/block/paride/pseudo.h index 3d0d1c1a07a8..97d6fdbcd7f3 100644 --- a/drivers/block/paride/pseudo.h +++ b/drivers/block/paride/pseudo.h @@ -16,21 +16,19 @@ when either it returns true, or timeout jiffies have passed, continuation() will be invoked. - If nice is 1, the test will done approximately once a + If nice is true, the test will done approximately once a jiffy. If nice is 0, the test will also be done whenever - the scheduler runs (by adding it to a task queue). If - nice is greater than 1, the test will be done once every - (nice-1) jiffies. + the scheduler runs (by adding it to a task queue). */ /* Changes: 1.01 1998.05.03 Switched from cli()/sti() to spinlocks - 1.02 1998.12.14 Added support for nice > 1 + */ -#define PS_VERSION "1.02" +#define PS_VERSION "1.01" #include #include @@ -39,13 +37,13 @@ static void ps_timer_int( unsigned long data); static void ps_tq_int( void *data); +static int ps_use_tq = 1; static void (* ps_continuation)(void); static int (* ps_ready)(void); static int ps_then; static int ps_timeout; static int ps_timer_active = 0; static int ps_tq_active = 0; -static int ps_nice = 0; /* static spinlock_t ps_spinlock = SPIN_LOCK_UNLOCKED; */ @@ -64,9 +62,9 @@ static void ps_set_intr( void (*continuation)(void), ps_ready = ready; ps_then = jiffies; ps_timeout = jiffies + timeout; - ps_nice = nice; + ps_use_tq = !nice; - if (!ps_nice && !ps_tq_active) { + if (ps_use_tq && !ps_tq_active) { #ifdef HAVE_DISABLE_HLT disable_hlt(); #endif @@ -76,7 +74,7 @@ static void ps_set_intr( void (*continuation)(void), if (!ps_timer_active) { ps_timer_active = 1; - ps_timer.expires = jiffies + (ps_nice>0)?(ps_nice-1):0; + ps_timer.expires = jiffies; add_timer(&ps_timer); } @@ -138,7 +136,7 @@ static void ps_timer_int( unsigned long data) return; } ps_timer_active = 1; - ps_timer.expires = jiffies + (ps_nice>0)?(ps_nice-1):0; + ps_timer.expires = jiffies; add_timer(&ps_timer); spin_unlock_irqrestore(&ps_spinlock,flags); } diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c index 7a6b1e7f551e..2a541922ffee 100644 --- a/drivers/block/paride/pt.c +++ b/drivers/block/paride/pt.c @@ -464,7 +464,7 @@ static int pt_poll_dsc( int unit, int pause, int tmo, char *msg ) { int k, e, s; - k = 0; e = 0; s = 0; + k = 0; while (k < tmo) { pt_sleep(pause); k++; diff --git a/drivers/block/proc_array.c b/drivers/block/proc_array.c deleted file mode 100644 index 403aaf24b60f..000000000000 --- a/drivers/block/proc_array.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Taken from linux/fs/proc/net.c - * - * Copyright (C) 1991, 1992 Linus Torvalds - * - * gjh 3/'93 heim@peanuts.informatik.uni-tuebingen.de (Gerald J. Heim) - * most of this file is stolen from base.c - * it works, but you shouldn't use it as a guideline - * for new proc-fs entries. once i'll make it better. - * fvk 3/'93 waltje@uwalt.nl.mugnet.org (Fred N. van Kempen) - * cleaned up the whole thing, moved "net" specific code to - * the NET kernel layer (where it belonged in the first place). - * Michael K. Johnson (johnsonm@stolaf.edu) 3/93 - * Added support from my previous inet.c. Cleaned things up - * quite a bit, modularized the code. - * fvk 4/'93 waltje@uwalt.nl.mugnet.org (Fred N. van Kempen) - * Renamed "route_get_info()" to "rt_get_info()" for consistency. - * Alan Cox (gw4pts@gw4pts.ampr.org) 4/94 - * Dusted off the code and added IPX. Fixed the 4K limit. - * Erik Schoenfelder (schoenfr@ibr.cs.tu-bs.de) - * /proc/net/snmp. - * Alan Cox (gw4pts@gw4pts.ampr.org) 1/95 - * Added Appletalk slots - * - * proc diskarray directory handling functions - */ -#include -#include -#include -#include -#include -#include - -#include - -#define PROC_BLOCK_SIZE (3*1024) /* 4K page size but our output routines use some slack for overruns */ - -static int proc_readdiskarray(struct inode * inode, struct file * file, - char * buf, int count) -{ - char * page; - int bytes=count; - int copied=0; - char *start; - struct proc_dir_entry * dp; - - if (count < 0) - return -EINVAL; - dp = (struct proc_dir_entry *) inode->u.generic_ip; - if (!(page = (char*) __get_free_page(GFP_KERNEL))) - return -ENOMEM; - - while (bytes>0) - { - int length, thistime=bytes; - if (bytes > PROC_BLOCK_SIZE) - thistime=PROC_BLOCK_SIZE; - - length = dp->get_info(page, &start, - file->f_pos, - thistime, (int)dp); - - /* - * We have been given a non page aligned block of - * the data we asked for + a bit. We have been given - * the start pointer and we know the length.. - */ - - if (length <= 0) - break; - /* - * Copy the bytes - */ - memcpy_tofs(buf+copied, start, length); - file->f_pos += length; /* Move down the file */ - bytes -= length; - copied += length; - if (length for researching this). + * + * And, yes, Intel Zappa boards really *do* use the Triton IDE ports. */ - #include #include #include @@ -31,13 +120,6 @@ #include "ide.h" #undef DISPLAY_TRITON_TIMINGS /* define this to display timings */ -#undef DISPLAY_APOLLO_TIMINGS /* define this for extensive debugging information */ - -#if defined(CONFIG_PROC_FS) && defined(DISPLAY_APOLLO_TIMINGS) -#include -#include -#include -#endif /* * good_dma_drives() lists the model names (from "hdparm -i") @@ -49,27 +131,6 @@ const char *good_dma_drives[] = {"Micropolis 2112A", "CONNER CTT8000-A", NULL}; -/* - * bad_dma_drives() lists the model names (from "hdparm -i") - * of drives which supposedly support (U)DMA but which are - * known to corrupt data with this interface under Linux. - * - * Note: the list was generated by statistical analysis of problem - * reports. It's not clear if there are problems with the drives, - * or with some combination of drive/controller or what. - * - * You can forcibly override this if you wish. This is the kernel - * 'Tread carefully' list. - * - * Finally see http://www.wdc.com/quality/err-rec.html if you have - * one of the listed drives. - */ -const char *bad_dma_drives[] = {"WDC AC11000H", - "WDC AC22100H", - "WDC AC32500H", - "WDC AC33100H", - NULL}; - /* * Our Physical Region Descriptor (PRD) table should be large enough * to handle the biggest I/O request we are likely to see. Since requests @@ -89,7 +150,6 @@ const char *bad_dma_drives[] = {"WDC AC11000H", #define PRD_BYTES 8 #define PRD_ENTRIES (PAGE_SIZE / (2 * PRD_BYTES)) #define DEFAULT_BMIBA 0xe800 /* in case BIOS did not init it */ -#define DEFAULT_BMCRBA 0xcc00 /* VIA's default value */ /* * dma_intr() is the handler for disk read/write DMA interrupts @@ -101,8 +161,8 @@ static void dma_intr (ide_drive_t *drive) struct request *rq = HWGROUP(drive)->rq; unsigned short dma_base = HWIF(drive)->dma_base; - outb(inb(dma_base)&~1, dma_base); /* stop DMA operation */ dma_stat = inb(dma_base+2); /* get DMA status */ + outb(inb(dma_base)&~1, dma_base); /* stop DMA operation */ stat = GET_STAT(); /* get drive status */ if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { if ((dma_stat & 7) == 4) { /* verify good DMA status */ @@ -184,37 +244,23 @@ static int build_dmatable (ide_drive_t *drive) return 1; /* let the PIO routines handle this weirdness */ } -/* - * We will only enable drives with multi-word (mode2) (U)DMA capabilities, - * and ignore the very rare cases of drives that can only do single-word - * (modes 0 & 1) (U)DMA transfers. We also discard "blacklisted" hard disks. - */ static int config_drive_for_dma (ide_drive_t *drive) { const char **list; struct hd_driveid *id = drive->id; if (id && (id->capability & 1)) { - /* Consult the list of known "bad" drives */ - list = bad_dma_drives; - while (*list) { - if (!strcmp(*list++,id->model)) { - drive->using_dma = 0; /* no DMA */ - printk("ide: Disabling DMA modes on %s drive (%s).\n", drive->name, id->model); - return 1; /* DMA disabled */ - } - } - /* Enable DMA on any drive that has mode 2 UltraDMA enabled */ + /* Enable DMA on any drive that has UltraDMA (mode 0/1/2) enabled */ if (id->field_valid & 4) /* UltraDMA */ - if ((id->dma_ultra & 0x404) == 0x404) { + if ((id->dma_ultra & (id->dma_ultra >> 8) & 7)) { drive->using_dma = 1; - return 0; /* DMA enabled */ + return 0; /* dma enabled */ } - /* Enable DMA on any drive that has mode2 DMA enabled */ + /* Enable DMA on any drive that has mode2 DMA (multi or single) enabled */ if (id->field_valid & 2) /* regular DMA */ - if ((id->dma_mword & 0x404) == 0x404) { + if ((id->dma_mword & 0x404) == 0x404 || (id->dma_1word & 0x404) == 0x404) { drive->using_dma = 1; - return 0; /* DMA enabled */ + return 0; /* dma enabled */ } /* Consult the list of known "good" drives */ list = good_dma_drives; @@ -340,136 +386,23 @@ static void init_triton_dma (ide_hwif_t *hwif, unsigned short base) printk("\n"); } -/* - * Set VIA Chipset Timings for (U)DMA modes enabled. - */ -static int set_via_timings (byte bus, byte fn, byte post, byte flush) -{ - byte via_config = 0; - int rc = 0; - - /* setting IDE read prefetch buffer and IDE post write buffer */ - if ((rc = pcibios_read_config_byte(bus, fn, 0x41, &via_config))) - return (1); - if ((rc = pcibios_write_config_byte(bus, fn, 0x41, via_config | post))) - return (1); - - /* setting Channel read and End-of-sector FIFO flush: */ - if ((rc = pcibios_read_config_byte(bus, fn, 0x46, &via_config))) - return (1); - if ((rc = pcibios_write_config_byte(bus, fn, 0x46, via_config | flush))) - return (1); - - return (0); -} - /* * ide_init_triton() prepares the IDE driver for DMA operation. * This routine is called once, from ide.c during driver initialization, - * for each BM-DMA chipset which is found (rarely more than one). + * for each triton chipset which is found (unlikely to be more than one). */ void ide_init_triton (byte bus, byte fn) { int rc = 0, h; int dma_enabled = 0; - unsigned short io[6], count = 0, step_count = 0; - unsigned short pcicmd, vendor, device, class; - unsigned int bmiba, timings, reg, tmp; - unsigned int addressbios = 0; - -#ifdef DISPLAY_APOLLO_TIMINGS - bmide_bus = bus; - bmide_fn = fn; -#endif /* DISPLAY_APOLLO_TIMINGS */ - -/* - * We pick up the vendor, device, and class info for selecting the correct - * controller that is supported. Since we can access this routine more than - * once with the use of onboard and off-board EIDE controllers, a method - * of determining "who is who for what" is needed. - */ - - pcibios_read_config_word (bus, fn, PCI_VENDOR_ID, &vendor); - pcibios_read_config_word (bus, fn, PCI_DEVICE_ID, &device); - pcibios_read_config_word (bus, fn, PCI_CLASS_DEVICE, &class); - - switch(vendor) { - case PCI_VENDOR_ID_INTEL: - printk("ide: Intel 82371 (single FIFO) DMA Bus Mastering IDE "); - break; - case PCI_VENDOR_ID_SI: - printk("ide: SiS 5513 (dual FIFO) DMA Bus Mastering IDE "); - break; - case PCI_VENDOR_ID_VIA: - printk("ide: VIA VT82C586B (split FIFO) UDMA Bus Mastering IDE "); - break; - case PCI_VENDOR_ID_PROMISE: - /* PCI_CLASS_STORAGE_RAID == class */ - /* - * I have been able to make my Promise Ultra33 UDMA card change class. - * It has reported as both PCI_CLASS_STORAGE_RAID and PCI_CLASS_STORAGE_IDE. - * Since the PCI_CLASS_STORAGE_RAID mode should automatically mirror the - * two halves of the PCI_CONFIG register data, but sometimes it forgets. - * Thus we guarantee that they are identical, with a quick check and - * correction if needed. - * PDC20246 (primary) PDC20247 (secondary) IDE hwif's. - * - * Note that Promise "stories,fibs,..." about this device not being - * capable of ATAPI and AT devices. - */ - if (PCI_CLASS_STORAGE_RAID == class) { - unsigned char irq1 = 0, irq2 = 0; - pcibios_read_config_byte (bus, fn, PCI_INTERRUPT_LINE, &irq1); - pcibios_read_config_byte (bus, fn, (PCI_INTERRUPT_LINE)|0x80, &irq2); - if (irq1 != irq2) { - pcibios_write_config_byte(bus, fn, (PCI_INTERRUPT_LINE)|0x80, irq1); - } - } - case PCI_VENDOR_ID_ARTOP: - /* PCI_CLASS_STORAGE_SCSI == class */ - /* - * I have found that by stroking rom_enable_bit on both the AEC6210U/UF and - * PDC20246 controller cards, the features desired are almost guaranteed - * to be enabled and compatible. This ROM may not be registered in the - * config data, but it can be turned on. Registration failure has only - * been observed if and only if Linux sets up the pci_io_address in the - * 0x6000 range. If they are setup in the 0xef00 range it is reported. - * WHY??? got me......... - */ - printk("ide: %s UDMA Bus Mastering ", - (vendor == PCI_VENDOR_ID_ARTOP) ? "AEC6210" : "PDC20246"); - pcibios_read_config_dword(bus, fn, PCI_ROM_ADDRESS, &addressbios); - if (addressbios) { - pcibios_write_config_byte(bus, fn, PCI_ROM_ADDRESS, addressbios | PCI_ROM_ADDRESS_ENABLE); - printk("with ROM enabled at 0x%08x", addressbios); - } - /* - * This was stripped out of 2.1.XXX kernel code and parts from a patch called - * promise_update. This finds the PCI_BASE_ADDRESS spaces and makes them - * available for configuration later. - * PCI_BASE_ADDRESS_0 hwif0->io_base - * PCI_BASE_ADDRESS_1 hwif0->ctl_port - * PCI_BASE_ADDRESS_2 hwif1->io_base - * PCI_BASE_ADDRESS_3 hwif1->ctl_port - * PCI_BASE_ADDRESS_4 bmiba - */ - memset(io, 0, 6 * sizeof(unsigned short)); - for (reg = PCI_BASE_ADDRESS_0; reg <= PCI_BASE_ADDRESS_5; reg += 4) { - pcibios_read_config_dword(bus, fn, reg, &tmp); - if (tmp & PCI_BASE_ADDRESS_SPACE_IO) - io[count++] = tmp & PCI_BASE_ADDRESS_IO_MASK; - } - break; - default: - return; - } - - printk("\n Controller on PCI bus %d function %d\n", bus, fn); + unsigned short pcicmd; + unsigned int bmiba, timings; + printk("ide: i82371 PIIX (Triton) on PCI bus %d function %d\n", bus, fn); /* * See if IDE and BM-DMA features are enabled: */ - if ((rc = pcibios_read_config_word(bus, fn, PCI_COMMAND, &pcicmd))) + if ((rc = pcibios_read_config_word(bus, fn, 0x04, &pcicmd))) goto quit; if ((pcicmd & 1) == 0) { printk("ide: ports are not enabled (BIOS)\n"); @@ -483,21 +416,21 @@ void ide_init_triton (byte bus, byte fn) */ int try_again = 1; do { - if ((rc = pcibios_read_config_dword(bus, fn, PCI_BASE_ADDRESS_4, &bmiba))) + if ((rc = pcibios_read_config_dword(bus, fn, 0x20, &bmiba))) goto quit; bmiba &= 0xfff0; /* extract port base address */ if (bmiba) { dma_enabled = 1; break; } else { - printk("ide: BM-DMA base register is invalid (0x%04x, PnP BIOS problem)\n", bmiba); - if (inb(((vendor == PCI_VENDOR_ID_VIA) ? DEFAULT_BMCRBA : DEFAULT_BMIBA)) != 0xff || !try_again) + printk("ide: BM-DMA base register is invalid (0x%04x, PnP BIOS problem)\n", bmiba); + if (inb(DEFAULT_BMIBA) != 0xff || !try_again) break; - printk("ide: setting BM-DMA base register to 0x%04x\n", ((vendor == PCI_VENDOR_ID_VIA) ? DEFAULT_BMCRBA : DEFAULT_BMIBA)); - if ((rc = pcibios_write_config_word(bus, fn, PCI_COMMAND, pcicmd&~1))) + printk("ide: setting BM-DMA base register to 0x%04x\n", DEFAULT_BMIBA); + if ((rc = pcibios_write_config_word(bus, fn, 0x04, pcicmd&~1))) goto quit; - rc = pcibios_write_config_dword(bus, fn, 0x20, ((vendor == PCI_VENDOR_ID_VIA) ? DEFAULT_BMCRBA : DEFAULT_BMIBA)|1); - if (pcibios_write_config_word(bus, fn, PCI_COMMAND, pcicmd|5) || rc) + rc = pcibios_write_config_dword(bus, fn, 0x20, DEFAULT_BMIBA|1); + if (pcibios_write_config_word(bus, fn, 0x04, pcicmd|5) || rc) goto quit; } } while (try_again--); @@ -506,218 +439,89 @@ void ide_init_triton (byte bus, byte fn) /* * See if ide port(s) are enabled */ - if ((rc = pcibios_read_config_dword(bus, fn, - (vendor == PCI_VENDOR_ID_PROMISE) ? 0x50 : - (vendor == PCI_VENDOR_ID_ARTOP) ? 0x54 : - 0x40, &timings))) + if ((rc = pcibios_read_config_dword(bus, fn, 0x40, &timings))) goto quit; - /* - * We do a vendor check since the Ultra33 and AEC6210 - * holds their timings in a different location. - */ - printk("ide: timings == %08x\n", timings); - - /* - * The switch preserves some stuff that was original. - */ - switch(vendor) { - case PCI_VENDOR_ID_INTEL: - if (!(timings & 0x80008000)) { - printk("ide: INTEL: neither port is enabled\n"); - goto quit; - } - break; - case PCI_VENDOR_ID_VIA: - if(!(timings & 0x03)) { - printk("ide: VIA: neither port is enabled\n"); - goto quit; - } - break; - case PCI_VENDOR_ID_SI: - case PCI_VENDOR_ID_PROMISE: - case PCI_VENDOR_ID_ARTOP: - default: - break; - } + if (!(timings & 0x80008000)) { + printk("ide: neither port is enabled\n"); + goto quit; + } /* * Save the dma_base port addr for each interface */ for (h = 0; h < MAX_HWIFS; ++h) { - ide_hwif_t *hwif = &ide_hwifs[h]; - - /* - * This prevents the first contoller from accidentally - * initalizing the hwif's that it does not use and block - * an off-board ide-pci from getting in the game. - */ - if (step_count >= 2) { - goto quit; - } -#ifdef CONFIG_BLK_DEV_OFFBOARD - /* - * This is a forced override for the onboard ide controller - * to be enabled, if one chooses to have an offboard ide-pci - * card as the primary booting device. This beasty is - * for offboard UDMA upgrades with hard disks, but saving - * the onboard DMA2 controllers for CDROMS, TAPES, ZIPS, etc... - */ - if ((vendor == PCI_VENDOR_ID_INTEL) || - (vendor == PCI_VENDOR_ID_SI) || - (vendor == PCI_VENDOR_ID_VIA)) { - if (h == 2) { - hwif->io_base = 0x1f0; - hwif->ctl_port = 0x3f6; - hwif->irq = 14; - hwif->noprobe = 0; - } - if (h == 3) { - hwif->io_base = 0x170; - hwif->ctl_port = 0x376; - hwif->irq = 15; - hwif->noprobe = 0; - } - } -#endif /* CONFIG_BLK_DEV_OFFBOARD */ - /* - * If the chipset is listed as "ide_unknown", lets get a - * hwif while they last. This does the first check on - * the current availability of the ide_hwifs[h] in question. - */ - if (hwif->chipset != ide_unknown) { - continue; - } else if (vendor == PCI_VENDOR_ID_INTEL) { - unsigned short time; #ifdef DISPLAY_TRITON_TIMINGS - byte s_clks, r_clks; - unsigned short devid; + byte s_clks, r_clks; + unsigned short devid; #endif /* DISPLAY_TRITON_TIMINGS */ - if (hwif->io_base == 0x1f0) { - time = timings & 0xffff; - if ((time & 0x8000) == 0) /* interface enabled? */ - continue; - hwif->chipset = ide_triton; - if (dma_enabled) - init_triton_dma(hwif, bmiba); - step_count++; - } else if (hwif->io_base == 0x170) { - time = timings >> 16; - if ((time & 0x8000) == 0) /* interface enabled? */ - continue; - hwif->chipset = ide_triton; - if (dma_enabled) - init_triton_dma(hwif, bmiba + 8); - step_count++; - } else { + ide_hwif_t *hwif = &ide_hwifs[h]; + unsigned short time; + if (hwif->io_base == 0x1f0) { + time = timings & 0xffff; + if ((time & 0x8000) == 0) /* interface enabled? */ continue; - } -#ifdef DISPLAY_TRITON_TIMINGS - s_clks = ((~time >> 12) & 3) + 2; - r_clks = ((~time >> 8) & 3) + 1; - printk(" %s timing: (0x%04x) sample_CLKs=%d, recovery_CLKs=%d\n", - hwif->name, time, s_clks, r_clks); - if ((time & 0x40) && !pcibios_read_config_word(bus, fn, PCI_DEVICE_ID, &devid) - && devid == PCI_DEVICE_ID_INTEL_82371SB_1) { - byte stime; - if (pcibios_read_config_byte(bus, fn, 0x44, &stime)) { - if (hwif->io_base == 0x1f0) { - s_clks = ~stime >> 6; - r_clks = ~stime >> 4; - } else { - s_clks = ~stime >> 2; - r_clks = ~stime; - } - s_clks = (s_clks & 3) + 2; - r_clks = (r_clks & 3) + 1; - printk(" slave: sample_CLKs=%d, recovery_CLKs=%d\n", - s_clks, r_clks); - } - } - print_triton_drive_flags (0, time & 0xf); - print_triton_drive_flags (1, (time >> 4) & 0xf); -#endif /* DISPLAY_TRITON_TIMINGS */ - } else if (vendor == PCI_VENDOR_ID_SI) { - if (hwif->io_base == 0x1f0) { - hwif->chipset = ide_triton; - if (dma_enabled) - init_triton_dma(hwif, bmiba); - step_count++; - } else if (hwif->io_base == 0x170) { - hwif->chipset = ide_triton; - if (dma_enabled) - init_triton_dma(hwif, bmiba + 8); - step_count++; - } else { + hwif->chipset = ide_triton; + if (dma_enabled) + init_triton_dma(hwif, bmiba); + } else if (hwif->io_base == 0x170) { + time = timings >> 16; + if ((time & 0x8000) == 0) /* interface enabled? */ continue; - } - } else if(vendor == PCI_VENDOR_ID_VIA) { - if (hwif->io_base == 0x1f0) { - if((timings & 0x02) == 0) - continue; - hwif->chipset = ide_triton; - if (dma_enabled) - init_triton_dma(hwif, bmiba); - if (set_via_timings(bus, fn, 0xc0, 0xa0)) - goto quit; -#ifdef DISPLAY_APOLLO_TIMINGS - proc_register_dynamic(&proc_root, &via_proc_entry); -#endif /* DISPLAY_APOLLO_TIMINGS */ - step_count++; - } else if (hwif->io_base == 0x170) { - if((timings & 0x01) == 0) - continue; - hwif->chipset = ide_triton; - if (dma_enabled) - init_triton_dma(hwif, bmiba + 8); - if (set_via_timings(bus, fn, 0x30, 0x50)) - goto quit; - step_count++; - } else { - continue; - } - } else if ((vendor == PCI_VENDOR_ID_PROMISE) || - (vendor == PCI_VENDOR_ID_ARTOP)) { - /* - * This silly tmp = h routine allows an off-board ide-pci card to - * be booted as primary hwifgroup, provided that the onboard - * controllers are disabled. If they are active, then we wait our - * turn for hwif assignment. - */ - unsigned char irq = 0; - pcibios_read_config_byte (bus, fn, PCI_INTERRUPT_LINE, &irq); - if ((h == 0) || (h == 1)) { - tmp = h * 2; - } else { - tmp = (h - 2) * 2; - } - hwif->io_base = io[tmp]; - hwif->ctl_port = io[tmp + 1] + 2; - hwif->irq = irq; - hwif->noprobe = 0; - - if (vendor == PCI_VENDOR_ID_ARTOP) { - hwif->serialized = 1; - } - - if (dma_enabled) { - if (!check_region(bmiba, 8)) { - hwif->chipset = ide_udma; - init_triton_dma(hwif, bmiba); - step_count++; - } else if (!check_region((bmiba + 0x08), 8)) { - if ((vendor == PCI_VENDOR_ID_PROMISE) && - (!check_region(bmiba+16, 16))) { - request_region(bmiba+16, 16, "PDC20246"); - } - hwif->chipset = ide_udma; - init_triton_dma(hwif, bmiba + 8); - step_count++; + hwif->chipset = ide_triton; + if (dma_enabled) + init_triton_dma(hwif, bmiba + 8); + } else + continue; +#ifdef DISPLAY_TRITON_TIMINGS + s_clks = ((~time >> 12) & 3) + 2; + r_clks = ((~time >> 8) & 3) + 1; + printk(" %s timing: (0x%04x) sample_CLKs=%d, recovery_CLKs=%d\n", + hwif->name, time, s_clks, r_clks); + if ((time & 0x40) && !pcibios_read_config_word(bus, fn, 0x02, &devid) + && devid == PCI_DEVICE_ID_INTEL_82371SB_1) + { + byte stime; + if (pcibios_read_config_byte(bus, fn, 0x44, &stime)) { + if (hwif->io_base == 0x1f0) { + s_clks = ~stime >> 6; + r_clks = ~stime >> 4; } else { - continue; + s_clks = ~stime >> 2; + r_clks = ~stime; } + s_clks = (s_clks & 3) + 2; + r_clks = (r_clks & 3) + 1; + printk(" slave: sample_CLKs=%d, recovery_CLKs=%d\n", + s_clks, r_clks); } } + print_triton_drive_flags (0, time & 0xf); + print_triton_drive_flags (1, (time >> 4) & 0xf); +#endif /* DISPLAY_TRITON_TIMINGS */ } - quit: if (rc) printk("ide: pcibios access failed - %s\n", pcibios_strerror(rc)); +quit: if (rc) printk("ide: pcibios access failed - %s\n", pcibios_strerror(rc)); +} + +void ide_init_promise (byte bus, byte fn, ide_hwif_t *hwif0, ide_hwif_t *hwif1, unsigned short dma) +{ + int rc; + unsigned short pcicmd; + unsigned int bmiba = 0; + + printk("ide: Enabling DMA for Promise Technology IDE Ultra-DMA 33 on PCI bus %d function %d, port 0x%04x\n", bus, fn, dma); + if ((rc = pcibios_read_config_word(bus, fn, 0x04, &pcicmd)) || (pcicmd & 1) == 0 || (pcicmd & 4) == 0) + goto abort; + if ((rc = pcibios_read_config_dword(bus, fn, 0x20, &bmiba))) + goto abort; + bmiba &= 0xfff0; /* extract port base address */ + if (bmiba != dma || !bmiba) + goto abort; + hwif0->chipset = ide_promise_udma; + hwif1->chipset = ide_promise_udma; + init_triton_dma(hwif0, bmiba); + init_triton_dma(hwif1, bmiba + 0x08); + return; +abort: + printk(KERN_WARNING "ide: Promise/33 not configured correctly (BIOS)\n"); } diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c index 7bdc4f199b53..18c1bed2a84c 100644 --- a/drivers/cdrom/sbpcd.c +++ b/drivers/cdrom/sbpcd.c @@ -4911,16 +4911,14 @@ static int sbp_data(struct request *req) msg(DBG_000, "sbp_data: beginning to read.\n"); p = D_S[d].sbp_buf + frame * CD_FRAMESIZE; if (sbpro_type==1) OUT(CDo_sel_i_d,1); - if (cmd_type==READ_M2) { + if (cmd_type==READ_M2) if (do_16bit) insw(CDi_data, xa_head_buf, CD_XA_HEAD>>1); else insb(CDi_data, xa_head_buf, CD_XA_HEAD); - } if (do_16bit) insw(CDi_data, p, CD_FRAMESIZE>>1); else insb(CDi_data, p, CD_FRAMESIZE); - if (cmd_type==READ_M2) { + if (cmd_type==READ_M2) if (do_16bit) insw(CDi_data, xa_tail_buf, CD_XA_TAIL>>1); else insb(CDi_data, xa_tail_buf, CD_XA_TAIL); - } D_S[d].sbp_current++; if (sbpro_type==1) OUT(CDo_sel_i_d,0); if (cmd_type==READ_M2) @@ -5504,10 +5502,9 @@ int SBPCD_INIT(void) cc_ReadStatus(); i=ResponseStatus(); /* returns orig. status or p_busy_new */ if (famT_drive) i=ResponseStatus(); /* returns orig. status or p_busy_new */ - if (i<0) { + if (i<0) if (i!=-402) msg(DBG_INF,"init: ResponseStatus returns %d.\n",i); - } else { if (st_check) diff --git a/drivers/char/Config.in b/drivers/char/Config.in index 20deda773415..c4dddf6af591 100644 --- a/drivers/char/Config.in +++ b/drivers/char/Config.in @@ -58,6 +58,15 @@ if [ "$CONFIG_FTAPE" != "n" ]; then comment 'Set IObase/IRQ/DMA for ftape in ./drivers/char/ftape/Makefile' fi +bool 'Advanced Power Management BIOS support' CONFIG_APM +if [ "$CONFIG_APM" = "y" ]; then + bool ' Ignore USER SUSPEND' CONFIG_APM_IGNORE_USER_SUSPEND + bool ' Enable PM at boot time' CONFIG_APM_DO_ENABLE + bool ' Make CPU Idle calls when idle' CONFIG_APM_CPU_IDLE + bool ' Enable console blanking using APM' CONFIG_APM_DISPLAY_BLANK + bool ' Power off on shutdown' CONFIG_APM_POWER_OFF + bool ' Ignore multiple suspend' CONFIG_APM_IGNORE_MULTIPLE_SUSPEND +fi if [ "$CONFIG_ALPHA_BOOK1" = "y" ]; then bool 'Tadpole ANA H8 Support' CONFIG_H8 fi diff --git a/drivers/char/Makefile b/drivers/char/Makefile index b1ed782e5ca2..7a13e826eed2 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -200,6 +200,7 @@ else endif ifdef CONFIG_APM +LX_OBJS += apm_bios.o M = y endif diff --git a/arch/i386/kernel/apm.c b/drivers/char/apm_bios.c similarity index 99% rename from arch/i386/kernel/apm.c rename to drivers/char/apm_bios.c index 299c23d572ce..eb594707c80c 100644 --- a/arch/i386/kernel/apm.c +++ b/drivers/char/apm_bios.c @@ -1,9 +1,7 @@ /* -*- linux-c -*- * APM BIOS driver for Linux - * Copyright 1994-1999 Stephen Rothwell - * (Stephen.Rothwell@canb.auug.org.au) - * Development of this driver was funded by NEC Australia P/L - * and NEC Corporation + * Copyright 1994, 1995, 1996 Stephen Rothwell + * (Stephen.Rothwell@canb.auug.org.au) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -15,6 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * + * $Id: apm_bios.c,v 0.22 1995/03/09 14:12:02 sfr Exp $ + * * October 1995, Rik Faith (faith@cs.unc.edu): * Minor enhancements and updates (to the patch set) for 1.3.x * Documentation diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index 514301946d1d..8b7695ff54b9 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c @@ -1,7 +1,7 @@ #define BLOCKMOVE #define Z_WAKE static char rcsid[] = -"$Revision: 2.1.2.1 $$Date: 1999/04/08 16:17:18 $"; +"$Revision: 2.1.1.10 $$Date: 1998/11/12 16:08:23 $"; /* * linux/drivers/char/cyclades.c @@ -31,21 +31,7 @@ static char rcsid[] = * void cleanup_module(void); * * $Log: cyclades.c,v $ - * Revision 2.1.2.1 1999/04/08 16:17:18 ivan - * cy_wait_until_sent function revisited; - * Module usage counter scheme revisited; - * Added support to the upcoming Y PCI boards (i.e., support to additional - * PCI Device ID's). - * - * Revision 2.1.1.12 1999/01/19 13:08:18 ivan - * Fixed PLX PCI bridge registers mapping for Cyclom-Y boards, so - * that it works even with addresses out of memory page boundaries. - * - * Revision 2.1.1.11 1998/12/30 18:58:47 ivan - * Changed access to PLX PCI bridge registers from I/O to MMIO, in - * order to make PLX9050-based boards work with certain motherboards. - * - * Revision 2.1.1.10 1998/11/12 16:08:23 ivan + * Revision: 2.1.1.10 1998/11/12 16:08:23 ivan * cy_close function now resets (correctly) the tty->closing flag; * JIFFIES_DIFF macro fixed. * @@ -533,7 +519,6 @@ static char rcsid[] = #undef CY_DEBUG_COUNT #undef CY_DEBUG_DTR #undef CY_DEBUG_WAIT_UNTIL_SENT -#undef CY_DEBUG_INTERRUPTS #undef CY_16Y_HACK #undef CY_ENABLE_MONITORING #undef CY_PCI_DEBUG @@ -773,20 +758,16 @@ static int cy_chip_offset [] = /* PCI related definitions */ -static unsigned short cy_pci_nboard = 0; -static unsigned short cy_isa_nboard = 0; -static unsigned short cy_nboard = 0; -static unsigned short cy_pci_dev_id[] = { - PCI_DEVICE_ID_CYCLOM_Y_Lo, /* PCI < 1Mb */ - PCI_DEVICE_ID_CYCLOM_Y_Hi, /* PCI > 1Mb */ - PCI_DEVICE_ID_CYCLOM_4Y_Lo, /* 4Y PCI < 1Mb */ - PCI_DEVICE_ID_CYCLOM_4Y_Hi, /* 4Y PCI > 1Mb */ - PCI_DEVICE_ID_CYCLOM_8Y_Lo, /* 8Y PCI < 1Mb */ - PCI_DEVICE_ID_CYCLOM_8Y_Hi, /* 8Y PCI > 1Mb */ - PCI_DEVICE_ID_CYCLOM_Z_Lo, /* Z PCI < 1Mb */ - PCI_DEVICE_ID_CYCLOM_Z_Hi, /* Z PCI > 1Mb */ - 0 /* end of table */ - }; +static unsigned short cy_pci_nboard = 0; +static unsigned short cy_isa_nboard = 0; +static unsigned short cy_nboard = 0; +static unsigned short cy_pci_dev_id[] = { + PCI_DEVICE_ID_CYCLOM_Y_Lo,/* PCI below 1Mb */ + PCI_DEVICE_ID_CYCLOM_Y_Hi,/* PCI above 1Mb */ + PCI_DEVICE_ID_CYCLOM_Z_Lo,/* PCI below 1Mb */ + PCI_DEVICE_ID_CYCLOM_Z_Hi,/* PCI above 1Mb */ + 0 /* end of table */ + }; static void cy_start(struct tty_struct *); @@ -2527,17 +2508,13 @@ cy_open(struct tty_struct *tty, struct file * filp) { struct cyclades_port *info; int retval, line; - unsigned long page; - MOD_INC_USE_COUNT; line = MINOR(tty->device) - tty->driver.minor_start; if ((line < 0) || (NR_PORTS <= line)){ - MOD_DEC_USE_COUNT; return -ENODEV; } info = &cy_port[line]; if (info->line < 0){ - MOD_DEC_USE_COUNT; return -ENODEV; } @@ -2563,8 +2540,6 @@ cy_open(struct tty_struct *tty, struct file * filp) #ifdef CY_DEBUG_OTHER printk("cyc:cy_open ttyC%d\n", info->line); /* */ #endif - tty->driver_data = info; - info->tty = tty; if (serial_paranoia_check(info, tty->device, "cy_open")){ return -ENODEV; } @@ -2577,15 +2552,16 @@ cy_open(struct tty_struct *tty, struct file * filp) printk("cyc:cy_open (%d): incrementing count to %d\n", current->pid, info->count); #endif + tty->driver_data = info; + info->tty = tty; + /* Some drivers have (incorrect/incomplete) code to test + against a race condition. Should add good code here!!! */ if (!tmp_buf) { - page = get_free_page(GFP_KERNEL); - if (!page) - return -ENOMEM; - if (tmp_buf) - free_page(page); - else - tmp_buf = (unsigned char *) page; + tmp_buf = (unsigned char *) get_free_page(GFP_KERNEL); + if (!tmp_buf){ + return -ENOMEM; + } } if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) { @@ -2602,6 +2578,8 @@ cy_open(struct tty_struct *tty, struct file * filp) return retval; } + MOD_INC_USE_COUNT; + retval = block_til_ready(tty, filp, info); if (retval) { #ifdef CY_DEBUG_OPEN @@ -2634,9 +2612,6 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout) if (serial_paranoia_check(info, tty->device, "cy_wait_until_sent")) return; - if (info->xmit_fifo_size == 0) - return; /* Just in case.... */ - orig_jiffies = jiffies; /* * Set the check interval to be 1/5 of the estimated time to @@ -2654,17 +2629,6 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout) timeout = 0; if (timeout) char_time = MIN(char_time, timeout); - /* - * If the transmitter hasn't cleared in twice the approximate - * amount of time to send the entire FIFO, it probably won't - * ever clear. This assumes the UART isn't doing flow - * control, which is currently the case. Hence, if it ever - * takes longer than info->timeout, this is probably due to a - * UART bug of some kind. So, we clamp the timeout parameter at - * 2*info->timeout. - */ - if (!timeout || timeout > 2*info->timeout) - timeout = 2*info->timeout; #ifdef CY_DEBUG_WAIT_UNTIL_SENT printk("In cy_wait_until_sent(%d) check=%lu...", timeout, char_time); printk("jiff=%lu...", jiffies); @@ -2718,7 +2682,8 @@ cy_close(struct tty_struct * tty, struct file * filp) printk("cyc:cy_close ttyC%d\n", info->line); #endif - if (!info || serial_paranoia_check(info, tty->device, "cy_close")){ + if (!info + || serial_paranoia_check(info, tty->device, "cy_close")){ return; } #ifdef CY_DEBUG_OPEN @@ -4742,6 +4707,7 @@ cy_detect_pci(void)) { #ifdef CONFIG_PCI unsigned char cyy_bus, cyy_dev_fn, cyy_rev_id; + unsigned long pci_intr_ctrl; unsigned char cy_pci_irq; uclong cy_pci_addr0, cy_pci_addr1, cy_pci_addr2; unsigned short i,j,cy_pci_nchan, plx_ver; @@ -4785,8 +4751,6 @@ cy_detect_pci(void)) pcibios_read_config_byte(cyy_bus, cyy_dev_fn, PCI_REVISION_ID, &cyy_rev_id); - device_id &= ~PCI_DEVICE_ID_MASK; - if ((device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) || (device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi)){ #ifdef CY_PCI_DEBUG @@ -4794,11 +4758,11 @@ cy_detect_pci(void)) cyy_bus, cyy_dev_fn); printk("rev_id=%d) IRQ%d\n", cyy_rev_id, (int)cy_pci_irq); - printk("Cyclom-Y/PCI:found winaddr=0x%lx ctladdr=0x%lx\n", - (ulong)cy_pci_addr2, (ulong)cy_pci_addr0); + printk("Cyclom-Y/PCI:found winaddr=0x%lx ioaddr=0x%lx\n", + (ulong)cy_pci_addr2, (ulong)cy_pci_addr1); #endif - cy_pci_addr0 &= PCI_BASE_ADDRESS_MEM_MASK; - cy_pci_addr2 &= PCI_BASE_ADDRESS_MEM_MASK; + cy_pci_addr1 &= PCI_BASE_ADDRESS_IO_MASK; + cy_pci_addr2 &= PCI_BASE_ADDRESS_MEM_MASK; #if defined(__alpha__) if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) { /* below 1M? */ @@ -4806,24 +4770,21 @@ cy_detect_pci(void)) cyy_bus, cyy_dev_fn); printk("rev_id=%d) IRQ%d\n", cyy_rev_id, (int)cy_pci_irq); - printk("Cyclom-Y/PCI:found winaddr=0x%lx ctladdr=0x%lx\n", - (ulong)cy_pci_addr2, (ulong)cy_pci_addr0); + printk("Cyclom-Y/PCI:found winaddr=0x%lx ioaddr=0x%lx\n", + (ulong)cy_pci_addr2, (ulong)cy_pci_addr1); printk("Cyclom-Y/PCI not supported for low addresses in " "Alpha systems.\n"); i--; continue; } #else - cy_pci_addr0 = (ulong)ioremap(cy_pci_addr0 & PAGE_MASK, - PAGE_ALIGN(CyPCI_Yctl)) - + (cy_pci_addr0 & (PAGE_SIZE-1)); if ((ulong)cy_pci_addr2 >= 0x100000) /* above 1M? */ cy_pci_addr2 = (ulong) ioremap(cy_pci_addr2, CyPCI_Ywin); #endif #ifdef CY_PCI_DEBUG - printk("Cyclom-Y/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n", - (u_long)cy_pci_addr2, (u_long)cy_pci_addr0); + printk("Cyclom-Y/PCI: relocate winaddr=0x%lx ioaddr=0x%lx\n", + (u_long)cy_pci_addr2, (u_long)cy_pci_addr1); #endif cy_pci_nchan = (unsigned short)(CyPORTS_PER_CHIP * cyy_init_card((volatile ucchar *)cy_pci_addr2, 1)); @@ -4866,7 +4827,7 @@ cy_detect_pci(void)) /* set cy_card */ cy_card[j].base_addr = (ulong)cy_pci_addr2; - cy_card[j].ctl_addr = (ulong)cy_pci_addr0; + cy_card[j].ctl_addr = 0; cy_card[j].irq = (int) cy_pci_irq; cy_card[j].bus_index = 1; cy_card[j].first_line = cy_next_channel; @@ -4878,16 +4839,20 @@ cy_detect_pci(void)) switch (plx_ver) { case PLX_9050: - cy_writew(cy_pci_addr0+0x4c, - cy_readw(cy_pci_addr0+0x4c)|0x0040); + outw(inw(cy_pci_addr1+0x4c)|0x0040,cy_pci_addr1+0x4c); + pci_intr_ctrl = (unsigned long) + (inw(cy_pci_addr1+0x4c) + | inw(cy_pci_addr1+0x4e)<<16); break; case PLX_9060: case PLX_9080: default: /* Old boards, use PLX_9060 */ - cy_writew(cy_pci_addr0+0x68, - cy_readw(cy_pci_addr0+0x68)|0x0900); + outw(inw(cy_pci_addr1+0x68)|0x0900,cy_pci_addr1+0x68); + pci_intr_ctrl = (unsigned long) + (inw(cy_pci_addr1+0x68) + | inw(cy_pci_addr1+0x6a)<<16); break; } diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c index 3c1491fa3d29..fbbf48bfc1b4 100644 --- a/drivers/char/isicom.c +++ b/drivers/char/isicom.c @@ -116,7 +116,6 @@ static int ISILoad_open(struct inode *inode, struct file *filp) #ifdef ISICOM_DEBUG printk(KERN_DEBUG "ISILoad:Firmware loader Opened!!!\n"); #endif - MOD_INC_USE_COUNT; return 0; } @@ -125,7 +124,6 @@ static void ISILoad_release(struct inode *inode, struct file *filp) #ifdef ISICOM_DEBUG printk(KERN_DEBUG "ISILoad:Firmware loader Close(Release)d\n",); #endif - MOD_DEC_USE_COUNT; } static int ISILoad_ioctl(struct inode *inode, struct file *filp, diff --git a/drivers/char/random.c b/drivers/char/random.c index 28de370b901d..3e8d21d55036 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1004,17 +1004,7 @@ static int extract_entropy(struct random_bucket *r, char * buf, buf += i; add_timer_randomness(r, &extract_timer_state, nbytes); if (to_user && need_resched) - { - if(current->signal & ~current->blocked) - { - if(nbytes==0) - ret = -ERESTARTSYS; - else - ret -= nbytes; - break; - } schedule(); - } } /* Wipe data from memory */ diff --git a/drivers/char/selection.h b/drivers/char/selection.h index 51f6b6fa42f2..41e4c11d0bff 100644 --- a/drivers/char/selection.h +++ b/drivers/char/selection.h @@ -66,13 +66,12 @@ extern void putconsxy(int currcons, char *p); #ifdef CONFIG_TGA_CONSOLE # ifdef CONFIG_VGA_CONSOLE +extern int curr_cons; extern const struct console_desc cons_devices[]; # endif extern unsigned long video_mem_term; -int tga_blitc (unsigned int, unsigned long); - /* * TGA console screen memory access * @@ -111,8 +110,8 @@ static inline void scr_writew(unsigned short val, unsigned short * addr) * TGA might need the char blitted to the screen, * but check first, we could be running on a VGA. */ - if (tga_blitc && IS_VIDEO_MEMORY(addr)) - tga_blitc(val, (unsigned long) addr); + if (con_blitc && IS_VIDEO_MEMORY(addr)) + con_blitc(val, (unsigned long) addr); } else writew(val, (unsigned long) addr); } diff --git a/drivers/char/serial.c b/drivers/char/serial.c index 8eb5a6909f08..2747e9eedadc 100644 --- a/drivers/char/serial.c +++ b/drivers/char/serial.c @@ -57,7 +57,7 @@ #include static char *serial_name = "Serial driver"; -static char *serial_version = "4.13p1"; +static char *serial_version = "4.13p"; DECLARE_TASK_QUEUE(tq_serial); @@ -1805,26 +1805,6 @@ static int do_autoconfig(struct async_struct * info) } -/* - * rs_break() --- routine which turns the break handling on or off - * adapted from 2.1.124 - */ -static void rs_break(struct async_struct * info, int break_state) -{ - unsigned long flags; - - if (!info->port) - return; - save_flags(flags);cli(); - if (break_state == -1) - serial_out(info, UART_LCR, - serial_inp(info, UART_LCR) | UART_LCR_SBC); - else - serial_out(info, UART_LCR, - serial_inp(info, UART_LCR) & ~UART_LCR_SBC); - restore_flags(flags); -} - /* * This routine sends a break character out the serial port. */ @@ -2017,20 +1997,6 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file, } switch (cmd) { - case TIOCSBRK: /* Turn break on, unconditionally */ - retval = tty_check_change(tty); - if (retval) - return retval; - tty_wait_until_sent(tty, 0); - rs_break(info,-1); - return 0; - case TIOCCBRK: /* Turn break off, unconditionally */ - retval = tty_check_change(tty); - if (retval) - return retval; - tty_wait_until_sent(tty, 0); - rs_break(info,0); - return 0; case TCSBRK: /* SVID version: non-zero arg --> no break */ retval = tty_check_change(tty); if (retval) diff --git a/drivers/char/tga.c b/drivers/char/tga.c index cb66571a9b68..607b908a9788 100644 --- a/drivers/char/tga.c +++ b/drivers/char/tga.c @@ -40,7 +40,6 @@ extern void register_console(void (*proc)(const char *)); extern void console_print(const char *); -extern void set_palette (void); /* vga.c */ /* TGA hardware description (minimal) */ /* @@ -485,6 +484,11 @@ tga_console_find(void) tga_init_video(); tga_clear_screen(); +#ifdef CONFIG_VGA_CONSOLE + /* if both are configured, we are using a dispatch table, + so we must set the index */ + curr_cons = 1; +#endif } unsigned char PLLbits[7] = { 0x80, 0x04, 0x00, 0x24, 0x44, 0x80, 0xb8 }; diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index d1a12f598e75..98d03a9c99b7 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -1932,9 +1932,8 @@ int tty_unregister_driver(struct tty_driver *driver) { int retval; struct tty_driver *p; - int i, found = 0; + int found = 0; const char *othername = NULL; - struct termios *tp; if (*driver->refcount) return -EBUSY; @@ -1964,18 +1963,6 @@ int tty_unregister_driver(struct tty_driver *driver) if (driver->next) driver->next->prev = driver->prev; - for (i = 0; i < driver->num; i++) { - tp = driver->termios[i]; - if (tp != NULL) { - kfree_s(tp, sizeof(struct termios)); - driver->termios[i] = NULL; - } - tp = driver->termios_locked[i]; - if (tp != NULL) { - kfree_s(tp, sizeof(struct termios)); - driver->termios_locked[i] = NULL; - } - } return 0; } diff --git a/drivers/isdn/isdn_net.c b/drivers/isdn/isdn_net.c index 8998cdac9a2f..bb43dc9c60bb 100644 --- a/drivers/isdn/isdn_net.c +++ b/drivers/isdn/isdn_net.c @@ -1,4 +1,4 @@ -/* $Id: isdn_net.c,v 1.48.2.28 1998/11/27 15:38:12 paul Exp $ +/* $Id: isdn_net.c,v 1.48.2.27 1998/11/05 22:11:53 fritz Exp $ * Linux ISDN subsystem, network interfaces and related functions (linklevel). * @@ -21,9 +21,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log: isdn_net.c,v $ - * Revision 1.48.2.28 1998/11/27 15:38:12 paul - * Also huptimeout with dialmode == manual - * * Revision 1.48.2.27 1998/11/05 22:11:53 fritz * Changed mail-address. * @@ -353,11 +350,11 @@ static int isdn_net_start_xmit(struct sk_buff *, struct device *); static int isdn_net_xmit(struct device *, isdn_net_local *, struct sk_buff *); static void dev_purge_queues(struct device *dev); /* move this to net/core/dev.c */ -char *isdn_net_revision = "$Revision: 1.48.2.28 $"; +char *isdn_net_revision = "$Revision: 1.48.2.27 $"; -/* - * Code for raw-networking over ISDN - */ + /* + * Code for raw-networking over ISDN + */ static void isdn_net_unreachable(struct device *dev, struct sk_buff *skb, char *reason) @@ -365,6 +362,7 @@ isdn_net_unreachable(struct device *dev, struct sk_buff *skb, char *reason) int i; if(skb != NULL) { + u_short proto = ntohs(skb->protocol); printk(KERN_DEBUG "isdn_net: %s: %s, send ICMP %s\n", @@ -540,14 +538,13 @@ isdn_net_autohup() if ((l->flags & ISDN_NET_CONNECTED) && (!l->dialstate)) { anymore = 1; l->huptimer++; - /* - * if there is some dialmode where timeout-hangup - * should _not_ be done, check for that here and - * 35 lines below (ifdef CONFIG_ISDN_BUDGET) - * eg: (ISDN_NET_DIALMODE(*l) != ISDN_NET_DM_NOTIMEOUT) - */ - if ((l->onhtime) && - (l->huptimer > l->onhtime)) + /* + * only do timeout-hangup + * if interface is configured as AUTO + */ + if ((ISDN_NET_DIALMODE(*l) == ISDN_NET_DM_AUTO) && + (l->onhtime) && + (l->huptimer > l->onhtime)) if (l->hupflags & ISDN_MANCHARGE && l->hupflags & ISDN_CHARGEHUP) { while (jiffies - l->chargetime > l->chargeint) diff --git a/drivers/isdn/isdn_ppp.c b/drivers/isdn/isdn_ppp.c index 2ce04b402a59..9ebb1a6c82ac 100644 --- a/drivers/isdn/isdn_ppp.c +++ b/drivers/isdn/isdn_ppp.c @@ -1,4 +1,4 @@ -/* $Id: isdn_ppp.c,v 1.28.2.3 1998/12/30 17:49:00 paul Exp $ +/* $Id: isdn_ppp.c,v 1.28.2.2 1998/11/03 14:31:23 fritz Exp $ * * Linux ISDN subsystem, functions for synchronous PPP (linklevel). * @@ -19,9 +19,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log: isdn_ppp.c,v $ - * Revision 1.28.2.3 1998/12/30 17:49:00 paul - * fixed syncPPP callback out - * * Revision 1.28.2.2 1998/11/03 14:31:23 fritz * Reduced stack usage in various functions. * Adapted statemachine to work with certified HiSax. @@ -184,7 +181,7 @@ static int isdn_ppp_fill_mpqueue(isdn_net_dev *, struct sk_buff **skb, static void isdn_ppp_free_mpqueue(isdn_net_dev *); #endif -char *isdn_ppp_revision = "$Revision: 1.28.2.3 $"; +char *isdn_ppp_revision = "$Revision: 1.28.2.2 $"; static struct ippp_struct *ippp_table[ISDN_MAX_CHANNELS]; static struct isdn_ppp_compressor *ipc_head = NULL; @@ -306,8 +303,7 @@ isdn_ppp_bind(isdn_net_local * lp) } } else { for (i = 0; i < ISDN_MAX_CHANNELS; i++) - if (ippp_table[i]->minor == lp->pppbind && - (ippp_table[i]->state & IPPP_OPEN) == IPPP_OPEN) + if (ippp_table[i]->minor == lp->pppbind && ippp_table[i]->state == IPPP_OPEN) break; } diff --git a/drivers/net/Makefile b/drivers/net/Makefile index e7e06d9b37d3..a084af63f6ed 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -682,8 +682,8 @@ include $(TOPDIR)/Rules.make clean: rm -f core *.o *.a *.s -rcpci.o: rcpci45.o rclanmtl.o - $(LD) -r -o rcpci.o rcpci45.o rclanmtl.o +rcpci.o: rcpci45.o rcmtl.o + $(LD) -r -o rcpci.o rcpci45.o rcmtl.o wd.o: wd.c CONFIG $(CC) $(CPPFLAGS) $(CFLAGS) $(WD_OPTS) -c $< diff --git a/drivers/net/README.rcpci b/drivers/net/README.rcpci deleted file mode 100644 index e3710f0b375e..000000000000 --- a/drivers/net/README.rcpci +++ /dev/null @@ -1,79 +0,0 @@ - -Application Information - - -The included application, called "rcc" (for RedCreek Control), is an -example of a user-space application (i.e., not running within kernel -space). It issues ioctl commands to communicate with the PCI driver. -It can currently report any of the following information: - - - PCI driver information ("getinfo") - - card statistics ("getstats") - - card's ip address & netmask ("getipnmask") - - card's mac address ("getmac") - - current speed ("getspeed") - - firmware version string ("getfirmware") - - status of the link (up or down) ("getstatus") - -Also, it can "set" the following parameters: - - - IP and mask - - mac address - - link speed - - promiscuous mode - -Example: rcc eth1 setipnmask="192.168.254.254 255.255.255.0" - -Note: rcc's command line parser is very basic. If you type the -command incorrectly, it might result in a core dump. - -This program needs to run as root, to avoid encountering permission -problems. An alternative is to change the permission and ownership -so that it runs as a setuid root process (for example, "chown -root.root rcc; chmod u+s rcc"). - - - -Quick PCI driver background - - -The adapter has its own IP and mac addresses which you have to -assign using the RedCreek manager (assuming the adapter is -running 3.X firmware). Your linux box will not know anything -about the adapter's IP address -- ie, the adapter will show up -as a regular nic. You will assign the linux box IP address using -the "ifconfig" command, as mentioned below. - - -To compile the driver, simply type "make". -This, of course, assumes that you have GNU compiler environment -already setup on a linux box. The .c and .h files were copied -to a dos filesystem (the floppy), so you may have to use "dos2unix" to -convert it back to a unix text file. Keep in mind that the driver -currently works with kernels 2.0.X only. Furthermore, it was only -tested with kernel 2.0.34. - -To load the driver: - -"insmod rcpci" - -The adapter will show up as a regular nic. Thus, if you have only -one nic (the pci card) in your box, you would at this point configure -it with the following commands: - -mandatory: -"ifconfig eth0 " -"route add -net eth0" - -optional (if you want to be able to access other networks): -"route add default gw eth0" - -Done. Type "ifconfig" to see "eth0" and the packet count, as well -as the IP address, net mask, etc. - -To unload the driver, you first have to shutdown the interface: - -"ifconfig eth0 down" - -Then you unload the driver with "rmmod rcpci". diff --git a/drivers/net/Space.c b/drivers/net/Space.c index 590488dd0963..083cdeb706bb 100644 --- a/drivers/net/Space.c +++ b/drivers/net/Space.c @@ -52,7 +52,6 @@ extern int znet_probe(struct device *); extern int express_probe(struct device *); extern int eepro_probe(struct device *); extern int el3_probe(struct device *); -extern int tc515_probe(struct device *); extern int at1500_probe(struct device *); extern int at1700_probe(struct device *); extern int fmv18x_probe(struct device *); diff --git a/drivers/net/at1700.c b/drivers/net/at1700.c index 99386a159474..953c188959da 100644 --- a/drivers/net/at1700.c +++ b/drivers/net/at1700.c @@ -595,6 +595,7 @@ net_rx(struct device *dev) /* The inverse routine to net_open(). */ static int net_close(struct device *dev) { + struct net_local *lp = (struct net_local *)dev->priv; int ioaddr = dev->base_addr; dev->tbusy = 1; @@ -605,6 +606,14 @@ static int net_close(struct device *dev) /* No statistic counters on the chip to update. */ +#if 0 + /* Disable the IRQ on boards where it is feasible. */ + if (lp->jumpered) { + outb(0x00, ioaddr + IOCONFIG1); + free_irq(dev->irq, dev); + } +#endif + /* Power-down the chip. Green, green, green! */ outb(0x00, ioaddr + CONFIG_1); diff --git a/drivers/net/de4x5.c b/drivers/net/de4x5.c index 510aeea13e0a..b6364cd6c30b 100644 --- a/drivers/net/de4x5.c +++ b/drivers/net/de4x5.c @@ -404,12 +404,11 @@ alignment for Alpha's and avoid their unaligned access traps. This flag is merely for log messages: should do something more definitive though... - 0.5352 30-Dec-98 Fix driver recognition of the newer DECchips. ========================================================================= */ -static const char *version = "de4x5.c:V0.5352 1998/12/30 davies@maniac.ultranet.com\n"; +static const char *version = "de4x5.c:V0.5351 1998/10/4 davies@maniac.ultranet.com\n"; #include @@ -770,7 +769,7 @@ struct de4x5_private { int tx_new, tx_old; /* TX descriptor ring pointers */ char setup_frame[SETUP_FRAME_LEN]; /* Holds MCA and PA info. */ char frame[64]; /* Min sized packet for loopback*/ - struct net_device_stats stats; /* Public stats */ + struct net_device_stats stats; /* Public stats */ struct { u_int bins[DE4X5_PKT_STAT_SZ]; /* Private stats counters */ u_int unicast; @@ -1357,6 +1356,7 @@ de4x5_open(struct device *dev) ** Re-initialize the DE4X5... */ status = de4x5_init(dev); + lp->state = OPEN; de4x5_dbg_open(dev); @@ -1599,7 +1599,7 @@ de4x5_interrupt(int irq, void *dev_id, struct pt_regs *regs) DISABLE_IRQs; /* Ensure non re-entrancy */ if (test_and_set_bit(MASK_INTERRUPTS, (void*) &lp->interrupt)) - printk("%s: Re-entering the interrupt handler.\n", dev->name); + printk("%s: Re-entering the interrupt handler.\n", dev->name); #if LINUX_VERSION_CODE >= ((2 << 16) | (1 << 8)) synchronize_irq(); @@ -2075,9 +2075,7 @@ eisa_probe(struct device *dev, u_long ioaddr)) irq = inb(EISA_REG0); irq = de4x5_irq[(irq >> 1) & 0x03]; - if (is_DC2114x) { - device = ((cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143); - } + if (is_DC2114x) device |= (cfrv & CFRV_RN); lp->chipset = device; /* Write the PCI Configuration Registers */ @@ -2182,9 +2180,7 @@ pci_probe(struct device *dev, u_long ioaddr)) lp->bus_num = pb; /* Set the chipset information */ - if (is_DC2114x) { - device = ((cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143); - } + if (is_DC2114x) device |= (cfrv & CFRV_RN); lp->chipset = device; /* Get the board I/O address (64 bits on sparc64) */ @@ -2295,9 +2291,7 @@ srom_search(int index)) lp->bus_num = pb; /* Set the chipset information */ - if (is_DC2114x) { - device = ((cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143); - } + if (is_DC2114x) device |= (cfrv & CFRV_RN); lp->chipset = device; /* Get the board I/O address (64 bits on sparc64) */ @@ -5663,7 +5657,7 @@ de4x5_ioctl(struct device *dev, struct ifreq *rq, int cmd) cli(); copy_to_user(ioc->data, &lp->pktStats, ioc->len); sti(); - + break; case DE4X5_CLR_STATS: /* Zero out the driver statistics */ if (suser()) { @@ -5836,12 +5830,6 @@ init_module(void) if (!mdev) mdev = p; if (register_netdev(p) != 0) { - struct de4x5_private *lp = (struct de4x5_private *)p->priv; - if (lp) { - release_region(p->base_addr, (lp->bus == PCI ? - DE4X5_PCI_TOTAL_SIZE : - DE4X5_EISA_TOTAL_SIZE)); - } kfree(p); } else { status = 0; /* At least one adapter will work */ diff --git a/drivers/net/de4x5.h b/drivers/net/de4x5.h index 0a83efa91418..c0c58ccf4beb 100644 --- a/drivers/net/de4x5.h +++ b/drivers/net/de4x5.h @@ -121,7 +121,6 @@ #define DC2114x DC2114x_DID #define DC21142 (DC2114x_DID | 0x0010) #define DC21143 (DC2114x_DID | 0x0030) -#define DC2114x_BRK 0x0020 /* CFRV break between DC21142 & DC21143 */ #define is_DC21040 ((vendor == DC21040_VID) && (device == DC21040_DID)) #define is_DC21041 ((vendor == DC21041_VID) && (device == DC21041_DID)) diff --git a/drivers/net/dgrs.c b/drivers/net/dgrs.c index 81a5eee4d362..15c1bcac9388 100644 --- a/drivers/net/dgrs.c +++ b/drivers/net/dgrs.c @@ -1254,11 +1254,10 @@ dgrs_found_device( ) { DGRS_PRIV *priv; + int i; #ifdef MODULE { - int i; - /* Allocate and fill new device structure. */ int dev_size = sizeof(struct device) + sizeof(DGRS_PRIV); diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c index a8426bf4d64d..6f360b968032 100644 --- a/drivers/net/dummy.c +++ b/drivers/net/dummy.c @@ -70,10 +70,6 @@ static int dummy_close(struct device *dev) return 0; } -static int dummy_rebuild(void *eth, struct device *dev, unsigned long raddr, struct sk_buff *skb) -{ - return 0; -} int dummy_init(struct device *dev) { @@ -98,7 +94,6 @@ int dummy_init(struct device *dev) /* Fill in the fields of the device structure with ethernet-generic values. */ ether_setup(dev); dev->flags |= IFF_NOARP; - dev->rebuild_header = dummy_rebuild; return 0; } diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c index f6552a8da036..1ff99fe624ea 100644 --- a/drivers/net/epic100.c +++ b/drivers/net/epic100.c @@ -1,6 +1,6 @@ /* epic100.c: A SMC 83c170 EPIC/100 Fast Ethernet driver for Linux. */ /* - Written/copyright 1997-1998 by Donald Becker. + Written 1997-1998 by Donald Becker. This software may be used and distributed according to the terms of the GNU Public License, incorporated herein by reference. @@ -10,15 +10,15 @@ SMC EtherPower II 9432 PCI adapter, and several CardBus cards. The author may be reached as becker@CESDIS.gsfc.nasa.gov, or C/O - USRA Center of Excellence in Space Data and Information Sciences + Center of Excellence in Space Data and Information Sciences Code 930.5, Goddard Space Flight Center, Greenbelt MD 20771 - Information and updates available at + Support and updates available at http://cesdis.gsfc.nasa.gov/linux/drivers/epic100.html */ static const char *version = -"epic100.c:v1.04 8/23/98 Donald Becker http://cesdis.gsfc.nasa.gov/linux/drivers/epic100.html\n"; +"epic100.c:v1.03 8/7/98 Donald Becker http://cesdis.gsfc.nasa.gov/linux/drivers/epic100.html\n"; /* A few user-configurable values. */ @@ -118,7 +118,6 @@ MODULE_PARM(max_interrupt_work, "i"); /* The I/O extent. */ #define EPIC_TOTAL_SIZE 0x100 -#define epic_debug debug static int epic_debug = 1; /* @@ -156,8 +155,7 @@ IVc. Errata /* The rest of these values should never change. */ static struct device *epic_probe1(int pci_bus, int pci_devfn, - struct device *dev, long ioaddr, int irq, - int chip_id, int card_idx); + struct device *dev, int card_idx); enum pci_flags_bit { PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4, @@ -168,11 +166,9 @@ struct chip_info { u16 vendor_id, device_id, device_id_mask, pci_flags; int io_size, min_latency; struct device *(*probe1)(int pci_bus, int pci_devfn, struct device *dev, - long ioaddr, int irq, int chip_idx, int fnd_cnt); + int chip_idx); } chip_tbl[] = { - {"SMSC EPIC/100 83c170", 0x10B8, 0x0005, 0x7fff, - PCI_USES_IO|PCI_USES_MASTER|PCI_ADDR0, EPIC_TOTAL_SIZE, 32, epic_probe1}, - {"SMSC EPIC/C 83c175", 0x10B8, 0x0006, 0x7fff, + {"SMSC EPIC/100", 0x10B8, 0x0005, 0x7fff, PCI_USES_IO|PCI_USES_MASTER|PCI_ADDR0, EPIC_TOTAL_SIZE, 32, epic_probe1}, {0,}, }; @@ -280,7 +276,7 @@ static struct device *root_epic_dev = NULL; int epic100_probe(struct device *dev) { int cards_found = 0; - int chip_idx, irq; + int chip_idx; u16 pci_command, new_command; unsigned char pci_bus, pci_device_fn; @@ -302,7 +298,6 @@ int epic100_probe(struct device *dev) continue; pci_bus = pcidev->bus->number; pci_device_fn = pcidev->devfn; - irq = pcidev->irq; #else int pci_index; @@ -310,7 +305,6 @@ int epic100_probe(struct device *dev) return -ENODEV; for (pci_index = 0; pci_index < 0xff; pci_index++) { - u8 pci_irq_line; u16 vendor, device; u32 pci_ioaddr; @@ -333,11 +327,8 @@ int epic100_probe(struct device *dev) pcibios_read_config_dword(pci_bus, pci_device_fn, PCI_BASE_ADDRESS_0, &pci_ioaddr); - pcibios_read_config_byte(pci_bus, pci_device_fn, - PCI_INTERRUPT_LINE, &pci_irq_line); /* Remove I/O space marker in bit 0. */ pci_ioaddr &= ~3; - irq = pci_irq_line; if (check_region(pci_ioaddr, chip_tbl[chip_idx].io_size)) continue; @@ -359,8 +350,8 @@ int epic100_probe(struct device *dev) PCI_COMMAND, new_command); } - dev = chip_tbl[chip_idx].probe1(pci_bus, pci_device_fn, dev, pci_ioaddr, - irq, chip_idx, cards_found); + dev = chip_tbl[chip_idx].probe1(pci_bus, pci_device_fn, + dev, cards_found); /* Check the latency timer. */ if (dev) { @@ -384,12 +375,17 @@ int epic100_probe(struct device *dev) } #endif /* not CARDBUS */ -static struct device *epic_probe1(int pci_bus, int pci_devfn, - struct device *dev, long ioaddr, int irq, - int chip_idx, int card_idx) +static struct device *epic_probe1(int bus, int devfn, struct device *dev, + int card_idx) { + static int did_version = 0; /* Already printed version info. */ struct epic_private *ep; int i, option = 0, duplex = 0; + u16 chip_id; + u32 ioaddr; + + if (epic_debug > 0 && did_version++ == 0) + printk(KERN_INFO "%s", version); if (dev && dev->mem_start) { option = dev->mem_start; @@ -403,10 +399,26 @@ static struct device *epic_probe1(int pci_bus, int pci_devfn, dev = init_etherdev(dev, 0); + { /* Grrrr, badly consider interface change. */ +#if defined(PCI_SUPPORT_VER2) + struct pci_dev *pdev = pci_find_slot(bus, devfn); + ioaddr = pdev->base_address[0] & ~3; + dev->irq = pdev->irq; + chip_id = pdev->device; +#else + u8 irq; + u32 ioaddr0; + pcibios_read_config_dword(bus, devfn, PCI_BASE_ADDRESS_0, &ioaddr0); + pcibios_read_config_byte(bus, devfn, PCI_INTERRUPT_LINE, &irq); + pcibios_read_config_word(bus, devfn, PCI_DEVICE_ID, &chip_id); + ioaddr = ioaddr0 & ~3; + dev->irq = irq; +#endif + } + dev->base_addr = ioaddr; - dev->irq = irq; - printk(KERN_INFO "%s: SMC EPIC/100 at %#lx, IRQ %d, ", - dev->name, ioaddr, dev->irq); + printk(KERN_INFO "%s: SMC EPIC/100 (chip ID %4.4x) at %#3x, IRQ %d, ", + dev->name, chip_id, ioaddr, dev->irq); /* Bring the chip out of low-power mode. */ outl(0x4200, ioaddr + GENCTL); @@ -415,7 +427,7 @@ static struct device *epic_probe1(int pci_bus, int pci_devfn, /* Turn on the MII transceiver. */ outl(0x12, ioaddr + MIICfg); - if (chip_idx == 1) + if (chip_id == 6) outl((inl(ioaddr + NVCTL) & ~0x003C) | 0x4800, ioaddr + NVCTL); outl(0x0200, ioaddr + GENCTL); @@ -435,7 +447,7 @@ static struct device *epic_probe1(int pci_bus, int pci_devfn, } /* We do a request_region() to register /proc/ioports info. */ - request_region(ioaddr, EPIC_TOTAL_SIZE, dev->name); + request_region(ioaddr, EPIC_TOTAL_SIZE, "SMC EPIC/100"); /* The data structures must be quadword aligned. */ ep = kmalloc(sizeof(*ep), GFP_KERNEL | GFP_DMA); @@ -445,13 +457,9 @@ static struct device *epic_probe1(int pci_bus, int pci_devfn, ep->next_module = root_epic_dev; root_epic_dev = dev; - ep->pci_bus = pci_bus; - ep->pci_dev_fn = pci_devfn; -#if defined(PCI_SUPPORT_VER2) - ep->chip_id = pci_find_slot(pci_bus, pci_devfn)->device; -#else - ep->chip_id = chip_tbl[chip_idx].device_id; -#endif + ep->pci_bus = bus; + ep->pci_dev_fn = devfn; + ep->chip_id = chip_id; /* Find the connected MII xcvrs. Doing this in open() would allow detecting external xcvrs later, but @@ -537,6 +545,7 @@ static int read_eeprom(long ioaddr, int location) int read_cmd = location | (inl(ee_addr) & 0x40) ? EE_READ64_CMD : EE_READ256_CMD; + printk("EEctrl is %x.\n", inl(ee_addr)); outl(EE_ENB & ~EE_CS, ee_addr); outl(EE_ENB, ee_addr); @@ -921,9 +930,11 @@ epic_start_xmit(struct sk_buff *skb, struct device *dev) static void epic_interrupt(int irq, void *dev_instance, struct pt_regs *regs) { struct device *dev = (struct device *)dev_instance; - struct epic_private *ep = (struct epic_private *)dev->priv; - long ioaddr = dev->base_addr; - int status, boguscnt = max_interrupt_work; + struct epic_private *ep; + int status, ioaddr, boguscnt = max_interrupt_work; + + ioaddr = dev->base_addr; + ep = (struct epic_private *)dev->priv; #if defined(__i386__) /* A lock to prevent simultaneous entry bug on Intel SMP machines. */ @@ -1329,18 +1340,12 @@ static dev_node_t *epic_attach(dev_locator_t *loc) if (loc->bus != LOC_PCI) return NULL; bus = loc->b.pci.bus; devfn = loc->b.pci.devfn; - printk(KERN_DEBUG "epic_attach(bus %d, function %d)\n", bus, devfn); + printk(KERN_INFO "epic_attach(bus %d, function %d)\n", bus, devfn); pcibios_read_config_dword(bus, devfn, PCI_BASE_ADDRESS_0, &io); pcibios_read_config_byte(bus, devfn, PCI_INTERRUPT_LINE, &irq); pcibios_read_config_word(bus, devfn, PCI_DEVICE_ID, &dev_id); io &= ~3; - if (io == 0 || irq == 0) { - printk(KERN_ERR "The EPIC/C CardBus Ethernet interface was not " - "assigned an %s.\n" KERN_ERR " It will not be activated.\n", - io == 0 ? "I/O address" : "IRQ"); - return NULL; - } - dev = epic_probe1(bus, devfn, NULL, io, irq, 2, -1); + dev = epic_probe1(bus, devfn, NULL, -1); if (dev) { dev_node_t *node = kmalloc(sizeof(dev_node_t), GFP_KERNEL); strcpy(node->dev_name, dev->name); @@ -1405,10 +1410,14 @@ struct driver_operations epic_ops = { #ifdef MODULE -int init_module(void) +/* An additional parameter that may be passed in... */ +static int debug = -1; + +int +init_module(void) { - if (epic_debug) - printk(KERN_INFO "%s", version); + if (debug >= 0) + epic_debug = debug; #ifdef CARDBUS register_driver(&epic_ops); @@ -1418,7 +1427,8 @@ int init_module(void) #endif } -void cleanup_module(void) +void +cleanup_module(void) { struct device *next_dev; @@ -1428,13 +1438,11 @@ void cleanup_module(void) /* No need to check MOD_IN_USE, as sys_delete_module() checks. */ while (root_epic_dev) { - struct epic_private *ep = (struct epic_private *)root_epic_dev->priv; - next_dev = ep->next_module; + next_dev = ((struct epic_private *)root_epic_dev->priv)->next_module; unregister_netdev(root_epic_dev); release_region(root_epic_dev->base_addr, EPIC_TOTAL_SIZE); kfree(root_epic_dev); root_epic_dev = next_dev; - kfree(ep); } } diff --git a/drivers/net/eql.c b/drivers/net/eql.c index 4f130eea2998..fa6e1e4a1c0d 100644 --- a/drivers/net/eql.c +++ b/drivers/net/eql.c @@ -389,8 +389,8 @@ static int eql_slave_xmit(struct sk_buff *skb, struct device *dev) eql_schedule_slaves (eql->queue); + slave_dev = eql_best_slave_dev (eql->queue); slave = eql_best_slave (eql->queue); - slave_dev = slave ? slave->dev : 0; if ( slave_dev != 0 ) { @@ -426,9 +426,9 @@ static int eql_slave_xmit(struct sk_buff *skb, struct device *dev) if (slave_dev->hard_header == NULL || slave_dev->hard_header(skb,slave_dev, ETH_P_IP,NULL,NULL,skb->len) >= 0) { - slave->bytes_queued += skb->len; dev_queue_xmit (skb, slave_dev, 1); eql->stats->tx_packets++; + slave->bytes_queued += skb->len; /* dev_kfree_skb(skb, FREE_WRITE); */ return 0; } diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c index a2619b44cf63..59921bfc228f 100644 --- a/drivers/net/eth16i.c +++ b/drivers/net/eth16i.c @@ -886,7 +886,7 @@ static int eth16i_check_signature(int ioaddr) creg[0] &= 0x0F; /* Mask collision cnr */ creg[2] &= 0x7F; /* Mask DCLEN bit */ -#if 0 +#ifdef 0 /* This was removed because the card was sometimes left to state from which it couldn't be find anymore. If there is need diff --git a/drivers/net/lance.c b/drivers/net/lance.c index 09b73bfcb3c6..f64f0feea7ce 100644 --- a/drivers/net/lance.c +++ b/drivers/net/lance.c @@ -334,17 +334,14 @@ int init_module(void) dev->base_addr = io[this_dev]; dev->dma = dma[this_dev]; dev->init = lance_probe; -#if NO_AUTOPROBE_MODULE if (io[this_dev] == 0) { if (this_dev != 0) break; /* only complain once */ printk(KERN_NOTICE "lance.c: Module autoprobing not allowed. Append \"io=0xNNN\" value(s).\n"); return -EPERM; } -#endif if (register_netdev(dev) != 0) { - if (found != 0) - return 0; /* Got at least one. */ - printk(KERN_WARNING "lance.c: No PCnet/LANCE card found\n"); + printk(KERN_WARNING "lance.c: No PCnet/LANCE card found (i/o = 0x%x).\n", io[this_dev]); + if (found != 0) return 0; /* Got at least one. */ return -ENXIO; } found++; @@ -353,7 +350,8 @@ int init_module(void) return 0; } -void cleanup_module(void) +void +cleanup_module(void) { int this_dev; @@ -392,21 +390,15 @@ int lance_probe(struct device *dev) unsigned short pci_command; if (pcibios_find_device (PCI_VENDOR_ID_AMD, - PCI_DEVICE_ID_AMD_LANCE, pci_index, - &pci_bus, &pci_device_fn) != 0) + PCI_DEVICE_ID_AMD_LANCE, pci_index, + &pci_bus, &pci_device_fn) != 0) break; pcibios_read_config_byte(pci_bus, pci_device_fn, - PCI_INTERRUPT_LINE, &pci_irq_line); + PCI_INTERRUPT_LINE, &pci_irq_line); pcibios_read_config_dword(pci_bus, pci_device_fn, - PCI_BASE_ADDRESS_0, &pci_ioaddr); + PCI_BASE_ADDRESS_0, &pci_ioaddr); /* Remove I/O space marker in bit 0. */ pci_ioaddr &= ~3; - - /* Avoid already found cards from previous calls - */ - if (check_region(pci_ioaddr, LANCE_TOTAL_SIZE)) - continue; - /* PCI Spec 2.1 states that it is either the driver or PCI card's * responsibility to set the PCI Master Enable Bit if needed. * (From Mark Stockton ) diff --git a/drivers/net/ne.c b/drivers/net/ne.c index 3dffc53ae414..ed2efbb0bdd5 100644 --- a/drivers/net/ne.c +++ b/drivers/net/ne.c @@ -43,7 +43,6 @@ static const char *version = #include #include #include -#include #include #include @@ -98,7 +97,6 @@ bad_clone_list[] = { {"ET-100","ET-200", {0x00, 0x45, 0x54}}, /* YANG and YA clone */ {"COMPEX","COMPEX16",{0x00,0x80,0x48}}, /* Broken ISA Compex cards */ {"E-LAN100", "E-LAN200", {0x00, 0x00, 0x5d}}, /* Broken ne1000 clones */ - {"PCM-4823", "PCM-4823", {0x00, 0xc0, 0x6c}}, /* Broken Advantech MoBo */ {0,} }; #endif @@ -424,7 +422,6 @@ static int ne_probe1(struct device *dev, int ioaddr) outb_p(0x00, ioaddr + EN0_RCNTLO); outb_p(0x00, ioaddr + EN0_RCNTHI); outb_p(E8390_RREAD+E8390_START, ioaddr); /* Trigger it... */ - udelay(10000); /* wait 10ms for interrupt to propagate */ outb_p(0x00, ioaddr + EN0_IMR); /* Mask it again. */ dev->irq = autoirq_report(0); if (ei_debug > 2) @@ -678,7 +675,9 @@ ne_block_output(struct device *dev, int count, outb_p(0x00, nic_base + EN0_RSARHI); outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD); /* Make certain that the dummy read has occurred. */ - udelay(6); + SLOW_DOWN_IO; + SLOW_DOWN_IO; + SLOW_DOWN_IO; #endif outb_p(ENISR_RDC, nic_base + EN0_ISR); diff --git a/drivers/net/ni52.c b/drivers/net/ni52.c index 5a0c1bb2f3f6..6d486e95d052 100644 --- a/drivers/net/ni52.c +++ b/drivers/net/ni52.c @@ -363,11 +363,10 @@ int ni52_probe(struct device *dev) #endif int base_addr = dev->base_addr; - if (base_addr > 0x1ff) { /* Check a single specified location. */ + if (base_addr > 0x1ff) /* Check a single specified location. */ if( (inb(base_addr+NI52_MAGIC1) == NI52_MAGICVAL1) && (inb(base_addr+NI52_MAGIC2) == NI52_MAGICVAL2)) return ni52_probe1(dev, base_addr); - } else if (base_addr > 0) /* Don't probe at all. */ return ENXIO; diff --git a/drivers/net/pi2.c b/drivers/net/pi2.c index 511841b82dc2..f0def520ca84 100644 --- a/drivers/net/pi2.c +++ b/drivers/net/pi2.c @@ -1452,7 +1452,7 @@ static int pi_probe(struct device *dev, int card_type) static int pi_open(struct device *dev) { unsigned long flags; - static int first_time = 1; + static first_time = 1; struct pi_local *lp = (struct pi_local *) dev->priv; diff --git a/drivers/net/ppp.c b/drivers/net/ppp.c index bd2c4788cfa8..d78146d5faf3 100644 --- a/drivers/net/ppp.c +++ b/drivers/net/ppp.c @@ -3155,7 +3155,7 @@ ppp_dev_stats (struct device *dev) ppp_stats.tx_heartbeat_errors = 0; if (ppp->flags & SC_DEBUG) - printk (KERN_INFO "ppp_dev_stats called\n"); + printk (KERN_INFO "ppp_dev_stats called"); return &ppp_stats; } diff --git a/drivers/net/pt.c b/drivers/net/pt.c index d979ef83052a..9681e98a29e0 100644 --- a/drivers/net/pt.c +++ b/drivers/net/pt.c @@ -909,7 +909,7 @@ static int pt_open(struct device *dev) { unsigned long flags; struct pt_local *lp = dev->priv; - static int first_time = 1; + static first_time = 1; if (dev->base_addr & CHANA) { diff --git a/drivers/net/rcif.h b/drivers/net/rcif.h index a41f05aac20d..4996b01daba5 100644 --- a/drivers/net/rcif.h +++ b/drivers/net/rcif.h @@ -8,7 +8,7 @@ ** RedCreek InterFace include file. ** ** --------------------------------------------------------------------- -** --- Copyright (c) 1998-1999, RedCreek Communications Inc. --- +** --- Copyright (c) 1998, RedCreek Communications Inc. --- ** --- All rights reserved. --- ** --------------------------------------------------------------------- ** @@ -38,7 +38,7 @@ /* 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 */ +int USER_PROTOCOL_REV = 1; /* used to track different protocol revisions */ /* define a single TCB & buffer */ typedef struct /* a single buffer */ @@ -124,31 +124,6 @@ struct RC_user_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 { @@ -161,23 +136,12 @@ struct RC_user_tag 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; @@ -202,56 +166,35 @@ struct RC_user_tag 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 */ @@ -262,14 +205,7 @@ union RC_user_data_tag { /* structure tags used are taken from RC_user_ta #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 diff --git a/drivers/net/rclanmtl.c b/drivers/net/rcmtl.c similarity index 52% rename from drivers/net/rclanmtl.c rename to drivers/net/rcmtl.c index 504cd865e006..db1509affebd 100644 --- a/drivers/net/rclanmtl.c +++ b/drivers/net/rcmtl.c @@ -2,19 +2,19 @@ ** ************************************************************************* ** ** -** R C L A N M T L . C $Revision: 6 $ +** R C M T L . C $Revision: 1.1 $ ** ** -** RedCreek I2O LAN Message Transport Layer program module. +** RedCreek Message Transport Layer program module. ** ** --------------------------------------------------------------------- -** --- Copyright (c) 1997-1999, RedCreek Communications Inc. --- +** --- Copyright (c) 1997-1998, RedCreek Communications Inc. --- ** --- All rights reserved. --- ** --------------------------------------------------------------------- ** -** File Description: +** File Description: ** -** Host side I2O (Intelligent I/O) LAN message transport layer. +** Host side 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 @@ -30,158 +30,154 @@ ** 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. -** ************************************************************************* -*/ +***************************************************************************/ #undef DEBUG #define RC_LINUX_MODULE -#include "rclanmtl.h" +#include "rcmtl.h" #define dprintf kprintf extern int printk(const char * fmt, ...); /* RedCreek LAN device Target ID */ -#define RC_LAN_TARGET_ID 0x10 +#define LAN_TARGET_ID 0x10 /* RedCreek's OSM default LAN receive Initiator */ #define DEFAULT_RECV_INIT_CONTEXT 0xA17 /* -** I2O message structures +** message structures */ -#define I2O_TID_SZ 12 -#define I2O_FUNCTION_SZ 8 +#define TID_SZ 12 +#define 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 +#define TRL_SINGLE_FIXED_LENGTH 0x00 +#define TRL_SINGLE_VARIABLE_LENGTH 0x40 +#define TRL_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 +#define LAN_PACKET_SEND 0x3B +#define LAN_SDU_SEND 0x3D +#define LAN_RECEIVE_POST 0x3E +#define LAN_RESET 0x35 +#define 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 +#define RC_PRIVATE 0xFF + +/* RC Executive Function Codes. */ + +#define RC_CMD_ADAPTER_ASSIGN 0xB3 +#define RC_CMD_ADAPTER_READ 0xB2 +#define RC_CMD_ADAPTER_RELEASE 0xB5 +#define RC_CMD_BIOS_INFO_SET 0xA5 +#define RC_CMD_BOOT_DEVICE_SET 0xA7 +#define RC_CMD_CONFIG_VALIDATE 0xBB +#define RC_CMD_CONN_SETUP 0xCA +#define RC_CMD_DEVICE_ASSIGN 0xB7 +#define RC_CMD_DEVICE_RELEASE 0xB9 +#define RC_CMD_HRT_GET 0xA8 +#define RC_CMD_ADAPTER_CLEAR 0xBE +#define RC_CMD_ADAPTER_CONNECT 0xC9 +#define RC_CMD_ADAPTER_RESET 0xBD +#define RC_CMD_LCT_NOTIFY 0xA2 +#define RC_CMD_OUTBOUND_INIT 0xA1 +#define RC_CMD_PATH_ENABLE 0xD3 +#define RC_CMD_PATH_QUIESCE 0xC5 +#define RC_CMD_PATH_RESET 0xD7 +#define RC_CMD_STATIC_MF_CREATE 0xDD +#define RC_CMD_STATIC_MF_RELEASE 0xDF +#define RC_CMD_STATUS_GET 0xA0 +#define RC_CMD_SW_DOWNLOAD 0xA9 +#define RC_CMD_SW_UPLOAD 0xAB +#define RC_CMD_SW_REMOVE 0xAD +#define RC_CMD_SYS_ENABLE 0xD1 +#define RC_CMD_SYS_MODIFY 0xC1 +#define RC_CMD_SYS_QUIESCE 0xC3 +#define RC_CMD_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 RC_CMD_OUTBOUND_INIT_IN_PROGRESS 0x01 +#define RC_CMD_OUTBOUND_INIT_REJECTED 0x02 +#define RC_CMD_OUTBOUND_INIT_FAILED 0x03 +#define RC_CMD_OUTBOUND_INIT_COMPLETE 0x04 -#define I2O_UTIL_NOP 0x00 +#define UTIL_NOP 0x00 -/* I2O Get Status State values */ +/* RC 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 +#define ADAPTER_STATE_INITIALIZING 0x01 +#define ADAPTER_STATE_RESET 0x02 +#define ADAPTER_STATE_HOLD 0x04 +#define ADAPTER_STATE_READY 0x05 +#define ADAPTER_STATE_OPERATIONAL 0x08 +#define ADAPTER_STATE_FAILED 0x10 +#define ADAPTER_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 +#define RC_REPLY_STATUS_SUCCESS 0x00 +#define RC_REPLY_STATUS_ABORT_DIRTY 0x01 +#define RC_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02 +#define RC_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03 +#define RC_REPLY_STATUS_ERROR_DIRTY 0x04 +#define RC_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05 +#define RC_REPLY_STATUS_ERROR_PARTIAL_TRANSFER 0x06 +#define RC_REPLY_STATUS_PROCESS_ABORT_DIRTY 0x07 +#define RC_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x08 +#define RC_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x09 +#define RC_REPLY_STATUS_TRANSACTION_ERROR 0x0A +#define RC_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 RC_DS_SUCCESS 0x0000 +#define RC_DS_BAD_KEY 0x0001 +#define RC_DS_CHAIN_BUFFER_TOO_LARGE 0x0002 +#define RC_DS_DEVICE_BUSY 0x0003 +#define RC_DS_DEVICE_LOCKED 0x0004 +#define RC_DS_DEVICE_NOT_AVAILABLE 0x0005 +#define RC_DS_DEVICE_RESET 0x0006 +#define RC_DS_INAPPROPRIATE_FUNCTION 0x0007 +#define RC_DS_INSUFFICIENT_RESOURCE_HARD 0x0008 +#define RC_DS_INSUFFICIENT_RESOURCE_SOFT 0x0009 +#define RC_DS_INVALID_INITIATOR_ADDRESS 0x000A +#define RC_DS_INVALID_MESSAGE_FLAGS 0x000B +#define RC_DS_INVALID_OFFSET 0x000C +#define RC_DS_INVALID_PARAMETER 0x000D +#define RC_DS_INVALID_REQUEST 0x000E +#define RC_DS_INVALID_TARGET_ADDRESS 0x000F +#define RC_DS_MESSAGE_TOO_LARGE 0x0010 +#define RC_DS_MESSAGE_TOO_SMALL 0x0011 +#define RC_DS_MISSING_PARAMETER 0x0012 +#define RC_DS_NO_SUCH_PAGE 0x0013 +#define RC_DS_REPLY_BUFFER_FULL 0x0014 +#define RC_DS_TCL_ERROR 0x0015 +#define RC_DS_TIMEOUT 0x0016 +#define RC_DS_UNKNOWN_ERROR 0x0017 +#define RC_DS_UNKNOWN_FUNCTION 0x0018 +#define RC_DS_UNSUPPORTED_FUNCTION 0x0019 +#define RC_DS_UNSUPPORTED_VERSION 0x001A + + /* msg header defines for VersionOffset */ +#define RCMSGVER_1 0x0001 +#define SGL_OFFSET_0 RCMSGVER_1 +#define SGL_OFFSET_4 (0x0040 | RCMSGVER_1) +#define TRL_OFFSET_5 (0x0050 | RCMSGVER_1) +#define TRL_OFFSET_6 (0x0060 | RCMSGVER_1) + + /* msg header defines for MsgFlags */ #define MSG_STATIC 0x0100 #define MSG_64BIT_CNTXT 0x0200 #define MSG_MULTI_TRANS 0x1000 @@ -203,13 +199,13 @@ extern int printk(const char * fmt, ...); /* Special TID Assignments */ -#define I2O_IOP_TID 0 -#define I2O_HOST_TID 0xB91 +#define ADAPTER_TID 0 +#define HOST_TID 1 - /* RedCreek I2O private message codes */ + /* RedCreek 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_LAN_STATS 0x0003 #define RC_PRIVATE_GET_LINK_STATUS 0x0004 #define RC_PRIVATE_SET_LINK_SPEED 0x0005 #define RC_PRIVATE_SET_IP_AND_MASK 0x0006 @@ -220,27 +216,23 @@ extern int printk(const char * fmt, ...); #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 +/* RC message header */ +typedef struct _RC_MSG_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[] */ + U8 VersionOffset; + U8 MsgFlags; + U16 MessageSize; + BF TargetAddress:TID_SZ; + BF InitiatorAddress:TID_SZ; + BF Function:FUNCTION_SZ; + U32 InitiatorContext; + /* SGL[] */ } -I2O_MESSAGE_FRAME, *PI2O_MESSAGE_FRAME; + RC_MSG_FRAME, *PRC_MSG_FRAME; /* assumed a 16K minus 256 byte space for outbound queue message frames */ @@ -272,13 +264,13 @@ typedef struct tag_rcatu volatile unsigned long OutQueue; /* outbound queue port */ volatile unsigned long reserved4; volatile unsigned long reserver5; - /* RedCreek extension */ + /* RedCreek extension */ volatile unsigned long EtherMacLow; volatile unsigned long EtherMacHi; volatile unsigned long IPaddr; volatile unsigned long IPmask; } -ATU, *PATU; + ATU, *PATU; /* ** typedef PAB @@ -296,10 +288,10 @@ typedef struct PFNRXCALLBACK pRecvCallbackFunc; PFNCALLBACK pRebootCallbackFunc; PFNCALLBACK pCallbackFunc; - U16 IOPState; + U16 ADAPTERState; U16 InboundMFrameSize; } -PAB, *PPAB; + PAB, *PPAB; /* ** in reserved space right after PAB in host memory is area for returning @@ -328,25 +320,25 @@ static PPAB PCIAdapterBlock[MAX_ADAPTERS] = */ 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 */ + 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; + NICSTAT, *P_NICSTAT; #define DUMP_DONE 0x0000A005 /* completed statistical dump */ @@ -357,21 +349,21 @@ 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 void ProcessOutboundAdapterMsg(PPAB pPab, U32 phyMsgAddr); +static int FillAdapterMsgSGLFromTCB(PU32 pMsg, PRCTCB pXmitCntrlBlock); +static int GetAdapterStatus(PPAB pPab); +static int SendAdapterOutboundQInitMsg(PPAB pPab); static int SendEnableSysMsg(PPAB pPab); -/* 1st 100h bytes of message block is reserved for messenger instance */ + /* 1st 100h bytes of message block is reserved for messenger instance */ #define ADAPTER_BLOCK_RESERVED_SPACE 0x100 /* ** ========================================================================= -** RCInitI2OMsgLayer() +** InitRCApiMsgLayer() ** -** Initialize the RedCreek I2O Module and adapter. +** Initialize the RedCreek API Module and adapter. ** ** Inputs: AdapterID - interface number from 0 to 15 ** pciBaseAddr - virual base address of PCI (set by BIOS) @@ -386,29 +378,29 @@ static int SendEnableSysMsg(PPAB pPab); ** ========================================================================= */ RC_RETURN -RCInitI2OMsgLayer(U16 AdapterID, U32 pciBaseAddr, +InitRCApiMsgLayer(U16 AdapterID, U32 pciBaseAddr, PU8 p_msgbuf, PU8 p_phymsgbuf, PFNTXCALLBACK TransmitCallbackFunction, PFNRXCALLBACK ReceiveCallbackFunction, PFNCALLBACK RebootCallbackFunction) { - int result; - PPAB pPab; + int result; + PPAB pPab; #ifdef DEBUG - kprintf("InitI2O: Adapter:0x%04.4ux ATU:0x%08.8ulx msgbuf:0x%08.8ulx phymsgbuf:0x%08.8ulx\n" - "TransmitCallbackFunction:0x%08.8ulx ReceiveCallbackFunction:0x%08.8ulx\n", - AdapterID, pciBaseAddr, p_msgbuf, p_phymsgbuf, TransmitCallbackFunction, ReceiveCallbackFunction); + kprintf("InitAPI: Adapter:0x%04.4ux ATU:0x%08.8ulx msgbuf:0x%08.8ulx phymsgbuf:0x%08.8ulx\n" + "TransmitCallbackFunction:0x%08.8ulx ReceiveCallbackFunction:0x%08.8ulx\n", + AdapterID, pciBaseAddr, p_msgbuf, p_phymsgbuf, TransmitCallbackFunction, ReceiveCallbackFunction); #endif /* DEBUG */ - /* Check if this interface already initialized - if so, shut it down */ - if (PCIAdapterBlock[AdapterID] != NULL) - { - printk("PCIAdapterBlock[%d]!=NULL\n", AdapterID); + /* Check if this interface already initialized - if so, shut it down */ + if (PCIAdapterBlock[AdapterID] != NULL) + { + printk("PCIAdapterBlock[%d]!=NULL\n", AdapterID); // RCResetLANCard(AdapterID, 0, (PU32)NULL, (PFNCALLBACK)NULL); - PCIAdapterBlock[AdapterID] = NULL; - } + PCIAdapterBlock[AdapterID] = NULL; + } /* ** store adapter instance values in adapter block. @@ -419,39 +411,39 @@ RCInitI2OMsgLayer(U16 AdapterID, U32 pciBaseAddr, pPab->p_atu = (PATU)pciBaseAddr; pPab->pPci45LinBaseAddr = (PU8)pciBaseAddr; - /* Set outbound message frame addr - skip over Adapter Block */ + /* Set outbound message frame addr - skip over Adapter Block */ pPab->outMsgBlockPhyAddr = (U32)(p_phymsgbuf + ADAPTER_BLOCK_RESERVED_SPACE); pPab->pLinOutMsgBlock = (PU8)(p_msgbuf + ADAPTER_BLOCK_RESERVED_SPACE); - /* store callback function addresses */ + /* store callback function addresses */ pPab->pTransCallbackFunc = TransmitCallbackFunction; pPab->pRecvCallbackFunc = ReceiveCallbackFunction; pPab->pRebootCallbackFunc = RebootCallbackFunction; pPab->pCallbackFunc = (PFNCALLBACK)NULL; /* - ** Initialize I2O IOP + ** Initialize API */ - result = GetI2OStatus(pPab); + result = GetAdapterStatus(pPab); if (result != RC_RTN_NO_ERROR) return result; - if (pPab->IOPState == I2O_IOP_STATE_OPERATIONAL) + if (pPab->ADAPTERState == ADAPTER_STATE_OPERATIONAL) { - printk("pPab->IOPState == op: resetting adapter\n"); - RCResetLANCard(AdapterID, 0, (PU32)NULL, (PFNCALLBACK)NULL); + printk("pPab->ADAPTERState == op: resetting adapter\n"); + RCResetLANCard(AdapterID, 0, (PU32)NULL, (PFNCALLBACK)NULL); } - result = SendI2OOutboundQInitMsg(pPab); + result = SendAdapterOutboundQInitMsg(pPab); if (result != RC_RTN_NO_ERROR) - return result; + return result; result = SendEnableSysMsg(pPab); if (result != RC_RTN_NO_ERROR) - return result; + return result; PCIAdapterBlock[AdapterID] = pPab; return RC_RTN_NO_ERROR; @@ -459,17 +451,17 @@ RCInitI2OMsgLayer(U16 AdapterID, U32 pciBaseAddr, /* ** ========================================================================= -** Disable and Enable I2O interrupts. I2O interrupts are enabled at Init time +** Disable and Enable Adapter interrupts. Adapter 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 +** be sent through RCSendPacket() functions. Disabling Adapter interrupts +** will prevent hardware interrupt to host even though the outbound Adapter msg ** queue is not emtpy. ** ========================================================================= */ #define i960_OUT_POST_Q_INT_BIT 0x0008 /* bit set masks interrupts */ -RC_RETURN RCDisableI2OInterrupts(U16 AdapterID) +RC_RETURN RCDisableAdapterInterrupts(U16 AdapterID) { PPAB pPab; @@ -484,14 +476,14 @@ RC_RETURN RCDisableI2OInterrupts(U16 AdapterID) return RC_RTN_NO_ERROR; } -RC_RETURN RCEnableI2OInterrupts(U16 AdapterID) +RC_RETURN RCEnableAdapterInterrupts(U16 AdapterID) { PPAB pPab; pPab = PCIAdapterBlock[AdapterID]; if (pPab == NULL) - return RC_RTN_ADPTR_NOT_REGISTERED; + return RC_RTN_ADPTR_NOT_REGISTERED; pPab->p_atu->OutIntMask &= ~i960_OUT_POST_Q_INT_BIT; @@ -502,11 +494,11 @@ RC_RETURN RCEnableI2OInterrupts(U16 AdapterID) /* ** ========================================================================= -** RCI2OSendPacket() +** RCSendPacket() ** ========================================================================= */ RC_RETURN -RCI2OSendPacket(U16 AdapterID, U32 InitiatorContext, PRCTCB pTransCtrlBlock) +RCSendPacket(U16 AdapterID, U32 InitiatorContext, PRCTCB pTransCtrlBlock) { U32 msgOffset; PU32 pMsg; @@ -514,7 +506,7 @@ RCI2OSendPacket(U16 AdapterID, U32 InitiatorContext, PRCTCB pTransCtrlBlock) PPAB pPab; #ifdef DEBUG - kprintf("RCI2OSendPacket()...\n"); +kprintf("RCSendPacket()...\n"); #endif /* DEBUG */ pPab = PCIAdapterBlock[AdapterID]; @@ -522,40 +514,40 @@ RCI2OSendPacket(U16 AdapterID, U32 InitiatorContext, PRCTCB pTransCtrlBlock) 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 */ + /* 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) { #ifdef DEBUG - kprintf("RCI2OSendPacket(): Inbound Free Q empty!\n"); + kprintf("RCSendPacket(): Inbound Free Q empty!\n"); #endif /* DEBUG */ return RC_RTN_FREE_Q_EMPTY; } - /* calc virual address of msg - virual already mapped to physical */ + /* calc virual address of msg - virual already mapped to physical */ pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset); - size = FillI2OMsgSGLFromTCB(pMsg + 4, pTransCtrlBlock); + size = FillAdapterMsgSGLFromTCB(pMsg + 4, pTransCtrlBlock); if (size == -1) /* error processing TCB - send NOP msg */ { #ifdef DEBUG - kprintf("RCI2OSendPacket(): Error Rrocess TCB!\n"); + kprintf("RCSendPacket(): Error Rrocess TCB!\n"); #endif /* DEBUG */ pMsg[0] = THREE_WORD_MSG_SIZE | SGL_OFFSET_0; - pMsg[1] = I2O_UTIL_NOP << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID; + pMsg[1] = UTIL_NOP << 24 | HOST_TID << 12 | 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[1] = LAN_PACKET_SEND << 24 | HOST_TID << 12 | LAN_TARGET_ID; pMsg[2] = InitiatorContext; pMsg[3] = 0; /* batch reply */ - /* post to Inbound Post Q */ + /* post to Inbound Post Q */ pPab->p_atu->InQueue = msgOffset; return RC_RTN_NO_ERROR; } @@ -564,7 +556,7 @@ RCI2OSendPacket(U16 AdapterID, U32 InitiatorContext, PRCTCB pTransCtrlBlock) /* ** ========================================================================= -** RCI2OPostRecvBuffer() +** RCPostRecvBuffer() ** ** inputs: pBufrCntrlBlock - pointer to buffer control block ** @@ -580,32 +572,32 @@ RCPostRecvBuffers(U16 AdapterID, PRCTCB pTransCtrlBlock) PPAB pPab; #ifdef DEBUG - kprintf("RCPostRecvBuffers()...\n"); +kprintf("RCPostRecvBuffers()...\n"); #endif /* DEBUG */ - /* search for DeviceHandle */ + /* search for DeviceHandle */ pPab = PCIAdapterBlock[AdapterID]; 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 */ + /* 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) { #ifdef DEBUG - kprintf("RCPostRecvBuffers(): Inbound Free Q empty!\n"); + kprintf("RCPostRecvBuffers(): Inbound Free Q empty!\n"); #endif /* DEBUG */ return RC_RTN_FREE_Q_EMPTY; } - /* calc virual address of msg - virual already mapped to physical */ + /* calc virual address of msg - virual already mapped to physical */ pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset); - size = FillI2OMsgSGLFromTCB(pMsg + 4, pTransCtrlBlock); + size = FillAdapterMsgSGLFromTCB(pMsg + 4, pTransCtrlBlock); if (size == -1) /* error prcessing TCB - send 3 DWORD private msg == NOP */ { @@ -613,18 +605,18 @@ RCPostRecvBuffers(U16 AdapterID, PRCTCB pTransCtrlBlock) kprintf("RCPostRecvBuffers(): Error Processing TCB! size = %d\n", size); #endif /* DEBUG */ 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 */ + pMsg[1] = UTIL_NOP << 24 | HOST_TID << 12 | 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[1] = LAN_RECEIVE_POST << 24 | HOST_TID << 12 | LAN_TARGET_ID; pMsg[2] = DEFAULT_RECV_INIT_CONTEXT; pMsg[3] = *(PU32)pTransCtrlBlock; /* number of packet buffers */ - /* post to Post Q */ + /* post to Post Q */ pPab->p_atu->InQueue = msgOffset; return RC_RTN_NO_ERROR; } @@ -633,13 +625,13 @@ RCPostRecvBuffers(U16 AdapterID, PRCTCB pTransCtrlBlock) /* ** ========================================================================= -** RCProcI2OMsgQ() +** RCProcMsgQ() ** -** Process I2O outbound message queue until empty. +** Process outbound message queue until empty. ** ========================================================================= */ void -RCProcI2OMsgQ(U16 AdapterID) +RCProcMsgQ(U16 AdapterID) { U32 phyAddrMsg; PU8 p8Msg; @@ -662,35 +654,35 @@ RCProcI2OMsgQ(U16 AdapterID) //printk(" msg: 0x%x 0x%x \n", p8Msg[7], p32[5]); - /* - ** Send Packet Reply Msg - */ - if (I2O_LAN_PACKET_SEND == p8Msg[7]) /* function code byte */ + /* + ** Send Packet Reply Msg + */ + if (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, AdapterID); + /* status, count, context[], adapter */ + (*pPab->pTransCallbackFunc)(p8Msg[19], count, p32+5, AdapterID); } - /* - ** Receive Packet Reply Msg */ - else if (I2O_LAN_RECEIVE_POST == p8Msg[7]) + /* + ** Receive Packet Reply Msg */ + else if (LAN_RECEIVE_POST == p8Msg[7]) { #ifdef DEBUG - kprintf("I2O_RECV_REPLY pPab:0x%08.8ulx p8Msg:0x%08.8ulx p32:0x%08.8ulx\n", pPab, p8Msg, p32); - kprintf("msg: 0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", - p32[0], p32[1], p32[2], p32[3]); - kprintf(" 0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", - p32[4], p32[5], p32[6], p32[7]); - kprintf(" 0x%08.8ulx:0X%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", - p32[8], p32[9], p32[10], p32[11]); + kprintf("RECV_REPLY pPab:0x%08.8ulx p8Msg:0x%08.8ulx p32:0x%08.8ulx\n", pPab, p8Msg, p32); + kprintf("msg: 0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", + p32[0], p32[1], p32[2], p32[3]); + kprintf(" 0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", + p32[4], p32[5], p32[6], p32[7]); + kprintf(" 0x%08.8ulx:0X%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", + p32[8], p32[9], p32[10], p32[11]); #endif - /* status, count, buckets remaining, packetParmBlock, adapter */ - (*pPab->pRecvCallbackFunc)(p8Msg[19], p8Msg[12], p32[5], p32+6, AdapterID); + /* status, count, buckets remaining, packetParmBlock, adapter */ + (*pPab->pRecvCallbackFunc)(p8Msg[19], p8Msg[12], p32[5], p32+6, AdapterID); } - else if (I2O_LAN_RESET == p8Msg[7] || I2O_LAN_SHUTDOWN == p8Msg[7]) + else if (LAN_RESET == p8Msg[7] || LAN_SHUTDOWN == p8Msg[7]) { if (pPab->pCallbackFunc) { @@ -702,63 +694,63 @@ RCProcI2OMsgQ(U16 AdapterID) } //PCIAdapterBlock[AdapterID] = 0; } - else if (I2O_PRIVATE == p8Msg[7]) + else if (RC_PRIVATE == p8Msg[7]) { //printk("i2o private 0x%x, 0x%x \n", p8Msg[7], p32[5]); - switch (p32[5]) - { - case RC_PRIVATE_DEBUG_MSG: - msgFlag = 1; - /*printk("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'; - printk (debug_msg); - break; - case RC_PRIVATE_REBOOT: - printk("Adapter reboot initiated...\n"); - if (pPab->pRebootCallbackFunc) - { + switch (p32[5]) + { + case RC_PRIVATE_DEBUG_MSG: + msgFlag = 1; + /*printk("Received RC_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'; + printk (debug_msg); + break; + case RC_PRIVATE_REBOOT: + printk("Adapter reboot initiated...\n"); + if (pPab->pRebootCallbackFunc) + { (*pPab->pRebootCallbackFunc)(0,0,0,AdapterID); - } - break; - default: - printk("Unknown private I2O msg received: 0x%x\n", - p32[5]); - break; - } + } + break; + default: + printk("Unknown private msg received: 0x%x\n", + p32[5]); + break; + } } - /* - ** Process other Msg's - */ + /* + ** Process other Msg's + */ else { - ProcessOutboundI2OMsg(pPab, phyAddrMsg); + ProcessOutboundAdapterMsg(pPab, phyAddrMsg); } - /* return MFA to outbound free Q*/ + /* return MFA to outbound free Q*/ pPab->p_atu->OutQueue = phyAddrMsg; - /* any more msgs? */ + /* any more msgs? */ phyAddrMsg = pPab->p_atu->OutQueue; } } @@ -796,23 +788,23 @@ RCGetLinkStatistics(U16 AdapterID, if (msgOffset == 0xFFFFFFFF) { -#ifdef DEBUG + #ifdef DEBUG kprintf("Get8255XStats(): Inbound Free Q empty!\n"); -#endif + #endif return RC_RTN_FREE_Q_EMPTY; } - /* calc virual address of msg - virual already mapped to physical */ + /* calc virual address of msg - virual already mapped to physical */ pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset); /*dprintf("Get82558Stats - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/ /*dprintf("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[1] = RC_PRIVATE << 24 | HOST_TID << 12 | 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[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_LAN_STATS; pMsg[5] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); p32 = (PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); @@ -820,14 +812,14 @@ RCGetLinkStatistics(U16 AdapterID, pStats = (P_NICSTAT)p32; pStats->dump_status = 0xFFFFFFFF; - /* post to Inbound Post Q */ + /* post to Inbound Post Q */ pPab->p_atu->InQueue = msgOffset; timeout = 100000; while (1) { if (WaitCallback) - (*WaitCallback)(); + (*WaitCallback)(); for (i = 0; i < 1000; i++) ; @@ -837,16 +829,16 @@ RCGetLinkStatistics(U16 AdapterID, if (!timeout--) { -#ifdef DEBUG + #ifdef DEBUG kprintf("RCGet82558Stats() Timeout waiting for NIC statistics\n"); -#endif + #endif return RC_RTN_MSG_REPLY_TIMEOUT; } } pReturnAddr = (PU32)StatsReturnAddr; - /* copy Nic stats to user's structure */ + /* copy Nic stats to user's structure */ for (i = 0; i < (int) sizeof(RCLINKSTATS) / 4; i++) pReturnAddr[i] = p32[i]; @@ -879,19 +871,19 @@ RCGetLinkStatus(U16 AdapterID, PU32 ReturnAddr, PFNWAITCALLBACK WaitCallback) if (msgOffset == 0xFFFFFFFF) { -#ifdef DEBUG + #ifdef DEBUG dprintf("Get82558LinkStatus(): Inbound Free Q empty!\n"); -#endif + #endif return RC_RTN_FREE_Q_EMPTY; } - /* calc virual address of msg - virual already mapped to physical */ + /* calc virual address of msg - virual already mapped to physical */ pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset); /*dprintf("Get82558LinkStatus - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/ /*dprintf("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[1] = RC_PRIVATE << 24 | HOST_TID << 12 | 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; @@ -900,7 +892,7 @@ RCGetLinkStatus(U16 AdapterID, PU32 ReturnAddr, PFNWAITCALLBACK WaitCallback) p32 = (PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); *p32 = 0xFFFFFFFF; - /* post to Inbound Post Q */ + /* post to Inbound Post Q */ pPab->p_atu->InQueue = msgOffset; timeout = 100000; @@ -909,7 +901,7 @@ RCGetLinkStatus(U16 AdapterID, PU32 ReturnAddr, PFNWAITCALLBACK WaitCallback) U32 i; if (WaitCallback) - (*WaitCallback)(); + (*WaitCallback)(); for (i = 0; i < 1000; i++) ; @@ -919,9 +911,9 @@ RCGetLinkStatus(U16 AdapterID, PU32 ReturnAddr, PFNWAITCALLBACK WaitCallback) if (!timeout--) { -#ifdef DEBUG + #ifdef DEBUG kprintf("Timeout waiting for link status\n"); -#endif + #endif return RC_RTN_MSG_REPLY_TIMEOUT; } } @@ -943,76 +935,76 @@ RCGetLinkStatus(U16 AdapterID, PU32 ReturnAddr, PFNWAITCALLBACK WaitCallback) RC_RETURN RCGetMAC(U16 AdapterID, PU8 mac, PFNWAITCALLBACK WaitCallback) { - unsigned i, timeout; - U32 off; - PU32 p; - U32 temp[2]; - PPAB pPab; - PATU p_atu; + unsigned i, timeout; + U32 off; + PU32 p; + U32 temp[2]; + PPAB pPab; + PATU p_atu; - pPab = PCIAdapterBlock[AdapterID]; + pPab = PCIAdapterBlock[AdapterID]; - if (pPab == NULL) - return RC_RTN_ADPTR_NOT_REGISTERED; + if (pPab == NULL) + return RC_RTN_ADPTR_NOT_REGISTERED; - p_atu = pPab->p_atu; + p_atu = pPab->p_atu; - p_atu->EtherMacLow = 0; /* first zero return data */ - p_atu->EtherMacHi = 0; + p_atu->EtherMacLow = 0; /* first zero return data */ + p_atu->EtherMacHi = 0; - off = p_atu->InQueue; /* get addresss of message */ + off = p_atu->InQueue; /* get addresss of message */ - if (0xFFFFFFFF == off) - return RC_RTN_FREE_Q_EMPTY; + if (0xFFFFFFFF == off) + return RC_RTN_FREE_Q_EMPTY; - p = (PU32)(pPab->pPci45LinBaseAddr + off); + p = (PU32)(pPab->pPci45LinBaseAddr + off); #ifdef RCDEBUG - printk("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n", - (uint)p_atu, (uint)off, (uint)p); + printk("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n", + (uint)p_atu, (uint)off, (uint)p); #endif /* RCDEBUG */ - /* 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; + /* setup private message */ + p[0] = FIVE_WORD_MSG_SIZE | SGL_OFFSET_0; + p[1] = RC_PRIVATE << 24 | HOST_TID << 12 | 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 */ + p_atu->InQueue = off; /* send it to the device */ #ifdef RCDEBUG - printk("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n", - (uint)p_atu, (uint)off, (uint)p); + printk("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n", + (uint)p_atu, (uint)off, (uint)p); #endif /* RCDEBUG */ - /* wait for the rcpci45 board to update the info */ - timeout = 1000000; - while (0 == p_atu->EtherMacLow) - { - if (WaitCallback) - (*WaitCallback)(); + /* wait for the rcpci45 board to update the info */ + timeout = 1000000; + while (0 == p_atu->EtherMacLow) + { + if (WaitCallback) + (*WaitCallback)(); - for (i = 0; i < 1000; i++) - ; + for (i = 0; i < 1000; i++) + ; - if (!timeout--) - { - printk("rc_getmac: Timeout\n"); - return RC_RTN_MSG_REPLY_TIMEOUT; - } - } + 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); + /* read the mac address */ + temp[0] = p_atu->EtherMacLow; + temp[1] = p_atu->EtherMacHi; + memcpy((char *)mac, (char *)temp, 6); #ifdef RCDEBUG // printk("rc_getmac: 0x%X\n", ptr); #endif /* RCDEBUG */ - return RC_RTN_NO_ERROR; + return RC_RTN_NO_ERROR; } @@ -1040,20 +1032,20 @@ RCSetMAC(U16 AdapterID, PU8 mac) off = pPab->p_atu->InQueue; /* get addresss of message */ if (0xFFFFFFFF == off) - return RC_RTN_FREE_Q_EMPTY; + 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[1] = RC_PRIVATE << 24 | HOST_TID << 12 | 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 */ + pPab->p_atu->InQueue = off; /* send it to the device */ return RC_RTN_NO_ERROR ; } @@ -1089,264 +1081,22 @@ RCSetLinkSpeed(U16 AdapterID, U16 LinkSpeedCode) off = pPab->p_atu->InQueue; /* get addresss of message */ if (0xFFFFFFFF == off) - return RC_RTN_FREE_Q_EMPTY; + 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[1] = RC_PRIVATE << 24 | HOST_TID << 12 | 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(U16 AdapterID, U16 Mode) -{ - U32 off; - PU32 pMsg; - PPAB pPab; - - pPab =PCIAdapterBlock[AdapterID]; - - 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(U16 AdapterID, PU32 pMode, PFNWAITCALLBACK WaitCallback) -{ - U32 msgOffset, timeout; - PU32 pMsg; - volatile PU32 p32; - PPAB pPab; - - pPab =PCIAdapterBlock[AdapterID]; - - - msgOffset = pPab->p_atu->InQueue; - - - if (msgOffset == 0xFFFFFFFF) - { - kprintf("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 - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); - 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 - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); - - /* post to Inbound Post Q */ - - pPab->p_atu->InQueue = msgOffset; - - /* wait for response */ - timeout = 1000000; - while(1) - { - int i; - - if (WaitCallback) - (*WaitCallback)(); - - for (i = 0; i < 1000; i++) /* please don't hog the bus!!! */ - ; - - if (p32[0] != 0xff) - break; - - if (!timeout--) - { - kprintf("Timeout waiting for promiscuous mode from adapter\n"); - kprintf("0x%08.8ulx\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(U16 AdapterID, U16 Mode) -{ - U32 off; - PU32 pMsg; - PPAB pPab; - - pPab =PCIAdapterBlock[AdapterID]; - - 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(U16 AdapterID, PU32 pMode, PFNWAITCALLBACK WaitCallback) -{ - U32 msgOffset, timeout; - PU32 pMsg; - volatile PU32 p32; - PPAB pPab; - - pPab =PCIAdapterBlock[AdapterID]; - - - msgOffset = pPab->p_atu->InQueue; - - - if (msgOffset == 0xFFFFFFFF) - { - kprintf("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 - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); - 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 - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); - - /* post to Inbound Post Q */ - - pPab->p_atu->InQueue = msgOffset; - - /* wait for response */ - timeout = 1000000; - while(1) - { - int i; - - if (WaitCallback) - (*WaitCallback)(); - - for (i = 0; i < 1000; i++) /* please don't hog the bus!!! */ - ; - - if (p32[0] != 0xff) - break; - - if (!timeout--) - { - kprintf("Timeout waiting for promiscuous mode from adapter\n"); - kprintf("0x%08.8ulx\n", p32[0]); - return RC_RTN_NO_LINK_SPEED; - } - } - - /* get mode */ - *pMode = (U8)((volatile PU8)p32)[0] & 0x0f; - - return RC_RTN_NO_ERROR; -} /* ** ========================================================================= @@ -1365,73 +1115,73 @@ RCGetBroadcastMode(U16 AdapterID, PU32 pMode, PFNWAITCALLBACK WaitCallback) RC_RETURN RCGetLinkSpeed(U16 AdapterID, PU32 pLinkSpeedCode, PFNWAITCALLBACK WaitCallback) { - U32 msgOffset, timeout; - PU32 pMsg; - volatile PU32 p32; - U8 IOPLinkSpeed; - PPAB pPab; + U32 msgOffset, timeout; + PU32 pMsg; + volatile PU32 p32; + U8 AdapterLinkSpeed; + PPAB pPab; - pPab =PCIAdapterBlock[AdapterID]; + pPab =PCIAdapterBlock[AdapterID]; - msgOffset = pPab->p_atu->InQueue; + msgOffset = pPab->p_atu->InQueue; - if (msgOffset == 0xFFFFFFFF) - { - kprintf("RCGetLinkSpeed(): Inbound Free Q empty!\n"); - return RC_RTN_FREE_Q_EMPTY; - } + if (msgOffset == 0xFFFFFFFF) + { + kprintf("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); + /* 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 - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); - p32[0] = 0xff; + /* virtual pointer to return buffer - clear first two dwords */ + p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); + 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 - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); + /* setup private message */ + pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0; + pMsg[1] = RC_PRIVATE << 24 | HOST_TID << 12 | 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 - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); - /* post to Inbound Post Q */ + /* post to Inbound Post Q */ - pPab->p_atu->InQueue = msgOffset; + pPab->p_atu->InQueue = msgOffset; - /* wait for response */ - timeout = 1000000; - while(1) - { - int i; + /* wait for response */ + timeout = 1000000; + while(1) + { + int i; - if (WaitCallback) - (*WaitCallback)(); + if (WaitCallback) + (*WaitCallback)(); - for (i = 0; i < 1000; i++) /* please don't hog the bus!!! */ - ; + for (i = 0; i < 1000; i++) /* please don't hog the bus!!! */ + ; - if (p32[0] != 0xff) - break; + if (p32[0] != 0xff) + break; - if (!timeout--) - { - kprintf("Timeout waiting for link speed from IOP\n"); - kprintf("0x%08.8ulx\n", p32[0]); - return RC_RTN_NO_LINK_SPEED; - } - } + if (!timeout--) + { + kprintf("Timeout waiting for link speed from adapter\n"); + kprintf("0x%08.8ulx\n", p32[0]); + return RC_RTN_NO_LINK_SPEED; + } + } - /* get Link speed */ - IOPLinkSpeed = (U8)((volatile PU8)p32)[0] & 0x0f; + /* get Link speed */ + AdapterLinkSpeed = (U8)((volatile PU8)p32)[0] & 0x0f; - *pLinkSpeedCode= IOPLinkSpeed; + *pLinkSpeedCode= AdapterLinkSpeed; - return RC_RTN_NO_ERROR; + return RC_RTN_NO_ERROR; } /* @@ -1458,19 +1208,19 @@ RCReportDriverCapability(U16 AdapterID, U32 capability) off = pPab->p_atu->InQueue; /* get addresss of message */ if (0xFFFFFFFF == off) - return RC_RTN_FREE_Q_EMPTY; + 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[1] = RC_PRIVATE << 24 | HOST_TID << 12 | 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 */ + pPab->p_atu->InQueue = off; /* send it to the device */ return RC_RTN_NO_ERROR ; } @@ -1486,69 +1236,69 @@ RCReportDriverCapability(U16 AdapterID, U32 capability) RC_RETURN RCGetFirmwareVer(U16 AdapterID, PU8 pFirmString, PFNWAITCALLBACK WaitCallback) { - U32 msgOffset, timeout; - PU32 pMsg; - volatile PU32 p32; - PPAB pPab; + U32 msgOffset, timeout; + PU32 pMsg; + volatile PU32 p32; + PPAB pPab; - pPab =PCIAdapterBlock[AdapterID]; + pPab =PCIAdapterBlock[AdapterID]; - msgOffset = pPab->p_atu->InQueue; + msgOffset = pPab->p_atu->InQueue; - if (msgOffset == 0xFFFFFFFF) - { - kprintf("RCGetFirmwareVer(): Inbound Free Q empty!\n"); - return RC_RTN_FREE_Q_EMPTY; - } + if (msgOffset == 0xFFFFFFFF) + { + kprintf("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); + /* 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 - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); - p32[0] = 0xff; + /* virtual pointer to return buffer - clear first two dwords */ + p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); + 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 - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); + /* setup private message */ + pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0; + pMsg[1] = RC_PRIVATE << 24 | HOST_TID << 12 | 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 - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); - /* post to Inbound Post Q */ + /* post to Inbound Post Q */ - pPab->p_atu->InQueue = msgOffset; + pPab->p_atu->InQueue = msgOffset; - /* wait for response */ - timeout = 1000000; - while(1) - { - int i; + /* wait for response */ + timeout = 1000000; + while(1) + { + int i; - if (WaitCallback) - (*WaitCallback)(); + if (WaitCallback) + (*WaitCallback)(); - for (i = 0; i < 1000; i++) /* please don't hog the bus!!! */ - ; + for (i = 0; i < 1000; i++) /* please don't hog the bus!!! */ + ; - if (p32[0] != 0xff) - break; + if (p32[0] != 0xff) + break; - if (!timeout--) - { - kprintf("Timeout waiting for link speed from IOP\n"); - return RC_RTN_NO_FIRM_VER; - } - } - - strcpy(pFirmString, (PU8)p32); - return RC_RTN_NO_ERROR; + if (!timeout--) + { + kprintf("Timeout waiting for link speed from adapter\n"); + return RC_RTN_NO_FIRM_VER; + } + } + + strcpy(pFirmString, (PU8)p32); + return RC_RTN_NO_ERROR; } /* @@ -1582,7 +1332,7 @@ RCResetLANCard(U16 AdapterID, U16 ResourceFlags, PU32 ReturnAddr, PFNCALLBACK Ca off = pPab->p_atu->InQueue; /* get addresss of message */ if (0xFFFFFFFF == off) - return RC_RTN_FREE_Q_EMPTY; + return RC_RTN_FREE_Q_EMPTY; pPab->pCallbackFunc = CallbackFunction; @@ -1590,21 +1340,21 @@ RCResetLANCard(U16 AdapterID, U16 ResourceFlags, PU32 ReturnAddr, PFNCALLBACK Ca /* 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[1] = LAN_RESET << 24 | HOST_TID << 12 | 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 */ + pPab->p_atu->InQueue = off; /* send it to the device */ if (CallbackFunction == (PFNCALLBACK)NULL) { - /* call RCProcI2OMsgQ() until something in pPab->pCallbackFunc + /* call RCProcMsgQ() until something in pPab->pCallbackFunc or until timer goes off */ while (pPab->pCallbackFunc == (PFNCALLBACK)NULL) { - RCProcI2OMsgQ(AdapterID); + RCProcMsgQ(AdapterID); for (i = 0; i < 100000; i++) /* please don't hog the bus!!! */ - ; + ; timeout++; if (timeout > 10000) { @@ -1612,77 +1362,77 @@ RCResetLANCard(U16 AdapterID, U16 ResourceFlags, PU32 ReturnAddr, PFNCALLBACK Ca } } if (ReturnAddr != (PU32)NULL) - *ReturnAddr = (U32)pPab->pCallbackFunc; + *ReturnAddr = (U32)pPab->pCallbackFunc; } return RC_RTN_NO_ERROR ; } /* ** ========================================================================= -** RCResetIOP() +** RCResetAdapter() ** ** Send StatusGet Msg, wait for results return directly to buffer. ** ** ========================================================================= */ RC_RETURN -RCResetIOP(U16 AdapterID) +RCResetAdapter(U16 AdapterID) { - U32 msgOffset, timeout; - PU32 pMsg; - PPAB pPab; - volatile PU32 p32; - - pPab = PCIAdapterBlock[AdapterID]; - 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 - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); - pMsg[7] = 0; - pMsg[8] = 1; /* return 1 byte */ - - /* virual pointer to return buffer - clear first two dwords */ - p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); - p32[0] = 0; - p32[1] = 0; - - /* post to Inbound Post Q */ - - pPab->p_atu->InQueue = msgOffset; - - /* wait for response */ - timeout = 1000000; - while(1) - { - int i; + U32 msgOffset, timeout; + PU32 pMsg; + PPAB pPab; + volatile PU32 p32; + + pPab = PCIAdapterBlock[AdapterID]; + 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] = RC_CMD_ADAPTER_RESET << 24 | HOST_TID << 12 | ADAPTER_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 - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); + pMsg[7] = 0; + pMsg[8] = 1; /* return 1 byte */ + + /* virual pointer to return buffer - clear first two dwords */ + p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); + p32[0] = 0; + p32[1] = 0; + + /* post to Inbound Post Q */ + + pPab->p_atu->InQueue = msgOffset; + + /* wait for response */ + timeout = 1000000; + while(1) + { + int i; - for (i = 0; i < 1000; i++) /* please don't hog the bus!!! */ - ; + for (i = 0; i < 1000; i++) /* please don't hog the bus!!! */ + ; - if (p32[0] || p32[1]) - break; + if (p32[0] || p32[1]) + break; - if (!timeout--) - { - printk("RCResetIOP timeout\n"); - return RC_RTN_MSG_REPLY_TIMEOUT; - } - } - return RC_RTN_NO_ERROR; + if (!timeout--) + { + printk("RCResetAdapter timeout\n"); + return RC_RTN_MSG_REPLY_TIMEOUT; + } + } + return RC_RTN_NO_ERROR; } /* @@ -1715,7 +1465,7 @@ RCShutdownLANCard(U16 AdapterID, U16 ResourceFlags, PU32 ReturnAddr, PFNCALLBACK off = pPab->p_atu->InQueue; /* get addresss of message */ if (0xFFFFFFFF == off) - return RC_RTN_FREE_Q_EMPTY; + return RC_RTN_FREE_Q_EMPTY; pPab->pCallbackFunc = CallbackFunction; @@ -1723,30 +1473,29 @@ RCShutdownLANCard(U16 AdapterID, U16 ResourceFlags, PU32 ReturnAddr, PFNCALLBACK /* 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[1] = LAN_SHUTDOWN << 24 | HOST_TID << 12 | 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 */ + pPab->p_atu->InQueue = off; /* send it to the device */ if (CallbackFunction == (PFNCALLBACK)NULL) { - /* call RCProcI2OMsgQ() until something in pPab->pCallbackFunc + /* call RCProcMsgQ() until something in pPab->pCallbackFunc or until timer goes off */ while (pPab->pCallbackFunc == (PFNCALLBACK)NULL) { - RCProcI2OMsgQ(AdapterID); + RCProcMsgQ(AdapterID); for (i = 0; i < 100000; i++) /* please don't hog the bus!!! */ - ; + ; timeout++; if (timeout > 10000) { - printk("RCShutdownLANCard(): timeout\n"); break; } } if (ReturnAddr != (PU32)NULL) - *ReturnAddr = (U32)pPab->pCallbackFunc; + *ReturnAddr = (U32)pPab->pCallbackFunc; } return RC_RTN_NO_ERROR ; } @@ -1779,13 +1528,13 @@ RCSetRavlinIPandMask(U16 AdapterID, U32 ipAddr, U32 netMask) off = pPab->p_atu->InQueue; /* get addresss of message */ if (0xFFFFFFFF == off) - return RC_RTN_FREE_Q_EMPTY; + 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[1] = RC_PRIVATE << 24 | HOST_TID << 12 | 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; @@ -1793,7 +1542,7 @@ RCSetRavlinIPandMask(U16 AdapterID, U32 ipAddr, U32 netMask) pMsg[6] = netMask; - pPab->p_atu->InQueue = off; /* send it to the I2O device */ + pPab->p_atu->InQueue = off; /* send it to the device */ return RC_RTN_NO_ERROR ; } @@ -1808,7 +1557,7 @@ RCSetRavlinIPandMask(U16 AdapterID, U32 ipAddr, U32 netMask) */ RC_RETURN RCGetRavlinIPandMask(U16 AdapterID, PU32 pIpAddr, PU32 pNetMask, - PFNWAITCALLBACK WaitCallback) + PFNWAITCALLBACK WaitCallback) { unsigned i, timeout; U32 off; @@ -1828,8 +1577,8 @@ RCGetRavlinIPandMask(U16 AdapterID, PU32 pIpAddr, PU32 pNetMask, p_atu = pPab->p_atu; off = p_atu->InQueue; /* get addresss of message */ - if (0xFFFFFFFF == off) - return RC_RTN_FREE_Q_EMPTY; + if (0xFFFFFFFF == off) + return RC_RTN_FREE_Q_EMPTY; p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); *p32 = 0xFFFFFFFF; @@ -1841,33 +1590,33 @@ RCGetRavlinIPandMask(U16 AdapterID, PU32 pIpAddr, PU32 pNetMask, #endif /* DEBUG */ /* 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[1] = RC_PRIVATE << 24 | HOST_TID << 12 | 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 - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); - p_atu->InQueue = off; /* send it to the I2O device */ + p_atu->InQueue = off; /* send it to the device */ #ifdef DEBUG kprintf("RCGetRavlinIPandMask: p_atu 0x%08.8ulx, off 0x%08.8ulx, p32 0x%08.8ulx\n", p_atu, off, p32); #endif /* DEBUG */ - /* wait for the rcpci45 board to update the info */ + /* wait for the rcpci45 board to update the info */ timeout = 100000; while (0xffffffff == *p32) { if (WaitCallback) - (*WaitCallback)(); + (*WaitCallback)(); for (i = 0; i < 1000; i++) ; if (!timeout--) { -#ifdef DEBUG + #ifdef DEBUG kprintf("RCGetRavlinIPandMask: Timeout\n"); -#endif /* DEBUG */ - return RC_RTN_MSG_REPLY_TIMEOUT; + #endif /* DEBUG */ + return RC_RTN_MSG_REPLY_TIMEOUT; } } @@ -1900,12 +1649,12 @@ RCGetRavlinIPandMask(U16 AdapterID, PU32 pIpAddr, PU32 pNetMask, /* ** ========================================================================= -** SendI2OOutboundQInitMsg() +** SendAdapterOutboundQInitMsg() ** ** ========================================================================= */ static int -SendI2OOutboundQInitMsg(PPAB pPab) +SendAdapterOutboundQInitMsg(PPAB pPab) { U32 msgOffset, timeout, phyOutQFrames, i; volatile PU32 pMsg; @@ -1919,37 +1668,37 @@ SendI2OOutboundQInitMsg(PPAB pPab) if (msgOffset == 0xFFFFFFFF) { #ifdef DEBUG - kprintf("SendI2OOutboundQInitMsg(): Inbound Free Q empty!\n"); + kprintf("SendAdapterOutboundQInitMsg(): Inbound Free Q empty!\n"); #endif /* DEBUG */ return RC_RTN_FREE_Q_EMPTY; } - /* calc virual address of msg - virual already mapped to physical */ + /* calc virual address of msg - virual already mapped to physical */ pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset); #ifdef DEBUG - kprintf("SendI2OOutboundQInitMsg - pMsg = 0x%08.8ulx, InQ msgOffset = 0x%08.8ulx\n", pMsg, msgOffset); +kprintf("SendAdapterOutboundQInitMsg - pMsg = 0x%08.8ulx, InQ msgOffset = 0x%08.8ulx\n", pMsg, msgOffset); #endif /* DEBUG */ pMsg[0] = EIGHT_WORD_MSG_SIZE | TRL_OFFSET_6; - pMsg[1] = I2O_EXEC_OUTBOUND_INIT << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID; + pMsg[1] = RC_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 | ADAPTER_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 */ + /* phys address to return status - area right after PAB */ pMsg[7] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); - /* virual pointer to return buffer - clear first two dwords */ + /* virual pointer to return buffer - clear first two dwords */ p32 = (PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); p32[0] = 0; - /* post to Inbound Post Q */ + /* post to Inbound Post Q */ pPab->p_atu->InQueue = msgOffset; - /* wait for response */ + /* wait for response */ timeout = 100000; while(1) { @@ -1962,9 +1711,9 @@ SendI2OOutboundQInitMsg(PPAB pPab) if (!timeout--) { #ifdef DEBUG - kprintf("Timeout wait for InitOutQ InPrgress status from IOP\n"); + kprintf("Timeout wait for InitOutQ InPrgress status from adapter\n"); #endif /* DEBUG */ - return RC_RTN_NO_I2O_STATUS; + return RC_RTN_NO_STATUS; } } @@ -1974,19 +1723,19 @@ SendI2OOutboundQInitMsg(PPAB pPab) for (i = 0; i < 1000; i++) /* please don't hog the bus!!! */ ; - if (p32[0] == I2O_EXEC_OUTBOUND_INIT_COMPLETE) + if (p32[0] == RC_CMD_OUTBOUND_INIT_COMPLETE) break; if (!timeout--) { #ifdef DEBUG - kprintf("Timeout wait for InitOutQ Complete status from IOP\n"); + kprintf("Timeout wait for InitOutQ Complete status from adapter\n"); #endif /* DEBUG */ - return RC_RTN_NO_I2O_STATUS; + return RC_RTN_NO_STATUS; } } - /* load PCI outbound free Q with MF physical addresses */ + /* load PCI outbound free Q with MF physical addresses */ phyOutQFrames = pPab->outMsgBlockPhyAddr; for (i = 0; i < NMBR_MSG_FRAMES; i++) @@ -2000,14 +1749,14 @@ SendI2OOutboundQInitMsg(PPAB pPab) /* ** ========================================================================= -** GetI2OStatus() +** GetAdapterStatus() ** ** Send StatusGet Msg, wait for results return directly to buffer. ** ** ========================================================================= */ static int -GetI2OStatus(PPAB pPab) +GetAdapterStatus(PPAB pPab) { U32 msgOffset, timeout; PU32 pMsg; @@ -2015,49 +1764,47 @@ GetI2OStatus(PPAB pPab) msgOffset = pPab->p_atu->InQueue; -#ifdef DEBUG - printk("GetI2OStatus: msg offset = 0x%x\n", msgOffset); -#endif /* DEBUG */ + printk("GetAdapterStatus: msg offset = 0x%x\n", msgOffset); if (msgOffset == 0xFFFFFFFF) { #ifdef DEBUG - kprintf("GetI2OStatus(): Inbound Free Q empty!\n"); + kprintf("GetAdapterStatus(): Inbound Free Q empty!\n"); #endif /* DEBUG */ return RC_RTN_FREE_Q_EMPTY; } - /* calc virual address of msg - virual already mapped to physical */ + /* calc virual address of msg - virual 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[1] = RC_CMD_STATUS_GET << 24 | HOST_TID << 12 | ADAPTER_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 */ + /* phys address to return status - area right after PAB */ pMsg[6] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); pMsg[7] = 0; pMsg[8] = 88; /* return 88 bytes */ - /* virual pointer to return buffer - clear first two dwords */ + /* virual pointer to return buffer - clear first two dwords */ p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); p32[0] = 0; p32[1] = 0; #ifdef DEBUG - kprintf("GetI2OStatus - pMsg:0x%08.8ulx, msgOffset:0x%08.8ulx, [1]:0x%08.8ulx, [6]:0x%08.8ulx\n", - pMsg, msgOffset, pMsg[1], pMsg[6]); +kprintf("GetAdapterStatus - pMsg:0x%08.8ulx, msgOffset:0x%08.8ulx, [1]:0x%08.8ulx, [6]:0x%08.8ulx\n", + pMsg, msgOffset, pMsg[1], pMsg[6]); #endif /* DEBUG */ - /* post to Inbound Post Q */ + /* post to Inbound Post Q */ pPab->p_atu->InQueue = msgOffset; #ifdef DEBUG - kprintf("Return status to p32 = 0x%08.8ulx\n", p32); +kprintf("Return status to p32 = 0x%08.8ulx\n", p32); #endif /* DEBUG */ - /* wait for response */ + /* wait for response */ timeout = 1000000; while(1) { @@ -2072,27 +1819,27 @@ GetI2OStatus(PPAB pPab) if (!timeout--) { #ifdef DEBUG - kprintf("Timeout waiting for status from IOP\n"); - kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[0], p32[1], p32[2], p32[3]); - kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[4], p32[5], p32[6], p32[7]); - kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[8], p32[9], p32[10], p32[11]); + kprintf("Timeout waiting for status from adapter\n"); +kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[0], p32[1], p32[2], p32[3]); +kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[4], p32[5], p32[6], p32[7]); +kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[8], p32[9], p32[10], p32[11]); #endif /* DEBUG */ - return RC_RTN_NO_I2O_STATUS; + return RC_RTN_NO_STATUS; } } #ifdef DEBUG - kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[0], p32[1], p32[2], p32[3]); - kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[4], p32[5], p32[6], p32[7]); - kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[8], p32[9], p32[10], p32[11]); +kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[0], p32[1], p32[2], p32[3]); +kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[4], p32[5], p32[6], p32[7]); +kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[8], p32[9], p32[10], p32[11]); #endif /* DEBUG */ - /* get IOP state */ - pPab->IOPState = ((volatile PU8)p32)[10]; + /* get adapter state */ + pPab->ADAPTERState = ((volatile PU8)p32)[10]; pPab->InboundMFrameSize = ((volatile PU16)p32)[6]; #ifdef DEBUG - kprintf("IOP state 0x%02.2x InFrameSize = 0x%04.4x\n", - pPab->IOPState, pPab->InboundMFrameSize); + kprintf("adapter state 0x%02.2x InFrameSize = 0x%04.4x\n", + pPab->ADAPTERState, pPab->InboundMFrameSize); #endif /* DEBUG */ return RC_RTN_NO_ERROR; } @@ -2121,20 +1868,20 @@ SendEnableSysMsg(PPAB pPab) return RC_RTN_FREE_Q_EMPTY; } - /* calc virual address of msg - virual already mapped to physical */ + /* calc virual address of msg - virual already mapped to physical */ pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset); #ifdef DEBUG - kprintf("SendEnableSysMsg - pMsg = 0x%08.8ulx, InQ msgOffset = 0x%08.8ulx\n", pMsg, msgOffset); +kprintf("SendEnableSysMsg - pMsg = 0x%08.8ulx, InQ msgOffset = 0x%08.8ulx\n", pMsg, msgOffset); #endif /* DEBUG */ pMsg[0] = FOUR_WORD_MSG_SIZE | SGL_OFFSET_0; - pMsg[1] = I2O_EXEC_SYS_ENABLE << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID; + pMsg[1] = RC_CMD_SYS_ENABLE << 24 | HOST_TID << 12 | ADAPTER_TID; pMsg[2] = DEFAULT_RECV_INIT_CONTEXT; pMsg[3] = 0x110; /* transaction context */ pMsg[4] = 0x50657465; /* RedCreek Private */ - /* post to Inbound Post Q */ + /* post to Inbound Post Q */ pPab->p_atu->InQueue = msgOffset; return RC_RTN_NO_ERROR; @@ -2143,7 +1890,7 @@ SendEnableSysMsg(PPAB pPab) /* ** ========================================================================= -** FillI2OMsgFromTCB() +** FillI12OMsgFromTCB() ** ** inputs pMsgU32 - virual pointer (mapped to physical) of message frame ** pXmitCntrlBlock - pointer to caller buffer control block. @@ -2152,12 +1899,12 @@ SendEnableSysMsg(PPAB pPab) ** ========================================================================= */ static int -FillI2OMsgSGLFromTCB(PU32 pMsgFrame, PRCTCB pTransCtrlBlock) +FillAdapterMsgSGLFromTCB(PU32 pMsgFrame, PRCTCB pTransCtrlBlock) { unsigned int nmbrBuffers, nmbrSeg, nmbrDwords, context, flags; PU32 pTCB, pMsg; - /* SGL element flags */ + /* SGL element flags */ #define EOB 0x40000000 #define LE 0x80000000 #define SIMPLE_SGL 0x10000000 @@ -2168,10 +1915,10 @@ FillI2OMsgSGLFromTCB(PU32 pMsgFrame, PRCTCB pTransCtrlBlock) nmbrDwords = 0; #ifdef DEBUG - kprintf("FillI2OMsgSGLFromTCBX\n"); - kprintf("TCB 0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", - pTCB[0], pTCB[1], pTCB[2], pTCB[3], pTCB[4]); - kprintf("pTCB 0x%08.8ulx, pMsg 0x%08.8ulx\n", pTCB, pMsg); + kprintf("FillAdapterMsgSGLFromTCBX\n"); +kprintf("TCB 0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", + pTCB[0], pTCB[1], pTCB[2], pTCB[3], pTCB[4]); +kprintf("pTCB 0x%08.8ulx, pMsg 0x%08.8ulx\n", pTCB, pMsg); #endif /* DEBUG */ nmbrBuffers = *pTCB++; @@ -2201,7 +1948,7 @@ FillI2OMsgSGLFromTCB(PU32 pMsgFrame, PRCTCB pTransCtrlBlock) flags |= LE; } - /* 1st SGL buffer element has context */ + /* 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 */ @@ -2241,30 +1988,30 @@ FillI2OMsgSGLFromTCB(PU32 pMsgFrame, PRCTCB pTransCtrlBlock) /* ** ========================================================================= -** ProcessOutboundI2OMsg() +** ProcessOutboundAdapterMsg() ** -** process I2O reply message +** process reply message ** * change to msg structure * ** ========================================================================= */ static void -ProcessOutboundI2OMsg(PPAB pPab, U32 phyAddrMsg) +ProcessOutboundAdapterMsg(PPAB pPab, U32 phyAddrMsg) { PU8 p8Msg; PU32 p32; - // U16 count; + // U16 count; p8Msg = pPab->pLinOutMsgBlock + (phyAddrMsg - pPab->outMsgBlockPhyAddr); p32 = (PU32)p8Msg; #ifdef DEBUG - kprintf("VXD: ProcessOutboundI2OMsg - pPab 0x%08.8ulx, phyAdr 0x%08.8ulx, linAdr 0x%08.8ulx\n", pPab, phyAddrMsg, p8Msg); - kprintf("msg :0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[0], p32[1], p32[2], p32[3]); - kprintf("msg :0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[4], p32[5], p32[6], p32[7]); + kprintf("VXD: ProcessOutboundAdapterMsg - pPab 0x%08.8ulx, phyAdr 0x%08.8ulx, linAdr 0x%08.8ulx\n", pPab, phyAddrMsg, p8Msg); + kprintf("msg :0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[0], p32[1], p32[2], p32[3]); + kprintf("msg :0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[4], p32[5], p32[6], p32[7]); #endif /* DEBUG */ - if (p32[4] >> 24 != I2O_REPLY_STATUS_SUCCESS) + if (p32[4] >> 24 != RC_REPLY_STATUS_SUCCESS) { #ifdef DEBUG kprintf("Message reply status not success\n"); @@ -2274,38 +2021,38 @@ ProcessOutboundI2OMsg(PPAB pPab, U32 phyAddrMsg) switch (p8Msg[7] ) /* function code byte */ { - case I2O_EXEC_SYS_TAB_SET: - msgFlag = 1; + case RC_CMD_SYS_TAB_SET: + msgFlag = 1; #ifdef DEBUG - kprintf("Received I2O_EXEC_SYS_TAB_SET reply\n"); + kprintf("Received RC_CMD_SYS_TAB_SET reply\n"); #endif /* DEBUG */ - break; + break; - case I2O_EXEC_HRT_GET: - msgFlag = 1; + case RC_CMD_HRT_GET: + msgFlag = 1; #ifdef DEBUG - kprintf("Received I2O_EXEC_HRT_GET reply\n"); + kprintf("Received RC_CMD_HRT_GET reply\n"); #endif /* DEBUG */ - break; + break; - case I2O_EXEC_LCT_NOTIFY: - msgFlag = 1; + case RC_CMD_LCT_NOTIFY: + msgFlag = 1; #ifdef DEBUG - kprintf("Received I2O_EXEC_LCT_NOTIFY reply\n"); + kprintf("Received RC_CMD_LCT_NOTIFY reply\n"); #endif /* DEBUG */ - break; + break; - case I2O_EXEC_SYS_ENABLE: - msgFlag = 1; + case RC_CMD_SYS_ENABLE: + msgFlag = 1; #ifdef DEBUG - kprintf("Received I2O_EXEC_SYS_ENABLE reply\n"); + kprintf("Received RC_CMD_SYS_ENABLE reply\n"); #endif /* DEBUG */ - break; + break; - default: + default: #ifdef DEBUG kprintf("Received UNKNOWN reply\n"); #endif /* DEBUG */ - break; + break; } } diff --git a/drivers/net/rclanmtl.h b/drivers/net/rcmtl.h similarity index 78% rename from drivers/net/rclanmtl.h rename to drivers/net/rcmtl.h index 2e594440cdf2..cfd14e0fa888 100644 --- a/drivers/net/rclanmtl.h +++ b/drivers/net/rcmtl.h @@ -2,20 +2,19 @@ ** ************************************************************************* ** ** -** R C L A N M T L . H $Revision: 6 $ +** R C M T L . H $Revision: 3 $ ** ** -** RedCreek I2O LAN Message Transport Layer header file. +** RedCreek Message Transport Layer header file. ** ** --------------------------------------------------------------------- -** --- Copyright (c) 1997-1999, RedCreek Communications Inc. --- +** --- Copyright (c) 1997-1998, RedCreek Communications Inc. --- ** --- All rights reserved. --- ** --------------------------------------------------------------------- ** ** File Description: ** -** Header file for host I2O (Intelligent I/O) LAN message transport layer -** API and data types. +** Header file for host 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 @@ -34,8 +33,8 @@ ** ************************************************************************* */ -#ifndef RCLANMTL_H -#define RCLANMTL_H +#ifndef RCMTL_H +#define RCMTL_H /* Linux specific includes */ #define kprintf printk @@ -52,7 +51,7 @@ /* RedCreek API function return values */ #define RC_RTN_NO_ERROR 0 -#define RC_RTN_I2O_NOT_INIT 1 +#define RC_RTN_NOT_INIT 1 #define RC_RTN_FREE_Q_EMPTY 2 #define RC_RTN_TCB_ERROR 3 #define RC_RTN_TRANSACTION_ERROR 4 @@ -60,7 +59,7 @@ #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_STATUS 9 #define RC_RTN_NO_FIRM_VER 10 #define RC_RTN_NO_LINK_SPEED 11 @@ -89,10 +88,10 @@ typedef void (*PFNWAITCALLBACK)(void); /* void argument avoids compiler complai ** 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 + ** called from RCProcMsgQ() when packet have been transmitted from buffers + ** given in the RCSendPacket() 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 + ** and passed in the TCB to the RCSendPacket() 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. @@ -106,7 +105,7 @@ typedef void (*PFNTXCALLBACK)(U32 Status, ** type PFNRXCALLBACK ** ** Pointer to user's receive callback function. This user function - ** is called from RCProcI2OMsgQ() when packets have been received into + ** is called from RCProcMsgQ() 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. @@ -145,29 +144,29 @@ typedef void (*PFNCALLBACK)(U32 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 +#define RC_REPLY_STATUS_SUCCESS 0x00 +#define RC_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02 +#define RC_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 +#define RC_DSC_SUCCESS 0x0000 +#define RC_DSC_DEVICE_FAILURE 0x0001 +#define RC_DSC_DESTINATION_NOT_FOUND 0x0002 +#define RC_DSC_TRANSMIT_ERROR 0x0003 +#define RC_DSC_TRANSMIT_ABORTED 0x0004 +#define RC_DSC_RECEIVE_ERROR 0x0005 +#define RC_DSC_RECEIVE_ABORTED 0x0006 +#define RC_DSC_DMA_ERROR 0x0007 +#define RC_DSC_BAD_PACKET_DETECTED 0x0008 +#define RC_DSC_OUT_OF_MEMORY 0x0009 +#define RC_DSC_BUCKET_OVERRUN 0x000A +#define RC_DSC_IOP_INTERNAL_ERROR 0x000B +#define RC_DSC_CANCELED 0x000C +#define RC_DSC_INVALID_TRANSACTION_CONTEXT 0x000D +#define RC_DSC_DESTINATION_ADDRESS_DETECTED 0x000E +#define RC_DSC_DESTINATION_ADDRESS_OMITTED 0x000F +#define RC_DSC_PARTIAL_PACKET_RETURNED 0x0010 /* @@ -212,7 +211,7 @@ typedef void (*PFNCALLBACK)(U32 Status, ** 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 +** RCSendPacket() 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. @@ -283,17 +282,17 @@ typedef struct typedef PU32 PRCTCB; /* ** ------------------------------------------------------------------------- -** Exported functions comprising the API to the LAN I2O message transport layer +** Exported functions comprising the API to the message transport layer ** ------------------------------------------------------------------------- */ /* - ** InitRCI2OMsgLayer() + ** InitRCApiMsgLayer() ** - ** Called once prior to using the I2O LAN message transport layer. User + ** Called once prior to using the API 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 + ** that is used as a private buffer for the RedCreek API 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 @@ -310,7 +309,7 @@ typedef PU32 PRCTCB; ** ReceiveCallbackFunction - address of user's RX callback function ** */ -RC_RETURN RCInitI2OMsgLayer(U16 AdapterID, U32 pciBaseAddr, +RC_RETURN InitRCApiMsgLayer(U16 AdapterID, U32 pciBaseAddr, PU8 p_msgbuf, PU8 p_phymsgbuf, PFNTXCALLBACK TransmitCallbackFunction, PFNRXCALLBACK ReceiveCallbackFunction, @@ -342,7 +341,7 @@ RCGetRavlinIPandMask(U16 AdapterID, PU32 pIpAddr, PU32 pNetMask, PFNWAITCALLBACK WaitCallback); /* - ** RCProcI2OMsgQ() + ** RCProcMsgQ() ** ** Called from user's polling loop or Interrupt Service Routine for a PCI ** interrupt from the RedCreek PCI adapter. User responsible for determining @@ -350,19 +349,19 @@ RCGetRavlinIPandMask(U16 AdapterID, PU32 pIpAddr, PU32 pNetMask, ** callback functions, TransmitCallbackFunction or ReceiveCallbackFunction, ** if a TX or RX transaction has completed. */ -void RCProcI2OMsgQ(U16 AdapterID); +void RCProcMsgQ(U16 AdapterID); /* - ** Disable and Enable I2O interrupts. I2O interrupts are enabled at Init time - ** but can be disabled and re-enabled through these two function calls. + ** Disable and Enable Adapter interrupts. Adapter 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 recieved buffers and packets will - ** be sent through RCI2OSendPacket() functions. Disabling I2O interrupts - ** will prevent hardware interrupt to host even though the outbound I2O msg + ** be sent through RCSendPacket() functions. Disabling Adapter interrupts + ** will prevent hardware interrupt to host even though the outbound msg ** queue is not emtpy. */ -RC_RETURN RCEnableI2OInterrupts(U16 adapterID); -RC_RETURN RCDisableI2OInterrupts(U16 AdapterID); +RC_RETURN RCEnableAdapterInterrupts(U16 adapterID); +RC_RETURN RCDisableAdapterInterrupts(U16 AdapterID); /* @@ -381,7 +380,7 @@ RC_RETURN RCPostRecvBuffers(U16 AdapterID, PRCTCB pTransactionCtrlBlock); #define MAX_NMBR_POST_BUFFERS_PER_MSG 32 /* - ** RCI2OSendPacket() + ** RCSendPacket() ** ** Send user's ethernet packet from a locked page buffer. ** Packet must have full MAC header, however without a CRC. @@ -390,7 +389,7 @@ RC_RETURN RCPostRecvBuffers(U16 AdapterID, PRCTCB pTransactionCtrlBlock); ** Transmit buffer are considered owned by the adapter until context's ** returned to user through the TransmitCallbackFunction. */ -RC_RETURN RCI2OSendPacket(U16 AdapterID, +RC_RETURN RCSendPacket(U16 AdapterID, U32 context, PRCTCB pTransactionCtrlBlock); @@ -440,8 +439,8 @@ RC_RETURN RCGetLinkStatus(U16 AdapterID, PFNWAITCALLBACK WaitCallback); /* Link Status defines - value returned in pReturnStatus */ -#define RC_LAN_LINK_STATUS_DOWN 0 -#define RC_LAN_LINK_STATUS_UP 1 +#define LAN_LINK_STATUS_DOWN 0 +#define LAN_LINK_STATUS_UP 1 /* ** RCGetMAC() @@ -492,63 +491,7 @@ RC_RETURN RCSetLinkSpeed(U16 AdapterID, U16 LinkSpeedCode); RC_RETURN RCGetLinkSpeed(U16 AdapterID, PU32 pLinkSpeedCode, PFNWAITCALLBACK WaitCallback); -/* -** ========================================================================= -** RCSetPromiscuousMode(U16 AdapterID, 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(U16 AdapterID, U16 Mode); -/* -** ========================================================================= -** RCGetPromiscuousMode(U16 AdapterID, 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(U16 AdapterID, PU32 pMode, PFNWAITCALLBACK WaitCallback); -/* -** ========================================================================= -** RCSetBroadcastMode(U16 AdapterID, 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(U16 AdapterID, U16 Mode); -/* -** ========================================================================= -** RCGetBroadcastMode(U16 AdapterID, 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(U16 AdapterID, PU32 pMode, PFNWAITCALLBACK WaitCallback); /* ** ========================================================================= ** RCReportDriverCapability(U16 AdapterID, U32 capability) @@ -586,13 +529,13 @@ RCGetFirmwareVer(U16 AdapterID, PU8 pFirmString, PFNWAITCALLBACK WaitCallback); ** 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 + ** host with reply status of RC_REPLY_STATUS_ABORT_NO_DATA_TRANSFER and + ** detailed status of RC_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). + ** to complete (please disable adapter 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. @@ -609,13 +552,13 @@ RC_RETURN RCResetLANCard(U16 AdapterID, U16 ResourceFlags, PU32 ReturnAddr, PFNC ** 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 + ** to the host with reply status of RC_REPLY_STATUS_ABORT_NO_DATA_TRANSFER + ** and detailed status of RC_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). + ** to complete (please disable adapter 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. @@ -625,13 +568,13 @@ RC_RETURN RCShutdownLANCard(U16 AdapterID, U16 ResourceFlags, PU32 ReturnAddr, PFNCALLBACK CallbackFunction); /* - ** RCResetIOP(); - ** Initializes IOPState to I2O_IOP_STATE_RESET. + ** RCResetAdapter(); + ** Initializes ADAPTERState to ADAPTER_STATE_RESET. ** Stops access to outbound message Q. ** Discards any outstanding transmit or posted receive buffers. ** Clears outbound message Q. */ RC_RETURN -RCResetIOP(U16 AdapterID); +RCResetAdapter(U16 AdapterID); -#endif /* RCLANMTL_H */ +#endif /* RCMTL_H */ diff --git a/drivers/net/rcpci45.c b/drivers/net/rcpci45.c index 0aa979bc1648..ebc5f1f61fd0 100644 --- a/drivers/net/rcpci45.c +++ b/drivers/net/rcpci45.c @@ -1,11 +1,10 @@ /* -** ** RCpci45.c ** ** ** ** --------------------------------------------------------------------- -** --- Copyright (c) 1998, 1999, RedCreek Communications Inc. --- +** --- Copyright (c) 1998, RedCreek Communications Inc. --- ** --- All rights reserved. --- ** --------------------------------------------------------------------- ** @@ -13,13 +12,14 @@ ** ** Known Problems ** -** None known at this time. +** Billions and Billions... +** +** ... apparently added by Brian. Pete knows of no bugs. ** ** TODO: ** -Get rid of the wait loops in the API and replace them ** with system independent delays ...something like -** "delayms(2)". However, under normal circumstances, the -** delays are very short so they're not a problem. +** "delayms(2)". ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -35,24 +35,20 @@ ** along with this program; if not, write to the Free Software ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ** -** -** 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. -** ***************************************************************************/ +#define __NO_VERSION__ /* don't define kernel_verion in module.h */ + static char *version = -"RedCreek Communications PCI linux driver version 2.02\n"; +"RedCreek Communications PCI linux driver version 1.32 Beta\n"; +#include #include #include + +static char kernel_version [] = UTS_RELEASE; + #include #include #include @@ -69,34 +65,25 @@ static char *version = #include #include -#if LINUX_VERSION_CODE >= 0x020100 -#define LINUX_2_1 -#endif - -#ifdef LINUX_2_1 -#include -#endif - #include #include #include #include - #define RC_LINUX_MODULE -#include "rclanmtl.h" +#include "rcmtl.h" #include "rcif.h" #define RUN_AT(x) (jiffies + (x)) +#define DEV_ALLOC_SKB(len) dev_alloc_skb(len + 2) + +#define FREE_IRQ(irqnum, dev) free_irq(irqnum) +#define REQUEST_IRQ(i,h,f,n, instance) request_irq(i,h,f,n) +#define IRQ(irq, dev_id, pt_regs) (irq, pt_regs) #define NEW_MULTICAST #include -#ifndef LINUX_2_1 -#define ioremap vremap -#define iounmap vfree -#endif - /* PCI/45 Configuration space values */ #define RC_PCI45_VENDOR_ID 0x4916 #define RC_PCI45_DEVICE_ID 0x1960 @@ -124,25 +111,25 @@ static void rc_timer(unsigned long); typedef struct { - /* - * pointer to the device structure which is part - * of the interface to the Linux kernel. - */ - struct device *dev; + /* + * pointer to the device structure which is part + * of the interface to the Linux kernel. + */ + struct device *dev; - char devname[8]; /* "ethN" string */ - U8 id; /* the AdapterID */ - U32 pci_addr; /* the pci address of the adapter */ - U32 bus; - U32 function; - struct timer_list timer; /* timer */ - struct enet_statistics stats; /* the statistics structure */ - struct device *next; /* points to the next RC adapter */ - unsigned long numOutRcvBuffers;/* number of outstanding receive buffers*/ - unsigned char shutdown; - unsigned char reboot; - unsigned char nexus; - PU8 PLanApiPA; /* Pointer to Lan Api Private Area */ + char devname[8]; /* "ethN" string */ + U8 id; /* the AdapterID */ + U32 pci_addr; /* the pci address of the adapter */ + U32 bus; + U32 function; + struct timer_list timer; /* timer */ + struct enet_statistics stats; /* the statistics structure */ + struct device *next; /* points to the next RC adapter */ + unsigned long numOutRcvBuffers;/* number of outstanding receive buffers*/ + unsigned char shutdown; + unsigned char reboot; + unsigned char nexus; + PU8 PLanApiPA; /* Pointer to Lan Api Private Area */ } DPA, *PDPA; @@ -151,17 +138,18 @@ DPA, *PDPA; static PDPA PCIAdapters[MAX_ADAPTERS] = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; -static int RCinit(struct device *dev); -static int RCscan(struct device *dev); -static int RCfound_device(struct device *, int, int, int, int, int, int); +static int RCscan(void); +static struct device +*RCfound_device(struct device *, int, int, int, int, int, int); +static int RCprobe1(struct device *); static int RCopen(struct device *); static int RC_xmit_packet(struct sk_buff *, struct device *); static void RCinterrupt(int, void *, struct pt_regs *); @@ -182,282 +170,261 @@ static struct device *root_RCdev = NULL; #ifdef MODULE int init_module(void) #else -int rcpci_probe(struct device *dev) +int rcpci_probe(struct netdevice *dev) #endif { - int cards_found; + int cards_found; -#ifdef MODULE - cards_found = RCscan(NULL); + printk(version); + + root_RCdev = NULL; + cards_found = RCscan(); +#ifdef MODULE + return cards_found ? 0 : -ENODEV; #else - cards_found = RCscan(dev); -#endif - if (cards_found) - printk(version); - return cards_found ? 0 : -ENODEV; + return -1; +#endif } -static int RCscan(struct device *dev) +static int RCscan(void) { - int cards_found = 0; - static int pci_index = 0; - - if (!pcibios_present()) - return cards_found; - - for (;pci_index < 0x8; pci_index++) - { - unsigned char pci_bus, pci_device_fn; - int scan_status; - int board_index = 0; - unsigned char pci_irq_line; - unsigned short pci_command, vendor, device, class; - unsigned int pci_ioaddr; - - - scan_status = - (pcibios_find_device (RC_PCI45_VENDOR_ID, - RC_PCI45_DEVICE_ID, - pci_index, - &pci_bus, - &pci_device_fn)); + int cards_found = 0; + struct device *dev = 0; + + if (pcibios_present()) + { + static int pci_index = 0; + unsigned char pci_bus, pci_device_fn; + int scan_status; + int board_index = 0; + + for (;pci_index < 0xff; pci_index++) + { + unsigned char pci_irq_line; + unsigned short pci_command, vendor, device, class; + unsigned int pci_ioaddr; + + + scan_status = + (pcibios_find_device (RC_PCI45_VENDOR_ID, + RC_PCI45_DEVICE_ID, + pci_index, + &pci_bus, + &pci_device_fn)); #ifdef RCDEBUG - printk("rc scan_status = 0x%X\n", scan_status); + printk("rc scan_status = 0x%X\n", scan_status); #endif - if (scan_status != PCIBIOS_SUCCESSFUL) - break; - pcibios_read_config_word(pci_bus, - pci_device_fn, - PCI_VENDOR_ID, &vendor); - pcibios_read_config_word(pci_bus, - pci_device_fn, - PCI_DEVICE_ID, &device); - pcibios_read_config_byte(pci_bus, - pci_device_fn, - PCI_INTERRUPT_LINE, &pci_irq_line); - pcibios_read_config_dword(pci_bus, - pci_device_fn, - PCI_BASE_ADDRESS_0, &pci_ioaddr); - pcibios_read_config_word(pci_bus, - pci_device_fn, - PCI_CLASS_DEVICE, &class); - - pci_ioaddr &= ~0xf; + if (scan_status != PCIBIOS_SUCCESSFUL) + break; + pcibios_read_config_word(pci_bus, + pci_device_fn, + PCI_VENDOR_ID, &vendor); + pcibios_read_config_word(pci_bus, + pci_device_fn, + PCI_DEVICE_ID, &device); + pcibios_read_config_byte(pci_bus, + pci_device_fn, + PCI_INTERRUPT_LINE, &pci_irq_line); + pcibios_read_config_dword(pci_bus, + pci_device_fn, + PCI_BASE_ADDRESS_0, &pci_ioaddr); + pcibios_read_config_word(pci_bus, + pci_device_fn, + PCI_CLASS_DEVICE, &class); + + pci_ioaddr &= ~0xf; #ifdef RCDEBUG - printk("rc: Found RedCreek PCI adapter\n"); - printk("rc: pci class = 0x%x 0x%x \n", class, class>>8); - printk("rc: pci_bus = %d, pci_device_fn = %d\n", pci_bus, pci_device_fn); - printk("rc: pci_irq_line = 0x%x \n", pci_irq_line); - printk("rc: pci_ioaddr = 0x%x\n", pci_ioaddr); + printk("rc: Found RedCreek PCI adapter\n"); + printk("rc: pci class = 0x%x 0x%x \n", class, class>>8); + printk("rc: pci_bus = %d, pci_device_fn = %d\n", pci_bus, pci_device_fn); + printk("rc: pci_irq_line = 0x%x \n", pci_irq_line); + printk("rc: pci_ioaddr = 0x%x\n", pci_ioaddr); #endif - if (check_region(pci_ioaddr, 2*32768)) - { - printk("rc: check_region failed\n"); - continue; - } -#ifdef RCDEBUG - else - { - printk("rc: check_region passed\n"); - } -#endif - - /* - * Get and check the bus-master and latency values. - * Some PCI BIOSes fail to set the master-enable bit. - */ - - pcibios_read_config_word(pci_bus, - pci_device_fn, - PCI_COMMAND, - &pci_command); - if ( ! (pci_command & PCI_COMMAND_MASTER)) { - printk("rc: PCI Master Bit has not been set!\n"); - - pci_command |= PCI_COMMAND_MASTER; - pcibios_write_config_word(pci_bus, - pci_device_fn, - PCI_COMMAND, - pci_command); - } - if ( ! (pci_command & PCI_COMMAND_MEMORY)) { - /* - * If the BIOS did not set the memory enable bit, what else - * did it not initialize? Skip this adapter. - */ - printk("rc: Adapter %d, PCI Memory Bit has not been set!\n", - cards_found); - printk("rc: Bios problem? \n"); - continue; - } - - if (!RCfound_device(dev, pci_ioaddr, pci_irq_line, - pci_bus, pci_device_fn, - board_index++, cards_found)) - { - dev = 0; - cards_found++; - } - } -#ifdef RCDEBUG - printk("rc: found %d cards \n", cards_found); +#if 0 + if (check_region(pci_ioaddr, 32768)) + { + printk("rc: check_region failed\n"); + continue; + } + else + { + printk("rc: check_region passed\n"); + } #endif - return cards_found; -} - -static int RCinit(struct device *dev) -{ - 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; - return 0; + + /* + * Get and check the bus-master and latency values. + * Some PCI BIOSes fail to set the master-enable bit. + */ + + pcibios_read_config_word(pci_bus, + pci_device_fn, + PCI_COMMAND, + &pci_command); + if ( ! (pci_command & PCI_COMMAND_MASTER)) { + printk("rc: PCI Master Bit has not been set!\n"); + + pci_command |= PCI_COMMAND_MASTER; + pcibios_write_config_word(pci_bus, + pci_device_fn, + PCI_COMMAND, + pci_command); + } + if ( ! (pci_command & PCI_COMMAND_MEMORY)) { + /* + * If the BIOS did not set the memory enable bit, what else + * did it not initialize? Skip this adapter. + */ + printk("rc: Adapter %d, PCI Memory Bit has not been set!\n", + cards_found); + printk("rc: Bios problem? \n"); + continue; + } + + dev = RCfound_device(dev, pci_ioaddr, pci_irq_line, + pci_bus, pci_device_fn, + board_index++, cards_found); + + if (dev) { + dev = 0; + cards_found++; + } + } + } + printk("rc: found %d cards \n", cards_found); + return cards_found; } -static int +static struct device * RCfound_device(struct device *dev, int memaddr, int irq, int bus, int function, int product_index, int card_idx) { - int dev_size = 32768; - unsigned long *vaddr=0; - PDPA pDpa; - int init_status; - - /* - * Allocate and fill new device structure. - * We need enough for struct 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 device; the next chunk will be - * assigned to DPA; and finally, the rest will be assigned to the - * the LAN API layer. - */ - -#ifdef MODULE - dev = (struct device *) kmalloc(dev_size, GFP_DMA | GFP_KERNEL |GFP_ATOMIC); - if (!dev) - { - printk("rc: unable to kmalloc dev\n"); - return 1; - } - memset(dev, 0, dev_size); - /* - * dev->priv will point to the start of DPA. - */ - dev->priv = (void *)(((long)dev + sizeof(struct device) + 15) & ~15); -#else - dev->priv = 0; - dev->priv = (struct device *) kmalloc(dev_size, GFP_DMA | GFP_KERNEL |GFP_ATOMIC); - if (!dev->priv) - { - printk("rc: unable to kmalloc private area\n"); - return 1; - } - memset(dev->priv, 0, dev_size); -#endif - + int dev_size = 32768; + unsigned long *vaddr=0; + PDPA pDpa; + int init_status; + + /* + * Allocate and fill new device structure. + * We need enough for struct 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 device; the next chunk will be + * assigned to DPA; and finally, the rest will be assigned to the + * the LAN API layer. + */ + dev = (struct device *) kmalloc(dev_size, GFP_DMA | GFP_KERNEL |GFP_ATOMIC); + memset(dev, 0, dev_size); #ifdef RCDEBUG - printk("rc: dev = 0x%x, dev->priv = 0x%x\n", (uint)dev, (uint)dev->priv); -#endif + printk("rc: dev = 0x%08X\n", (uint)dev); +#endif - pDpa = dev->priv; - if (!dev->name) - dev->name = pDpa->devname; - - pDpa->dev = dev; /* this is just for easy reference */ - pDpa->function = function; - pDpa->bus = bus; - pDpa->id = card_idx; /* the device number */ - pDpa->pci_addr = memaddr; - PCIAdapters[card_idx] = pDpa; + /* + * dev->priv will point to the start of DPA. + */ + dev->priv = (void *)(((long)dev + sizeof(struct device) + 15) & ~15); + pDpa = dev->priv; + dev->name = pDpa->devname; + + pDpa->dev = dev; /* this is just for easy reference */ + pDpa->function = function; + pDpa->bus = bus; + pDpa->id = card_idx; /* the device number */ + pDpa->pci_addr = memaddr; + PCIAdapters[card_idx] = pDpa; #ifdef RCDEBUG - printk("rc: pDpa = 0x%x, id = %d \n", (uint)pDpa, (uint)pDpa->id); + printk("rc: pDpa = 0x%x, id = %d \n", (uint)pDpa, (uint)pDpa->id); #endif - /* - * Save the starting address of the LAN API private area. We'll - * pass that to RCInitI2OMsgLayer(). - */ - pDpa->PLanApiPA = (void *)(((long)pDpa + sizeof(DPA) + 0xff) & ~0xff); + /* + * Save the starting address of the LAN API private area. We'll + * pass that to InitRCApiMsgLayer(). + */ + pDpa->PLanApiPA = (void *)(((long)pDpa + sizeof(DPA) + 0xff) & ~0xff); #ifdef RCDEBUG - printk("rc: pDpa->PLanApiPA = 0x%x\n", (uint)pDpa->PLanApiPA); + printk("rc: pDpa->PLanApiPA = 0x%x\n", (uint)pDpa->PLanApiPA); #endif - /* The adapter is accessable 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 are normal memory. - */ - vaddr = (ulong *) ioremap (memaddr, 2*32768); + /* The adapter is accessable 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 are normal memory. + */ + vaddr = (ulong *) vremap (memaddr, 32768); #ifdef RCDEBUG - printk("rc: RCfound_device: 0x%x, priv = 0x%x, vaddr = 0x%x\n", - (uint)dev, (uint)dev->priv, (uint)vaddr); + printk("rc: RCfound_device: 0x%x, priv = 0x%x, vaddr = 0x%x\n", + (uint)dev, (uint)dev->priv, (uint)vaddr); #endif - dev->base_addr = (unsigned long)vaddr; - dev->irq = irq; - dev->interrupt = 0; - - /* - * Request a shared interrupt line. - */ - if ( request_irq(dev->irq, (void *)RCinterrupt, - SA_INTERRUPT|SA_SHIRQ, "RedCreek VPN Adapter", dev) ) - { - printk( "RC PCI 45: %s: unable to get IRQ %d\n", (PU8)dev->name, (uint)dev->irq ); - iounmap(vaddr); - kfree(dev); - return 1; - } + dev->base_addr = (unsigned long)vaddr; + dev->irq = irq; + dev->interrupt = 0; - init_status = RCInitI2OMsgLayer(pDpa->id, dev->base_addr, - pDpa->PLanApiPA, (PU8)virt_to_bus((void *)pDpa->PLanApiPA), - (PFNTXCALLBACK)RCxmit_callback, - (PFNRXCALLBACK)RCrecv_callback, - (PFNCALLBACK)RCreboot_callback); - if (init_status) - { - printk("rc: Unable to initialize msg layer\n"); - free_irq(dev->irq, dev); - iounmap(vaddr); - kfree(dev); - return 1; - } - if (RCGetMAC(pDpa->id, dev->dev_addr, NULL)) - { - printk("rc: Unable to get adapter MAC\n"); - free_irq(dev->irq, dev); - iounmap(vaddr); - kfree(dev); - return 1; - } - - DriverControlWord |= WARM_REBOOT_CAPABLE; - RCReportDriverCapability(pDpa->id, DriverControlWord); - - dev->init = &RCinit; - ether_setup(dev); /* linux kernel interface */ - - pDpa->next = root_RCdev; - root_RCdev = dev; - -#ifdef MODULE - if (register_netdev(dev) != 0) /* linux kernel interface */ - { - printk("rc: unable to register device \n"); - free_irq(dev->irq, dev); - iounmap(vaddr); - kfree(dev); - return 1; - } -#else - RCinit(dev); + /* + * Request a shared interrupt line. + */ + if ( request_irq(dev->irq, (void *)RCinterrupt, + SA_INTERRUPT|SA_SHIRQ, "RedCreek VPN Adapter", dev) ) + { + printk( "RC PCI 45: %s: unable to get IRQ %d\n", (PU8)dev->name, (uint)dev->irq ); + vfree(vaddr); + kfree(dev); + return 0; + } + + init_status = InitRCApiMsgLayer(pDpa->id, dev->base_addr, + pDpa->PLanApiPA, pDpa->PLanApiPA, + (PFNTXCALLBACK)RCxmit_callback, + (PFNRXCALLBACK)RCrecv_callback, + (PFNCALLBACK)RCreboot_callback); +#ifdef RCDEBUG + printk("rc: msg initted: status = 0x%x\n", init_status); #endif - printk("%s: RedCreek Communications IPSEC VPN adapter\n", - dev->name); + if (init_status) + { + printk("rc: Unable to initialize msg layer\n"); + free_irq(dev->irq, dev); + vfree(vaddr); + kfree(dev); + return 0; + } + if (RCGetMAC(pDpa->id, dev->dev_addr, NULL)) + { + printk("rc: Unable to get adapter MAC\n"); + free_irq(dev->irq, dev); + vfree(vaddr); + kfree(dev); + return 0; + } + + DriverControlWord |= WARM_REBOOT_CAPABLE; + RCReportDriverCapability(pDpa->id, DriverControlWord); + + dev->init = RCprobe1; + ether_setup(dev); /* linux kernel interface */ + + pDpa->next = root_RCdev; + root_RCdev = dev; + + if (register_netdev(dev) != 0) /* linux kernel interface */ + { + printk("rc: unable to register device \n"); + free_irq(dev->irq, dev); + vfree(vaddr); + kfree(dev); + return 0; + } + return dev; +} - return 0; /* success */ +static int RCprobe1(struct device *dev) +{ + 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; + return 0; } static int @@ -471,25 +438,25 @@ RCopen(struct device *dev) #ifdef RCDEBUG printk("rc: RCopen\n"); #endif - RCEnableI2OInterrupts(pDpa->id); + RCEnableAdapterInterrupts(pDpa->id); 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. - */ + /* 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("rc: Waking up adapter...\n"); RCResetLANCard(pDpa->id,0,0,0); } else { - pDpa->nexus = 1; + pDpa->nexus = 1; } while(post_buffers) @@ -502,19 +469,19 @@ RCopen(struct device *dev) if ( count < requested ) { - /* - * Check to see if we were able to post any buffers at all. - */ - if (post_buffers == MAX_NMBR_RCV_BUFFERS) - { - printk("rc: Error RCopen: not able to allocate any buffers\r\n"); - return(-ENOMEM); - } - printk("rc: Warning RCopen: not able to allocate all requested buffers\r\n"); - break; /* we'll try to post more buffers later */ + /* + * Check to see if we were able to post any buffers at all. + */ + if (post_buffers == MAX_NMBR_RCV_BUFFERS) + { + printk("rc: Error RCopen: not able to allocate any buffers\r\n"); + return(-ENOMEM); + } + printk("rc: Warning RCopen: not able to allocate all requested buffers\r\n"); + break; /* we'll try to post more buffers later */ } else - post_buffers -= count; + post_buffers -= count; } pDpa->numOutRcvBuffers = MAX_NMBR_RCV_BUFFERS - post_buffers; pDpa->shutdown = 0; /* just in case */ @@ -529,70 +496,68 @@ static int RC_xmit_packet(struct sk_buff *skb, struct device *dev) { - PDPA pDpa = (PDPA) dev->priv; - singleTCB tcb; - psingleTCB ptcb = &tcb; - RC_RETURN status = 0; + PDPA pDpa = (PDPA) dev->priv; + singleTCB tcb; + psingleTCB ptcb = &tcb; + RC_RETURN status = 0; - if (dev->tbusy || pDpa->shutdown || pDpa->reboot) - { + if (dev->tbusy || pDpa->shutdown || pDpa->reboot) + { #ifdef RCDEBUG - printk("rc: RC_xmit_packet: tbusy!\n"); + printk("rc: RC_xmit_packet: tbusy!\n"); #endif - dev->tbusy = 1; - return 1; - } + return 1; + } - if ( skb->len <= 0 ) - { - printk("RC_xmit_packet: skb->len less than 0!\n"); - return 0; - } - - /* - * 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 transmision 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 = virt_to_bus((void *)skb->data); + if ( skb->len <= 0 ) + { + printk("RC_xmit_packet: skb->len less than 0!\n"); + return 0; + } + + /* + * The user is free to reuse the TCB after RCSendPacket() 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 transmision 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 = (U32)skb->data; #ifdef RCDEBUG - printk("rc: RC xmit: skb = 0x%x, pDpa = 0x%x, id = %d, ptcb = 0x%x\n", - (uint)skb, (uint)pDpa, (uint)pDpa->id, (uint)ptcb); + printk("rc: RC xmit: skb = 0x%x, pDpa = 0x%x, id = %d, ptcb = 0x%x\n", + (uint)skb, (uint)pDpa, (uint)pDpa->id, (uint)ptcb); #endif - if ( (status = RCI2OSendPacket(pDpa->id, (U32)NULL, (PRCTCB)ptcb)) - != RC_RTN_NO_ERROR) - { + if ( (status = RCSendPacket(pDpa->id, (U32)NULL, (PRCTCB)ptcb)) + != RC_RTN_NO_ERROR) + { #ifdef RCDEBUG - printk("rc: RC send error 0x%x\n", (uint)status); + printk("rc: RC send error 0x%x\n", (uint)status); #endif - dev->tbusy = 1; - return 1; - } - else - { - dev->trans_start = jiffies; - // dev->tbusy = 0; - } - /* - * That's it! - */ - return 0; + dev->tbusy = 1; + } + else + { + dev->trans_start = jiffies; + // dev->tbusy = 0; + } + /* + * That's it! + */ + return 0; } /* * RCxmit_callback() * - * The transmit callback routine. It's called by RCProcI2OMsgQ() + * The transmit callback routine. It's called by RCProcMsgQ() * 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 @@ -609,84 +574,80 @@ RCxmit_callback(U32 Status, PDPA pDpa; struct device *dev; - pDpa = PCIAdapters[AdapterID]; - if (!pDpa) - { - printk("rc: Fatal error: xmit callback, !pDpa\n"); - return; - } - dev = pDpa->dev; + pDpa = PCIAdapters[AdapterID]; + if (!pDpa) + { + printk("rc: Fatal error: xmit callback, !pDpa\n"); + return; + } + dev = pDpa->dev; // printk("xmit_callback: Status = 0x%x\n", (uint)Status); - if (Status != I2O_REPLY_STATUS_SUCCESS) - { - printk("rc: xmit_callback: Status = 0x%x\n", (uint)Status); - } + if (Status != RC_REPLY_STATUS_SUCCESS) + { + printk("rc: xmit_callback: Status = 0x%x\n", (uint)Status); + } #ifdef RCDEBUG - if (pDpa->shutdown || pDpa->reboot) - printk("rc: xmit callback: shutdown||reboot\n"); + if (pDpa->shutdown || pDpa->reboot) + printk("rc: xmit callback: shutdown||reboot\n"); #endif #ifdef RCDEBUG - printk("rc: xmit_callback: PcktCount = %d, BC = 0x%x\n", - (uint)PcktCount, (uint)BufferContext); + printk("rc: xmit_callback: PcktCount = %d, BC = 0x%x\n", + (uint)PcktCount, (uint)BufferContext); #endif - while (PcktCount--) - { - skb = (struct sk_buff *)(BufferContext[0]); + while (PcktCount--) + { + skb = (struct sk_buff *)(BufferContext[0]); #ifdef RCDEBUG - printk("rc: skb = 0x%x\n", (uint)skb); + printk("rc: skb = 0x%x\n", (uint)skb); #endif - BufferContext++; -#ifdef LINUX_2_1 - dev_kfree_skb (skb); -#else - dev_kfree_skb (skb, FREE_WRITE); -#endif - } - dev->tbusy = 0; + BufferContext++; + dev_kfree_skb (skb, FREE_WRITE); + } + dev->tbusy = 0; } static void RCreset_callback(U32 Status, U32 p1, U32 p2, U16 AdapterID) { - PDPA pDpa; - struct device *dev; + PDPA pDpa; + struct device *dev; - pDpa = PCIAdapters[AdapterID]; - dev = pDpa->dev; + pDpa = PCIAdapters[AdapterID]; + dev = pDpa->dev; #ifdef RCDEBUG - printk("rc: RCreset_callback Status 0x%x\n", (uint)Status); + printk("rc: RCreset_callback Status 0x%x\n", (uint)Status); #endif - /* - * Check to see why we were called. - */ - if (pDpa->shutdown) - { - printk("rc: Shutting down interface\n"); - pDpa->shutdown = 0; - pDpa->reboot = 0; - MOD_DEC_USE_COUNT; - } - else if (pDpa->reboot) - { - printk("rc: reboot, shutdown adapter\n"); - /* - * 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(pDpa->id); - RCShutdownLANCard(pDpa->id,0,0,0); - printk("rc: scheduling timer...\n"); - 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); - } + /* + * Check to see why we were called. + */ + if (pDpa->shutdown) + { + printk("rc: Shutting down interface\n"); + pDpa->shutdown = 0; + pDpa->reboot = 0; + MOD_DEC_USE_COUNT; + } + else if (pDpa->reboot) + { + printk("rc: reboot, shutdown adapter\n"); + /* + * 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. + */ + RCDisableAdapterInterrupts(pDpa->id); + RCShutdownLANCard(pDpa->id,0,0,0); + printk("rc: scheduling timer...\n"); + init_timer(&pDpa->timer); + pDpa->timer.expires = RUN_AT((30*HZ)/10); /* 3 sec. */ + pDpa->timer.data = (unsigned long)dev; + pDpa->timer.function = &rc_timer; /* timer handler */ + add_timer(&pDpa->timer); + } @@ -695,33 +656,33 @@ RCreset_callback(U32 Status, U32 p1, U32 p2, U16 AdapterID) static void RCreboot_callback(U32 Status, U32 p1, U32 p2, U16 AdapterID) { - PDPA pDpa; + PDPA pDpa; - pDpa = PCIAdapters[AdapterID]; + pDpa = PCIAdapters[AdapterID]; #ifdef RCDEBUG - printk("rc: RCreboot: rcv buffers outstanding = %d\n", - (uint)pDpa->numOutRcvBuffers); + printk("rc: RCreboot: rcv buffers outstanding = %d\n", + (uint)pDpa->numOutRcvBuffers); #endif - if (pDpa->shutdown) - { - printk("rc: skipping reboot sequence -- shutdown already initiated\n"); - 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(pDpa->id, - RC_RESOURCE_RETURN_POSTED_RX_BUCKETS | - RC_RESOURCE_RETURN_PEND_TX_BUFFERS,0, - (PFNCALLBACK)RCreset_callback); + if (pDpa->shutdown) + { + printk("rc: skipping reboot sequence -- shutdown already initiated\n"); + 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(pDpa->id, + RC_RESOURCE_RETURN_POSTED_RX_BUCKETS | + RC_RESOURCE_RETURN_PEND_TX_BUFFERS,0, + (PFNCALLBACK)RCreset_callback); } @@ -738,7 +699,7 @@ int broadcast_packet(unsigned char * address) * RCrecv_callback() * * The receive packet callback routine. This is called by - * RCProcI2OMsgQ() after the adapter posts buffers which have been + * RCProcMsgQ() after the adapter posts buffers which have been * filled (one ethernet packet per buffer). */ static void @@ -749,149 +710,134 @@ RCrecv_callback(U32 Status, U16 AdapterID) { - U32 len, count; - PDPA pDpa; - struct sk_buff *skb; - struct device *dev; - singleTCB tcb; - psingleTCB ptcb = &tcb; + U32 len, count; + PDPA pDpa; + struct sk_buff *skb; + struct device *dev; + singleTCB tcb; + psingleTCB ptcb = &tcb; - pDpa = PCIAdapters[AdapterID]; - dev = pDpa->dev; + pDpa = PCIAdapters[AdapterID]; + dev = pDpa->dev; - ptcb->bcount = 1; + ptcb->bcount = 1; #ifdef RCDEBUG - printk("rc: RCrecv_callback: 0x%x, 0x%x, 0x%x\n", - (uint)PktCount, (uint)BucketsRemain, (uint)PacketDescBlock); + printk("rc: RCrecv_callback: 0x%x, 0x%x, 0x%x\n", + (uint)PktCount, (uint)BucketsRemain, (uint)PacketDescBlock); #endif #ifdef RCDEBUG - if ((pDpa->shutdown || pDpa->reboot) && !Status) - printk("shutdown||reboot && !Status: PktCount = %d\n",PktCount); + if ((pDpa->shutdown || pDpa->reboot) && !Status) + printk("shutdown||reboot && !Status: PktCount = %d\n",PktCount); #endif - if ( (Status != I2O_REPLY_STATUS_SUCCESS) || pDpa->shutdown) - { - /* - * Free whatever buffers the adapter returned, but don't - * pass them to the kernel. - */ + if ( (Status != RC_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("rc: RCrecv error: status = 0x%x\n", (uint)Status); + if (!pDpa->shutdown && !pDpa->reboot) + printk("rc: RCrecv error: status = 0x%x\n", (uint)Status); + else + printk("rc: Returning %d buffers, status = 0x%x\n", + 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 (Status == RC_REPLY_STATUS_ABORT_NO_DATA_TRANSFER) + { #ifdef RCDEBUG - else - printk("rc: Returning %d buffers, status = 0x%x\n", - PktCount, (uint)Status); + printk("RCrecv status ABORT NO DATA TRANSFER\n"); #endif - /* - * 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 (Status == I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER) - { + } + /* check for reset status: RC_REPLY_STATUS_ABORT_NO_DATA_TRANSFER */ + if (PacketDescBlock) + { + while(PktCount--) + { + skb = (struct sk_buff *)PacketDescBlock[0]; + skb->free = 1; + skb->lock = 0; #ifdef RCDEBUG - printk("RCrecv status ABORT NO DATA TRANSFER\n"); + printk("free skb 0x%p\n", skb); #endif - } - /* check for reset status: I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER */ - if (PacketDescBlock) - { - while(PktCount--) - { + dev_kfree_skb(skb, FREE_READ); + pDpa->numOutRcvBuffers--; + PacketDescBlock += BD_SIZE; /* point to next context field */ + } + } + return; + } + else + { + while(PktCount--) + { skb = (struct sk_buff *)PacketDescBlock[0]; -#ifndef LINUX_2_1 - skb->free = 1; - skb->lock = 0; -#endif -#ifdef RCDEBUG - printk("free skb 0x%p\n", skb); -#endif -#ifdef LINUX_2_1 - dev_kfree_skb (skb); -#else - dev_kfree_skb(skb, FREE_READ); -#endif - pDpa->numOutRcvBuffers--; - PacketDescBlock += BD_SIZE; /* point to next context field */ - } - } - return; - } - else - { - while(PktCount--) - { - skb = (struct sk_buff *)PacketDescBlock[0]; #ifdef RCDEBUG - if (pDpa->shutdown) - printk("shutdown: skb=0x%x\n", (uint)skb); + if (pDpa->shutdown) + printk("shutdown: skb=0x%x\n", (uint)skb); - printk("skb = 0x%x: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", (uint)skb, - (uint)skb->data[0], (uint)skb->data[1], (uint)skb->data[2], - (uint)skb->data[3], (uint)skb->data[4], (uint)skb->data[5]); + printk("skb = 0x%x: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", (uint)skb, + (uint)skb->data[0], (uint)skb->data[1], (uint)skb->data[2], + (uint)skb->data[3], (uint)skb->data[4], (uint)skb->data[5]); #endif - -#ifdef PROMISCUOUS_BY_DEFAULT /* early 2.x firmware */ - if ( (memcmp(dev->dev_addr, skb->data, 6)) && - (!broadcast_packet(skb->data))) - { - /* - * Re-post the buffer to the adapter. Since the adapter usually - * return 1 to 2 receive buffers at a time, it's not too inefficient - * post one buffer at a time but ... may be that should be - * optimized at some point. - */ - ptcb->b.context = (U32)skb; - ptcb->b.scount = 1; - ptcb->b.size = MAX_ETHER_SIZE; - ptcb->b.addr = virt_to_bus((void *)skb->data); - - if ( RCPostRecvBuffers(pDpa->id, (PRCTCB)ptcb ) != RC_RTN_NO_ERROR) + if ( (memcmp(dev->dev_addr, skb->data, 6)) && + (!broadcast_packet(skb->data))) { - printk("rc: RCrecv_callback: post buffer failed!\n"); -#ifdef LINUX_2_1 - dev_kfree_skb (skb); -#else - skb->free = 1; - dev_kfree_skb(skb, FREE_READ); -#endif + /* + * Re-post the buffer to the adapter. Since the adapter usually + * return 1 to 2 receive buffers at a time, it's not too inefficient + * post one buffer at a time but ... may be that should be + * optimized at some point. + */ + ptcb->b.context = (U32)skb; + ptcb->b.scount = 1; + ptcb->b.size = MAX_ETHER_SIZE; + ptcb->b.addr = (U32)skb->data; + + if ( RCPostRecvBuffers(pDpa->id, (PRCTCB)ptcb ) != RC_RTN_NO_ERROR) + { + printk("rc: RCrecv_callback: post buffer failed!\n"); + skb->free = 1; + dev_kfree_skb(skb, FREE_READ); + } + else + { + pDpa->numOutRcvBuffers++; + } } else { - pDpa->numOutRcvBuffers++; + 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; } - } - else -#endif /* PROMISCUOUS_BY_DEFAULT */ - { - 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--; - PacketDescBlock += BD_SIZE; /* point to next context field */ - } - } + pDpa->numOutRcvBuffers--; + PacketDescBlock += BD_SIZE; /* point to next context field */ + } + } - /* - * 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; - } + /* + * 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; + } } @@ -900,159 +846,156 @@ RCrecv_callback(U32 Status, * * Interrupt handler. * This routine sets up a couple of pointers and calls - * RCProcI2OMsgQ(), which in turn process the message and + * RCProcMsgQ(), which in turn process the message and * calls one of our callback functions. */ static void RCinterrupt(int irq, void *dev_id, struct pt_regs *regs) { - PDPA pDpa; - struct device *dev = (struct device *)(dev_id); + PDPA pDpa; + struct device *dev = (struct device *)(dev_id); - pDpa = (PDPA) (dev->priv); + pDpa = (PDPA) (dev->priv); -#ifdef RCDEBUG - if (pDpa->shutdown) - printk("rc: shutdown: service irq\n"); + if (pDpa->shutdown) + printk("rc: shutdown: service irq\n"); - printk("RC irq: pDpa = 0x%x, dev = 0x%x, id = %d\n", - (uint)pDpa, (uint)dev, (uint)pDpa->id); - printk("dev = 0x%x\n", (uint)dev); +#ifdef RCDEBUG + printk("RC irq: pDpa = 0x%x, dev = 0x%x, id = %d\n", + (uint)pDpa, (uint)dev, (uint)pDpa->id); + printk("dev = 0x%x\n", (uint)dev); #endif - if (dev->interrupt) - printk("%s: Re-entering the interrupt handler.\n", dev->name); - dev->interrupt = 1; + if (dev->interrupt) + printk("%s: Re-entering the interrupt handler.\n", dev->name); + dev->interrupt = 1; - RCProcI2OMsgQ(pDpa->id); - dev->interrupt = 0; + RCProcMsgQ(pDpa->id); + dev->interrupt = 0; - return; + return; } - -#define REBOOT_REINIT_RETRY_LIMIT 4 +#define REBOOT_REINIT_RETRY_LIMIT 10 static void rc_timer(unsigned long data) { - struct device *dev = (struct device *)data; - PDPA pDpa = (PDPA) (dev->priv); - int init_status; - static int retry = 0; - int post_buffers = MAX_NMBR_RCV_BUFFERS; - int count = 0; - int requested = 0; - - if (pDpa->reboot) - { - init_status = RCInitI2OMsgLayer(pDpa->id, dev->base_addr, - pDpa->PLanApiPA, - (PU8)virt_to_bus((void *)pDpa->PLanApiPA), - (PFNTXCALLBACK)RCxmit_callback, - (PFNRXCALLBACK)RCrecv_callback, - (PFNCALLBACK)RCreboot_callback); - - switch(init_status) - { - case RC_RTN_NO_ERROR: + struct device *dev = (struct device *)data; + PDPA pDpa = (PDPA) (dev->priv); + int init_status; + static int retry = 0; + int post_buffers = MAX_NMBR_RCV_BUFFERS; + int count = 0; + int requested = 0; + + if (pDpa->reboot) + { + + init_status = InitRCApiMsgLayer(pDpa->id, dev->base_addr, + pDpa->PLanApiPA, pDpa->PLanApiPA, + (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(pDpa->id, DriverControlWord); - RCEnableI2OInterrupts(pDpa->id); - - if (dev->flags & IFF_UP) - { - 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("rc: posted %d buffers \r\n", - (uint)pDpa->numOutRcvBuffers); - } - printk("rc: Initialization done.\n"); - dev->tbusy=0; - retry=0; - return; - case RC_RTN_FREE_Q_EMPTY: - retry++; - printk("rc: inbound free q empty\n"); - break; - default: - retry++; - printk("rc: bad status after reboot: %d\n", init_status); - break; - } - - if (retry > REBOOT_REINIT_RETRY_LIMIT) - { - printk("rc: unable to reinitialize adapter after reboot\n"); - printk("rc: decrementing driver and closing interface\n"); - RCDisableI2OInterrupts(pDpa->id); - dev->flags &= ~IFF_UP; - MOD_DEC_USE_COUNT; - } - else - { - printk("rc: rescheduling timer...\n"); - init_timer(&pDpa->timer); - pDpa->timer.expires = RUN_AT((40*HZ)/10); /* 3 sec. */ - pDpa->timer.data = (unsigned long)dev; - pDpa->timer.function = &rc_timer; /* timer handler */ - add_timer(&pDpa->timer); - } - } - else - { - printk("rc: timer??\n"); - } + pDpa->reboot = 0; + pDpa->shutdown = 0; /* just in case */ + RCReportDriverCapability(pDpa->id, DriverControlWord); + RCEnableAdapterInterrupts(pDpa->id); + + if (dev->flags & IFF_UP) + { + 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("rc: posted %d buffers \r\n", + (uint)pDpa->numOutRcvBuffers); + } + printk("rc: Initialization done.\n"); + return; + case RC_RTN_FREE_Q_EMPTY: + retry++; + printk("rc: inbound free q emtpy\n"); + break; + default: + retry++; + printk("rc: unexpected bad status after reboot\n"); + break; + } + + if (retry > REBOOT_REINIT_RETRY_LIMIT) + { + printk("rc: unable to reinitialize adapter after reboot\n"); + printk("rc: decrementing driver and closing interface\n"); + RCDisableAdapterInterrupts(pDpa->id); + dev->flags &= ~IFF_UP; + MOD_DEC_USE_COUNT; + } + else + { + printk("rc: rescheduling timer...\n"); + init_timer(&pDpa->timer); + pDpa->timer.expires = RUN_AT((30*HZ)/10); /* 3 sec. */ + pDpa->timer.data = (unsigned long)dev; + pDpa->timer.function = &rc_timer; /* timer handler */ + add_timer(&pDpa->timer); + } + } + else + { + printk("rc: timer??\n"); + } } static int RCclose(struct device *dev) { - PDPA pDpa = (PDPA) dev->priv; + PDPA pDpa = (PDPA) dev->priv; #ifdef RCDEBUG - printk("rc: RCclose\r\n"); + printk("rc: RCclose\r\n"); #endif - if (pDpa->reboot) - { - printk("rc: skipping reset -- adapter already in reboot mode\n"); - dev->flags &= ~IFF_UP; - pDpa->shutdown = 1; - return 0; - } + if (pDpa->reboot) + { + printk("rc: skipping reset -- adapter already in reboot mode\n"); + dev->flags &= ~IFF_UP; + pDpa->shutdown = 1; + return 0; + } #ifdef RCDEBUG - printk("rc: receive buffers outstanding: %d\n", - (uint)pDpa->numOutRcvBuffers); + printk("rc: receive buffers outstanding: %d\n", + (uint)pDpa->numOutRcvBuffers); #endif - pDpa->shutdown = 1; + 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. - */ + /* + * 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(pDpa->id, - RC_RESOURCE_RETURN_POSTED_RX_BUCKETS | - RC_RESOURCE_RETURN_PEND_TX_BUFFERS,0, - (PFNCALLBACK)RCreset_callback); + RCShutdownLANCard(pDpa->id, + RC_RESOURCE_RETURN_POSTED_RX_BUCKETS | + RC_RESOURCE_RETURN_PEND_TX_BUFFERS,0, + (PFNCALLBACK)RCreset_callback); - dev->flags &= ~IFF_UP; - return 0; + dev->flags &= ~IFF_UP; + return 0; } static struct enet_statistics * @@ -1154,200 +1097,140 @@ static int RCioctl(struct device *dev, struct ifreq *rq, int cmd) 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_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: - { -#ifdef LINUX_2_1 - if(copy_from_user(&RCuser, rq->ifr_data, sizeof(RCuser))) - return -EFAULT; -#else - int error; - error=verify_area(VERIFY_WRITE, rq->ifr_data, sizeof(RCuser)); - if (error) { - return error; - } - memcpy_fromfs(&RCuser, rq->ifr_data, sizeof(RCuser)); -#endif + case RCU_COMMAND: + { + int error; + + error=verify_area(VERIFY_WRITE, rq->ifr_data, sizeof(RCuser)); + if (error) { + return error; + } + memcpy_fromfs(&RCuser, rq->ifr_data, sizeof(RCuser)); #ifdef RCDEBUG - printk("RCioctl: RCuser_cmd = 0x%x\n", RCuser.cmd); + printk("RCioctl: RCuser_cmd = 0x%x\n", RCuser.cmd); #endif - switch(RCuser.cmd) - { - case RCUC_GETFWVER: - printk("RC GETFWVER\n"); - RCUD_GETFWVER = &RCuser.RCUS_GETFWVER; - RCGetFirmwareVer(pDpa->id, (PU8) &RCUD_GETFWVER->FirmString, NULL); - break; - case RCUC_GETINFO: - printk("RC GETINFO\n"); - RCUD_GETINFO = &RCuser.RCUS_GETINFO; - RCUD_GETINFO -> mem_start = dev->base_addr; - RCUD_GETINFO -> mem_end = dev->base_addr + 2*32768; - RCUD_GETINFO -> base_addr = pDpa->pci_addr; - RCUD_GETINFO -> irq = dev->irq; - break; - case RCUC_GETIPANDMASK: - printk("RC GETIPANDMASK\n"); - RCUD_GETIPANDMASK = &RCuser.RCUS_GETIPANDMASK; - RCGetRavlinIPandMask(pDpa->id, (PU32) &RCUD_GETIPANDMASK->IpAddr, - (PU32) &RCUD_GETIPANDMASK->NetMask, NULL); - break; - case RCUC_GETLINKSTATISTICS: - printk("RC GETLINKSTATISTICS\n"); - RCUD_GETLINKSTATISTICS = &RCuser.RCUS_GETLINKSTATISTICS; - RCGetLinkStatistics(pDpa->id, (P_RCLINKSTATS) &RCUD_GETLINKSTATISTICS->StatsReturn, NULL); - break; - case RCUC_GETLINKSTATUS: - printk("RC GETLINKSTATUS\n"); - RCUD_GETLINKSTATUS = &RCuser.RCUS_GETLINKSTATUS; - RCGetLinkStatus(pDpa->id, (PU32) &RCUD_GETLINKSTATUS->ReturnStatus, NULL); - break; - case RCUC_GETMAC: - printk("RC GETMAC\n"); - RCUD_GETMAC = &RCuser.RCUS_GETMAC; - RCGetMAC(pDpa->id, (PU8) &RCUD_GETMAC->mac, NULL); - break; - case RCUC_GETPROM: - printk("RC GETPROM\n"); - RCUD_GETPROM = &RCuser.RCUS_GETPROM; - RCGetPromiscuousMode(pDpa->id, (PU32) &RCUD_GETPROM->PromMode, NULL); - break; - case RCUC_GETBROADCAST: - printk("RC GETBROADCAST\n"); - RCUD_GETBROADCAST = &RCuser.RCUS_GETBROADCAST; - RCGetBroadcastMode(pDpa->id, (PU32) &RCUD_GETBROADCAST->BroadcastMode, NULL); - break; - case RCUC_GETSPEED: - printk("RC GETSPEED\n"); - if (!(dev->flags & IFF_UP)) + switch(RCuser.cmd) { - printk("RCioctl, GETSPEED error: interface down\n"); - return -ENODATA; + case RCUC_GETFWVER: + printk("RC GETFWVER\n"); + RCUD_GETFWVER = &RCuser.RCUS_GETFWVER; + RCGetFirmwareVer(pDpa->id, (PU8) &RCUD_GETFWVER->FirmString, NULL); + break; + case RCUC_GETINFO: + printk("RC GETINFO\n"); + RCUD_GETINFO = &RCuser.RCUS_GETINFO; + RCUD_GETINFO -> mem_start = dev->base_addr; + RCUD_GETINFO -> mem_end = dev->base_addr + 32768; + RCUD_GETINFO -> base_addr = pDpa->pci_addr; + RCUD_GETINFO -> irq = dev->irq; + break; + case RCUC_GETIPANDMASK: + printk("RC GETIPANDMASK\n"); + RCUD_GETIPANDMASK = &RCuser.RCUS_GETIPANDMASK; + RCGetRavlinIPandMask(pDpa->id, (PU32) &RCUD_GETIPANDMASK->IpAddr, + (PU32) &RCUD_GETIPANDMASK->NetMask, NULL); + break; + case RCUC_GETLINKSTATISTICS: + printk("RC GETLINKSTATISTICS\n"); + RCUD_GETLINKSTATISTICS = &RCuser.RCUS_GETLINKSTATISTICS; + RCGetLinkStatistics(pDpa->id, (P_RCLINKSTATS) &RCUD_GETLINKSTATISTICS->StatsReturn, NULL); + break; + case RCUC_GETLINKSTATUS: + printk("RC GETLINKSTATUS\n"); + RCUD_GETLINKSTATUS = &RCuser.RCUS_GETLINKSTATUS; + RCGetLinkStatus(pDpa->id, (PU32) &RCUD_GETLINKSTATUS->ReturnStatus, NULL); + break; + case RCUC_GETMAC: + printk("RC GETMAC\n"); + RCUD_GETMAC = &RCuser.RCUS_GETMAC; + RCGetMAC(pDpa->id, (PU8) &RCUD_GETMAC->mac, NULL); + break; + case RCUC_GETSPEED: + printk("RC GETSPEED\n"); + if (!(dev->flags & IFF_UP)) + { + printk("RCioctl, GETSPEED error: interface down\n"); + return -ENODATA; + } + RCUD_GETSPEED = &RCuser.RCUS_GETSPEED; + RCGetLinkSpeed(pDpa->id, (PU32) &RCUD_GETSPEED->LinkSpeedCode, NULL); + printk("RC speed = 0x%ld\n", RCUD_GETSPEED->LinkSpeedCode); + break; + default: + printk("RC command default\n"); + RCUD_DEFAULT = &RCuser.RCUS_DEFAULT; + RCUD_DEFAULT -> rc = 0x11223344; + break; } - RCUD_GETSPEED = &RCuser.RCUS_GETSPEED; - RCGetLinkSpeed(pDpa->id, (PU32) &RCUD_GETSPEED->LinkSpeedCode, NULL); - printk("RC speed = 0x%ld\n", RCUD_GETSPEED->LinkSpeedCode); - break; - case RCUC_SETIPANDMASK: - printk("RC SETIPANDMASK\n"); - RCUD_SETIPANDMASK = &RCuser.RCUS_SETIPANDMASK; - printk ("RC New IP Addr = %d.%d.%d.%d, ", (U8) ((RCUD_SETIPANDMASK->IpAddr) & 0xff), - (U8) ((RCUD_SETIPANDMASK->IpAddr >> 8) & 0xff), - (U8) ((RCUD_SETIPANDMASK->IpAddr >> 16) & 0xff), - (U8) ((RCUD_SETIPANDMASK->IpAddr >> 24) & 0xff)); - printk ("RC New Mask = %d.%d.%d.%d\n", (U8) ((RCUD_SETIPANDMASK->NetMask) & 0xff), - (U8) ((RCUD_SETIPANDMASK->NetMask >> 8) & 0xff), - (U8) ((RCUD_SETIPANDMASK->NetMask >> 16) & 0xff), - (U8) ((RCUD_SETIPANDMASK->NetMask >> 24) & 0xff)); - RCSetRavlinIPandMask(pDpa->id, (U32) RCUD_SETIPANDMASK->IpAddr, - (U32) RCUD_SETIPANDMASK->NetMask); - break; - case RCUC_SETMAC: - printk("RC SETMAC\n"); - RCUD_SETMAC = &RCuser.RCUS_SETMAC; - printk ("RC New MAC addr = %02X:%02X:%02X:%02X:%02X:%02X\n", - (U8) (RCUD_SETMAC->mac[0]), (U8) (RCUD_SETMAC->mac[1]), (U8) (RCUD_SETMAC->mac[2]), - (U8) (RCUD_SETMAC->mac[3]), (U8) (RCUD_SETMAC->mac[4]), (U8) (RCUD_SETMAC->mac[5])); - RCSetMAC(pDpa->id, (PU8) &RCUD_SETMAC->mac); - break; - case RCUC_SETSPEED: - printk("RC SETSPEED\n"); - RCUD_SETSPEED = &RCuser.RCUS_SETSPEED; - RCSetLinkSpeed(pDpa->id, (U16) RCUD_SETSPEED->LinkSpeedCode); - printk("RC New speed = 0x%d\n", RCUD_SETSPEED->LinkSpeedCode); - break; - case RCUC_SETPROM: - printk("RC SETPROM\n"); - RCUD_SETPROM = &RCuser.RCUS_SETPROM; - RCSetPromiscuousMode(pDpa->id,(U16)RCUD_SETPROM->PromMode); - printk("RC New prom mode = 0x%d\n", RCUD_SETPROM->PromMode); - break; - case RCUC_SETBROADCAST: - printk("RC SETBROADCAST\n"); - RCUD_SETBROADCAST = &RCuser.RCUS_SETBROADCAST; - RCSetBroadcastMode(pDpa->id,(U16)RCUD_SETBROADCAST->BroadcastMode); - printk("RC New broadcast mode = 0x%d\n", RCUD_SETBROADCAST->BroadcastMode); + memcpy_tofs(rq->ifr_data, &RCuser, sizeof(RCuser)); break; + } /* RCU_COMMAND */ + default: - printk("RC command default\n"); - RCUD_DEFAULT = &RCuser.RCUS_DEFAULT; - RCUD_DEFAULT -> rc = 0x11223344; + printk("RC default\n"); + rq->ifr_ifru.ifru_data = (caddr_t) 0x12345678; break; - } -#ifdef LINUX_2_1 - copy_to_user(rq->ifr_data, &RCuser, sizeof(RCuser)); -#else - memcpy_tofs(rq->ifr_data, &RCuser, sizeof(RCuser)); -#endif - break; - } /* RCU_COMMAND */ - - default: - printk("RC default\n"); - rq->ifr_ifru.ifru_data = (caddr_t) 0x12345678; - break; } return 0; } static int RCconfig(struct device *dev, struct ifmap *map) { - /* - * To be completed ... + /* + * To be completed ... */ - printk("rc: RCconfig\n"); - return 0; - if (dev->flags & IFF_UP) /* can't act on a running interface */ - return -EBUSY; + printk("rc: RCconfig\n"); + 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 "RC pci45: Change I/O address not implemented\n"); - return -EOPNOTSUPP; - } - return 0; + if (map->base_addr != dev->base_addr) { + printk(KERN_WARNING "RC pci45: Change I/O address not implemented\n"); + return -EOPNOTSUPP; + } + return 0; } - #ifdef MODULE -void -cleanup_module(void) +void cleanup_module(void) { - PDPA pDpa; - struct device *next; + PDPA pDpa; + struct device *next; #ifdef RCDEBUG - printk("rc: RC cleanup_module\n"); - printk("rc: root_RCdev = 0x%x\n", (uint)root_RCdev); + printk("rc: RC cleanup_module\n"); + printk("rc: root_RCdev = 0x%x\n", (uint)root_RCdev); #endif - while (root_RCdev) - { - pDpa = (PDPA) root_RCdev->priv; + while (root_RCdev) + { + pDpa = (PDPA) root_RCdev->priv; #ifdef RCDEBUG - printk("rc: cleanup 0x%08X\n", (uint)root_RCdev); + printk("rc: cleanup 0x%08X\n", (uint)root_RCdev); #endif - printk("IOP reset: 0x%x\n", RCResetIOP(pDpa->id)); - unregister_netdev(root_RCdev); - next = pDpa->next; - - iounmap((unsigned long *)root_RCdev->base_addr); - free_irq( root_RCdev->irq, root_RCdev ); - kfree(root_RCdev); - root_RCdev = next; - } + printk("Adapter reset: 0x%x\n", RCResetAdapter(pDpa->id)); + unregister_netdev(root_RCdev); + next = pDpa->next; + + vfree((unsigned long *)root_RCdev->base_addr); + free_irq( root_RCdev->irq, root_RCdev ); + kfree(root_RCdev); + root_RCdev = next; + } } #endif @@ -1356,100 +1239,94 @@ static int RC_allocate_and_post_buffers(struct device *dev, int numBuffers) { - int i; - PDPA pDpa = (PDPA)dev->priv; - PU32 p; - psingleB pB; - struct sk_buff *skb; - RC_RETURN status; - - if (!numBuffers) - return 0; - else if (numBuffers > MAX_NMBR_POST_BUFFERS_PER_MSG) - { + int i; + PDPA pDpa = (PDPA)dev->priv; + PU32 p; + psingleB pB; + struct sk_buff *skb; + RC_RETURN status; + + if (!numBuffers) + return 0; + else if (numBuffers > MAX_NMBR_POST_BUFFERS_PER_MSG) + { #ifdef RCDEBUG - printk("rc: Too many buffers requested!\n"); - printk("rc: attempting to allocate only 32 buffers\n"); + printk("rc: Too many buffers requested!\n"); + printk("rc: attempting to allocate only 32 buffers\n"); #endif - numBuffers = 32; - } + numBuffers = 32; + } - p = (PU32) kmalloc(sizeof(U32) + numBuffers*sizeof(singleB), GFP_ATOMIC); + p = (PU32) kmalloc(sizeof(U32) + numBuffers*sizeof(singleB), GFP_ATOMIC); #ifdef RCDEBUG - printk("rc: TCB = 0x%x\n", (uint)p); + printk("rc: TCB = 0x%x\n", (uint)p); #endif - if (!p) - { - printk("rc: RCopen: unable to allocate TCB\n"); - return 0; - } + if (!p) + { + printk("rc: RCopen: unable to allocate TCB\n"); + return 0; + } - p[0] = 0; /* Buffer Count */ - pB = (psingleB)((U32)p + sizeof(U32)); /* point to the first buffer */ + p[0] = 0; /* Buffer Count */ + pB = (psingleB)((U32)p + sizeof(U32)); /* point to the first buffer */ #ifdef RCDEBUG - printk("rc: p[0] = 0x%x, p = 0x%x, pB = 0x%x\n", (uint)p[0], (uint)p, (uint)pB); - printk("rc: pB = 0x%x\n", (uint)pB); + printk("rc: p[0] = 0x%x, p = 0x%x, pB = 0x%x\n", (uint)p[0], (uint)p, (uint)pB); + printk("rc: pB = 0x%x\n", (uint)pB); #endif - for (i=0; icontext = (U32)skb; - pB->scount = 1; /* segment count */ - pB->size = MAX_ETHER_SIZE; - pB->addr = virt_to_bus((void *)skb->data); - p[0]++; - pB++; - } - - if ( (status = RCPostRecvBuffers(pDpa->id, (PRCTCB)p )) != RC_RTN_NO_ERROR) - { - printk("rc: Post buffer failed with error code 0x%x!\n", status); - pB = (psingleB)((U32)p + sizeof(U32)); /* point to the first buffer */ - while(p[0]) - { - skb = (struct sk_buff *)pB->context; -#ifndef LINUX_2_1 - skb->free = 1; + printk("post 0x%x\n", (uint)skb); #endif + 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 = (U32)skb->data; + p[0]++; + pB++; + } + + if ( (status = RCPostRecvBuffers(pDpa->id, (PRCTCB)p )) != RC_RTN_NO_ERROR) + { + printk("rc: Post buffer failed with error code 0x%x!\n", status); + pB = (psingleB)((U32)p + sizeof(U32)); /* point to the first buffer */ + while(p[0]) + { + skb = (struct sk_buff *)pB->context; + skb->free = 1; #ifdef RCDEBUG - printk("rc: freeing 0x%x\n", (uint)skb); + printk("rc: freeing 0x%x\n", (uint)skb); #endif -#ifdef LINUX_2_1 - dev_kfree_skb (skb); -#else - dev_kfree_skb(skb, FREE_READ); -#endif - p[0]--; - pB++; - } + dev_kfree_skb(skb, FREE_READ); + p[0]--; + pB++; + } #ifdef RCDEBUG - printk("rc: freed all buffers, p[0] = %ld\n", p[0]); + printk("rc: freed all buffers, p[0] = %ld\n", p[0]); #endif - } - kfree(p); - return(p[0]); /* return the number of posted buffers */ + } + kfree(p); + return(p[0]); /* return the number of posted buffers */ } diff --git a/drivers/net/sdla.c b/drivers/net/sdla.c index 11c5f0311647..6eb1efae5b57 100644 --- a/drivers/net/sdla.c +++ b/drivers/net/sdla.c @@ -452,7 +452,7 @@ static int sdla_cmd(struct device *dev, int cmd, short dlci, short flags, save_flags(pflags); cli(); SDLA_WINDOW(dev, window); - waiting = ((volatile int)(cmd_buf->opp_flag)); + waiting = ((volatile)(cmd_buf->opp_flag)); restore_flags(pflags); } } @@ -566,12 +566,11 @@ int sdla_assoc(struct device *slave, struct device *master) flp->dlci[i] = -*(short *)(master->dev_addr); master->mtu = slave->mtu; - if (slave->start) { + if (slave->start) if (flp->config.station == FRAD_STATION_CPE) sdla_reconfig(slave); else sdla_cmd(slave, SDLA_ADD_DLCI, 0, 0, master->dev_addr, sizeof(short), NULL, NULL); - } return(0); } @@ -595,12 +594,11 @@ int sdla_deassoc(struct device *slave, struct device *master) MOD_DEC_USE_COUNT; - if (slave->start) { + if (slave->start) if (flp->config.station == FRAD_STATION_CPE) sdla_reconfig(slave); else sdla_cmd(slave, SDLA_DELETE_DLCI, 0, 0, master->dev_addr, sizeof(short), NULL, NULL); - } return(0); } @@ -625,14 +623,13 @@ int sdla_dlci_conf(struct device *slave, struct device *master, int get) ret = SDLA_RET_OK; len = sizeof(struct dlci_conf); - if (slave->start) { + if (slave->start) if (get) ret = sdla_cmd(slave, SDLA_READ_DLCI_CONFIGURATION, abs(flp->dlci[i]), 0, NULL, 0, &dlp->config, &len); else ret = sdla_cmd(slave, SDLA_SET_DLCI_CONFIGURATION, abs(flp->dlci[i]), 0, &dlp->config, sizeof(struct dlci_conf) - 4 * sizeof(short), NULL, NULL); - } return(ret == SDLA_RET_OK ? 0 : -EIO); } diff --git a/drivers/net/wavelan.c b/drivers/net/wavelan.c index 4e68cab3dcdd..dbe88153e705 100644 --- a/drivers/net/wavelan.c +++ b/drivers/net/wavelan.c @@ -290,26 +290,24 @@ psa_write(u_long ioaddr, wv_16_on(ioaddr, hacr); } /* psa_write */ -#ifdef SET_PSA_CRC +#ifdef PSA_CRC /*------------------------------------------------------------------*/ /* - * Calculate the PSA CRC + * Calculate the PSA CRC (not tested yet) + * As the WaveLAN drivers don't use the CRC, I won't use it either. * Thanks to Valster, Nico for the code * NOTE: By specifying a length including the CRC position the * returned value should be zero. (i.e. a correct checksum in the PSA) - * - * The Windows drivers don't use the CRC, but the AP and the PtP tool - * depend on it. */ -static inline u_short -psa_crc(u_char * psa, /* The PSA */ +static u_short +psa_crc(u_short * psa, /* The PSA */ int size) /* Number of short for CRC */ { int byte_cnt; /* Loop on the PSA */ u_short crc_bytes = 0; /* Data in the PSA */ int bit_cnt; /* Loop on the bits of the short */ - for(byte_cnt = 0; byte_cnt < size; byte_cnt++ ) + for(byte_cnt = 0; byte_cnt <= size; byte_cnt++ ) { crc_bytes ^= psa[byte_cnt]; /* Its an xor */ @@ -324,47 +322,7 @@ psa_crc(u_char * psa, /* The PSA */ return crc_bytes; } /* psa_crc */ - -/*------------------------------------------------------------------*/ -/* - * update the checksum field in the Wavelan's PSA - */ -static void -update_psa_checksum(device * dev, - u_long ioaddr, - u_short hacr) -{ - psa_t psa; - u_short crc; - - /* read the parameter storage area */ - psa_read(ioaddr, hacr, 0, (unsigned char *) &psa, sizeof(psa)); - - /* update the checksum */ - crc = psa_crc((unsigned char *) &psa, - sizeof(psa) - sizeof(psa.psa_crc[0]) - sizeof(psa.psa_crc[1]) - - sizeof(psa.psa_crc_status)); - - psa.psa_crc[0] = crc & 0xFF; - psa.psa_crc[1] = (crc & 0xFF00) >> 8; - - /* Write it ! */ - psa_write(ioaddr, hacr, (char *)&psa.psa_crc - (char *)&psa, - (unsigned char *)&psa.psa_crc, 2); - -#ifdef DEBUG_IOCTL_INFO - printk (KERN_DEBUG "%s: update_psa_checksum(): crc = 0x%02x%02x\n", - dev->name, psa.psa_crc[0], psa.psa_crc[1]); - - /* Check again (luxury !) */ - crc = psa_crc ((unsigned char *) &psa, - sizeof(psa) - sizeof(psa.psa_crc_status)); - - if(crc != 0) - printk(KERN_WARNING "%s: update_psa_checksum(): CRC does not agree with PSA data (even after recalculating)\n", dev->name); -#endif /* DEBUG_IOCTL_INFO */ -} /* update_psa_checksum */ -#endif /* SET_PSA_CRC */ +#endif /* PSA_CRC */ /*------------------------------------------------------------------*/ /* @@ -748,21 +706,21 @@ wv_config_complete(device * dev, unsigned short ias_addr; /* Check mc_config command */ - if((status & AC_SFLD_OK) != 0) + if(status & AC_SFLD_OK != 0) printk(KERN_INFO "wv_config_complete(): set_multicast_address failed; status = 0x%x\n", dev->name, str, status); /* check ia-config command */ ias_addr = mcs_addr - sizeof(ac_ias_t); obram_read(ioaddr, acoff(ias_addr, ac_status), (unsigned char *)&status, sizeof(status)); - if((status & AC_SFLD_OK) != 0) + if(status & AC_SFLD_OK != 0) printk(KERN_INFO "wv_config_complete(): set_MAC_address; status = 0x%x\n", dev->name, str, status); /* Check config command */ cfg_addr = ias_addr - sizeof(ac_cfg_t); obram_read(ioaddr, acoff(cfg_addr, ac_status), (unsigned char *)&status, sizeof(status)); - if((status & AC_SFLD_OK) != 0) + if(status & AC_SFLD_OK != 0) printk(KERN_INFO "wv_config_complete(): configure; status = 0x%x\n", dev->name, str, status); #endif /* DEBUG_CONFIG_ERROR */ @@ -1940,10 +1898,6 @@ wavelan_ioctl(struct device * dev, /* device on which the ioctl is applied */ /* Disable nwid in the mmc (no filtering) */ mmc_out(ioaddr, mmwoff(0, mmw_loopt_sel), MMW_LOOPT_SEL_DIS_NWID); } -#ifdef SET_PSA_CRC - /* update the Wavelan checksum */ - update_psa_checksum(dev, ioaddr, lp->hacr); -#endif break; case SIOCGIWNWID: @@ -2001,10 +1955,6 @@ wavelan_ioctl(struct device * dev, /* device on which the ioctl is applied */ psa.psa_thr_pre_set = wrq->u.sensitivity & 0x3F; psa_write(ioaddr, lp->hacr, (char *)&psa.psa_thr_pre_set - (char *)&psa, (unsigned char *) &psa.psa_thr_pre_set, 1); -#ifdef SET_PSA_CRC - /* update the Wavelan checksum */ - update_psa_checksum(dev, ioaddr, lp->hacr); -#endif mmc_out(ioaddr, mmwoff(0, mmw_thr_pre_set), psa.psa_thr_pre_set); break; @@ -2052,10 +2002,6 @@ wavelan_ioctl(struct device * dev, /* device on which the ioctl is applied */ mmc_out(ioaddr, mmwoff(0, mmw_encr_enable), 0); } -#ifdef SET_PSA_CRC - /* update the Wavelan checksum */ - update_psa_checksum(dev, ioaddr, lp->hacr); -#endif break; case SIOCGIWENCODE: @@ -2269,10 +2215,6 @@ wavelan_ioctl(struct device * dev, /* device on which the ioctl is applied */ psa.psa_quality_thr = *(wrq->u.name) & 0x0F; psa_write(ioaddr, lp->hacr, (char *)&psa.psa_quality_thr - (char *)&psa, (unsigned char *)&psa.psa_quality_thr, 1); -#ifdef SET_PSA_CRC - /* update the Wavelan checksum */ - update_psa_checksum(dev, ioaddr, lp->hacr); -#endif mmc_out(ioaddr, mmwoff(0, mmw_quality_thr), psa.psa_quality_thr); break; @@ -2383,7 +2325,7 @@ wavelan_get_wireless_stats(device * dev) mmc_out(ioaddr, mmwoff(0, mmw_freeze), 0); /* Copy data to wireless stuff */ - wstats->status = m.mmr_dce_status & MMR_DCE_STATUS; + wstats->status = m.mmr_dce_status; wstats->qual.qual = m.mmr_sgnl_qual & MMR_SGNL_QUAL; wstats->qual.level = m.mmr_signal_lvl & MMR_SIGNAL_LVL; wstats->qual.noise = m.mmr_silence_lvl & MMR_SILENCE_LVL; @@ -2967,10 +2909,6 @@ wv_mmc_init(device * dev) (unsigned char *)&psa.psa_quality_thr, 1); psa_write(ioaddr, lp->hacr, (char *)&psa.psa_conf_status - (char *)&psa, (unsigned char *)&psa.psa_conf_status, 1); -#ifdef SET_PSA_CRC - /* update the Wavelan checksum */ - update_psa_checksum(dev, ioaddr, lp->hacr); -#endif #endif } @@ -2997,18 +2935,21 @@ wv_mmc_init(device * dev) m.mmw_thr_pre_set = psa.psa_thr_pre_set & 0x3F; m.mmw_quality_thr = psa.psa_quality_thr & 0x0F; + /* Missing: encryption stuff... */ + /* * Set default modem control parameters. * See NCR document 407-0024326 Rev. A. */ m.mmw_jabber_enable = 0x01; - m.mmw_freeze = 0; m.mmw_anten_sel = MMW_ANTEN_SEL_ALG_EN; m.mmw_ifs = 0x20; m.mmw_mod_delay = 0x04; m.mmw_jam_time = 0x38; + m.mmw_encr_enable = 0; m.mmw_des_io_invert = 0; + m.mmw_freeze = 0; m.mmw_decay_prm = 0; m.mmw_decay_updat_prm = 0; @@ -3473,29 +3414,39 @@ wv_82586_config(device * dev) /* Create a configure action */ memset(&cfg, 0x00, sizeof(cfg)); +#if 0 + /* + * The default board configuration + */ + cfg.fifolim_bytecnt = 0x080c; + cfg.addrlen_mode = 0x2600; + cfg.linprio_interframe = 0x7820; /* IFS=120, ACS=2 */ + cfg.slot_time = 0xf00c; /* slottime=12 */ + cfg.hardware = 0x0008; /* tx even without CD */ + cfg.min_frame_len = 0x0040; +#endif /* 0 */ + /* * For Linux we invert AC_CFG_ALOC(..) so as to conform * to the way that net packets reach us from above. * (See also ac_tx_t.) - * - * Updated from Wavelan Manual WCIN085B */ cfg.cfg_byte_cnt = AC_CFG_BYTE_CNT(sizeof(ac_cfg_t) - sizeof(ach_t)); - cfg.cfg_fifolim = AC_CFG_FIFOLIM(4); - cfg.cfg_byte8 = AC_CFG_SAV_BF(1) | + cfg.cfg_fifolim = AC_CFG_FIFOLIM(8); + cfg.cfg_byte8 = AC_CFG_SAV_BF(0) | AC_CFG_SRDY(0); cfg.cfg_byte9 = AC_CFG_ELPBCK(0) | AC_CFG_ILPBCK(0) | AC_CFG_PRELEN(AC_CFG_PLEN_2) | AC_CFG_ALOC(1) | AC_CFG_ADDRLEN(WAVELAN_ADDR_SIZE); - cfg.cfg_byte10 = AC_CFG_BOFMET(1) | - AC_CFG_ACR(6) | + cfg.cfg_byte10 = AC_CFG_BOFMET(0) | + AC_CFG_ACR(0) | AC_CFG_LINPRIO(0); - cfg.cfg_ifs = 0x20; - cfg.cfg_slotl = 0x0C; + cfg.cfg_ifs = 32; + cfg.cfg_slotl = 0; cfg.cfg_byte13 = AC_CFG_RETRYNUM(15) | - AC_CFG_SLTTMHI(0); + AC_CFG_SLTTMHI(2); cfg.cfg_byte14 = AC_CFG_FLGPAD(0) | AC_CFG_BTSTF(0) | AC_CFG_CRC16(0) | @@ -4094,10 +4045,6 @@ wavelan_config(device * dev) #endif psa_write(ioaddr, HACR_DEFAULT, psaoff(0, psa_int_req_no), &irq_mask, 1); -#ifdef SET_PSA_CRC - /* update the Wavelan checksum */ - update_psa_checksum(dev, ioaddr, HACR_DEFAULT); -#endif wv_hacr_reset(ioaddr); } } @@ -4280,7 +4227,7 @@ int init_module(void) { mac_addr mac; /* MAC address (check WaveLAN existence) */ - int ret = -EIO; /* Return error if no cards found */ + int ret = 0; int i; #ifdef DEBUG_MODULE_TRACE @@ -4325,11 +4272,7 @@ init_module(void) /* DeAllocate everything */ /* Note : if dev->priv is mallocated, there is no way to fail */ kfree_s(dev, sizeof(struct device)); - } - else - { - /* If at least one device OK, we do not fail */ - ret = 0; + ret = -EIO; } } /* if there is something at the address */ } /* Loop on all addresses. */ diff --git a/drivers/net/wavelan.h b/drivers/net/wavelan.h index c72233e95092..2e92c798eaa8 100644 --- a/drivers/net/wavelan.h +++ b/drivers/net/wavelan.h @@ -28,8 +28,6 @@ const char MAC_ADDRESSES[][3] = { { 0x08, 0x00, 0x0E }, /* AT&T Wavelan (standard) & DEC RoamAbout */ { 0x08, 0x00, 0x6A }, /* AT&T Wavelan (alternate) */ - { 0x00, 0x00, 0xE1 }, /* Hitachi Wavelan */ - { 0x00, 0x60, 0x1D } /* Lucent Wavelan (another one) */ /* Add your card here and send me the patch ! */ }; @@ -295,7 +293,6 @@ struct mmr_t #define MMR_DCE_STATUS_LOOPT_IND 0x02 /* loop test indicated */ #define MMR_DCE_STATUS_TX_BUSY 0x04 /* transmitter on */ #define MMR_DCE_STATUS_JBR_EXPIRED 0x08 /* jabber timer expired */ -#define MMR_DCE_STATUS 0x0F /* mask to get the bits */ unsigned char mmr_dsp_id; /* DSP id (AA = Daedalus rev A) */ unsigned char mmr_unused2[2]; /* unused */ unsigned char mmr_correct_nwid_l; /* # of correct NWID's rxd (low) */ diff --git a/drivers/net/wavelan.p.h b/drivers/net/wavelan.p.h index 136ebb510238..3a6124e70104 100644 --- a/drivers/net/wavelan.p.h +++ b/drivers/net/wavelan.p.h @@ -16,9 +16,15 @@ /************************** DOCUMENTATION **************************/ /* * This driver provide a Linux interface to the Wavelan ISA hardware - * The Wavelan is a product of Lucent ("http://www.wavelan.com/"). + * The Wavelan is a product of Lucent ("http://wavelan.netland.nl/"). * This division was formerly part of NCR and then AT&T. - * Wavelan are also distributed by DEC (RoamAbout DS) and Digital Ocean. + * Wavelan are also distributed by DEC (RoamAbout), Digital Ocean and + * Aironet (Arlan). If you have one of those product, you will need to + * make some changes below... + * + * This driver is still a beta software. A lot of bugs have been corrected, + * a lot of functionalities are implemented, the whole appear pretty stable, + * but there is still some area of improvement (encryption, performance...). * * To know how to use this driver, read the NET3 HOWTO. * If you want to exploit the many other fonctionalities, look comments @@ -29,22 +35,12 @@ /* ------------------------ SPECIFIC NOTES ------------------------ */ /* - * Web page - * -------- - * I try to maintain a web page with the Wireless LAN Howto at : - * http://www-uk.hpl.hp.com/people/jt/Linux/Wavelan.html - * * wavelan.o is darn too big * ------------------------- * That's true ! There is a very simple way to reduce the driver * object by 33% (yes !). Comment out the following line : * #include * - * Debugging and options - * --------------------- - * You will find below a set of '#define" allowing a very fine control - * on the driver behaviour and the debug messages printed. - * * MAC address and hardware detection : * ---------------------------------- * The detection code of the wavelan chech that the first 3 @@ -64,6 +60,23 @@ * 3) Compile & verify * 4) Send me the MAC code - I will include it in the next version... * + * "CU Inactive" message at boot up : + * ----------------------------------- + * It seem that there is some weird timings problems with the + * Intel microcontroler. In fact, this message is triggered by a + * bad reading of the on board ram the first time we read the + * control block. If you ignore this message, all is ok (but in + * fact, currently, it reset the wavelan hardware). + * + * To get rid of that problem, there is two solution. The first + * is to add a dummy read of the scb at the end of + * wv_82586_config. The second is to add the timers + * wv_synchronous_cmd and wv_ack (the udelay just after the + * waiting loops - seem that the controler is not totally ready + * when it say it is !). + * + * In the current code, I use the second solution (to be + * consistent with the original solution of Bruce Janson). */ /* --------------------- WIRELESS EXTENSIONS --------------------- */ @@ -258,22 +271,6 @@ * - Encryption setting from Brent Elphick (thanks a lot !) * - 'ioaddr' to 'u_long' for the Alpha (thanks to Stanislav Sinyagin) * - * Other changes (not by me) : - * ------------------------- - * - Spelling and gramar "rectification". - * - * Changes made for release in 2.0.37 & 2.2.2 : - * ------------------------------------------ - * - Correct status in /proc/net/wireless - * - Set PSA CRC to make PtP diagnostic tool happy (Bob Gray) - * - Module init code don't fail if we found at least one card in - * the address list (Karlis Peisenieks) - * - Missing parenthesis (Christopher Peterson) - * - Correct i82586 configuration parameters - * - Encryption initialisation bug (Robert McCormack) - * - New mac addresses detected in the probe - * - Increase watchdog for busy envirnoments - * * Wishes & dreams : * --------------- * - Roaming @@ -341,9 +338,9 @@ /* Options : */ #define USE_PSA_CONFIG /* Use info from the PSA */ -#define SET_PSA_CRC /* Calculate and set the CRC on PSA */ #define IGNORE_NORMAL_XMIT_ERRS /* Don't bother with normal conditions */ #undef STRUCT_CHECK /* Verify padding of structures */ +#undef PSA_CRC /* Check CRC in PSA */ #undef OLDIES /* Old code (to redo) */ #undef RECORD_SNR /* To redo */ #undef EEPROM_IS_PROTECTED /* Doesn't seem to be necessary */ @@ -358,11 +355,11 @@ /************************ CONSTANTS & MACROS ************************/ #ifdef DEBUG_VERSION_SHOW -static const char *version = "wavelan.c : v18 (wireless extensions) 18/2/99\n"; +static const char *version = "wavelan.c : v16 (wireless extensions) 17/4/97\n"; #endif /* Watchdog temporisation */ -#define WATCHDOG_JIFFIES 256 /* TODO: express in HZ. */ +#define WATCHDOG_JIFFIES 32 /* TODO: express in HZ. */ /* Macro to get the number of elements in an array */ #define NELS(a) (sizeof(a) / sizeof(a[0])) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index fdecf6fa300d..080a3edcc6cc 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -110,8 +110,6 @@ struct pci_dev_info dev_info[] = { DEVICE( DEC, DEC_21052, "DC21052"), DEVICE( DEC, DEC_21150, "DC21150"), DEVICE( DEC, DEC_21152, "DC21152"), - DEVICE( DEC, DEC_21154, "DC21154"), - DEVICE( DEC, DEC_21285, "DC21285 Footbridge"), DEVICE( CIRRUS, CIRRUS_7548, "GD 7548"), DEVICE( CIRRUS, CIRRUS_5430, "GD 5430"), DEVICE( CIRRUS, CIRRUS_5434_4, "GD 5434"), @@ -148,11 +146,7 @@ struct pci_dev_info dev_info[] = { DEVICE( MATROX, MATROX_MYS, "Mystique"), DEVICE( MATROX, MATROX_MIL_2, "Millennium II"), DEVICE( MATROX, MATROX_MIL_2_AGP,"Millennium II AGP"), - DEVICE( MATROX, MATROX_G200_PCI,"Matrox G200 PCI"), - DEVICE( MATROX, MATROX_G200_AGP,"Matrox G200 AGP"), DEVICE( MATROX, MATROX_MGA_IMP, "MGA Impression"), - DEVICE( MATROX, MATROX_G100_MM, "Matrox G100 multi monitor"), - DEVICE( MATROX, MATROX_G100_AGP,"Matrox G100 AGP"), DEVICE( CT, CT_65545, "65545"), DEVICE( CT, CT_65548, "65548"), DEVICE( CT, CT_65550, "65550"), @@ -330,7 +324,6 @@ struct pci_dev_info dev_info[] = { DEVICE( TRUEVISION, TRUEVISION_T1000,"TARGA 1000"), DEVICE( INIT, INIT_320P, "320 P"), DEVICE( INIT, INIT_360P, "360 P"), - DEVICE( TTI, TTI_HPT343, "HPT343"), DEVICE( VIA, VIA_82C505, "VT 82C505"), DEVICE( VIA, VIA_82C561, "VT 82C561"), DEVICE( VIA, VIA_82C586_1, "VT 82C586 Apollo IDE"), @@ -339,7 +332,6 @@ struct pci_dev_info dev_info[] = { DEVICE( VIA, VIA_82C586_0, "VT 82C586 Apollo ISA"), DEVICE( VIA, VIA_82C595, "VT 82C595 Apollo VP2"), DEVICE( VIA, VIA_82C597_0, "VT 82C597 Apollo VP3"), - DEVICE( VIA, VIA_82C598_0, "VT 82C598 Apollo MVP3"), DEVICE( VIA, VIA_82C926, "VT 82C926 Amazon"), DEVICE( VIA, VIA_82C416, "VT 82C416MV"), DEVICE( VIA, VIA_82C595_97, "VT 82C595 Apollo VP2/97"), @@ -347,7 +339,6 @@ struct pci_dev_info dev_info[] = { DEVICE( VIA, VIA_82C586_3, "VT 82C586B Apollo ACPI"), DEVICE( VIA, VIA_86C100A, "VT 86C100A"), DEVICE( VIA, VIA_82C597_1, "VT 82C597 Apollo VP3 AGP"), - DEVICE( VIA, VIA_82C598_1, "VT 82C598 Apollo MVP3 AGP"), DEVICE( SMC2, SMC2_1211TX, "1211 TX"), DEVICE( VORTEX, VORTEX_GDT60x0, "GDT 60x0"), DEVICE( VORTEX, VORTEX_GDT6000B,"GDT 6000b"), @@ -432,12 +423,8 @@ struct pci_dev_info dev_info[] = { DEVICE( RP, RP32INTF, "RocketPort 32 Intf"), DEVICE( CYCLADES, CYCLOM_Y_Lo, "Cyclom-Y below 1Mbyte"), DEVICE( CYCLADES, CYCLOM_Y_Hi, "Cyclom-Y above 1Mbyte"), - DEVICE( CYCLADES, CYCLOM_4Y_Lo, "Cyclom-4Y below 1Mbyte"), - DEVICE( CYCLADES, CYCLOM_4Y_Hi, "Cyclom-4Y above 1Mbyte"), - DEVICE( CYCLADES, CYCLOM_8Y_Lo, "Cyclom-8Y below 1Mbyte"), - DEVICE( CYCLADES, CYCLOM_8Y_Hi, "Cyclom-8Y above 1Mbyte"), - DEVICE( CYCLADES, CYCLOM_Z_Lo, "Cyclades-Z below 1Mbyte"), - DEVICE( CYCLADES, CYCLOM_Z_Hi, "Cyclades-Z above 1Mbyte"), + DEVICE( CYCLADES, CYCLOM_Z_Lo, "Cyclom-Z below 1Mbyte"), + DEVICE( CYCLADES, CYCLOM_Z_Hi, "Cyclom-Z above 1Mbyte"), DEVICE( ESSENTIAL, ESSENTIAL_ROADRUNNER,"Roadrunner serial HIPPI"), DEVICE( O2, O2_6832, "6832"), DEVICE( 3DFX, 3DFX_VOODOO, "Voodoo"), @@ -531,12 +518,9 @@ struct pci_dev_info dev_info[] = { DEVICE( INTEL, INTEL_82450GX, "82450GX Orion P6"), DEVICE( KTI, KTI_ET32P2, "ET32P2"), DEVICE( ADAPTEC, ADAPTEC_7810, "AIC-7810 RAID"), - DEVICE( ADAPTEC, ADAPTEC_7821, "AIC-7860"), DEVICE( ADAPTEC, ADAPTEC_7850, "AIC-7850"), DEVICE( ADAPTEC, ADAPTEC_7855, "AIC-7855"), - DEVICE( ADAPTEC, ADAPTEC_3860, "AIC-7860"), DEVICE( ADAPTEC, ADAPTEC_5800, "AIC-5800"), - DEVICE( ADAPTEC, ADAPTEC_1480A, "AIC-1480A"), DEVICE( ADAPTEC, ADAPTEC_7860, "AIC-7860"), DEVICE( ADAPTEC, ADAPTEC_7861, "AIC-7861"), DEVICE( ADAPTEC, ADAPTEC_7870, "AIC-7870"), @@ -550,26 +534,11 @@ struct pci_dev_info dev_info[] = { DEVICE( ADAPTEC, ADAPTEC_7882, "AIC-7882U"), DEVICE( ADAPTEC, ADAPTEC_7883, "AIC-7883U"), DEVICE( ADAPTEC, ADAPTEC_7884, "AIC-7884U"), - DEVICE( ADAPTEC, ADAPTEC_7885, "AIC-7885U"), - DEVICE( ADAPTEC, ADAPTEC_7886, "AIC-7886U"), - DEVICE( ADAPTEC, ADAPTEC_7887, "AIC-7887U"), - DEVICE( ADAPTEC, ADAPTEC_7888, "AIC-7888U"), DEVICE( ADAPTEC, ADAPTEC_1030, "ABA-1030 DVB receiver"), - DEVICE( ADAPTEC2, ADAPTEC2_2940U2,"AHA-2940U2"), - DEVICE( ADAPTEC2, ADAPTEC2_2930U2,"AHA-2930U2"), - DEVICE( ADAPTEC2, ADAPTEC2_7890B, "AIC-7890/1"), - DEVICE( ADAPTEC2, ADAPTEC2_7890, "AIC-7890/1"), - DEVICE( ADAPTEC2, ADAPTEC2_3940U2,"AHA-3940U2"), - DEVICE( ADAPTEC2, ADAPTEC2_3950U2D, "AHA-3950U2D"), - DEVICE( ADAPTEC2, ADAPTEC2_7896, "AIC-7896/7"), - DEVICE( ADAPTEC2, ADAPTEC2_7892A, "AIC-7892"), - DEVICE( ADAPTEC2, ADAPTEC2_7892B, "AIC-7892"), - DEVICE( ADAPTEC2, ADAPTEC2_7892D, "AIC-7892"), - DEVICE( ADAPTEC2, ADAPTEC2_7892P, "AIC-7892"), - DEVICE( ADAPTEC2, ADAPTEC2_7899A, "AIC-7899"), - DEVICE( ADAPTEC2, ADAPTEC2_7899B, "AIC-7899"), - DEVICE( ADAPTEC2, ADAPTEC2_7899D, "AIC-7899"), - DEVICE( ADAPTEC2, ADAPTEC2_7899P, "AIC-7899"), + DEVICE( ADAPTEC2, ADAPTEC2_2940U2, "AHA-2940U2"), + DEVICE( ADAPTEC2, ADAPTEC2_7890, "AIC-7890/1"), + DEVICE( ADAPTEC2, ADAPTEC2_3940U2, "AHA-3940U2"), + DEVICE( ADAPTEC2, ADAPTEC2_7896, "AIC-7896/7"), DEVICE( ATRONICS, ATRONICS_2015, "IDE-2015PL"), DEVICE( TIGERJET, TIGERJET_300, "Tiger300 ISDN"), DEVICE( ARK, ARK_STING, "Stingray"), @@ -835,7 +804,6 @@ const char *pci_strvendor(unsigned int vendor) case PCI_VENDOR_ID_REALTEK: return "Realtek"; case PCI_VENDOR_ID_TRUEVISION: return "Truevision"; case PCI_VENDOR_ID_INIT: return "Initio Corp"; - case PCI_VENDOR_ID_TTI: return "Triones Technologies, Inc."; case PCI_VENDOR_ID_VIA: return "VIA Technologies"; case PCI_VENDOR_ID_SMC2: return "SMC"; case PCI_VENDOR_ID_VORTEX: return "VORTEX"; @@ -851,7 +819,6 @@ const char *pci_strvendor(unsigned int vendor) case PCI_VENDOR_ID_RENDITION: return "Rendition"; case PCI_VENDOR_ID_TOSHIBA: return "Toshiba"; case PCI_VENDOR_ID_RICOH: return "Ricoh"; - case PCI_VENDOR_ID_ARTOP: return "Artop Electronics"; case PCI_VENDOR_ID_ZEITNET: return "ZeitNet"; case PCI_VENDOR_ID_OMEGA: return "Omega Micro"; case PCI_VENDOR_ID_NP: return "Network Peripherals"; diff --git a/drivers/scsi/ChangeLog.ncr53c8xx b/drivers/scsi/ChangeLog.ncr53c8xx index 037c198c5d8b..2efc835e67e7 100644 --- a/drivers/scsi/ChangeLog.ncr53c8xx +++ b/drivers/scsi/ChangeLog.ncr53c8xx @@ -1,265 +1,5 @@ -Sun Dec 13 18:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 3.1e - - Same work-around as for the 53c876 rev <= 0x15 for 53c896 rev 1: - Disable overlapped arbitration. This will not make difference - since the chip has on-chip RAM. - -Thu Nov 26 22:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 3.1d - - The SISL RAID change requires now remap_pci_mem() stuff to be - compiled for __i386__ when normal IOs are used. - - Minor spelling fixes in doc files. - -Sat Nov 21 18:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 3.1c - - Ignore chips that are driven by SISL RAID (DAC 960). - Change sent by Leonard Zubkoff and slightly reworked. - - Still a buglet in the tags initial settings that needed to be fixed. - It was not possible to disable TGQ at system startup for devices - that claim TGQ support. The driver used at least 2 for the queue - depth but did'nt keep track of user settings for tags depth lower - than 2. - -Wed Nov 11 10:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 3.1b - - The driver was unhappy when configured with default_tags > MAX_TAGS - Hopefully doubly-fixed. - - Update the Configure.help driver section that speaks of TAGS. - -Wed Oct 21 21:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 3.1a - - Changes from Eddie Dost for Sparc and Alpha: - ioremap/iounmap support for Sparc. - pcivtophys changed to bus_dvma_to_phys. - - Add the 53c876 description to the chip table. This is only usefull - for printing the right name of the controller. - - DEL-441 Item 2 work-around for the 53c876 rev <= 5 (0x15). - - Add additionnal checking of INQUIRY data: - Check INQUIRY data received length is at least 7. Byte 7 of - inquiry data contains device features bits and the driver might - be confused by garbage. Also check peripheral qualifier. - - Cleanup of the SCSI tasks management: - Remove the special case for 32 tags. Now the driver only uses the - scheme that allows up to 64 tags per LUN. - Merge some code from the 896 driver. - Use a 1,3,5,...MAXTAGS*2+1 tag numbering. Previous driver could - use any tag number from 1 to 253 and some non conformant devices - might have problems with large tag numbers. - - 'no_sync' changed to 'no_disc' in the README file. This is an old - and trivial mistake that seems to demonstrate the README file is - not often read. :) - -Sun Oct 4 14:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 3.0i - - Cosmetic changes for sparc (but not for the driver) that needs - __irq_itoa() to be used for printed IRQ value to be understandable. - - Some problems with the driver that didn't occur using driver 2.5f - were due to a SCSI selection problem triggered by a clearly - documented feature that in fact seems not to work: (53C8XX chips - are claimed by the manuals to be able to execute SCSI scripts just - after abitration while the SCSI core is performing SCSI selection). - This optimization is broken and has been removed. - - Some broken scsi devices are confused when a negotiation is started - on a LUN that does not correspond to a real device. According to - SCSI specs, this is a device firmware bug. This has been worked - around by only starting negotiation if the LUN has previously be - used for at least 1 successful SCSI command. - - The 'last message sent' printed out on M_REJECT message reception - was read from the SFBR i/o register after the previous message had - been sent. - This was not correct and affects all previous driver versions and - the original FreeBSD one as well. The SCSI scripts has been fixed - so that it now provides the right information to the C code. - -Sat Jul 18 13:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 3.0g - - Preliminary fixes for Big Endian (sent by Eddie C. Dost). - Big Endian architectures should work again with the driver. - Eddie's patch has been partially applied since current 2.1.109 - does not have all the Sparc changes of the vger tree. - - Use of BITS_PER_LONG instead of (~0UL == 0xffffffffUL) has fixed - the problem observed when the driver was compiled using EGCS or - PGCC. - -Mon Jul 13 20:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 3.0f - - Some spelling fixes. - - linux/config.h misplaced in ncr53c8xx.h - - MODULE_PARM stuff added for linux 2.1. - - check INQUIRY response data format is exactly 2. - - use BITS_PER_LONG if defined. - -Sun Jun 28 12:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 3.0e - - Some cleanup, spelling fixes, version checks, documentations - changes, etc ... - -Sat Jun 20 20:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 3.0c - - Add a boot setup option that allows to set up device queue depths - at boot-up. This option is very usefull since Linux does not - allow to change scsi device queue depth once the system has been - booted up. - -Sun Jun 15 23:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 3.0a - - Support for up to 64 TAGS per LUN. - - Rewrite the TARGET vs LUN capabilities management. - CmdQueue is now handled as a LUN capability as it shall be. - This also fixes a bug triggered when disabling tagged command - queuing for a device that had this feature enabled. - - Remove the ncr_opennings() stuff that was useless under Linux - and hard to understand to me. - - Add "setverbose" procfs driver command. It allows to tune - verbose level after boot-up. Setting this level to zero, for - example avoid flooding the syslog file. - - Add KERN_XXX to some printk's. - -Tue Jun 10 23:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 3.0 - - Linux config changes for 2.0.34: - Remove NVRAM detection config option. This option is now enabled - by default but can be disabled by editing the driver header file. - Add a PROFILE config option. - - Update Configure.help - - Add calls to new function mdelay() for milli-seconds delay if - kernel version >= 2.1.105. - - Replace all printf(s) by printk(s). After all, the ncr53c8xx is - a driver for Linux. - - Perform auto-sense on COMMAND TERMINATED. Not sure it is usefull. - - Some other minor changes. - -Tue Jun 4 23:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 2.6n - - Code cleanup and simplification: - Remove kernel 1.2.X and 1.3.X support. - Remove the _old_ target capabilities table. - Remove the error recovery code that have'nt been really usefull. - Use a single alignment boundary (CACHE_LINE_SIZE) for data - structures. - - Several aggressive SCRIPTS optimizations and changes: - Reselect SCRIPTS code rewritten. - Support for selection/reselection without ATN. - And some others. - - Miscallaneous changes in the C code: - Count actual number of CCB queued to the controller (future use). - Lots of other minor changes. - -Wed May 13 20:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 2.6m - - Problem of missed SCSI bus reset with the 53C895 fixed by - Richard Waltham. The 53C895 needs about 650 us for the bus - mode to settle. Delays used while resetting the controller - and the bus have been adjusted. Thanks Richard! - - Some simplification for 64 bit arch done ccb address testing. - - Add a check of the MSG_OUT phase after Selection with ATN. - - The new tagged queue stuff seems ok, so some informationnal - message have been conditionned by verbose >= 3. - - Donnot reset if a SBMC interrupt reports the same bus mode. - - Print out the whole driver set-up. Some options were missing and - the print statement was misplaced for modules. - - Ignore a SCSI parity interrupt if the chip is not connected to - the SCSI bus. - -Sat May 1 16:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 2.6l - - Add CCB done queue support for Alpha and perhaps some other - architectures. - - Add some barriers to enforce memory ordering for x86 and - Alpha architectures. - - Fix something that looks like an old bug in the nego SIR - interrupt code in case of negotiation failure. - -Sat Apr 25 21:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 2.6k - - Remove all accesses to the on-chip RAM from the C code: - Use SCRIPTS to load the on-chip RAM. - Use SCRIPTS to repair the start queue on selection timeout. - Use the copy of script in main memory to calculate the chip - context on phase mismatch. - - The above allows now to use the on-chip RAM without requiring - to get access to the on-chip RAM from the C code. This makes - on-chip RAM useable for linux-1.2.13 and for Linux-Alpha for - instance. - - Some simplifications and cleanups in the SCRIPTS and C code. - - Buglet fixed in parity error recovery SCRIPTS (never tested). - - Minor updates in README.ncr53c8xx. - -Wed Apr 15 21:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 2.6j - - Incorporate changes from linux-2.1.95 ncr53c8xx driver version. - - Add SMP support for linux-2.1.95 and above. - - Fix a bug when QUEUE FULL is returned and no commands are - disconnected. This happens with Atlas I / L912 and may happen - with Atlas II / LXY4. - - Nail another one on CHECK condition when requeuing the command - for auto-sense. - - Call scsi_done() for all completed commands after interrupt - handling. - - Increase the done queue to 24 entries. - -Sat Apr 4 20:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 2.6i - - CTEST0 is used by the 53C885 for Power Management and - priority setting between the 2 functions. - Use SDID instead as actual target number. Just have had to - overwrite it with SSID on reselection. - - Split DATA_IN and DATA_OUT scripts into 2 sub-scripts. - 64 segments are moved from on-chip RAM scripts. - If more segments, a script in main memory is used for the - additionnal segments. - - Since the SCRIPTS processor continues SCRIPTS execution after - having won arbitration, do some stuff prior to testing any SCSI - phase on reselection. This should have the vertue to process - scripts in parallel with the SCSI core performing selection. - - Increase the done queue to 12 entries. - -Sun Mar 29 12:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 2.6h - - Some fixes. - -Tue Mar 26 23:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 2.6g - - New done queue. 8 entries by default (6 always useable). - Can be increased if needed. - - Resources management using doubly linked queues. - - New auto-sense and QUEUE FULL handling that does not need to - stall the NCR queue any more. - - New CCB starvation avoiding algorithm. - - Prepare CCBs for SCSI commands that cannot be queued, instead of - inserting these commands into the waiting list. The waiting list - is now only used while resetting and when memory for CCBs is not - yet available? - -Sun Feb 8 22:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 2.6f - - Some fixes in order to really support the 53C895, at least with - FAST-20 devices. - - Heavy changes in the target/lun resources management to allow - the scripts to jump directly to the CCB on reselection instead - of walking on the lun CCBs list. Up to 32 tags per lun are now - supported without script processor and PCI traffic overhead. - -Sun Jan 11 22:00 1998 Gerard Roudier (groudier@club-internet.fr) - * revision 2.6d - - new (different ?) implementation of the start queue: - Use a simple CALL to a launch script in the CCB. - - implement a minimal done queue (1 entry :-) ). - this avoid scanning all CCBs on INT FLY (Only scan all CCBs, on - overflow). Hit ratio is better than 99.9 % on my system, so no - need to have a larger done queue. - - generalization of the restart of CCB on special condition as - Abort, QUEUE FULL, CHECK CONDITION. - This has been called 'silly scheduler'. - - make all the profiling code conditionned by a config option. - This spare some PCI traffic and C code when this feature is not - needed. - - handle more cleanly the situation where direction is unknown. - The pointers patching is now performed by the SCRIPTS processor. - - remove some useless scripts instructions. - - Ported from driver 2.5 series: - ------------------------------ +Fri Jan 2 18:00 1998 Gerard Roudier (groudier@club-internet.fr) + * Revision 2.5f - Use FAST-5 instead of SLOW for slow scsi devices according to new SPI-2 draft. - Make some changes in order to accomodate with 875 rev <= 3 @@ -270,13 +10,1142 @@ Sun Jan 11 22:00 1998 Gerard Roudier (groudier@club-internet.fr) . Memory Read Line is not enabled for 875 and 875-like chips. . Programmed burst length set to 64 DWORDS (instead of 128). (Note: SYMBIOS uses 32 DWORDS for the SDMS BIOS) + +Sun Oct 26 12:00 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.5e - Add 'buschk' boot option. This option enables checking of SCSI BUS data lines after SCSI RESET (set by default). (Submitted by Richard Waltham). - Update the README file. + +Sat Oct 4 18:00 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.5d - Dispatch CONDITION MET and RESERVATION CONFLICT scsi status as OK driver status. - Update the README file and the Symbios NVRAM format definition with removable media flags values (available with SDMS 4.09). + +Sat Sep 20 21:00 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.5c - Several PCI configuration registers fix-ups for powerpc. (Patch sent by Cort). + +Thu Aug 28 10:00 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.5b + - Add 'ncr53c8xx' char pointer variable. This variable allows to + pass a boot command to the driver when it is loaded as a module. + Option separator is ' ' instead of ','. Example: + insmod /ncr53c8xx.o ncr53c8xx='verb:2 sync:0 specf:n' + - Always use 'driver_setup.settle_delay' for internal resets. + 2 seconds hardcoded is sometimes too short. Suggested by Richard W. + This delay may be shortenned in order to avoid spurious timeouts. + - Fix release module stuff that failed for more than 1 controller. + - For linux versions > 1.3.70, trust the 'dev_id' parameter passed + to the interrupt handler (dev_id = struct ncb *). + - Fix up in 'ncr_log_hard_error()' when the DSP points outside scripts. + Suggested by Stefan Esser. + +Tue Aug 23 23:43 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.5a + - Update Configure.help for inclusion in linux-2.1.51/2/3 + - Use BASE_2 address from PCI config space instead of some + IO register for getting the on-board SRAM bus address. + - Remove error testing of pcibios_read/write functions. + These functions are intended to be used for successfully + detected PCI devices. Expecting error condition from them + is nothing but paranoia. + +Thu Aug 21 23:00 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.5 + - 53C860 chip support fix. + - Move the 'host_status' to the last DWORD of the CCB header. + This header is copied back by the script processor. This + guarantees that the header is entirely copied back over + the PCI when the CPU completes a CCB. + - (re)read ISTAT prior to scanning CCBs for completion. This + ensure that any posted buffer are flushed prior CCBs scan. + - Support for BIG ENDIAN cpu. Added by Cort . + Initial patch did'nt support disconnections and tagged commands. + I've completed the patch and it seems that all is ok now. + Only some powerpc under 2.1.X is supported for the moment. + - Misc. trivial fixes and cleanups. + +Sat July 26 18:00 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.4 + Several clean-ups: + - Asynchronous pre-scaler calculation. + Synchronous divisor calculation. + - Use FE_ as feature identifier prefix instead of _F_. + - Change 'ns_sync' identifier to "minsync". + - Some others. + Apply some SPI2-R12 recommendations. + - Use Slow, Fast-10, Fast-20, Fast-40 SCSI instead of SCSI-2, + FAST SCSI-2, ULTRA, ULTRA-2. + - Reset the SCSI on bus mode change. + +Wed July 02 22:58 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.3c + - Add define SCSI_NCR_PCI_FIX_UP_SUPPORT for conditionnal compilation + of the corresponding pci fix-up code when a small driver is needed. + - Use "ncr53c8xx" as driver name for both request_irq() and + request_region(). Using different names confused 'lsdev'. + (Suggestion sent by Henrik Storner). + +Wed June 24 22:08 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.3b + - Print an error message on unexpected boot command line option. + - Switch to asynchronous data transfer mode after SCSI wide + negotiation. + +Wed June 24 22:08 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.3b + - Print an error message on unexpected boot command line option. + - Switch to asynchronous data transfer mode after SCSI wide + negotiation. + +Wed June 14 22:00 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.3a + - Add PCI LATENCY TIMER fixup code. + Increase it if necessary according to burst size. + Boot option bit : 'pcifix:4' + - On phase mismatch, calculate residual data size for all OUTPUT + phases. That's only required for interrupted DATA OUT phase, but + this information is usefull for problem solving. + - Add KERN_INFO to some messages printed to the log. + (Patch sent by Wolfram Kleff). + +Tue June 02 22:30 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.3 + - NvRAM support code slightly improved (I think): + Use IO or MMIO according to driver setup for reading the NvRAM. + Use structures for NvRAM data instead of raw data. + - Prevent from queuing more than 1 command to the scsi SCRIPT with + negotiation attached when tagged command queueing is enabled. + - Fix-up for old 53C8XX chips that support PCI READ LINE but not + CACHE LINE SIZE. If the cache line size is unknown, set burst + to 8 dwords and disable READ LINE, otherwise set burst max to + the cache line size value. + +Sat May 24 12:30 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.2c (for linux-2.1.40) + - Remove reference to 'x86' symbol when MODULE is defined, since this + symbol is not exported for module loading. + The value of 'x86' is used for fixing up the PCI CACHE LINE SIZE + configuration register. + - Bytes/words read one bit at a time from the serial NVRAM were'nt + initialized with zero. + - Some comments added. Minor cosmetic changes. + +Mon May 19 20:30 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.2b + - Patch for NVRAM support by Richard Waltham applied. + The code detects Symbios NVRAM format and Tekram NVRAM format. + This enhancement allows to get hosts and devices user set up + from the NVRAM. + - Use the NVRAM contents when present to initialize user definable + target parameters. + - Update the README file. + +Sun May 11 22:30 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.1b + - Cosmetic changes. + - Some heavy testings under pre-linux-2.1.37-6 + +Sun May 4 22:30 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.1a + - PFEN wrongly used for PREFETCH feature bit testing. + Changed to _F_PFEN. + - 2 SCR_COPY that need NO FLUSH bit to be removed had been missed + in tp->getscr[] script (loads SXFER and SCNTL3 on reselection). + +Sat May 3 22:30 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.1 + - Use the NO FLUSH option for MOVE MEMORY (COPY) each time it is + possible. More than 100 COPY with NO FLUSH and 6 with FLUSH for + my configuration (max queued command / device = 8). + This option bit is removed from the script instance for chips + that donnot support prefetching. + - Rewrite the ncr_exception() routine more simple (I think) and + remove useless code. + - Change the data_in and data_out script management. + Use the bottom part of these scripts instead of the beginning. + That avoids to zero the scatter/gather array when a command is + queued (1k) and to deal with some weird IID on MOVE 0 bytes when + a target wants to transfer more bytes than expected. + - Misc. improvements in the init code. + - Remove IOMAPPED/MMIO automatic switching option. + Was useless and reported not reliable. + - Fix a double read of DSTAT and remove DFE testing in the + Phase mismatch service routine. + - Etc... + +Fri Apr 26 20:00 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.0a + - Add support if the Diamond FirePort 40 (SYM53C875J chip) + +Mon Apr 22 22:00 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 2.0 + - incorporate __initdata and __initfunc directives in order to + allow 'init' to free unused memory after driver initialisations. + Patch sent by Roberto Fichera. + - rewrite the init code of the driver. Now a feature descriptor + is used for each real chip types. The code is a lot more clean, + since the driver uses device and revision ids only in the + detection procedure. + - add 'pcifix' boot command line. This command allows to fix up PCI + config space for new chips which support features based on the + cache line size and 'write and invalidate'. + - incorporate in the driver, the code used for error recovery + testing. This code is normally not compiled; have to define + SCSI_NCR_DEBUG_ERROR_RECOVERY in order to compile it. + - take into account actual SCSI bus mode for 53C895 LVD/SE controller. + In single ended mode only fast20 is supported. + (Just to not be late since such controllers are not yet available) + + +Sat Apr 20 21:00 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 1.18f + - fix an old bug included in the initial port (version 0.0). + The driver allocated 10 bytes of static data and uses 12 bytes. + No danger, since data are generally aligned on 4 bytes boundary + and so byte 10 and 11 are free (I hope ...) + +Wed Apr 16 12:00 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 1.18e + - reset all when an unexpected data cycle is detected while + disconnecting. + - make changes to abort() ans reset() functions according to + Leonard's documentation. + - small fix in some message for hard errors. + +Sat Apr 5 13:00 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 1.18d + - Probe NCR pci device ids in reverse order if asked by user from + the boot command line. Suggested by Richard Waltham. + - Make a separate function that prints out verbose information on + severe error (assumed from hardware). + - Add the transfer period factor and the max commands per lun value + to the proc info data. If debug flags are set or verbosity is + greater than 1, debug flags and verbosity are returned in proc + info data. + - Update the documentation. + +Thu Mar 20 23:00 1997 Gerard Roudier (groudier@club-internet.fr) + * revision 1.18c + - Add special features support for NCR53C885 and NCR53C896 chip. + Quite obvious, but untested, and based on the fact that: + The 885 supports same features as the 875. + The 896 is a 64 bits PCI version of the 895. + - Improve recovery from SCSI GROSS ERRORS. + I can get such errors by making the driver negotiate offset 8 with + a disk and setting the ncr chip to a lower offset value. + I got bunches of errors that have been gracefully recovered by + the driver. + The driver now uses its timer handler in order to wait 2 sec. for + devices to settle after SCSI reset and so does not uselessly freeze + the system with interrupt masked for seconds. + - Enable 'burst op code fetch' and 'read line' for 815 chips. + - Use a 2 commands queue depth instead of 1 for devices that does + not support tagged command queuing. + - The ULTRA timing flag setting was based on the output resulting + period factor of the ncr and not on the negotiated one. + This flag setting was wrong only for 24 ns negotiated period factor. + - Some other minor changes and cleanups. + +Thu Feb 27 23:00 1997 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c ncr53c8xx.h revision 1.18b + - 'On paper' support of the NCR53C895 Ultra-2 chip. + (Clock quadrupler + 7 clock divisors) + - Load the main part of the script into the on-board RAM. + - 810A rev. 0x11 PCI problem fixed. + This chip is now supported with all PCI features enabled and + 16 dwords burst transfers. + - Align on 32 boundary some internal structures. + That fixes the 810A problem and allows cache line bursting when + moving the global header (64 bytes) from/to CCBs to/from NCB. + - Synchronous parameters calculation rewritten. The driver + now uses all available clock divisors and will be able to support + clock frequencies that are not multiple of 40 Mhz if necessary. + +Sat Feb 8 22:00 1997 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c - revision 1.17a + - IRQ mode set up from boot setup command. + irqm:0 open drain (default) + irqm:1 preserve initial setting (assumed from BIOS) + irqm:2 totem pole + - DIFF mode set up from boot setup command. + Suggested by Richard Waltham. + diff:0 never set up diff mode (default) + diff:1 set up diff mode according to initial setting (BIOS?) + diff:2 always set up diff mode + diff:3 set up diff mode if GPIO3 is zero (SYMBIOS boards) + - Change CONFIG option for LED support. + CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT allows LED support and + DIFF support for SYMBIOS boards and compatibles (clones?). + - Set 16 DWORD bursts for 810A rev. >= 0x12 since my SC200 with + such a chip have no problem with it (MB with Triton 2 HX). + 810A rev. 0x11 are set to 8 DWORD bursts since they may give + problems with PCI read multiple and Triton 2 HX. + Thanks to Stefan for this information. + +Sat Jan 25 22:00 1997 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c - revision 1.17 + - Controller LED support. + Only works with LED pin wired to GPIO_FETCHN, so probably with + all boards using SMDS BIOS. + This option can be enabled only if CONFIG_EXPERIMENTAL is set. + - Assume clock doubler for 875 chip when clock frequency measurement + result is 40 MHz. May help when some old stuff as SDMS BIOS 3.0 + or some old driver has broken the normal BIOS settings. + - Add wide negotiation control from boot setup command. + May be usefull with systems using a 875 based board connected to + a wide device through a 50 pins to 68 pins converter. + - Add a "boot fail safe option" to the boot setup command line. + - Rewrite the "reset_command" routine. + Low-level driver are responsible to keep the involved command + alive. The new code seems to behave correctly. + - Change some variables used by the script from u_long to u_int32. + - Remove some useless code. + +Sun Jan 12 12:00 1997 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c - revision 1.16e + - Add support of PCI burst length control from boot setup command. + burst:0 disable burst + burst:255 get burst from initial settings (BIOS settings?) + burst:#x set burst transfers to 1<<#x + - Only check xfer direction for common op-codes. + For all device specific / vendor specific opcodes the driver + now uses the xfer direction decided by the target. + +Sun Jan 05 12:00 1997 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c - revision 1.16d + - The driver is now able to process scsi commands without + knowledge of xfer data direction. + Stefan agreed with this change for Linux. This change is + not needed under FreeBSD since low-level drivers receive + the expected data direction for each scsi request. + - Save ctest5 features bits at start-up and restore them at + module release step. + Avoid side effects when a ncr driver which trusts bios + settings is reloaded (could be the ncr53c8xx itself). + + +Wed Jan 01 23:30 1997 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c - revision 1.16c + - Bad decision about 20MHz for 13 ns period factor. + Was wrong, so I restore the previous algorithm. + - Burst length 128 not correctly set in dmode. + +Thu Dec 26 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c ncr53c8xx.h README.ncr53c8xx - revision 1.16b + - Remove useless code. + - Try to improve error recovery in case of abort and reset. + - Remove DEBUG_NEGO by default. + - Add boot setup command support. + Now, all experimental config options can be removed. + - Update README file. + + +Mon Dec 23 23:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c ncr53c8xx.h - revision 1.16a + New display for speed ##.# MB/s (From Stefan) + - I add "WIDE" qualifier after ULTRA and FAST + - I get "FAST WIDE SCSI-2 20 MB/s" with my Atlas. That's nice. + + Richard Waltham reports SYMBIOS set the 875 to 20 MB/s for 13 ns + period factor. I decide to trust SYMBIOS. 20 MB/s output speed + instead of 19.2 MB/s should not cause problem. The ncr is only able + to use 16.67 MB/s when 20 MB/s is not possible. + + Fix from Markus Kossman: "Ultra SCSI enabled" wrongly printed + when not enabled. + + Set DEBUG_NEGO by default in order to get reports about sync nego. + Will remove it in the next patch. + +Thu Dec 19 21:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c ncr53c8xx.h README.ncr53c8xx - revision 1.16 + Incorporate new definitions in ncr53c8xx.h (From Stefan). + Check changes against Stefan's current version of the driver. + All seems ok. + +Sat Nov 30 21:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c ncr53c8xx.h + Make changes in order to support: + - Clock doubler and so 80 Mhz scsi clock for 875 chips. + - Sync transfers below 7.5 MB/sec. + Use Clock/2 between 5 and 10 Mega-transfers/s and Clock/4 below 5. + - Ultra SCSI data transfers. + - Offset 16. + + Works with my configuration. However I cannot test Ultra transfers, + since my disks are only fast scsi-2. + +Tue Nov 28 21:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + I received yesterday my Promise SCSI Ultra board. + NCR53C875 rev. 3 with clock doubler. + Add the code to support some bus features, the large 536 dma fifo and + burst 128. Works. + +Mon Nov 4 21:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c ncr53c8xx.h - revision 1.14c + Severall control command improvements: + + - Allow to specify "all" to commands that apply to #target. + For example: "setsync all 255" sets asynchronous data + transfers for all targets on a bus. + + - Allow to control disconnection privilege per device, as follow: + "setflag #target no_sync" disables disconnection for #target. + "setflag #target" with no flag specified reenables it. + + Obviously #target may be specified as "all" in order to control + disconnection for all targets with a single control command. + + - README file updated and some hints about SCSI problems solving added. + +Sun Oct 27 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c ncr53c8xx.h - revision 1.14b + Add the following config parameters: + + - CONFIG_SCSI_NCR53C8XX_MAX_TAGS + Max number of queued tagged commands. + Allow from 2 to 12, default 4. + + - CONFIG_SCSI_NCR53C8XX_SYNC + Synchronous transfers frequency in MHz. + Allow from 5 to 10, default 5, 0 means asynchronous. + (And so remove CONFIG_SCSI_NCR53C8XX_FORCE_ASYNCHRONOUS) + +Sun Oct 20 16:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + ncr_scatter() rewritten. + remove "ncr dead" detection. + +Sun Oct 13 19:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c ncr53c8xx.h - revision 1.14a + Enabling some special features makes problems with some hardware. + So, disable them by default. + Add SCSI_NCR_SPECIAL_FEATURES define to play with. + +Sun Oct 13 14:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c ncr53c8xx.h + Incorporate Stefan's patch for clock frequency detection. + (Committed in FreeBSD/ncr.c rev. 1.81). + The driver then does about the following: + Assume 40 MHz clock for all ncr chips except: + - NCR53C860 chips: + Assume 80 Mhz clock. + - NCR53C875 chips: + If clock doubler enabled, disable it and assume 40 Mhz clock. + Else if (scntl3&7)=0 measure scsi clock frequency. + Else trust bios setting of scntl3&7 (3=40 Mhz, 5=80Mhz). + +Wed Oct 9 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c - release 1.14 + For now, just change the clock detection as follow: + - If clock doubler selected by BIOS, assume 40 MHz clock since + clock doubler will be disabled by chip reset. + - Else if NCR53C860 assume 80 MHz clock. + - Else trust BIOS setting if (scntl3&7 >= 3) + - Else assume 40 MHz clock. + +Sat Oct 05 17:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Stefan sent me a patch that improves the clock frequency detection + of the driver. Stefan uses the general timer register stime1 in + order to measure as accurately as possible the scsi clock. + Works ok with my 825, but needs still testing. So will be + released later. + +Sun Sep 29 17:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Preserve dcntl/dmode/ctest3/ctest4 features bits at start-up. + Add the define option SCSI_NCR_TRUST_BIOS_SETTING. + - If this option is defined, the driver will preserve the + corresponding bits of io registers. + - Else, the driver will set features bits according to chip + and revision ids. + +Sun Sep 22 17:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Remove useless fields and code and so spare cpu: + - profile data are accumulated in jiffies ticks and converted + to milli-seconds when read through proc fs. + - when IOMAPPED is not defined, try only MMIO. + (avoid testing a value in order to choose between IO and MMIO) + +Sun Sep 01 20:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.h, ncr53c8xx.c - Version 1.13 + Adaptation of the tagged command queuing depth control of the + FreeBSD driver to Linux. Now, tagged command queueing can be + disabled at run time by a "settags N 0" control command. + Add the following heuristic in order to manage intelligently (perhaps) + QUEUE_FULL status: + - Each time a QUEUE FULL status is returned by a device, disable tagged + command queuing for that device. + - Every 100 successfully complete commands, increment the maximum + queuable commands (up to the allowed limit). + +Fri Aug 30 10:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c - Version 1.12c + Incorporate the changes of FreeBSD/ncr.c revision 1.76. + The changes add support for the 53c860 and 53c875, + but without taking advantage of the new features. + Those chips are used exactly as the old 53c810. + +Sun Jul 21 00:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c, README.ncr53c8xx + Add the ncr53c8xx_select_queue_depths() function. + Set queue_depth to SCSI_NCR_MAX_TAGS (4 by default) for devices that + support tagged command queueing. + For other devices, set queue_depth to 1. No need to queue a command + to the driver if this command cannot be sent to the device. + Each time the driver hide io requests from the kernel and/or from the + driver, it may break a little (or a lot) optimization algorithms that + try to increase throughput by reordering io requests. + It is better to enable the disk write caching to reduce latencies for + write operations, and to trust asynchronous read ahead from the device + and from the kernel that can reduce latencies for read operations, + even when tagged command queuing is not supported or enabled. + +Sat Jul 20 20:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Minor changes: + - Problem of "CCB address mismatch" that happens with the 3 versions + of the driver. The CCB is correct and Stefan Esser suggests a little + patch that seems to be a bypass. + Stefan says he will change that in a future version of the BSD driver. + - Set burst transfers to 8 for 815 chips. + +Sun Jul 14 15:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c, Configure.help + Memory mapped io donnot work under linux/Alpha for the driver. + For the moment it is better to not support this feature for this + architecture. + +Tue Jul 09 20:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Garbage printed out with the following command (fixed): + - cat /proc/scsi/ncr53c8xx/0 + +Sun Jul 07 20:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Tagged command queueing cannot be disabled at run time. + I probably never try that because I felt the risk. + Shortest patch sent to Linus. I have to plan something better. + +Wed Jul 03 23:00 1996 Gerard Roudier (groudier@club-internet.fr) + Release 1.12a + Tested linux releases: 1.2.13, 2.0.0, 2.0.1 + +Mon Jul 01 21:00 1996 Gerard Roudier (groudier@club-internet.fr) + ncr53c8xx.h, ncr53c8xx.c + Add "clearprof" user command that clear the profile counters. + Automatically clear profile counters when num_kbytes=1000000000 + in order to avoid ugly overflow. + Donnot compile user command code and profile data with 1.2.13. + +Wed Jun 29 20:38 1996 Gerard Roudier (groudier@club-internet.fr) + Matthew Geier reported to me a weird problem of unexpected + disconnection while asynchronous negotiation. + The message sent by the driver is 1-3-1-ff-00. I sent a patch to + Matthew that change the message to 1-3-1-00-00. + The sync msgout was correct however some devices might be to happy + with ff. + +Wed Jun 26 22:57 1996 Gerard Roudier (groudier@club-internet.fr) + Patch no 4 sent to Harald. + The drived used "wtime" for timeouts adn time measurements. + I change for jiffies. + Work with my P133. + +Mon Jun 24 23:05 1996 Gerard Roudier (groudier@club-internet.fr) + Patch no 3 sent to Harald. + +Sun Jun 23 22:29 1996 Gerard Roudier (groudier@club-internet.fr) + Patch no 2 sent to Harald. + I think that the driver have some chance to work. + +Sun Jun 23 15:00 1996 Gerard Roudier (groudier@club-internet.fr) + Harald Koenig is interested in the adaptation of the driver to + Linux/Alpha. + I have prepared a patch and sent it to Harald. + +Sun Jun 16 19:00 1996 Gerard Roudier (groudier@club-internet.fr) + Release 1.11 + Tested linux releases: 1.2.13, 2.0.0 + +Sat Jun 15 23:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.h, Configure.help, scsi/Config.in + Add CONFIG_SCSI_NCR53C8XX_IOMAPPED config option. + Prepare the 2.0.0 with the new version of the driver. + +Wed Jun 12 23:00 1996 Gerard Roudier (groudier@club-internet.fr) + Rewrite the README file. + Add some documentations of the proc file system support. + +Sun Jun 9 18:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Add proc filesystem support of the driver. + Read operations returns profile information. + Write operations send control commands to the host adapter driver. + +Wed Jun 5 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + Change xfer direction for SCAN command to write. + Was bogus. + +Tue May 30 18:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Set the DMA FIFO to 88 for 825A and 875 boards. + The previous value of 536 is bogus since the script only read 7 + bits for the fifo size (thanks to Stefan). + +Mon May 27 18:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Correct the xfer direction guessing for scanner SCAN command (write). + +Mon May 27 18:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Add the following config options: + SCSI_NCR_DISABLE_MPARITY_CHECK : disable master parity checking. + SCSI_NCR_DISABLE_PARITY_CHECK : disable scsi parity checking. + SCSI_NCR_FORCE_SYNC_NEGO : force sync nego for all scsi 2 devices. + +Sat May 25 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + Release 1.10 + Tested linux releases: 1.2.13, 1.3.45, 1.3.71, 1.3.90, 1.3.100 + 1.99.6, 1.99.7 + Switch between Drew's driver and Bsd driver tested for 1.99.7. + Both driver was made as modules. + +Sat May 25 16:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Some weird problems happen with multi-lun configurations and HDs. + SDTR seems to be sent with TEST UNIT READY of lun 1. + Tagged Queue cannot be enabled. It seems that inqdata are + filled with garbage probably due to some INQUIRY command to + lun 1. + I have fixed the problem as follow: + - negotiation are initiated only with a command to lun 0. + - inquiry data are store only for lun 0. + +Wed May 22 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c, ncr53c8xx.h + Have prepared the patch that allow to install the driver in the + kernel tree, without moving Drew's one. + Seems to work. However, I have to check that nothing has been + broken for 1.2.13 and 1.3.45 to 1.3.100. + +Sun May 4 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.h + Adapt the source to some modifications of the linux tree of 1.3.98. + (include/linux/scsicam.h moved to include/scsi/scsicam.h) + +Thu Apr 25 21:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.h, ncr53c8xx.c + Release 1.9 + Prepare conditionnal compilations for the future Linux version(s). + Assume that these versions will be nicely compatible with current + one. + 1.3.255, 1.4.0 or 2.0.0 ? + I suggest 3.0.0 for some obvious reason. + +Wed Apr 24 23:15 1996 Gerard Roudier (groudier@club-internet.fr) + * Install.ncr53c8xx + Add Patch-Current.ncr53c8xx to the distribution. + This patch is applied to the scsi Makefile at installation time for + Linux release V.P.S (V*1000000000+P*100000000+S > 1300000094). + Each time it'll be necessary I will send the patch corresponding to + the current Linux release to the linux-scsi@vger.rutgers.edu. + +Sun Apr 21 19:00 1996 Gerard Roudier (groudier@club-internet.fr) + * README.ncr53c8xx + Update Bonnie results of linux-1.3.92 + prepatch read-ahead 1.3.93. + Results are so good that I must remove FreeBSD-2.0.5 results from the + README file, otherwise I should cause trouble for myself. + +Sun Apr 07 21:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.h + Define SCSI_NCR_MAX_LUN (8) inconditionaly. + Previous releases did not work for multi-lun devices. + This definition was wrongly conditionned: + (SCSI_CONFIG_MULTI_LUN instead of CONFIG_SCSI_MULTI_LUN). + No luck, since I donnot have multi-lun devices and could'nt + test it. + Some tests under linux-1.3.84 with an experimental patch that + try to do asynchronous read-ahead. + +Wed Apr 03 23:15 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.h, ncr53c8xx.c + Change some wrong "assert (target == cmd->target & 7)" to + "assert (target == (cmd->target & 0xf)". + Remove NCR_TIMEOUT_ALERT from ncr53c8xx.c + Add SCSI_NCR_TIMEOUT_ALERT to ncr53c8xx.h + +Sun Mar 24 21:15 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.h + During "make dep" of linux-1.2.13, LINUX_VERSION_CODE is undefined. + Have to assume 1.2.13 in such situation. + Release 1.8 + +Sun Mar 24 21:00 1996 Gerard Roudier (groudier@club-internet.fr) + * README.ncr53c8xx + Make changes according to the new uninstallation procedure. + +Sun Mar 24 20:00 1996 Gerard Roudier (groudier@club-internet.fr) + * Uninstall.ncr53c8xx + Add an uninstallation script to the distribution. + This shell script restore the standard driver. + Very usefull for people who prefers to use a driver that + does not support: + - Master parity check + - Tagged command queuing + - Fast Wide Scsi-2 features (up to 20 MB/sec) + and that would be capable to reject a Wide Negotiation that it had + previously initiated. + +Sat Mar 23 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + * README.ncr53c8xx + Make changes according to the new installation procedure. + +Fri Mar 22 23:00 1996 Gerard Roudier (groudier@club-internet.fr) + * Install.ncr53c8xx + Add an installation script to the distribution. + 3 differents patches are necessary: + - linux-1.2.13 + - linux-1.3.45 to linux-1.3.49 + - linux-1.3.50 to linux-1.3.77 + +Wed Mar 13 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c, ncr53c8xx.h + Add share irq support. + This facility appears with linux-1.3.70. It seems that the + corresponding code of the kernel was questionnable before 1.3.72. + I decide to support this options from linux-1.3.72 and above. + (Add define option SCSI_NCR_SHARE_IRQ) + Release 1.7 + +Tue Mar 12 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Download BSD ncr.c 1.67 and apply the correction of negotiations order. + Now the Wide and Sync negotiation are done in the proper order. + (Problem reported by Johannes Plass). + Round up correctly the announced speed in MB/sec. + +Tue Mar 05 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + * README.ncr53c8xx + Have to upload release 1.6 for users of linux-1.3.70-71 + +Mon Mar 04 16:00 1996 Gerard Roudier (groudier@club-internet.fr) + * README.ncr53c8xx + Add some Bonnie results to the README file. + +Sun Mar 03 20:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Make changes for linux-1.3.70 according to the new specification of + irq services interface (request_irq(), free_irq()). + With 26 letters, "_", and 10 digits we can build about: + 53x62**9 C names of 10 characters. + Why to use SAME function names with DIFFERENT parameters ? + +Sat Mar 02 22:30 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Using SIMPLE QUEUE TAG for all operations is good for performances, + but may be bad for assumed timeout values. + Under heavy disk load (Bonnie), the drive may start IO process of a + command, then disconnect, then execute lots of other commands + before completing the interrupted command. + The standard value of SD_TIMEOUT (6 sec or 7 sec) seems (is) too short. + I fix the problem by forcing an ORDERED QUEUE TAG for the next + command when I found some "old" pending command. + "Old" means that they might be timeouted in a few seconds. + Add NCR_TIMEOUT_ALERT and set it to 3 seconds. + +Fri Mar 01 22:30 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.h, ncr53c8xx.c + Add define SCSI_NCR_SEGMENT_SIZE and set it by default to 512. + If undefined, the driver use the scatter list given by the upper + scsi driver, else it tries to split segments into shorter one + according to the value of SCSI_NCR_SEGMENT_SIZE. + +Tue Feb 27 21:30 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.h + Set sg_tablesize to 127 = SCSI_NCR_MAX_SCATTER-1. + (was 64 = SCSI_NCR_MAX_SCATTER/2). + May increase the speed (about 20%) for linear read/write operations. + Bonnie results may be better, but I prefered the previous + value. + +Tue Feb 27 21:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr54c8xx.c, ncr53c8xx.h + Tagged command queueing seems to affect linux-1.3.XY kernels. + I decide to disable tagged queue by default and to provide a command + tool to enable it per device after boot-up. + Add scsitag.c to the distribution. + Usage: scsitag device + Examples: scsitag /dev/sda + scsitag /dev/sdb + +Sun Feb 25 14:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c, ncr53c8xx.h + Add INQ7_Default definition and set the target capabilities to this + value by default. + Add some code to reject a synchronous negotiation request from a target + that is defined as not capable of Sync in the table of capabilities. + +Sat Feb 24 23:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Add some code to fill some write-only host instance fields: + - base + - io_port + - n_io_port + - dma_channel + This fields may be used with some "standard" drivers that do not + process correctly the release function. + +Fri Feb 23 23:00 1996 Gerard Roudier (groudier@club-internet.fr) + I receive a mail from Jason Duerstock. + A new bug in ncrBsd2Linux which is probably outside the driver code + and inside Linux kernel code. + The kernel memory is quite corrupted and we cannot get any information + by looking into the messages about the crash. However Linus see a bug in + ncrBsd2Linux because it is a "non standard" driver. + I think too that ncrBsd2Linux is not a standard driver of Linux kernel, + because it has no bugs enough to become standard for Linux. + Drew's driver is quite standard. + +Wed Feb 21 23:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c, ncr53c8xx.h + I incorporate the differences between FreeBSD ncr.c revision 1.62 and + revision 1.64. + - Some cosmetic changes. + - Use M_SIMPLE_TAG by default (even for write operations). + I seems to me that SIMPLE TAG is safe only if the flag "queue + algorithm modifier" is set to zero. + I will ask some questions to Stefan Esser about this. + Add option SCSI_NCR_ALWAYS_SIMPLE_TAG in ncr53c8xx.h. + +Fri Feb 16 23:00 1996 Gerard Roudier (groudier@club-internet.fr) + I have found the bug. It is a recursion in __get_free_pages(). + I will send a mail to Linus about this. + +Sat Feb 10 20:00 1996 Gerard Roudier (groudier@club-internet.fr) + I am sure that the kernel stack overflow is due to a severe bug in + the Linux kernel. + I decide to try to find the bug by myself. + +Fri Feb 09 20:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c, ncr53c8xx.h + Limit commands per lun to 2 for linux-1.3.XY. + The patch-1.3.60 does not correct the kernel stack overflow problem. + I decide to make some tests with Drew's driver and Bsd2Linux with same + working conditions (3 commands per lun, FAST SCSI, no command queueing). + I get the stack overflow problem with the 2 drivers at the same + frequency. + With only 2 commands per LUN, I don't have the problem with any driver. + It seems that the madness of recursion and the recent introduction of + the silly generic read function have broken performance and reliability + of scsi drivers. + +Thu Feb 08 23:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c, ncr_attach() + Release memory mapped region and io port if initialisation + does not succeed. + +Thu Feb 08 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c, ncr53c8xx.c + Try to spare some CPU time in queue_command() function and interrupt + handler: + Add SCSI_NCR_PARANOIA define option in ncr53c8xx.h. + Add SCSI_NCR_PROFILE define option in ncr53c8xx.h. + Avoid useless code and function calls. + +Tue Feb 06 21:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c, ncr53c8xx.h, ncr_timeout() + Add SCSI_NCR_BROKEN_INTR define option in ncr53c8xx.h. + If this option is set, the timeout handler polls the interrupt status + register every tick (10 ms). So, boards with broken interrupt can work. + +Mon Feb 05 21:30 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Print the correct speed, for devices with successfull wide negotiation. + For same period, such devices are two times faster then narrow ones. + +Mon Feb 05 21:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.h, ncr53c8xx.c, ncr_attach() + Add define SCSI_NCR_SETTLE_TIME in header file and set it by default + to 2 seconds. + +Sat Jan 27 14:00 1996 Gerard Roudier (groudier@club-internet.fr) + Upload release 1.3 + +Wed Jan 24 24:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Update from ncr Bsd 1.60 (Stefan Esser): + The handshake timeout is disabled, since + a few devices will delay ACK for more than a + second: Scanner, CDROM writer and a few old hard + disk drives. + +Wed Jan 24 22:30 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Set the selection timeout to 0.4 sec, since 0.25 sec + is recommended for scsi-1 devices. + Note that the Bsd ncr driver sets this timeout to 0.1 sec + and the linux standard ncr driver sets it to 0.8 sec. + +Wed Jan 24 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Add a 5 seconds delay after chip initialization, + waiting for scsi devices to settle their stomach, + as FreeBSD generic scsi driver does. + +Tue Jan 23 23:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Set burst length value according to chip type. + The original Bsd ncr driver sets burst length to 16 for + all chip types. + +Tue Jan 16 23:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c, ncr53c8xx.h + Add comments to linux specific glue code. + +Mon Jan 15 22:00 1996 Gerard Roudier (groudier@club-internet.fr) + io mapped versus memory mapped. + * ncr53c8xx.c + Add some code to dynamicaly switch to io mapped if memory mapped + does not work. + No more need to reconfigure, compile and link the kernel if + memory mapped is not possible. + +Sun Jan 14 18:00 1996 Gerard Roudier (groudier@club-internet.fr) + Patch sent to ncr mailing list by Jason Duerstock + + I have omitted to provide the proc_dir_entry to the middle + scsi driver. + * ncr53c8xxx.c + Add the declaration of the ncr53c8xx proc_dir_entry and return + the pointer to middle scsi driver. + +Sat Jan 13 01:00 1996 Gerard Roudier (groudier@club-internet.fr) + ncrBsd2Linux 1.1 is ready. + Upload to sunsite immediatly. + +Fri Jan 12 23:45 1996 Gerard Roudier (groudier@club-internet.fr) + It seems that scsi-2 devices too may cause problems because they + have flawes in the firmware. + * ncr53c8xx.h + I add a table of capabilities per target. + This table contains one byte per target. The value of this byte + is anded with byte 7 of INQUIRY data. + Edit ncr53c8xx.h and read the corresponding comments for more + details. + +Wed Jan 10 22:35 1996 Gerard Roudier (groudier@club-internet.fr) + I have some time to read the scsi-1 specifications. + Some very old scsi devices may cause problems with the ncr Bsd driver + for the following raisons: + The Synchronous Negotiation protocol was optional. + The standardized INQUIRY data does not include the byte 7 of + the scsi-2 specifications which contains the capabilities of + the device. + I think that negotiation with such devices are very questionnable. + * ncr53c8xx.c + ncrBsd2Linux 1.1 does not negotiate with scsi-1 devices. + +Sat Jan 06 21:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c function ncr_attach() + Disable chip interrupt before soft reset in attach procedure. + When loadlin is used to boot the system, the state of the NCR chip + is unpredicable. This modification avoid unexpected interrupts. + +Thu Jan 04 23:45 1996 Gerard Roudier (groudier@club-internet.fr) + ncrBsd2Linux 1.0 is ready. + Upload to sunsite immediatly. + +Tue Jan 02 23:00 1996 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Add a waiting list for Scsi Commands than can be inserted + into the start queue immediatly. + When a command complete, the waiting commands are requeued by calling + the queuecommand() function. + +Sun Dec 31 23:59 1995 Gerard Roudier (groudier@club-internet.fr) + * ncr53c8xx.c + Use kmalloc()/kfree() for internal data structures allocation to + avoid scsi memory pool shortage. + +Sat Dec 30 23:00 1995 Gerard Roudier (groudier@club-internet.fr) + ncrBsd2Linux can now use memory mapped IO. + Works fine. + * ncr53c8xx.c + Call vremap() from ncr_attach() to map the physical page which + contains the memory IO window. + Call vfree() from ncr_detach() (release module). + +Fri Dec 29 23:45 1995 Gerard Roudier (groudier@club-internet.fr) + ncrBsd2Linux can now be configured as a module. + Works fine. + * ncr53c8xx.c: add new functions ncr53c8xx_release() and ncr_detach() + Add the code to (per host): + Stop the timer. + Stop the chip. + Free allocated memory. + +Fri Dec 29 23:00 1995 Gerard Roudier (groudier@club-internet.fr) + Problem: detection routine returns 0 and can detect only one host. + * ncr53c8xx.c function ncr_attach() + ncr_attach() now returns 0 on success and -1 on error. + ncr53c8xx_detect() returns the number of detected hosts. + +Thu Dec 28 22:00 1995 Gerard Roudier (groudier@club-internet.fr) + I must upload the new version which corrects the severe problem with + WRITE_10 command. + Release 0.5 + Known or probable problems with this ncr driver release: + -------------------------------------------------------- + Same as the previous release. + +Wed Dec 27 23:00 1995 Gerard Roudier (groudier@club-internet.fr) + Problem: + System CRASH or scsi ERROR "extra data disgarded" on WRITE(10) + command. + * ncr53c8xx.c function guess_xfer_direction() + I add the WRITE(10) (0x2A) into the list of Data Out scsi commands. + It was a big mistake. + This BUG was introduced in the release 0.3 and is obvious present in + the release 0.4. + +Wed Dec 27 22:00 1995 Gerard Roudier (groudier@club-internet.fr) + Problem: + When I was testing tagged command queueing and disconnections + with one hard disk at a time (IBM S12), the script process hung + every 5 minutes with a non empty stall queue. + * ncr53c8xx.c function ncr_exception() + I replace "OUTB (nc_istat, INTF)" by + "OUTB (nc_istat, (istat & SIGP) | INTF)". + This statement cleared the INTF condition, but cleared the SIGP flag too. + (This bug is in the original FreeBSD ncr driver). + +Mon Dec 25 22:00 1995 Gerard Roudier (groudier@club-internet.fr) + Release 0.4 + Known or probable problems with this ncr driver release: + -------------------------------------------------------- + Hardware (or software) conflicts with some ethernet cards. + See release 0.2 above. + Crash with Intel saturn chipset with write-back cache enabled. + The SCSI SCRIPT access the internal registers of + the NCR chip by memory addressing. + Ensure that the memory area of the NCR chip is not cacheable. + Use scanpci to get the base memory address of the ncr chip. + The 128 bytes following this address must not be cached. + +Sat Dec 23 22:00 1995 Gerard Roudier (groudier@club-internet.fr) + Problem: + FreeBSD driver important comments + --------------------------------- + We try to reduce the number of interrupts caused + by unexpected phase changes due to disconnects. + A typical harddisk may disconnect before ANY block. + If we wanted to avoid unexpected phase changes at all + we had to use a break point every 512 bytes. + Of course the number of scatter/gather blocks is + limited. + * ncr53c8xx.c function ncr_scatter() + This function has been rewritten according to the above comments. + The Linux scatter list is scanned, and blocks are broken as possible + into 512 bytes chunks. + +Wed Dec 22 22:00 1995 Gerard Roudier (groudier@club-internet.fr) + Problem: ensure that there are enough allocated Command Control Blocks + for each unit to enqueue commands according to cmd_per_lun. + * ncr53c8xx.c function ncr_allocate_ccb() + Allocate all required ccb(s) instead of one at a time. + +Mon Dec 18 23:00 1995 Gerard Roudier (groudier@club-internet.fr) + Problem: A copy of the system time is used to compute timeouts. + When the system time is changed , we can get spurious timeouts + if scsi commands are pending. + * ncr53c8xx.c function ncr_timeout() + In FreeBSD the kernel time (volatile struct timeval time) is not + affected by settimeofday() or other change time functions. + For Linux, I replace "time" by "xtime". But "xtime" is the system time, + and is affected by change time functions. + If we detect a change <=-1s or >1s we assume system time has been changed. + For all active ccb(s), we recompute tlimit. + We set heartbeat to thistime to prevent spurious chip reset. + +Sun Dec 17 23:00 1995 Gerard Roudier (groudier@club-internet.fr) + Release 0.3. + +Sun Dec 17 11:00 1995 Gerard Roudier (groudier@club-internet.fr) + + Problem: Linux middle-level scsi driver does not provide the + direction of transfert in scsi command parameters. + FreeBSD ncr driver need this information to patch the SCSI script + for SAVE DATA POINTER and to check actual data transfer direction. + * ncr53c8xx.c + I add the function guess_xfer_direction(int opcode) which try to + guess the transfer direction. + Unfortunately my documentation about SCSI-II standard is very old. + It does not contain PHOTO-CD command specifications. + I assume input transfer direction, for unknown command. (not perfect) + +Wed Dec 15 23:00 1995 Gerard Roudier (groudier@club-internet.fr) + + It's time to schedule the release 0.2 + Known or probable problems with this ncr driver release: + -------------------------------------------------------- + Scsi tapes do not work. + scsi-config-1.5 does not work too. + Hardware (or software) conflicts with some ethernet cards. + The linux native ncr53c810 scsi driver does'not use memory + mapped IO at all. + The BSD driver can use memory mapped IO. + Under Linux, i seems to be difficult (or impossible) to map + a PCI memory area. So I decide to use normal IO in the code of + the ported driver. + However, the SCSI SCRIPT access the internal registers of + the NCR chip by memory addressing. + EThernet cards use a memory area to communicate with the system. + I think that this memory area conflicts with the memory area + used by the NCR chip. + The configuration diskette of your ethernet card can help you + to fix the problem (try sofware configurations). + +Wed Dec 15 22:00 1995 Gerard Roudier (groudier@club-internet.fr) + + Problem: detection of CD change did not work. + * ncr53c8xx.c + Signal a CHECK_CONDITION (S_CHECK_COND) to the middle-level + scsi drivers when the scsi completion status = S_SENSE|S_GOOD. + + Problem: System hang with status <4/82> after mounting the root + partition. System disk is a QUANTUM EMPIRE 1080 S. + Submitted by rwilhelm@Physik.TU-Muenchen.DE (Robert Wilhelm) + Thu, 14 Dec 1995 10:18:43 +0100 (MET) + * ncr53c8xx.c + Signal a CHECK_CONDITION (S_CHECK_COND) to the middle-level + scsi drivers when the scsi completion status = S_SENSE|S_CHECK_COND. + (HS_COMPLETE=4, S_SENSE|S_CHECK_COND=x82). + I can't test this fix. I think that it should work. + +Thu Dec 14 22:00 1995 Gerard Roudier (groudier@club-internet.fr) + + Problem submitted by Bill Dyess Tue 12 Dec 1995 + Only one lun detected on a Pioneer DRM-602X 6-disk CD-ROM changer. + * ncr53c8xx.h, ncr53c8xx.c + Define NCR_SCSI_MAX_LUN to 8 if the Linux configuration flag + SCSI_CONFIG_MULTI_LUN is set. + My CD device has only one lun. I can't test multi-lun device, + but I think that it should work. + + * ncr53c8xx.c + Write the ncr_abort_command() and ncr_reset_command() functions. + I intend to test these functions next week. + +Sun Dec 10 22:00 1995 Gerard Roudier (groudier@club-internet.fr) + * Release 0.1 + Works fine with hard disks under Linux 1.2.13 and Linux 1.3.45. diff --git a/drivers/scsi/Config.in b/drivers/scsi/Config.in index 60b4b675cd27..483b848ac9ac 100644 --- a/drivers/scsi/Config.in +++ b/drivers/scsi/Config.in @@ -21,8 +21,10 @@ dep_tristate 'Adaptec AHA1542 support' CONFIG_SCSI_AHA1542 $CONFIG_SCSI dep_tristate 'Adaptec AHA1740 support' CONFIG_SCSI_AHA1740 $CONFIG_SCSI dep_tristate 'Adaptec AIC7xxx support' CONFIG_SCSI_AIC7XXX $CONFIG_SCSI if [ "$CONFIG_SCSI_AIC7XXX" != "n" ]; then - bool ' Enable Tagged Command Queueing (TCQ) by default' CONFIG_AIC7XXX_TCQ_ON_BY_DEFAULT - int ' Maximum number of TCQ commands per device' CONFIG_AIC7XXX_CMDS_PER_DEVICE 8 + bool ' Override driver defaults for commands per LUN' CONFIG_OVERRIDE_CMDS N + if [ "$CONFIG_OVERRIDE_CMDS" != "n" ]; then + int ' Maximum number of commands per LUN' CONFIG_AIC7XXX_CMDS_PER_LUN 24 + fi bool ' Collect statistics to report in /proc' CONFIG_AIC7XXX_PROC_STATS N int ' Delay in seconds after SCSI bus reset' CONFIG_AIC7XXX_RESET_DELAY 5 fi @@ -52,9 +54,7 @@ if [ "$CONFIG_SCSI_GENERIC_NCR5380" != "n" ]; then Memory CONFIG_SCSI_G_NCR5380_MEM" Port fi dep_tristate 'Initio 91XX support' CONFIG_SCSI_INITIO $CONFIG_SCSI -dep_tristate 'Initio INI-A100U2W support' CONFIG_SCSI_INIA100 $CONFIG_SCSI dep_tristate 'NCR53c406a SCSI support' CONFIG_SCSI_NCR53C406A $CONFIG_SCSI -dep_tristate 'symbios 53c416 SCSI support' CONFIG_SCSI_SYM53C416 $CONFIG_SCSI if [ "$CONFIG_PCI" = "y" ]; then dep_tristate 'NCR53c7,8xx SCSI support' CONFIG_SCSI_NCR53C7xx $CONFIG_SCSI if [ "$CONFIG_SCSI_NCR53C7xx" != "n" ]; then @@ -66,12 +66,12 @@ fi if [ "$CONFIG_PCI" = "y" -a "$CONFIG_SCSI_NCR53C7xx" != "y" ]; then dep_tristate 'NCR53C8XX SCSI support' CONFIG_SCSI_NCR53C8XX $CONFIG_SCSI if [ "$CONFIG_SCSI_NCR53C8XX" != "n" ]; then - int ' default tagged command queue depth' CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS 8 - int ' maximum number of queued commands' CONFIG_SCSI_NCR53C8XX_MAX_TAGS 32 - int ' synchronous transfers frequency in MHz' CONFIG_SCSI_NCR53C8XX_SYNC 20 - bool ' enable profiling' CONFIG_SCSI_NCR53C8XX_PROFILE + bool ' detect and read serial NVRAMs' CONFIG_SCSI_NCR53C8XX_NVRAM_DETECT + bool ' enable tagged command queueing' CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE bool ' use normal IO' CONFIG_SCSI_NCR53C8XX_IOMAPPED - if [ "$CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS" = "0" ]; then + int ' maximum number of queued commands' CONFIG_SCSI_NCR53C8XX_MAX_TAGS 4 + int ' synchronous transfers frequency in MHz' CONFIG_SCSI_NCR53C8XX_SYNC 5 + if [ "$CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE" != "y" ]; then bool ' not allow targets to disconnect' CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT fi if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then @@ -84,9 +84,6 @@ if [ "$CONFIG_SCSI_PPA" != "n" ]; then bool ' Buggy EPP chipset support' CONFIG_SCSI_PPA_HAVE_PEDANTIC fi dep_tristate 'PAS16 SCSI support' CONFIG_SCSI_PAS16 $CONFIG_SCSI -dep_tristate 'PCI-2000 support' CONFIG_SCSI_PCI2000 $CONFIG_SCSI -dep_tristate 'PCI2220I support' CONFIG_SCSI_PCI2220I $CONFIG_SCSI -dep_tristate 'PSI240I support' CONFIG_SCSI_PSI240I $CONFIG_SCSI dep_tristate 'Qlogic FAS SCSI support' CONFIG_SCSI_QLOGIC_FAS $CONFIG_SCSI if [ "$CONFIG_PCI" = "y" ]; then dep_tristate 'Qlogic ISP SCSI support' CONFIG_SCSI_QLOGIC_ISP $CONFIG_SCSI @@ -99,7 +96,6 @@ if [ "$CONFIG_PCI" = "y" ]; then fi fi dep_tristate 'Trantor T128/T128F/T228 SCSI support' CONFIG_SCSI_T128 $CONFIG_SCSI -dep_tristate 'Tripace TC-2550x SCSI support' CONFIG_SCSI_TC2550 $CONFIG_SCSI dep_tristate 'UltraStor 14F/34F support' CONFIG_SCSI_U14_34F $CONFIG_SCSI if [ "$CONFIG_SCSI_U14_34F" != "n" ]; then bool ' enable elevator sorting' CONFIG_SCSI_U14_34F_LINKED_COMMANDS diff --git a/drivers/block/DAC960.c b/drivers/scsi/DAC960.c similarity index 99% rename from drivers/block/DAC960.c rename to drivers/scsi/DAC960.c index 28b0014596fc..1dcf660e4680 100644 --- a/drivers/block/DAC960.c +++ b/drivers/scsi/DAC960.c @@ -38,7 +38,6 @@ #include #include #include -#include #include "DAC960.h" diff --git a/drivers/block/DAC960.h b/drivers/scsi/DAC960.h similarity index 100% rename from drivers/block/DAC960.h rename to drivers/scsi/DAC960.h diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index f2ae232e6aff..bc397dc42bce 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -153,7 +153,6 @@ else endif endif - ifeq ($(CONFIG_SCSI_INITIO),y) L_OBJS += initio.o else @@ -380,22 +379,6 @@ else endif endif -ifeq ($(CONFIG_SCSI_SYM53C416),y) -L_OBJS += sym53c416.o -else - ifeq ($(CONFIG_SCSI_SYM53C416),m) - M_OBJS += sym53c416.o - endif -endif - -ifeq ($(CONFIG_SCSI_TC2550),y) -L_OBJS += tripace.o -else - ifeq ($(CONFIG_SCSI_TC2550),m) - M_OBJS += tripace.o - endif -endif - ifeq ($(CONFIG_SCSI_MEGARAID),y) L_OBJS += megaraid.o else @@ -404,38 +387,6 @@ else endif endif -ifeq ($(CONFIG_SCSI_INIA100),y) -L_OBJS += a100u2w.o -else - ifeq ($(CONFIG_SCSI_INIA100),m) - M_OBJS += a100u2w.o - endif -endif - -ifeq ($(CONFIG_SCSI_PCI2000),y) -L_OBJS += pci2000.o -else - ifeq ($(CONFIG_SCSI_PCI2000),m) - M_OBJS += pci2000.o - endif -endif - -ifeq ($(CONFIG_SCSI_PCI2220I),y) -L_OBJS += pci2220i.o -else - ifeq ($(CONFIG_SCSI_PCI2220I),m) - M_OBJS += pci2220i.o - endif -endif - -ifeq ($(CONFIG_SCSI_PSI240I),y) -L_OBJS += psi240i.o -else - ifeq ($(CONFIG_SCSI_PSI240I),m) - M_OBJS += psi240i.o - endif -endif - ifeq ($(CONFIG_BLK_DEV_IDESCSI),y) L_OBJS += ide-scsi.o endif @@ -467,15 +418,15 @@ tmscsim.o : tmscsim.c g_NCR5380.o: g_NCR5380.c $(CC) $(CFLAGS) -DGENERIC_NCR5380_OVERRIDE="{{(NCR5380_map_type)0x350,5,0, BOARD_NCR53C400}};" -c g_NCR5380.c -initio.o: ini9100u.o i91uscsi.o +initio.o: ini9100u.c i91uscsi.c + $(CC) $(CFLAGS) -c ini9100u.c -o ini9100u.o + $(CC) $(CFLAGS) -c i91uscsi.c -o i91uscsi.o $(LD) -r -o initio.o ini9100u.o i91uscsi.o + rm -f ini9100u.o i91uscsi.o megaraid.o: megaraid.c $(CC) $(CFLAGS) -c megaraid.c -a100u2w.o: inia100.o i60uscsi.o - $(LD) -r -o a100u2w.o inia100.o i60uscsi.o - scsi_mod.o: $(MX_OBJS) hosts.o scsi.o scsi_ioctl.o constants.o \ scsicam.o scsi_proc.o $(LD) $(LD_RFLAG) -r -o $@ $(MX_OBJS) hosts.o scsi.o scsi_ioctl.o constants.o scsicam.o scsi_proc.o diff --git a/drivers/scsi/README.aic7xxx b/drivers/scsi/README.aic7xxx index 0497bbb10f11..b350d9d5812f 100644 --- a/drivers/scsi/README.aic7xxx +++ b/drivers/scsi/README.aic7xxx @@ -17,10 +17,6 @@ linux-1.1.x and fairly stable since linux-1.2.x, and are also in FreeBSD AHA-274xT AHA-2842 AHA-2910B - AHA-2920C - AHA-2930 - AHA-2930U - AHA-2930U2 AHA-2940 AHA-2940W AHA-2940U @@ -41,10 +37,8 @@ linux-1.1.x and fairly stable since linux-1.2.x, and are also in FreeBSD AHA-3940U AHA-3940W AHA-3940UW - AHA-3940AUW AHA-3940U2W AHA-3950U2B - AHA-3950U2D AHA-3985 AHA-3985U AHA-3985W @@ -58,7 +52,6 @@ linux-1.1.x and fairly stable since linux-1.2.x, and are also in FreeBSD AIC-787x AIC-788x AIC-789x - AIC-3860 Bus Types ---------------------------- @@ -76,30 +69,8 @@ linux-1.1.x and fairly stable since linux-1.2.x, and are also in FreeBSD AHA-398x - PCI RAID controllers with three separate SCSI controllers on-board. - Not Supported Devices - ------------------------------ - Adaptec Cards - ---------------------------- - AHA-2920 (Only the cards that use the Future Domain chipset are not - supported, any 2920 cards based on Adaptec AIC chipsets, - such as the 2920C, are supported) - AAA-13x Raid Adapters - AAA-113x Raid Port Card - - Motherboard Chipsets - ---------------------------- - AIC-7810 - - Bus Types - ---------------------------- - R - Raid Port busses are not supported. - - The hardware RAID devices sold by Adaptec are *NOT* supported by this - driver (and will people please stop emailing me about them, they are - a totally separate beast from the bare SCSI controllers and this driver - can not be retrofitted in any sane manner to support the hardware RAID - features on those cards - Doug Ledford). - + NOTE: The AHA-2920 is NOT an AIC-7xxx based controller, and is not + handled by this driver. People ------------------------------ @@ -112,7 +83,7 @@ linux-1.1.x and fairly stable since linux-1.2.x, and are also in FreeBSD Jess Johnson jester@frenzy.com (AIC7xxx FAQ author) Doug Ledford dledford@redhat.com - (Current Linux aic7xxx-5.x.x Driver/Patch/FTP maintainer) + (Current Linux aic7xxx-5.x.x Driver/Patch/FTP/FAQ maintainer) Special thanks go to John Aycock (aycock@cpsc.ucalgary.ca), the original author of the driver. John has since retired from the project. Thanks @@ -328,13 +299,13 @@ linux-1.1.x and fairly stable since linux-1.2.x, and are also in FreeBSD binary->hex conversion then send an email to the aic7xxx mailing list and someone can help you out. - "aic7xxx=tag_info:{{8,8..},{8,8..},..}" - This option is used to disable - or enable Tagged Command Queueing (TCQ) on specific devices. As of - driver version 5.1.11, TCQ is now either on or off by default - according to the setting you choose during the make config process. - In order to en/disable TCQ for certian devices at boot time, a user - may use this boot param. The driver will then parse this message out - and en/disable the specific device entries that are present based upon + "aic7xxx=tag_info:{{8,8..},{8,8..},..}" - This option is used to enable + tagged queueing on specific devices. As of driver version 5.0.6, we + now globally enable tagged queueing by default, but we also disable + tagged queueing on all individual devices by default. In order to + enable tagged queueing for certian devices at boot time, a user may + use this boot param. The driver will then parse this message out + and enable the specific device entries that are present based upon the value given. The param line is parsed in the following manner: { - first instance indicates the start of this parameter values @@ -366,13 +337,18 @@ linux-1.1.x and fairly stable since linux-1.2.x, and are also in FreeBSD commas with no value specified will simply increment to the next id without changing anything for the missing values. - tag_info:{,,,{,,,255}} + tag_info:{{8,8},,{8,8}} + First adapter, scsi id 0 to 8, id 1 to 8, remainder stay at their + default. Second adapter stays entirely at default. Third + adapter, id 0 to 8, id 1 to 8, remainder at default (identical to + first adapter). + + tag_info:{,,,{,,,64}} First, second, and third adapters at default values. Fourth - adapter, id 3 is disabled. Notice that leading commas simply - increment what the first number effects, and there are no need - for trailing commas. When you close out an adapter, or the - entire entry, anything not explicitly set stays at the default - value. + adapter, id 3 to 64. Notice that leading commas simply increment + what the first number effects, and there are no need for trailing + commas. When you close out an adapter, or the entire entry, + anything not explicitly set stays at the default value. A final note on this option. The scanner I used for this isn't perfect or highly robust. If you mess the line up, the worst that @@ -424,10 +400,10 @@ linux-1.1.x and fairly stable since linux-1.2.x, and are also in FreeBSD see this documentation, you need to use one of the advanced configuration programs (menuconfig and xconfig). If you are using the "make menuconfig" method of configuring your kernel, then you would simply highlight the - option in question and hit the ? key. If you are using the "make xconfig" - method of configuring your kernel, then simply click on the help button - next to the option you have questions about. The help information from - the Configure.help file will then get automatically displayed. + option in question and hit the F1 key. If you are using the "make xconfig" + method of configuring your kernel, then simply click on the help button next + to the option you have questions about. The help information from the + Configure.help file will then get automatically displayed. /proc support ------------------------------ @@ -473,16 +449,10 @@ linux-1.1.x and fairly stable since linux-1.2.x, and are also in FreeBSD ftp://ekf2.vsb.cz/pub/linux/kernel/aic7xxx/ftp.teleport.com/ - European Linux mirror of Teleport site - Web sites - ------------------------------ - http://developer.redhat.com/aic7xxx/ - - Primary web site maintained by Doug Ledford. I haven't actually - put anything up yet....but I'm planning on it. This information - is put here as an add for the vapor page :) Dean W. Gehnert deang@teleport.com $Revision: 3.0 $ -Modified by Doug Ledford 1998-9 +Modified by Doug Ledford 1998 diff --git a/drivers/scsi/README.ncr53c8xx b/drivers/scsi/README.ncr53c8xx index f22184759d8e..28e152367a4b 100644 --- a/drivers/scsi/README.ncr53c8xx +++ b/drivers/scsi/README.ncr53c8xx @@ -4,7 +4,7 @@ Written by Gerard Roudier 21 Rue Carnot 95170 DEUIL LA BARRE - FRANCE -13 December 1998 +2 January 1998 =============================================================================== 1. Introduction @@ -21,8 +21,8 @@ Written by Gerard Roudier 8.4 Set order type for tagged command 8.5 Set debug mode 8.6 Clear profile counters - 8.7 Set flag (no_disc) - 8.8 Set verbose level + 8.7 Set flag (no_sync) + 8.8 Debug error recovery 9. Configuration parameters 10. Boot setup commands 10.1 Syntax @@ -33,7 +33,9 @@ Written by Gerard Roudier 10.6 SCSI BUS checking boot option 11. Some constants and flags of the ncr53c8xx.h header file 12. Installation -13. Architecture dependant features + 12.1 Provided files + 12.2 Installation procedure +13. Control commands under linux-1.2.13 14. Known problems 14.1 Tagged commands with Iomega Jaz device 14.2 Device names change when another controller is added @@ -91,7 +93,7 @@ This driver has been tested OK with linux/i386, Linux/Alpha and Linux/PPC. Latest driver version and patches are available at: - ftp://ftp.tux.org/pub/people/gerard-roudier + ftp://linux.wauug.org/pub/roudier I am not a native speaker of English and there are probably lots of mistakes in this README file. Any help will be welcome. @@ -110,32 +112,19 @@ The following features are supported for all chips: "Wide negotiation" is supported for chips that allow it. The following table shows some characteristics of NCR 8xx family chips: - On board Supported by -Chip SDMS BIOS Wide SCSI std. Max. sync the driver ----- --------- ---- --------- ---------- ------------ -810 N N FAST10 10 MB/s Y -810A N N FAST10 10 MB/s Y(2) -815 Y N FAST10 10 MB/s Y -825 Y Y FAST10 20 MB/s Y -825A Y Y FAST10 20 MB/s Y(2) -860 N N FAST20 20 MB/s Y(2) -875 Y Y FAST20 40 MB/s Y(2) -876 Y Y FAST20 40 MB/s Y(2) -895 Y Y FAST40 80 MB/s Y(2) -896 Y Y FAST40 80 MB/s Y(1) - -(1) The ncr53c8xx driver does not support the following features of - the 896: - - Hardware phase mismatch. - - 8k on-chip RAM. - If you have a 896 chip, you may want to use the enhanced sym53c8xx - driver that supports all the features of the 896. - The sym53c8xx driver is available at the following URL: - - ftp://ftp.tux.org/pub/roudier/896/ - -(2) Chip also supported by the sym53c8xx enhanced driver. + On board Supported by Tested with +Chip SDMS BIOS Wide Ultra SCSI the driver the driver +---- --------- ---- ---------- ------------ ----------- +810 N N N Y Y +810A N N N Y Y +815 Y N N Y Y +825 Y Y N Y Y +825A Y Y N Y Y +860 N N Y Y Y +875 Y Y Y Y Y +895 Y Y Y(1) Y not yet +(1) The 895 chip is supported 'on paper'. 3. Summary of other supported features. @@ -163,88 +152,49 @@ driver to use normal I/O in all cases. 5. Tagged command queueing -Queuing more than 1 command at a time to a device allows it to perform -optimizations based on actual head positions and its mechanical -characteristics. This feature may also reduce average command latency. -In order to really gain advantage of this feature, devices must have -a reasonnable cache size (No miracle is to be expected for a low-end -hard disk with 128 KB or less). -Some kown SCSI devices do not properly support tagged command queuing. -Generally, firmware revisions that fix this kind of problems are available -at respective vendor web/ftp sites. -All I can say is that the hard disks I use on my machines behave well with -this driver with tagged command queuing enabled: - -- IBM S12 0662 -- Conner 1080S -- Quantum Atlas I -- Quantum Atlas II - -If your controller has NVRAM, you can configure this feature per target -from the user setup tool. The Tekram Setup program allows to tune the -maximum number of queued commands up to 32. The Symbios Setup only allows -to enable or disable this feature. +Some SCSI devices do not properly support tagged command queuing. A +safe configuration is to not enable tagged command queuing support at +boot-up, and to enable support of it with the control command +"settags" described further in this text. -The maximum number of simultaneous tagged commands queued to a device -is currently set to 8 by default. This value is suitable for most SCSI -disks. With large SCSI disks (>= 2GB, cache >= 512KB, average seek time -<= 10 ms), using a larger value may give better performances. -The driver supports up to 64 commands per device, but using more than -32 is generally not worth it, unless you are using a very large disk -or disk array. - -If your controller does not have NVRAM or if it is managed by the SDMS -BIOS/SETUP, you can configure tagged queueing feature and device queue -depths from the boot command-line. For example: - - ncr53c8xx=tags:4/t2t3q15-t4q7/t1u0q32 - -will set tagged commands queue depths as follow: +Once you are sure that all your devices properly support tagged +command queuing, you can enable it by default with the +CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE configuration option. -- target 2 all luns on controller 0 --> 15 -- target 3 all luns on controller 0 --> 15 -- target 4 all luns on controller 0 --> 7 -- target 1 lun 0 on controller 1 --> 32 -- all other target/lun --> 4 +The maximum number of simultaneous tagged commands queued to a device +is currently set to 4 by default. It is defined in the file +ncr53c8xx.h by SCSI_NCR_MAX_TAGS. This value is suitable for most SCSI +disks. With large SCSI disks (> 2GB, cache > 512KB average seek time +< 10 ms), 8 tagged commands may give better performance. In some special conditions, some SCSI disk firmwares may return a QUEUE FULL status for a SCSI command. This behaviour is managed by the -driver using the following heuristic: - -- Each time a QUEUE FULL status is returned, tagged queue depth is reduced - to the actual number of disconnected commands. +driver by the following heuristic: -- Every 1000 successfully completed SCSI commands, if allowed by the - current limit, the maximum number of queueable commands is incremented. +- Each time a QUEUE FULL status is returned, tagged command queueing is + temporarily disabled. -Since QUEUE FULL status reception and handling is resource wasting, the -driver notifies by default this problem to user by indicating the actual -number of commands used and their status, as well as its decision on the -device queue depth change. -The heuristic used by the driver in handling QUEUE FULL ensures that the -impact on performances is not too bad. You can get rid of the messages by -setting verbose level to zero, as follow: +- Every 100 successfully completed SCSI commands, if allowed by the + current limit, the maximum number of queueable commands is + incremented and tagged command queueing is reenabled. -1st method: boot your system using 'ncr53c8xx=verb:0' option. -2nd method: apply "setverbose 0" control command to the proc fs entry - corresponding to your controller after boot-up. 6. Parity checking The driver supports SCSI parity checking and PCI bus master parity checking. These features must be enabled in order to ensure safe data transfers. However, some flawed devices or mother boards will have -problems with parity. You can disable either PCI parity or SCSI parity -checking by entering appropriate options from the boot command line. -(See 10: Boot setup commands). +problems with parity. You can disable parity by choosing first +"CONFIG_EXPERIMENTAL". Then, "make config" will allow to set the +following configuration options: + + CONFIG_SCSI_NCR53C8XX_DISABLE_PARITY_CHECK (disable SCSI parity checking) + CONFIG_SCSI_NCR53C8XX_DISABLE_MPARITY_CHECK (disable master parity checking) + 7. Profiling information Profiling information is available through the proc SCSI file system. -Since gathering profiling information may impact performances, this -feature is disabled by default and requires a compilation configuration -option to be set to Y. - The device associated with a host has the following pathname: /proc/scsi/ncr53c8xx/N (N=0,1,2 ....) @@ -396,7 +346,7 @@ Available commands: target: target number tags: number of concurrent tagged commands - must not be greater than SCSI_NCR_MAX_TAGS (default: 8) + must not be greater than SCSI_NCR_MAX_TAGS (default: 4) 8.4 Set order type for tagged command @@ -437,7 +387,7 @@ Available commands: The "clearprof" command allows you to clear these counters at any time. -8.7 Set flag (no_disc) +8.7 Set flag (no_sync) setflag @@ -445,21 +395,35 @@ Available commands: For the moment, only one flag is available: - no_disc: not allow target to disconnect. + no_sync: not allow target to disconnect. Do not specify any flag in order to reset the flag. For example: - setflag 4 - will reset no_disc flag for target 4, so will allow it disconnections. + will reset no_sync flag for target 4, so will allow it disconnections. - setflag all will allow disconnection for all devices on the SCSI bus. -8.8 Set verbose level +8.8 Debug error recovery - setverbose #level + debug_error_recovery - The driver default verbose level is 1. This command allows to change - th driver verbose level after boot-up. + Available error type to trigger: + sge: SCSI gross error + abort: abort command from the middle-level driver + reset: reset command from the middle-level driver + parity: scsi parity detected in DATA IN phase + none: restore driver normal behaviour + + The code corresponding to this feature is normally not compiled. + Its purpose is driver testing only. In order to compile the code + that allows to trigger error recovery you must define at compile time + SCSI_NCR_DEBUG_ERROR_RECOVERY. + If you have compiled the driver with this option, nothing will happen + as long as you donnot use the control command 'debug_error_recovery' + with sge, abort, reset or parity as argument. + If you select an error type, it will be triggered by the driver every + 30 seconds. 9. Configuration parameters @@ -469,11 +433,6 @@ if only one has a flaw for some SCSI feature, you can disable the support by the driver of this feature at linux start-up and enable this feature after boot-up only for devices that support it safely. -CONFIG_SCSI_NCR53C8XX_PROFILE_SUPPORT (default answer: n) - This option must be set for profiling information to be gathered - and printed out through the proc file system. This features may - impact performances. - CONFIG_SCSI_NCR53C8XX_IOMAPPED (default answer: n) Answer "y" if you suspect your mother board to not allow memory mapped I/O. May slow down performance a little. This option is required by @@ -481,12 +440,13 @@ CONFIG_SCSI_NCR53C8XX_IOMAPPED (default answer: n) suffers no performance loss with this option since all IO is memory mapped anyway. -CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS (default answer: 8) - Default tagged command queue depth. +CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE (default answer: n) + Answer "y" if you are sure that all your SCSI devices that are able to + accept tagged commands will proceed safely. -CONFIG_SCSI_NCR53C8XX_MAX_TAGS (default answer: 8) +CONFIG_SCSI_NCR53C8XX_MAX_TAGS (default answer: 4) This option allows you to specify the maximum number of tagged commands - that can be queued to a device. The maximum supported value is 64. + that can be queued to a device. CONFIG_SCSI_NCR53C8XX_SYNC (default answer: 5) This option allows you to specify the frequency in MHz the driver @@ -575,8 +535,8 @@ Scsi disconnections disc:n disabled Special features - Only apply to 810A, 825A, 860, 875 and 895 controllers. - Have no effect with other ones. + Only apply to 810A, 825A, 860 and 875 controllers. + Have no effect with normal 810 and 825. specf:y (or 1) enabled specf:n (or 0) disabled specf:3 enabled except Memory Write And Invalidate @@ -585,25 +545,17 @@ Special features Invalidate. Ultra SCSI support - Only apply to 860, 875 and 895 controllers. + Only apply to 860 and 875 controllers. Have no effect with other ones. - ultra:2 Ultra2 enabled - ultra:1 Ultra enabled + ultra:y enabled ultra:n disabled -Default number of tagged commands +Number of tagged commands tags:0 (or tags:1 ) tagged command queuing disabled tags:#tags (#tags > 1) tagged command queuing enabled #tags will be truncated to the max queued commands configuration parameter. - This option also allows to specify a command queue depth for each device - that support tagged command queueing. - Example: - ncr53c8xx=tags:10/t2t3q16-t5q24/t1u2q32 - will set devices queue depth as follow: - - controller #0 target #2 and target #3 -> 16 commands, - - controller #0 target #5 -> 24 commands, - - controller #1 target #1 logical unit #2 -> 32 commands, - - all other logical units (all targets, all controllers) -> 10 commands. + If the driver is configured with a maximum of 4 queued commands, tags:4 is + the right argument to specify. Default synchronous period factor sync:255 disabled (asynchronous transfer mode) @@ -740,7 +692,7 @@ Boot fail safe If the driver has been configured with default options, the equivalent boot setup is: - ncr53c8xx=mpar:y,spar:y,disc:y,specf:3,fsn:n,ultra:2,fsn:n,revprob:n,verb:1\ + ncr53c8xx=mpar:y,spar:y,disc:y,specf:3,fsn:n,ultra:y,fsn:n,revprob:n,verb:1\ tags:0,sync:50,debug:0,burst:7,led:0,wide:1,settle:2,diff:0,irqm:0 For an installation diskette or a safe but not fast system, @@ -753,8 +705,8 @@ boot setup can be: My personnal system works flawlessly with the following equivalent setup: - ncr53c8xx=mpar:y,spar:y,disc:y,specf:1,fsn:n,ultra:2,fsn:n,revprob:n,verb:1\ - tags:32,sync:12,debug:0,burst:7,led:1,wide:1,settle:2,diff:0,irqm:0 + ncr53c8xx=mpar:y,spar:y,disc:y,specf:1,fsn:n,ultra:y,fsn:n,revprob:n,verb:1\ + tags:8,sync:12,debug:0,burst:7,led:1,wide:1,settle:2,diff:0,irqm:0 The driver prints its actual setup when verbosity level is 2. You can try "ncr53c8xx=verb:2" to get the "static" setup of the driver, or add "verb:2" @@ -771,8 +723,8 @@ Available option bits: Use 'pcifix:3' in order to allow the driver to fix both PCI features. -These options only apply to new SYMBIOS chips 810A, 825A, 860, 875 -and 895 and are only supported for Pentium and 486 class processors. +These options only apply to new SYMBIOS chips 810A, 825A, 860 and 875 +and are only supported for Pentium and 486 class processors. Recent SYMBIOS 53C8XX scsi processors are able to use PCI read multiple and PCI write and invalidate commands. These features require the cache line size register to be properly set in the PCI configuration @@ -785,7 +737,7 @@ invalidate bit in the PCI configuration space of 53C8XX chips. Optimized PCI accesses may be broken for some PCI/memory controllers or make problems with some PCI boards. -This fix-up worked flawlessly on my previous system. +This fix-up works flawlessly on my system. (MB Triton HX / 53C875 / 53C810A) I use these options at my own risks as you will do if you decide to use them too. @@ -860,12 +812,17 @@ Some of these are defined from the configuration parameters. To change other "defines", you must edit the header file. Do that only if you know what you are doing. +SCSI_NCR_SETUP_ULTRA_SUPPORT (default: defined) + Ultra SCSI support. + Can be changed by the following boot setup command: + ncr53c8xx=ultra:n + SCSI_NCR_SETUP_SPECIAL_FEATURES (default: defined) If defined, the driver will enable some special features according to chip and revision id. - For 810A, 860, 825A, 875 and 895 scsi chips, this option enables - support of features that reduce load of PCI bus and memory accesses - during scsi transfer processing: burst op-code fetch, read multiple, + For 810A, 860, 825A and 875 scsi chips, this option enables support + of features that reduce load of PCI bus and memory accesses during + scsi transfer processing: burst op-code fetch, read multiple, read line, prefetch, cache line, write and invalidate, burst 128 (875 only), large dma fifo (875 only), offset 16 (875 only). Can be changed by the following boot setup command: @@ -877,7 +834,7 @@ SCSI_NCR_IOMAPPED (default: not defined) SCSI_NCR_SHARE_IRQ (default: defined) If defined, request shared IRQ. -SCSI_NCR_MAX_TAGS (default: 8) +SCSI_NCR_MAX_TAGS (default: 4) Maximum number of simultaneous tagged commands to a device. Can be changed by "settags " @@ -886,7 +843,7 @@ SCSI_NCR_SETUP_DEFAULT_SYNC (default: 50) negotiation. 0 means asynchronous. Can be changed by "setsync " -SCSI_NCR_SETUP_DEFAULT_TAGS (default: 8) +SCSI_NCR_SETUP_DEFAULT_TAGS (default: 4) Default number of simultaneous tagged commands to a device. < 1 means tagged command queuing disabled at start-up. @@ -907,7 +864,7 @@ SCSI_NCR_SETUP_MASTER_PARITY (default: defined) SCSI_NCR_SETUP_MASTER_PARITY (default: defined) If defined, SCSI parity checking is enabled. -SCSI_NCR_PROFILE_SUPPORT (default: not defined) +SCSI_NCR_PROFILE (default: defined) If defined, profiling information is gathered. SCSI_NCR_MAX_SCATTER (default: 128) @@ -942,28 +899,67 @@ SCSI_NCR_MAX_LUN (default: 8) 12. Installation -This driver is part of the linux kernel distribution. -Driver files are located in the sub-directory "drivers/scsi" of the -kernel source tree. +12.1 Provided files -Driver files: +Driver and common files: README.ncr53c8xx : this file ChangeLog.ncr53c8xx : change log + ConfigHelp.ncr53c8xx : Part of Configure.help about the driver ncr53c8xx.h : definitions ncr53c8xx.c : the driver code + scsitag.c : command tool to enable tagged queue + conf.modules : sample of /etc/conf.modules + + Install.ncr53c8xx : installation script + + Patch-1.2.13.ncr53c8xx : patch for linux-1.2.13 + Patch-2.0.29.ncr53c8xx : patch for linux-2.0.29 + +You must untar the distribution with the following command: + + tar zxvf ncrBsd2Linux-2.2b-src.tar.gz + +The sub-directory ncr53c8xx-2.2b will be created. Change to this directory. + + +12.2 Installation procedure + +This install script has been tested with linux-1.2.13 and 2.0.29. + +This procedure copies the new driver files to the kernel tree and +applies a patch to some files of the kernel tree. + + If your linux directory is at the standard location + "/usr/src/linux", just enter: + Install.ncr53c8xx + + Else enter: + Install.ncr53c8xx + + Make the kernel: + Change to linux source directory + Configure with NCR53C7,8XX support = N + Configure with NCR53C8XX support = Y (or m) + Make dependancies + Make the kernel (use make zdisk first) + Make and install modules if you have configured with 'm' + + +13. Control commands under linux-1.2.13 -New driver versions are made available separately in order to allow testing -changes and new features prior to including them into the linux kernel -distribution. The following URL provides informations on latest avalaible -patches: +Profiling data and control commands using the proc SCSI file system +are not available for linux-1.2.13. The only control command +available is "scsitag" which allows you to enable tagged command +queuing support after linux boot-up. - ftp://ftp.tux.org/pub/people/gerard-roudier/README +Tagged command queueing is disabled by default at system startup. +You can enable tagged queue per device with the following command: -13. Architecture dependant features. + scsitag device_name (ex: scsitag /dev/sda) - +Use "cc -o scsitag scsitag.c" to create the "scsitag" executable. 14. Known problems @@ -1080,10 +1076,10 @@ Try to enable one feature at a time with control commands. For example: Will enable fast synchronous data transfer negotiation for all targets. - echo "setflag 3" >/proc/scsi/ncr53c8xx/0 - Will reset flags (no_disc) for target 3, and so will allow it to disconnect + Will reset flags (no_sync) for target 3, and so will allow it to disconnect the SCSI Bus. -- echo "settags 3 8" >/proc/scsi/ncr53c8xx/0 +- echo "settags 3 4" >/proc/scsi/ncr53c8xx/0 Will enable tagged command queuing for target 3 if that device supports it. Once you have found the device and the feature that cause problems, just @@ -1104,14 +1100,12 @@ Periods are in nano-seconds and speeds are in Mega-transfers per second. 1 Mega-transfers/second means 1 MB/s with 8 bits SCSI and 2 MB/s with Wide16 SCSI. -16.1 Synchronous timings for 53C895, 53C875 and 53C860 SCSI controllers +16.1 Synchronous timings for 53C875 and 53C860 Ultra-SCSI controllers ---------------------------------------------- Negotiated NCR settings Factor Period Speed Period Speed ------ ------ ------ ------ ------ - 10 25 40.000 25 40.000 (53C895 only) - 11 30.2 33.112 31.25 32.000 (53C895 only) 12 50 20.000 50 20.000 13 52 19.230 62 16.000 14 56 17.857 62 16.000 diff --git a/drivers/scsi/README.tmscsim b/drivers/scsi/README.tmscsim index 99ae1e5a71ff..9aab761af7e3 100644 --- a/drivers/scsi/README.tmscsim +++ b/drivers/scsi/README.tmscsim @@ -45,8 +45,7 @@ The numbering scheme isn't consistent. The first versions went from 1.00 to 1.12, then 1.20a to 1.20t. Finally I decided to use the ncr53c8xx scheme. So the next revisions will be 2.0a to 2.0X (stable), 2.1a to 2.1X (experimental), 2.2a to 2.2X (stable, again) etc. (X = anything between a and z.) If I send -fixes to people for testing, I create intermediate versions with a digit -appended, e.g. 2.0c3. +fixes to people for testing, those will have a digit appended, e.g. 2.0a1. 2. Installation @@ -57,36 +56,32 @@ driver. Of course you have to choose to compile SCSI support and DC390(T) support into your kernel or as module when configuring your kernel for compiling. - If you got an old kernel (pre 2.1.127, pre 2.0.37p1) with an old version of - this driver: Get dc390-21125-20b.diff.gz or dc390-2036p21-20b1.diff.gz from - my website and apply the patch. +If you got an older kernel with an old version of this driver included, you +should copy the files (dc390.h, tmscsim.h, tmscsim.c, scsiiom.c and +README.tmscsim) from this directory to linux/drivers/scsi. You have to +recompile your kernel/module of course. - If you want to do it manually, you should copy the files (dc390.h, - tmscsim.h, tmscsim.c, scsiiom.c and README.tmscsim) from this directory to - linux/drivers/scsi. You have to recompile your kernel/module of course. +You should apply the three patches included in dc390-20-kernel.diff +(Applying them: cd /usr/src; patch -p0 <~/dc390-20-kernel.diff) +The patches are against 2.1.103, so you might have to manually resolve +rejections when applying to another kernel version. - You should apply the three patches included in dc390-120-kernel.diff - (Applying them: cd /usr/src; patch -p0 <~/dc390-120-kernel.diff) - The patches are against 2.1.125, so you might have to manually resolve - rejections when applying to another kernel version. - - The patches will update the kernel startup code to allow boot parameters to - be passed to the driver, update the Documentation and finally offer you the - possibility to omit the non-DC390 parts of the driver. - (By selecting "Omit support for non DC390" you basically disable the - emulation of a DC390 EEPROM for non DC390 adapters. This saves a few bytes - of memory.) +The patches will update the kernel startup code to allow boot parameters to +be passed to the driver, update the Documentation and finally offer you the +possibility to omit the non-DC390 parts of the driver. +(By selecting "Omit support for non DC390" you basically disable the +emulation of a DC390 EEPROM for non DC390 adapters. This saves a few bytes +of memory.) If you got a very old kernel without the tmscsim driver (pre 2.0.31) I recommend upgrading your kernel. However, if you don't want to, please contact me to get the appropriate patches. - -Upgrading a SCSI driver is always a delicate thing to do. The 2.0 driver has +Testing a SCSI driver is always a delicate thing to do. The 2.0 driver has proven stable on many systems, but it's still a good idea to take some precautions. In an ideal world you would have a full backup of your disks. The world isn't ideal and most people don't have full backups (me neither). -So take at least the following measures: +So take at least the following two measures: * make your kernel remount the FS read-only on detecting an error: tune2fs -e remount-ro /dev/sd?? * have copies of your SCSI disk's partition tables on some safe location: @@ -109,19 +104,18 @@ SA_SHIRQ | SA_INTERRUPT. 3.Features ---------- - SCSI - * Tagged command queueing + * Tagged queueing * Sync speed up to 10 MHz * Disconnection * Multiple LUNs - General / Linux interface - * Support for up to 4 AM53C974 adapters. + * Support for up to 4 adapters. * DC390 EEPROM usage or boot/module params * Information via cat /proc/scsi/tmscsim/? * Dynamically configurable by writing to /proc/scsi/tmscsim/? * Dynamic allocation of resources - * SMP support: Locking on io_request lock (Linux 2.1/2.2) or adapter - specific locks (Linux 2.3) + * SMP support: Adapter specific locks (Linux 2.1.x) * Uniform source code for Linux-2.x.y * Support for dyn. addition/removal of devices via add/remove-single-device (Try: echo "scsi add-single-device H C I L" >/proc/scsi/scsi @@ -343,7 +337,9 @@ to further improve its usability: Further investigation on these problems: -* Driver hangs with sync readcdda (xcdroast) (most probably VIA PCI error) +* TagQ and Disconnection (Resel: SRB Tag Seleection) +* Problems with IRQ sharing (IO-APIC on SMP Systems) (??) +* Driver crashes with readcdda (xcdroast) Known problems: @@ -367,9 +363,12 @@ Known problems: Richard Waltham or Doug Ledford , if you want to help further debugging it. * 2.0.35: CD changers (e.g. NAKAMICHI MBR-7.{0,2}) have problems because - the mid-level code doesn't handle BLIST_SINGLELUN correctly. There used - to be a patch included here to fix this, but I was told that it is fixed - in 2.0.36. + the mid-level code doesn't handle BLIST_SINGLELUN correctly. Apply + the patch 2035-scsi-singlelun.diff. Thanks to Chiaki Ishikawa. + I was told that this fix will be in 2.0.36, so you don't need it for + 2.0.36. +[The patch file is contained in the dc390-XXX.tar.gz files which can be found +on the ftp server. See below.] 7. Bug reports, debugging and updates @@ -381,7 +380,7 @@ If you find something, which you believe to be a bug, please report it to me. Please append the output of /proc/scsi/scsi, /proc/scsi/tmscsim/? and maybe the DC390 log messages to the report. -Bug reports should be send to me (Kurt Garloff ) as well +Bug reports should be send to me (Kurt Garloff ) as well as to the linux-scsi list (), as sometimes bugs are caused by the SCSI mid-level code. @@ -393,10 +392,7 @@ AM53C974, the logging might produce log output again, and you might end having your box spending most of its time doing the logging. The latest version of the driver can be found at: - http://www.garloff.de/kurt/linux/dc390/ -and - ftp://student.physik.uni-dortmund.de/pub/linux/kernel/dc390/ -(The latter might shut down some day.) +ftp://student.physik.uni-dortmund.de/pub/linux/kernel/dc390/ 8. Acknowledgements @@ -413,6 +409,6 @@ doing this during early revisions). ------------------------------------------------------------------------- -Written by Kurt Garloff 1998/06/11 -Last updated 1998/12/25, driver revision 2.0d -$Id: README.tmscsim,v 2.9 1998/12/25 18:04:20 garloff Exp $ +Written by Kurt Garloff 1998/06/11 +Last updated 1998/10/15, driver revision 2.0b +$Id: README.tmscsim,v 2.5 1998/11/05 10:38:38 garloff Exp $ diff --git a/drivers/scsi/TRIPACE.REL b/drivers/scsi/TRIPACE.REL deleted file mode 100644 index 4b6211c2bf3b..000000000000 --- a/drivers/scsi/TRIPACE.REL +++ /dev/null @@ -1,21 +0,0 @@ -Dated December 21 Chennai,India:- ------ -------- ----------------- - - -Release Notes of 1.00.000 (904) version:- - -1.0 All machine dependent timing loops have been removed and - replaced with the udelay function. - -2.0 Search function has been made static - -3.0 Search function ,in case of failure was not reenabling interrupts - This has been corrected. - -4.0 The save_flags,cli & restore_flags in ISR has been removed. - -5.0 Wait_risc_halt has a sanity check and times out incase hw failure. - -6.0 Source code indentation with "indent -kr -i8 -bl -bli0 tripace.c" - - diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index f76530c09c84..e130317512a6 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -120,8 +120,8 @@ static int aha1542_restart(struct Scsi_Host * shost); #define aha1542_intr_reset(base) outb(IRST, CONTROL(base)) #define WAIT(port, mask, allof, noneof) \ - { register int WAITbits; \ - register int WAITtimeout = WAITnexttimeout; \ + { register WAITbits; \ + register WAITtimeout = WAITnexttimeout; \ while (1) { \ WAITbits = inb(port) & (mask); \ if ((WAITbits & (allof)) == (allof) && ((WAITbits & (noneof)) == 0)) \ @@ -133,8 +133,8 @@ static int aha1542_restart(struct Scsi_Host * shost); /* Similar to WAIT, except we use the udelay call to regulate the amount of time we wait. */ #define WAITd(port, mask, allof, noneof, timeout) \ - { register int WAITbits; \ - register int WAITtimeout = timeout; \ + { register WAITbits; \ + register WAITtimeout = timeout; \ while (1) { \ WAITbits = inb(port) & (mask); \ if ((WAITbits & (allof)) == (allof) && ((WAITbits & (noneof)) == 0)) \ diff --git a/drivers/scsi/aic7xxx.c b/drivers/scsi/aic7xxx.c index 1c1bc810ce36..201a1a919658 100644 --- a/drivers/scsi/aic7xxx.c +++ b/drivers/scsi/aic7xxx.c @@ -100,7 +100,7 @@ * * Further driver modifications made by Doug Ledford * - * Copyright (c) 1997-1999 Doug Ledford + * Copyright (c) 1997-1998 Doug Ledford * * These changes are released under the same licensing terms as the FreeBSD * driver written by Justin Gibbs. Please see his Copyright notice above @@ -336,7 +336,6 @@ #include "aic7xxx/sequencer.h" #include "aic7xxx/scsi_message.h" #include "aic7xxx_reg.h" -#include #include #include /* for kmalloc() */ @@ -355,7 +354,7 @@ struct proc_dir_entry proc_scsi_aic7xxx = { 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; -#define AIC7XXX_C_VERSION "5.1.13" +#define AIC7XXX_C_VERSION "5.1.5" #define NUMBER(arr) (sizeof(arr) / sizeof(arr[0])) #define MIN(a,b) (((a) < (b)) ? (a) : (b)) @@ -448,10 +447,8 @@ struct proc_dir_entry proc_scsi_aic7xxx = { * You can try raising me if tagged queueing is enabled, or lowering * me if you only have 4 SCBs. */ -#ifdef CONFIG_AIC7XXX_CMDS_PER_DEVICE -#define AIC7XXX_CMDS_PER_DEVICE CONFIG_AIC7XXX_CMDS_PER_DEVICE -#else -#define AIC7XXX_CMDS_PER_DEVICE 8 +#ifdef CONFIG_AIC7XXX_CMDS_PER_LUN +#define AIC7XXX_CMDS_PER_LUN CONFIG_AIC7XXX_CMDS_PER_LUN #endif /* Set this to the delay in seconds after SCSI bus reset. */ @@ -496,7 +493,7 @@ struct proc_dir_entry proc_scsi_aic7xxx = { * * *** Determining commands per LUN *** * - * When AIC7XXX_CMDS_PER_DEVICE is not defined, the driver will use its + * When AIC7XXX_CMDS_PER_LUN is not defined, the driver will use its * own algorithm to determine the commands/LUN. If SCB paging is * enabled, which is always now, the default is 8 commands per lun * that indicates it supports tagged queueing. All non-tagged devices @@ -514,13 +511,8 @@ typedef struct * Make a define that will tell the driver not to use tagged queueing * by default. */ -#ifdef CONFIG_AIC7XXX_TCQ_ON_BY_DEFAULT -#define DEFAULT_TAG_COMMANDS {0, 0, 0, 0, 0, 0, 0, 0,\ - 0, 0, 0, 0, 0, 0, 0, 0} -#else #define DEFAULT_TAG_COMMANDS {255, 255, 255, 255, 255, 255, 255, 255,\ 255, 255, 255, 255, 255, 255, 255, 255} -#endif /* * Modify this as you see fit for your system. By setting tag_commands @@ -559,27 +551,6 @@ adapter_tag_info_t aic7xxx_tag_info[] = }; */ -static adapter_tag_info_t aic7xxx_tag_info[] = -{ - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS}, - {DEFAULT_TAG_COMMANDS} -}; - - /* * Define an array of board names that can be indexed by aha_type. * Don't forget to change this when changing the types! @@ -606,14 +577,10 @@ static const char *board_names[] = { "Adaptec AHA-2944 Ultra SCSI host adapter", /* AIC_7884 */ "Adaptec AIC-7895 Ultra SCSI host adapter", /* AIC_7895 */ "Adaptec AIC-7890/1 Ultra2 SCSI host adapter", /* AIC_7890 */ - "Adaptec AHA-293X Ultra2 SCSI host adapter", /* AIC_7890 */ "Adaptec AHA-294X Ultra2 SCSI host adapter", /* AIC_7890 */ "Adaptec AIC-7896/7 Ultra2 SCSI host adapter", /* AIC_7896 */ "Adaptec AHA-394X Ultra2 SCSI host adapter", /* AIC_7897 */ - "Adaptec AHA-395X Ultra2 SCSI host adapter", /* AIC_7897 */ "Adaptec PCMCIA SCSI controller", /* card bus stuff */ - "Adaptec AIC-7892 Ultra 160/m SCSI host adapter", /* AIC_7892 */ - "Adaptec AIC-7899 Ultra 160/m SCSI host adapter", /* AIC_7899 */ }; /* @@ -916,7 +883,6 @@ typedef enum { * and what flags weren't. This way, I could clean up the flag usage on * a use by use basis. Doug Ledford */ - AHC_RESET_DELAY = 0x00080000, AHC_A_SCANNED = 0x00100000, AHC_B_SCANNED = 0x00200000, AHC_MULTI_CHANNEL = 0x00400000, @@ -943,8 +909,6 @@ typedef enum { AHC_AIC7890 = 0x0006, AHC_AIC7895 = 0x0007, AHC_AIC7896 = 0x0008, - AHC_AIC7892 = 0x0009, - AHC_AIC7899 = 0x000a, AHC_VL = 0x0100, AHC_EISA = 0x0200, AHC_PCI = 0x0400, @@ -961,7 +925,6 @@ typedef enum { AHC_QUEUE_REGS = 0x0040, AHC_SG_PRELOAD = 0x0080, AHC_SPIOCAP = 0x0100, - AHC_ULTRA160 = 0x0200, AHC_AIC7770_FE = AHC_FENONE, AHC_AIC7850_FE = AHC_SPIOCAP, AHC_AIC7860_FE = AHC_ULTRA|AHC_SPIOCAP, @@ -971,8 +934,6 @@ typedef enum { AHC_QUEUE_REGS|AHC_SG_PRELOAD, AHC_AIC7895_FE = AHC_MORE_SRAM|AHC_CMD_CHAN|AHC_ULTRA, AHC_AIC7896_FE = AHC_AIC7890_FE, - AHC_AIC7892_FE = AHC_AIC7890_FE|AHC_ULTRA160, - AHC_AIC7899_FE = AHC_AIC7890_FE|AHC_ULTRA160, } ahc_feature; struct aic7xxx_scb { @@ -1080,10 +1041,6 @@ struct aic7xxx_host { unsigned long isr_count; /* Interrupt count */ unsigned long spurious_int; scb_data_type *scb_data; - volatile unsigned short needsdtr; - volatile unsigned short sdtr_pending; - volatile unsigned short needwdtr; - volatile unsigned short wdtr_pending; struct aic7xxx_cmd_queue { Scsi_Cmnd *head; Scsi_Cmnd *tail; @@ -1108,22 +1065,20 @@ struct aic7xxx_host { #define DEVICE_RESET_DELAY 0x04 #define DEVICE_PRINT_SDTR 0x08 #define DEVICE_PRINT_WDTR 0x10 -#define DEVICE_WAS_BUSY 0x20 +#define DEVICE_SUCCESS 0x20 +#define DEVICE_TAGGED_SUCCESS 0x40 #define DEVICE_SCANNED 0x80 volatile unsigned char dev_flags[MAX_TARGETS]; volatile unsigned char dev_active_cmds[MAX_TARGETS]; volatile unsigned char dev_temp_queue_depth[MAX_TARGETS]; unsigned char dev_commands_sent[MAX_TARGETS]; - unsigned int dev_timer_active; /* Which devs have a timer set */ - struct timer_list dev_timer; - unsigned long dev_expires[MAX_TARGETS]; - #if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,0) spinlock_t spin_lock; volatile unsigned char cpu_lock_count[NR_CPUS]; #endif + unsigned short dev_timer_active; /* Which devs have a timer set */ #ifdef AIC7XXX_FAKE_NEGOTIATION_CMDS Scsi_Cmnd *dev_wdtr_cmnd[MAX_TARGETS]; @@ -1136,6 +1091,12 @@ struct aic7xxx_host { volatile scb_queue_type delayed_scbs[MAX_TARGETS]; + unsigned long dev_expires[MAX_TARGETS]; + struct timer_list dev_timer; + + /* + * The next 64.... + */ unsigned char msg_buf[9]; /* The message for the target */ unsigned char msg_type; @@ -1162,11 +1123,16 @@ struct aic7xxx_host { volatile unsigned char qoutfifo[256]; volatile unsigned char qinfifo[256]; unsigned int irq; /* IRQ for this adapter */ + volatile unsigned short needsdtr; + volatile unsigned short sdtr_pending; + volatile unsigned short needwdtr; + volatile unsigned short wdtr_pending; int instance; /* aic7xxx instance number */ int scsi_id; /* host adapter SCSI ID */ int scsi_id_b; /* channel B for twin adapters */ unsigned int bios_address; int board_name_index; + unsigned long reset_start; unsigned short needsdtr_copy; /* default config */ unsigned short needwdtr_copy; /* default config */ unsigned short ultraenb; /* Ultra mode target list */ @@ -1184,6 +1150,7 @@ struct aic7xxx_host { struct Scsi_Host *host; /* pointer to scsi host */ int host_no; /* SCSI host number */ unsigned long mbase; /* I/O memory address */ + unsigned long last_reset; ahc_chip chip; /* chip type */ /* @@ -1199,21 +1166,21 @@ struct aic7xxx_host { * * NOTE: Enabling this feature is likely to cause a noticeable performance * decrease as the accesses into the stats structures blows apart multiple - * cache lines and is CPU time consuming. - * - * NOTE: Since it doesn't really buy us much, but consumes *tons* of RAM - * and blows apart all sorts of cache lines, I modified this so that we - * no longer look at the LUN. All LUNs now go into the same bin on each - * device for stats purposes. + * cache lines and is CPU time consuming. We keep the xfer count always + * for use by the aic7xxx_proc.c code, but only do the bins if the + * proc stats code is enabled. */ struct aic7xxx_xferstats { - long w_total; /* total writes */ - long r_total; /* total reads */ + long w_total; /* total writes */ + long r_total; /* total reads */ #ifdef AIC7XXX_PROC_STATS - long w_bins[8]; /* binned write */ - long r_bins[8]; /* binned reads */ + long xfers; /* total xfer count */ + long w_total512; /* 512 byte blocks written */ + long r_total512; /* 512 byte blocks read */ + long w_bins[10]; /* binned write */ + long r_bins[10]; /* binned reads */ #endif /* AIC7XXX_PROC_STATS */ - } stats[MAX_TARGETS]; /* [(channel << 3)|target] */ + } stats[MAX_TARGETS][MAX_LUNS]; /* [(channel << 3)|target][lun] */ #if 0 struct target_cmd *targetcmds; @@ -1445,6 +1412,35 @@ static char dummy_buffer[60] = "Please don't trounce on me insmod!!\n"; #endif +/* + * See the comments earlier in the file for what this item is all about + * If you have more than 4 controllers, you will need to increase the + * the number of items in the array below. Additionally, if you don't + * want to have lilo pass a humongous config line to the aic7xxx driver, + * then you can get in and manually adjust these instead of leaving them + * at the default. Pay attention to the comments earlier in this file + * concerning this array if you are going to hand modify these values. + */ +static adapter_tag_info_t aic7xxx_tag_info[] = +{ + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS}, + {DEFAULT_TAG_COMMANDS} +}; + #define VERBOSE_NORMAL 0x0000 #define VERBOSE_NEGOTIATION 0x0001 #define VERBOSE_SEQINT 0x0002 @@ -2802,7 +2798,6 @@ aic7xxx_done_cmds_complete(struct aic7xxx_host *p) Scsi_Cmnd *cmd; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,95) unsigned int cpu_flags = 0; -#endif DRIVER_LOCK while (p->completeq.head != NULL) @@ -2810,9 +2805,20 @@ aic7xxx_done_cmds_complete(struct aic7xxx_host *p) cmd = p->completeq.head; p->completeq.head = (Scsi_Cmnd *)cmd->host_scribble; cmd->host_scribble = NULL; + sti(); cmd->scsi_done(cmd); + cli(); } DRIVER_UNLOCK +#else + while (p->completeq.head != NULL) + { + cmd = p->completeq.head; + p->completeq.head = (Scsi_Cmnd *)cmd->host_scribble; + cmd->host_scribble = NULL; + cmd->scsi_done(cmd); + } +#endif } /*+F************************************************************************* @@ -2871,7 +2877,6 @@ aic7xxx_done(struct aic7xxx_host *p, struct aic7xxx_scb *scb) { char *buffer; - p->dev_flags[tindex] |= DEVICE_PRESENT; if(cmd->use_sg) { struct scatterlist *sg; @@ -2913,34 +2918,23 @@ aic7xxx_done(struct aic7xxx_host *p, struct aic7xxx_scb *scb) p->needsdtr_copy |= (1<flags & AHC_SEEPROM_FOUND) - { p->transinfo[tindex].goal_period = p->transinfo[tindex].user_period; - p->transinfo[tindex].goal_offset = p->transinfo[tindex].user_offset; - } + else if (p->features & AHC_ULTRA2) + p->transinfo[tindex].goal_period = + aic7xxx_syncrates[AHC_SYNCRATE_ULTRA2].period; + else if (p->features & AHC_ULTRA) + p->transinfo[tindex].goal_period = + aic7xxx_syncrates[AHC_SYNCRATE_ULTRA].period; else - { - if (p->features & AHC_ULTRA2) - { - p->transinfo[tindex].goal_period = - aic7xxx_syncrates[AHC_SYNCRATE_ULTRA2].period; - } - else if (p->features & AHC_ULTRA) - { - p->transinfo[tindex].goal_period = - aic7xxx_syncrates[AHC_SYNCRATE_ULTRA].period; - } - else - { - p->transinfo[tindex].goal_period = - aic7xxx_syncrates[AHC_SYNCRATE_FAST].period; - } - if (p->features & AHC_ULTRA2) - p->transinfo[tindex].goal_offset = MAX_OFFSET_ULTRA2; - else if (p->transinfo[tindex].goal_width == MSG_EXT_WDTR_BUS_16_BIT) - p->transinfo[tindex].goal_offset = MAX_OFFSET_16BIT; - else - p->transinfo[tindex].goal_offset = MAX_OFFSET_8BIT; - } + p->transinfo[tindex].goal_period = + aic7xxx_syncrates[AHC_SYNCRATE_FAST].period; + + if (p->features & AHC_ULTRA2) + p->transinfo[tindex].goal_offset = MAX_OFFSET_ULTRA2; + else if (p->transinfo[tindex].goal_width == MSG_EXT_WDTR_BUS_16_BIT) + p->transinfo[tindex].goal_offset = MAX_OFFSET_16BIT; + else + p->transinfo[tindex].goal_offset = MAX_OFFSET_8BIT; } else { @@ -3086,7 +3080,7 @@ aic7xxx_done(struct aic7xxx_host *p, struct aic7xxx_scb *scb) int x; #endif /* AIC7XXX_PROC_STATS */ - sp = &p->stats[TARGET_INDEX(cmd)]; + sp = &p->stats[TARGET_INDEX(cmd)][cmd->lun & 0x7]; /* * For block devices, cmd->request.cmd is always == either READ or @@ -3103,6 +3097,8 @@ aic7xxx_done(struct aic7xxx_host *p, struct aic7xxx_scb *scb) aic7xxx_verbose &= 0xffff; #endif #ifdef AIC7XXX_PROC_STATS + sp->xfers++; + sp->w_total512 += (actual >> 9); ptr = sp->w_bins; #endif /* AIC7XXX_PROC_STATS */ } @@ -3114,27 +3110,23 @@ aic7xxx_done(struct aic7xxx_host *p, struct aic7xxx_scb *scb) aic7xxx_verbose &= 0xffff; #endif #ifdef AIC7XXX_PROC_STATS + sp->xfers++; + sp->r_total512 += (actual >> 9); ptr = sp->r_bins; #endif /* AIC7XXX_PROC_STATS */ } #ifdef AIC7XXX_PROC_STATS - x = -10; - while(actual) - { - actual >>= 1; - x++; - } - if (x < 0) - { - ptr[0]++; - } - else if (x > 7) + for (x = 9; x <= 17; x++) { - ptr[7]++; + if (actual < (1 << x)) + { + ptr[x - 9]++; + break; + } } - else + if (x > 17) { - ptr[x]++; + ptr[x - 9]++; } #endif /* AIC7XXX_PROC_STATS */ } @@ -3425,6 +3417,19 @@ aic7xxx_reset_device(struct aic7xxx_host *p, int target, int channel, if (aic7xxx_verbose & (VERBOSE_ABORT_PROCESS | VERBOSE_RESET_PROCESS)) printk(INFO_LEAD "Cleaning up status information " "and delayed_scbs.\n", p->host_no, channel, i, lun); + if ( !(p->dev_flags[i] & DEVICE_TAGGED_SUCCESS) && + (p->dev_active_cmds[i]) && + (p->tagenable & (0x01 << i)) ) + { + printk(INFO_LEAD "Device appears to be choking on tagged commands.\n", + p->host_no, channel, i, lun); + printk(INFO_LEAD "Will use untagged I/O instead.\n", p->host_no, + channel, i, lun); + p->dev_max_queue_depth[i] = 1; + p->dev_temp_queue_depth[i] = 1; + p->tagenable &= ~(0x01 << i); + p->orderedtag &= ~(0x01 << i); + } p->dev_flags[i] &= ~BUS_DEVICE_RESET_PENDING; if ( tag == SCB_LIST_NULL ) { @@ -3482,13 +3487,13 @@ aic7xxx_reset_device(struct aic7xxx_host *p, int target, int channel, "delayed_scbs queue!\n", p->host_no, channel, i, lun); scbq_init(&p->delayed_scbs[i]); } - if ( !(p->dev_timer_active & (0x01 << MAX_TARGETS)) || + if ( !(p->dev_timer_active & (0x01 << p->scsi_id)) || time_after_eq(p->dev_timer.expires, p->dev_expires[i]) ) { del_timer(&p->dev_timer); p->dev_timer.expires = p->dev_expires[i]; add_timer(&p->dev_timer); - p->dev_timer_active |= (0x01 << MAX_TARGETS); + p->dev_timer_active |= (0x01 << p->scsi_id); } } } @@ -3621,7 +3626,7 @@ aic7xxx_reset_device(struct aic7xxx_host *p, int target, int channel, if (aic7xxx_verbose & (VERBOSE_ABORT_PROCESS | VERBOSE_RESET_PROCESS)) printk(INFO_LEAD "Cleaning disconnected scbs " "list.\n", p->host_no, channel, target, lun); - if (p->flags & AHC_PAGESCBS) + if (p->features & AHC_PAGESCBS) { unsigned char next, prev, scb_index; @@ -3673,7 +3678,7 @@ aic7xxx_reset_device(struct aic7xxx_host *p, int target, int channel, * Walk the free list making sure no entries on the free list have * a valid SCB_TAG value or SCB_CONTROL byte. */ - if (p->flags & AHC_PAGESCBS) + if (p->features & AHC_PAGESCBS) { unsigned char next; @@ -3954,6 +3959,12 @@ aic7xxx_reset_channel(struct aic7xxx_host *p, int channel, int initiate_reset) */ aic7xxx_reset_device(p, ALL_TARGETS, channel, ALL_LUNS, SCB_LIST_NULL); + /* + * Convince Mid Level SCSI code to leave us be for a little bit... + */ + p->last_reset = jiffies; + p->host->last_reset = (jiffies + (HZ * AIC7XXX_RESET_DELAY)); + if ( !(p->features & AHC_TWIN) ) { restart_sequencer(p); @@ -3999,8 +4010,7 @@ aic7xxx_run_waiting_queues(struct aic7xxx_host *p) } if ( (p->dev_active_cmds[tindex] >= p->dev_temp_queue_depth[tindex]) || - (p->dev_flags[tindex] & (DEVICE_RESET_DELAY|DEVICE_WAS_BUSY)) || - (p->flags & AHC_RESET_DELAY) ) + (p->dev_flags[tindex] & DEVICE_RESET_DELAY) ) { scbq_insert_tail(&p->delayed_scbs[tindex], scb); } @@ -4119,21 +4129,18 @@ aic7xxx_timer(struct aic7xxx_host *p) #else spin_lock_irqsave(&io_request_lock, cpu_flags); #endif - p->dev_timer_active &= ~(0x01 << MAX_TARGETS); - if ( (p->dev_timer_active & (0x01 << p->scsi_id)) && - time_after_eq(jiffies, p->dev_expires[p->scsi_id]) ) - { - p->flags &= ~AHC_RESET_DELAY; - p->dev_timer_active &= ~(0x01 << p->scsi_id); - } + p->dev_timer_active &= ~(0x01 << p->scsi_id); for(i=0; iscsi_id) && - (p->dev_timer_active & (0x01 << i)) && + if ( i == p->scsi_id ) + { + continue; + } + if ( (p->dev_timer_active & (0x01 << i)) && time_after_eq(jiffies, p->dev_expires[i]) ) { p->dev_timer_active &= ~(0x01 << i); - p->dev_flags[i] &= ~(DEVICE_RESET_DELAY|DEVICE_WAS_BUSY); + p->dev_flags[i] &= ~DEVICE_RESET_DELAY; p->dev_temp_queue_depth[i] = p->dev_max_queue_depth[i]; j = 0; while ( ((scb = scbq_remove_head(&p->delayed_scbs[i])) != NULL) && @@ -4155,7 +4162,7 @@ aic7xxx_timer(struct aic7xxx_host *p) } else if ( p->dev_timer_active & (0x01 << i) ) { - if ( p->dev_timer_active & (0x01 << MAX_TARGETS) ) + if ( p->dev_timer_active & (0x01 << p->scsi_id) ) { if ( time_after_eq(p->dev_timer.expires, p->dev_expires[i]) ) { @@ -4165,11 +4172,11 @@ aic7xxx_timer(struct aic7xxx_host *p) else { p->dev_timer.expires = p->dev_expires[i]; - p->dev_timer_active |= (0x01 << MAX_TARGETS); + p->dev_timer_active |= (0x01 << p->scsi_id); } } } - if ( p->dev_timer_active & (0x01 << MAX_TARGETS) ) + if ( p->dev_timer_active & (0x01 << p->scsi_id) ) { add_timer(&p->dev_timer); } @@ -4448,7 +4455,8 @@ aic7xxx_handle_seqint(struct aic7xxx_host *p, unsigned char intstat) (scb->tag_action) && !(scb->flags & SCB_MSGOUT_BITS) ) { - if (scb->tag_action == MSG_ORDERED_Q_TAG) + if ((scb->tag_action == MSG_ORDERED_Q_TAG) && + (p->dev_flags[tindex] & DEVICE_TAGGED_SUCCESS)) { /* * OK...the device seems able to accept tagged commands, but @@ -4469,7 +4477,8 @@ aic7xxx_handle_seqint(struct aic7xxx_host *p, unsigned char intstat) aic_outb(p, MSG_IDENTIFYFLAG, MSG_OUT); aic_outb(p, aic_inb(p, SCSISIGI) | ATNO, SCSISIGO); } - else if (scb->tag_action == MSG_SIMPLE_Q_TAG) + else if ( (scb->tag_action == MSG_SIMPLE_Q_TAG) && + !(p->dev_flags[tindex] & DEVICE_TAGGED_SUCCESS) ) { unsigned char i, reset = 0; struct aic7xxx_scb *scbp; @@ -4889,16 +4898,16 @@ aic7xxx_handle_seqint(struct aic7xxx_host *p, unsigned char intstat) p->dev_timer_active |= (0x01 << tindex); if ( p->dev_active_cmds[tindex] ) { - p->dev_expires[tindex] = jiffies + HZ; + p->dev_expires[tindex] = jiffies + (HZ * 2); } else { - p->dev_expires[tindex] = jiffies + (HZ / 10); + p->dev_expires[tindex] = jiffies + (HZ / 2); } - if ( !(p->dev_timer_active & (0x01 << MAX_TARGETS)) ) + if ( !(p->dev_timer_active & (0x01 << p->scsi_id)) ) { p->dev_timer.expires = p->dev_expires[tindex]; - p->dev_timer_active |= (0x01 << MAX_TARGETS); + p->dev_timer_active |= (0x01 << p->scsi_id); add_timer(&p->dev_timer); } else if ( time_after_eq(p->dev_timer.expires, @@ -4948,10 +4957,6 @@ aic7xxx_handle_seqint(struct aic7xxx_host *p, unsigned char intstat) p->dev_last_queue_full[tindex] = 0; p->dev_last_queue_full_count[tindex] = 0; } - else - { - p->dev_flags[tindex] |= DEVICE_WAS_BUSY; - } } break; } @@ -5276,8 +5281,7 @@ aic7xxx_parse_msg(struct aic7xxx_host *p, struct aic7xxx_scb *scb) * have a device ask for a higher speed then we want to give it * in that case */ - if ( (scb->flags & (SCB_MSGOUT_SENT|SCB_MSGOUT_SDTR)) != - (SCB_MSGOUT_SENT|SCB_MSGOUT_SDTR) ) + if (!(p->sdtr_pending & target_mask)) { if (!(p->dev_flags[tindex] & DEVICE_SCANNED)) { @@ -5295,36 +5299,54 @@ aic7xxx_parse_msg(struct aic7xxx_host *p, struct aic7xxx_scb *scb) p->transinfo[tindex].user_offset; p->needsdtr_copy |= target_mask; } - if ( !p->transinfo[tindex].goal_offset ) - period = 255; if ( p->transinfo[tindex].goal_period > period ) period = p->transinfo[tindex].goal_period; + if ( p->transinfo[tindex].goal_offset < offset ) + saved_offset = offset = p->transinfo[tindex].goal_offset; } +#ifdef AIC7XXX_VERBOSE_DEBUGGING + if (aic7xxx_verbose > 0xffff) + { + printk(INFO_LEAD "Finished receipt of SDTR, parsing %d/%d\n", + p->host_no, CTL_OF_SCB(scb), period, offset); + syncrate = aic7xxx_find_syncrate(p, &period, maxsync); + printk(INFO_LEAD "After find_syncrate() %d/%d\n", + p->host_no, CTL_OF_SCB(scb), period, offset); + aic7xxx_validate_offset(p, syncrate, &offset, + target_scsirate & WIDEXFER); + printk(INFO_LEAD "After validate_offset() %d/%d\n", + p->host_no, CTL_OF_SCB(scb), period, offset); + aic7xxx_set_syncrate(p, syncrate, target, channel, period, + offset, AHC_TRANS_ACTIVE|AHC_TRANS_CUR); + printk(INFO_LEAD "Final values of Period/Offset as set: %d/%d\n", + p->host_no, CTL_OF_SCB(scb), period, offset); + } + else + { + syncrate = aic7xxx_find_syncrate(p, &period, maxsync); + aic7xxx_validate_offset(p, syncrate, &offset, + target_scsirate & WIDEXFER); + aic7xxx_set_syncrate(p, syncrate, target, channel, period, + offset, AHC_TRANS_ACTIVE|AHC_TRANS_CUR); + } +#else syncrate = aic7xxx_find_syncrate(p, &period, maxsync); aic7xxx_validate_offset(p, syncrate, &offset, target_scsirate & WIDEXFER); aic7xxx_set_syncrate(p, syncrate, target, channel, period, offset, AHC_TRANS_ACTIVE|AHC_TRANS_CUR); +#endif - /* - * Did we drop to async? If so, are we sending a reply? If we are, - * then we have to make sure that the reply value reflects the proper - * settings so we need to set the goal values according to what - * we need to send. - */ - if ( (offset == 0) || (offset != saved_offset) || - ((scb->flags & (SCB_MSGOUT_SENT|SCB_MSGOUT_SDTR)) != - (SCB_MSGOUT_SENT|SCB_MSGOUT_SDTR) ) ) + if (offset == 0) { + /* + * Uhh ohh, things fell through to async....update the goal + * items and the needsdtr_copy to reflect this... + */ aic7xxx_set_syncrate(p, syncrate, target, channel, period, - offset, AHC_TRANS_GOAL|AHC_TRANS_QUITE); - if ( offset == 0 ) - { - p->needsdtr_copy &= ~target_mask; - } + offset, AHC_TRANS_GOAL|AHC_TRANS_QUITE); } - /* * Did we start this, if not, or if we went to low and had to * go async, then send an SDTR back to the target @@ -5415,6 +5437,7 @@ aic7xxx_parse_msg(struct aic7xxx_host *p, struct aic7xxx_scb *scb) p->transinfo[tindex].user_width; p->needwdtr_copy |= target_mask; p->needsdtr_copy |= target_mask; + p->dev_flags[tindex] |= DEVICE_SCANNED; } switch(bus_width) { @@ -5810,19 +5833,23 @@ aic7xxx_handle_scsiint(struct aic7xxx_host *p, unsigned char intstat) * Put this SCB back on the free list. */ aic7xxx_add_curscb_to_free_list(p); + /* + * XXX - If we queued an abort tag, go clean up the disconnected list. + * We know that this particular SCB had to be the queued abort since + * the disconnected SCB would have gotten a reconnect instead. + * However, if this is an abort command, then DID_TIMEOUT isn't + * appropriate, neither is returning the command for that matter. + * What we need to do then is to let the command timeout again so + * we get a reset since this abort just failed. + */ #ifdef AIC7XXX_VERBOSE_DEBUGGING if (aic7xxx_verbose > 0xffff) printk(INFO_LEAD "Selection Timeout.\n", p->host_no, CTL_OF_SCB(scb)); #endif - if (scb->flags & SCB_QUEUED_ABORT) + if (p->flags & SCB_QUEUED_ABORT) { - /* - * We know that this particular SCB had to be the queued abort since - * the disconnected SCB would have gotten a reconnect instead. - * What we need to do then is to let the command timeout again so - * we get a reset since this abort just failed. - */ cmd->result = 0; + scb->flags &= ~SCB_QUEUED_ABORT; scb = NULL; } } @@ -6239,6 +6266,12 @@ aic7xxx_isr(int irq, void *dev_id, struct pt_regs *regs) aic7xxx_calculate_residual(p, scb); } cmd->result |= (aic7xxx_error(cmd) << 16); + if (scb->tag_action) + p->dev_flags[TARGET_INDEX(cmd)] |= + DEVICE_TAGGED_SUCCESS | DEVICE_SUCCESS | DEVICE_PRESENT; + else + p->dev_flags[TARGET_INDEX(cmd)] |= + DEVICE_SUCCESS | DEVICE_PRESENT; aic7xxx_done(p, scb); break; } @@ -6364,7 +6397,7 @@ do_aic7xxx_isr(int irq, void *dev_id, struct pt_regs *regs) * Determines the queue depth for a given device. There are two ways * a queue depth can be obtained for a tagged queueing device. One * way is the default queue depth which is determined by whether - * AIC7XXX_CMDS_PER_DEVICE is defined. If it is defined, then it is used + * AIC7XXX_CMDS_PER_LUN is defined. If it is defined, then it is used * as the default queue depth. Otherwise, we use either 4 or 8 as the * default queue depth (dependent on the number of hardware SCBs). * The other way we determine queue depth is through the use of the @@ -6392,7 +6425,11 @@ aic7xxx_device_queue_depth(struct aic7xxx_host *p, Scsi_Device *device) { int tag_enabled = TRUE; - default_depth = AIC7XXX_CMDS_PER_DEVICE; +#ifdef AIC7XXX_CMDS_PER_LUN + default_depth = AIC7XXX_CMDS_PER_LUN; +#else + default_depth = 8; /* Not many SCBs to work with. */ +#endif if (!(p->discenable & target_mask)) { @@ -6954,7 +6991,7 @@ read_seeprom(struct aic7xxx_host *p, int offset, } printk("\n"); #endif - if ( (checksum != scarray[len - 1]) || (checksum == 0) ) + if (checksum != scarray[len - 1]) { return (0); } @@ -7438,6 +7475,7 @@ aic7xxx_register(Scsi_Host_Template *template, struct aic7xxx_host *p, } p->host = host; + p->last_reset = jiffies; p->host_no = host->host_no; host->unique_id = p->instance; p->isr_count = 0; @@ -7523,9 +7561,10 @@ aic7xxx_register(Scsi_Host_Template *template, struct aic7xxx_host *p, } aic_outb(p, 0, SEQ_FLAGS); + /* + * Detect SCB parameters and initialize the SCB array. + */ detect_maxscb(p); - - printk("%d/%d SCBs\n", p->scb_data->maxhscbs, p->scb_data->maxscbs); if (aic7xxx_verbose & VERBOSE_PROBE2) { @@ -7644,7 +7683,7 @@ aic7xxx_register(Scsi_Host_Template *template, struct aic7xxx_host *p, aic_outb(p, p->scsi_id_b, SCSIID); scsi_conf = aic_inb(p, SCSICONF + 1); aic_outb(p, DFON | SPIOEN, SXFRCTL0); - aic_outb(p, (scsi_conf & ENSPCHK) | STIMESEL | term | + aic_outb(p, (scsi_conf & ENSPCHK) | term | ENSTIMER | ACTNEGEN, SXFRCTL1); aic_outb(p, 0, SIMODE0); aic_outb(p, ENSELTIMO | ENSCSIRST | ENSCSIPERR, SIMODE1); @@ -7661,7 +7700,7 @@ aic7xxx_register(Scsi_Host_Template *template, struct aic7xxx_host *p, aic_outb(p, p->scsi_id, SCSIID); scsi_conf = aic_inb(p, SCSICONF); aic_outb(p, DFON | SPIOEN, SXFRCTL0); - aic_outb(p, (scsi_conf & ENSPCHK) | STIMESEL | term | + aic_outb(p, (scsi_conf & ENSPCHK) | term | ENSTIMER | ACTNEGEN, SXFRCTL1); aic_outb(p, 0, SIMODE0); aic_outb(p, ENSELTIMO | ENSCSIRST | ENSCSIPERR, SIMODE1); @@ -7836,11 +7875,6 @@ aic7xxx_register(Scsi_Host_Template *template, struct aic7xxx_host *p, */ aic7xxx_loadseq(p); - /* - * Make sure the AUTOFLUSHDIS bit is *not* set in the SBLKCTL register - */ - aic_outb(p, aic_inb(p, SBLKCTL) & ~AUTOFLUSHDIS, SBLKCTL); - if ( (p->chip & AHC_CHIPID_MASK) == AHC_AIC7770 ) { aic_outb(p, ENABLE, BCTL); /* Enable the boards BUS drivers. */ @@ -8127,8 +8161,6 @@ aic7xxx_load_seeprom(struct aic7xxx_host *p, unsigned char *sxfrctl1) p->flags |= AHC_TERM_ENB_A; if ( (p->features & AHC_TWIN) && (aic_inb(p, SCSICONF + 1) & TERM_ENB) ) p->flags |= AHC_TERM_ENB_B; - aic_outb(p, 0, DISC_DSB); - aic_outb(p, 0, DISC_DSB + 1); break; case (AHC_AIC7770|AHC_VL): @@ -8187,16 +8219,14 @@ aic7xxx_load_seeprom(struct aic7xxx_host *p, unsigned char *sxfrctl1) { printk("aic7xxx: Using leftover BIOS values.\n"); } - if ( ((p->chip & ~AHC_CHIPID_MASK) == AHC_PCI) && (*sxfrctl1 & STPWEN) ) + if ( *sxfrctl1 & STPWEN ) { p->flags |= AHC_TERM_ENB_SE_LOW | AHC_TERM_ENB_SE_HIGH; sc->adapter_control &= ~CFAUTOTERM; sc->adapter_control |= CFSTERM | CFWSTERM | CFLVDSTERM; } if (aic7xxx_extended) - p->flags |= (AHC_EXTEND_TRANS_A | AHC_EXTEND_TRANS_B); - else - p->flags &= ~(AHC_EXTEND_TRANS_A | AHC_EXTEND_TRANS_B); + p->flags |= AHC_EXTEND_TRANS_A | AHC_EXTEND_TRANS_B; } else { @@ -8284,7 +8314,7 @@ aic7xxx_load_seeprom(struct aic7xxx_host *p, unsigned char *sxfrctl1) mask = (0x01 << i); if (!have_seeprom) { - if (aic_inb(p, SCSISEQ) != 0) + if(aic_inb(p, SCSISEQ) != 0) { /* * OK...the BIOS set things up and left behind the settings we need. @@ -8344,30 +8374,20 @@ aic7xxx_load_seeprom(struct aic7xxx_host *p, unsigned char *sxfrctl1) } if (p->flags & AHC_NEWEEPROM_FMT) { - if ( (sc->device_flags[i] & CFNEWULTRAFORMAT) && - !(p->features & AHC_ULTRA2) ) + if (sc->device_flags[i] & CFSYNCHISULTRA) { - /* - * I know of two different Ultra BIOSes that do this differently. - * One on the Gigabyte 6BXU mb that wants flags[i] & CFXFER to - * be == to 0x03 and SYNCISULTRA to be true to mean 40MByte/s - * while on the IBM Netfinity 5000 they want the same thing - * to be something else, while flags[i] & CFXFER == 0x03 and - * SYNCISULTRA false should be 40MByte/s. So, we set both to - * 40MByte/s and the lower speeds be damned. People will have - * to select around the conversely mapped lower speeds in order - * to select lower speeds on these boards. - */ - if ((sc->device_flags[i] & (CFXFER)) == 0x03) + p->ultraenb |= mask; + } + else if (sc->device_flags[i] & CFNEWULTRAFORMAT) + { + if ( ((sc->device_flags[i] & (CFSYNCHISULTRA | CFXFER)) == 0x03) && + !(p->features & AHC_ULTRA2) ) { sc->device_flags[i] &= ~CFXFER; sc->device_flags[i] |= CFSYNCHISULTRA; + p->ultraenb |= mask; } } - if (sc->device_flags[i] & CFSYNCHISULTRA) - { - p->ultraenb |= mask; - } } else if (sc->adapter_control & CFULTRAEN) { @@ -8798,14 +8818,6 @@ aic7xxx_detect(Scsi_Host_Template *template) {PCI_VENDOR_ID_ADAPTEC, PCI_DEVICE_ID_ADAPTEC_7855, AHC_AIC7850, AHC_PAGESCBS, AHC_AIC7850_FE, 6, 32, C46 }, - {PCI_VENDOR_ID_ADAPTEC, PCI_DEVICE_ID_ADAPTEC_7821, AHC_AIC7860, - AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7860_FE, 7, - 32, C46 }, - {PCI_VENDOR_ID_ADAPTEC, PCI_DEVICE_ID_ADAPTEC_3860, AHC_AIC7860, - AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7860_FE, 7, - 32, C46 }, {PCI_VENDOR_ID_ADAPTEC, PCI_DEVICE_ID_ADAPTEC_7860, AHC_AIC7860, AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, AHC_AIC7860_FE, 7, @@ -8848,18 +8860,6 @@ aic7xxx_detect(Scsi_Host_Template *template) {PCI_VENDOR_ID_ADAPTEC, PCI_DEVICE_ID_ADAPTEC_7884, AHC_AIC7880, AHC_PAGESCBS | AHC_BIOS_ENABLED, AHC_AIC7880_FE, 18, 32, C46 }, - {PCI_VENDOR_ID_ADAPTEC, PCI_DEVICE_ID_ADAPTEC_7885, AHC_AIC7880, - AHC_PAGESCBS | AHC_BIOS_ENABLED, AHC_AIC7880_FE, 18, - 32, C46 }, - {PCI_VENDOR_ID_ADAPTEC, PCI_DEVICE_ID_ADAPTEC_7886, AHC_AIC7880, - AHC_PAGESCBS | AHC_BIOS_ENABLED, AHC_AIC7880_FE, 18, - 32, C46 }, - {PCI_VENDOR_ID_ADAPTEC, PCI_DEVICE_ID_ADAPTEC_7887, AHC_AIC7880, - AHC_PAGESCBS | AHC_BIOS_ENABLED, AHC_AIC7880_FE, 18, - 32, C46 }, - {PCI_VENDOR_ID_ADAPTEC, PCI_DEVICE_ID_ADAPTEC_7888, AHC_AIC7880, - AHC_PAGESCBS | AHC_BIOS_ENABLED, AHC_AIC7880_FE, 18, - 32, C46 }, {PCI_VENDOR_ID_ADAPTEC, PCI_DEVICE_ID_ADAPTEC_7895, AHC_AIC7895, AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED | AHC_MULTI_CHANNEL, AHC_AIC7895_FE, 19, @@ -8868,70 +8868,29 @@ aic7xxx_detect(Scsi_Host_Template *template) AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, AHC_AIC7890_FE, 20, 32, C46 }, - {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_7890B, AHC_AIC7890, - AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7890_FE, 20, - 32, C46 }, - {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_2930U2, AHC_AIC7890, - AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7890_FE, 21, - 32, C46 }, {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_2940U2, AHC_AIC7890, AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7890_FE, 22, + AHC_AIC7890_FE, 21, 32, C46 }, {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_7896, AHC_AIC7896, AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED | AHC_MULTI_CHANNEL, - AHC_AIC7896_FE, 23, + AHC_AIC7896_FE, 22, 32, C56_66 }, {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_3940U2, AHC_AIC7896, AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED | AHC_MULTI_CHANNEL, - AHC_AIC7896_FE, 24, - 32, C56_66 }, - {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_3950U2D, AHC_AIC7896, - AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED | AHC_MULTI_CHANNEL, - AHC_AIC7896_FE, 25, + AHC_AIC7896_FE, 23, 32, C56_66 }, {PCI_VENDOR_ID_ADAPTEC, PCI_DEVICE_ID_ADAPTEC_1480A, AHC_AIC7860, AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7860_FE, 26, - 32, C46 }, - {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_7892A, AHC_AIC7892, - AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7892_FE, 27, - 32, C46 }, - {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_7892B, AHC_AIC7892, - AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7892_FE, 27, - 32, C46 }, - {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_7892D, AHC_AIC7892, - AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7892_FE, 27, + AHC_AIC7860_FE, 24, 32, C46 }, - {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_7892P, AHC_AIC7892, - AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7892_FE, 27, - 32, C46 }, - {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_7899A, AHC_AIC7899, - AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7899_FE, 28, - 32, C56_66 }, - {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_7899B, AHC_AIC7899, - AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7899_FE, 28, - 32, C56_66 }, - {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_7899D, AHC_AIC7899, - AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7899_FE, 28, - 32, C56_66 }, - {PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_7899P, AHC_AIC7899, - AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED, - AHC_AIC7899_FE, 28, - 32, C56_66 }, }; unsigned short command; unsigned int devconfig, i, oldverbose; +#ifdef MMAPIO + unsigned long page_offset, base; +#endif #if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,92) struct pci_dev *pdev = NULL; #else @@ -9082,68 +9041,21 @@ aic7xxx_detect(Scsi_Host_Template *template) temp_p->mbase &= PCI_BASE_ADDRESS_MEM_MASK; temp_p->unpause = INTEN; temp_p->pause = temp_p->unpause | PAUSE; - if ( ((temp_p->base == 0) && - (temp_p->mbase == 0)) || - (temp_p->irq == 0) ) - { - printk("aic7xxx: <%s> at PCI %d/%d\n", - board_names[aic_pdevs[i].board_name_index], - PCI_SLOT(temp_p->pci_device_fn), - PCI_FUNC(temp_p->pci_device_fn)); - printk("aic7xxx: Controller disabled by BIOS, ignoring.\n"); - kfree(temp_p); - temp_p = NULL; - continue; - } #ifdef MMAPIO - { - unsigned long page_offset, base; - - base = temp_p->mbase & PAGE_MASK; - page_offset = temp_p->mbase - base; + base = temp_p->mbase & PAGE_MASK; + page_offset = temp_p->mbase - base; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0) - temp_p->maddr = ioremap_nocache(base, page_offset + 256); + temp_p->maddr = ioremap_nocache(base, page_offset + 256); #else - temp_p->maddr = vremap(base, page_offset + 256); + temp_p->maddr = vremap(base, page_offset + 256); #endif - if(temp_p->maddr) - { - temp_p->maddr += page_offset; - /* - * We need to check the I/O with the MMAPed address. Some machines - * simply fail to work with MMAPed I/O and certain controllers. - */ - if(aic_inb(temp_p, HCNTRL) == 0xff) - { - /* - * OK.....we failed our test....go back to programmed I/O - */ - printk(KERN_INFO "aic7xxx: <%s> at PCI %d/%d\n", - board_names[aic_pdevs[i].board_name_index], - PCI_SLOT(temp_p->pci_device_fn), - PCI_FUNC(temp_p->pci_device_fn)); - printk(KERN_INFO "aic7xxx: MMAPed I/O failed, reverting to " - "Programmed I/O.\n"); -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,0) - iounmap((void *) (((unsigned long) temp_p->maddr) & PAGE_MASK)); -#else - vfree((void *) (((unsigned long) temp_p->maddr) & PAGE_MASK)); -#endif - temp_p->maddr = 0; - } - } + if(temp_p->maddr) + { + temp_p->maddr += page_offset; } #endif - /* - * We HAVE to make sure the first pause_sequencer() and all other - * subsequent I/O that isn't PCI config space I/O takes place - * after the MMAPed I/O region is configured and tested. The - * problem is the PowerPC architecture that doesn't support - * programmed I/O at all, so we have to have the MMAP I/O set up - * for this pause to even work on those machines. - */ pause_sequencer(temp_p); /* @@ -9178,36 +9090,44 @@ aic7xxx_detect(Scsi_Host_Template *template) } /* - * We need to set the CHNL? assignments before loading the SEEPROM - * The 3940 and 3985 cards (original stuff, not any of the later - * stuff) are 7870 and 7880 class chips. The Ultra2 stuff falls - * under 7896 and 7897. The 7895 is in a class by itself :) + * Doing a switch based upon i is really gross, but since Justin + * changed around the chip ID stuff, we can't use that any more. + * Since we don't scan the devices the same way as FreeBSD, we end + * up doing this gross hack in order to avoid totally splitting + * away from Justin's init code in ahc_pci.c */ - switch (temp_p->chip & AHC_CHIPID_MASK) + switch (i) { - case AHC_AIC7870: /* 3840 / 3985 */ - case AHC_AIC7880: /* 3840 UW / 3985 UW */ - if(temp_p->flags & AHC_MULTI_CHANNEL) + case 7: /* 3940 */ + case 12: /* 3940-Ultra */ + switch(PCI_SLOT(temp_p->pci_device_fn)) { - switch(PCI_SLOT(temp_p->pci_device_fn)) - { - case 5: - temp_p->flags |= AHC_CHNLB; - break; - case 8: - temp_p->flags |= AHC_CHNLB; - break; - case 12: - temp_p->flags |= AHC_CHNLC; - break; - default: - break; - } + case 5: + temp_p->flags |= AHC_CHNLB; + break; + default: + break; + } + break; + + case 8: /* 3985 */ + case 13: /* 3985-Ultra */ + switch(PCI_SLOT(temp_p->pci_device_fn)) + { + case 8: + temp_p->flags |= AHC_CHNLB; + break; + case 12: + temp_p->flags |= AHC_CHNLC; + break; + default: + break; } break; - case AHC_AIC7895: /* 7895 */ - case AHC_AIC7896: /* 7896/7 */ + case 15: + case 18: + case 19: #if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,92) if (PCI_FUNC(temp_p->pdev->devfn) != 0) { @@ -9283,6 +9203,16 @@ aic7xxx_detect(Scsi_Host_Template *template) aic_outb(temp_p, (aic_inb(temp_p, DSCOMMAND0) | CACHETHEN | MPARCKEN | USCBSIZE32 | CIOPARCKEN) & ~DPARCKEN, DSCOMMAND0); + /* FALLTHROUGH */ + default: + /* + * We attempt to read a SEEPROM on *everything*. If we fail, + * then we fail, but this covers things like 2910c cards that + * now have SEEPROMs with their 7856 chipset that we would + * otherwise ignore. They still don't have a BIOS, but they + * have a SEEPROM that the SCSISelect utility on the Adaptec + * diskettes can configure. + */ aic7xxx_load_seeprom(temp_p, &sxfrctl1); break; case AHC_AIC7850: @@ -9294,13 +9224,14 @@ aic7xxx_detect(Scsi_Host_Template *template) aic_outb(temp_p, (aic_inb(temp_p, DSCOMMAND0) | CACHETHEN | MPARCKEN) & ~DPARCKEN, DSCOMMAND0); - /* FALLTHROUGH */ - default: aic7xxx_load_seeprom(temp_p, &sxfrctl1); break; case AHC_AIC7880: /* - * Check the rev of the chipset before we change DSCOMMAND0 + * Only set the DSCOMMAND0 register if this is a Rev B. + * chipset. For those, we also enable Ultra mode by + * force due to brain-damage on the part of some BIOSes + * We overload the devconfig variable here since we can. */ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,92) pci_read_config_dword(pdev, DEVCONFIG, &devconfig); @@ -9364,10 +9295,13 @@ aic7xxx_detect(Scsi_Host_Template *template) } /* - * We only support external SCB RAM on the 7895/6/7 chipsets. - * We could support it on the 7890/1 easy enough, but I don't - * know of any 7890/1 based cards that have it. I do know - * of 7895/6/7 cards that have it and they work properly. + * We do another switch based on i so that we can exclude all + * 3895 devices from the next option since the 3895 cards use + * shared external SCB RAM while all other cards have dedicated + * external SCB RAM per channel. Also exclude the 7850 and + * 7860 based stuff since they can have garbage in the bit + * that indicates external RAM and get some of this stuff + * wrong as a result. */ switch(temp_p->chip & AHC_CHIPID_MASK) { @@ -10197,6 +10131,8 @@ aic7xxx_bus_device_reset(struct aic7xxx_host *p, Scsi_Cmnd *cmd) "message buffer\n", p->host_no, CTL_OF_SCB(scb)); scb->flags |= SCB_RESET | SCB_DEVICE_RESET; aic7xxx_error(scb->cmd) = DID_RESET; + p->dev_flags[TARGET_INDEX(scb->cmd)] &= + ~DEVICE_SUCCESS; p->dev_flags[TARGET_INDEX(scb->cmd)] |= BUS_DEVICE_RESET_PENDING; /* Send the abort message to the active SCB. */ @@ -10217,6 +10153,8 @@ aic7xxx_bus_device_reset(struct aic7xxx_host *p, Scsi_Cmnd *cmd) "in use\n", p->host_no, CTL_OF_SCB(scb)); scb->flags |= SCB_RESET | SCB_DEVICE_RESET; aic7xxx_error(scb->cmd) = DID_RESET; + p->dev_flags[TARGET_INDEX(scb->cmd)] &= + ~DEVICE_SUCCESS; p->dev_flags[TARGET_INDEX(scb->cmd)] |= BUS_DEVICE_RESET_PENDING; return(SCSI_RESET_ERROR); @@ -10244,6 +10182,7 @@ aic7xxx_bus_device_reset(struct aic7xxx_host *p, Scsi_Cmnd *cmd) */ scb->hscb->control |= MK_MESSAGE; scb->flags |= SCB_RESET | SCB_DEVICE_RESET; + p->dev_flags[TARGET_INDEX(scb->cmd)] &= ~DEVICE_SUCCESS; p->dev_flags[TARGET_INDEX(scb->cmd)] |= BUS_DEVICE_RESET_PENDING; if (hscb_index != SCB_LIST_NULL) @@ -10985,14 +10924,23 @@ aic7xxx_reset(Scsi_Cmnd *cmd, unsigned int flags) } action = BUS_RESET; } - if ( (p->flags & AHC_RESET_DELAY) && - (action & (HOST_RESET | BUS_RESET)) ) + if ( ((jiffies - p->last_reset) < (HZ * 3)) && + (action & (HOST_RESET | BUS_RESET)) ) { if (aic7xxx_verbose & VERBOSE_RESET_PROCESS) printk(INFO_LEAD "Reset called too soon after " "last bus reset, delaying.\n", p->host_no, CTL_OF_CMD(cmd)); action = RESET_DELAY; } + if ( (action & (BUS_RESET | HOST_RESET)) && (p->flags & AHC_IN_RESET) + && ((jiffies - p->reset_start) > (2 * HZ * 3)) ) + { + printk(KERN_ERR "(scsi%d:%d:%d:%d) Yikes!! Card must have left to go " + "back to Adaptec!!\n", p->host_no, CTL_OF_CMD(cmd)); + unpause_sequencer(p, FALSE); + DRIVER_UNLOCK + return(SCSI_RESET_SNOOZE); + } /* * By this point, we want to already know what we are going to do and * only have the following code implement our course of action. @@ -11024,23 +10972,15 @@ aic7xxx_reset(Scsi_Cmnd *cmd, unsigned int flags) case BUS_RESET: case HOST_RESET: default: - p->flags |= AHC_IN_RESET | AHC_RESET_DELAY; - p->dev_expires[p->scsi_id] = jiffies + (3 * HZ); - p->dev_timer_active |= (0x01 << p->scsi_id); - if ( !(p->dev_timer_active & (0x01 << MAX_TARGETS)) || - time_after_eq(p->dev_timer.expires, p->dev_expires[p->scsi_id]) ) - { - del_timer(&p->dev_timer); - p->dev_timer.expires = p->dev_expires[p->scsi_id]; - add_timer(&p->dev_timer); - p->dev_timer_active |= (0x01 << MAX_TARGETS); - } + p->reset_start = jiffies; + p->flags |= AHC_IN_RESET; aic7xxx_reset_channel(p, cmd->channel, TRUE); if ( (p->features & AHC_TWIN) && (action & HOST_RESET) ) { aic7xxx_reset_channel(p, cmd->channel ^ 0x01, TRUE); restart_sequencer(p); } + p->last_reset = jiffies; if (action != HOST_RESET) result = SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET; else @@ -11062,13 +11002,11 @@ aic7xxx_reset(Scsi_Cmnd *cmd, unsigned int flags) * entirely and avoids getting a bogus dead command back through the * mid-level code due to too many retries. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,132) if ( flags & SCSI_RESET_SYNCHRONOUS ) { - cmd->result = DID_BUS_BUSY << 16; + cmd->result = DID_RESET << 16; cmd->done(cmd); } -#endif p->flags &= ~AHC_IN_RESET; /* * We can't rely on run_waiting_queues to unpause the sequencer for @@ -11094,21 +11032,16 @@ aic7xxx_reset(Scsi_Cmnd *cmd, unsigned int flags) int aic7xxx_biosparam(Disk *disk, kdev_t dev, int geom[]) { - int heads, sectors, cylinders, ret; + int heads, sectors, cylinders; struct aic7xxx_host *p; - struct buffer_head *bh; p = (struct aic7xxx_host *) disk->device->host->hostdata; - bh = bread(MKDEV(MAJOR(dev), MINOR(dev)&~0xf), 0, 1024); - if ( bh ) - { - ret = scsi_partsize(bh, disk->capacity, &geom[2], &geom[0], &geom[1]); - brelse(bh); - if ( ret != -1 ) - return(ret); - } - + /* + * XXX - if I could portably find the card's configuration + * information, then this could be autodetected instead + * of left to a boot-time switch. + */ heads = 64; sectors = 32; cylinders = disk->capacity / (heads * sectors); diff --git a/drivers/scsi/aic7xxx_proc.c b/drivers/scsi/aic7xxx_proc.c index e0ff63aea6e3..3e6e4c678fb7 100644 --- a/drivers/scsi/aic7xxx_proc.c +++ b/drivers/scsi/aic7xxx_proc.c @@ -31,7 +31,7 @@ #define BLS (&aic7xxx_buffer[size]) #define HDRB \ -" < 2K 2K+ 4K+ 8K+ 16K+ 32K+ 64K+ 128K+" +" < 512 512-1K 1-2K 2-4K 4-8K 8-16K 16-32K 32-64K 64-128K >128K" #ifdef PROC_DEBUG extern int vsprintf(char *, const char *, va_list); @@ -86,7 +86,7 @@ aic7xxx_proc_info ( char *buffer, char **start, off_t offset, int length, int size = 0; unsigned char i; struct aic7xxx_xferstats *sp; - unsigned char target; + unsigned char target, lun; HBAptr = NULL; @@ -130,12 +130,15 @@ aic7xxx_proc_info ( char *buffer, char **start, off_t offset, int length, size = 4096; for (target = 0; target < MAX_TARGETS; target++) { - if (p->dev_flags[target] & DEVICE_PRESENT) + for (lun = 0; lun < MAX_LUNS; lun++) + { + if (p->stats[target][lun].r_total != 0) #ifdef AIC7XXX_PROC_STATS - size += 512; + size += 512; #else - size += 256; + size += 256; #endif + } } if (aic7xxx_buffer_size != size) { @@ -160,17 +163,21 @@ aic7xxx_proc_info ( char *buffer, char **start, off_t offset, int length, size += sprintf(BLS, "%s", AIC7XXX_H_VERSION); size += sprintf(BLS, "\n"); size += sprintf(BLS, "Compile Options:\n"); -#ifdef CONFIG_AIC7XXX_TCQ_ON_BY_DEFAULT - size += sprintf(BLS, " TCQ Enabled By Default : Enabled\n"); -#else - size += sprintf(BLS, " TCQ Enabled By Default : Disabled\n"); +#ifdef AIC7XXX_RESET_DELAY + size += sprintf(BLS, " AIC7XXX_RESET_DELAY : %d\n", AIC7XXX_RESET_DELAY); #endif + size += sprintf(BLS, " AIC7XXX_TAGGED_QUEUEING: Adapter Support Enabled\n"); + size += sprintf(BLS, " Check below to see " + "which\n" + " devices use tagged " + "queueing\n"); + size += sprintf(BLS, " AIC7XXX_PAGE_ENABLE : Enabled (This is no longer " + "an option)\n"); #ifdef AIC7XXX_PROC_STATS size += sprintf(BLS, " AIC7XXX_PROC_STATS : Enabled\n"); #else size += sprintf(BLS, " AIC7XXX_PROC_STATS : Disabled\n"); #endif - size += sprintf(BLS, " AIC7XXX_RESET_DELAY : %d\n", AIC7XXX_RESET_DELAY); size += sprintf(BLS, "\n"); size += sprintf(BLS, "Adapter Configuration:\n"); size += sprintf(BLS, " SCSI Adapter: %s\n", @@ -246,7 +253,11 @@ aic7xxx_proc_info ( char *buffer, char **start, off_t offset, int length, } size += sprintf(BLS, " Tag Queue Enable Flags: 0x%04x\n", p->tagenable); size += sprintf(BLS, "Ordered Queue Tag Flags: 0x%04x\n", p->orderedtag); - size += sprintf(BLS, "Default Tag Queue Depth: %d\n", AIC7XXX_CMDS_PER_DEVICE); +#ifdef AIC7XXX_CMDS_PER_LUN + size += sprintf(BLS, "Default Tag Queue Depth: %d\n", AIC7XXX_CMDS_PER_LUN); +#else + size += sprintf(BLS, "Default Tag Queue Depth: %d\n", 8); +#endif size += sprintf(BLS, " Tagged Queue By Device array for aic7xxx host " "instance %d:\n", p->instance); size += sprintf(BLS, " {"); @@ -261,83 +272,88 @@ aic7xxx_proc_info ( char *buffer, char **start, off_t offset, int length, size += sprintf(BLS, "%d}\n", p->dev_max_queue_depth[i]); size += sprintf(BLS, "\n"); - size += sprintf(BLS, "Statistics:\n\n"); + size += sprintf(BLS, "Statistics:\n"); for (target = 0; target < MAX_TARGETS; target++) { - sp = &p->stats[target]; - if ((p->dev_flags[target] & DEVICE_PRESENT) == 0) - { - continue; - } - if (p->features & AHC_TWIN) - { - size += sprintf(BLS, "(scsi%d:%d:%d:%d)\n", - p->host_no, (target >> 3), (target & 0x7), 0); - } - else + for (lun = 0; lun < MAX_LUNS; lun++) { - size += sprintf(BLS, "(scsi%d:%d:%d:%d)\n", - p->host_no, 0, target, 0); - } - size += sprintf(BLS, " Device using %s/%s", - (p->transinfo[target].cur_width == MSG_EXT_WDTR_BUS_16_BIT) ? - "Wide" : "Narrow", - (p->transinfo[target].cur_offset != 0) ? - "Sync transfers at " : "Async transfers.\n" ); - if (p->transinfo[target].cur_offset != 0) - { - struct aic7xxx_syncrate *sync_rate; - int period = p->transinfo[target].cur_period; - int rate = (p->transinfo[target].cur_width == - MSG_EXT_WDTR_BUS_16_BIT) ? 1 : 0; - - sync_rate = aic7xxx_find_syncrate(p, &period, AHC_SYNCRATE_ULTRA2); - if (sync_rate != NULL) + sp = &p->stats[target][lun]; + if (sp->r_total == 0) + { + continue; + } + if (p->features & AHC_TWIN) { - size += sprintf(BLS, "%s MByte/sec, offset %d\n", - sync_rate->rate[rate], - p->transinfo[target].cur_offset ); + size += sprintf(BLS, "(scsi%d:%d:%d:%d)\n", + p->host_no, (target >> 3), (target & 0x7), lun); } else { - size += sprintf(BLS, "3.3 MByte/sec, offset %d\n", - p->transinfo[target].cur_offset ); + size += sprintf(BLS, "(scsi%d:%d:%d:%d)\n", + p->host_no, 0, target, lun); } - } - size += sprintf(BLS, " Transinfo settings: "); - size += sprintf(BLS, "current(%d/%d/%d), ", - p->transinfo[target].cur_period, - p->transinfo[target].cur_offset, - p->transinfo[target].cur_width); - size += sprintf(BLS, "goal(%d/%d/%d), ", - p->transinfo[target].goal_period, - p->transinfo[target].goal_offset, - p->transinfo[target].goal_width); - size += sprintf(BLS, "user(%d/%d/%d)\n", - p->transinfo[target].user_period, - p->transinfo[target].user_offset, - p->transinfo[target].user_width); + size += sprintf(BLS, " Device using %s/%s\n", + (p->transinfo[target].cur_width == MSG_EXT_WDTR_BUS_16_BIT) ? + "Wide" : "Narrow", + (p->transinfo[target].cur_offset != 0) ? + "Sync transfers at" : "Async transfers." ); + if (p->transinfo[target].cur_offset != 0) + { + struct aic7xxx_syncrate *sync_rate; + int period = p->transinfo[target].cur_period; + int rate = (p->transinfo[target].cur_width == + MSG_EXT_WDTR_BUS_16_BIT) ? 1 : 0; + + sync_rate = aic7xxx_find_syncrate(p, &period, AHC_SYNCRATE_ULTRA2); + if (sync_rate != NULL) + { + size += sprintf(BLS, " %s MByte/sec, offset %d\n", + sync_rate->rate[rate], + p->transinfo[target].cur_offset ); + } + else + { + size += sprintf(BLS, " 3.3 MByte/sec, offset %d\n", + p->transinfo[target].cur_offset ); + } + } + size += sprintf(BLS, " Device Negotiation Settings\n"); + size += sprintf(BLS, " Period Offset Bus Width\n"); + size += sprintf(BLS, "User %03d %03d %d\n", + p->transinfo[target].user_period, + p->transinfo[target].user_offset, + p->transinfo[target].user_width); + size += sprintf(BLS, "Goal %03d %03d %d\n", + p->transinfo[target].goal_period, + p->transinfo[target].goal_offset, + p->transinfo[target].goal_width); + size += sprintf(BLS, "Current %03d %03d %d\n", + p->transinfo[target].cur_period, + p->transinfo[target].cur_offset, + p->transinfo[target].cur_width); #ifdef AIC7XXX_PROC_STATS - size += sprintf(BLS, " Total transfers %ld (%ld reads and %ld writes)\n", - sp->r_total + sp->w_total, sp->r_total, sp->w_total); - size += sprintf(BLS, "%s\n", HDRB); - size += sprintf(BLS, " Reads:"); - for (i = 0; i < NUMBER(sp->r_bins); i++) - { - size += sprintf(BLS, " %7ld", sp->r_bins[i]); - } - size += sprintf(BLS, "\n"); - size += sprintf(BLS, " Writes:"); - for (i = 0; i < NUMBER(sp->w_bins); i++) - { - size += sprintf(BLS, " %7ld", sp->w_bins[i]); - } - size += sprintf(BLS, "\n"); + size += sprintf(BLS, " Total transfers %ld (%ld read;%ld written)\n", + sp->xfers, sp->r_total, sp->w_total); + size += sprintf(BLS, " blks(512) rd=%ld; blks(512) wr=%ld\n", + sp->r_total512, sp->w_total512); + size += sprintf(BLS, "%s\n", HDRB); + size += sprintf(BLS, " Reads:"); + for (i = 0; i < NUMBER(sp->r_bins); i++) + { + size += sprintf(BLS, "%6ld ", sp->r_bins[i]); + } + size += sprintf(BLS, "\n"); + size += sprintf(BLS, "Writes:"); + for (i = 0; i < NUMBER(sp->w_bins); i++) + { + size += sprintf(BLS, "%6ld ", sp->w_bins[i]); + } #else - size += sprintf(BLS, " Total transfers %ld (%ld reads and %ld writes)\n", - sp->r_total + sp->w_total, sp->r_total, sp->w_total); + size += sprintf(BLS, " Total transfers: %ld/%ld read/written)\n", + sp->r_total, sp->w_total); #endif /* AIC7XXX_PROC_STATS */ - size += sprintf(BLS, "\n\n"); + size += sprintf(BLS, "\n\n"); + } } if (size >= aic7xxx_buffer_size) diff --git a/drivers/scsi/dc390.h b/drivers/scsi/dc390.h index 719df770a060..e422e99bf374 100644 --- a/drivers/scsi/dc390.h +++ b/drivers/scsi/dc390.h @@ -4,7 +4,7 @@ * Description: Device Driver for Tekram DC-390(T) PCI SCSI * * Bus Master Host Adapter * ***********************************************************************/ -/* $Id: dc390.h,v 2.12 1998/12/25 17:33:27 garloff Exp $ */ +/* $Id: dc390.h,v 2.4 1998/11/05 10:16:42 garloff Exp $ */ #include @@ -16,7 +16,7 @@ #define DC390_H #define DC390_BANNER "Tekram DC390/AM53C974" -#define DC390_VERSION "2.0d 1998/12/25" +#define DC390_VERSION "2.0b1 1998/11/05" #if defined(HOSTS_C) || defined(MODULE) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 5c4b867b1056..0c2f33d0e762 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -153,10 +153,6 @@ #include "NCR53c406a.h" #endif -#ifdef CONFIG_SCSI_SYM53C416 -#include "sym53c416.h" -#endif - #ifdef CONFIG_SCSI_DC390T #include "dc390.h" #endif @@ -193,26 +189,6 @@ #include "ini9100u.h" #endif -#ifdef CONFIG_SCSI_TC2550 -#include "tripace.h" -#endif - -#ifdef CONFIG_SCSI_INIA100 -#include "inia100.h" -#endif - -#ifdef CONFIG_SCSI_PCI2000 -#include "pci2000.h" -#endif - -#ifdef CONFIG_SCSI_PCI2220I -#include "pci2220i.h" -#endif - -#ifdef CONFIG_SCSI_PSI240I -#include "psi240i.h" -#endif - #ifdef CONFIG_SCSI_DEBUG #include "scsi_debug.h" #endif @@ -306,9 +282,6 @@ static Scsi_Host_Template builtin_scsi_hosts[] = #ifdef CONFIG_SCSI_NCR53C406A /* 53C406A should come before QLOGIC */ NCR53c406a, #endif -#ifdef CONFIG_SCSI_SYM53C416 - SYM53C416, -#endif #ifdef CONFIG_SCSI_QLOGIC_FAS QLOGICFAS, #endif @@ -354,9 +327,6 @@ static Scsi_Host_Template builtin_scsi_hosts[] = #ifdef CONFIG_SCSI_MEGARAID MEGARAID, #endif -#ifdef CONFIG_SCSI_INIA100 - INIA100, -#endif #ifdef CONFIG_SCSI_PPA PPA, #endif @@ -372,15 +342,6 @@ static Scsi_Host_Template builtin_scsi_hosts[] = #ifdef CONFIG_SCSI_INITIO INI9100U, #endif -#ifdef CONFIG_SCSI_PCI2000 - PCI2000, -#endif -#ifdef CONFIG_SCSI_PCI2220I - PCI2220I, -#endif -#ifdef CONFIG_SCSI_PSI240I - PSI240I, -#endif #ifdef CONFIG_BLK_DEV_IDESCSI IDESCSI, #endif diff --git a/drivers/scsi/i60uscsi.c b/drivers/scsi/i60uscsi.c deleted file mode 100644 index 6e8e650b0339..000000000000 --- a/drivers/scsi/i60uscsi.c +++ /dev/null @@ -1,956 +0,0 @@ -/************************************************************************** - * Initio A100 device driver for Linux. - * - * Copyright (c) 1994-1998 Initio Corporation - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * -------------------------------------------------------------------------- - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification, immediately at the beginning of the file. - * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * Where this Software is combined with software released under the terms of - * the GNU Public License ("GPL") and the terms of the GPL would require the - * combined work to also be released under the terms of the GPL, the terms - * and conditions of this License will apply in addition to those of the - * GPL with the exception of any terms or conditions of this License that - * conflict with, or are expressly prohibited by, the GPL. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - ************************************************************************* - * - * module: i60uscsi.c - * DESCRIPTION: - * This is the Linux low-level SCSI driver for Initio INIA100 SCSI host - * adapters - * - * 07/02/98 hl - v.91n Initial drivers. - * 09/14/98 hl - v1.01 Support new Kernel. - * 09/22/98 hl - v1.01a Support reset. - * 09/24/98 hl - v1.01b Fixed reset. - * 10/05/98 hl - v1.02 split the source code and release. - * 12/19/98 bv - v1.02a Use spinlocks for 2.1.95 and up - **************************************************************************/ - -#ifndef CVT_LINUX_VERSION -#define CVT_LINUX_VERSION(V,P,S) (V * 65536 + P * 256 + S) -#endif - -#include -#include -#include "i60uscsi.h" - - -/* ---- INTERNAL FUNCTIONS ---- */ -static UCHAR waitChipReady(ORC_HCS * hcsp); -static UCHAR waitFWReady(ORC_HCS * hcsp); -static UCHAR waitFWReady(ORC_HCS * hcsp); -static UCHAR waitSCSIRSTdone(ORC_HCS * hcsp); -static UCHAR waitHDOoff(ORC_HCS * hcsp); -static UCHAR waitHDIset(ORC_HCS * hcsp, UCHAR * pData); -static unsigned short get_FW_version(ORC_HCS * hcsp); -static UCHAR set_NVRAM(ORC_HCS * hcsp, unsigned char address, unsigned char value); -static UCHAR get_NVRAM(ORC_HCS * hcsp, unsigned char address, unsigned char *pDataIn); -static int se2_rd_all(ORC_HCS * hcsp); -static void se2_update_all(ORC_HCS * hcsp); /* setup default pattern */ -static void read_eeprom(ORC_HCS * hcsp); -static UCHAR load_FW(ORC_HCS * hcsp); -static void setup_SCBs(ORC_HCS * hcsp); -static void initAFlag(ORC_HCS * hcsp); -ORC_SCB *orc_alloc_scb(ORC_HCS * hcsp); - -/* ---- EXTERNAL FUNCTIONS ---- */ -extern void inia100SCBPost(BYTE * pHcb, BYTE * pScb); - -/* ---- INTERNAL VARIABLES ---- */ -ORC_HCS orc_hcs[MAX_SUPPORTED_ADAPTERS]; -static INIA100_ADPT_STRUCT inia100_adpt[MAX_SUPPORTED_ADAPTERS]; -/* set by inia100_setup according to the command line */ -int orc_num_scb; - -NVRAM nvram, *nvramp = &nvram; -static UCHAR dftNvRam[64] = -{ -/*----------header -------------*/ - 0x01, /* 0x00: Sub System Vendor ID 0 */ - 0x11, /* 0x01: Sub System Vendor ID 1 */ - 0x60, /* 0x02: Sub System ID 0 */ - 0x10, /* 0x03: Sub System ID 1 */ - 0x00, /* 0x04: SubClass */ - 0x01, /* 0x05: Vendor ID 0 */ - 0x11, /* 0x06: Vendor ID 1 */ - 0x60, /* 0x07: Device ID 0 */ - 0x10, /* 0x08: Device ID 1 */ - 0x00, /* 0x09: Reserved */ - 0x00, /* 0x0A: Reserved */ - 0x01, /* 0x0B: Revision of Data Structure */ - /* -- Host Adapter Structure --- */ - 0x01, /* 0x0C: Number Of SCSI Channel */ - 0x01, /* 0x0D: BIOS Configuration 1 */ - 0x00, /* 0x0E: BIOS Configuration 2 */ - 0x00, /* 0x0F: BIOS Configuration 3 */ - /* --- SCSI Channel 0 Configuration --- */ - 0x07, /* 0x10: H/A ID */ - 0x83, /* 0x11: Channel Configuration */ - 0x20, /* 0x12: MAX TAG per target */ - 0x0A, /* 0x13: SCSI Reset Recovering time */ - 0x00, /* 0x14: Channel Configuration4 */ - 0x00, /* 0x15: Channel Configuration5 */ - /* SCSI Channel 0 Target Configuration */ - /* 0x16-0x25 */ - 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, - 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, - /* --- SCSI Channel 1 Configuration --- */ - 0x07, /* 0x26: H/A ID */ - 0x83, /* 0x27: Channel Configuration */ - 0x20, /* 0x28: MAX TAG per target */ - 0x0A, /* 0x29: SCSI Reset Recovering time */ - 0x00, /* 0x2A: Channel Configuration4 */ - 0x00, /* 0x2B: Channel Configuration5 */ - /* SCSI Channel 1 Target Configuration */ - /* 0x2C-0x3B */ - 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, - 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, - 0x00, /* 0x3C: Reserved */ - 0x00, /* 0x3D: Reserved */ - 0x00, /* 0x3E: Reserved */ - 0x00 /* 0x3F: Checksum */ -}; - - -/***************************************************************************/ -static void waitForPause(unsigned amount) -{ - ULONG the_time = jiffies + amount; /* 0.01 seconds per jiffy */ - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - while (time_before_eq(jiffies, the_time)); -#else - while (jiffies < the_time); -#endif -} - -/***************************************************************************/ -UCHAR waitChipReady(ORC_HCS * hcsp) -{ - int i; - - for (i = 0; i < 2000; i++) { /* Wait 1 second for report timeout */ - if (ORC_RD(hcsp->HCS_Base, ORC_HCTRL) & HOSTSTOP) /* Wait HOSTSTOP set */ - return (TRUE); - waitForPause(5); /* wait 500ms before try again */ - } - return (FALSE); -} - -/***************************************************************************/ -UCHAR waitFWReady(ORC_HCS * hcsp) -{ - int i; - - for (i = 0; i < 2000; i++) { /* Wait 1 second for report timeout */ - if (ORC_RD(hcsp->HCS_Base, ORC_HSTUS) & RREADY) /* Wait READY set */ - return (TRUE); - waitForPause(5); /* wait 500ms before try again */ - } - return (FALSE); -} - -/***************************************************************************/ -UCHAR waitSCSIRSTdone(ORC_HCS * hcsp) -{ - int i; - - for (i = 0; i < 2000; i++) { /* Wait 1 second for report timeout */ - if (!(ORC_RD(hcsp->HCS_Base, ORC_HCTRL) & SCSIRST)) /* Wait SCSIRST done */ - return (TRUE); - waitForPause(5); /* wait 500ms before try again */ - } - return (FALSE); -} - -/***************************************************************************/ -UCHAR waitHDOoff(ORC_HCS * hcsp) -{ - int i; - - for (i = 0; i < 2000; i++) { /* Wait 1 second for report timeout */ - if (!(ORC_RD(hcsp->HCS_Base, ORC_HCTRL) & HDO)) /* Wait HDO off */ - return (TRUE); - waitForPause(5); /* wait 500ms before try again */ - } - return (FALSE); -} - -/***************************************************************************/ -UCHAR waitHDIset(ORC_HCS * hcsp, UCHAR * pData) -{ - int i; - - for (i = 0; i < 2000; i++) { /* Wait 1 second for report timeout */ - if ((*pData = ORC_RD(hcsp->HCS_Base, ORC_HSTUS)) & HDI) - return (TRUE); /* Wait HDI set */ - waitForPause(5); /* wait 500ms before try again */ - } - return (FALSE); -} - -/***************************************************************************/ -unsigned short get_FW_version(ORC_HCS * hcsp) -{ - UCHAR bData; - union { - unsigned short sVersion; - unsigned char cVersion[2]; - } Version; - - ORC_WR(hcsp->HCS_Base + ORC_HDATA, ORC_CMD_VERSION); - ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO); - if (waitHDOoff(hcsp) == FALSE) /* Wait HDO off */ - return (FALSE); - - if (waitHDIset(hcsp, &bData) == FALSE) /* Wait HDI set */ - return (FALSE); - Version.cVersion[0] = ORC_RD(hcsp->HCS_Base, ORC_HDATA); - ORC_WR(hcsp->HCS_Base + ORC_HSTUS, bData); /* Clear HDI */ - - if (waitHDIset(hcsp, &bData) == FALSE) /* Wait HDI set */ - return (FALSE); - Version.cVersion[1] = ORC_RD(hcsp->HCS_Base, ORC_HDATA); - ORC_WR(hcsp->HCS_Base + ORC_HSTUS, bData); /* Clear HDI */ - - return (Version.sVersion); -} - -/***************************************************************************/ -UCHAR set_NVRAM(ORC_HCS * hcsp, unsigned char address, unsigned char value) -{ - ORC_WR(hcsp->HCS_Base + ORC_HDATA, ORC_CMD_SET_NVM); /* Write command */ - ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO); - if (waitHDOoff(hcsp) == FALSE) /* Wait HDO off */ - return (FALSE); - - ORC_WR(hcsp->HCS_Base + ORC_HDATA, address); /* Write address */ - ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO); - if (waitHDOoff(hcsp) == FALSE) /* Wait HDO off */ - return (FALSE); - - ORC_WR(hcsp->HCS_Base + ORC_HDATA, value); /* Write value */ - ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO); - if (waitHDOoff(hcsp) == FALSE) /* Wait HDO off */ - return (FALSE); - - return (TRUE); -} - -/***************************************************************************/ -UCHAR get_NVRAM(ORC_HCS * hcsp, unsigned char address, unsigned char *pDataIn) -{ - unsigned char bData; - - ORC_WR(hcsp->HCS_Base + ORC_HDATA, ORC_CMD_GET_NVM); /* Write command */ - ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO); - if (waitHDOoff(hcsp) == FALSE) /* Wait HDO off */ - return (FALSE); - - ORC_WR(hcsp->HCS_Base + ORC_HDATA, address); /* Write address */ - ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO); - if (waitHDOoff(hcsp) == FALSE) /* Wait HDO off */ - return (FALSE); - - if (waitHDIset(hcsp, &bData) == FALSE) /* Wait HDI set */ - return (FALSE); - *pDataIn = ORC_RD(hcsp->HCS_Base, ORC_HDATA); - ORC_WR(hcsp->HCS_Base + ORC_HSTUS, bData); /* Clear HDI */ - - return (TRUE); -} - -/***************************************************************************/ -void orc_exec_scb(ORC_HCS * hcsp, ORC_SCB * scbp) -{ - scbp->SCB_Status = SCB_POST; - ORC_WR(hcsp->HCS_Base + ORC_PQUEUE, scbp->SCB_ScbIdx); - return; -} - - -/*********************************************************************** - Read SCSI H/A configuration parameters from serial EEPROM -************************************************************************/ -int se2_rd_all(ORC_HCS * hcsp) -{ - int i; - UCHAR *np, chksum = 0; - - np = (UCHAR *) nvramp; - for (i = 0; i < 64; i++, np++) { /* <01> */ - if (get_NVRAM(hcsp, (unsigned char) i, np) == FALSE) - return -1; -// *np++ = get_NVRAM(hcsp, (unsigned char ) i); - } - -/*------ Is ckecksum ok ? ------*/ - np = (UCHAR *) nvramp; - for (i = 0; i < 63; i++) - chksum += *np++; - - if (nvramp->CheckSum != (UCHAR) chksum) - return -1; - return 1; -} - -/************************************************************************ - Update SCSI H/A configuration parameters from serial EEPROM -*************************************************************************/ -void se2_update_all(ORC_HCS * hcsp) -{ /* setup default pattern */ - int i; - UCHAR *np, *np1, chksum = 0; - - /* Calculate checksum first */ - np = (UCHAR *) dftNvRam; - for (i = 0; i < 63; i++) - chksum += *np++; - *np = chksum; - - np = (UCHAR *) dftNvRam; - np1 = (UCHAR *) nvramp; - for (i = 0; i < 64; i++, np++, np1++) { - if (*np != *np1) { - set_NVRAM(hcsp, (unsigned char) i, *np); - } - } - return; -} - -/************************************************************************* - Function name : read_eeprom -**************************************************************************/ -void read_eeprom(ORC_HCS * hcsp) -{ - if (se2_rd_all(hcsp) != 1) { - se2_update_all(hcsp); /* setup default pattern */ - se2_rd_all(hcsp); /* load again */ - } -} - - -/***************************************************************************/ -UCHAR load_FW(ORC_HCS * hcsp) -{ - U32 dData; - USHORT wBIOSAddress; - USHORT i; - UCHAR *pData, bData; - - - bData = ORC_RD(hcsp->HCS_Base, ORC_GCFG); - ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData | EEPRG); /* Enable EEPROM programming */ - ORC_WR(hcsp->HCS_Base + ORC_EBIOSADR2, 0x00); - ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x00); - if (ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA) != 0x55) { - ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData); /* Disable EEPROM programming */ - return (FALSE); - } - ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x01); - if (ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA) != 0xAA) { - ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData); /* Disable EEPROM programming */ - return (FALSE); - } - ORC_WR(hcsp->HCS_Base + ORC_RISCCTL, PRGMRST | DOWNLOAD); /* Enable SRAM programming */ - pData = (UCHAR *) & dData; - dData = 0; /* Initial FW address to 0 */ - ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x10); - *pData = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA); /* Read from BIOS */ - ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x11); - *(pData + 1) = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA); /* Read from BIOS */ - ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x12); - *(pData + 2) = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA); /* Read from BIOS */ - ORC_WR(hcsp->HCS_Base + ORC_EBIOSADR2, *(pData + 2)); - ORC_WRLONG(hcsp->HCS_Base + ORC_FWBASEADR, dData); /* Write FW address */ - - wBIOSAddress = (USHORT) dData; /* FW code locate at BIOS address + ? */ - for (i = 0, pData = (UCHAR *) & dData; /* Download the code */ - i < 0x1000; /* Firmware code size = 4K */ - i++, wBIOSAddress++) { - ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, wBIOSAddress); - *pData++ = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA); /* Read from BIOS */ - if ((i % 4) == 3) { - ORC_WRLONG(hcsp->HCS_Base + ORC_RISCRAM, dData); /* Write every 4 bytes */ - pData = (UCHAR *) & dData; - } - } - - ORC_WR(hcsp->HCS_Base + ORC_RISCCTL, PRGMRST | DOWNLOAD); /* Reset program count 0 */ - wBIOSAddress -= 0x1000; /* Reset the BIOS adddress */ - for (i = 0, pData = (UCHAR *) & dData; /* Check the code */ - i < 0x1000; /* Firmware code size = 4K */ - i++, wBIOSAddress++) { - ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, wBIOSAddress); - *pData++ = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA); /* Read from BIOS */ - if ((i % 4) == 3) { - if (ORC_RDLONG(hcsp->HCS_Base, ORC_RISCRAM) != dData) { - ORC_WR(hcsp->HCS_Base + ORC_RISCCTL, PRGMRST); /* Reset program to 0 */ - ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData); /*Disable EEPROM programming */ - return (FALSE); - } - pData = (UCHAR *) & dData; - } - } - ORC_WR(hcsp->HCS_Base + ORC_RISCCTL, PRGMRST); /* Reset program to 0 */ - ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData); /* Disable EEPROM programming */ - return (TRUE); -} - -/***************************************************************************/ -void setup_SCBs(ORC_HCS * hcsp) -{ - ORC_SCB *pVirScb; - int i; - UCHAR j; - ESCB *pVirEscb; - PVOID pPhysEscb; - PVOID tPhysEscb; - - j = 0; - pVirScb = NULL; - tPhysEscb = (PVOID) NULL; - pPhysEscb = (PVOID) NULL; - /* Setup SCB HCS_Base and SCB Size registers */ - ORC_WR(hcsp->HCS_Base + ORC_SCBSIZE, orc_num_scb); /* Total number of SCBs */ - /* SCB HCS_Base address 0 */ - ORC_WRLONG(hcsp->HCS_Base + ORC_SCBBASE0, hcsp->HCS_physScbArray); - /* SCB HCS_Base address 1 */ - ORC_WRLONG(hcsp->HCS_Base + ORC_SCBBASE1, hcsp->HCS_physScbArray); - - /* setup scatter list address with one buffer */ - pVirScb = (ORC_SCB *) hcsp->HCS_virScbArray; - pVirEscb = (ESCB *) hcsp->HCS_virEscbArray; - - for (i = 0; i < orc_num_scb; i++) { -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - pPhysEscb = (PVOID) ((ULONG) hcsp->HCS_virEscbArray + (sizeof(ESCB) * i)); - pVirScb->SCB_SGPAddr = (U32) VIRT_TO_BUS(pPhysEscb); - pVirScb->SCB_SensePAddr = (U32) VIRT_TO_BUS(pPhysEscb); -#else - pPhysEscb = (PVOID) (hcsp->HCS_physEscbArray + (sizeof(ESCB) * i)); - pVirScb->SCB_SGPAddr = (U32) pPhysEscb; - pVirScb->SCB_SensePAddr = (U32) pPhysEscb; -#endif - pVirScb->SCB_EScb = pVirEscb; - pVirScb->SCB_ScbIdx = i; - pVirScb++; - pVirEscb++; - } - - return; -} - -/***************************************************************************/ -static void initAFlag(ORC_HCS * hcsp) -{ - UCHAR i, j; - - for (i = 0; i < MAX_CHANNELS; i++) { - for (j = 0; j < 8; j++) { - hcsp->BitAllocFlag[i][j] = 0xffffffff; - } - } -} - -/***************************************************************************/ -int init_orchid(ORC_HCS * hcsp) -{ - UBYTE *readBytep; - USHORT revision; - UCHAR i; - - initAFlag(hcsp); - ORC_WR(hcsp->HCS_Base + ORC_GIMSK, 0xFF); /* Disable all interrupt */ - if (ORC_RD(hcsp->HCS_Base, ORC_HSTUS) & RREADY) { /* Orchid is ready */ - revision = get_FW_version(hcsp); - if (revision == 0xFFFF) { - ORC_WR(hcsp->HCS_Base + ORC_HCTRL, DEVRST); /* Reset Host Adapter */ - if (waitChipReady(hcsp) == FALSE) - return (-1); - load_FW(hcsp); /* Download FW */ - setup_SCBs(hcsp); /* Setup SCB HCS_Base and SCB Size registers */ - ORC_WR(hcsp->HCS_Base + ORC_HCTRL, 0); /* clear HOSTSTOP */ - if (waitFWReady(hcsp) == FALSE) - return (-1); - /* Wait for firmware ready */ - } else { - setup_SCBs(hcsp); /* Setup SCB HCS_Base and SCB Size registers */ - } - } else { /* Orchid is not Ready */ - ORC_WR(hcsp->HCS_Base + ORC_HCTRL, DEVRST); /* Reset Host Adapter */ - if (waitChipReady(hcsp) == FALSE) - return (-1); - load_FW(hcsp); /* Download FW */ - setup_SCBs(hcsp); /* Setup SCB HCS_Base and SCB Size registers */ - ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO); /* Do Hardware Reset & */ - - /* clear HOSTSTOP */ - if (waitFWReady(hcsp) == FALSE) /* Wait for firmware ready */ - return (-1); - } - -/*------------- get serial EEProm settting -------*/ - - read_eeprom(hcsp); - - if (nvramp->Revision != 1) - return (-1); - - hcsp->HCS_SCSI_ID = nvramp->SCSI0Id; - hcsp->HCS_BIOS = nvramp->BIOSConfig1; - hcsp->HCS_MaxTar = MAX_TARGETS; - readBytep = (UCHAR *) & (nvramp->Target00Config); - for (i = 0; i < 16; readBytep++, i++) { - hcsp->TargetFlag[i] = *readBytep; - hcsp->MaximumTags[i] = orc_num_scb; - } /* for */ - - if (nvramp->SCSI0Config & NCC_BUSRESET) { /* Reset SCSI bus */ - hcsp->HCS_Flags |= HCF_SCSI_RESET; - } - ORC_WR(hcsp->HCS_Base + ORC_GIMSK, 0xFB); /* enable RP FIFO interrupt */ - return (0); -} - -/***************************************************************************** - Function name : orc_reset_scsi_bus - Description : Reset registers, reset a hanging bus and - kill active and disconnected commands for target w/o soft reset - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -int orc_reset_scsi_bus(ORC_HCS * pHCB) -{ /* I need Host Control Block Information */ - ULONG flags; - -#if 0 - printk("inia100: enter inia100_reset\n"); -#endif - -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - save_flags(flags); - cli(); -#else - spin_lock_irqsave(&(pHCB->BitAllocFlagLock), flags); -#endif - - initAFlag(pHCB); - /* reset scsi bus */ - ORC_WR(pHCB->HCS_Base + ORC_HCTRL, SCSIRST); - if (waitSCSIRSTdone(pHCB) == FALSE) { -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - restore_flags(flags); -#else - spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags); -#endif - return (SCSI_RESET_ERROR); - } else { -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - restore_flags(flags); -#else - spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags); -#endif - return (SCSI_RESET_SUCCESS); - } -} - -/***************************************************************************** - Function name : orc_device_reset - Description : Reset registers, reset a hanging bus and - kill active and disconnected commands for target w/o soft reset - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -int orc_device_reset(ORC_HCS * pHCB, ULONG SCpnt, unsigned int target, unsigned int ResetFlags) -{ /* I need Host Control Block Information */ - ORC_SCB *pScb; - ESCB *pVirEscb; - ORC_SCB *pVirScb; - UCHAR i; - ULONG flags; - -#if 0 - printk("inia100: enter inia100_reset\n"); -#endif - -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - save_flags(flags); - cli(); -#else - spin_lock_irqsave(&(pHCB->BitAllocFlagLock), flags); -#endif - pScb = (ORC_SCB *) NULL; - pVirEscb = (ESCB *) NULL; - - /* setup scatter list address with one buffer */ - pVirScb = (ORC_SCB *) pHCB->HCS_virScbArray; - - initAFlag(pHCB); - /* device reset */ - for (i = 0; i < orc_num_scb; i++) { - pVirEscb = pVirScb->SCB_EScb; - if ((pVirScb->SCB_Status) && (pVirEscb->SCB_Srb == (unsigned char *) SCpnt)) - break; - pVirScb++; - } - - if (i == orc_num_scb) { - printk("Unable to Reset - No SCB Found\n"); -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - restore_flags(flags); -#else - spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags); -#endif - return (SCSI_RESET_NOT_RUNNING); - } - if ((pScb = orc_alloc_scb(pHCB)) == NULL) { -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - restore_flags(flags); -#else - spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags); -#endif - return (SCSI_RESET_NOT_RUNNING); - } - pScb->SCB_Opcode = ORC_BUSDEVRST; - pScb->SCB_Target = target; - pScb->SCB_HaStat = 0; - pScb->SCB_TaStat = 0; - pScb->SCB_Status = 0x0; - pScb->SCB_Link = 0xFF; - pScb->SCB_Reserved0 = 0; - pScb->SCB_Reserved1 = 0; - pScb->SCB_XferLen = 0; - pScb->SCB_SGLen = 0; - - pVirEscb->SCB_Srb = 0; - if (ResetFlags & SCSI_RESET_SYNCHRONOUS) { - pVirEscb->SCB_Srb = (unsigned char *) SCpnt; - } - orc_exec_scb(pHCB, pScb); /* Start execute SCB */ -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - restore_flags(flags); -#else - spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags); -#endif - return SCSI_RESET_PENDING; -} - - -/***************************************************************************/ -ORC_SCB *orc_alloc_scb(ORC_HCS * hcsp) -{ - ORC_SCB *pTmpScb; - UCHAR Ch; - ULONG idx; - UCHAR index; - UCHAR i; - ULONG flags; - -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - save_flags(flags); - cli(); -#else - spin_lock_irqsave(&(hcsp->BitAllocFlagLock), flags); -#endif - Ch = hcsp->HCS_Index; - for (i = 0; i < 8; i++) { - for (index = 0; index < 32; index++) { - if ((hcsp->BitAllocFlag[Ch][i] >> index) & 0x01) { - hcsp->BitAllocFlag[Ch][i] &= ~(1 << index); - break; - } - } - idx = index + 32 * i; - pTmpScb = (PVOID) ((ULONG) hcsp->HCS_virScbArray + (idx * sizeof(ORC_SCB))); -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - restore_flags(flags); -#else - spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags); -#endif - return (pTmpScb); - } -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - restore_flags(flags); -#else - spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags); -#endif - return (NULL); -} - - -/***************************************************************************/ -void orc_release_scb(ORC_HCS * hcsp, ORC_SCB * scbp) -{ - ULONG flags; - UCHAR Index; - UCHAR i; - UCHAR Ch; - -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - save_flags(flags); - cli(); -#else - spin_lock_irqsave(&(hcsp->BitAllocFlagLock), flags); -#endif - Ch = hcsp->HCS_Index; - Index = scbp->SCB_ScbIdx; - i = Index / 32; - Index %= 32; - hcsp->BitAllocFlag[Ch][i] |= (1 << Index); -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - restore_flags(flags); -#else - spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags); -#endif -} - - -/***************************************************************************** - Function name : Addinia100_into_Adapter_table - Description : This function will scan PCI bus to get all Orchid card - Input : None. - Output : None. - Return : SUCCESSFUL - Successful scan - ohterwise - No drives founded -*****************************************************************************/ -int Addinia100_into_Adapter_table(WORD wBIOS, WORD wBASE, BYTE bInterrupt, - BYTE bBus, BYTE bDevice) -{ - unsigned int i, j; - - for (i = 0; i < MAX_SUPPORTED_ADAPTERS; i++) { - if (inia100_adpt[i].ADPT_BIOS < wBIOS) - continue; - if (inia100_adpt[i].ADPT_BIOS == wBIOS) { - if (inia100_adpt[i].ADPT_BASE == wBASE) - if (inia100_adpt[i].ADPT_Bus != 0xFF) - return (FAILURE); - else if (inia100_adpt[i].ADPT_BASE < wBASE) - continue; - } - for (j = MAX_SUPPORTED_ADAPTERS - 1; j > i; j--) { - inia100_adpt[j].ADPT_BASE = inia100_adpt[j - 1].ADPT_BASE; - inia100_adpt[j].ADPT_INTR = inia100_adpt[j - 1].ADPT_INTR; - inia100_adpt[j].ADPT_BIOS = inia100_adpt[j - 1].ADPT_BIOS; - inia100_adpt[j].ADPT_Bus = inia100_adpt[j - 1].ADPT_Bus; - inia100_adpt[j].ADPT_Device = inia100_adpt[j - 1].ADPT_Device; - } - inia100_adpt[i].ADPT_BASE = wBASE; - inia100_adpt[i].ADPT_INTR = bInterrupt; - inia100_adpt[i].ADPT_BIOS = wBIOS; - inia100_adpt[i].ADPT_Bus = bBus; - inia100_adpt[i].ADPT_Device = bDevice; - return (SUCCESSFUL); - } - return (FAILURE); -} - - -/***************************************************************************** - Function name : init_inia100Adapter_table - Description : This function will scan PCI bus to get all Orchid card - Input : None. - Output : None. - Return : SUCCESSFUL - Successful scan - ohterwise - No drives founded -*****************************************************************************/ -void init_inia100Adapter_table(void) -{ - int i; - - for (i = 0; i < MAX_SUPPORTED_ADAPTERS; i++) { /* Initialize adapter structure */ - inia100_adpt[i].ADPT_BIOS = 0xffff; - inia100_adpt[i].ADPT_BASE = 0xffff; - inia100_adpt[i].ADPT_INTR = 0xff; - inia100_adpt[i].ADPT_Bus = 0xff; - inia100_adpt[i].ADPT_Device = 0xff; - } -} - -/***************************************************************************** - Function name : get_orcPCIConfig - Description : - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -void get_orcPCIConfig(ORC_HCS * pCurHcb, int ch_idx) -{ - pCurHcb->HCS_Base = inia100_adpt[ch_idx].ADPT_BASE; /* Supply base address */ - pCurHcb->HCS_BIOS = inia100_adpt[ch_idx].ADPT_BIOS; /* Supply BIOS address */ - pCurHcb->HCS_Intr = inia100_adpt[ch_idx].ADPT_INTR; /* Supply interrupt line */ - return; -} - - -/***************************************************************************** - Function name : abort_SCB - Description : Abort a queued command. - (commands that are on the bus can't be aborted easily) - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -int abort_SCB(ORC_HCS * hcsp, ORC_SCB * pScb) -{ - unsigned char bData, bStatus; - - ORC_WR(hcsp->HCS_Base + ORC_HDATA, ORC_CMD_ABORT_SCB); /* Write command */ - ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO); - if (waitHDOoff(hcsp) == FALSE) /* Wait HDO off */ - return (FALSE); - - ORC_WR(hcsp->HCS_Base + ORC_HDATA, pScb->SCB_ScbIdx); /* Write address */ - ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO); - if (waitHDOoff(hcsp) == FALSE) /* Wait HDO off */ - return (FALSE); - - if (waitHDIset(hcsp, &bData) == FALSE) /* Wait HDI set */ - return (FALSE); - bStatus = ORC_RD(hcsp->HCS_Base, ORC_HDATA); - ORC_WR(hcsp->HCS_Base + ORC_HSTUS, bData); /* Clear HDI */ - - if (bStatus == 1) /* 0 - Successfully */ - return (FALSE); /* 1 - Fail */ - return (TRUE); -} - -/***************************************************************************** - Function name : inia100_abort - Description : Abort a queued command. - (commands that are on the bus can't be aborted easily) - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -int orc_abort_srb(ORC_HCS * hcsp, ULONG SCpnt) -{ - ESCB *pVirEscb; - ORC_SCB *pVirScb; - UCHAR i; - ULONG flags; - -#if 0 - printk("inia100: abort SRB \n"); -#endif -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - save_flags(flags); - cli(); -#else - spin_lock_irqsave(&(hcsp->BitAllocFlagLock), flags); -#endif - - pVirScb = (ORC_SCB *) hcsp->HCS_virScbArray; - - for (i = 0; i < orc_num_scb; i++, pVirScb++) { - pVirEscb = pVirScb->SCB_EScb; - if ((pVirScb->SCB_Status) && (pVirEscb->SCB_Srb == (unsigned char *) SCpnt)) { - if (pVirScb->SCB_TagMsg == 0) { -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - restore_flags(flags); -#else - spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags); -#endif - return (SCSI_ABORT_BUSY); - } else { - if (abort_SCB(hcsp, pVirScb)) { - pVirEscb->SCB_Srb = NULL; -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - restore_flags(flags); -#else - spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags); -#endif - return (SCSI_ABORT_SUCCESS); - } else { -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - restore_flags(flags); -#else - spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags); -#endif - return (SCSI_ABORT_NOT_RUNNING); - } - } - } - } -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2,1,95) - restore_flags(flags); -#else - spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags); -#endif - return (SCSI_ABORT_NOT_RUNNING); -} - -/*********************************************************************** - Routine Description: - This is the interrupt service routine for the Orchid SCSI adapter. - It reads the interrupt register to determine if the adapter is indeed - the source of the interrupt and clears the interrupt at the device. - Arguments: - HwDeviceExtension - HBA miniport driver's adapter data storage - Return Value: -***********************************************************************/ -void orc_interrupt( - ORC_HCS * hcsp -) -{ - BYTE bScbIdx; - ORC_SCB *pScb; - - if (ORC_RD(hcsp->HCS_Base, ORC_RQUEUECNT) == 0) { - return; // (FALSE); - - } - do { - bScbIdx = ORC_RD(hcsp->HCS_Base, ORC_RQUEUE); - - pScb = (ORC_SCB *) ((ULONG) hcsp->HCS_virScbArray + (ULONG) (sizeof(ORC_SCB) * bScbIdx)); - pScb->SCB_Status = 0x0; - - inia100SCBPost((BYTE *) hcsp, (BYTE *) pScb); - } while (ORC_RD(hcsp->HCS_Base, ORC_RQUEUECNT)); - return; //(TRUE); - -} /* End of I1060Interrupt() */ diff --git a/drivers/scsi/i60uscsi.h b/drivers/scsi/i60uscsi.h deleted file mode 100644 index 1c48c6e17f71..000000000000 --- a/drivers/scsi/i60uscsi.h +++ /dev/null @@ -1,572 +0,0 @@ -/************************************************************************** - * Initio A100 device driver for Linux. - * - * Copyright (c) 1994-1998 Initio Corporation - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * -------------------------------------------------------------------------- - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification, immediately at the beginning of the file. - * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * Where this Software is combined with software released under the terms of - * the GNU Public License ("GPL") and the terms of the GPL would require the - * combined work to also be released under the terms of the GPL, the terms - * and conditions of this License will apply in addition to those of the - * GPL with the exception of any terms or conditions of this License that - * conflict with, or are expressly prohibited by, the GPL. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - ************************************************************************** - * - * Module: inia100.h - * Description: INI-A100U2W LINUX device driver header - * Revision History: - * 06/18/98 HL, Initial Version 1.02 - * 12/19/98 bv, v1.02a Use spinlocks for 2.1.95 and up. - **************************************************************************/ - -#define ULONG unsigned long -#define PVOID void * -#define USHORT unsigned short -#define UCHAR unsigned char -#define BYTE unsigned char -#define WORD unsigned short -#define DWORD unsigned long -#define UBYTE unsigned char -#define UWORD unsigned short -#define UDWORD unsigned long -#ifdef ALPHA -#define U32 unsigned int -#else -#define U32 unsigned long -#endif - -#ifndef NULL -#define NULL 0 /* zero */ -#endif -#ifndef TRUE -#define TRUE (1) /* boolean true */ -#endif -#ifndef FALSE -#define FALSE (0) /* boolean false */ -#endif -#ifndef FAILURE -#define FAILURE (-1) -#endif -#if 1 -#define ORC_MAXQUEUE 245 -#else -#define ORC_MAXQUEUE 25 -#endif - -#define TOTAL_SG_ENTRY 32 -#define MAX_TARGETS 16 -#define IMAX_CDB 15 -#define SENSE_SIZE 14 -#define MAX_SUPPORTED_ADAPTERS 4 -#define SUCCESSFUL 0x00 - -#define I920_DEVICE_ID 0x0002 /* Initio's inic-950 product ID */ - -/************************************************************************/ -/* Scatter-Gather Element Structure */ -/************************************************************************/ -typedef struct ORC_SG_Struc { - U32 SG_Ptr; /* Data Pointer */ - U32 SG_Len; /* Data Length */ -} ORC_SG; - -typedef struct inia100_Adpt_Struc { - UWORD ADPT_BIOS; /* 0 */ - UWORD ADPT_BASE; /* 1 */ - UBYTE ADPT_Bus; /* 2 */ - UBYTE ADPT_Device; /* 3 */ - UBYTE ADPT_INTR; /* 4 */ -} INIA100_ADPT_STRUCT; - - -/* SCSI related definition */ -#define DISC_NOT_ALLOW 0x80 /* Disconnect is not allowed */ -#define DISC_ALLOW 0xC0 /* Disconnect is allowed */ - - -#define ORC_OFFSET_SCB 16 -#define ORC_MAX_SCBS 250 -#define MAX_CHANNELS 2 -#define MAX_ESCB_ELE 64 -#define TCF_DRV_255_63 0x0400 - -/********************************************************/ -/* Orchid Configuration Register Set */ -/********************************************************/ -#define ORC_PVID 0x00 /* Vendor ID */ -#define ORC_VENDOR_ID 0x1101 /* Orchid vendor ID */ -#define ORC_PDID 0x02 /* Device ID */ -#define ORC_DEVICE_ID 0x1060 /* Orchid device ID */ -#define ORC_COMMAND 0x04 /* Command */ -#define BUSMS 0x04 /* BUS MASTER Enable */ -#define IOSPA 0x01 /* IO Space Enable */ -#define ORC_STATUS 0x06 /* Status register */ -#define ORC_REVISION 0x08 /* Revision number */ -#define ORC_BASE 0x10 /* Base address */ -#define ORC_BIOS 0x50 /* Expansion ROM base address */ -#define ORC_INT_NUM 0x3C /* Interrupt line */ -#define ORC_INT_PIN 0x3D /* Interrupt pin */ - - -/********************************************************/ -/* Orchid Host Command Set */ -/********************************************************/ -#define ORC_CMD_NOP 0x00 /* Host command - NOP */ -#define ORC_CMD_VERSION 0x01 /* Host command - Get F/W version */ -#define ORC_CMD_ECHO 0x02 /* Host command - ECHO */ -#define ORC_CMD_SET_NVM 0x03 /* Host command - Set NVRAM */ -#define ORC_CMD_GET_NVM 0x04 /* Host command - Get NVRAM */ -#define ORC_CMD_GET_BUS_STATUS 0x05 /* Host command - Get SCSI bus status */ -#define ORC_CMD_ABORT_SCB 0x06 /* Host command - Abort SCB */ -#define ORC_CMD_ISSUE_SCB 0x07 /* Host command - Issue SCB */ - -/********************************************************/ -/* Orchid Register Set */ -/********************************************************/ -#define ORC_GINTS 0xA0 /* Global Interrupt Status */ -#define QINT 0x04 /* Reply Queue Interrupt */ -#define ORC_GIMSK 0xA1 /* Global Interrupt MASK */ -#define MQINT 0x04 /* Mask Reply Queue Interrupt */ -#define ORC_GCFG 0xA2 /* Global Configure */ -#define EEPRG 0x01 /* Enable EEPROM programming */ -#define ORC_GSTAT 0xA3 /* Global status */ -#define WIDEBUS 0x10 /* Wide SCSI Devices connected */ -#define ORC_HDATA 0xA4 /* Host Data */ -#define ORC_HCTRL 0xA5 /* Host Control */ -#define SCSIRST 0x80 /* SCSI bus reset */ -#define HDO 0x40 /* Host data out */ -#define HOSTSTOP 0x02 /* Host stop RISC engine */ -#define DEVRST 0x01 /* Device reset */ -#define ORC_HSTUS 0xA6 /* Host Status */ -#define HDI 0x02 /* Host data in */ -#define RREADY 0x01 /* RISC engine is ready to receive */ -#define ORC_NVRAM 0xA7 /* Nvram port address */ -#define SE2CS 0x008 -#define SE2CLK 0x004 -#define SE2DO 0x002 -#define SE2DI 0x001 -#define ORC_PQUEUE 0xA8 /* Posting queue FIFO */ -#define ORC_PQCNT 0xA9 /* Posting queue FIFO Cnt */ -#define ORC_RQUEUE 0xAA /* Reply queue FIFO */ -#define ORC_RQUEUECNT 0xAB /* Reply queue FIFO Cnt */ -#define ORC_FWBASEADR 0xAC /* Firmware base address */ - -#define ORC_EBIOSADR0 0xB0 /* External Bios address */ -#define ORC_EBIOSADR1 0xB1 /* External Bios address */ -#define ORC_EBIOSADR2 0xB2 /* External Bios address */ -#define ORC_EBIOSDATA 0xB3 /* External Bios address */ - -#define ORC_SCBSIZE 0xB7 /* SCB size register */ -#define ORC_SCBBASE0 0xB8 /* SCB base address 0 */ -#define ORC_SCBBASE1 0xBC /* SCB base address 1 */ - -#define ORC_RISCCTL 0xE0 /* RISC Control */ -#define PRGMRST 0x002 -#define DOWNLOAD 0x001 -#define ORC_PRGMCTR0 0xE2 /* RISC program counter */ -#define ORC_PRGMCTR1 0xE3 /* RISC program counter */ -#define ORC_RISCRAM 0xEC /* RISC RAM data port 4 bytes */ - -typedef struct orc_extended_scb { /* Extended SCB */ - ORC_SG ESCB_SGList[TOTAL_SG_ENTRY]; /*0 Start of SG list */ - unsigned char *SCB_Srb; /*50 SRB Pointer */ -// Scsi_Cmnd *SCB_Srb; /*50 SRB Pointer */ -} ESCB; - -/*********************************************************************** - SCSI Control Block -************************************************************************/ -typedef struct orc_scb { /* Scsi_Ctrl_Blk */ - UBYTE SCB_Opcode; /*00 SCB command code&residual */ - UBYTE SCB_Flags; /*01 SCB Flags */ - UBYTE SCB_Target; /*02 Target Id */ - UBYTE SCB_Lun; /*03 Lun */ - U32 SCB_Reserved0; /*04 Reserved for ORCHID must 0 */ - U32 SCB_XferLen; /*08 Data Transfer Length */ - U32 SCB_Reserved1; /*0C Reserved for ORCHID must 0 */ - U32 SCB_SGLen; /*10 SG list # * 8 */ - U32 SCB_SGPAddr; /*14 SG List Buf physical Addr */ - U32 SCB_SGPAddrHigh; /*18 SG Buffer high physical Addr */ - UBYTE SCB_HaStat; /*1C Host Status */ - UBYTE SCB_TaStat; /*1D Target Status */ - UBYTE SCB_Status; /*1E SCB status */ - UBYTE SCB_Link; /*1F Link pointer, default 0xFF */ - UBYTE SCB_SenseLen; /*20 Sense Allocation Length */ - UBYTE SCB_CDBLen; /*21 CDB Length */ - UBYTE SCB_Ident; /*22 Identify */ - UBYTE SCB_TagMsg; /*23 Tag Message */ - UBYTE SCB_CDB[IMAX_CDB]; /*24 SCSI CDBs */ - UBYTE SCB_ScbIdx; /*3C Index for this ORCSCB */ - U32 SCB_SensePAddr; /*34 Sense Buffer physical Addr */ - - ESCB *SCB_EScb; /*38 Extended SCB Pointer */ -#ifndef ALPHA - UBYTE SCB_Reserved2[4]; /*3E Reserved for Driver use */ -#endif -} ORC_SCB; - -/* Opcodes of ORCSCB_Opcode */ -#define ORC_EXECSCSI 0x00 /* SCSI initiator command with residual */ -#define ORC_BUSDEVRST 0x01 /* SCSI Bus Device Reset */ - -/* Status of ORCSCB_Status */ -#define SCB_COMPLETE 0x00 /* SCB request completed */ -#define SCB_POST 0x01 /* SCB is posted by the HOST */ - -/* Bit Definition for ORCSCB_Flags */ -#define SCF_DISINT 0x01 /* Disable HOST interrupt */ -#define SCF_DIR 0x18 /* Direction bits */ -#define SCF_NO_DCHK 0x00 /* Direction determined by SCSI */ -#define SCF_DIN 0x08 /* From Target to Initiator */ -#define SCF_DOUT 0x10 /* From Initiator to Target */ -#define SCF_NO_XF 0x18 /* No data transfer */ -#define SCF_POLL 0x40 - -/* Error Codes for ORCSCB_HaStat */ -#define HOST_SEL_TOUT 0x11 -#define HOST_DO_DU 0x12 -#define HOST_BUS_FREE 0x13 -#define HOST_BAD_PHAS 0x14 -#define HOST_INV_CMD 0x16 -#define HOST_SCSI_RST 0x1B -#define HOST_DEV_RST 0x1C - - -/* Error Codes for ORCSCB_TaStat */ -#define TARGET_CHK_COND 0x02 -#define TARGET_BUSY 0x08 -#define TARGET_TAG_FULL 0x28 - - -/* Queue tag msg: Simple_quque_tag, Head_of_queue_tag, Ordered_queue_tag */ -#define MSG_STAG 0x20 -#define MSG_HTAG 0x21 -#define MSG_OTAG 0x22 - -#define MSG_IGNOREWIDE 0x23 - -#define MSG_IDENT 0x80 -#define MSG_DISC 0x40 /* Disconnect allowed */ - - -/* SCSI MESSAGE */ -#define MSG_EXTEND 0x01 -#define MSG_SDP 0x02 -#define MSG_ABORT 0x06 -#define MSG_REJ 0x07 -#define MSG_NOP 0x08 -#define MSG_PARITY 0x09 -#define MSG_DEVRST 0x0C -#define MSG_STAG 0x20 - -/*********************************************************************** - Target Device Control Structure -**********************************************************************/ - -typedef struct ORC_Tar_Ctrl_Struc { - UBYTE TCS_DrvDASD; /* 6 */ - UBYTE TCS_DrvSCSI; /* 7 */ - UBYTE TCS_DrvHead; /* 8 */ - UWORD TCS_DrvFlags; /* 4 */ - UBYTE TCS_DrvSector; /* 7 */ -} ORC_TCS, *PORC_TCS; - -/* Bit Definition for TCF_DrvFlags */ -#define TCS_DF_NODASD_SUPT 0x20 /* Suppress OS/2 DASD Mgr support */ -#define TCS_DF_NOSCSI_SUPT 0x40 /* Suppress OS/2 SCSI Mgr support */ - - -/*********************************************************************** - Host Adapter Control Structure -************************************************************************/ -typedef struct ORC_Ha_Ctrl_Struc { - USHORT HCS_Base; /* 00 */ - UBYTE HCS_Index; /* 02 */ - UBYTE HCS_Intr; /* 04 */ - UBYTE HCS_SCSI_ID; /* 06 H/A SCSI ID */ - UBYTE HCS_BIOS; /* 07 BIOS configuration */ - - UBYTE HCS_Flags; /* 0B */ - UBYTE HCS_HAConfig1; /* 1B SCSI0MAXTags */ - UBYTE HCS_MaxTar; /* 1B SCSI0MAXTags */ - - USHORT HCS_Units; /* Number of units this adapter */ - USHORT HCS_AFlags; /* Adapter info. defined flags */ - ULONG HCS_Timeout; /* Adapter timeout value */ - PVOID HCS_virScbArray; /* 28 Virtual Pointer to SCB array */ - U32 HCS_physScbArray; /* Scb Physical address */ - PVOID HCS_virEscbArray; /* Virtual pointer to ESCB Scatter list */ - U32 HCS_physEscbArray; /* scatter list Physical address */ - UBYTE TargetFlag[16]; /* 30 target configuration, TCF_EN_TAG */ - UBYTE MaximumTags[16]; /* 40 ORC_MAX_SCBS */ - UBYTE ActiveTags[16][16]; /* 50 */ - ORC_TCS HCS_Tcs[16]; /* 28 */ - U32 BitAllocFlag[MAX_CHANNELS][8]; /* Max STB is 256, So 256/32 */ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spinlock_t BitAllocFlagLock; -#endif - ULONG pSRB_head; - ULONG pSRB_tail; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spinlock_t pSRB_lock; -#endif -} ORC_HCS; - -/* Bit Definition for HCS_Flags */ - -#define HCF_SCSI_RESET 0x01 /* SCSI BUS RESET */ -#define HCF_PARITY 0x02 /* parity card */ -#define HCF_LVDS 0x10 /* parity card */ - -/* Bit Definition for TargetFlag */ - -#define TCF_EN_255 0x08 -#define TCF_EN_TAG 0x10 -#define TCF_BUSY 0x20 -#define TCF_DISCONNECT 0x40 -#define TCF_SPIN_UP 0x80 - -/* Bit Definition for HCS_AFlags */ -#define HCS_AF_IGNORE 0x01 /* Adapter ignore */ -#define HCS_AF_DISABLE_RESET 0x10 /* Adapter disable reset */ -#define HCS_AF_DISABLE_ADPT 0x80 /* Adapter disable */ - - -/*---------------------------------------*/ -/* TimeOut for RESET to complete (30s) */ -/* */ -/* After a RESET the drive is checked */ -/* every 200ms. */ -/*---------------------------------------*/ -#define DELAYED_RESET_MAX (30*1000L) -#define DELAYED_RESET_INTERVAL 200L - -/*----------------------------------------------*/ -/* TimeOut for IRQ from last interrupt (5s) */ -/*----------------------------------------------*/ -#define IRQ_TIMEOUT_INTERVAL (5*1000L) - -/*----------------------------------------------*/ -/* Retry Delay interval (200ms) */ -/*----------------------------------------------*/ -#define DELAYED_RETRY_INTERVAL 200L - -#define INQUIRY_SIZE 36 -#define CAPACITY_SIZE 8 -#define DEFAULT_SENSE_LEN 14 - -#define DEVICE_NOT_FOUND 0x86 - -/*----------------------------------------------*/ -/* Definition for PCI device */ -/*----------------------------------------------*/ -#define MAX_PCI_DEVICES 21 -#define MAX_PCI_BUSES 8 - -typedef struct Adpt_Struc { - USHORT ADPT_BIOS; /* 0 */ - UBYTE ADPT_BASE; /* 1 */ - UBYTE ADPT_Bus; /* 2 */ - UBYTE ADPT_Device; /* 3 */ - UBYTE ADPT_Reserved[3]; -} JACS, *PJACS; - -typedef struct _NVRAM { -/*----------header ---------------*/ - UCHAR SubVendorID0; /* 00 - Sub Vendor ID */ - UCHAR SubVendorID1; /* 00 - Sub Vendor ID */ - UCHAR SubSysID0; /* 02 - Sub System ID */ - UCHAR SubSysID1; /* 02 - Sub System ID */ - UCHAR SubClass; /* 04 - Sub Class */ - UCHAR VendorID0; /* 05 - Vendor ID */ - UCHAR VendorID1; /* 05 - Vendor ID */ - UCHAR DeviceID0; /* 07 - Device ID */ - UCHAR DeviceID1; /* 07 - Device ID */ - UCHAR Reserved0[2]; /* 09 - Reserved */ - UCHAR Revision; /* 0B - Revision of data structure */ - /* ----Host Adapter Structure ---- */ - UCHAR NumOfCh; /* 0C - Number of SCSI channel */ - UCHAR BIOSConfig1; /* 0D - BIOS configuration 1 */ - UCHAR BIOSConfig2; /* 0E - BIOS boot channel&target ID */ - UCHAR BIOSConfig3; /* 0F - BIOS configuration 3 */ - /* ----SCSI channel Structure ---- */ - /* from "CTRL-I SCSI Host Adapter SetUp menu " */ - UCHAR SCSI0Id; /* 10 - Channel 0 SCSI ID */ - UCHAR SCSI0Config; /* 11 - Channel 0 SCSI configuration */ - UCHAR SCSI0MaxTags; /* 12 - Channel 0 Maximum tags */ - UCHAR SCSI0ResetTime; /* 13 - Channel 0 Reset recovering time */ - UCHAR ReservedforChannel0[2]; /* 14 - Reserved */ - - /* ----SCSI target Structure ---- */ - /* from "CTRL-I SCSI device SetUp menu " */ - UCHAR Target00Config; /* 16 - Channel 0 Target 0 config */ - UCHAR Target01Config; /* 17 - Channel 0 Target 1 config */ - UCHAR Target02Config; /* 18 - Channel 0 Target 2 config */ - UCHAR Target03Config; /* 19 - Channel 0 Target 3 config */ - UCHAR Target04Config; /* 1A - Channel 0 Target 4 config */ - UCHAR Target05Config; /* 1B - Channel 0 Target 5 config */ - UCHAR Target06Config; /* 1C - Channel 0 Target 6 config */ - UCHAR Target07Config; /* 1D - Channel 0 Target 7 config */ - UCHAR Target08Config; /* 1E - Channel 0 Target 8 config */ - UCHAR Target09Config; /* 1F - Channel 0 Target 9 config */ - UCHAR Target0AConfig; /* 20 - Channel 0 Target A config */ - UCHAR Target0BConfig; /* 21 - Channel 0 Target B config */ - UCHAR Target0CConfig; /* 22 - Channel 0 Target C config */ - UCHAR Target0DConfig; /* 23 - Channel 0 Target D config */ - UCHAR Target0EConfig; /* 24 - Channel 0 Target E config */ - UCHAR Target0FConfig; /* 25 - Channel 0 Target F config */ - - UCHAR SCSI1Id; /* 26 - Channel 1 SCSI ID */ - UCHAR SCSI1Config; /* 27 - Channel 1 SCSI configuration */ - UCHAR SCSI1MaxTags; /* 28 - Channel 1 Maximum tags */ - UCHAR SCSI1ResetTime; /* 29 - Channel 1 Reset recovering time */ - UCHAR ReservedforChannel1[2]; /* 2A - Reserved */ - - /* ----SCSI target Structure ---- */ - /* from "CTRL-I SCSI device SetUp menu " */ - UCHAR Target10Config; /* 2C - Channel 1 Target 0 config */ - UCHAR Target11Config; /* 2D - Channel 1 Target 1 config */ - UCHAR Target12Config; /* 2E - Channel 1 Target 2 config */ - UCHAR Target13Config; /* 2F - Channel 1 Target 3 config */ - UCHAR Target14Config; /* 30 - Channel 1 Target 4 config */ - UCHAR Target15Config; /* 31 - Channel 1 Target 5 config */ - UCHAR Target16Config; /* 32 - Channel 1 Target 6 config */ - UCHAR Target17Config; /* 33 - Channel 1 Target 7 config */ - UCHAR Target18Config; /* 34 - Channel 1 Target 8 config */ - UCHAR Target19Config; /* 35 - Channel 1 Target 9 config */ - UCHAR Target1AConfig; /* 36 - Channel 1 Target A config */ - UCHAR Target1BConfig; /* 37 - Channel 1 Target B config */ - UCHAR Target1CConfig; /* 38 - Channel 1 Target C config */ - UCHAR Target1DConfig; /* 39 - Channel 1 Target D config */ - UCHAR Target1EConfig; /* 3A - Channel 1 Target E config */ - UCHAR Target1FConfig; /* 3B - Channel 1 Target F config */ - UCHAR reserved[3]; /* 3C - Reserved */ - /* ---------- CheckSum ---------- */ - UCHAR CheckSum; /* 3F - Checksum of NVRam */ -} NVRAM, *PNVRAM; - -/* Bios Configuration for nvram->BIOSConfig1 */ -#define NBC_BIOSENABLE 0x01 /* BIOS enable */ -#define NBC_CDROM 0x02 /* Support bootable CDROM */ -#define NBC_REMOVABLE 0x04 /* Support removable drive */ - -/* Bios Configuration for nvram->BIOSConfig2 */ -#define NBB_TARGET_MASK 0x0F /* Boot SCSI target ID number */ -#define NBB_CHANL_MASK 0xF0 /* Boot SCSI channel number */ - -/* Bit definition for nvram->SCSIConfig */ -#define NCC_BUSRESET 0x01 /* Reset SCSI bus at power up */ -#define NCC_PARITYCHK 0x02 /* SCSI parity enable */ -#define NCC_LVDS 0x10 /* Enable LVDS */ -#define NCC_ACTTERM1 0x20 /* Enable active terminator 1 */ -#define NCC_ACTTERM2 0x40 /* Enable active terminator 2 */ -#define NCC_AUTOTERM 0x80 /* Enable auto termination */ - -/* Bit definition for nvram->TargetxConfig */ -#define NTC_PERIOD 0x07 /* Maximum Sync. Speed */ -#define NTC_1GIGA 0x08 /* 255 head / 63 sectors (64/32) */ -#define NTC_NO_SYNC 0x10 /* NO SYNC. NEGO */ -#define NTC_NO_WIDESYNC 0x20 /* NO WIDE SYNC. NEGO */ -#define NTC_DISC_ENABLE 0x40 /* Enable SCSI disconnect */ -#define NTC_SPINUP 0x80 /* Start disk drive */ - -/* Default NVRam values */ -#define NBC_DEFAULT (NBC_ENABLE) -#define NCC_DEFAULT (NCC_BUSRESET | NCC_AUTOTERM | NCC_PARITYCHK) -#define NCC_MAX_TAGS 0x20 /* Maximum tags per target */ -#define NCC_RESET_TIME 0x0A /* SCSI RESET recovering time */ -#define NTC_DEFAULT (NTC_1GIGA | NTC_NO_WIDESYNC | NTC_DISC_ENABLE) - -typedef union { /* Union define for mechanism 1 */ - struct { - unsigned char RegNum; - unsigned char FcnNum:3; - unsigned char DeviceNum:5; - unsigned char BusNum; - unsigned char Reserved:7; - unsigned char Enable:1; - } sConfigAdr; - unsigned long lConfigAdr; -} CONFIG_ADR; - -typedef union { /* Union define for mechanism 2 */ - struct { - unsigned char RegNum; - unsigned char DeviceNum; - unsigned short Reserved; - } sHostAdr; - unsigned long lHostAdr; -} HOST_ADR; - -#define ORC_RD(x,y) (UCHAR)(inb( (int)((ULONG)((ULONG)x+(UCHAR)y)) )) -#define ORC_RDLONG(x,y) (long)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) )) - -#define ORC_WR( adr,data) outb( (UCHAR)(data), (int)(adr)) -#define ORC_WRSHORT(adr,data) outw( (UWORD)(data), (int)(adr)) -#define ORC_WRLONG( adr,data) outl( (ULONG)(data), (int)(adr)) - - -#define SCSI_ABORT_SNOOZE 0 -#define SCSI_ABORT_SUCCESS 1 -#define SCSI_ABORT_PENDING 2 -#define SCSI_ABORT_BUSY 3 -#define SCSI_ABORT_NOT_RUNNING 4 -#define SCSI_ABORT_ERROR 5 - -#define SCSI_RESET_SNOOZE 0 -#define SCSI_RESET_PUNT 1 -#define SCSI_RESET_SUCCESS 2 -#define SCSI_RESET_PENDING 3 -#define SCSI_RESET_WAKEUP 4 -#define SCSI_RESET_NOT_RUNNING 5 -#define SCSI_RESET_ERROR 6 - -#define SCSI_RESET_SYNCHRONOUS 0x01 -#define SCSI_RESET_ASYNCHRONOUS 0x02 -#define SCSI_RESET_SUGGEST_BUS_RESET 0x04 -#define SCSI_RESET_SUGGEST_HOST_RESET 0x08 - -#define SCSI_RESET_BUS_RESET 0x100 -#define SCSI_RESET_HOST_RESET 0x200 -#define SCSI_RESET_ACTION 0xff diff --git a/drivers/scsi/i91uscsi.c b/drivers/scsi/i91uscsi.c index 088a2f19e9fd..1a0c947ce0c2 100644 --- a/drivers/scsi/i91uscsi.c +++ b/drivers/scsi/i91uscsi.c @@ -2,7 +2,6 @@ * Initio 9100 device driver for Linux. * * Copyright (c) 1994-1998 Initio Corporation - * Copyright (c) 1998 Bas Vermeulen * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -65,13 +64,6 @@ 07/08/98 hc, Support 0002134A 07/23/98 wh, Change the abort_srb routine. 09/16/98 hl, Support ALPHA, Rewrite the returnNumberAdapters <01> - 12/09/98 bv, Removed unused code, changed tul_se2_wait to - use udelay(30) and tul_do_pause to enable - interrupts for >= 2.1.95 - 12/13/98 bv, Use spinlocks instead of cli() for serialized - access to HCS_Semaph, HCS_FirstAvail and HCS_LastAvail - members of the HCS structure. - 01/09/98 bv, Fix a deadlock on SMP system. **********************************************************************/ #define DEBUG_INTERRUPT 0 @@ -83,104 +75,119 @@ #ifndef CVT_LINUX_VERSION #define CVT_LINUX_VERSION(V,P,S) (V * 65536 + P * 256 + S) #endif +#if 0 +#include "../block/blk.h" +#include +#include "scsi.h" +#include "hosts.h" +#include "constants.h" +#include "i91uscsi.h" -#ifndef LINUX_VERSION_CODE -#include #endif - +#if 1 #include -#include -#include +/*#include */ #include - +/*#include "hosts.h"*/ +/*#include "scsi.h"*/ #include "i91uscsi.h" +#endif /*--- external functions --*/ -static void tul_se2_wait(void); +static void tul_se2_wait(void); +/*extern void tul_do_pause(unsigned int);*/ /*--- forward refrence ---*/ -static SCB *tul_find_busy_scb(HCS * pCurHcb, WORD tarlun); -static SCB *tul_find_done_scb(HCS * pCurHcb); - -static int tulip_main(HCS * pCurHcb); - -static int tul_next_state(HCS * pCurHcb); -static int tul_state_1(HCS * pCurHcb); -static int tul_state_2(HCS * pCurHcb); -static int tul_state_3(HCS * pCurHcb); -static int tul_state_4(HCS * pCurHcb); -static int tul_state_5(HCS * pCurHcb); -static int tul_state_6(HCS * pCurHcb); -static int tul_state_7(HCS * pCurHcb); -static int tul_xfer_data_in(HCS * pCurHcb); -static int tul_xfer_data_out(HCS * pCurHcb); -static int tul_xpad_in(HCS * pCurHcb); -static int tul_xpad_out(HCS * pCurHcb); -static int tul_status_msg(HCS * pCurHcb); - -static int tul_msgin(HCS * pCurHcb); -static int tul_msgin_sync(HCS * pCurHcb); -static int tul_msgin_accept(HCS * pCurHcb); -static int tul_msgout_reject(HCS * pCurHcb); -static int tul_msgin_extend(HCS * pCurHcb); - -static int tul_msgout_ide(HCS * pCurHcb); -static int tul_msgout_abort_targ(HCS * pCurHcb); -static int tul_msgout_abort_tag(HCS * pCurHcb); - -static int tul_bus_device_reset(HCS * pCurHcb); -static void tul_select_atn(HCS * pCurHcb, SCB * pCurScb); -static void tul_select_atn3(HCS * pCurHcb, SCB * pCurScb); -static void tul_select_atn_stop(HCS * pCurHcb, SCB * pCurScb); -static int int_tul_busfree(HCS * pCurHcb); -int int_tul_scsi_rst(HCS * pCurHcb); -static int int_tul_bad_seq(HCS * pCurHcb); -static int int_tul_resel(HCS * pCurHcb); -static int tul_sync_done(HCS * pCurHcb); -static int wdtr_done(HCS * pCurHcb); -static int wait_tulip(HCS * pCurHcb); -static int tul_wait_done_disc(HCS * pCurHcb); -static int tul_wait_disc(HCS * pCurHcb); -static void tulip_scsi(HCS * pCurHcb); -static int tul_post_scsi_rst(HCS * pCurHcb); - -static void tul_se2_ew_en(WORD CurBase); -static void tul_se2_ew_ds(WORD CurBase); -static int tul_se2_rd_all(WORD CurBase); -static void tul_se2_update_all(WORD CurBase); /* setup default pattern */ -static void tul_read_eeprom(WORD CurBase); +static SCB *tul_find_busy_scb(HCS *pCurHcb, WORD tarlun); +static SCB *tul_find_done_scb(HCS *pCurHcb); + +static int tulip_main(HCS *pCurHcb); +/* static int init_tulip(HCS *pCurHcb, SCB *pCurScb, int ch_idx);*/ + +static int tul_next_state(HCS *pCurHcb); +static int tul_state_1(HCS *pCurHcb); +static int tul_state_2(HCS *pCurHcb); +static int tul_state_3(HCS *pCurHcb); +static int tul_state_4(HCS *pCurHcb); +static int tul_state_5(HCS *pCurHcb); +static int tul_state_6(HCS *pCurHcb); +static int tul_state_7(HCS *pCurHcb); +static int tul_xfer_data_in(HCS *pCurHcb); +static int tul_xfer_data_out(HCS *pCurHcb); +static int tul_xpad_in(HCS *pCurHcb); +static int tul_xpad_out(HCS *pCurHcb); +static int tul_status_msg(HCS *pCurHcb); +/*static int tul_bad_seq(HCS *pCurHcb); 10/13/97 */ + +static int tul_msgin(HCS *pCurHcb); +static int tul_msgin_sync(HCS *pCurHcb); +static int tul_msgin_accept(HCS *pCurHcb); +static int tul_msgout_reject(HCS *pCurHcb); +static int tul_msgin_extend(HCS *pCurHcb); + +static int tul_msgout_ide(HCS *pCurHcb); +static int tul_msgout_abort_targ(HCS *pCurHcb); +static int tul_msgout_abort_tag(HCS *pCurHcb); + +static int tul_bus_device_reset(HCS *pCurHcb); +static void tul_select_atn(HCS *pCurHcb, SCB *pCurScb); +static void tul_select_atn3(HCS *pCurHcb, SCB *pCurScb); +static void tul_select_atn_stop(HCS *pCurHcb, SCB *pCurScb); +//static int tul_reset_scsi(HCS *pCurHcb, int seconds); +static int int_tul_busfree(HCS *pCurHcb); +#if 0 +static int int_tul_scsi_rst(HCS *pCurHcb); +#else +int int_tul_scsi_rst(HCS *pCurHcb); +#endif +static int int_tul_bad_seq(HCS *pCurHcb); +static int int_tul_resel(HCS *pCurHcb); +static int tul_sync_done(HCS *pCurHcb); +static int wdtr_done(HCS *pCurHcb); +static int wait_tulip(HCS *pCurHcb); +static int tul_wait_done_disc(HCS *pCurHcb); +static int tul_wait_disc(HCS *pCurHcb); +/*static int tul_msgin_par_err(HCS *pCurHcb);*/ +static void tulip_scsi(HCS *pCurHcb); +static int tul_post_scsi_rst(HCS *pCurHcb); + +static void tul_se2_ew_en(WORD CurBase); +static void tul_se2_ew_ds(WORD CurBase); +static int tul_se2_rd_all(WORD CurBase); +static void tul_se2_update_all(WORD CurBase); /* setup default pattern */ +static void tul_read_eeprom(WORD CurBase); /* ---- EXTERNAL VARIABLES ---- */ -HCS tul_hcs[MAX_SUPPORTED_ADAPTERS]; +HCS tul_hcs[MAX_SUPPORTED_ADAPTERS]; /* ---- INTERNAL VARIABLES ---- */ -static INI_ADPT_STRUCT i91u_adpt[MAX_SUPPORTED_ADAPTERS]; +static INI_ADPT_STRUCT i91u_adpt[MAX_SUPPORTED_ADAPTERS]; -/*NVRAM nvram, *nvramp = &nvram; */ +/*NVRAM nvram, *nvramp = &nvram;*/ static NVRAM i91unvram; static NVRAM *i91unvramp; +/* HCSINFO HcsInfo[ MAX_PCI_DEVICES * MAX_PCI_CHANL ]; ??? */ +/*HCSINFO HcsInfo[ MAX_PCI_CHANL ];*/ -static UCHAR i91udftNvRam[64] = -{ -/*----------- header -----------*/ - 0x25, 0xc9, /* Signature */ - 0x40, /* Size */ - 0x01, /* Revision */ +static UCHAR i91udftNvRam[64] = { /*----------- header -----------*/ + 0x25, 0xc9, /* Signature */ + 0x40, /* Size */ + 0x01, /* Revision */ /* -- Host Adapter Structure -- */ - 0x95, /* ModelByte0 */ - 0x00, /* ModelByte1 */ - 0x00, /* ModelInfo */ - 0x01, /* NumOfCh */ - NBC1_DEFAULT, /* BIOSConfig1 */ - 0, /* BIOSConfig2 */ - 0, /* HAConfig1 */ - 0, /* HAConfig2 */ + 0x95, /* ModelByte0 */ + 0x00, /* ModelByte1 */ + 0x00, /* ModelInfo */ + 0x01, /* NumOfCh */ + NBC1_DEFAULT, /* BIOSConfig1 */ + 0, /* BIOSConfig2 */ + 0, /* HAConfig1 */ + 0, /* HAConfig2 */ /* SCSI channel 0 and target Structure */ - 7, /* SCSIid */ - NCC1_DEFAULT, /* SCSIconfig1 */ - 0, /* SCSIconfig2 */ - 0x10, /* NumSCSItarget */ + 7, /* SCSIid */ + NCC1_DEFAULT, /* SCSIconfig1 */ + 0, /* SCSIconfig2 */ + 0x10, /* NumSCSItarget*/ NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, @@ -188,82 +195,112 @@ static UCHAR i91udftNvRam[64] = NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, /* SCSI channel 1 and target Structure */ - 7, /* SCSIid */ - NCC1_DEFAULT, /* SCSIconfig1 */ - 0, /* SCSIconfig2 */ - 0x10, /* NumSCSItarget */ + 7, /* SCSIid */ + NCC1_DEFAULT, /* SCSIconfig1 */ + 0, /* SCSIconfig2 */ + 0x10, /* NumSCSItarget*/ NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0}; /* - CheckSum - */ + 0, 0 }; /* - CheckSum - */ -static UCHAR tul_rate_tbl[8] = /* fast 20 */ -{ +static UCHAR tul_rate_tbl[8] = /* fast 20 */ + { /* nanosecond devide by 4 */ - 12, /* 50ns, 20M */ - 18, /* 75ns, 13.3M */ - 25, /* 100ns, 10M */ - 31, /* 125ns, 8M */ - 37, /* 150ns, 6.6M */ - 43, /* 175ns, 5.7M */ - 50, /* 200ns, 5M */ - 62 /* 250ns, 4M */ -}; - -extern int tul_num_ch; + 12, /* 50ns, 20M */ + 18, /* 75ns, 13.3M */ + 25, /* 100ns, 10M */ + 31, /* 125ns, 8M */ + 37, /* 150ns, 6.6M */ + 43, /* 175ns, 5.7M */ + 50, /* 200ns, 5M */ + 62 /* 250ns, 4M */ + }; + +#if 0 /* <01> */ +static UCHAR bi91uPCI_mechanism = 0; /* The mechanism used by read PCI */ +#endif +extern int tul_num_ch; -static void tul_do_pause(unsigned amount) -{ /* Pause for amount*10 milliseconds */ - unsigned long the_time = jiffies + amount; /* 0.01 seconds per jiffy */ +#if 1 +static void tul_do_pause( unsigned amount ) /* Pause for amount*10 milliseconds */ +{ + unsigned long the_time = jiffies + amount; /* 0.01 seconds per jiffy */ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - while (time_before_eq(jiffies, the_time)); -#else - while (jiffies < the_time); -#endif + while (jiffies < the_time) + ; } +#endif /*-- forward reference --*/ +#if 0 +static void tul_snapdump(ULONG *ptr, int length) +{ + int col, row; + int i, idx; + + row = length / 16 + ((length % 16) ? 1 : 0); + idx = 0; + printk("\n\r"); + for (i = 0; i < row; i++) + { + printk("Offset %04x at %08lx : ", idx, (ULONG) ptr); + for (col = 0; (col < 2) & (idx < length); col++, idx+=4) + { + printk(" %08lx", *ptr++); + } + printk(" -"); + for (col = 0; (col < 2) & (idx < length); col++, idx+=4) + { + printk(" %08lx", *ptr++); + } + printk("\n\r"); + } +} +#endif +/*--- forward reference ---*/ /******************************************************************* Use memeory refresh time ~ 15us * 2 ********************************************************************/ void tul_se2_wait() { -#if 1 - udelay(30); +#if 0 + ULONG i; + i = jiffies + (30 * HZ / 100000); + while (jiffies , i++); #else - UCHAR readByte; - - readByte = TUL_RD(0, 0x61); - if ((readByte & 0x10) == 0x10) { - for (;;) { - readByte = TUL_RD(0, 0x61); - if ((readByte & 0x10) == 0x10) - break; - } - for (;;) { - readByte = TUL_RD(0, 0x61); - if ((readByte & 0x10) != 0x10) - break; - } - } else { - for (;;) { - readByte = TUL_RD(0, 0x61); - if ((readByte & 0x10) == 0x10) - break; - } - for (;;) { - readByte = TUL_RD(0, 0x61); - if ((readByte & 0x10) != 0x10) - break; - } + UCHAR readByte; + + readByte = TUL_RD( 0, 0x61 ); + if ( (readByte & 0x10) == 0x10) { + for (; ;) { + readByte = TUL_RD( 0, 0x61 ); + if ( (readByte & 0x10) == 0x10) + break; } + for (;;) { + readByte = TUL_RD( 0, 0x61 ); + if ( (readByte & 0x10) != 0x10) + break; + } + } else { + for (; ; ) { + readByte = TUL_RD( 0, 0x61 ); + if ( (readByte & 0x10) == 0x10) + break; + } + for (; ; ) { + readByte = TUL_RD( 0, 0x61 ); + if ( (readByte & 0x10) != 0x10) + break; + } + } #endif } @@ -300,28 +337,28 @@ void tul_se2_wait() ******************************************************************/ void tul_se2_instr(WORD CurBase, UCHAR instr) { - int i; - UCHAR b; + int i; + UCHAR b; - TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2DO); /* cs+start bit */ - tul_se2_wait(); - TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK | SE2DO); /* +CLK */ - tul_se2_wait(); + TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2DO); /* cs+start bit */ + tul_se2_wait(); + TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK | SE2DO); /* +CLK */ + tul_se2_wait(); - for (i = 0; i < 8; i++) { - if (instr & 0x80) - b = SE2CS | SE2DO; /* -CLK+dataBit */ - else - b = SE2CS; /* -CLK */ - TUL_WR(CurBase + TUL_NVRAM, b); - tul_se2_wait(); - TUL_WR(CurBase + TUL_NVRAM, b | SE2CLK); /* +CLK */ - tul_se2_wait(); - instr <<= 1; - } - TUL_WR(CurBase + TUL_NVRAM, SE2CS); /* -CLK */ + for ( i = 0; i < 8; i++) { + if (instr & 0x80) + b = SE2CS | SE2DO; /* -CLK+dataBit */ + else + b = SE2CS ; /* -CLK */ + TUL_WR(CurBase + TUL_NVRAM, b); tul_se2_wait(); - return; + TUL_WR(CurBase + TUL_NVRAM, b | SE2CLK); /* +CLK */ + tul_se2_wait(); + instr <<= 1; + } + TUL_WR(CurBase + TUL_NVRAM, SE2CS ); /* -CLK */ + tul_se2_wait(); + return; } @@ -331,10 +368,10 @@ void tul_se2_instr(WORD CurBase, UCHAR instr) ******************************************************************/ void tul_se2_ew_en(WORD CurBase) { - tul_se2_instr(CurBase, 0x30); /* EWEN */ - TUL_WR(CurBase + TUL_NVRAM, 0); /* -CS */ - tul_se2_wait(); - return; + tul_se2_instr(CurBase, 0x30); /* EWEN */ + TUL_WR(CurBase + TUL_NVRAM, 0); /* -CS */ + tul_se2_wait(); + return; } @@ -343,10 +380,10 @@ void tul_se2_ew_en(WORD CurBase) *************************************************************************/ void tul_se2_ew_ds(WORD CurBase) { - tul_se2_instr(CurBase, 0); /* EWDS */ - TUL_WR(CurBase + TUL_NVRAM, 0); /* -CS */ - tul_se2_wait(); - return; + tul_se2_instr(CurBase, 0); /* EWDS */ + TUL_WR(CurBase + TUL_NVRAM, 0); /* -CS */ + tul_se2_wait(); + return; } @@ -356,29 +393,29 @@ void tul_se2_ew_ds(WORD CurBase) *******************************************************************/ USHORT tul_se2_rd(WORD CurBase, ULONG adr) { - UCHAR instr, readByte; - USHORT readWord; - int i; + UCHAR instr, readByte; + USHORT readWord; + int i; - instr = (UCHAR) (adr | 0x80); - tul_se2_instr(CurBase, instr); /* READ INSTR */ - readWord = 0; + instr = (UCHAR)( adr | 0x80 ); + tul_se2_instr(CurBase, instr); /* READ INSTR */ + readWord = 0; - for (i = 15; i >= 0; i--) { - TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK); /* +CLK */ - tul_se2_wait(); - TUL_WR(CurBase + TUL_NVRAM, SE2CS); /* -CLK */ + for ( i = 15; i >= 0; i--) { + TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK ); /* +CLK */ + tul_se2_wait(); + TUL_WR(CurBase + TUL_NVRAM, SE2CS ); /* -CLK */ /* sample data after the following edge of clock */ - readByte = TUL_RD(CurBase, TUL_NVRAM); - readByte &= SE2DI; - readWord += (readByte << i); - tul_se2_wait(); /* 6/20/95 */ - } + readByte = TUL_RD(CurBase, TUL_NVRAM); + readByte &= SE2DI; + readWord += (readByte << i); + tul_se2_wait(); /* 6/20/95 */ + } - TUL_WR(CurBase + TUL_NVRAM, 0); /* no chip select */ - tul_se2_wait(); - return readWord; + TUL_WR(CurBase + TUL_NVRAM, 0 ); /* no chip select */ + tul_se2_wait(); + return readWord; } @@ -387,40 +424,40 @@ USHORT tul_se2_rd(WORD CurBase, ULONG adr) *******************************************************************/ void tul_se2_wr(WORD CurBase, UCHAR adr, USHORT writeWord) { - UCHAR readByte; - UCHAR instr; - int i; + UCHAR readByte; + UCHAR instr; + int i; - instr = (UCHAR) (adr | 0x40); - tul_se2_instr(CurBase, instr); /* WRITE INSTR */ - for (i = 15; i >= 0; i--) { - if (writeWord & 0x8000) - TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2DO); /* -CLK+dataBit 1 */ - else - TUL_WR(CurBase + TUL_NVRAM, SE2CS); /* -CLK+dataBit 0 */ - tul_se2_wait(); - TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK); /* +CLK */ - tul_se2_wait(); - writeWord <<= 1; - } - TUL_WR(CurBase + TUL_NVRAM, SE2CS); /* -CLK */ + instr = (UCHAR)( adr | 0x40 ); + tul_se2_instr(CurBase, instr); /* WRITE INSTR */ + for ( i = 15; i >= 0; i--) { + if (writeWord & 0x8000) + TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2DO); /* -CLK+dataBit 1 */ + else + TUL_WR(CurBase + TUL_NVRAM, SE2CS ); /* -CLK+dataBit 0 */ tul_se2_wait(); - TUL_WR(CurBase + TUL_NVRAM, 0); /* -CS */ + TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK ); /* +CLK */ tul_se2_wait(); - - TUL_WR(CurBase + TUL_NVRAM, SE2CS); /* +CS */ + writeWord <<= 1; + } + TUL_WR(CurBase + TUL_NVRAM, SE2CS); /* -CLK */ + tul_se2_wait(); + TUL_WR(CurBase + TUL_NVRAM, 0); /* -CS */ + tul_se2_wait(); + + TUL_WR(CurBase + TUL_NVRAM, SE2CS); /* +CS */ + tul_se2_wait(); + + for (; ; ) { + TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK); /* +CLK */ tul_se2_wait(); - - for (;;) { - TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK); /* +CLK */ - tul_se2_wait(); - TUL_WR(CurBase + TUL_NVRAM, SE2CS); /* -CLK */ - tul_se2_wait(); - if ((readByte = TUL_RD(CurBase, TUL_NVRAM)) & SE2DI) - break; /* write complete */ - } - TUL_WR(CurBase + TUL_NVRAM, 0); /* -CS */ - return; + TUL_WR(CurBase + TUL_NVRAM, SE2CS ); /* -CLK */ + tul_se2_wait(); + if ((readByte = TUL_RD(CurBase, TUL_NVRAM )) & SE2DI ) + break; /* write complete */ + } + TUL_WR(CurBase + TUL_NVRAM, 0); /* -CS */ + return; } @@ -429,56 +466,61 @@ void tul_se2_wr(WORD CurBase, UCHAR adr, USHORT writeWord) ************************************************************************/ int tul_se2_rd_all(WORD CurBase) { - int i; - ULONG chksum = 0; - USHORT *np; - - i91unvramp = &i91unvram; - np = (USHORT *) i91unvramp; - for (i = 0; i < 32; i++) { - *np++ = tul_se2_rd(CurBase, i); - } - -/*--------------------Is signature "ini" ok ? ----------------*/ - if (i91unvramp->NVM_Signature != INI_SIGNATURE) - return -1; -/*---------------------- Is ckecksum ok ? ----------------------*/ - np = (USHORT *) i91unvramp; - for (i = 0; i < 31; i++) - chksum += *np++; - if (i91unvramp->NVM_CheckSum != (USHORT) chksum) - return -1; - return 1; + int i; + ULONG chksum = 0; + USHORT *np; + + i91unvramp = &i91unvram; + np = (USHORT * )i91unvramp; + for ( i = 0; i < 32; i++) { + *np++ = tul_se2_rd(CurBase, i); + } + + /*--------------------Is signature "ini" ok ? ----------------*/ + if ( i91unvramp->NVM_Signature != INI_SIGNATURE ) + return - 1; +#if 0 + /*--------------------Is Model# byte 1 "91" ok ? ----------------*/ +// if ( i91unvramp->ModelByte0 != 0x91) /* 4: Model number (byte 0) */ +// return - 1; +#endif + /*---------------------- Is ckecksum ok ? ----------------------*/ + np = (USHORT * )i91unvramp; + for ( i = 0; i < 31; i++) + chksum += *np++; + if ( i91unvramp->NVM_CheckSum != (USHORT)chksum ) + return - 1; + return 1; } /*********************************************************************** Update SCSI H/A configuration parameters from serial EEPROM ************************************************************************/ -void tul_se2_update_all(WORD CurBase) -{ /* setup default pattern */ - int i; - ULONG chksum = 0; - USHORT *np, *np1; +void tul_se2_update_all(WORD CurBase) /* setup default pattern */ +{ + int i; + ULONG chksum = 0; + USHORT * np, *np1; - i91unvramp = &i91unvram; + i91unvramp = &i91unvram; /* Calculate checksum first */ - np = (USHORT *) i91udftNvRam; - for (i = 0; i < 31; i++) - chksum += *np++; - *np = (USHORT) chksum; - tul_se2_ew_en(CurBase); /* Enable write */ - - np = (USHORT *) i91udftNvRam; - np1 = (USHORT *) i91unvramp; - for (i = 0; i < 32; i++, np++, np1++) { - if (*np != *np1) { - tul_se2_wr(CurBase, i, *np); - } + np = (USHORT * )i91udftNvRam; + for ( i = 0; i < 31; i++) + chksum += *np++; + *np = (USHORT)chksum; + tul_se2_ew_en(CurBase); /* Enable write */ + + np = (USHORT * )i91udftNvRam; + np1 = (USHORT * )i91unvramp; + for ( i = 0; i < 32; i++, np++, np1++) { + if (*np != *np1) { + tul_se2_wr(CurBase, i, *np); } + } - tul_se2_ew_ds(CurBase); /* Disable write */ - return; + tul_se2_ew_ds(CurBase); /* Disable write */ + return; } /************************************************************************* @@ -486,1897 +528,2297 @@ void tul_se2_update_all(WORD CurBase) **************************************************************************/ void tul_read_eeprom(WORD CurBase) { - UCHAR gctrl; - - i91unvramp = &i91unvram; -/*------Enable EEProm programming ---*/ - gctrl = TUL_RD(CurBase, TUL_GCTRL); - TUL_WR(CurBase + TUL_GCTRL, gctrl | TUL_GCTRL_EEPROM_BIT); - if (tul_se2_rd_all(CurBase) != 1) { - tul_se2_update_all(CurBase); /* setup default pattern */ - tul_se2_rd_all(CurBase); /* load again */ - } -/*------ Disable EEProm programming ---*/ - gctrl = TUL_RD(CurBase, TUL_GCTRL); - TUL_WR(CurBase + TUL_GCTRL, gctrl & ~TUL_GCTRL_EEPROM_BIT); -} /* read_eeprom */ - -int Addi91u_into_Adapter_table(WORD wBIOS, WORD wBASE, BYTE bInterrupt, - BYTE bBus, BYTE bDevice) -{ - int i, j; - - for (i = 0; i < MAX_SUPPORTED_ADAPTERS; i++) { - if (i91u_adpt[i].ADPT_BIOS < wBIOS) - continue; - if (i91u_adpt[i].ADPT_BIOS == wBIOS) { - if (i91u_adpt[i].ADPT_BASE == wBASE) { - if (i91u_adpt[i].ADPT_Bus != 0xFF) - return (FAILURE); - } else if (i91u_adpt[i].ADPT_BASE < wBASE) - continue; - } - for (j = MAX_SUPPORTED_ADAPTERS - 1; j > i; j--) { - i91u_adpt[j].ADPT_BASE = i91u_adpt[j - 1].ADPT_BASE; - i91u_adpt[j].ADPT_INTR = i91u_adpt[j - 1].ADPT_INTR; - i91u_adpt[j].ADPT_BIOS = i91u_adpt[j - 1].ADPT_BIOS; - i91u_adpt[j].ADPT_Bus = i91u_adpt[j - 1].ADPT_Bus; - i91u_adpt[j].ADPT_Device = i91u_adpt[j - 1].ADPT_Device; - } - i91u_adpt[i].ADPT_BASE = wBASE; - i91u_adpt[i].ADPT_INTR = bInterrupt; - i91u_adpt[i].ADPT_BIOS = wBIOS; - i91u_adpt[i].ADPT_Bus = bBus; - i91u_adpt[i].ADPT_Device = bDevice; - return (SUCCESSFUL); + UCHAR gctrl; + + i91unvramp = &i91unvram; + /*------Enable EEProm programming ---*/ + gctrl = TUL_RD(CurBase, TUL_GCTRL); + TUL_WR(CurBase + TUL_GCTRL, gctrl | TUL_GCTRL_EEPROM_BIT ); + if ( tul_se2_rd_all(CurBase) != 1 ) { + tul_se2_update_all(CurBase); /* setup default pattern */ + tul_se2_rd_all(CurBase); /* load again */ + } + /*------ Disable EEProm programming ---*/ + gctrl = TUL_RD(CurBase, TUL_GCTRL); + TUL_WR(CurBase + TUL_GCTRL, gctrl & ~TUL_GCTRL_EEPROM_BIT ); +} /* read_eeprom */ + + +#if 0 /* <01> */ +static UBYTE i91uGetPCIMechanism(void) +{ + int bus, device; + unsigned long lConfigAddress, lConfigData; + + lConfigAddress = 0x80000000; + for (bus = 0; bus < 255; bus++) + { + lConfigAddress &= 0xFFFF0000; + for (device = 0; device < 21; device++) + { + outl(lConfigAddress, 0xCF8); /*Write config_address,enable*/ + lConfigData = inl(0xCFC); /* Read config_data */ + if ((lConfigData & 0xFFFF) == 0x1101) + return (1); /* Mechanism 1 */ + if ((lConfigData & 0xFFFF) == 0x134A) + return (1); /* Mechanism 1 */ + lConfigAddress += 0x800; + } + lConfigAddress += 0x10000; + } + return (2); /* Mechanism 2 */ +} + +#if 1 + +/*****************************************************************************/ +static unsigned long i91uReadPCIConfig( unsigned char BusNum, + unsigned char DeviceNum, + unsigned char RegNum) +{ + HOST_ADR HostAdr; + CONFIG_ADR ConfigAdr; + unsigned long ConfigData; + +#if BIOS32 + REGS Regs; + + if (CallBIOS32) + { /* PCI BIOS32 exists, use it */ + Regs.eax.byte.ah = PCI_FUNCTION_ID; + Regs.eax.byte.al = READ_CONFIG_DWORD; + Regs.ebx.byte.bh = BusNum; + Regs.ebx.byte.bl = DeviceNum & 0xFC; + Regs.edi.word.di = RegNum; + if (PCIBIOS32Call(CallBIOS32, &Regs)) + { + return(-1); /* Read configuration error */ + } + if (Regs.eax.byte.ah != SUCCESSFUL) + { /* Check return code */ + return(-1); /* Read configuration error */ + } + return(Regs.ecx.ecx); } - return (FAILURE); +#endif + if (bi91uPCI_mechanism == 0) + bi91uPCI_mechanism = i91uGetPCIMechanism(); + if (bi91uPCI_mechanism == 1) + { /* Mechanism #1 */ + ConfigAdr.lConfigAdr = 0; + ConfigAdr.sConfigAdr.RegNum = RegNum & 0xFC; /* Get rid of bit 0&1 */ + ConfigAdr.sConfigAdr.DeviceNum = DeviceNum; + ConfigAdr.sConfigAdr.BusNum = BusNum; + ConfigAdr.sConfigAdr.Enable = 1; + outl(ConfigAdr.lConfigAdr, 0xCF8); /*Write config_address,enable*/ + ConfigData = inl(0xCFC); /* Read config_data */ + ConfigAdr.lConfigAdr = 0; + outl(ConfigAdr.lConfigAdr, 0xCF8); /*Write config_address,disable*/ + /*if (ConfigData != -1) Read success */ + return(ConfigData); + } + else + { /* Mechanism #2 */ + if (DeviceNum >= 16) /* Mechanism #2 only support 16 */ + return(-1); /* devices C000- CF00 */ + HostAdr.sHostAdr.RegNum = RegNum & 0xFC; /* Get rid of bit 0&1 */ + HostAdr.sHostAdr.DeviceNum = 0xC0 | (DeviceNum & 0xF); + HostAdr.sHostAdr.Reserved = 0x0000; + outb(BusNum, 0xCFA);/* Setup forward address */ + outb(0xC0, 0xCF8); /* Configuration mapping enable */ +/* outb(0xC0, 0xCFA); Configuration mapping enable */ + ConfigData = inl(HostAdr.lHostAdr);/* Read configuration data */ + outb(0, 0xCFA); /* Setup forward address */ + outb(0, 0xCF8); /* Configuration mapping disable*/ + return(ConfigData); + } +} + +#else + +/************************************************************************* + Function name : ReadPCIConfig + Description : This function return configuration space's register value. + Input : + BusNum - Bus number + DeviceNum - Device number + RegNum - Register number + Output : None. + Return : Register value +**************************************************************************/ +unsigned long ReadPCIConfig( unsigned char BusNum, + unsigned char DeviceNum, + unsigned char RegNum) +{ + HOST_ADR HostAdr; + CONFIG_ADR ConfigAdr; + unsigned long ConfigData; + + if (bPCI_mechanism == 1) { + /*------------------ Mechanism #1 ------------------------- */ + ConfigAdr.lConfigAdr = 0; + ConfigAdr.sConfigAdr.RegNum = RegNum & 0xFC; /* Get rid of bit 0&1 */ + ConfigAdr.sConfigAdr.DeviceNum = DeviceNum; + ConfigAdr.sConfigAdr.BusNum = BusNum; + ConfigAdr.sConfigAdr.Enable = 1; + outpl( 0xCF8, ConfigAdr.lConfigAdr); /* Write config_address, enable */ + + ConfigData = inpl( 0xCFC ); /* Read config_data */ + ConfigAdr.lConfigAdr = 0; + outpl( 0xCF8, ConfigAdr.lConfigAdr); /* Write config_address, disable*/ + return(ConfigData); + } else { + /*------------------ Mechanism #2 ------------------------- */ + if (DeviceNum >= 16) /* Mechanism #2 only support 16 */ + return(0); /* devices C000- CF00 */ + HostAdr.lHostAdr = 0; + HostAdr.sHostAdr.RegNum = RegNum & 0xFC; /* Get rid of bit 0&1 */ + HostAdr.sHostAdr.DeviceNum = 0xC0 | (DeviceNum & 0xF); + outp(0xCFA, BusNum); /* Setup forward address */ + outp(0xCF8, 0xC0); /* Configuration mapping enable */ + ConfigData = inpl(HostAdr.lHostAdr); /* Read configuration data */ + outp(0xCFA, 0); /* Setup forward address */ + outp(0xCF8, 0); /* Configuration mapping disable*/ + return(ConfigData); + } +} +#endif +#endif + +int Addi91u_into_Adapter_table(WORD wBIOS, WORD wBASE, BYTE bInterrupt, + BYTE bBus, BYTE bDevice) +{ + int i, j; + + for (i = 0; i < MAX_SUPPORTED_ADAPTERS; i++) + { + if (i91u_adpt[i].ADPT_BIOS < wBIOS) + continue; + if (i91u_adpt[i].ADPT_BIOS == wBIOS) + { + if (i91u_adpt[i].ADPT_BASE == wBASE) + if (i91u_adpt[i].ADPT_Bus != 0xFF) + return(FAILURE); + else + if (i91u_adpt[i].ADPT_BASE < wBASE) + continue; + } + for (j = MAX_SUPPORTED_ADAPTERS - 1; j > i; j--) + { + i91u_adpt[j].ADPT_BASE = i91u_adpt[j-1].ADPT_BASE; + i91u_adpt[j].ADPT_INTR = i91u_adpt[j-1].ADPT_INTR; + i91u_adpt[j].ADPT_BIOS = i91u_adpt[j-1].ADPT_BIOS; + i91u_adpt[j].ADPT_Bus = i91u_adpt[j-1].ADPT_Bus; + i91u_adpt[j].ADPT_Device = i91u_adpt[j-1].ADPT_Device; + } + i91u_adpt[i].ADPT_BASE = wBASE; + i91u_adpt[i].ADPT_INTR = bInterrupt; + i91u_adpt[i].ADPT_BIOS = wBIOS; + i91u_adpt[i].ADPT_Bus = bBus; + i91u_adpt[i].ADPT_Device = bDevice; + return(SUCCESSFUL); + } + return(FAILURE); } void init_i91uAdapter_table(void) { - int i; + int i; - for (i = 0; i < MAX_SUPPORTED_ADAPTERS; i++) { /* Initialize adapter structure */ - i91u_adpt[i].ADPT_BIOS = 0xffff; - i91u_adpt[i].ADPT_BASE = 0xffff; - i91u_adpt[i].ADPT_INTR = 0xff; - i91u_adpt[i].ADPT_Bus = 0xff; - i91u_adpt[i].ADPT_Device = 0xff; + for (i = 0; i < MAX_SUPPORTED_ADAPTERS; i++) + { /* Initialize adapter structure */ + i91u_adpt[i].ADPT_BIOS = 0xffff; + i91u_adpt[i].ADPT_BASE = 0xffff; + i91u_adpt[i].ADPT_INTR = 0xff; + i91u_adpt[i].ADPT_Bus = 0xff; + i91u_adpt[i].ADPT_Device = 0xff; } - return; + return; } -void tul_stop_bm(HCS * pCurHcb) +#if 0 /* <01> */ +int tul_ReturnNumberOfAdapters(void) { + long dRegValue; + int i, iAdapters; + BYTE bPCIBusNum, bTotalBusNum, bInterrupt, bPCIDeviceNum; + WORD wBIOS, wBASE; - if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND) { /* if DMA xfer is pending, abort DMA xfer */ - TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_ABT | TAX_X_CLR_FIFO); - /* wait Abort DMA xfer done */ - while ((TUL_RD(pCurHcb->HCS_Base, TUL_Int) & XABT) == 0); + for (i = 0; i < MAX_SUPPORTED_ADAPTERS; i++) + { /* Initialize adapter structure */ + i91u_adpt[i].ADPT_BIOS = 0xffff; + i91u_adpt[i].ADPT_BASE = 0xffff; + i91u_adpt[i].ADPT_INTR = 0xff; + i91u_adpt[i].ADPT_Bus = 0xff; + i91u_adpt[i].ADPT_Device = 0xff; } - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); + + bTotalBusNum = 0xFF; /* Search 255 buses */ + +/* bi91uPCI_mechanism = 1; 02/05/95 */ + + for (bPCIBusNum = 0, iAdapters = 0; bPCIBusNum < bTotalBusNum; bPCIBusNum++) + { /* Scan all the buses */ + for (bPCIDeviceNum=0; bPCIDeviceNum < MAX_PCI_DEVICES; bPCIDeviceNum++) + { /* Find all jasmine devices */ + if (iAdapters >= MAX_SUPPORTED_ADAPTERS) + break; /* Never greater than maximum */ + dRegValue = i91uReadPCIConfig(bPCIBusNum, bPCIDeviceNum, TUL_PVID); + if ((dRegValue & 0xFFFF) != INI_VENDOR_ID) + { +#if 1 + if ((dRegValue & 0xFFFF) != 0x134A) /* 07/08/98 */ + continue; +#else + if (bPCI_MechanismDone) + continue; + bi91uPCI_mechanism = 2; /* 02/05/95 */ + dRegValue =i91uReadPCIConfig(bPCIBusNum,bPCIDeviceNum,TUL_PVID); + if ((dRegValue & 0xFFFF) != INI_VENDOR_ID) + { + bi91uPCI_mechanism = 1; /* 02/05/95 */ + continue; /* Wrong vendor ID */ + } +#endif + } +/* bPCI_MechanismDone = 1;*/ + if ((((dRegValue >> 16) & 0xFF00) != I950_DEVICE_ID) && + (((dRegValue >> 16) & 0xFF00) != I940_DEVICE_ID) && + (((dRegValue >> 16) & 0xFF00) != 0x0002) && /* 07/08/98 */ + (((dRegValue >> 16) & 0xFF00) != I935_DEVICE_ID)) + continue; /* Wrong device ID */ + /* Read base address */ + dRegValue = i91uReadPCIConfig(bPCIBusNum, bPCIDeviceNum, TUL_PBAD); + if (dRegValue == -1) + { /* Check return code */ + printk("\n\ri91u: Jasmine read configuration error.\n"); + return(0); /* Read configuration space error */ + } + if ((dRegValue & 0x01) == 0) + { /* Base address for memory */ + printk("\n\ri91u: Wrong base address setting at -> Bus: %d; Device: %d", bPCIBusNum, bPCIDeviceNum); + continue; /* PCI configuration setup error*/ + } + + wBASE = (WORD) (dRegValue & 0xFFFE); + /* Now read the BIOS address */ + dRegValue = i91uReadPCIConfig(bPCIBusNum, bPCIDeviceNum, TUL_SDCFG0); + wBIOS = (UWORD) (dRegValue & 0xFF); + if (((dRegValue & 0xFF00) >> 8) == 0xFF) + dRegValue = 0; + wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8)); + /* Now read the interrupt line */ + dRegValue = i91uReadPCIConfig(bPCIBusNum, bPCIDeviceNum, TUL_PINTL); + bInterrupt = dRegValue & 0xFF;/* Assign interrupt line */ + + if (Addi91u_into_Adapter_table(wBIOS, wBASE, bInterrupt, bPCIBusNum, + bPCIDeviceNum) == SUCCESSFUL) + iAdapters++; + } + } + return (iAdapters); } +#endif -/***************************************************************************/ -void get_tulipPCIConfig(HCS * pCurHcb, int ch_idx) +void tul_stop_bm(HCS *pCurHcb) { - pCurHcb->HCS_Base = i91u_adpt[ch_idx].ADPT_BASE; /* Supply base address */ - pCurHcb->HCS_BIOS = i91u_adpt[ch_idx].ADPT_BIOS; /* Supply BIOS address */ - pCurHcb->HCS_Intr = i91u_adpt[ch_idx].ADPT_INTR; /* Supply interrupt line */ - return; + + if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND) + { /* if DMA xfer is pending, abort DMA xfer */ + TUL_WR(pCurHcb->HCS_Base+ TUL_XCmd, TAX_X_ABT | TAX_X_CLR_FIFO); + /* wait Abort DMA xfer done */ + while ((TUL_RD(pCurHcb->HCS_Base, TUL_Int) & XABT) == 0); + } + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); } /***************************************************************************/ -int tul_reset_scsi(HCS * pCurHcb, int seconds) +void get_tulipPCIConfig(HCS *pCurHcb, int ch_idx) { - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_RST_BUS); + pCurHcb->HCS_Base = i91u_adpt[ch_idx].ADPT_BASE; /* Supply base address */ + pCurHcb->HCS_BIOS = i91u_adpt[ch_idx].ADPT_BIOS; /* Supply BIOS address */ + pCurHcb->HCS_Intr = i91u_adpt[ch_idx].ADPT_INTR; /* Supply interrupt line*/ + return; +} - while (!((pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt)) & TSS_SCSIRST_INT)); - /* reset tulip chip */ +/***************************************************************************/ +int tul_reset_scsi(HCS *pCurHcb, int seconds) +{ +#if 0 + printk("i91u: enter tul_reset_scsi.\n"); +#endif - TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, 0); + TUL_WR( pCurHcb->HCS_Base + TUL_SCtrl0, TSC_RST_BUS); - /* Stall for a while, wait for target's firmware ready,make it 2 sec ! */ - /* SONY 5200 tape drive won't work if only stall for 1 sec */ - tul_do_pause(seconds * 100); + while(!((pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base,TUL_SInt)) & TSS_SCSIRST_INT)); + /* reset tulip chip */ - TUL_RD(pCurHcb->HCS_Base, TUL_SInt); + TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, 0); - return (SCSI_RESET_SUCCESS); -} + /* Stall for a while, wait for target's firmware ready,make it 2 sec ! */ + /* SONY 5200 tape drive won't work if only stall for 1 sec */ +#if 1 + tul_do_pause(seconds*100); +#else + for (i = 0; i < 66666; i++) /* wait 2 sec */ + tul_se2_wait(); /* wait 30 us */ +#endif -/***************************************************************************/ -int init_tulip(HCS * pCurHcb, SCB * scbp, int tul_num_scb, BYTE * pbBiosAdr, int seconds) -{ - int i; - WORD *pwFlags; - BYTE *pbHeads; - SCB *pTmpScb, *pPrevScb = NULL; + TUL_RD(pCurHcb->HCS_Base,TUL_SInt); + +#if 0 + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0,TSC_RST_CHIP); + /* program HBA's SCSI ID */ + TUL_WR( hcsp->Base+TUL_SScsiId,hcsp->HaId << 4); + + /* Enable Initiator Mode ,phase latch,alternate sync period mode, + disable SCSI reset */ + if (hcsp->Config & HCC_EN_PAR) + TUL_WR(hcsp->Base+TUL_SConfig, TSC_INITDEFAULT | TSC_EN_SCSI_PAR); + else + TUL_WR(hcsp->Base+TUL_SConfig, TSC_INITDEFAULT ); + + /*Synchronous data transfer rate + Sync. period 0 -> 100 ns for 10 MHz + Sync. offset 0 -> Async. operation */ + /* Initialize the sync. xfer register values to an narrow, async. xfer */ + TUL_WR(hcsp->Base+TUL_SPeriodOffset, 0x70); + + /* selection time out = 250 ms */ + TUL_WR(hcsp->Base+TUL_STimeOut, 153); - pCurHcb->HCS_NumScbs = tul_num_scb; - pCurHcb->HCS_Semaph = 1; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - pCurHcb->HCS_SemaphLock = SPIN_LOCK_UNLOCKED; -#endif - pCurHcb->HCS_JSStatus0 = 0; - pCurHcb->HCS_Scb = scbp; - pCurHcb->HCS_NxtPend = scbp; - pCurHcb->HCS_NxtAvail = scbp; - for (i = 0, pTmpScb = scbp; i < tul_num_scb; i++, pTmpScb++) { - pTmpScb->SCB_TagId = i; - if (i != 0) - pPrevScb->SCB_NxtScb = pTmpScb; - pPrevScb = pTmpScb; - } - pPrevScb->SCB_NxtScb = NULL; - pCurHcb->HCS_ScbEnd = pTmpScb; - pCurHcb->HCS_FirstAvail = scbp; - pCurHcb->HCS_LastAvail = pPrevScb; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - pCurHcb->HCS_AvailLock = SPIN_LOCK_UNLOCKED; +#if 1 + /* Initialize the sync. xfer register values to an async. xfer */ + tcsp = &hcsp->HCS_Tcs[0]; + for (i = 0; i < pCurHcb->HCS_MaxTar; tcsp++, i++) { + tcsp->Flags &= ~(TCF_SYNC_DONE|TCF_WDTR_DONE); + } /* for */ #endif - pCurHcb->HCS_FirstPend = NULL; - pCurHcb->HCS_LastPend = NULL; - pCurHcb->HCS_FirstBusy = NULL; - pCurHcb->HCS_LastBusy = NULL; - pCurHcb->HCS_FirstDone = NULL; - pCurHcb->HCS_LastDone = NULL; - pCurHcb->HCS_ActScb = NULL; - pCurHcb->HCS_ActTcs = NULL; - tul_read_eeprom(pCurHcb->HCS_Base); -/*---------- get H/A configuration -------------*/ - if (i91unvramp->NVM_SCSIInfo[0].NVM_NumOfTarg == 8) - pCurHcb->HCS_MaxTar = 8; - else - pCurHcb->HCS_MaxTar = 16; + if (hwInitialized) { + /* Post_scsi_rst: clean up active SCB */ + /* clear sync done flag */ + dbgPrint0(0,"tul_reset_scsi:call tul_post_scsi_rst\n"); + tul_post_scsi_rst(hcsp); + } + +#if NEWCHIP_BUG0 + TUL_WR(hcsp->Base+TUL_STest1, 0x22); +#endif + + return; + + /* Post_scsi_rst: clean up active SCB */ + pCurHcb->HCS_ActScb = 0; + pCurHcb->HCS_ActTcs = 0; + + while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) + { +// pCurScb->SCB_Status = SCB_DONE; + pCurScb->SCB_HaStat = HOST_BAD_PHAS; + tul_append_done_scb(pCurHcb, pCurScb); + } + /* clear sync done flag */ + pCurTcb = &pCurHcb->HCS_Tcs[0]; + for (i = 0; i < 8; pCurTcb++, i++) { + pCurTcb->TCS_Flags &= (BYTE)~(TCF_SYNC_DONE|TCF_WDTR_DONE); + /* Initialize the sync. xfer register values to an asyn xfer */ + pCurTcb->TCS_JS_Period = 5; /* Async xfer before nego. */ + pCurTcb->TCS_JS_Offset = 0x0; /* Async xfer before nego. */ + pCurTcb->TCS_JS_Config3 = 0x8; /* Fast clock */ + } /* for */ - pCurHcb->HCS_Config = i91unvramp->NVM_SCSIInfo[0].NVM_ChConfig1; +#endif + return (SCSI_RESET_SUCCESS); +} - pCurHcb->HCS_SCSI_ID = i91unvramp->NVM_SCSIInfo[0].NVM_ChSCSIID; - pCurHcb->HCS_IdMask = ~(1 << pCurHcb->HCS_SCSI_ID); +/***************************************************************************/ +int init_tulip(HCS *pCurHcb, SCB *scbp, int tul_num_scb, BYTE *pbBiosAdr, int seconds) +{ + int i; + WORD *pwFlags; + BYTE *pbHeads; + SCB *pTmpScb, *pPrevScb = NULL; + + pCurHcb->HCS_NumScbs = tul_num_scb; + pCurHcb->HCS_Semaph = 1; + pCurHcb->HCS_JSStatus0 = 0; + pCurHcb->HCS_Scb = scbp; + pCurHcb->HCS_NxtPend = scbp; + pCurHcb->HCS_NxtAvail = scbp; + for (i = 0, pTmpScb = scbp; i < tul_num_scb; i++, pTmpScb++) + { + pTmpScb->SCB_TagId = i; + if (i != 0) + pPrevScb->SCB_NxtScb = pTmpScb; + pPrevScb = pTmpScb; + } + pPrevScb->SCB_NxtScb = NULL; + pCurHcb->HCS_ScbEnd = pTmpScb; + pCurHcb->HCS_FirstAvail = scbp; + pCurHcb->HCS_LastAvail = pPrevScb; + pCurHcb->HCS_FirstPend = NULL; + pCurHcb->HCS_LastPend = NULL; + pCurHcb->HCS_FirstBusy = NULL; + pCurHcb->HCS_LastBusy = NULL; + pCurHcb->HCS_FirstDone = NULL; + pCurHcb->HCS_LastDone = NULL; + pCurHcb->HCS_ActScb = NULL; + pCurHcb->HCS_ActTcs = NULL; + + tul_read_eeprom( pCurHcb->HCS_Base ); + /*---------- get H/A configuration -------------*/ + if (i91unvramp->NVM_SCSIInfo[0].NVM_NumOfTarg == 8) + pCurHcb->HCS_MaxTar = 8; + else + pCurHcb->HCS_MaxTar = 16; + + pCurHcb->HCS_Config = i91unvramp->NVM_SCSIInfo[0].NVM_ChConfig1; + + pCurHcb->HCS_SCSI_ID = i91unvramp->NVM_SCSIInfo[0].NVM_ChSCSIID; + pCurHcb->HCS_IdMask = ~(1 << pCurHcb->HCS_SCSI_ID); #if CHK_PARITY - /* Enable parity error response */ - TUL_WR(pCurHcb->HCS_Base + TUL_PCMD, TUL_RD(pCurHcb->HCS_Base, TUL_PCMD) | 0x40); + /* Enable parity error response */ + TUL_WR(pCurHcb->HCS_Base + TUL_PCMD, TUL_RD(pCurHcb->HCS_Base, TUL_PCMD) | 0x40); #endif - /* Mask all the interrupt */ - TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); - - tul_stop_bm(pCurHcb); - /* --- Initialize the tulip --- */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_RST_CHIP); + /* Mask all the interrupt */ + TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); - /* program HBA's SCSI ID */ - TUL_WR(pCurHcb->HCS_Base + TUL_SScsiId, pCurHcb->HCS_SCSI_ID << 4); + tul_stop_bm(pCurHcb); + /* --- Initialize the tulip --- */ + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_RST_CHIP); + + /* program HBA's SCSI ID */ + TUL_WR(pCurHcb->HCS_Base + TUL_SScsiId, pCurHcb->HCS_SCSI_ID << 4); /* Enable Initiator Mode ,phase latch,alternate sync period mode, - disable SCSI reset */ - if (pCurHcb->HCS_Config & HCC_EN_PAR) - pCurHcb->HCS_SConf1 = (TSC_INITDEFAULT | TSC_EN_SCSI_PAR); - else - pCurHcb->HCS_SConf1 = (TSC_INITDEFAULT); - TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurHcb->HCS_SConf1); + disable SCSI reset */ + if (pCurHcb->HCS_Config & HCC_EN_PAR) + pCurHcb->HCS_SConf1 = (TSC_INITDEFAULT | TSC_EN_SCSI_PAR); + else + pCurHcb->HCS_SConf1 = (TSC_INITDEFAULT); + TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurHcb->HCS_SConf1); - /* Enable HW reselect */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT); + /* Enable HW reselect */ + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT ); - TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, 0); + TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, 0); /* selection time out = 250 ms */ - TUL_WR(pCurHcb->HCS_Base + TUL_STimeOut, 153); - -/*--------- Enable SCSI terminator -----*/ - TUL_WR(pCurHcb->HCS_Base + TUL_XCtrl, (pCurHcb->HCS_Config & (HCC_ACT_TERM1 | HCC_ACT_TERM2))); - TUL_WR(pCurHcb->HCS_Base + TUL_GCTRL1, - ((pCurHcb->HCS_Config & HCC_AUTO_TERM) >> 4) | (TUL_RD(pCurHcb->HCS_Base, TUL_GCTRL1) & 0xFE)); - - for (i = 0, - pwFlags = (WORD *) & (i91unvramp->NVM_SCSIInfo[0].NVM_Targ0Config), - pbHeads = pbBiosAdr + 0x180; - i < pCurHcb->HCS_MaxTar; - i++, pwFlags++) { - pCurHcb->HCS_Tcs[i].TCS_Flags = *pwFlags & ~(TCF_SYNC_DONE | TCF_WDTR_DONE); - if (pCurHcb->HCS_Tcs[i].TCS_Flags & TCF_EN_255) - pCurHcb->HCS_Tcs[i].TCS_DrvFlags = TCF_DRV_255_63; - else - pCurHcb->HCS_Tcs[i].TCS_DrvFlags = 0; - pCurHcb->HCS_Tcs[i].TCS_JS_Period = 0; - pCurHcb->HCS_Tcs[i].TCS_SConfig0 = pCurHcb->HCS_SConf1; - pCurHcb->HCS_Tcs[i].TCS_DrvHead = *pbHeads++; - if (pCurHcb->HCS_Tcs[i].TCS_DrvHead == 255) - pCurHcb->HCS_Tcs[i].TCS_DrvFlags = TCF_DRV_255_63; - else - pCurHcb->HCS_Tcs[i].TCS_DrvFlags = 0; - pCurHcb->HCS_Tcs[i].TCS_DrvSector = *pbHeads++; - pCurHcb->HCS_Tcs[i].TCS_Flags &= ~TCF_BUSY; - pCurHcb->HCS_ActTags[i] = 0; - pCurHcb->HCS_MaxTags[i] = 0xFF; - } /* for */ - printk("i91u: PCI Base=0x%04X, IRQ=%d, BIOS=0x%04X0, SCSI ID=%d\n", - pCurHcb->HCS_Base, pCurHcb->HCS_Intr, - pCurHcb->HCS_BIOS, pCurHcb->HCS_SCSI_ID); -/*------------------- reset SCSI Bus ---------------------------*/ - if (pCurHcb->HCS_Config & HCC_SCSI_RESET) { - printk("i91u: Reset SCSI Bus ... \n"); - tul_reset_scsi(pCurHcb, seconds); - } - TUL_WR(pCurHcb->HCS_Base + TUL_SCFG1, 0x17); - TUL_WR(pCurHcb->HCS_Base + TUL_SIntEnable, 0xE9); - return (0); + TUL_WR(pCurHcb->HCS_Base + TUL_STimeOut, 153); + + /*--------- Enable SCSI terminator -----*/ + TUL_WR(pCurHcb->HCS_Base + TUL_XCtrl, (pCurHcb->HCS_Config & (HCC_ACT_TERM1 | HCC_ACT_TERM2))); + TUL_WR(pCurHcb->HCS_Base + TUL_GCTRL1, + ((pCurHcb->HCS_Config & HCC_AUTO_TERM) >> 4) | (TUL_RD(pCurHcb->HCS_Base, TUL_GCTRL1) & 0xFE)); + +// dBiosAdr += 0x180; + for (i = 0, + pwFlags = (WORD *) &(i91unvramp->NVM_SCSIInfo[0].NVM_Targ0Config), +// pbHeads = (BYTE *)(dBiosAdr); + pbHeads = pbBiosAdr+0x180; + i < pCurHcb->HCS_MaxTar; + i++, pwFlags++) + { + pCurHcb->HCS_Tcs[i].TCS_Flags = *pwFlags & ~(TCF_SYNC_DONE | TCF_WDTR_DONE); + if (pCurHcb->HCS_Tcs[i].TCS_Flags & TCF_EN_255) + pCurHcb->HCS_Tcs[i].TCS_DrvFlags = TCF_DRV_255_63; + else + pCurHcb->HCS_Tcs[i].TCS_DrvFlags = 0; + pCurHcb->HCS_Tcs[i].TCS_JS_Period = 0; + pCurHcb->HCS_Tcs[i].TCS_SConfig0 = pCurHcb->HCS_SConf1; + pCurHcb->HCS_Tcs[i].TCS_DrvHead = *pbHeads++; + if (pCurHcb->HCS_Tcs[i].TCS_DrvHead == 255) + pCurHcb->HCS_Tcs[i].TCS_DrvFlags = TCF_DRV_255_63; + else + pCurHcb->HCS_Tcs[i].TCS_DrvFlags = 0; + pCurHcb->HCS_Tcs[i].TCS_DrvSector = *pbHeads++; + pCurHcb->HCS_Tcs[i].TCS_Flags &= ~TCF_BUSY; + pCurHcb->HCS_ActTags[i] = 0; + pCurHcb->HCS_MaxTags[i] = 0xFF; + } /* for */ +#if 1 + printk("i91u: PCI Base=0x%04X, IRQ=%d, BIOS=0x%04X0, SCSI ID=%d\n", + pCurHcb->HCS_Base, pCurHcb->HCS_Intr, + pCurHcb->HCS_BIOS, pCurHcb->HCS_SCSI_ID); +#endif + /*------------------- reset SCSI Bus ---------------------------*/ + if (pCurHcb->HCS_Config & HCC_SCSI_RESET) + { +#if 1 + printk("i91u: Reset SCSI Bus ... \n"); +#endif + tul_reset_scsi(pCurHcb, seconds); + } + TUL_WR(pCurHcb->HCS_Base + TUL_SCFG1, 0x17); + TUL_WR(pCurHcb->HCS_Base + TUL_SIntEnable, 0xE9); + return(0); } /***************************************************************************/ -SCB *tul_alloc_scb(HCS * hcsp) +SCB *tul_alloc_scb(HCS *hcsp) { - SCB *pTmpScb; - ULONG flags; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(hcsp->HCS_AvailLock), flags); -#else - save_flags(flags); - cli(); -#endif - if ((pTmpScb = hcsp->HCS_FirstAvail) != NULL) { + SCB *pTmpScb; + ULONG flags; + + save_flags(flags); + cli(); + if ((pTmpScb = hcsp->HCS_FirstAvail) != NULL) + { #if DEBUG_QUEUE - printk("find scb at %08lx\n", (ULONG) pTmpScb); + printk("find scb at %08lx\n", (ULONG) pTmpScb); #endif - if ((hcsp->HCS_FirstAvail = pTmpScb->SCB_NxtScb) == NULL) - hcsp->HCS_LastAvail = NULL; - pTmpScb->SCB_NxtScb = NULL; - pTmpScb->SCB_Status = SCB_RENT; + if ((hcsp->HCS_FirstAvail = pTmpScb->SCB_NxtScb) == NULL) + hcsp->HCS_LastAvail = NULL; + pTmpScb->SCB_NxtScb = NULL; + pTmpScb->SCB_Status = SCB_RENT; } -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(hcsp->HCS_AvailLock), flags); -#else - restore_flags(flags); -#endif - return (pTmpScb); + restore_flags(flags); + return (pTmpScb); } /***************************************************************************/ -void tul_release_scb(HCS * hcsp, SCB * scbp) +void tul_release_scb(HCS *hcsp, SCB *scbp) { - ULONG flags; + ULONG flags; #if DEBUG_QUEUE - printk("Release SCB %lx; ", (ULONG) scbp); -#endif -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(hcsp->HCS_AvailLock), flags); -#else - save_flags(flags); - cli(); -#endif - scbp->SCB_Srb = 0; - scbp->SCB_Status = 0; - scbp->SCB_NxtScb = NULL; - if (hcsp->HCS_LastAvail != NULL) { - hcsp->HCS_LastAvail->SCB_NxtScb = scbp; - hcsp->HCS_LastAvail = scbp; - } else { - hcsp->HCS_FirstAvail = scbp; - hcsp->HCS_LastAvail = scbp; - } -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(hcsp->HCS_AvailLock), flags); -#else - restore_flags(flags); +printk("Release SCB %lx; ", (ULONG) scbp); #endif + save_flags(flags); + cli(); + scbp->SCB_Srb = 0; + scbp->SCB_Status = 0; + scbp->SCB_NxtScb = NULL; + if (hcsp->HCS_LastAvail != NULL) + { + hcsp->HCS_LastAvail->SCB_NxtScb = scbp; + hcsp->HCS_LastAvail = scbp; + } + else + { + hcsp->HCS_FirstAvail = scbp; + hcsp->HCS_LastAvail = scbp; + } + restore_flags(flags); } /***************************************************************************/ -void tul_append_pend_scb(HCS * pCurHcb, SCB * scbp) +void tul_append_pend_scb(HCS *pCurHcb, SCB *scbp) { #if DEBUG_QUEUE - printk("Append pend SCB %lx; ", (ULONG) scbp); +printk("Append pend SCB %lx; ", (ULONG) scbp); #endif - scbp->SCB_Status = SCB_PEND; - scbp->SCB_NxtScb = NULL; - if (pCurHcb->HCS_LastPend != NULL) { - pCurHcb->HCS_LastPend->SCB_NxtScb = scbp; - pCurHcb->HCS_LastPend = scbp; - } else { - pCurHcb->HCS_FirstPend = scbp; - pCurHcb->HCS_LastPend = scbp; + scbp->SCB_Status = SCB_PEND; + scbp->SCB_NxtScb = NULL; + if (pCurHcb->HCS_LastPend != NULL) + { + pCurHcb->HCS_LastPend->SCB_NxtScb = scbp; + pCurHcb->HCS_LastPend = scbp; + } + else + { + pCurHcb->HCS_FirstPend = scbp; + pCurHcb->HCS_LastPend = scbp; } } /***************************************************************************/ -void tul_push_pend_scb(HCS * pCurHcb, SCB * scbp) +void tul_push_pend_scb(HCS *pCurHcb, SCB *scbp) { #if DEBUG_QUEUE - printk("Push pend SCB %lx; ", (ULONG) scbp); +printk("Push pend SCB %lx; ", (ULONG) scbp); #endif - scbp->SCB_Status = SCB_PEND; - if ((scbp->SCB_NxtScb = pCurHcb->HCS_FirstPend) != NULL) { - pCurHcb->HCS_FirstPend = scbp; - } else { - pCurHcb->HCS_FirstPend = scbp; - pCurHcb->HCS_LastPend = scbp; + scbp->SCB_Status = SCB_PEND; + if ((scbp->SCB_NxtScb = pCurHcb->HCS_FirstPend) != NULL) + { + pCurHcb->HCS_FirstPend = scbp; + } + else + { + pCurHcb->HCS_FirstPend = scbp; + pCurHcb->HCS_LastPend = scbp; } } /***************************************************************************/ -SCB *tul_find_first_pend_scb(HCS * pCurHcb) +SCB *tul_find_first_pend_scb(HCS *pCurHcb) { - SCB *pFirstPend; + SCB *pFirstPend; - pFirstPend = pCurHcb->HCS_FirstPend; - while (pFirstPend != NULL) { - if (pFirstPend->SCB_Opcode != ExecSCSI) { - return (pFirstPend); - } - if (pFirstPend->SCB_TagMsg == 0) { - if ((pCurHcb->HCS_ActTags[pFirstPend->SCB_Target] == 0) && - !(pCurHcb->HCS_Tcs[pFirstPend->SCB_Target].TCS_Flags & TCF_BUSY)) { - return (pFirstPend); - } - } else { - if ((pCurHcb->HCS_ActTags[pFirstPend->SCB_Target] >= - pCurHcb->HCS_MaxTags[pFirstPend->SCB_Target]) | - (pCurHcb->HCS_Tcs[pFirstPend->SCB_Target].TCS_Flags & TCF_BUSY)) { - pFirstPend = pFirstPend->SCB_NxtScb; - continue; - } - return (pFirstPend); + pFirstPend = pCurHcb->HCS_FirstPend; + while (pFirstPend != NULL) { + if (pFirstPend->SCB_Opcode != ExecSCSI) { + return (pFirstPend); + } + + if (pFirstPend->SCB_TagMsg == 0) + { + if ((pCurHcb->HCS_ActTags[pFirstPend->SCB_Target] == 0) && + !(pCurHcb->HCS_Tcs[pFirstPend->SCB_Target].TCS_Flags & TCF_BUSY)) + { + return (pFirstPend); } + } + else + { + if ((pCurHcb->HCS_ActTags[pFirstPend->SCB_Target] >= + pCurHcb->HCS_MaxTags[pFirstPend->SCB_Target]) | + (pCurHcb->HCS_Tcs[pFirstPend->SCB_Target].TCS_Flags & TCF_BUSY)) + { pFirstPend = pFirstPend->SCB_NxtScb; + continue; + } + return (pFirstPend); + } + pFirstPend = pFirstPend->SCB_NxtScb; } - return (pFirstPend); + return (pFirstPend); } /***************************************************************************/ -SCB *tul_pop_pend_scb(HCS * pCurHcb) +SCB *tul_pop_pend_scb(HCS *pCurHcb) { - SCB *pTmpScb; + SCB *pTmpScb; - if ((pTmpScb = pCurHcb->HCS_FirstPend) != NULL) { - if ((pCurHcb->HCS_FirstPend = pTmpScb->SCB_NxtScb) == NULL) - pCurHcb->HCS_LastPend = NULL; - pTmpScb->SCB_NxtScb = NULL; + if ((pTmpScb = pCurHcb->HCS_FirstPend) != NULL) + { + if ((pCurHcb->HCS_FirstPend = pTmpScb->SCB_NxtScb) == NULL) + pCurHcb->HCS_LastPend = NULL; + pTmpScb->SCB_NxtScb = NULL; } #if DEBUG_QUEUE - printk("Pop pend SCB %lx; ", (ULONG) pTmpScb); +printk("Pop pend SCB %lx; ", (ULONG) pTmpScb); #endif - return (pTmpScb); + return (pTmpScb); } /***************************************************************************/ -void tul_unlink_pend_scb(HCS * pCurHcb, SCB * pCurScb) +void tul_unlink_pend_scb(HCS *pCurHcb, SCB *pCurScb) { - SCB *pTmpScb, *pPrevScb; + SCB *pTmpScb, *pPrevScb; #if DEBUG_QUEUE - printk("unlink pend SCB %lx; ", (ULONG) pCurScb); +printk("unlink pend SCB %lx; ", (ULONG) pCurScb); #endif - pPrevScb = pTmpScb = pCurHcb->HCS_FirstPend; - while (pTmpScb != NULL) { - if (pCurScb == pTmpScb) { /* Unlink this SCB */ - if (pTmpScb == pCurHcb->HCS_FirstPend) { - if ((pCurHcb->HCS_FirstPend = pTmpScb->SCB_NxtScb) == NULL) - pCurHcb->HCS_LastPend = NULL; - } else { - pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb; - if (pTmpScb == pCurHcb->HCS_LastPend) - pCurHcb->HCS_LastPend = pPrevScb; - } - pTmpScb->SCB_NxtScb = NULL; - break; + pPrevScb = pTmpScb = pCurHcb->HCS_FirstPend; + while (pTmpScb != NULL) + { + if (pCurScb == pTmpScb) + { /* Unlink this SCB */ + if (pTmpScb == pCurHcb->HCS_FirstPend) + { + if ((pCurHcb->HCS_FirstPend = pTmpScb->SCB_NxtScb) == NULL) + pCurHcb->HCS_LastPend = NULL; + } + else + { + pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb; + if (pTmpScb == pCurHcb->HCS_LastPend) + pCurHcb->HCS_LastPend = pPrevScb; } - pPrevScb = pTmpScb; - pTmpScb = pTmpScb->SCB_NxtScb; + pTmpScb->SCB_NxtScb = NULL; + break; + } + pPrevScb = pTmpScb; + pTmpScb = pTmpScb->SCB_NxtScb; } - return; + return; } /***************************************************************************/ -void tul_append_busy_scb(HCS * pCurHcb, SCB * scbp) +void tul_append_busy_scb(HCS *pCurHcb, SCB *scbp) { #if DEBUG_QUEUE - printk("append busy SCB %lx; ", (ULONG) scbp); +printk("append busy SCB %lx; ", (ULONG) scbp); #endif - if (scbp->SCB_TagMsg) - pCurHcb->HCS_ActTags[scbp->SCB_Target]++; - else - pCurHcb->HCS_Tcs[scbp->SCB_Target].TCS_Flags |= TCF_BUSY; - scbp->SCB_Status = SCB_BUSY; - scbp->SCB_NxtScb = NULL; - if (pCurHcb->HCS_LastBusy != NULL) { - pCurHcb->HCS_LastBusy->SCB_NxtScb = scbp; - pCurHcb->HCS_LastBusy = scbp; - } else { - pCurHcb->HCS_FirstBusy = scbp; - pCurHcb->HCS_LastBusy = scbp; + if (scbp->SCB_TagMsg) + pCurHcb->HCS_ActTags[scbp->SCB_Target]++; + else + pCurHcb->HCS_Tcs[scbp->SCB_Target].TCS_Flags |= TCF_BUSY; + scbp->SCB_Status = SCB_BUSY; + scbp->SCB_NxtScb = NULL; + if (pCurHcb->HCS_LastBusy != NULL) + { + pCurHcb->HCS_LastBusy->SCB_NxtScb = scbp; + pCurHcb->HCS_LastBusy = scbp; + } + else + { + pCurHcb->HCS_FirstBusy = scbp; + pCurHcb->HCS_LastBusy = scbp; } } /***************************************************************************/ -SCB *tul_pop_busy_scb(HCS * pCurHcb) +SCB *tul_pop_busy_scb(HCS *pCurHcb) { - SCB *pTmpScb; + SCB *pTmpScb; - if ((pTmpScb = pCurHcb->HCS_FirstBusy) != NULL) { - if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL) - pCurHcb->HCS_LastBusy = NULL; - pTmpScb->SCB_NxtScb = NULL; - if (pTmpScb->SCB_TagMsg) - pCurHcb->HCS_ActTags[pTmpScb->SCB_Target]--; - else - pCurHcb->HCS_Tcs[pTmpScb->SCB_Target].TCS_Flags &= ~TCF_BUSY; + if ((pTmpScb = pCurHcb->HCS_FirstBusy) != NULL) + { + if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL) + pCurHcb->HCS_LastBusy = NULL; + pTmpScb->SCB_NxtScb = NULL; + if (pTmpScb->SCB_TagMsg) + pCurHcb->HCS_ActTags[pTmpScb->SCB_Target]--; + else + pCurHcb->HCS_Tcs[pTmpScb->SCB_Target].TCS_Flags &= ~TCF_BUSY; } #if DEBUG_QUEUE - printk("Pop busy SCB %lx; ", (ULONG) pTmpScb); +printk("Pop busy SCB %lx; ", (ULONG) pTmpScb); #endif - return (pTmpScb); + return (pTmpScb); } /***************************************************************************/ -void tul_unlink_busy_scb(HCS * pCurHcb, SCB * pCurScb) +void tul_unlink_busy_scb(HCS *pCurHcb, SCB *pCurScb) { - SCB *pTmpScb, *pPrevScb; + SCB *pTmpScb, *pPrevScb; #if DEBUG_QUEUE - printk("unlink busy SCB %lx; ", (ULONG) pCurScb); +printk("unlink busy SCB %lx; ", (ULONG) pCurScb); #endif - pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy; - while (pTmpScb != NULL) { - if (pCurScb == pTmpScb) { /* Unlink this SCB */ - if (pTmpScb == pCurHcb->HCS_FirstBusy) { - if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL) - pCurHcb->HCS_LastBusy = NULL; - } else { - pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb; - if (pTmpScb == pCurHcb->HCS_LastBusy) - pCurHcb->HCS_LastBusy = pPrevScb; - } - pTmpScb->SCB_NxtScb = NULL; - if (pTmpScb->SCB_TagMsg) - pCurHcb->HCS_ActTags[pTmpScb->SCB_Target]--; - else - pCurHcb->HCS_Tcs[pTmpScb->SCB_Target].TCS_Flags &= ~TCF_BUSY; - break; + pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy; + while (pTmpScb != NULL) + { + if (pCurScb == pTmpScb) + { /* Unlink this SCB */ + if (pTmpScb == pCurHcb->HCS_FirstBusy) + { + if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL) + pCurHcb->HCS_LastBusy = NULL; + } + else + { + pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb; + if (pTmpScb == pCurHcb->HCS_LastBusy) + pCurHcb->HCS_LastBusy = pPrevScb; } - pPrevScb = pTmpScb; - pTmpScb = pTmpScb->SCB_NxtScb; + pTmpScb->SCB_NxtScb = NULL; + if (pTmpScb->SCB_TagMsg) + pCurHcb->HCS_ActTags[pTmpScb->SCB_Target]--; + else + pCurHcb->HCS_Tcs[pTmpScb->SCB_Target].TCS_Flags &= ~TCF_BUSY; + break; + } + pPrevScb = pTmpScb; + pTmpScb = pTmpScb->SCB_NxtScb; } - return; + return; } /***************************************************************************/ -SCB *tul_find_busy_scb(HCS * pCurHcb, WORD tarlun) +SCB *tul_find_busy_scb(HCS *pCurHcb, WORD tarlun) { - SCB *pTmpScb, *pPrevScb; - WORD scbp_tarlun; + SCB *pTmpScb, *pPrevScb; + WORD scbp_tarlun; - pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy; - while (pTmpScb != NULL) { - scbp_tarlun = (pTmpScb->SCB_Lun << 8) | (pTmpScb->SCB_Target); - if (scbp_tarlun == tarlun) { /* Unlink this SCB */ - break; + pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy; + while (pTmpScb != NULL) + { + scbp_tarlun = (pTmpScb->SCB_Lun << 8) | (pTmpScb->SCB_Target); + if (scbp_tarlun == tarlun) + { /* Unlink this SCB */ +#if 0 + if (pTmpScb == pCurHcb->HCS_FirstBusy) + { + if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL) + pCurHcb->HCS_LastBusy = NULL; + } + else + { + pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb; + if (pTmpScb == pCurHcb->HCS_LastBusy) + pCurHcb->HCS_LastBusy = pPrevScb; } - pPrevScb = pTmpScb; - pTmpScb = pTmpScb->SCB_NxtScb; + pTmpScb->SCB_NxtScb = NULL; +#endif + break; + } + pPrevScb = pTmpScb; + pTmpScb = pTmpScb->SCB_NxtScb; } #if DEBUG_QUEUE - printk("find busy SCB %lx; ", (ULONG) pTmpScb); +printk("find busy SCB %lx; ", (ULONG) pTmpScb); #endif - return (pTmpScb); + return (pTmpScb); } /***************************************************************************/ -void tul_append_done_scb(HCS * pCurHcb, SCB * scbp) +void tul_append_done_scb(HCS *pCurHcb, SCB *scbp) { #if DEBUG_QUEUE - printk("append done SCB %lx; ", (ULONG) scbp); +printk("append done SCB %lx; ", (ULONG) scbp); #endif +/* tul_unlink_busy_scb(pCurHcb, scbp);*/ - scbp->SCB_Status = SCB_DONE; - scbp->SCB_NxtScb = NULL; - if (pCurHcb->HCS_LastDone != NULL) { - pCurHcb->HCS_LastDone->SCB_NxtScb = scbp; - pCurHcb->HCS_LastDone = scbp; - } else { - pCurHcb->HCS_FirstDone = scbp; - pCurHcb->HCS_LastDone = scbp; + scbp->SCB_Status = SCB_DONE; + scbp->SCB_NxtScb = NULL; + if (pCurHcb->HCS_LastDone != NULL) + { + pCurHcb->HCS_LastDone->SCB_NxtScb = scbp; + pCurHcb->HCS_LastDone = scbp; + } + else + { + pCurHcb->HCS_FirstDone = scbp; + pCurHcb->HCS_LastDone = scbp; } } /***************************************************************************/ -SCB *tul_find_done_scb(HCS * pCurHcb) +SCB *tul_find_done_scb(HCS *pCurHcb) { - SCB *pTmpScb; + SCB *pTmpScb; - if ((pTmpScb = pCurHcb->HCS_FirstDone) != NULL) { - if ((pCurHcb->HCS_FirstDone = pTmpScb->SCB_NxtScb) == NULL) - pCurHcb->HCS_LastDone = NULL; - pTmpScb->SCB_NxtScb = NULL; + if ((pTmpScb = pCurHcb->HCS_FirstDone) != NULL) + { + if ((pCurHcb->HCS_FirstDone = pTmpScb->SCB_NxtScb) == NULL) + pCurHcb->HCS_LastDone = NULL; + pTmpScb->SCB_NxtScb = NULL; } #if DEBUG_QUEUE - printk("find done SCB %lx; ", (ULONG) pTmpScb); +printk("find done SCB %lx; ", (ULONG) pTmpScb); #endif - return (pTmpScb); + return (pTmpScb); } /***************************************************************************/ -int tul_abort_srb(HCS * pCurHcb, ULONG srbp) +int tul_abort_srb(HCS *pCurHcb, ULONG srbp) { - ULONG flags; - SCB *pTmpScb, *pPrevScb; - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags); -#else - save_flags(flags); - cli(); -#endif - - if ((pCurHcb->HCS_Semaph == 0) && (pCurHcb->HCS_ActScb == NULL)) { - TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); - /* disable Jasmin SCSI Int */ - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#endif + ULONG flags; + SCB *pTmpScb, *pPrevScb; - tulip_main(pCurHcb); + save_flags(flags); + cli(); -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags); -#endif - - pCurHcb->HCS_Semaph = 1; - TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F); - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif + if ((pCurHcb->HCS_Semaph == 0) && (pCurHcb->HCS_ActScb == NULL)) { + TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); + /* disable Jasmin SCSI Int */ + tulip_main(pCurHcb); - return SCSI_ABORT_SNOOZE; - } - pPrevScb = pTmpScb = pCurHcb->HCS_FirstPend; /* Check Pend queue */ - while (pTmpScb != NULL) { - /* 07/27/98 */ - if (pTmpScb->SCB_Srb == (unsigned char *) srbp) { - if (pTmpScb == pCurHcb->HCS_ActScb) { -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif - return SCSI_ABORT_BUSY; - } else if (pTmpScb == pCurHcb->HCS_FirstPend) { - if ((pCurHcb->HCS_FirstPend = pTmpScb->SCB_NxtScb) == NULL) - pCurHcb->HCS_LastPend = NULL; - } else { - pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb; - if (pTmpScb == pCurHcb->HCS_LastPend) - pCurHcb->HCS_LastPend = pPrevScb; - } - pTmpScb->SCB_HaStat = HOST_ABORTED; - pTmpScb->SCB_Flags |= SCF_DONE; - if (pTmpScb->SCB_Flags & SCF_POST) - (*pTmpScb->SCB_Post) ((BYTE *) pCurHcb, (BYTE *) pTmpScb); -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif - return SCSI_ABORT_SUCCESS; - } - pPrevScb = pTmpScb; - pTmpScb = pTmpScb->SCB_NxtScb; - } + pCurHcb->HCS_Semaph = 1; + TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F); - pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy; /* Check Busy queue */ - while (pTmpScb != NULL) { + restore_flags(flags); - if (pTmpScb->SCB_Srb == (unsigned char *) srbp) { + return SCSI_ABORT_SNOOZE; + } - if (pTmpScb == pCurHcb->HCS_ActScb) { -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif - return SCSI_ABORT_BUSY; - } else if (pTmpScb->SCB_TagMsg == 0) { -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif - return SCSI_ABORT_BUSY; - } else { - pCurHcb->HCS_ActTags[pTmpScb->SCB_Target]--; - if (pTmpScb == pCurHcb->HCS_FirstBusy) { - if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL) - pCurHcb->HCS_LastBusy = NULL; - } else { - pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb; - if (pTmpScb == pCurHcb->HCS_LastBusy) - pCurHcb->HCS_LastBusy = pPrevScb; - } - pTmpScb->SCB_NxtScb = NULL; - - - pTmpScb->SCB_HaStat = HOST_ABORTED; - pTmpScb->SCB_Flags |= SCF_DONE; - if (pTmpScb->SCB_Flags & SCF_POST) - (*pTmpScb->SCB_Post) ((BYTE *) pCurHcb, (BYTE *) pTmpScb); -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif - return SCSI_ABORT_SUCCESS; - } - } - pPrevScb = pTmpScb; - pTmpScb = pTmpScb->SCB_NxtScb; - } -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif - return (SCSI_ABORT_NOT_RUNNING); + pPrevScb = pTmpScb = pCurHcb->HCS_FirstPend; /* Check Pend queue */ + while (pTmpScb != NULL) + { + /* 07/27/98 */ + if (pTmpScb->SCB_Srb == (unsigned char *)srbp) { + if (pTmpScb == pCurHcb->HCS_ActScb) { + restore_flags(flags); + return SCSI_ABORT_BUSY; + } + else if (pTmpScb == pCurHcb->HCS_FirstPend) { + if ((pCurHcb->HCS_FirstPend = pTmpScb->SCB_NxtScb) == NULL) + pCurHcb->HCS_LastPend = NULL; + } + else { + pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb; + if (pTmpScb == pCurHcb->HCS_LastPend) + pCurHcb->HCS_LastPend = pPrevScb; + } + pTmpScb->SCB_HaStat = HOST_ABORTED; + pTmpScb->SCB_Flags |= SCF_DONE; + if (pTmpScb->SCB_Flags & SCF_POST) + (*pTmpScb->SCB_Post)((BYTE *) pCurHcb, (BYTE *) pTmpScb); + restore_flags(flags); + return SCSI_ABORT_SUCCESS ; + } + pPrevScb = pTmpScb; + pTmpScb = pTmpScb->SCB_NxtScb; + } + + pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy; /* Check Busy queue */ + while (pTmpScb != NULL) { + + if (pTmpScb->SCB_Srb == (unsigned char *)srbp) { + + if (pTmpScb == pCurHcb->HCS_ActScb) { + restore_flags(flags); + return SCSI_ABORT_BUSY; + } + else if (pTmpScb->SCB_TagMsg == 0) { + restore_flags(flags); + return SCSI_ABORT_BUSY; + } + else { + pCurHcb->HCS_ActTags[pTmpScb->SCB_Target]--; + if (pTmpScb == pCurHcb->HCS_FirstBusy) { + if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL) + pCurHcb->HCS_LastBusy = NULL; + } + else { + pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb; + if (pTmpScb == pCurHcb->HCS_LastBusy) + pCurHcb->HCS_LastBusy = pPrevScb; + } + pTmpScb->SCB_NxtScb = NULL; + + + pTmpScb->SCB_HaStat = HOST_ABORTED; + pTmpScb->SCB_Flags |= SCF_DONE; + if (pTmpScb->SCB_Flags & SCF_POST) + (*pTmpScb->SCB_Post)((BYTE *) pCurHcb, (BYTE *) pTmpScb); + restore_flags(flags); + return SCSI_ABORT_SUCCESS ; + } + } + pPrevScb = pTmpScb; + pTmpScb = pTmpScb->SCB_NxtScb; + } + restore_flags(flags); + return (SCSI_ABORT_NOT_RUNNING); } /***************************************************************************/ -int tul_bad_seq(HCS * pCurHcb) +int tul_bad_seq(HCS *pCurHcb) { - SCB *pCurScb; - - printk("tul_bad_seg c=%d\n", pCurHcb->HCS_Index); + SCB *pCurScb; - if ((pCurScb = pCurHcb->HCS_ActScb) != NULL) { - tul_unlink_busy_scb(pCurHcb, pCurScb); - pCurScb->SCB_HaStat = HOST_BAD_PHAS; - pCurScb->SCB_TaStat = 0; - tul_append_done_scb(pCurHcb, pCurScb); +#if 1 +printk("tul_bad_seg c=%d\n", pCurHcb->HCS_Index); +#endif + if ((pCurScb = pCurHcb->HCS_ActScb) != NULL) + { + tul_unlink_busy_scb(pCurHcb, pCurScb); + pCurScb->SCB_HaStat = HOST_BAD_PHAS; + pCurScb->SCB_TaStat = 0; +// pCurScb->SCB_Status = SCB_DONE; /* Done */ + tul_append_done_scb(pCurHcb, pCurScb); } - tul_stop_bm(pCurHcb); - tul_reset_scsi(pCurHcb, 8); /* 7/29/98 */ + tul_stop_bm(pCurHcb); + + tul_reset_scsi(pCurHcb, 8); /* 7/29/98 */ - return (tul_post_scsi_rst(pCurHcb)); + return (tul_post_scsi_rst(pCurHcb)); } /************************************************************************/ -int tul_device_reset(HCS * pCurHcb, ULONG pSrb, unsigned int target, unsigned int ResetFlags) +int tul_device_reset(HCS *pCurHcb, ULONG pSrb, unsigned int target, unsigned int ResetFlags) { - ULONG flags; - SCB *pScb; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags); -#else - save_flags(flags); - cli(); -#endif + ULONG flags; + SCB *pScb; - if (ResetFlags & SCSI_RESET_ASYNCHRONOUS) { +#if 0 +printk("tul_device_reset c=%d %d \n", pCurHcb->HCS_Index, pCurHcb->HCS_Semaph); +#endif - if ((pCurHcb->HCS_Semaph == 0) && (pCurHcb->HCS_ActScb == NULL)) { - TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); - /* disable Jasmin SCSI Int */ + save_flags(flags); + cli(); -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#endif - tulip_main(pCurHcb); + if (ResetFlags & SCSI_RESET_ASYNCHRONOUS) { -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags); -#endif + if ((pCurHcb->HCS_Semaph == 0) && (pCurHcb->HCS_ActScb == NULL)) { + TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); + /* disable Jasmin SCSI Int */ + tulip_main(pCurHcb); - pCurHcb->HCS_Semaph = 1; - TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F); + pCurHcb->HCS_Semaph = 1; + TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F); -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif + restore_flags(flags); - return SCSI_RESET_SNOOZE; - } - pScb = pCurHcb->HCS_FirstBusy; /* Check Busy queue */ - while (pScb != NULL) { - if (pScb->SCB_Srb == (unsigned char *) pSrb) - break; - pScb = pScb->SCB_NxtScb; - } - if (pScb == NULL) { - printk("Unable to Reset - No SCB Found\n"); + return SCSI_RESET_SNOOZE ; + } -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif - return SCSI_RESET_NOT_RUNNING; - } - } - if ((pScb = tul_alloc_scb(pCurHcb)) == NULL) { -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif - return SCSI_RESET_NOT_RUNNING; + pScb = pCurHcb->HCS_FirstBusy; /* Check Busy queue */ + while (pScb != NULL) { + if (pScb->SCB_Srb == (unsigned char *)pSrb) + break; + pScb = pScb->SCB_NxtScb; } - pScb->SCB_Opcode = BusDevRst; - pScb->SCB_Flags = SCF_POST; - pScb->SCB_Target = target; - pScb->SCB_Mode = 0; + if (pScb == NULL) { + printk("Unable to Reset - No SCB Found\n"); - pScb->SCB_Srb = 0; - if (ResetFlags & SCSI_RESET_SYNCHRONOUS) { - pScb->SCB_Srb = (unsigned char *) pSrb; + restore_flags(flags); + return SCSI_RESET_NOT_RUNNING; } - tul_push_pend_scb(pCurHcb, pScb); /* push this SCB to Pending queue */ - - if (pCurHcb->HCS_Semaph == 1) { - TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); - /* disable Jasmin SCSI Int */ - pCurHcb->HCS_Semaph = 0; + } + if ((pScb = tul_alloc_scb(pCurHcb)) == NULL) { + restore_flags(flags); + return SCSI_RESET_NOT_RUNNING; + } + pScb->SCB_Opcode = BusDevRst; + pScb->SCB_Flags = SCF_POST; + pScb->SCB_Target = target; + pScb->SCB_Mode = 0; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#endif + pScb->SCB_Srb = 0; + if (ResetFlags & SCSI_RESET_SYNCHRONOUS) + { + pScb->SCB_Srb = (unsigned char *)pSrb; + } + tul_push_pend_scb(pCurHcb,pScb); /* push this SCB to Pending queue */ - tulip_main(pCurHcb); + if (pCurHcb->HCS_Semaph == 1) { + TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); + /* disable Jasmin SCSI Int */ + pCurHcb->HCS_Semaph = 0; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags); -#endif + tulip_main(pCurHcb); - pCurHcb->HCS_Semaph = 1; - TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F); + pCurHcb->HCS_Semaph = 1; + TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F); } -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif - return SCSI_RESET_PENDING; + restore_flags(flags); + return SCSI_RESET_PENDING; + + } -int tul_reset_scsi_bus(HCS * pCurHcb) +int tul_reset_scsi_bus(HCS *pCurHcb) { - ULONG flags; + ULONG flags; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags); -#else - save_flags(flags); - cli(); +#if 0 +printk("tul_reset_scsi_bus c=%d %d \n", pCurHcb->HCS_Index, pCurHcb->HCS_Semaph); #endif - TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); - pCurHcb->HCS_Semaph = 0; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif + save_flags(flags); + cli(); + TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); + pCurHcb->HCS_Semaph = 0; - tul_stop_bm(pCurHcb); + restore_flags(flags); - tul_reset_scsi(pCurHcb, 2); /* 7/29/98 */ + tul_stop_bm(pCurHcb); -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags); -#else - save_flags(flags); - cli(); -#endif - tul_post_scsi_rst(pCurHcb); + tul_reset_scsi(pCurHcb, 2); /* 7/29/98 */ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#endif + save_flags(flags); + cli(); + tul_post_scsi_rst(pCurHcb); - tulip_main(pCurHcb); +// tul_do_pause(7*100); -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags); -#endif + tulip_main(pCurHcb); - pCurHcb->HCS_Semaph = 1; - TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F); -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif - return (SCSI_RESET_SUCCESS | SCSI_RESET_HOST_RESET); + pCurHcb->HCS_Semaph = 1; + TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F); + restore_flags(flags); + return (SCSI_RESET_SUCCESS | SCSI_RESET_HOST_RESET); } /************************************************************************/ -void tul_exec_scb(HCS * pCurHcb, SCB * pCurScb) +void tul_exec_scb(HCS *pCurHcb, SCB *pCurScb) { - ULONG flags; + ULONG flags; + +/* printk("Enter tul_exec_scb");*/ + + +/* pCurScb->SCB_Status = SCB_PEND; 7/22/98 */ pCurScb->SCB_Mode = 0; pCurScb->SCB_SGIdx = 0; pCurScb->SCB_SGMax = pCurScb->SCB_SGLen; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags); -#else - save_flags(flags); - cli(); -#endif + save_flags(flags); + cli(); - tul_append_pend_scb(pCurHcb, pCurScb); /* Append this SCB to Pending queue */ + tul_append_pend_scb(pCurHcb,pCurScb); /* Append this SCB to Pending queue */ /* VVVVV 07/21/98 */ - if (pCurHcb->HCS_Semaph == 1) { - TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); - /* disable Jasmin SCSI Int */ - pCurHcb->HCS_Semaph = 0; - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#endif + if (pCurHcb->HCS_Semaph == 1) { + TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); + /* disable Jasmin SCSI Int */ + pCurHcb->HCS_Semaph = 0; - tulip_main(pCurHcb); + tulip_main(pCurHcb); -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags); -#endif - - pCurHcb->HCS_Semaph = 1; - TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F); + pCurHcb->HCS_Semaph = 1; + TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F); } -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags); -#else - restore_flags(flags); -#endif - return; + restore_flags(flags); + return; } /***************************************************************************/ -int tul_isr(HCS * pCurHcb) +int tul_isr(HCS *pCurHcb) { - /* Enter critical section */ +/* printk("Enter i91u_isr\n");*/ + /* Enter critical section */ - if (TUL_RD(pCurHcb->HCS_Base, TUL_Int) & TSS_INT_PENDING) { - if (pCurHcb->HCS_Semaph == 1) { - TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); - /* Disable Tulip SCSI Int */ - pCurHcb->HCS_Semaph = 0; + if (TUL_RD(pCurHcb->HCS_Base, TUL_Int) & TSS_INT_PENDING) + { + if (pCurHcb->HCS_Semaph == 1) + { + TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F); + /* Disable Tulip SCSI Int */ + pCurHcb->HCS_Semaph = 0; - tulip_main(pCurHcb); + tulip_main(pCurHcb); - pCurHcb->HCS_Semaph = 1; - TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F); - return (1); - } + pCurHcb->HCS_Semaph = 1; + TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F); + return (1); + } } - return (0); + return (0); } /***************************************************************************/ -int tulip_main(HCS * pCurHcb) +int tulip_main(HCS *pCurHcb) { - SCB *pCurScb; + SCB *pCurScb; +// ULONG flags; - for (;;) { +/*printk("Enter tulip_main\n");*/ - tulip_scsi(pCurHcb); /* Call tulip_scsi */ + for (;;) + { - while ((pCurScb = tul_find_done_scb(pCurHcb)) != NULL) { /* find done entry */ - if (pCurScb->SCB_TaStat == QUEUE_FULL) { - pCurHcb->HCS_MaxTags[pCurScb->SCB_Target] = - pCurHcb->HCS_ActTags[pCurScb->SCB_Target] - 1; - pCurScb->SCB_TaStat = 0; - tul_append_pend_scb(pCurHcb, pCurScb); - continue; - } - if (!(pCurScb->SCB_Mode & SCM_RSENS)) { /* not in auto req. sense mode */ - if (pCurScb->SCB_TaStat == 2) { - - /* clr sync. nego flag */ - - if (pCurScb->SCB_Flags & SCF_SENSE) { - BYTE len; - len = pCurScb->SCB_SenseLen; - if (len == 0) - len = 1; - pCurScb->SCB_BufLen = pCurScb->SCB_SenseLen; - pCurScb->SCB_BufPtr = pCurScb->SCB_SensePtr; - pCurScb->SCB_Flags &= ~(SCF_SG | SCF_DIR); /* for xfer_data_in */ -/* pCurScb->SCB_Flags |= SCF_NO_DCHK; */ - /* so, we won't report worng direction in xfer_data_in, - and won't report HOST_DO_DU in state_6 */ - pCurScb->SCB_Mode = SCM_RSENS; - pCurScb->SCB_Ident &= 0xBF; /* Disable Disconnect */ - pCurScb->SCB_TagMsg = 0; - pCurScb->SCB_TaStat = 0; - pCurScb->SCB_CDBLen = 6; - pCurScb->SCB_CDB[0] = SCSICMD_RequestSense; - pCurScb->SCB_CDB[1] = 0; - pCurScb->SCB_CDB[2] = 0; - pCurScb->SCB_CDB[3] = 0; - pCurScb->SCB_CDB[4] = len; - pCurScb->SCB_CDB[5] = 0; - tul_push_pend_scb(pCurHcb, pCurScb); - break; - } - } - } else { /* in request sense mode */ - - if (pCurScb->SCB_TaStat == 2) { /* check contition status again after sending - requset sense cmd 0x3 */ - pCurScb->SCB_HaStat = HOST_BAD_PHAS; - } - pCurScb->SCB_TaStat = 2; - } - pCurScb->SCB_Flags |= SCF_DONE; - if (pCurScb->SCB_Flags & SCF_POST) { - (*pCurScb->SCB_Post) ((BYTE *) pCurHcb, (BYTE *) pCurScb); - } - } /* while */ +// save_flags(flags); /* wh 07/21/98 */ +// sti(); - /* find_active: */ - if (TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0) & TSS_INT_PENDING) - continue; + tulip_scsi(pCurHcb); /* Call tulip_scsi */ - if (pCurHcb->HCS_ActScb) { /* return to OS and wait for xfer_done_ISR/Selected_ISR */ - return 1; /* return to OS, enable interrupt */ - } - /* Check pending SCB */ - if (tul_find_first_pend_scb(pCurHcb) == NULL) { - return 1; /* return to OS, enable interrupt */ +// restore_flags(flags); /* Addedby hc 07/21/98 */ + + while ((pCurScb = tul_find_done_scb(pCurHcb)) != NULL) + {/* find done entry */ + if (pCurScb->SCB_TaStat == QUEUE_FULL) + { + pCurHcb->HCS_MaxTags[pCurScb->SCB_Target] = + pCurHcb->HCS_ActTags[pCurScb->SCB_Target] - 1; + pCurScb->SCB_TaStat = 0; +// pCurScb->SCB_Status = SCB_PEND; + tul_append_pend_scb(pCurHcb, pCurScb); + continue; } - } /* End of for loop */ + + if (!(pCurScb->SCB_Mode & SCM_RSENS)) + { /* not in auto req. sense mode*/ + if (pCurScb->SCB_TaStat == 2) + { + +// pCurHcb->HCS_Tcs[pCurScb->SCB_Target].TCS_Flags +// &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE); + /* clr sync. nego flag */ + + if (pCurScb->SCB_Flags & SCF_SENSE) + { + BYTE len; + len = pCurScb->SCB_SenseLen; + if (len == 0) + len = 1; + pCurScb->SCB_BufLen = pCurScb->SCB_SenseLen; + pCurScb->SCB_BufPtr = pCurScb->SCB_SensePtr; + pCurScb->SCB_Flags &= ~(SCF_SG|SCF_DIR); /* for xfer_data_in */ +/* pCurScb->SCB_Flags |= SCF_NO_DCHK; */ + /* so, we won't report worng direction in xfer_data_in, + and won't report HOST_DO_DU in state_6 */ + pCurScb->SCB_Mode = SCM_RSENS; + pCurScb->SCB_Ident &= 0xBF; /* Disable Disconnect */ + pCurScb->SCB_TagMsg = 0; + pCurScb->SCB_TaStat = 0; + pCurScb->SCB_CDBLen = 6; + pCurScb->SCB_CDB[0] = SCSICMD_RequestSense; + pCurScb->SCB_CDB[1] = 0; + pCurScb->SCB_CDB[2] = 0; + pCurScb->SCB_CDB[3] = 0; + pCurScb->SCB_CDB[4] = len; + pCurScb->SCB_CDB[5] = 0; + tul_push_pend_scb(pCurHcb, pCurScb); + break; + } + } + } + else { /* in request sense mode */ + + if (pCurScb->SCB_TaStat == 2) + {/* check contition status again after sending + requset sense cmd 0x3*/ + pCurScb->SCB_HaStat = HOST_BAD_PHAS; + } + pCurScb->SCB_TaStat = 2; + } + pCurScb->SCB_Flags |= SCF_DONE; + if (pCurScb->SCB_Flags & SCF_POST) + { +// restore_flags(flags); /* Addedby hc 07/08/98 */ +// sti(); + (*pCurScb->SCB_Post)((BYTE *) pCurHcb, (BYTE *) pCurScb); +// save_flags(flags); /* Addedby hc 07/08/98 */ + } + } /* while */ + + /* find_active: */ + if (TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0) & TSS_INT_PENDING) + continue; + + if (pCurHcb->HCS_ActScb) /* return to OS and wait for xfer_done_ISR/Selected_ISR */ + { + return 1; /* return to OS, enable interrupt */ + } + /* Check pending SCB */ + if (tul_find_first_pend_scb(pCurHcb) == NULL) + { + return 1; /* return to OS, enable interrupt */ + } + } /* End of for loop */ /* statement won't reach here */ } -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ -void tulip_scsi(HCS * pCurHcb) +void tulip_scsi(HCS *pCurHcb) { - SCB *pCurScb; - TCS *pCurTcb; + SCB *pCurScb; + TCS *pCurTcb; +/* printk("Enter tulip_scsi()\n");*/ /* make sure to service interrupt asap */ - if ((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0)) & TSS_INT_PENDING) { + if ((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0)) & TSS_INT_PENDING) + { + + pCurHcb->HCS_Phase = pCurHcb->HCS_JSStatus0 & TSS_PH_MASK; + pCurHcb->HCS_JSStatus1 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1); + pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt); +/* printk("SCSI status = %x\n", pCurHcb->HCS_JSStatus0 ); + printk("SCSI status 1 = %x\n", pCurHcb->HCS_JSStatus1); + printk("SCSI interrupt = %x\n", pCurHcb->HCS_JSInt);*/ + if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) + { /* SCSI bus reset detected */ + int_tul_scsi_rst(pCurHcb); + return; + } + if (pCurHcb->HCS_JSInt & TSS_RESEL_INT) + { /* if selected/reselected interrupt */ + if (int_tul_resel(pCurHcb) == 0) + tul_next_state(pCurHcb); + return; + } + if (pCurHcb->HCS_JSInt & TSS_SEL_TIMEOUT) + { + int_tul_busfree(pCurHcb) ; + return; + } + if (pCurHcb->HCS_JSInt & TSS_DISC_INT) + { /* BUS disconnection */ + int_tul_busfree(pCurHcb); /* unexpected bus free or sel timeout */ + return; + } + if (pCurHcb->HCS_JSInt & (TSS_FUNC_COMP | TSS_BUS_SERV)) + { /* func complete or Bus service */ + if ((pCurScb = pCurHcb->HCS_ActScb) != NULL) + tul_next_state(pCurHcb); + return; + } + } + + if (pCurHcb->HCS_ActScb != NULL) + return; - pCurHcb->HCS_Phase = pCurHcb->HCS_JSStatus0 & TSS_PH_MASK; - pCurHcb->HCS_JSStatus1 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1); - pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt); - if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) { /* SCSI bus reset detected */ - int_tul_scsi_rst(pCurHcb); - return; - } - if (pCurHcb->HCS_JSInt & TSS_RESEL_INT) { /* if selected/reselected interrupt */ - if (int_tul_resel(pCurHcb) == 0) - tul_next_state(pCurHcb); - return; - } - if (pCurHcb->HCS_JSInt & TSS_SEL_TIMEOUT) { - int_tul_busfree(pCurHcb); - return; - } - if (pCurHcb->HCS_JSInt & TSS_DISC_INT) { /* BUS disconnection */ - int_tul_busfree(pCurHcb); /* unexpected bus free or sel timeout */ - return; - } - if (pCurHcb->HCS_JSInt & (TSS_FUNC_COMP | TSS_BUS_SERV)) { /* func complete or Bus service */ - if ((pCurScb = pCurHcb->HCS_ActScb) != NULL) - tul_next_state(pCurHcb); - return; - } - } - if (pCurHcb->HCS_ActScb != NULL) - return; +/* if ((pCurScb = pCurHcb->HCS_FirstPend) == NULL)*/ + if ((pCurScb = tul_find_first_pend_scb(pCurHcb)) == NULL) + return; - if ((pCurScb = tul_find_first_pend_scb(pCurHcb)) == NULL) - return; + /* program HBA's SCSI ID & target SCSI ID */ + TUL_WR( pCurHcb->HCS_Base + TUL_SScsiId, + (pCurHcb->HCS_SCSI_ID << 4) | (pCurScb->SCB_Target & 0x0F) ); + if (pCurScb->SCB_Opcode == ExecSCSI) { + pCurTcb = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target]; - /* program HBA's SCSI ID & target SCSI ID */ - TUL_WR(pCurHcb->HCS_Base + TUL_SScsiId, - (pCurHcb->HCS_SCSI_ID << 4) | (pCurScb->SCB_Target & 0x0F)); - if (pCurScb->SCB_Opcode == ExecSCSI) { - pCurTcb = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target]; + if (pCurScb->SCB_TagMsg) + pCurTcb->TCS_DrvFlags |= TCF_DRV_EN_TAG; + else + pCurTcb->TCS_DrvFlags &= ~TCF_DRV_EN_TAG; + TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, pCurTcb->TCS_JS_Period); +/*printk("TCS_Flags = %x\n", pCurTcb->TCS_Flags); +do_pause(15000);*/ + if ((pCurTcb->TCS_Flags & (TCF_WDTR_DONE | TCF_NO_WDTR)) == 0) + { /* do wdtr negotiation */ + tul_select_atn_stop(pCurHcb, pCurScb); + } + else + { + if ((pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) + { /* do sync negotiation */ + tul_select_atn_stop(pCurHcb, pCurScb); + } + else + { if (pCurScb->SCB_TagMsg) - pCurTcb->TCS_DrvFlags |= TCF_DRV_EN_TAG; + tul_select_atn3(pCurHcb, pCurScb); else - pCurTcb->TCS_DrvFlags &= ~TCF_DRV_EN_TAG; - - TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, pCurTcb->TCS_JS_Period); - if ((pCurTcb->TCS_Flags & (TCF_WDTR_DONE | TCF_NO_WDTR)) == 0) { /* do wdtr negotiation */ - tul_select_atn_stop(pCurHcb, pCurScb); - } else { - if ((pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) { /* do sync negotiation */ - tul_select_atn_stop(pCurHcb, pCurScb); - } else { - if (pCurScb->SCB_TagMsg) - tul_select_atn3(pCurHcb, pCurScb); - else - tul_select_atn(pCurHcb, pCurScb); - } - } - if (pCurScb->SCB_Flags & SCF_POLL) { - while (wait_tulip(pCurHcb) != -1) { - if (tul_next_state(pCurHcb) == -1) - break; - } - } - } else if (pCurScb->SCB_Opcode == BusDevRst) { - tul_select_atn_stop(pCurHcb, pCurScb); - pCurScb->SCB_NxtStat = 8; - if (pCurScb->SCB_Flags & SCF_POLL) { - while (wait_tulip(pCurHcb) != -1) { - if (tul_next_state(pCurHcb) == -1) - break; - } + tul_select_atn(pCurHcb, pCurScb); + } + } + if (pCurScb->SCB_Flags & SCF_POLL) + { + while (wait_tulip(pCurHcb) != -1) + { + if (tul_next_state(pCurHcb) == -1) + break; + } + } + } + else if (pCurScb->SCB_Opcode == BusDevRst) { + tul_select_atn_stop(pCurHcb, pCurScb); + pCurScb->SCB_NxtStat = 8; + if (pCurScb->SCB_Flags & SCF_POLL) + { + while (wait_tulip(pCurHcb) != -1) + { + if (tul_next_state(pCurHcb) == -1) + break; + } } - } else if (pCurScb->SCB_Opcode == AbortCmd) { - ULONG srbp; + } + else if (pCurScb->SCB_Opcode == AbortCmd ) { + ULONG srbp; - srbp = (ULONG) pCurScb->SCB_Srb; + srbp = (ULONG)pCurScb->SCB_Srb; /* 08/03/98 */ - if (tul_abort_srb(pCurHcb, srbp) != 0) { - + if (tul_abort_srb(pCurHcb, srbp) != 0) { + - tul_unlink_pend_scb(pCurHcb, pCurScb); + tul_unlink_pend_scb(pCurHcb, pCurScb); - tul_release_scb(pCurHcb, pCurScb); - } else { - pCurScb->SCB_Opcode = BusDevRst; - tul_select_atn_stop(pCurHcb, pCurScb); - pCurScb->SCB_NxtStat = 8; + tul_release_scb(pCurHcb, pCurScb); } - + else { + pCurScb->SCB_Opcode = BusDevRst; + tul_select_atn_stop(pCurHcb, pCurScb); + pCurScb->SCB_NxtStat = 8; + } + /* 08/03/98 */ - } else { - tul_unlink_pend_scb(pCurHcb, pCurScb); - pCurScb->SCB_HaStat = 0x16; /* bad command */ - tul_append_done_scb(pCurHcb, pCurScb); - } - return; + } + else { + tul_unlink_pend_scb(pCurHcb, pCurScb); +// pCurScb->SCB_Status = SCB_DONE; /* done */ + pCurScb->SCB_HaStat = 0x16; /* bad command */ + tul_append_done_scb(pCurHcb, pCurScb); + } + return; } /***************************************************************************/ -int tul_next_state(HCS * pCurHcb) -{ - int next; - - next = pCurHcb->HCS_ActScb->SCB_NxtStat; - for (;;) { - switch (next) { - case 1: - next = tul_state_1(pCurHcb); - break; - case 2: - next = tul_state_2(pCurHcb); - break; - case 3: - next = tul_state_3(pCurHcb); - break; - case 4: - next = tul_state_4(pCurHcb); - break; - case 5: - next = tul_state_5(pCurHcb); - break; - case 6: - next = tul_state_6(pCurHcb); - break; - case 7: - next = tul_state_7(pCurHcb); - break; - case 8: - return (tul_bus_device_reset(pCurHcb)); - default: - return (tul_bad_seq(pCurHcb)); - } - if (next <= 0) - return next; +int tul_next_state(HCS *pCurHcb) +{ + int next; + + next = pCurHcb->HCS_ActScb->SCB_NxtStat; + for (;;) { + switch (next) { + case 1: + next = tul_state_1(pCurHcb); + break; + case 2: + next = tul_state_2(pCurHcb); + break; + case 3: + next = tul_state_3(pCurHcb); + break; + case 4: + next = tul_state_4(pCurHcb); + break; + case 5: + next = tul_state_5(pCurHcb); + break; + case 6: + next = tul_state_6(pCurHcb); + break; + case 7: + next = tul_state_7(pCurHcb); + break; + case 8: + return (tul_bus_device_reset(pCurHcb)); + default: + return (tul_bad_seq(pCurHcb)); } + if (next <= 0) + return next; + } } /***************************************************************************/ /* sTate after selection with attention & stop */ -int tul_state_1(HCS * pCurHcb) +int tul_state_1(HCS *pCurHcb) { - SCB *pCurScb = pCurHcb->HCS_ActScb; - TCS *pCurTcb = pCurHcb->HCS_ActTcs; + SCB *pCurScb = pCurHcb->HCS_ActScb; + TCS *pCurTcb = pCurHcb->HCS_ActTcs; #if DEBUG_STATE - printk("-s1-"); +printk("-s1-"); #endif - tul_unlink_pend_scb(pCurHcb, pCurScb); - tul_append_busy_scb(pCurHcb, pCurScb); + tul_unlink_pend_scb(pCurHcb, pCurScb); + tul_append_busy_scb(pCurHcb, pCurScb); - TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurTcb->TCS_SConfig0); - /* ATN on */ - if (pCurHcb->HCS_Phase == MSG_OUT) { + TUL_WR(pCurHcb->HCS_Base+ TUL_SConfig, pCurTcb->TCS_SConfig0); + /* ATN on */ + if (pCurHcb->HCS_Phase == MSG_OUT) { - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, (TSC_EN_BUS_IN | TSC_HW_RESELECT)); +/*printk("MSG OUT\n");*/ + TUL_WR(pCurHcb->HCS_Base+ TUL_SCtrl1, (TSC_EN_BUS_IN | TSC_HW_RESELECT)); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_Ident); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, pCurScb->SCB_Ident); - if (pCurScb->SCB_TagMsg) { - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_TagMsg); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_TagId); - } - if ((pCurTcb->TCS_Flags & (TCF_WDTR_DONE | TCF_NO_WDTR)) == 0) { + if (pCurScb->SCB_TagMsg) + { + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, pCurScb->SCB_TagMsg); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, pCurScb->SCB_TagId); + } - pCurTcb->TCS_Flags |= TCF_WDTR_DONE; + if ((pCurTcb->TCS_Flags & (TCF_WDTR_DONE | TCF_NO_WDTR)) == 0) { - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 2); /* Extended msg length */ - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3); /* Sync request */ - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 1); /* Start from 16 bits */ - } else if ((pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) { + pCurTcb->TCS_Flags |= TCF_WDTR_DONE; - pCurTcb->TCS_Flags |= TCF_SYNC_DONE; + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, MSG_EXTEND); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, 2); /* Extended msg length*/ + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, 3); /* Sync request*/ + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, 1); /* Start from 16 bits */ + } + else if ((pCurTcb->TCS_Flags & (TCF_SYNC_DONE|TCF_NO_SYNC_NEGO)) == 0) { - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3); /* extended msg length */ - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 1); /* sync request */ - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, tul_rate_tbl[pCurTcb->TCS_Flags & TCF_SCSI_RATE]); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MAX_OFFSET); /* REQ/ACK offset */ - } - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - if (wait_tulip(pCurHcb) == -1) - return (-1); + pCurTcb->TCS_Flags |= TCF_SYNC_DONE; + + TUL_WR(pCurHcb->HCS_Base+TUL_SFifo, MSG_EXTEND); + TUL_WR(pCurHcb->HCS_Base+TUL_SFifo, 3); /* extended msg length */ + TUL_WR(pCurHcb->HCS_Base+TUL_SFifo, 1); /* sync request */ + TUL_WR(pCurHcb->HCS_Base+TUL_SFifo, tul_rate_tbl[pCurTcb->TCS_Flags & TCF_SCSI_RATE]); + TUL_WR(pCurHcb->HCS_Base+TUL_SFifo, MAX_OFFSET); /* REQ/ACK offset */ + } + + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_XF_FIFO_OUT); + if (wait_tulip(pCurHcb) == -1) + return(-1); } - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); + + TUL_WR(pCurHcb->HCS_Base+ TUL_SCtrl0, TSC_FLUSH_FIFO); TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, (TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7))); - return (3); + return(3); } /***************************************************************************/ /* state after selection with attention */ /* state after selection with attention3 */ -int tul_state_2(HCS * pCurHcb) +int tul_state_2(HCS *pCurHcb) { - SCB *pCurScb = pCurHcb->HCS_ActScb; - TCS *pCurTcb = pCurHcb->HCS_ActTcs; + SCB *pCurScb = pCurHcb->HCS_ActScb; + TCS *pCurTcb = pCurHcb->HCS_ActTcs; #if DEBUG_STATE - printk("-s2-"); +printk("-s2-"); #endif - tul_unlink_pend_scb(pCurHcb, pCurScb); - tul_append_busy_scb(pCurHcb, pCurScb); + tul_unlink_pend_scb(pCurHcb, pCurScb); + tul_append_busy_scb(pCurHcb, pCurScb); - TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurTcb->TCS_SConfig0); + TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurTcb->TCS_SConfig0); - if (pCurHcb->HCS_JSStatus1 & TSS_CMD_PH_CMP) { - return (4); - } - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); - TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, (TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7))); - return (3); + if ( pCurHcb->HCS_JSStatus1 & TSS_CMD_PH_CMP) { + return (4); + } + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); + TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, (TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7))); + return (3); } /***************************************************************************/ /* state before CDB xfer is done */ -int tul_state_3(HCS * pCurHcb) +int tul_state_3(HCS *pCurHcb) { - SCB *pCurScb = pCurHcb->HCS_ActScb; - TCS *pCurTcb = pCurHcb->HCS_ActTcs; - int i; + SCB *pCurScb = pCurHcb->HCS_ActScb; + TCS *pCurTcb = pCurHcb->HCS_ActTcs; + int i; #if DEBUG_STATE - printk("-s3-"); +printk("-s3-"); #endif - for (;;) { - switch (pCurHcb->HCS_Phase) { - case CMD_OUT: /* Command out phase */ - for (i = 0; i < (int) pCurScb->SCB_CDBLen; i++) - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_CDB[i]); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - if (wait_tulip(pCurHcb) == -1) - return (-1); - if (pCurHcb->HCS_Phase == CMD_OUT) { - return (tul_bad_seq(pCurHcb)); - } - return (4); - - case MSG_IN: /* Message in phase */ - pCurScb->SCB_NxtStat = 3; - if (tul_msgin(pCurHcb) == -1) - return (-1); - break; - - case STATUS_IN: /* Status phase */ - if (tul_status_msg(pCurHcb) == -1) - return (-1); - break; - - case MSG_OUT: /* Message out phase */ - if (pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) { - - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_NOP); /* msg nop */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - if (wait_tulip(pCurHcb) == -1) - return (-1); - - } else { - pCurTcb->TCS_Flags |= TCF_SYNC_DONE; + for (;;) { + switch (pCurHcb->HCS_Phase) + { + case CMD_OUT: /* Command out phase */ +/*printk("Command Out Phase\n");*/ + for ( i = 0; i < (int) pCurScb->SCB_CDBLen; i++) + TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_CDB[i]); + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); + if (wait_tulip(pCurHcb) == -1) + return (-1); + if (pCurHcb->HCS_Phase == CMD_OUT) { + return (tul_bad_seq(pCurHcb)); + } + return(4); + + case MSG_IN: /* Message in phase */ +/*printk("Message In Phase\n");*/ + pCurScb->SCB_NxtStat = 3; + if (tul_msgin(pCurHcb) == -1) + return (-1); + break; + + case STATUS_IN: /* Status phase */ +/*printk("Status Phase\n");*/ + if (tul_status_msg(pCurHcb) == -1) + return (-1); + break; + + case MSG_OUT: /* Message out phase */ +/*printk("Message Out Phase\n");*/ + if (pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) { + + TUL_WR(pCurHcb->HCS_Base+TUL_SFifo, MSG_NOP); /* msg nop */ + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); + if (wait_tulip(pCurHcb) == -1) + return(-1); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3); /* ext. msg len */ - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 1); /* sync request */ - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, tul_rate_tbl[pCurTcb->TCS_Flags & TCF_SCSI_RATE]); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MAX_OFFSET); /* REQ/ACK offset */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - if (wait_tulip(pCurHcb) == -1) - return (-1); - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); - TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)); + } else { + pCurTcb->TCS_Flags |= TCF_SYNC_DONE; - } - break; + TUL_WR(pCurHcb->HCS_Base+TUL_SFifo, MSG_EXTEND); + TUL_WR(pCurHcb->HCS_Base+TUL_SFifo, 3); /* ext. msg len */ + TUL_WR(pCurHcb->HCS_Base+TUL_SFifo, 1); /* sync request */ + TUL_WR(pCurHcb->HCS_Base+TUL_SFifo, tul_rate_tbl[pCurTcb->TCS_Flags & TCF_SCSI_RATE]); + TUL_WR(pCurHcb->HCS_Base+TUL_SFifo, MAX_OFFSET); /* REQ/ACK offset */ + TUL_WR(pCurHcb->HCS_Base+TUL_SCmd, TSC_XF_FIFO_OUT); + if (wait_tulip(pCurHcb) == -1) + return(-1); + TUL_WR(pCurHcb->HCS_Base+TUL_SCtrl0, TSC_FLUSH_FIFO); + TUL_WR(pCurHcb->HCS_Base+TUL_SSignal, TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)); - default: - return (tul_bad_seq(pCurHcb)); } + break; + + default: + return (tul_bad_seq(pCurHcb)); + } } } /***************************************************************************/ -int tul_state_4(HCS * pCurHcb) +int tul_state_4(HCS *pCurHcb) { - SCB *pCurScb = pCurHcb->HCS_ActScb; + SCB *pCurScb = pCurHcb->HCS_ActScb; #if DEBUG_STATE - printk("-s4-"); +printk("-s4-"); #endif - if ((pCurScb->SCB_Flags & SCF_DIR) == SCF_NO_XF) { - return (6); /* Go to state 6 */ - } - for (;;) { - if (pCurScb->SCB_BufLen == 0) - return (6); /* Go to state 6 */ + if ((pCurScb->SCB_Flags & SCF_DIR) == SCF_NO_XF) { + return (6); /* Go to state 6 */ + } - switch (pCurHcb->HCS_Phase) { + for (;;) { + if (pCurScb->SCB_BufLen == 0) + return (6); /* Go to state 6 */ - case STATUS_IN: /* Status phase */ - if ((pCurScb->SCB_Flags & SCF_DIR) != 0) { /* if direction bit set then report data underrun */ - pCurScb->SCB_HaStat = HOST_DO_DU; - } - if ((tul_status_msg(pCurHcb)) == -1) - return (-1); - break; - - case MSG_IN: /* Message in phase */ - pCurScb->SCB_NxtStat = 0x4; - if (tul_msgin(pCurHcb) == -1) - return (-1); - break; + switch (pCurHcb->HCS_Phase) { - case MSG_OUT: /* Message out phase */ - if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) { - pCurScb->SCB_BufLen = 0; - pCurScb->SCB_HaStat = HOST_DO_DU; - if (tul_msgout_ide(pCurHcb) == -1) - return (-1); - return (6); /* Go to state 6 */ - } else { - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_NOP); /* msg nop */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - if (wait_tulip(pCurHcb) == -1) - return (-1); - } - break; + case STATUS_IN: /* Status phase */ + if ((pCurScb->SCB_Flags & SCF_DIR) != 0) + { /* if direction bit set then report data underrun */ + pCurScb->SCB_HaStat = HOST_DO_DU; + } + if ((tul_status_msg(pCurHcb)) == -1) + return (-1); + break; + + case MSG_IN: /* Message in phase */ + pCurScb->SCB_NxtStat = 0x4; + if (tul_msgin(pCurHcb) == -1) + return (-1); + break; + + case MSG_OUT: /* Message out phase */ + if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) { + pCurScb->SCB_BufLen = 0; + pCurScb->SCB_HaStat = HOST_DO_DU; + if (tul_msgout_ide(pCurHcb) == -1) + return (-1); + return (6); /* Go to state 6 */ + } else { + TUL_WR(pCurHcb->HCS_Base+TUL_SFifo, MSG_NOP); /* msg nop */ + TUL_WR(pCurHcb->HCS_Base+TUL_SCmd, TSC_XF_FIFO_OUT); + if (wait_tulip(pCurHcb) == -1) + return (-1); + } + break; - case DATA_IN: /* Data in phase */ - return (tul_xfer_data_in(pCurHcb)); + case DATA_IN: /* Data in phase */ + return (tul_xfer_data_in(pCurHcb)); - case DATA_OUT: /* Data out phase */ - return (tul_xfer_data_out(pCurHcb)); + case DATA_OUT: /* Data out phase */ + return (tul_xfer_data_out(pCurHcb)); - default: - return (tul_bad_seq(pCurHcb)); - } + default: + return (tul_bad_seq(pCurHcb)); } + } } /***************************************************************************/ /* state after dma xfer done or phase change before xfer done */ -int tul_state_5(HCS * pCurHcb) +int tul_state_5(HCS *pCurHcb) { - SCB *pCurScb = pCurHcb->HCS_ActScb; - long cnt, xcnt; /* cannot use unsigned !! code: if (xcnt < 0) */ + SCB *pCurScb = pCurHcb->HCS_ActScb; + long cnt, xcnt; /* cannot use unsigned !! code: if (xcnt < 0) */ #if DEBUG_STATE - printk("-s5-"); +printk("-s5-"); #endif -/*------ get remaining count -------*/ + /*------ get remaining count -------*/ - cnt = TUL_RDLONG(pCurHcb->HCS_Base, TUL_SCnt0) & 0x0FFFFFF; + cnt = TUL_RDLONG(pCurHcb->HCS_Base, TUL_SCnt0) & 0x0FFFFFF; - if (TUL_RD(pCurHcb->HCS_Base, TUL_XCmd) & 0x20) { - /* ----------------------- DATA_IN ----------------------------- */ +/*printk("Remaining SCSI Count = %lx\n", cnt);*/ + if (TUL_RD(pCurHcb->HCS_Base, TUL_XCmd) & 0x20) + { + /* ----------------------- DATA_IN -----------------------------*/ /* check scsi parity error */ - if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) { - pCurScb->SCB_HaStat = HOST_DO_DU; - } - if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND) { /* DMA xfer pending, Send STOP */ + if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) + { + pCurScb->SCB_HaStat = HOST_DO_DU; + } + + if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND) + { /* DMA xfer pending, Send STOP */ /* tell Hardware scsi xfer has been terminated */ - TUL_WR(pCurHcb->HCS_Base + TUL_XCtrl, TUL_RD(pCurHcb->HCS_Base, TUL_XCtrl) | 0x80); + TUL_WR(pCurHcb->HCS_Base + TUL_XCtrl, TUL_RD(pCurHcb->HCS_Base, TUL_XCtrl) | 0x80); /* wait until DMA xfer not pending */ - while (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND); - } - } else { -/*-------- DATA OUT -----------*/ - if ((TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1) & TSS_XFER_CMP) == 0) { - if (pCurHcb->HCS_ActTcs->TCS_JS_Period & TSC_WIDE_SCSI) - cnt += (TUL_RD(pCurHcb->HCS_Base, TUL_SFifoCnt) & 0x1F) << 1; - else - cnt += (TUL_RD(pCurHcb->HCS_Base, TUL_SFifoCnt) & 0x1F); - } - if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND) { /* if DMA xfer is pending, abort DMA xfer */ - TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_ABT); - /* wait Abort DMA xfer done */ - while ((TUL_RD(pCurHcb->HCS_Base, TUL_Int) & XABT) == 0); + while (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND ); + } + } + else + { /*-------- DATA OUT -----------*/ + if ((TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1) & TSS_XFER_CMP) == 0) + { + if (pCurHcb->HCS_ActTcs->TCS_JS_Period & TSC_WIDE_SCSI) + cnt += (TUL_RD(pCurHcb->HCS_Base, TUL_SFifoCnt) & 0x1F) << 1; + else + cnt += (TUL_RD(pCurHcb->HCS_Base, TUL_SFifoCnt) & 0x1F); + } + if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND) + { /* if DMA xfer is pending, abort DMA xfer */ + TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_ABT); + /* wait Abort DMA xfer done */ + while ((TUL_RD(pCurHcb->HCS_Base, TUL_Int) & XABT) == 0); + } + if ((cnt == 1) && (pCurHcb->HCS_Phase == DATA_OUT)) + { + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_XF_FIFO_OUT); + if (wait_tulip(pCurHcb) == -1) + { + return (-1); } - if ((cnt == 1) && (pCurHcb->HCS_Phase == DATA_OUT)) { - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - if (wait_tulip(pCurHcb) == -1) { - return (-1); - } - cnt = 0; - } else { - if ((TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1) & TSS_XFER_CMP) == 0) - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); + cnt = 0; + } + else + { + if ((TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1) & TSS_XFER_CMP) == 0) + TUL_WR(pCurHcb->HCS_Base+ TUL_SCtrl0, TSC_FLUSH_FIFO); + } + } + + if (cnt == 0) + { + pCurScb->SCB_BufLen = 0; + return (6); /* Go to state 6 */ + } + /* Update active data pointer */ + xcnt = (long)pCurScb->SCB_BufLen - cnt; /* xcnt== bytes already xferred */ + pCurScb->SCB_BufLen = (U32)cnt; /* cnt == bytes left to be xferred */ + if (pCurScb->SCB_Flags & SCF_SG) + { + register SG *sgp; + ULONG i; + + sgp = &pCurScb->SCB_SGList[pCurScb->SCB_SGIdx]; + for (i = pCurScb->SCB_SGIdx; i < pCurScb->SCB_SGMax; sgp++, i++) + { + xcnt -= (long)sgp->SG_Len; + if (xcnt < 0) + { /* this sgp xfer half done */ + xcnt += (long)sgp->SG_Len; /* xcnt == bytes xferred in this sgp */ + sgp->SG_Ptr += (U32)xcnt; /* new ptr to be xfer */ + sgp->SG_Len -= (U32)xcnt; /* new len to be xfer */ + pCurScb->SCB_BufPtr += ((U32)(i - pCurScb->SCB_SGIdx) << 3); + /* new SG table ptr */ + pCurScb->SCB_SGLen = (BYTE)(pCurScb->SCB_SGMax - i); + /* new SG table len */ + pCurScb->SCB_SGIdx = (WORD)i; + /* for next disc and come in this loop*/ + return (4); /* Go to state 4 */ } - } - - if (cnt == 0) { - pCurScb->SCB_BufLen = 0; - return (6); /* Go to state 6 */ - } - /* Update active data pointer */ - xcnt = (long) pCurScb->SCB_BufLen - cnt; /* xcnt== bytes already xferred */ - pCurScb->SCB_BufLen = (U32) cnt; /* cnt == bytes left to be xferred */ - if (pCurScb->SCB_Flags & SCF_SG) { - register SG *sgp; - ULONG i; - - sgp = &pCurScb->SCB_SGList[pCurScb->SCB_SGIdx]; - for (i = pCurScb->SCB_SGIdx; i < pCurScb->SCB_SGMax; sgp++, i++) { - xcnt -= (long) sgp->SG_Len; - if (xcnt < 0) { /* this sgp xfer half done */ - xcnt += (long) sgp->SG_Len; /* xcnt == bytes xferred in this sgp */ - sgp->SG_Ptr += (U32) xcnt; /* new ptr to be xfer */ - sgp->SG_Len -= (U32) xcnt; /* new len to be xfer */ - pCurScb->SCB_BufPtr += ((U32) (i - pCurScb->SCB_SGIdx) << 3); - /* new SG table ptr */ - pCurScb->SCB_SGLen = (BYTE) (pCurScb->SCB_SGMax - i); - /* new SG table len */ - pCurScb->SCB_SGIdx = (WORD) i; - /* for next disc and come in this loop */ - return (4); /* Go to state 4 */ - } /* else (xcnt >= 0 , i.e. this sgp already xferred */ - } /* for */ - return (6); /* Go to state 6 */ - } else { - pCurScb->SCB_BufPtr += (U32) xcnt; + } /* for */ + return (6); /* Go to state 6 */ } - return (4); /* Go to state 4 */ + else + { + pCurScb->SCB_BufPtr += (U32)xcnt; + } + return (4); /* Go to state 4 */ } /***************************************************************************/ /* state after Data phase */ -int tul_state_6(HCS * pCurHcb) +int tul_state_6(HCS *pCurHcb) { - SCB *pCurScb = pCurHcb->HCS_ActScb; + SCB *pCurScb = pCurHcb->HCS_ActScb; #if DEBUG_STATE - printk("-s6-"); +printk("-s6-"); #endif - for (;;) { - switch (pCurHcb->HCS_Phase) { - case STATUS_IN: /* Status phase */ - if ((tul_status_msg(pCurHcb)) == -1) - return (-1); - break; - - case MSG_IN: /* Message in phase */ - pCurScb->SCB_NxtStat = 6; - if ((tul_msgin(pCurHcb)) == -1) - return (-1); - break; - - case MSG_OUT: /* Message out phase */ - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_NOP); /* msg nop */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - if (wait_tulip(pCurHcb) == -1) - return (-1); - break; + for (;;) { + switch (pCurHcb->HCS_Phase) { + case STATUS_IN: /* Status phase */ + if ((tul_status_msg(pCurHcb)) == -1) + return (-1); + break; + + case MSG_IN: /* Message in phase */ + pCurScb->SCB_NxtStat = 6; + if ((tul_msgin(pCurHcb)) == -1) + return (-1); + break; + + case MSG_OUT: /* Message out phase */ + TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_NOP); /* msg nop */ + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); + if (wait_tulip(pCurHcb) == -1) + return (-1); + break; - case DATA_IN: /* Data in phase */ - return (tul_xpad_in(pCurHcb)); + case DATA_IN: /* Data in phase */ + return (tul_xpad_in(pCurHcb)); - case DATA_OUT: /* Data out phase */ - return (tul_xpad_out(pCurHcb)); + case DATA_OUT: /* Data out phase */ + return (tul_xpad_out(pCurHcb)); - default: - return (tul_bad_seq(pCurHcb)); - } + default: + return (tul_bad_seq(pCurHcb)); } + } } /***************************************************************************/ -int tul_state_7(HCS * pCurHcb) +int tul_state_7(HCS *pCurHcb) { - int cnt, i; + int cnt, i; #if DEBUG_STATE - printk("-s7-"); +printk("-s7-"); #endif /* flush SCSI FIFO */ - cnt = TUL_RD(pCurHcb->HCS_Base, TUL_SFifoCnt) & 0x1F; - if (cnt) { - for (i = 0; i < cnt; i++) - TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); - } - switch (pCurHcb->HCS_Phase) { - case DATA_IN: /* Data in phase */ - case DATA_OUT: /* Data out phase */ - return (tul_bad_seq(pCurHcb)); + cnt = TUL_RD(pCurHcb->HCS_Base, TUL_SFifoCnt) & 0x1F; + if (cnt) { + for (i = 0; i < cnt; i++) + TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); + } + + switch (pCurHcb->HCS_Phase) { + case DATA_IN: /* Data in phase */ + case DATA_OUT: /* Data out phase */ + return (tul_bad_seq(pCurHcb)); default: - return (6); /* Go to state 6 */ - } + return (6); /* Go to state 6 */ + } } /***************************************************************************/ -int tul_xfer_data_in(HCS * pCurHcb) +int tul_xfer_data_in(HCS *pCurHcb) { - SCB *pCurScb = pCurHcb->HCS_ActScb; + SCB *pCurScb = pCurHcb->HCS_ActScb; - if ((pCurScb->SCB_Flags & SCF_DIR) == SCF_DOUT) { - return (6); /* wrong direction */ - } - TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, pCurScb->SCB_BufLen); +/*printk("\nEnter xfer data in; ptr = %lx; cnt = %lx\n", pCurScb->SCB_BufPtr, + pCurScb->SCB_BufLen);*/ + if ((pCurScb->SCB_Flags & SCF_DIR) == SCF_DOUT) { + return (6); /* wrong direction */ + } + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_SCnt0, pCurScb->SCB_BufLen); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_DMA_IN); /* 7/25/95 */ + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_XF_DMA_IN); /* 7/25/95 */ - if (pCurScb->SCB_Flags & SCF_SG) { /* S/G xfer */ - TUL_WRLONG(pCurHcb->HCS_Base + TUL_XCntH, ((ULONG) pCurScb->SCB_SGLen) << 3); - TUL_WRLONG(pCurHcb->HCS_Base + TUL_XAddH, pCurScb->SCB_BufPtr); - TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_SG_IN); - } else { - TUL_WRLONG(pCurHcb->HCS_Base + TUL_XCntH, pCurScb->SCB_BufLen); - TUL_WRLONG(pCurHcb->HCS_Base + TUL_XAddH, pCurScb->SCB_BufPtr); - TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_IN); - } - pCurScb->SCB_NxtStat = 0x5; - return (0); /* return to OS, wait xfer done , let jas_isr come in */ + if (pCurScb->SCB_Flags & SCF_SG) { /* S/G xfer */ + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_XCntH, ((ULONG)pCurScb->SCB_SGLen) << 3); + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_XAddH, pCurScb->SCB_BufPtr); + TUL_WR(pCurHcb->HCS_Base+ TUL_XCmd, TAX_SG_IN); + } else { + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_XCntH, pCurScb->SCB_BufLen); + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_XAddH, pCurScb->SCB_BufPtr); + TUL_WR(pCurHcb->HCS_Base+ TUL_XCmd, TAX_X_IN); + } + pCurScb->SCB_NxtStat = 0x5; + return (0); /* return to OS, wait xfer done , let jas_isr come in */ } /***************************************************************************/ -int tul_xfer_data_out(HCS * pCurHcb) +int tul_xfer_data_out(HCS *pCurHcb) { - SCB *pCurScb = pCurHcb->HCS_ActScb; + SCB *pCurScb = pCurHcb->HCS_ActScb; - if ((pCurScb->SCB_Flags & SCF_DIR) == SCF_DIN) { - return (6); /* wrong direction */ - } - TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, pCurScb->SCB_BufLen); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_DMA_OUT); +/*printk("Enter xfer data out\n");*/ + if ((pCurScb->SCB_Flags & SCF_DIR) == SCF_DIN) { + return (6); /* wrong direction */ + } - if (pCurScb->SCB_Flags & SCF_SG) { /* S/G xfer */ - TUL_WRLONG(pCurHcb->HCS_Base + TUL_XCntH, ((ULONG) pCurScb->SCB_SGLen) << 3); - TUL_WRLONG(pCurHcb->HCS_Base + TUL_XAddH, pCurScb->SCB_BufPtr); - TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_SG_OUT); - } else { - TUL_WRLONG(pCurHcb->HCS_Base + TUL_XCntH, pCurScb->SCB_BufLen); - TUL_WRLONG(pCurHcb->HCS_Base + TUL_XAddH, pCurScb->SCB_BufPtr); - TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_OUT); - } + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_SCnt0, pCurScb->SCB_BufLen); + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_XF_DMA_OUT); - pCurScb->SCB_NxtStat = 0x5; - return (0); /* return to OS, wait xfer done , let jas_isr come in */ + if (pCurScb->SCB_Flags & SCF_SG) { /* S/G xfer */ + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_XCntH, ((ULONG)pCurScb->SCB_SGLen) << 3); + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_XAddH, pCurScb->SCB_BufPtr); + TUL_WR(pCurHcb->HCS_Base+ TUL_XCmd, TAX_SG_OUT); + } else { + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_XCntH, pCurScb->SCB_BufLen); + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_XAddH, pCurScb->SCB_BufPtr); + TUL_WR(pCurHcb->HCS_Base+ TUL_XCmd, TAX_X_OUT); + } + + pCurScb->SCB_NxtStat = 0x5; + return (0); /* return to OS, wait xfer done , let jas_isr come in */ } /***************************************************************************/ -int tul_xpad_in(HCS * pCurHcb) -{ - SCB *pCurScb = pCurHcb->HCS_ActScb; - TCS *pCurTcb = pCurHcb->HCS_ActTcs; - - if ((pCurScb->SCB_Flags & SCF_DIR) != SCF_NO_DCHK) { - pCurScb->SCB_HaStat = HOST_DO_DU; /* over run */ - } - for (;;) { - if (pCurTcb->TCS_JS_Period & TSC_WIDE_SCSI) - TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 2); - else - TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1); - - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN); - if ((wait_tulip(pCurHcb)) == -1) { - return (-1); - } - if (pCurHcb->HCS_Phase != DATA_IN) { - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); - return (6); - } - TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); - } -} - -int tul_xpad_out(HCS * pCurHcb) +int tul_xpad_in(HCS *pCurHcb) { - SCB *pCurScb = pCurHcb->HCS_ActScb; - TCS *pCurTcb = pCurHcb->HCS_ActTcs; + SCB *pCurScb = pCurHcb->HCS_ActScb; + TCS *pCurTcb = pCurHcb->HCS_ActTcs; - if ((pCurScb->SCB_Flags & SCF_DIR) != SCF_NO_DCHK) { - pCurScb->SCB_HaStat = HOST_DO_DU; /* over run */ - } - for (;;) { - if (pCurTcb->TCS_JS_Period & TSC_WIDE_SCSI) - TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 2); - else - TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1); + if ((pCurScb->SCB_Flags & SCF_DIR) != SCF_NO_DCHK) { + pCurScb->SCB_HaStat = HOST_DO_DU; /* over run */ + } + for (;;) { + if (pCurTcb->TCS_JS_Period & TSC_WIDE_SCSI) + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_SCnt0, 2); + else + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_SCnt0, 1); + + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_XF_FIFO_IN); + if ((wait_tulip(pCurHcb)) == -1) + { + return (-1); + } + if (pCurHcb->HCS_Phase != DATA_IN) + { + TUL_WR(pCurHcb->HCS_Base+ TUL_SCtrl0, TSC_FLUSH_FIFO); + return (6); + } + TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); + } +} + +int tul_xpad_out(HCS *pCurHcb) +{ + SCB *pCurScb = pCurHcb->HCS_ActScb; + TCS *pCurTcb = pCurHcb->HCS_ActTcs; + + if ((pCurScb->SCB_Flags & SCF_DIR) != SCF_NO_DCHK) { + pCurScb->SCB_HaStat = HOST_DO_DU; /* over run */ + } + for (;;) { + if (pCurTcb->TCS_JS_Period & TSC_WIDE_SCSI) + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_SCnt0, 2); + else + TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 0); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - if ((wait_tulip(pCurHcb)) == -1) { - return (-1); - } - if (pCurHcb->HCS_Phase != DATA_OUT) { /* Disable wide CPU to allow read 16 bits */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT); - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); - return (6); - } - } + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, 0); + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_XF_FIFO_OUT); + if ((wait_tulip(pCurHcb)) == -1) + { + return (-1); + } + if (pCurHcb->HCS_Phase != DATA_OUT) + { /* Disable wide CPU to allow read 16 bits */ + TUL_WR(pCurHcb->HCS_Base+ TUL_SCtrl1, TSC_HW_RESELECT); + TUL_WR(pCurHcb->HCS_Base+ TUL_SCtrl0, TSC_FLUSH_FIFO); + return (6); + } + } } /***************************************************************************/ -int tul_status_msg(HCS * pCurHcb) -{ /* status & MSG_IN */ - SCB *pCurScb = pCurHcb->HCS_ActScb; - BYTE msg; +int tul_status_msg(HCS *pCurHcb) /* status & MSG_IN */ +{ + SCB *pCurScb = pCurHcb->HCS_ActScb; + BYTE msg; - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_CMD_COMP); - if ((wait_tulip(pCurHcb)) == -1) { - return (-1); - } + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_CMD_COMP); + if ((wait_tulip(pCurHcb)) == -1) { + return (-1); + } /* get status */ - pCurScb->SCB_TaStat = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); - - if (pCurHcb->HCS_Phase == MSG_OUT) { - if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) { - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_PARITY); - } else { - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_NOP); - } - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - return (wait_tulip(pCurHcb)); - } - if (pCurHcb->HCS_Phase == MSG_IN) { - msg = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); - if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) { /* Parity error */ - if ((tul_msgin_accept(pCurHcb)) == -1) - return (-1); - if (pCurHcb->HCS_Phase != MSG_OUT) - return (tul_bad_seq(pCurHcb)); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_PARITY); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - return (wait_tulip(pCurHcb)); + pCurScb->SCB_TaStat = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); + + if (pCurHcb->HCS_Phase == MSG_OUT) + { + if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) + { + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, MSG_PARITY); + } + else + { + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, MSG_NOP); + } + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_XF_FIFO_OUT); + return (wait_tulip(pCurHcb)); + } + if (pCurHcb->HCS_Phase == MSG_IN) + { + msg = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); + if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) + { /* Parity error */ + if ((tul_msgin_accept(pCurHcb)) == -1) + return (-1); + if (pCurHcb->HCS_Phase != MSG_OUT) + return (tul_bad_seq(pCurHcb)); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, MSG_PARITY); + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_XF_FIFO_OUT); + return (wait_tulip(pCurHcb)); + } + if (msg == 0) { /* Command complete */ + + if ((pCurScb->SCB_TaStat & 0x18) == 0x10) + { /* No link support */ + return (tul_bad_seq(pCurHcb)); } - if (msg == 0) { /* Command complete */ - if ((pCurScb->SCB_TaStat & 0x18) == 0x10) { /* No link support */ - return (tul_bad_seq(pCurHcb)); - } - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT); - return tul_wait_done_disc(pCurHcb); - } - if ((msg == MSG_LINK_COMP) || (msg == MSG_LINK_FLAG)) { - if ((pCurScb->SCB_TaStat & 0x18) == 0x10) - return (tul_msgin_accept(pCurHcb)); - } + TUL_WR(pCurHcb->HCS_Base+ TUL_SCtrl0, TSC_FLUSH_FIFO); + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_MSG_ACCEPT); + return tul_wait_done_disc(pCurHcb); + + } + if ((msg == MSG_LINK_COMP) || (msg == MSG_LINK_FLAG)) + { + if ((pCurScb->SCB_TaStat & 0x18) == 0x10) + return (tul_msgin_accept(pCurHcb)); + } } - return (tul_bad_seq(pCurHcb)); + return (tul_bad_seq(pCurHcb)); } /***************************************************************************/ /* scsi bus free */ -int int_tul_busfree(HCS * pCurHcb) -{ - SCB *pCurScb = pCurHcb->HCS_ActScb; - - if (pCurScb != NULL) { - if (pCurScb->SCB_Status & SCB_SELECT) { /* selection timeout */ - tul_unlink_pend_scb(pCurHcb, pCurScb); - pCurScb->SCB_HaStat = HOST_SEL_TOUT; - tul_append_done_scb(pCurHcb, pCurScb); - } else { /* Unexpected bus free */ - tul_unlink_busy_scb(pCurHcb, pCurScb); - pCurScb->SCB_HaStat = HOST_BUS_FREE; - tul_append_done_scb(pCurHcb, pCurScb); - } - pCurHcb->HCS_ActScb = NULL; - pCurHcb->HCS_ActTcs = NULL; +int int_tul_busfree(HCS *pCurHcb) +{ + SCB *pCurScb = pCurHcb->HCS_ActScb; + + if (pCurScb != NULL) + { + if (pCurScb->SCB_Status & SCB_SELECT) + { /* selection timeout */ +#if 0 +// if (pCurScb != tul_pop_pend_scb(pCurHcb)) +// { +// printk("Differnet SCB\n"); +// } +#endif + tul_unlink_pend_scb(pCurHcb, pCurScb); +// pCurScb->SCB_Status = SCB_DONE; + pCurScb->SCB_HaStat = HOST_SEL_TOUT; + tul_append_done_scb(pCurHcb, pCurScb); + } + else + { /* Unexpected bus free */ + tul_unlink_busy_scb(pCurHcb, pCurScb); +// pCurScb->SCB_Status = SCB_DONE; + pCurScb->SCB_HaStat = HOST_BUS_FREE; + tul_append_done_scb(pCurHcb, pCurScb); + } + pCurHcb->HCS_ActScb = NULL; + pCurHcb->HCS_ActTcs = NULL; } - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); /* Flush SCSI FIFO */ - TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT); - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT); /* Enable HW reselect */ - return (-1); + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); /* Flush SCSI FIFO */ + TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT); + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);/* Enable HW reselect */ + return (-1); +/* return (1);*/ } /***************************************************************************/ /* scsi bus reset */ -int int_tul_scsi_rst(HCS * pCurHcb) +int int_tul_scsi_rst(HCS *pCurHcb) { - SCB *pCurScb; - int i; + SCB *pCurScb; + int i; /* if DMA xfer is pending, abort DMA xfer */ - if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & 0x01) { - TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_ABT | TAX_X_CLR_FIFO); + if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & 0x01) + { + TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_ABT | TAX_X_CLR_FIFO); /* wait Abort DMA xfer done */ - while ((TUL_RD(pCurHcb->HCS_Base, TUL_Int) & 0x04) == 0); - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); + while ((TUL_RD(pCurHcb->HCS_Base, TUL_Int) & 0x04) == 0) + ; + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); } - /* Abort all active & disconnected scb */ - while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) { - pCurScb->SCB_HaStat = HOST_BAD_PHAS; - tul_append_done_scb(pCurHcb, pCurScb); + /* Abort all active & disconnected scb */ + while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) + { +// pCurScb->SCB_Status = SCB_DONE; + pCurScb->SCB_HaStat = HOST_BAD_PHAS; + tul_append_done_scb(pCurHcb, pCurScb); } - pCurHcb->HCS_ActScb = NULL; - pCurHcb->HCS_ActTcs = NULL; + pCurHcb->HCS_ActScb = NULL; + pCurHcb->HCS_ActTcs = NULL; /* clr sync nego. done flag */ - for (i = 0; i < pCurHcb->HCS_MaxTar; i++) { - pCurHcb->HCS_Tcs[i].TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE); + for (i = 0; i < pCurHcb->HCS_MaxTar; i++) + { + pCurHcb->HCS_Tcs[i].TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE); } - return (-1); + return(-1); } /***************************************************************************/ /* scsi reselection */ -int int_tul_resel(HCS * pCurHcb) -{ - SCB *pCurScb; - TCS *pCurTcb; - BYTE tag, msg = 0; - BYTE tar, lun; - - if ((pCurScb = pCurHcb->HCS_ActScb) != NULL) { - if (pCurScb->SCB_Status & SCB_SELECT) { /* if waiting for selection complete */ - pCurScb->SCB_Status &= ~SCB_SELECT; - } - pCurHcb->HCS_ActScb = NULL; +int int_tul_resel(HCS *pCurHcb) +{ + SCB *pCurScb; + TCS *pCurTcb; + BYTE tag, msg = 0; + BYTE tar, lun; + + if ((pCurScb = pCurHcb->HCS_ActScb) != NULL) + { + if (pCurScb->SCB_Status & SCB_SELECT) + { /* if waiting for selection complete*/ + pCurScb->SCB_Status &= ~SCB_SELECT; + } + pCurHcb->HCS_ActScb = NULL; } + /* --------- get target id---------------------- */ - tar = TUL_RD(pCurHcb->HCS_Base, TUL_SBusId); + tar = TUL_RD(pCurHcb->HCS_Base, TUL_SBusId); /* ------ get LUN from Identify message----------- */ - lun = TUL_RD(pCurHcb->HCS_Base, TUL_SIdent) & 0x0F; - /* 07/22/98 from 0x1F -> 0x0F */ - pCurTcb = &pCurHcb->HCS_Tcs[tar]; - pCurHcb->HCS_ActTcs = pCurTcb; - TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurTcb->TCS_SConfig0); - TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, pCurTcb->TCS_JS_Period); + lun = TUL_RD(pCurHcb->HCS_Base, TUL_SIdent) & 0x0F; + /* 07/22/98 from 0x1F -> 0x0F */ + pCurTcb = &pCurHcb->HCS_Tcs[tar]; + pCurHcb->HCS_ActTcs = pCurTcb; + TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurTcb->TCS_SConfig0); + TUL_WR(pCurHcb->HCS_Base+ TUL_SPeriod, pCurTcb->TCS_JS_Period); /* ------------- tag queueing ? ------------------- */ - if (pCurTcb->TCS_DrvFlags & TCF_DRV_EN_TAG) { - if ((tul_msgin_accept(pCurHcb)) == -1) - return (-1); - if (pCurHcb->HCS_Phase != MSG_IN) - goto no_tag; - TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN); - if ((wait_tulip(pCurHcb)) == -1) - return (-1); - msg = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); /* Read Tag Message */ + if (pCurTcb->TCS_DrvFlags & TCF_DRV_EN_TAG) + { +/*printk("Tag enabled\n");*/ + if ((tul_msgin_accept(pCurHcb)) == -1) + return (-1); + if (pCurHcb->HCS_Phase != MSG_IN) + goto no_tag; + TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1); + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_XF_FIFO_IN); + if ((wait_tulip(pCurHcb)) == -1) + return (-1); + msg = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); /* Read Tag Message */ - if ((msg < MSG_STAG) || (msg > MSG_OTAG)) /* Is simple Tag */ - goto no_tag; + if ((msg < MSG_STAG) || (msg > MSG_OTAG)) /* Is simple Tag */ + goto no_tag; - if ((tul_msgin_accept(pCurHcb)) == -1) - return (-1); + if ((tul_msgin_accept(pCurHcb)) == -1) + return (-1); - if (pCurHcb->HCS_Phase != MSG_IN) - goto no_tag; + if (pCurHcb->HCS_Phase != MSG_IN) + goto no_tag; - TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN); - if ((wait_tulip(pCurHcb)) == -1) - return (-1); - tag = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); /* Read Tag ID */ - pCurScb = pCurHcb->HCS_Scb + tag; - if ((pCurScb->SCB_Target != tar) || (pCurScb->SCB_Lun != lun)) { - return tul_msgout_abort_tag(pCurHcb); - } - if (pCurScb->SCB_Status != SCB_BUSY) { /* 03/24/95 */ - return tul_msgout_abort_tag(pCurHcb); - } - pCurHcb->HCS_ActScb = pCurScb; - if ((tul_msgin_accept(pCurHcb)) == -1) - return (-1); - } else { /* No tag */ - no_tag: - if ((pCurScb = tul_find_busy_scb(pCurHcb, tar | (lun << 8))) == NULL) { - return tul_msgout_abort_targ(pCurHcb); - } - pCurHcb->HCS_ActScb = pCurScb; - if (!(pCurTcb->TCS_DrvFlags & TCF_DRV_EN_TAG)) { - if ((tul_msgin_accept(pCurHcb)) == -1) - return (-1); - } + TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1); + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN); + if ((wait_tulip(pCurHcb)) == -1) + return (-1); + tag = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); /* Read Tag ID */ + pCurScb = pCurHcb->HCS_Scb + tag; + if ((pCurScb->SCB_Target != tar) || (pCurScb->SCB_Lun != lun)) + { + return tul_msgout_abort_tag(pCurHcb); + } + if (pCurScb->SCB_Status != SCB_BUSY) + { /* 03/24/95 */ + return tul_msgout_abort_tag(pCurHcb); + } + pCurHcb->HCS_ActScb = pCurScb; + if ((tul_msgin_accept(pCurHcb)) == -1) + return (-1); + } + else /* No tag */ + { +no_tag: + if ((pCurScb = tul_find_busy_scb(pCurHcb, tar | (lun << 8))) == NULL) + { +/*printk("SCB pointer = NULL\n");*/ + return tul_msgout_abort_targ(pCurHcb); + } + pCurHcb->HCS_ActScb = pCurScb; + if (!(pCurTcb->TCS_DrvFlags & TCF_DRV_EN_TAG)) + { + if ((tul_msgin_accept(pCurHcb)) == -1) + return (-1); + } } - return 0; + return 0; } /***************************************************************************/ -int int_tul_bad_seq(HCS * pCurHcb) -{ /* target wrong phase */ - SCB *pCurScb; - int i; +int int_tul_bad_seq(HCS *pCurHcb) /* target wrong phase */ +{ + SCB *pCurScb; + int i; - tul_reset_scsi(pCurHcb, 10); + tul_reset_scsi(pCurHcb, 10); - while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) { - pCurScb->SCB_HaStat = HOST_BAD_PHAS; - tul_append_done_scb(pCurHcb, pCurScb); + while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) + { +// pCurScb->SCB_Status = SCB_DONE; + pCurScb->SCB_HaStat = HOST_BAD_PHAS; + tul_append_done_scb(pCurHcb, pCurScb); } - for (i = 0; i < pCurHcb->HCS_MaxTar; i++) { - pCurHcb->HCS_Tcs[i].TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);; + for (i = 0; i < pCurHcb->HCS_MaxTar; i++) + { + pCurHcb->HCS_Tcs[i].TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);; } - return (-1); + return (-1); } /***************************************************************************/ -int tul_msgout_abort_targ(HCS * pCurHcb) +int tul_msgout_abort_targ(HCS *pCurHcb) { - TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); - if (tul_msgin_accept(pCurHcb) == -1) - return (-1); - if (pCurHcb->HCS_Phase != MSG_OUT) - return (tul_bad_seq(pCurHcb)); + TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); + if (tul_msgin_accept(pCurHcb) == -1) + return(-1); + if (pCurHcb->HCS_Phase != MSG_OUT) + return(tul_bad_seq(pCurHcb)); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_ABORT); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); + TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_ABORT); + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - return tul_wait_disc(pCurHcb); + return tul_wait_disc(pCurHcb); } /***************************************************************************/ -int tul_msgout_abort_tag(HCS * pCurHcb) +int tul_msgout_abort_tag(HCS *pCurHcb) { - TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); - if (tul_msgin_accept(pCurHcb) == -1) - return (-1); - if (pCurHcb->HCS_Phase != MSG_OUT) - return (tul_bad_seq(pCurHcb)); + TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); + if (tul_msgin_accept(pCurHcb) == -1) + return(-1); + if (pCurHcb->HCS_Phase != MSG_OUT) + return(tul_bad_seq(pCurHcb)); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_ABORT_TAG); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); + TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_ABORT_TAG); + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - return tul_wait_disc(pCurHcb); + return tul_wait_disc(pCurHcb); } /***************************************************************************/ -int tul_msgin(HCS * pCurHcb) +int tul_msgin(HCS *pCurHcb) { - TCS *pCurTcb; + TCS *pCurTcb; - for (;;) { + for (;;) { - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); - TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1); + TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1); + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN); + if ((wait_tulip(pCurHcb)) == -1) + return (-1); + + switch (TUL_RD(pCurHcb->HCS_Base, TUL_SFifo)) { + case MSG_DISC: /* Disconnect msg */ + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT); + + return tul_wait_disc(pCurHcb); + + case MSG_SDP: + case MSG_RESTORE: + case MSG_NOP: + tul_msgin_accept(pCurHcb); + break; + + case MSG_REJ: /* Clear ATN first */ + TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, + (TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7))); + pCurTcb = pCurHcb->HCS_ActTcs; + if ((pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) + { /* do sync nego */ + TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); + } + tul_msgin_accept(pCurHcb); + break; + + case MSG_EXTEND: /* extended msg */ + tul_msgin_extend(pCurHcb); + break; + + case MSG_IGNOREWIDE: + tul_msgin_accept(pCurHcb); + break; + + /* get */ TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN); - if ((wait_tulip(pCurHcb)) == -1) - return (-1); - - switch (TUL_RD(pCurHcb->HCS_Base, TUL_SFifo)) { - case MSG_DISC: /* Disconnect msg */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT); - - return tul_wait_disc(pCurHcb); - - case MSG_SDP: - case MSG_RESTORE: - case MSG_NOP: - tul_msgin_accept(pCurHcb); - break; - - case MSG_REJ: /* Clear ATN first */ - TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, - (TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7))); - pCurTcb = pCurHcb->HCS_ActTcs; - if ((pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) { /* do sync nego */ - TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); - } - tul_msgin_accept(pCurHcb); - break; - - case MSG_EXTEND: /* extended msg */ - tul_msgin_extend(pCurHcb); - break; - - case MSG_IGNOREWIDE: - tul_msgin_accept(pCurHcb); - break; - - /* get */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN); - if (wait_tulip(pCurHcb) == -1) - return -1; + if (wait_tulip(pCurHcb) == -1) + return -1; - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 0); /* put pad */ - TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); /* get IGNORE field */ - TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); /* get pad */ + TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 0); /* put pad */ + TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); /* get IGNORE field */ + TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); /* get pad */ - tul_msgin_accept(pCurHcb); - break; + tul_msgin_accept(pCurHcb); + break; - case MSG_COMP: - { - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT); - return tul_wait_done_disc(pCurHcb); - } - default: - tul_msgout_reject(pCurHcb); - break; + case MSG_COMP: + { + TUL_WR(pCurHcb->HCS_Base+ TUL_SCtrl0, TSC_FLUSH_FIFO); + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_MSG_ACCEPT); + return tul_wait_done_disc(pCurHcb); } - if (pCurHcb->HCS_Phase != MSG_IN) - return (pCurHcb->HCS_Phase); + default: + tul_msgout_reject(pCurHcb); + break; } + if (pCurHcb->HCS_Phase != MSG_IN) + return (pCurHcb->HCS_Phase); + } /* statement won't reach here */ } @@ -2384,425 +2826,507 @@ int tul_msgin(HCS * pCurHcb) /***************************************************************************/ -int tul_msgout_reject(HCS * pCurHcb) +int tul_msgout_reject(HCS *pCurHcb) { - TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); + TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); - if ((tul_msgin_accept(pCurHcb)) == -1) - return (-1); + if ((tul_msgin_accept(pCurHcb)) == -1) + return(-1); - if (pCurHcb->HCS_Phase == MSG_OUT) { - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_REJ); /* Msg reject */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - return (wait_tulip(pCurHcb)); + if (pCurHcb->HCS_Phase == MSG_OUT) + { + TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_REJ); /* Msg reject */ + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); + return (wait_tulip(pCurHcb)); } - return (pCurHcb->HCS_Phase); + return (pCurHcb->HCS_Phase); } /***************************************************************************/ -int tul_msgout_ide(HCS * pCurHcb) +int tul_msgout_ide(HCS *pCurHcb) { - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_IDE); /* Initiator Detected Error */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - return (wait_tulip(pCurHcb)); + TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_IDE); /* Initiator Detected Error */ + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); + return (wait_tulip(pCurHcb)); } /***************************************************************************/ -int tul_msgin_extend(HCS * pCurHcb) +int tul_msgin_extend(HCS *pCurHcb) { - BYTE len, idx; + BYTE len, idx; - if (tul_msgin_accept(pCurHcb) != MSG_IN) - return (pCurHcb->HCS_Phase); + if (tul_msgin_accept(pCurHcb) != MSG_IN) + return (pCurHcb->HCS_Phase); - /* Get extended msg length */ - TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN); - if (wait_tulip(pCurHcb) == -1) - return (-1); + /* Get extended msg length */ + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_SCnt0, 1); + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_XF_FIFO_IN); + if (wait_tulip(pCurHcb) == -1) + return (-1); - len = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); - pCurHcb->HCS_Msg[0] = len; - for (idx = 1; len != 0; len--) { + len = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); + pCurHcb->HCS_Msg[0] = len; + for (idx = 1 ; len != 0; len--) { - if ((tul_msgin_accept(pCurHcb)) != MSG_IN) - return (pCurHcb->HCS_Phase); - TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN); - if (wait_tulip(pCurHcb) == -1) - return (-1); - pCurHcb->HCS_Msg[idx++] = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); - } - if (pCurHcb->HCS_Msg[1] == 1) { /* if it's synchronous data transfer request */ - if (pCurHcb->HCS_Msg[0] != 3) /* if length is not right */ - return (tul_msgout_reject(pCurHcb)); - if (pCurHcb->HCS_ActTcs->TCS_Flags & TCF_NO_SYNC_NEGO) { /* Set OFFSET=0 to do async, nego back */ - pCurHcb->HCS_Msg[3] = 0; - } else { - if ((tul_msgin_sync(pCurHcb) == 0) && - (pCurHcb->HCS_ActTcs->TCS_Flags & TCF_SYNC_DONE)) { - tul_sync_done(pCurHcb); - return (tul_msgin_accept(pCurHcb)); - } + if ((tul_msgin_accept(pCurHcb)) != MSG_IN) + return (pCurHcb->HCS_Phase); + TUL_WRLONG(pCurHcb->HCS_Base+ TUL_SCnt0, 1); + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_XF_FIFO_IN); + if (wait_tulip(pCurHcb) == -1) + return (-1); + pCurHcb->HCS_Msg[idx++] = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo); + } + if (pCurHcb->HCS_Msg[1] == 1) + { /* if it's synchronous data transfer request */ + if (pCurHcb->HCS_Msg[0] != 3) /* if length is not right */ + return (tul_msgout_reject(pCurHcb)); + if (pCurHcb->HCS_ActTcs->TCS_Flags & TCF_NO_SYNC_NEGO) + { /* Set OFFSET=0 to do async, nego back */ + pCurHcb->HCS_Msg[3] = 0; + } + else + { + if ((tul_msgin_sync(pCurHcb) == 0) && + (pCurHcb->HCS_ActTcs->TCS_Flags & TCF_SYNC_DONE)) + { + tul_sync_done(pCurHcb); + return (tul_msgin_accept(pCurHcb)); } + } - TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); - if ((tul_msgin_accept(pCurHcb)) != MSG_OUT) - return (pCurHcb->HCS_Phase); - /* sync msg out */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); + TUL_WR(pCurHcb->HCS_Base+ TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); + if ((tul_msgin_accept(pCurHcb)) != MSG_OUT) + return (pCurHcb->HCS_Phase); + /* sync msg out */ + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); +/* TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, TSC_FLUSH_FIFO); */ - tul_sync_done(pCurHcb); + tul_sync_done(pCurHcb); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 1); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurHcb->HCS_Msg[2]); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurHcb->HCS_Msg[3]); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, MSG_EXTEND); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, 3); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, 1); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, pCurHcb->HCS_Msg[2]); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, pCurHcb->HCS_Msg[3]); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - return (wait_tulip(pCurHcb)); - } - if ((pCurHcb->HCS_Msg[0] != 2) || (pCurHcb->HCS_Msg[1] != 3)) - return (tul_msgout_reject(pCurHcb)); - /* if it's WIDE DATA XFER REQ */ - if (pCurHcb->HCS_ActTcs->TCS_Flags & TCF_NO_WDTR) { - pCurHcb->HCS_Msg[2] = 0; - } else { - if (pCurHcb->HCS_Msg[2] > 2) /* > 32 bits */ - return (tul_msgout_reject(pCurHcb)); - if (pCurHcb->HCS_Msg[2] == 2) { /* == 32 */ - pCurHcb->HCS_Msg[2] = 1; - } else { - if ((pCurHcb->HCS_ActTcs->TCS_Flags & TCF_NO_WDTR) == 0) { - wdtr_done(pCurHcb); - if ((pCurHcb->HCS_ActTcs->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) - TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); - return (tul_msgin_accept(pCurHcb)); - } + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_XF_FIFO_OUT); + return (wait_tulip(pCurHcb)); + } + + if ((pCurHcb->HCS_Msg[0] != 2) || (pCurHcb->HCS_Msg[1] != 3)) + return (tul_msgout_reject(pCurHcb)); + /* if it's WIDE DATA XFER REQ */ + if (pCurHcb->HCS_ActTcs->TCS_Flags & TCF_NO_WDTR) + { + pCurHcb->HCS_Msg[2] = 0; + } + else + { + if (pCurHcb->HCS_Msg[2] > 2) /* > 32 bits */ + return (tul_msgout_reject(pCurHcb)); + if (pCurHcb->HCS_Msg[2] == 2) /* == 32 */ + { + pCurHcb->HCS_Msg[2] = 1; + } + else + { + if ((pCurHcb->HCS_ActTcs->TCS_Flags & TCF_NO_WDTR) == 0) + { + wdtr_done(pCurHcb); + if ((pCurHcb->HCS_ActTcs->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) + TUL_WR(pCurHcb->HCS_Base+ TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); + return (tul_msgin_accept(pCurHcb)); } + } } - TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); + TUL_WR(pCurHcb->HCS_Base+ TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN)); - if (tul_msgin_accept(pCurHcb) != MSG_OUT) - return (pCurHcb->HCS_Phase); - /* WDTR msg out */ - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 2); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurHcb->HCS_Msg[2]); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - return (wait_tulip(pCurHcb)); + if (tul_msgin_accept(pCurHcb) != MSG_OUT) + return (pCurHcb->HCS_Phase); + /* WDTR msg out */ + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, MSG_EXTEND); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, 2); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, 3); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, pCurHcb->HCS_Msg[2]); + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_XF_FIFO_OUT); + return (wait_tulip(pCurHcb)); } /***************************************************************************/ -int tul_msgin_sync(HCS * pCurHcb) -{ - char default_period; - - default_period = tul_rate_tbl[pCurHcb->HCS_ActTcs->TCS_Flags & TCF_SCSI_RATE]; - if (pCurHcb->HCS_Msg[3] > MAX_OFFSET) { - pCurHcb->HCS_Msg[3] = MAX_OFFSET; - if (pCurHcb->HCS_Msg[2] < default_period) { - pCurHcb->HCS_Msg[2] = default_period; - return 1; - } - if (pCurHcb->HCS_Msg[2] >= 59) { /* Change to async */ - pCurHcb->HCS_Msg[3] = 0; - } - return 1; +int tul_msgin_sync(HCS *pCurHcb) +{ + char default_period; + + default_period = tul_rate_tbl[pCurHcb->HCS_ActTcs->TCS_Flags & TCF_SCSI_RATE]; + if (pCurHcb->HCS_Msg[3] > MAX_OFFSET) + { + pCurHcb->HCS_Msg[3] = MAX_OFFSET; + if (pCurHcb->HCS_Msg[2] < default_period) + { + pCurHcb->HCS_Msg[2] = default_period; + return 1; + } + if (pCurHcb->HCS_Msg[2] >= 59) + { /* Change to async */ + pCurHcb->HCS_Msg[3] = 0; + } + return 1; } - /* offset requests asynchronous transfers ? */ - if (pCurHcb->HCS_Msg[3] == 0) { - return 0; + + /* offset requests asynchronous transfers ? */ + if (pCurHcb->HCS_Msg[3] == 0) + { + return 0; } - if (pCurHcb->HCS_Msg[2] < default_period) { - pCurHcb->HCS_Msg[2] = default_period; - return 1; + if (pCurHcb->HCS_Msg[2] < default_period) + { + pCurHcb->HCS_Msg[2] = default_period; + return 1; } - if (pCurHcb->HCS_Msg[2] >= 59) { - pCurHcb->HCS_Msg[3] = 0; - return 1; + + if (pCurHcb->HCS_Msg[2] >= 59) + { + pCurHcb->HCS_Msg[3] = 0; + return 1; } - return 0; + return 0; } /***************************************************************************/ -int wdtr_done(HCS * pCurHcb) +int wdtr_done(HCS *pCurHcb) { - pCurHcb->HCS_ActTcs->TCS_Flags &= ~TCF_SYNC_DONE; - pCurHcb->HCS_ActTcs->TCS_Flags |= TCF_WDTR_DONE; + pCurHcb->HCS_ActTcs->TCS_Flags &= ~TCF_SYNC_DONE; + pCurHcb->HCS_ActTcs->TCS_Flags |= TCF_WDTR_DONE; - pCurHcb->HCS_ActTcs->TCS_JS_Period = 0; - if (pCurHcb->HCS_Msg[2]) { /* if 16 bit */ - pCurHcb->HCS_ActTcs->TCS_JS_Period |= TSC_WIDE_SCSI; + pCurHcb->HCS_ActTcs->TCS_JS_Period = 0; + if (pCurHcb->HCS_Msg[2]) + { /* if 16 bit */ + pCurHcb->HCS_ActTcs->TCS_JS_Period |= TSC_WIDE_SCSI; } - pCurHcb->HCS_ActTcs->TCS_SConfig0 &= ~TSC_ALT_PERIOD; - TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurHcb->HCS_ActTcs->TCS_SConfig0); - TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, pCurHcb->HCS_ActTcs->TCS_JS_Period); + pCurHcb->HCS_ActTcs->TCS_SConfig0 &= ~TSC_ALT_PERIOD; + TUL_WR(pCurHcb->HCS_Base+TUL_SConfig, pCurHcb->HCS_ActTcs->TCS_SConfig0); + TUL_WR(pCurHcb->HCS_Base+TUL_SPeriod, pCurHcb->HCS_ActTcs->TCS_JS_Period); - return 1; + return 1; } /***************************************************************************/ -int tul_sync_done(HCS * pCurHcb) +int tul_sync_done(HCS *pCurHcb) { - int i; + int i; - pCurHcb->HCS_ActTcs->TCS_Flags |= TCF_SYNC_DONE; + pCurHcb->HCS_ActTcs->TCS_Flags |= TCF_SYNC_DONE; - if (pCurHcb->HCS_Msg[3]) { - pCurHcb->HCS_ActTcs->TCS_JS_Period |= pCurHcb->HCS_Msg[3]; - for (i = 0; i < 8; i++) { - if (tul_rate_tbl[i] >= pCurHcb->HCS_Msg[2]) /* pick the big one */ - break; - } - pCurHcb->HCS_ActTcs->TCS_JS_Period |= (i << 4); - pCurHcb->HCS_ActTcs->TCS_SConfig0 |= TSC_ALT_PERIOD; + if (pCurHcb->HCS_Msg[3]) + { + pCurHcb->HCS_ActTcs->TCS_JS_Period |= pCurHcb->HCS_Msg[3]; + for (i = 0; i < 8; i++) + { + if (tul_rate_tbl[i] >= pCurHcb->HCS_Msg[2]) /* pick the big one */ + break; + } + pCurHcb->HCS_ActTcs->TCS_JS_Period |= (i << 4); + pCurHcb->HCS_ActTcs->TCS_SConfig0 |= TSC_ALT_PERIOD; } - TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurHcb->HCS_ActTcs->TCS_SConfig0); - TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, pCurHcb->HCS_ActTcs->TCS_JS_Period); + TUL_WR(pCurHcb->HCS_Base+TUL_SConfig, pCurHcb->HCS_ActTcs->TCS_SConfig0); + TUL_WR(pCurHcb->HCS_Base+TUL_SPeriod, pCurHcb->HCS_ActTcs->TCS_JS_Period); - return (-1); + return (-1); } -int tul_post_scsi_rst(HCS * pCurHcb) +int tul_post_scsi_rst(HCS *pCurHcb) { - SCB *pCurScb; - TCS *pCurTcb; - int i; + SCB *pCurScb; + TCS *pCurTcb; + int i; - pCurHcb->HCS_ActScb = 0; - pCurHcb->HCS_ActTcs = 0; - pCurHcb->HCS_Flags = 0; + pCurHcb->HCS_ActScb = 0; + pCurHcb->HCS_ActTcs = 0; + pCurHcb->HCS_Flags = 0; - while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) { - pCurScb->SCB_HaStat = HOST_BAD_PHAS; - tul_append_done_scb(pCurHcb, pCurScb); + while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) + { +// pCurScb->SCB_Status = SCB_DONE; + pCurScb->SCB_HaStat = HOST_BAD_PHAS; + tul_append_done_scb(pCurHcb, pCurScb); } - /* clear sync done flag */ - pCurTcb = &pCurHcb->HCS_Tcs[0]; - for (i = 0; i < pCurHcb->HCS_MaxTar; pCurTcb++, i++) { - pCurTcb->TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE); + /* clear sync done flag */ + pCurTcb = &pCurHcb->HCS_Tcs[0]; + for (i = 0; i < pCurHcb->HCS_MaxTar; pCurTcb++, i++) + { + pCurTcb->TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE); /* Initialize the sync. xfer register values to an asyn xfer */ - pCurTcb->TCS_JS_Period = 0; - pCurTcb->TCS_SConfig0 = pCurHcb->HCS_SConf1; - pCurHcb->HCS_ActTags[0] = 0; /* 07/22/98 */ - pCurHcb->HCS_Tcs[i].TCS_Flags &= ~TCF_BUSY; /* 07/22/98 */ - } /* for */ + pCurTcb->TCS_JS_Period = 0; + pCurTcb->TCS_SConfig0 = pCurHcb->HCS_SConf1; + pCurHcb->HCS_ActTags[0] = 0; /* 07/22/98 */ + pCurHcb->HCS_Tcs[i].TCS_Flags &= ~TCF_BUSY; /* 07/22/98 */ + } /* for */ - return (-1); +// pCurHcb->HCS_Semaph = 1; /* 07/29/98 */ + return (-1); } /***************************************************************************/ -void tul_select_atn_stop(HCS * pCurHcb, SCB * pCurScb) +void tul_select_atn_stop(HCS *pCurHcb, SCB *pCurScb) { - pCurScb->SCB_Status |= SCB_SELECT; - pCurScb->SCB_NxtStat = 0x1; - pCurHcb->HCS_ActScb = pCurScb; - pCurHcb->HCS_ActTcs = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target]; - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_SELATNSTOP); - return; + pCurScb->SCB_Status |= SCB_SELECT; + pCurScb->SCB_NxtStat = 0x1; + pCurHcb->HCS_ActScb = pCurScb; + pCurHcb->HCS_ActTcs = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target]; + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_SELATNSTOP); + return; } /***************************************************************************/ -void tul_select_atn(HCS * pCurHcb, SCB * pCurScb) +void tul_select_atn(HCS *pCurHcb, SCB *pCurScb) { - int i; + int i; - pCurScb->SCB_Status |= SCB_SELECT; - pCurScb->SCB_NxtStat = 0x2; + pCurScb->SCB_Status |= SCB_SELECT; + pCurScb->SCB_NxtStat = 0x2; - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_Ident); - for (i = 0; i < (int) pCurScb->SCB_CDBLen; i++) - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_CDB[i]); - pCurHcb->HCS_ActTcs = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target]; - pCurHcb->HCS_ActScb = pCurScb; - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_SEL_ATN); - return; + TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_Ident); + for (i = 0; i < (int)pCurScb->SCB_CDBLen; i++) + TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_CDB[i]); + pCurHcb->HCS_ActTcs = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target]; + pCurHcb->HCS_ActScb = pCurScb; + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_SEL_ATN); + return; } /***************************************************************************/ -void tul_select_atn3(HCS * pCurHcb, SCB * pCurScb) +void tul_select_atn3(HCS *pCurHcb, SCB *pCurScb) { - int i; + int i; - pCurScb->SCB_Status |= SCB_SELECT; - pCurScb->SCB_NxtStat = 0x2; + pCurScb->SCB_Status |= SCB_SELECT; + pCurScb->SCB_NxtStat = 0x2; - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_Ident); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_TagMsg); - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_TagId); - for (i = 0; i < (int) pCurScb->SCB_CDBLen; i++) - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_CDB[i]); - pCurHcb->HCS_ActTcs = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target]; - pCurHcb->HCS_ActScb = pCurScb; - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_SEL_ATN3); - return; + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, pCurScb->SCB_Ident); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, pCurScb->SCB_TagMsg); + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, pCurScb->SCB_TagId); + for (i = 0; i < (int) pCurScb->SCB_CDBLen; i++) + TUL_WR(pCurHcb->HCS_Base+ TUL_SFifo, pCurScb->SCB_CDB[i]); + pCurHcb->HCS_ActTcs = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target]; + pCurHcb->HCS_ActScb = pCurScb; + TUL_WR(pCurHcb->HCS_Base+ TUL_SCmd, TSC_SEL_ATN3); + return; } /***************************************************************************/ /* SCSI Bus Device Reset */ -int tul_bus_device_reset(HCS * pCurHcb) +int tul_bus_device_reset(HCS *pCurHcb) { - SCB *pCurScb = pCurHcb->HCS_ActScb; - TCS *pCurTcb = pCurHcb->HCS_ActTcs; - SCB *pTmpScb, *pPrevScb; - BYTE tar; + SCB *pCurScb = pCurHcb->HCS_ActScb; + TCS *pCurTcb = pCurHcb->HCS_ActTcs; + SCB *pTmpScb, *pPrevScb; + BYTE tar; - if (pCurHcb->HCS_Phase != MSG_OUT) { - return (int_tul_bad_seq(pCurHcb)); /* Unexpected phase */ + if (pCurHcb->HCS_Phase != MSG_OUT) + { + return (int_tul_bad_seq(pCurHcb)); /* Unexpected phase */ } - tul_unlink_pend_scb(pCurHcb, pCurScb); - tul_release_scb(pCurHcb, pCurScb); + tul_unlink_pend_scb(pCurHcb, pCurScb); +#if 0 + pCurScb->SCB_HaStat = 0; + pCurScb->SCB_Status = SCB_DONE; /* command done */ + tul_append_done_scb(pCurHcb, pCurScb); +#else + tul_release_scb(pCurHcb, pCurScb); +#endif - tar = pCurScb->SCB_Target; /* target */ - pCurTcb->TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE | TCF_BUSY); - /* clr sync. nego & WDTR flags 07/22/98 */ + + tar = pCurScb->SCB_Target; /* target */ + pCurTcb->TCS_Flags &= ~(TCF_SYNC_DONE|TCF_WDTR_DONE|TCF_BUSY); + /* clr sync. nego & WDTR flags 07/22/98 */ /* abort all SCB with same target */ - pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy; /* Check Busy queue */ - while (pTmpScb != NULL) { - - if (pTmpScb->SCB_Target == tar) { - /* unlink it */ - if (pTmpScb == pCurHcb->HCS_FirstBusy) { - if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL) - pCurHcb->HCS_LastBusy = NULL; - } else { - pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb; - if (pTmpScb == pCurHcb->HCS_LastBusy) - pCurHcb->HCS_LastBusy = pPrevScb; - } - pTmpScb->SCB_HaStat = HOST_ABORTED; - tul_append_done_scb(pCurHcb, pTmpScb); + pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy; /* Check Busy queue */ + while (pTmpScb != NULL) { + + if (pTmpScb->SCB_Target == tar) + { + /* unlink it */ + if (pTmpScb == pCurHcb->HCS_FirstBusy) + { + if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL) + pCurHcb->HCS_LastBusy = NULL; } - /* Previous haven't change */ - else { - pPrevScb = pTmpScb; + else + { + pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb; + if (pTmpScb == pCurHcb->HCS_LastBusy) + pCurHcb->HCS_LastBusy = pPrevScb; } - pTmpScb = pTmpScb->SCB_NxtScb; + pTmpScb->SCB_HaStat = HOST_ABORTED; + tul_append_done_scb(pCurHcb, pTmpScb); + } /* Previous haven't change */ + else + { + pPrevScb = pTmpScb; + } + pTmpScb = pTmpScb->SCB_NxtScb; } - TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_DEVRST); - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); + TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_DEVRST); + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT); - return tul_wait_disc(pCurHcb); + return tul_wait_disc(pCurHcb); } /***************************************************************************/ -int tul_msgin_accept(HCS * pCurHcb) +int tul_msgin_accept(HCS *pCurHcb) { - TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT); - return (wait_tulip(pCurHcb)); + TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT); + return (wait_tulip(pCurHcb)); } /***************************************************************************/ -int wait_tulip(HCS * pCurHcb) -{ - - while (!((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0)) - & TSS_INT_PENDING)); - - pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt); - pCurHcb->HCS_Phase = pCurHcb->HCS_JSStatus0 & TSS_PH_MASK; - pCurHcb->HCS_JSStatus1 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1); - - if (pCurHcb->HCS_JSInt & TSS_RESEL_INT) { /* if SCSI bus reset detected */ - return (int_tul_resel(pCurHcb)); - } - if (pCurHcb->HCS_JSInt & TSS_SEL_TIMEOUT) { /* if selected/reselected timeout interrupt */ - return (int_tul_busfree(pCurHcb)); - } - if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) { /* if SCSI bus reset detected */ - return (int_tul_scsi_rst(pCurHcb)); - } - if (pCurHcb->HCS_JSInt & TSS_DISC_INT) { /* BUS disconnection */ - if (pCurHcb->HCS_Flags & HCF_EXPECT_DONE_DISC) { - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); /* Flush SCSI FIFO */ - tul_unlink_busy_scb(pCurHcb, pCurHcb->HCS_ActScb); - pCurHcb->HCS_ActScb->SCB_HaStat = 0; - tul_append_done_scb(pCurHcb, pCurHcb->HCS_ActScb); - pCurHcb->HCS_ActScb = NULL; - pCurHcb->HCS_ActTcs = NULL; - pCurHcb->HCS_Flags &= ~HCF_EXPECT_DONE_DISC; - TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT); - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT); /* Enable HW reselect */ - return (-1); - } - if (pCurHcb->HCS_Flags & HCF_EXPECT_DISC) { - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); /* Flush SCSI FIFO */ - pCurHcb->HCS_ActScb = NULL; - pCurHcb->HCS_ActTcs = NULL; - pCurHcb->HCS_Flags &= ~HCF_EXPECT_DISC; - TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT); - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT); /* Enable HW reselect */ - return (-1); - } - return (int_tul_busfree(pCurHcb)); - } - if (pCurHcb->HCS_JSInt & (TSS_FUNC_COMP | TSS_BUS_SERV)) { - return (pCurHcb->HCS_Phase); - } +int wait_tulip(HCS *pCurHcb) +{ +/* register BYTE s; + int phase;*/ +// ULONG flags; + +// pCurHcb->HCS_Flags &= ~HCF_RESET; + + while (!((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base,TUL_SStatus0)) + & TSS_INT_PENDING)) { +// save_flags(flags); /* wh 07/21/98 */ +// sti(); +// restore_flags(flags); /* Addedby hc 07/21/98 */ + +// if (pCurHcb->HCS_Flags & HCF_RESET) { +// return -1; +// } + } + + pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt); + pCurHcb->HCS_Phase = pCurHcb->HCS_JSStatus0 & TSS_PH_MASK; + pCurHcb->HCS_JSStatus1 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1); + +/* stat2 = TUL_RD(pCurHcb->HCS_Base,TUL_SStatus2); + printk("SCSI int status = %x", pCurHcb->HCS_JSInt);*/ + + if (pCurHcb->HCS_JSInt & TSS_RESEL_INT) + { /* if SCSI bus reset detected */ + return (int_tul_resel(pCurHcb)); + } + + if (pCurHcb->HCS_JSInt & TSS_SEL_TIMEOUT) + { /* if selected/reselected timeout interrupt */ + return (int_tul_busfree(pCurHcb)); + } + + if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) + { /* if SCSI bus reset detected */ + return (int_tul_scsi_rst(pCurHcb)); + } + + if (pCurHcb->HCS_JSInt & TSS_DISC_INT) + { /* BUS disconnection */ + if (pCurHcb->HCS_Flags & HCF_EXPECT_DONE_DISC) + { + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); /* Flush SCSI FIFO */ + tul_unlink_busy_scb(pCurHcb, pCurHcb->HCS_ActScb); +// pCurHcb->HCS_ActScb->SCB_Status = SCB_DONE; + pCurHcb->HCS_ActScb->SCB_HaStat = 0; + tul_append_done_scb(pCurHcb, pCurHcb->HCS_ActScb); + pCurHcb->HCS_ActScb = NULL; + pCurHcb->HCS_ActTcs = NULL; + pCurHcb->HCS_Flags &= ~HCF_EXPECT_DONE_DISC; + TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT); + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);/* Enable HW reselect */ + return (-1); + } + if (pCurHcb->HCS_Flags & HCF_EXPECT_DISC) + { + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); /* Flush SCSI FIFO */ + pCurHcb->HCS_ActScb = NULL; + pCurHcb->HCS_ActTcs = NULL; + pCurHcb->HCS_Flags &= ~HCF_EXPECT_DISC; + TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT); + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);/* Enable HW reselect */ + return (-1); + } + return (int_tul_busfree(pCurHcb)); + } + + if (pCurHcb->HCS_JSInt & (TSS_FUNC_COMP | TSS_BUS_SERV)) + { return (pCurHcb->HCS_Phase); + } + + return (pCurHcb->HCS_Phase); } /***************************************************************************/ -int tul_wait_disc(HCS * pCurHcb) +int tul_wait_disc(HCS *pCurHcb) { - while (!((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0)) - & TSS_INT_PENDING)); - + while (!((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base,TUL_SStatus0)) + & TSS_INT_PENDING)) + ; + - pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt); + pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt); - if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) { /* if SCSI bus reset detected */ - return (int_tul_scsi_rst(pCurHcb)); + if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) + { /* if SCSI bus reset detected */ + return (int_tul_scsi_rst(pCurHcb)); } - if (pCurHcb->HCS_JSInt & TSS_DISC_INT) { /* BUS disconnection */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); /* Flush SCSI FIFO */ - TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT); - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT); /* Enable HW reselect */ - pCurHcb->HCS_ActScb = NULL; - return (-1); + + if (pCurHcb->HCS_JSInt & TSS_DISC_INT) + { /* BUS disconnection */ + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); /* Flush SCSI FIFO */ + TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT); + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);/* Enable HW reselect */ + pCurHcb->HCS_ActScb = NULL; + return (-1); } - return (tul_bad_seq(pCurHcb)); + + return (tul_bad_seq(pCurHcb)); } /***************************************************************************/ -int tul_wait_done_disc(HCS * pCurHcb) +int tul_wait_done_disc(HCS *pCurHcb) { - while (!((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0)) - & TSS_INT_PENDING)); - - pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt); + while (!((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base,TUL_SStatus0)) + & TSS_INT_PENDING)) + ; + pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt); + - if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) { /* if SCSI bus reset detected */ - return (int_tul_scsi_rst(pCurHcb)); + if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) + { /* if SCSI bus reset detected */ + return (int_tul_scsi_rst(pCurHcb)); } - if (pCurHcb->HCS_JSInt & TSS_DISC_INT) { /* BUS disconnection */ - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); /* Flush SCSI FIFO */ - TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT); - TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT); /* Enable HW reselect */ - tul_unlink_busy_scb(pCurHcb, pCurHcb->HCS_ActScb); - tul_append_done_scb(pCurHcb, pCurHcb->HCS_ActScb); - pCurHcb->HCS_ActScb = NULL; - return (-1); + if (pCurHcb->HCS_JSInt & TSS_DISC_INT) + { /* BUS disconnection */ + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO); /* Flush SCSI FIFO */ + TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT); + TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);/* Enable HW reselect */ + tul_unlink_busy_scb(pCurHcb, pCurHcb->HCS_ActScb); + + tul_append_done_scb(pCurHcb, pCurHcb->HCS_ActScb); + pCurHcb->HCS_ActScb = NULL; + return (-1); } - return (tul_bad_seq(pCurHcb)); + + + return (tul_bad_seq(pCurHcb)); } /**************************** EOF *********************************/ diff --git a/drivers/scsi/i91uscsi.h b/drivers/scsi/i91uscsi.h index b3a2253bd8f5..05ad7c101d90 100644 --- a/drivers/scsi/i91uscsi.h +++ b/drivers/scsi/i91uscsi.h @@ -1,3 +1,4 @@ + /************************************************************************** * Initio 9100 device driver for Linux. * @@ -53,8 +54,6 @@ * **************************************************************************/ -#include - #define ULONG unsigned long #define USHORT unsigned short #define UCHAR unsigned char @@ -71,271 +70,277 @@ #endif #ifndef NULL -#define NULL 0 /* zero */ +#define NULL 0 /* zero */ #endif #ifndef TRUE -#define TRUE (1) /* boolean true */ +#define TRUE (1) /* boolean true */ #endif #ifndef FALSE -#define FALSE (0) /* boolean false */ +#define FALSE (0) /* boolean false */ #endif #ifndef FAILURE #define FAILURE (-1) #endif +/*#endif*/ #define TOTAL_SG_ENTRY 32 #define MAX_SUPPORTED_ADAPTERS 8 #define MAX_OFFSET 15 #define MAX_TARGETS 16 -#define INI_VENDOR_ID 0x1101 /* Initio's PCI vendor ID */ -#define I950_DEVICE_ID 0x9500 /* Initio's inic-950 product ID */ -#define I940_DEVICE_ID 0x9400 /* Initio's inic-940 product ID */ -#define I935_DEVICE_ID 0x9401 /* Initio's inic-935 product ID */ +#define INI_VENDOR_ID 0x1101 /* Initio's PCI vendor ID */ +#define I950_DEVICE_ID 0x9500 /* Initio's inic-950 product ID */ +#define I940_DEVICE_ID 0x9400 /* Initio's inic-940 product ID */ +#define I935_DEVICE_ID 0x9401 /* Initio's inic-935 product ID */ + +//#if defined(__KERNEL__) #define _I91USCSI_H +#if 0 +#include "ini9100u.h" +#endif typedef struct { - unsigned short base; - unsigned short vec; -} i91u_config; + unsigned short base; + unsigned short vec; +} i91u_config ; /***************************************/ /* Tulip Configuration Register Set */ /***************************************/ -#define TUL_PVID 0x00 /* Vendor ID */ -#define TUL_PDID 0x02 /* Device ID */ -#define TUL_PCMD 0x04 /* Command */ -#define TUL_PSTUS 0x06 /* Status */ -#define TUL_PRID 0x08 /* Revision number */ -#define TUL_PPI 0x09 /* Programming interface */ -#define TUL_PSC 0x0A /* Sub Class */ -#define TUL_PBC 0x0B /* Base Class */ -#define TUL_PCLS 0x0C /* Cache line size */ -#define TUL_PLTR 0x0D /* Latency timer */ -#define TUL_PHDT 0x0E /* Header type */ -#define TUL_PBIST 0x0F /* BIST */ -#define TUL_PBAD 0x10 /* Base address */ -#define TUL_PBAD1 0x14 /* Base address */ -#define TUL_PBAD2 0x18 /* Base address */ -#define TUL_PBAD3 0x1C /* Base address */ -#define TUL_PBAD4 0x20 /* Base address */ -#define TUL_PBAD5 0x24 /* Base address */ -#define TUL_PRSVD 0x28 /* Reserved */ -#define TUL_PRSVD1 0x2C /* Reserved */ -#define TUL_PRAD 0x30 /* Expansion ROM base address */ -#define TUL_PRSVD2 0x34 /* Reserved */ -#define TUL_PRSVD3 0x38 /* Reserved */ -#define TUL_PINTL 0x3C /* Interrupt line */ -#define TUL_PINTP 0x3D /* Interrupt pin */ -#define TUL_PIGNT 0x3E /* MIN_GNT */ -#define TUL_PMGNT 0x3F /* MAX_GNT */ +#define TUL_PVID 0x00 /* Vendor ID */ +#define TUL_PDID 0x02 /* Device ID */ +#define TUL_PCMD 0x04 /* Command */ +#define TUL_PSTUS 0x06 /* Status */ +#define TUL_PRID 0x08 /* Revision number */ +#define TUL_PPI 0x09 /* Programming interface */ +#define TUL_PSC 0x0A /* Sub Class */ +#define TUL_PBC 0x0B /* Base Class */ +#define TUL_PCLS 0x0C /* Cache line size */ +#define TUL_PLTR 0x0D /* Latency timer */ +#define TUL_PHDT 0x0E /* Header type */ +#define TUL_PBIST 0x0F /* BIST */ +#define TUL_PBAD 0x10 /* Base address */ +#define TUL_PBAD1 0x14 /* Base address */ +#define TUL_PBAD2 0x18 /* Base address */ +#define TUL_PBAD3 0x1C /* Base address */ +#define TUL_PBAD4 0x20 /* Base address */ +#define TUL_PBAD5 0x24 /* Base address */ +#define TUL_PRSVD 0x28 /* Reserved */ +#define TUL_PRSVD1 0x2C /* Reserved */ +#define TUL_PRAD 0x30 /* Expansion ROM base address */ +#define TUL_PRSVD2 0x34 /* Reserved */ +#define TUL_PRSVD3 0x38 /* Reserved */ +#define TUL_PINTL 0x3C /* Interrupt line */ +#define TUL_PINTP 0x3D /* Interrupt pin */ +#define TUL_PIGNT 0x3E /* MIN_GNT */ +#define TUL_PMGNT 0x3F /* MAX_GNT */ /************************/ /* Jasmin Register Set */ /************************/ -#define TUL_HACFG0 0x40 /* H/A Configuration Register 0 */ -#define TUL_HACFG1 0x41 /* H/A Configuration Register 1 */ -#define TUL_HACFG2 0x42 /* H/A Configuration Register 2 */ - -#define TUL_SDCFG0 0x44 /* SCSI Device Configuration 0 */ -#define TUL_SDCFG1 0x45 /* SCSI Device Configuration 1 */ -#define TUL_SDCFG2 0x46 /* SCSI Device Configuration 2 */ -#define TUL_SDCFG3 0x47 /* SCSI Device Configuration 3 */ - -#define TUL_GINTS 0x50 /* Global Interrupt Status Register */ -#define TUL_GIMSK 0x52 /* Global Interrupt MASK Register */ -#define TUL_GCTRL 0x54 /* Global Control Register */ -#define TUL_GCTRL_EEPROM_BIT 0x04 -#define TUL_GCTRL1 0x55 /* Global Control Register */ -#define TUL_DMACFG 0x5B /* DMA configuration */ -#define TUL_NVRAM 0x5D /* Non-volatile RAM port */ - -#define TUL_SCnt0 0x80 /* 00 R/W Transfer Counter Low */ -#define TUL_SCnt1 0x81 /* 01 R/W Transfer Counter Mid */ -#define TUL_SCnt2 0x82 /* 02 R/W Transfer Count High */ -#define TUL_SFifoCnt 0x83 /* 03 R FIFO counter */ -#define TUL_SIntEnable 0x84 /* 03 W Interrupt enble */ -#define TUL_SInt 0x84 /* 04 R Interrupt Register */ -#define TUL_SCtrl0 0x85 /* 05 W Control 0 */ -#define TUL_SStatus0 0x85 /* 05 R Status 0 */ -#define TUL_SCtrl1 0x86 /* 06 W Control 1 */ -#define TUL_SStatus1 0x86 /* 06 R Status 1 */ -#define TUL_SConfig 0x87 /* 07 W Configuration */ -#define TUL_SStatus2 0x87 /* 07 R Status 2 */ -#define TUL_SPeriod 0x88 /* 08 W Sync. Transfer Period & Offset */ -#define TUL_SOffset 0x88 /* 08 R Offset */ -#define TUL_SScsiId 0x89 /* 09 W SCSI ID */ -#define TUL_SBusId 0x89 /* 09 R SCSI BUS ID */ -#define TUL_STimeOut 0x8A /* 0A W Sel/Resel Time Out Register */ -#define TUL_SIdent 0x8A /* 0A R Identify Message Register */ -#define TUL_SAvail 0x8A /* 0A R Availiable Counter Register */ -#define TUL_SData 0x8B /* 0B R/W SCSI data in/out */ -#define TUL_SFifo 0x8C /* 0C R/W FIFO */ -#define TUL_SSignal 0x90 /* 10 R/W SCSI signal in/out */ -#define TUL_SCmd 0x91 /* 11 R/W Command */ -#define TUL_STest0 0x92 /* 12 R/W Test0 */ -#define TUL_STest1 0x93 /* 13 R/W Test1 */ -#define TUL_SCFG1 0x94 /* 14 R/W Configuration */ - -#define TUL_XAddH 0xC0 /*DMA Transfer Physical Address */ -#define TUL_XAddW 0xC8 /*DMA Current Transfer Physical Address */ -#define TUL_XCntH 0xD0 /*DMA Transfer Counter */ -#define TUL_XCntW 0xD4 /*DMA Current Transfer Counter */ -#define TUL_XCmd 0xD8 /*DMA Command Register */ -#define TUL_Int 0xDC /*Interrupt Register */ -#define TUL_XStatus 0xDD /*DMA status Register */ -#define TUL_Mask 0xE0 /*Interrupt Mask Register */ -#define TUL_XCtrl 0xE4 /*DMA Control Register */ -#define TUL_XCtrl1 0xE5 /*DMA Control Register 1 */ -#define TUL_XFifo 0xE8 /*DMA FIFO */ - -#define TUL_WCtrl 0xF7 /*Bus master wait state control */ -#define TUL_DCtrl 0xFB /*DMA delay control */ +#define TUL_HACFG0 0x40 /* H/A Configuration Register 0 */ +#define TUL_HACFG1 0x41 /* H/A Configuration Register 1 */ +#define TUL_HACFG2 0x42 /* H/A Configuration Register 2 */ + +#define TUL_SDCFG0 0x44 /* SCSI Device Configuration 0 */ +#define TUL_SDCFG1 0x45 /* SCSI Device Configuration 1 */ +#define TUL_SDCFG2 0x46 /* SCSI Device Configuration 2 */ +#define TUL_SDCFG3 0x47 /* SCSI Device Configuration 3 */ + +#define TUL_GINTS 0x50 /* Global Interrupt Status Register */ +#define TUL_GIMSK 0x52 /* Global Interrupt MASK Register */ +#define TUL_GCTRL 0x54 /* Global Control Register */ + #define TUL_GCTRL_EEPROM_BIT 0x04 +#define TUL_GCTRL1 0x55 /* Global Control Register */ +#define TUL_DMACFG 0x5B /* DMA configuration */ +#define TUL_NVRAM 0x5D /* Non-volatile RAM port */ + +#define TUL_SCnt0 0x80 /* 00 R/W Transfer Counter Low */ +#define TUL_SCnt1 0x81 /* 01 R/W Transfer Counter Mid */ +#define TUL_SCnt2 0x82 /* 02 R/W Transfer Count High */ +#define TUL_SFifoCnt 0x83 /* 03 R FIFO counter */ +#define TUL_SIntEnable 0x84 /* 03 W Interrupt enble */ +#define TUL_SInt 0x84 /* 04 R Interrupt Register */ +#define TUL_SCtrl0 0x85 /* 05 W Control 0 */ +#define TUL_SStatus0 0x85 /* 05 R Status 0 */ +#define TUL_SCtrl1 0x86 /* 06 W Control 1 */ +#define TUL_SStatus1 0x86 /* 06 R Status 1 */ +#define TUL_SConfig 0x87 /* 07 W Configuration */ +#define TUL_SStatus2 0x87 /* 07 R Status 2 */ +#define TUL_SPeriod 0x88 /* 08 W Sync. Transfer Period & Offset*/ +#define TUL_SOffset 0x88 /* 08 R Offset */ +#define TUL_SScsiId 0x89 /* 09 W SCSI ID */ +#define TUL_SBusId 0x89 /* 09 R SCSI BUS ID */ +#define TUL_STimeOut 0x8A /* 0A W Sel/Resel Time Out Register */ +#define TUL_SIdent 0x8A /* 0A R Identify Message Register */ +#define TUL_SAvail 0x8A /* 0A R Availiable Counter Register */ +#define TUL_SData 0x8B /* 0B R/W SCSI data in/out */ +#define TUL_SFifo 0x8C /* 0C R/W FIFO */ +#define TUL_SSignal 0x90 /* 10 R/W SCSI signal in/out */ +#define TUL_SCmd 0x91 /* 11 R/W Command */ +#define TUL_STest0 0x92 /* 12 R/W Test0 */ +#define TUL_STest1 0x93 /* 13 R/W Test1 */ +#define TUL_SCFG1 0x94 /* 14 R/W Configuration */ + +#define TUL_XAddH 0xC0 /*DMA Transfer Physical Address */ +#define TUL_XAddW 0xC8 /*DMA Current Transfer Physical Address */ +#define TUL_XCntH 0xD0 /*DMA Transfer Counter */ +#define TUL_XCntW 0xD4 /*DMA Current Transfer Counter */ +#define TUL_XCmd 0xD8 /*DMA Command Register */ +#define TUL_Int 0xDC /*Interrupt Register */ +#define TUL_XStatus 0xDD /*DMA status Register */ +#define TUL_Mask 0xE0 /*Interrupt Mask Register */ +#define TUL_XCtrl 0xE4 /*DMA Control Register */ +#define TUL_XCtrl1 0xE5 /*DMA Control Register 1 */ +#define TUL_XFifo 0xE8 /*DMA FIFO */ + +#define TUL_WCtrl 0xF7 /*Bus master wait state control */ +#define TUL_DCtrl 0xFB /*DMA delay control */ /*----------------------------------------------------------------------*/ /* bit definition for Command register of Configuration Space Header */ /*----------------------------------------------------------------------*/ -#define BUSMS 0x04 /* BUS MASTER Enable */ -#define IOSPA 0x01 /* IO Space Enable */ +#define BUSMS 0x04 /* BUS MASTER Enable */ +#define IOSPA 0x01 /* IO Space Enable */ /*----------------------------------------------------------------------*/ /* Command Codes of Tulip SCSI Command register */ /*----------------------------------------------------------------------*/ -#define TSC_EN_RESEL 0x80 /* Enable Reselection */ -#define TSC_CMD_COMP 0x84 /* Command Complete Sequence */ -#define TSC_SEL 0x01 /* Select Without ATN Sequence */ -#define TSC_SEL_ATN 0x11 /* Select With ATN Sequence */ -#define TSC_SEL_ATN_DMA 0x51 /* Select With ATN Sequence with DMA */ -#define TSC_SEL_ATN3 0x31 /* Select With ATN3 Sequence */ -#define TSC_SEL_ATNSTOP 0x12 /* Select With ATN and Stop Sequence */ -#define TSC_SELATNSTOP 0x1E /* Select With ATN and Stop Sequence */ +#define TSC_EN_RESEL 0x80 /* Enable Reselection */ +#define TSC_CMD_COMP 0x84 /* Command Complete Sequence */ +#define TSC_SEL 0x01 /* Select Without ATN Sequence */ +#define TSC_SEL_ATN 0x11 /* Select With ATN Sequence */ +#define TSC_SEL_ATN_DMA 0x51 /* Select With ATN Sequence with DMA */ +#define TSC_SEL_ATN3 0x31 /* Select With ATN3 Sequence */ +#define TSC_SEL_ATNSTOP 0x12 /* Select With ATN and Stop Sequence */ +#define TSC_SELATNSTOP 0x1E /* Select With ATN and Stop Sequence */ -#define TSC_SEL_ATN_DIRECT_IN 0x95 /* Select With ATN Sequence */ -#define TSC_SEL_ATN_DIRECT_OUT 0x15 /* Select With ATN Sequence */ -#define TSC_SEL_ATN3_DIRECT_IN 0xB5 /* Select With ATN3 Sequence */ -#define TSC_SEL_ATN3_DIRECT_OUT 0x35 /* Select With ATN3 Sequence */ -#define TSC_XF_DMA_OUT_DIRECT 0x06 /* DMA Xfer Infomation out */ -#define TSC_XF_DMA_IN_DIRECT 0x86 /* DMA Xfer Infomation in */ +#define TSC_SEL_ATN_DIRECT_IN 0x95 /* Select With ATN Sequence */ +#define TSC_SEL_ATN_DIRECT_OUT 0x15 /* Select With ATN Sequence */ +#define TSC_SEL_ATN3_DIRECT_IN 0xB5 /* Select With ATN3 Sequence */ +#define TSC_SEL_ATN3_DIRECT_OUT 0x35 /* Select With ATN3 Sequence */ +#define TSC_XF_DMA_OUT_DIRECT 0x06 /* DMA Xfer Infomation out */ +#define TSC_XF_DMA_IN_DIRECT 0x86 /* DMA Xfer Infomation in */ -#define TSC_XF_DMA_OUT 0x43 /* DMA Xfer Infomation out */ -#define TSC_XF_DMA_IN 0xC3 /* DMA Xfer Infomation in */ -#define TSC_XF_FIFO_OUT 0x03 /* FIFO Xfer Infomation out */ -#define TSC_XF_FIFO_IN 0x83 /* FIFO Xfer Infomation in */ +#define TSC_XF_DMA_OUT 0x43 /* DMA Xfer Infomation out */ +#define TSC_XF_DMA_IN 0xC3 /* DMA Xfer Infomation in */ +#define TSC_XF_FIFO_OUT 0x03 /* FIFO Xfer Infomation out */ +#define TSC_XF_FIFO_IN 0x83 /* FIFO Xfer Infomation in */ -#define TSC_MSG_ACCEPT 0x0F /* Message Accept */ +#define TSC_MSG_ACCEPT 0x0F /* Message Accept */ /*----------------------------------------------------------------------*/ /* bit definition for Tulip SCSI Control 0 Register */ /*----------------------------------------------------------------------*/ -#define TSC_RST_SEQ 0x20 /* Reset sequence counter */ -#define TSC_FLUSH_FIFO 0x10 /* Flush FIFO */ -#define TSC_ABT_CMD 0x04 /* Abort command (sequence) */ -#define TSC_RST_CHIP 0x02 /* Reset SCSI Chip */ -#define TSC_RST_BUS 0x01 /* Reset SCSI Bus */ +#define TSC_RST_SEQ 0x20 /* Reset sequence counter */ +#define TSC_FLUSH_FIFO 0x10 /* Flush FIFO */ +#define TSC_ABT_CMD 0x04 /* Abort command (sequence) */ +#define TSC_RST_CHIP 0x02 /* Reset SCSI Chip */ +#define TSC_RST_BUS 0x01 /* Reset SCSI Bus */ /*----------------------------------------------------------------------*/ /* bit definition for Tulip SCSI Control 1 Register */ /*----------------------------------------------------------------------*/ -#define TSC_EN_SCAM 0x80 /* Enable SCAM */ -#define TSC_TIMER 0x40 /* Select timeout unit */ -#define TSC_EN_SCSI2 0x20 /* SCSI-2 mode */ -#define TSC_PWDN 0x10 /* Power down mode */ -#define TSC_WIDE_CPU 0x08 /* Wide CPU */ -#define TSC_HW_RESELECT 0x04 /* Enable HW reselect */ -#define TSC_EN_BUS_OUT 0x02 /* Enable SCSI data bus out latch */ -#define TSC_EN_BUS_IN 0x01 /* Enable SCSI data bus in latch */ +#define TSC_EN_SCAM 0x80 /* Enable SCAM */ +#define TSC_TIMER 0x40 /* Select timeout unit */ +#define TSC_EN_SCSI2 0x20 /* SCSI-2 mode */ +#define TSC_PWDN 0x10 /* Power down mode */ +#define TSC_WIDE_CPU 0x08 /* Wide CPU */ +#define TSC_HW_RESELECT 0x04 /* Enable HW reselect */ +#define TSC_EN_BUS_OUT 0x02 /* Enable SCSI data bus out latch */ +#define TSC_EN_BUS_IN 0x01 /* Enable SCSI data bus in latch */ /*----------------------------------------------------------------------*/ /* bit definition for Tulip SCSI Configuration Register */ /*----------------------------------------------------------------------*/ -#define TSC_EN_LATCH 0x80 /* Enable phase latch */ -#define TSC_INITIATOR 0x40 /* Initiator mode */ -#define TSC_EN_SCSI_PAR 0x20 /* Enable SCSI parity */ -#define TSC_DMA_8BIT 0x10 /* Alternate dma 8-bits mode */ -#define TSC_DMA_16BIT 0x08 /* Alternate dma 16-bits mode */ -#define TSC_EN_WDACK 0x04 /* Enable DACK while wide SCSI xfer */ -#define TSC_ALT_PERIOD 0x02 /* Alternate sync period mode */ -#define TSC_DIS_SCSIRST 0x01 /* Disable SCSI bus reset us */ +#define TSC_EN_LATCH 0x80 /* Enable phase latch */ +#define TSC_INITIATOR 0x40 /* Initiator mode */ +#define TSC_EN_SCSI_PAR 0x20 /* Enable SCSI parity */ +#define TSC_DMA_8BIT 0x10 /* Alternate dma 8-bits mode */ +#define TSC_DMA_16BIT 0x08 /* Alternate dma 16-bits mode */ +#define TSC_EN_WDACK 0x04 /* Enable DACK while wide SCSI xfer */ +#define TSC_ALT_PERIOD 0x02 /* Alternate sync period mode */ +#define TSC_DIS_SCSIRST 0x01 /* Disable SCSI bus reset us */ #define TSC_INITDEFAULT (TSC_INITIATOR | TSC_EN_LATCH | TSC_ALT_PERIOD | TSC_DIS_SCSIRST) -#define TSC_WIDE_SCSI 0x80 /* Enable Wide SCSI */ +#define TSC_WIDE_SCSI 0x80 /* Enable Wide SCSI */ /*----------------------------------------------------------------------*/ /* bit definition for Tulip SCSI signal Register */ /*----------------------------------------------------------------------*/ -#define TSC_RST_ACK 0x00 /* Release ACK signal */ -#define TSC_RST_ATN 0x00 /* Release ATN signal */ -#define TSC_RST_BSY 0x00 /* Release BSY signal */ +#define TSC_RST_ACK 0x00 /* Release ACK signal */ +#define TSC_RST_ATN 0x00 /* Release ATN signal */ +#define TSC_RST_BSY 0x00 /* Release BSY signal */ + +#define TSC_SET_ACK 0x40 /* ACK signal */ +#define TSC_SET_ATN 0x08 /* ATN signal */ -#define TSC_SET_ACK 0x40 /* ACK signal */ -#define TSC_SET_ATN 0x08 /* ATN signal */ - -#define TSC_REQI 0x80 /* REQ signal */ -#define TSC_ACKI 0x40 /* ACK signal */ -#define TSC_BSYI 0x20 /* BSY signal */ -#define TSC_SELI 0x10 /* SEL signal */ -#define TSC_ATNI 0x08 /* ATN signal */ -#define TSC_MSGI 0x04 /* MSG signal */ -#define TSC_CDI 0x02 /* C/D signal */ -#define TSC_IOI 0x01 /* I/O signal */ +#define TSC_REQI 0x80 /* REQ signal */ +#define TSC_ACKI 0x40 /* ACK signal */ +#define TSC_BSYI 0x20 /* BSY signal */ +#define TSC_SELI 0x10 /* SEL signal */ +#define TSC_ATNI 0x08 /* ATN signal */ +#define TSC_MSGI 0x04 /* MSG signal */ +#define TSC_CDI 0x02 /* C/D signal */ +#define TSC_IOI 0x01 /* I/O signal */ /*----------------------------------------------------------------------*/ /* bit definition for Tulip SCSI Status 0 Register */ /*----------------------------------------------------------------------*/ -#define TSS_INT_PENDING 0x80 /* Interrupt pending */ -#define TSS_SEQ_ACTIVE 0x40 /* Sequencer active */ -#define TSS_XFER_CNT 0x20 /* Transfer counter zero */ -#define TSS_FIFO_EMPTY 0x10 /* FIFO empty */ -#define TSS_PAR_ERROR 0x08 /* SCSI parity error */ -#define TSS_PH_MASK 0x07 /* SCSI phase mask */ +#define TSS_INT_PENDING 0x80 /* Interrupt pending */ +#define TSS_SEQ_ACTIVE 0x40 /* Sequencer active */ +#define TSS_XFER_CNT 0x20 /* Transfer counter zero */ +#define TSS_FIFO_EMPTY 0x10 /* FIFO empty */ +#define TSS_PAR_ERROR 0x08 /* SCSI parity error */ +#define TSS_PH_MASK 0x07 /* SCSI phase mask */ /*----------------------------------------------------------------------*/ /* bit definition for Tulip SCSI Status 1 Register */ /*----------------------------------------------------------------------*/ -#define TSS_STATUS_RCV 0x08 /* Status received */ -#define TSS_MSG_SEND 0x40 /* Message sent */ -#define TSS_CMD_PH_CMP 0x20 /* command phase done */ -#define TSS_DATA_PH_CMP 0x10 /* Data phase done */ -#define TSS_STATUS_SEND 0x08 /* Status sent */ -#define TSS_XFER_CMP 0x04 /* Transfer completed */ -#define TSS_SEL_CMP 0x02 /* Selection completed */ -#define TSS_ARB_CMP 0x01 /* Arbitration completed */ +#define TSS_STATUS_RCV 0x08 /* Status received */ +#define TSS_MSG_SEND 0x40 /* Message sent */ +#define TSS_CMD_PH_CMP 0x20 /* command phase done */ +#define TSS_DATA_PH_CMP 0x10 /* Data phase done */ +#define TSS_STATUS_SEND 0x08 /* Status sent */ +#define TSS_XFER_CMP 0x04 /* Transfer completed */ +#define TSS_SEL_CMP 0x02 /* Selection completed */ +#define TSS_ARB_CMP 0x01 /* Arbitration completed */ /*----------------------------------------------------------------------*/ /* bit definition for Tulip SCSI Status 2 Register */ /*----------------------------------------------------------------------*/ -#define TSS_CMD_ABTED 0x80 /* Command aborted */ -#define TSS_OFFSET_0 0x40 /* Offset counter zero */ -#define TSS_FIFO_FULL 0x20 /* FIFO full */ -#define TSS_TIMEOUT_0 0x10 /* Timeout counter zero */ -#define TSS_BUSY_RLS 0x08 /* Busy release */ -#define TSS_PH_MISMATCH 0x04 /* Phase mismatch */ -#define TSS_SCSI_BUS_EN 0x02 /* SCSI data bus enable */ -#define TSS_SCSIRST 0x01 /* SCSI bus reset in progress */ +#define TSS_CMD_ABTED 0x80 /* Command aborted */ +#define TSS_OFFSET_0 0x40 /* Offset counter zero */ +#define TSS_FIFO_FULL 0x20 /* FIFO full */ +#define TSS_TIMEOUT_0 0x10 /* Timeout counter zero */ +#define TSS_BUSY_RLS 0x08 /* Busy release */ +#define TSS_PH_MISMATCH 0x04 /* Phase mismatch */ +#define TSS_SCSI_BUS_EN 0x02 /* SCSI data bus enable */ +#define TSS_SCSIRST 0x01 /* SCSI bus reset in progress */ /*----------------------------------------------------------------------*/ /* bit definition for Tulip SCSI Interrupt Register */ /*----------------------------------------------------------------------*/ -#define TSS_RESEL_INT 0x80 /* Reselected interrupt */ -#define TSS_SEL_TIMEOUT 0x40 /* Selected/reselected timeout */ +#define TSS_RESEL_INT 0x80 /* Reselected interrupt */ +#define TSS_SEL_TIMEOUT 0x40 /* Selected/reselected timeout */ #define TSS_BUS_SERV 0x20 -#define TSS_SCSIRST_INT 0x10 /* SCSI bus reset detected */ -#define TSS_DISC_INT 0x08 /* Disconnected interrupt */ -#define TSS_SEL_INT 0x04 /* Select interrupt */ -#define TSS_SCAM_SEL 0x02 /* SCAM selected */ +#define TSS_SCSIRST_INT 0x10 /* SCSI bus reset detected */ +#define TSS_DISC_INT 0x08 /* Disconnected interrupt */ +#define TSS_SEL_INT 0x04 /* Select interrupt */ +#define TSS_SCAM_SEL 0x02 /* SCAM selected */ #define TSS_FUNC_COMP 0x01 /*----------------------------------------------------------------------*/ /* SCSI Phase Codes. */ /*----------------------------------------------------------------------*/ #define DATA_OUT 0 -#define DATA_IN 1 /* 4 */ +#define DATA_IN 1 /* 4 */ #define CMD_OUT 2 -#define STATUS_IN 3 /* 6 */ -#define MSG_OUT 6 /* 3 */ +#define STATUS_IN 3 /* 6 */ +#define MSG_OUT 6 /* 3 */ #define MSG_IN 7 @@ -365,8 +370,8 @@ typedef struct { /*----------------------------------------------------------------------*/ /* Tulip DMA Status Register */ /*----------------------------------------------------------------------*/ -#define XPEND 0x01 /* Transfer pending */ -#define FEMPTY 0x02 /* FIFO empty */ +#define XPEND 0x01 /* Transfer pending */ +#define FEMPTY 0x02 /* FIFO empty */ @@ -391,58 +396,59 @@ typedef struct { /************************************************************************/ /* Scatter-Gather Element Structure */ /************************************************************************/ -typedef struct SG_Struc { - U32 SG_Ptr; /* Data Pointer */ - U32 SG_Len; /* Data Length */ +typedef struct SG_Struc { + U32 SG_Ptr; /* Data Pointer */ + U32 SG_Len; /* Data Length */ } SG; /*********************************************************************** SCSI Control Block ************************************************************************/ -typedef struct Scsi_Ctrl_Blk { - struct Scsi_Ctrl_Blk *SCB_NxtScb; - UBYTE SCB_Status; /*4 */ - UBYTE SCB_NxtStat; /*5 */ - UBYTE SCB_Mode; /*6 */ - UBYTE SCB_Msgin; /*7 SCB_Res0 */ - UWORD SCB_SGIdx; /*8 */ - UWORD SCB_SGMax; /*A */ +typedef struct Scsi_Ctrl_Blk { + struct Scsi_Ctrl_Blk *SCB_NxtScb; + UBYTE SCB_Status; /*4 */ + UBYTE SCB_NxtStat; /*5 */ + UBYTE SCB_Mode; /*6 */ + UBYTE SCB_Msgin; /*7 SCB_Res0 */ + UWORD SCB_SGIdx; /*8 */ + UWORD SCB_SGMax; /*A */ #ifdef ALPHA - U32 SCB_Reserved[2]; /*C */ + U32 SCB_Reserved[2];/*C */ #else - U32 SCB_Reserved[3]; /*C */ + U32 SCB_Reserved[3];/*C */ #endif - U32 SCB_XferLen; /*18 Current xfer len */ - U32 SCB_TotXLen; /*1C Total xfer len */ - U32 SCB_PAddr; /*20 SCB phy. Addr. */ - - UBYTE SCB_Opcode; /*24 SCB command code */ - UBYTE SCB_Flags; /*25 SCB Flags */ - UBYTE SCB_Target; /*26 Target Id */ - UBYTE SCB_Lun; /*27 Lun */ - U32 SCB_BufPtr; /*28 Data Buffer Pointer */ - U32 SCB_BufLen; /*2C Data Allocation Length */ - UBYTE SCB_SGLen; /*30 SG list # */ - UBYTE SCB_SenseLen; /*31 Sense Allocation Length */ - UBYTE SCB_HaStat; /*32 */ - UBYTE SCB_TaStat; /*33 */ - UBYTE SCB_CDBLen; /*34 CDB Length */ - UBYTE SCB_Ident; /*35 Identify */ - UBYTE SCB_TagMsg; /*36 Tag Message */ - UBYTE SCB_TagId; /*37 Queue Tag */ - UBYTE SCB_CDB[12]; /*38 */ - U32 SCB_SGPAddr; /*44 SG List/Sense Buf phy. Addr. */ - U32 SCB_SensePtr; /*48 Sense data pointer */ - void (*SCB_Post) (BYTE *, BYTE *); /*4C POST routine */ - unsigned char *SCB_Srb; /*50 SRB Pointer */ - SG SCB_SGList[TOTAL_SG_ENTRY]; /*54 Start of SG list */ + U32 SCB_XferLen; /*18 Current xfer len */ + U32 SCB_TotXLen; /*1C Total xfer len */ + U32 SCB_PAddr; /*20 SCB phy. Addr. */ + + UBYTE SCB_Opcode; /*24 SCB command code */ + UBYTE SCB_Flags; /*25 SCB Flags */ + UBYTE SCB_Target; /*26 Target Id */ + UBYTE SCB_Lun; /*27 Lun */ + U32 SCB_BufPtr; /*28 Data Buffer Pointer */ + U32 SCB_BufLen; /*2C Data Allocation Length */ + UBYTE SCB_SGLen; /*30 SG list # */ + UBYTE SCB_SenseLen; /*31 Sense Allocation Length */ + UBYTE SCB_HaStat; /*32 */ + UBYTE SCB_TaStat; /*33 */ + UBYTE SCB_CDBLen; /*34 CDB Length */ + UBYTE SCB_Ident; /*35 Identify */ + UBYTE SCB_TagMsg; /*36 Tag Message */ + UBYTE SCB_TagId; /*37 Queue Tag */ + UBYTE SCB_CDB[12]; /*38 */ + U32 SCB_SGPAddr; /*44 SG List/Sense Buf phy. Addr. */ + U32 SCB_SensePtr; /*48 Sense data pointer */ + void (* SCB_Post)(BYTE *, BYTE *); /*4C POST routine */ + unsigned char *SCB_Srb; /*50 SRB Pointer */ +// Scsi_Cmnd *SCB_Srb; /*2C SRB Pointer */ + SG SCB_SGList[TOTAL_SG_ENTRY]; /*54 Start of SG list */ } SCB; /* Bit Definition for SCB_Status */ #define SCB_RENT 0x01 #define SCB_PEND 0x02 -#define SCB_CONTIG 0x04 /* Contigent Allegiance */ +#define SCB_CONTIG 0x04 /* Contigent Allegiance */ #define SCB_SELECT 0x08 #define SCB_BUSY 0x10 #define SCB_DONE 0x20 @@ -455,7 +461,7 @@ typedef struct Scsi_Ctrl_Blk { /* Bit Definition for SCB_Mode */ -#define SCM_RSENS 0x01 /* request sense mode */ +#define SCM_RSENS 0x01 /* request sense mode */ /* Bit Definition for SCB_Flags */ @@ -467,7 +473,7 @@ typedef struct Scsi_Ctrl_Blk { #define SCF_DIN 0x08 #define SCF_DOUT 0x10 #define SCF_NO_XF 0x18 -#define SCF_WR_VF 0x20 /* Write verify turn on */ +#define SCF_WR_VF 0x20 /* Write verify turn on */ #define SCF_POLL 0x40 #define SCF_SG 0x80 @@ -477,7 +483,7 @@ typedef struct Scsi_Ctrl_Blk { #define HOST_BUS_FREE 0x13 #define HOST_BAD_PHAS 0x14 #define HOST_INV_CMD 0x16 -#define HOST_ABORTED 0x1A /* 07/21/98 */ +#define HOST_ABORTED 0x1A /* 07/21/98 */ #define HOST_SCSI_RST 0x1B #define HOST_DEV_RST 0x1C @@ -516,13 +522,13 @@ typedef struct Scsi_Ctrl_Blk { **********************************************************************/ typedef struct Tar_Ctrl_Struc { - UWORD TCS_Flags; /* 0 */ - UBYTE TCS_JS_Period; /* 2 */ - UBYTE TCS_SConfig0; /* 3 */ + UWORD TCS_Flags; /* 0 */ + UBYTE TCS_JS_Period; /* 2 */ + UBYTE TCS_SConfig0; /* 3 */ - UWORD TCS_DrvFlags; /* 4 */ - UBYTE TCS_DrvHead; /* 6 */ - UBYTE TCS_DrvSector; /* 7 */ + UWORD TCS_DrvFlags; /* 4 */ + UBYTE TCS_DrvHead; /* 6 */ + UBYTE TCS_DrvSector; /* 7 */ } TCS; /*********************************************************************** @@ -542,16 +548,16 @@ typedef struct Tar_Ctrl_Struc { /* Bit Definition for TCF_DrvFlags */ -#define TCF_DRV_BUSY 0x01 /* Indicate target busy(driver) */ +#define TCF_DRV_BUSY 0x01 /* Indicate target busy(driver) */ #define TCF_DRV_EN_TAG 0x0800 #define TCF_DRV_255_63 0x0400 typedef struct I91u_Adpt_Struc { - UWORD ADPT_BIOS; /* 0 */ - UWORD ADPT_BASE; /* 1 */ - UBYTE ADPT_Bus; /* 2 */ - UBYTE ADPT_Device; /* 3 */ - UBYTE ADPT_INTR; /* 4 */ + UWORD ADPT_BIOS; /* 0 */ + UWORD ADPT_BASE; /* 1 */ + UBYTE ADPT_Bus; /* 2 */ + UBYTE ADPT_Device; /* 3 */ + UBYTE ADPT_INTR; /* 4 */ } INI_ADPT_STRUCT; @@ -559,52 +565,57 @@ typedef struct I91u_Adpt_Struc { Host Adapter Control Structure ************************************************************************/ typedef struct Ha_Ctrl_Struc { - UWORD HCS_Base; /* 00 */ - UWORD HCS_BIOS; /* 02 */ - UBYTE HCS_Intr; /* 04 */ - UBYTE HCS_SCSI_ID; /* 05 */ - UBYTE HCS_MaxTar; /* 06 */ - UBYTE HCS_NumScbs; /* 07 */ - - UBYTE HCS_Flags; /* 08 */ - UBYTE HCS_Index; /* 09 */ - UBYTE HCS_HaId; /* 0A */ - UBYTE HCS_Config; /* 0B */ - UWORD HCS_IdMask; /* 0C */ - UBYTE HCS_Semaph; /* 0E */ - UBYTE HCS_Phase; /* 0F */ - UBYTE HCS_JSStatus0; /* 10 */ - UBYTE HCS_JSInt; /* 11 */ - UBYTE HCS_JSStatus1; /* 12 */ - UBYTE HCS_SConf1; /* 13 */ - - UBYTE HCS_Msg[8]; /* 14 */ - SCB *HCS_NxtAvail; /* 1C */ - SCB *HCS_Scb; /* 20 */ - SCB *HCS_ScbEnd; /* 24 */ - SCB *HCS_NxtPend; /* 28 */ - SCB *HCS_NxtContig; /* 2C */ - SCB *HCS_ActScb; /* 30 */ - TCS *HCS_ActTcs; /* 34 */ - - SCB *HCS_FirstAvail; /* 38 */ - SCB *HCS_LastAvail; /* 3C */ - SCB *HCS_FirstPend; /* 40 */ - SCB *HCS_LastPend; /* 44 */ - SCB *HCS_FirstBusy; /* 48 */ - SCB *HCS_LastBusy; /* 4C */ - SCB *HCS_FirstDone; /* 50 */ - SCB *HCS_LastDone; /* 54 */ - UBYTE HCS_MaxTags[16]; /* 58 */ - UBYTE HCS_ActTags[16]; /* 68 */ - TCS HCS_Tcs[MAX_TARGETS]; /* 78 */ - ULONG pSRB_head; /* SRB save queue header */ - ULONG pSRB_tail; /* SRB save queue tail */ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spinlock_t HCS_AvailLock; - spinlock_t HCS_SemaphLock; - spinlock_t pSRB_lock; /* SRB queue lock */ + UWORD HCS_Base; /* 00 */ + UWORD HCS_BIOS; /* 02 */ + UBYTE HCS_Intr; /* 04 */ + UBYTE HCS_SCSI_ID; /* 05 */ + UBYTE HCS_MaxTar; /* 06 */ + UBYTE HCS_NumScbs; /* 07 */ + + UBYTE HCS_Flags; /* 08 */ + UBYTE HCS_Index; /* 09 */ + UBYTE HCS_HaId; /* 0A */ + UBYTE HCS_Config; /* 0B */ + UWORD HCS_IdMask; /* 0C */ + UBYTE HCS_Semaph; /* 0E */ + UBYTE HCS_Phase; /* 0F */ + UBYTE HCS_JSStatus0; /* 10 */ + UBYTE HCS_JSInt; /* 11 */ + UBYTE HCS_JSStatus1; /* 12 */ + UBYTE HCS_SConf1; /* 13 */ + + UBYTE HCS_Msg[8]; /* 14 */ + SCB *HCS_NxtAvail; /* 1C */ + SCB *HCS_Scb; /* 20 */ + SCB *HCS_ScbEnd; /* 24 */ + SCB *HCS_NxtPend; /* 28 */ + SCB *HCS_NxtContig; /* 2C */ + SCB *HCS_ActScb; /* 30 */ + TCS *HCS_ActTcs; /* 34 */ + + SCB *HCS_FirstAvail;/* 38 */ + SCB *HCS_LastAvail; /* 3C */ + SCB *HCS_FirstPend; /* 40 */ + SCB *HCS_LastPend; /* 44 */ + SCB *HCS_FirstBusy; /* 48 */ + SCB *HCS_LastBusy; /* 4C */ + SCB *HCS_FirstDone; /* 50 */ + SCB *HCS_LastDone; /* 54 */ +#if 1 /* HILAM */ + UBYTE HCS_MaxTags[16];/* 58 */ + UBYTE HCS_ActTags[16];/* 68 */ + TCS HCS_Tcs[MAX_TARGETS]; /* 78 */ + ULONG pSRB_head; /* SRB save queue header */ + ULONG pSRB_tail; /* SRB save queue tail */ +#else + ULONG pSRB_head; /* 58 SRB save queue header */ + ULONG pSRB_tail; /* 5C SRB save queue tail */ + UBYTE HCS_MaxTags[16];/* 60 */ + UBYTE HCS_ActTags[16];/* 70 */ + TCS HCS_Tcs[MAX_TARGETS]; /* 78 */ #endif +// Scsi_Cmnd *pSRB_head; /* B4 SRB save queue header */ +// Scsi_Cmnd *pSRB_tail; /* B8 SRB save queue tail */ } HCS; /* Bit Definition for HCB_Config */ @@ -625,77 +636,77 @@ typedef struct Ha_Ctrl_Struc { Serial EEProm *******************************************************************/ -typedef struct _NVRAM_SCSI { /* SCSI channel configuration */ - UCHAR NVM_ChSCSIID; /* 0Ch -> Channel SCSI ID */ - UCHAR NVM_ChConfig1; /* 0Dh -> Channel config 1 */ - UCHAR NVM_ChConfig2; /* 0Eh -> Channel config 2 */ - UCHAR NVM_NumOfTarg; /* 0Fh -> Number of SCSI target */ - /* SCSI target configuration */ - UCHAR NVM_Targ0Config; /* 10h -> Target 0 configuration */ - UCHAR NVM_Targ1Config; /* 11h -> Target 1 configuration */ - UCHAR NVM_Targ2Config; /* 12h -> Target 2 configuration */ - UCHAR NVM_Targ3Config; /* 13h -> Target 3 configuration */ - UCHAR NVM_Targ4Config; /* 14h -> Target 4 configuration */ - UCHAR NVM_Targ5Config; /* 15h -> Target 5 configuration */ - UCHAR NVM_Targ6Config; /* 16h -> Target 6 configuration */ - UCHAR NVM_Targ7Config; /* 17h -> Target 7 configuration */ - UCHAR NVM_Targ8Config; /* 18h -> Target 8 configuration */ - UCHAR NVM_Targ9Config; /* 19h -> Target 9 configuration */ - UCHAR NVM_TargAConfig; /* 1Ah -> Target A configuration */ - UCHAR NVM_TargBConfig; /* 1Bh -> Target B configuration */ - UCHAR NVM_TargCConfig; /* 1Ch -> Target C configuration */ - UCHAR NVM_TargDConfig; /* 1Dh -> Target D configuration */ - UCHAR NVM_TargEConfig; /* 1Eh -> Target E configuration */ - UCHAR NVM_TargFConfig; /* 1Fh -> Target F configuration */ +typedef struct _NVRAM_SCSI { /* SCSI channel configuration */ + UCHAR NVM_ChSCSIID; /* 0Ch -> Channel SCSI ID */ + UCHAR NVM_ChConfig1; /* 0Dh -> Channel config 1 */ + UCHAR NVM_ChConfig2; /* 0Eh -> Channel config 2 */ + UCHAR NVM_NumOfTarg; /* 0Fh -> Number of SCSI target */ + /* SCSI target configuration */ + UCHAR NVM_Targ0Config; /* 10h -> Target 0 configuration*/ + UCHAR NVM_Targ1Config; /* 11h -> Target 1 configuration*/ + UCHAR NVM_Targ2Config; /* 12h -> Target 2 configuration*/ + UCHAR NVM_Targ3Config; /* 13h -> Target 3 configuration*/ + UCHAR NVM_Targ4Config; /* 14h -> Target 4 configuration*/ + UCHAR NVM_Targ5Config; /* 15h -> Target 5 configuration*/ + UCHAR NVM_Targ6Config; /* 16h -> Target 6 configuration*/ + UCHAR NVM_Targ7Config; /* 17h -> Target 7 configuration*/ + UCHAR NVM_Targ8Config; /* 18h -> Target 8 configuration*/ + UCHAR NVM_Targ9Config; /* 19h -> Target 9 configuration*/ + UCHAR NVM_TargAConfig; /* 1Ah -> Target A configuration*/ + UCHAR NVM_TargBConfig; /* 1Bh -> Target B configuration*/ + UCHAR NVM_TargCConfig; /* 1Ch -> Target C configuration*/ + UCHAR NVM_TargDConfig; /* 1Dh -> Target D configuration*/ + UCHAR NVM_TargEConfig; /* 1Eh -> Target E configuration*/ + UCHAR NVM_TargFConfig; /* 1Fh -> Target F configuration*/ } NVRAM_SCSI; typedef struct _NVRAM { -/*----------header ---------------*/ - USHORT NVM_Signature; /* 0,1: Signature */ - UCHAR NVM_Size; /* 2: Size of data structure */ - UCHAR NVM_Revision; /* 3: Revision of data structure */ - /* ----Host Adapter Structure ---- */ - UCHAR NVM_ModelByte0; /* 4: Model number (byte 0) */ - UCHAR NVM_ModelByte1; /* 5: Model number (byte 1) */ - UCHAR NVM_ModelInfo; /* 6: Model information */ - UCHAR NVM_NumOfCh; /* 7: Number of SCSI channel */ - UCHAR NVM_BIOSConfig1; /* 8: BIOS configuration 1 */ - UCHAR NVM_BIOSConfig2; /* 9: BIOS configuration 2 */ - UCHAR NVM_HAConfig1; /* A: Hoat adapter configuration 1 */ - UCHAR NVM_HAConfig2; /* B: Hoat adapter configuration 2 */ + /*----------header ---------------*/ + USHORT NVM_Signature; /* 0,1: Signature */ + UCHAR NVM_Size; /* 2: Size of data structure */ + UCHAR NVM_Revision; /* 3: Revision of data structure */ + /* ----Host Adapter Structure ----*/ + UCHAR NVM_ModelByte0; /* 4: Model number (byte 0) */ + UCHAR NVM_ModelByte1; /* 5: Model number (byte 1) */ + UCHAR NVM_ModelInfo; /* 6: Model information */ + UCHAR NVM_NumOfCh; /* 7: Number of SCSI channel*/ + UCHAR NVM_BIOSConfig1; /* 8: BIOS configuration 1 */ + UCHAR NVM_BIOSConfig2; /* 9: BIOS configuration 2 */ + UCHAR NVM_HAConfig1; /* A: Hoat adapter configuration 1 */ + UCHAR NVM_HAConfig2; /* B: Hoat adapter configuration 2 */ NVRAM_SCSI NVM_SCSIInfo[2]; - UCHAR NVM_reserved[10]; + UCHAR NVM_reserved[10]; /* ---------- CheckSum ---------- */ - USHORT NVM_CheckSum; /* 0x3E, 0x3F: Checksum of NVRam */ -} NVRAM, *PNVRAM; + USHORT NVM_CheckSum; /* 0x3E, 0x3F: Checksum of NVRam */ + } NVRAM, *PNVRAM; /* Bios Configuration for nvram->BIOSConfig1 */ -#define NBC1_ENABLE 0x01 /* BIOS enable */ -#define NBC1_8DRIVE 0x02 /* Support more than 2 drives */ -#define NBC1_REMOVABLE 0x04 /* Support removable drive */ -#define NBC1_INT19 0x08 /* Intercept int 19h */ -#define NBC1_BIOSSCAN 0x10 /* Dynamic BIOS scan */ -#define NBC1_LUNSUPPORT 0x40 /* Support LUN */ +#define NBC1_ENABLE 0x01 /* BIOS enable */ +#define NBC1_8DRIVE 0x02 /* Support more than 2 drives */ +#define NBC1_REMOVABLE 0x04 /* Support removable drive */ +#define NBC1_INT19 0x08 /* Intercept int 19h */ +#define NBC1_BIOSSCAN 0x10 /* Dynamic BIOS scan */ +#define NBC1_LUNSUPPORT 0x40 /* Support LUN */ /* HA Configuration Byte 1 */ -#define NHC1_BOOTIDMASK 0x0F /* Boot ID number */ -#define NHC1_LUNMASK 0x70 /* Boot LUN number */ -#define NHC1_CHANMASK 0x80 /* Boot Channel number */ +#define NHC1_BOOTIDMASK 0x0F /* Boot ID number */ +#define NHC1_LUNMASK 0x70 /* Boot LUN number */ +#define NHC1_CHANMASK 0x80 /* Boot Channel number */ /* Bit definition for nvram->SCSIconfig1 */ -#define NCC1_BUSRESET 0x01 /* Reset SCSI bus at power up */ -#define NCC1_PARITYCHK 0x02 /* SCSI parity enable */ -#define NCC1_ACTTERM1 0x04 /* Enable active terminator 1 */ -#define NCC1_ACTTERM2 0x08 /* Enable active terminator 2 */ -#define NCC1_AUTOTERM 0x10 /* Enable auto terminator */ -#define NCC1_PWRMGR 0x80 /* Enable power management */ +#define NCC1_BUSRESET 0x01 /* Reset SCSI bus at power up */ +#define NCC1_PARITYCHK 0x02 /* SCSI parity enable */ +#define NCC1_ACTTERM1 0x04 /* Enable active terminator 1 */ +#define NCC1_ACTTERM2 0x08 /* Enable active terminator 2 */ +#define NCC1_AUTOTERM 0x10 /* Enable auto terminator */ +#define NCC1_PWRMGR 0x80 /* Enable power management */ /* Bit definition for SCSI Target configuration byte */ -#define NTC_DISCONNECT 0x08 /* Enable SCSI disconnect */ -#define NTC_SYNC 0x10 /* SYNC_NEGO */ -#define NTC_NO_WDTR 0x20 /* SYNC_NEGO */ -#define NTC_1GIGA 0x40 /* 255 head / 63 sectors (64/32) */ -#define NTC_SPINUP 0x80 /* Start disk drive */ +#define NTC_DISCONNECT 0x08 /* Enable SCSI disconnect */ +#define NTC_SYNC 0x10 /* SYNC_NEGO */ +#define NTC_NO_WDTR 0x20 /* SYNC_NEGO */ +#define NTC_1GIGA 0x40 /* 255 head / 63 sectors (64/32)*/ +#define NTC_SPINUP 0x80 /* Start disk drive */ /* Default NVRam values */ #define INI_SIGNATURE 0xC925 @@ -704,8 +715,8 @@ typedef struct _NVRAM { #define NTC_DEFAULT (NTC_NO_WDTR | NTC_1GIGA | NTC_DISCONNECT) /* SCSI related definition */ -#define DISC_NOT_ALLOW 0x80 /* Disconnect is not allowed */ -#define DISC_ALLOW 0xC0 /* Disconnect is allowed */ +#define DISC_NOT_ALLOW 0x80 /* Disconnect is not allowed */ +#define DISC_ALLOW 0xC0 /* Disconnect is allowed */ #define SCSICMD_RequestSense 0x03 @@ -726,105 +737,126 @@ typedef struct _NVRAM { #define SUCCESSFUL 0x00 #define FUNC_NOT_SUPPORTED 0x81 -#define BAD_VENDOR_ID 0x83 /* Bad vendor ID */ -#define DEVICE_NOT_FOUND 0x86 /* PCI device not found */ +#define BAD_VENDOR_ID 0x83 /* Bad vendor ID */ +#define DEVICE_NOT_FOUND 0x86 /* PCI device not found */ #define BAD_REGISTER_NUMBER 0x87 -#define MAX_PCI_DEVICES 21 /* Maximum devices supportted */ +#define MAX_PCI_DEVICES 21 /* Maximum devices supportted */ #define MAX_PCI_CHANL 4 typedef struct _BIOS32_ENTRY_STRUCTURE { - DWORD Signatures; /* Should be "_32_" */ - DWORD BIOS32Entry; /* 32-bit physical address */ - BYTE Revision; /* Revision level, should be 0 */ - BYTE Length; /* Multiply of 16, should be 1 */ - BYTE CheckSum; /* Checksum of whole structure */ - BYTE Reserved[5]; /* Reserved */ + DWORD Signatures; /* Should be "_32_" */ + DWORD BIOS32Entry; /* 32-bit physical address */ + BYTE Revision; /* Revision level, should be 0 */ + BYTE Length; /* Multiply of 16, should be 1 */ + BYTE CheckSum; /* Checksum of whole structure */ + BYTE Reserved[5]; /* Reserved */ } BIOS32_ENTRY_STRUCTURE, *PBIOS32_ENTRY_STRUCTURE; -typedef struct { - union { - unsigned int eax; - struct { - unsigned short ax; - } word; - struct { - unsigned char al; - unsigned char ah; - } byte; - } eax; - union { - unsigned int ebx; - struct { - unsigned short bx; - } word; - struct { - unsigned char bl; - unsigned char bh; - } byte; - } ebx; - union { - unsigned int ecx; - struct { - unsigned short cx; - } word; - struct { - unsigned char cl; - unsigned char ch; - } byte; - } ecx; - union { - unsigned int edx; - struct { - unsigned short dx; - } word; - struct { - unsigned char dl; - unsigned char dh; - } byte; - } edx; - union { - unsigned int edi; - struct { - unsigned short di; - } word; - } edi; - union { - unsigned int esi; - struct { - unsigned short si; - } word; - } esi; -} REGS; - -typedef union { /* Union define for mechanism 1 */ - struct { - unsigned char RegNum; - unsigned char FcnNum:3; - unsigned char DeviceNum:5; - unsigned char BusNum; - unsigned char Reserved:7; - unsigned char Enable:1; - } sConfigAdr; - unsigned long lConfigAdr; -} CONFIG_ADR; - -typedef union { /* Union define for mechanism 2 */ - struct { - unsigned char RegNum; - unsigned char DeviceNum; - unsigned short Reserved; - } sHostAdr; - unsigned long lHostAdr; -} HOST_ADR; +typedef struct + { + union + { + unsigned int eax; + struct + { + unsigned short ax; + } word; + struct + { + unsigned char al; + unsigned char ah; + } byte; + } eax; + union + { + unsigned int ebx; + struct + { + unsigned short bx; + } word; + struct + { + unsigned char bl; + unsigned char bh; + } byte; + } ebx; + union + { + unsigned int ecx; + struct + { + unsigned short cx; + } word; + struct + { + unsigned char cl; + unsigned char ch; + } byte; + } ecx; + union + { + unsigned int edx; + struct + { + unsigned short dx; + } word; + struct + { + unsigned char dl; + unsigned char dh; + } byte; + } edx; + union + { + unsigned int edi; + struct + { + unsigned short di; + } word; + } edi; + union + { + unsigned int esi; + struct + { + unsigned short si; + } word; + } esi; + } REGS; + +typedef union /* Union define for mechanism 1 */ + { + struct + { + unsigned char RegNum; + unsigned char FcnNum:3; + unsigned char DeviceNum:5; + unsigned char BusNum; + unsigned char Reserved:7; + unsigned char Enable:1; + } sConfigAdr; + unsigned long lConfigAdr; + } CONFIG_ADR; + +typedef union /* Union define for mechanism 2 */ + { + struct + { + unsigned char RegNum; + unsigned char DeviceNum; + unsigned short Reserved; + } sHostAdr; + unsigned long lHostAdr; + } HOST_ADR; typedef struct _HCSinfo { - ULONG base; - UCHAR vec; - UCHAR bios; /* High byte of BIOS address */ - USHORT BaseAndBios; /* high byte: pHcsInfo->bios,low byte:pHcsInfo->base */ -} HCSINFO; + ULONG base; + UCHAR vec; + UCHAR bios; /* High byte of BIOS address */ + USHORT BaseAndBios; /* high byte: pHcsInfo->bios,low byte:pHcsInfo->base */ + } HCSINFO ; #define TUL_RD(x,y) (UCHAR)(inb( (int)((ULONG)(x+y)) )) #define TUL_RDLONG(x,y) (ULONG)(inl((int)((ULONG)(x+y)) )) @@ -855,3 +887,4 @@ typedef struct _HCSinfo { #define SCSI_RESET_BUS_RESET 0x100 #define SCSI_RESET_HOST_RESET 0x200 #define SCSI_RESET_ACTION 0xff + diff --git a/drivers/scsi/ini9100u.c b/drivers/scsi/ini9100u.c index 509612db24f4..8026bb668a3f 100644 --- a/drivers/scsi/ini9100u.c +++ b/drivers/scsi/ini9100u.c @@ -1,8 +1,8 @@ + /************************************************************************** * Initio 9100 device driver for Linux. * * Copyright (c) 1994-1998 Initio Corporation - * Copyright (c) 1998 Bas Vermeulen * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -87,21 +87,6 @@ * - Handle reset routine. * 09/21/98 hl - v1.03 * - remove comments. - * 12/09/98 bv - v1.03a - * - Removed unused code - * 12/13/98 bv - v1.03b - * - Remove cli() locking for kernels >= 2.1.95. This uses - * spinlocks to serialize access to the pSRB_head and - * pSRB_tail members of the HCS structure. - * 09/01/99 bv - v1.03d - * - Fixed a deadlock problem in SMP. - * 21/01/99 bv - v1.03e - * - Add support for the Domex 3192U PCI SCSI - * This is a slightly modified patch by - * Brian Macy - * 22/02/99 bv - v1.03f - * - Didn't detect the INIC-950 in 2.0.x correctly. - * Now fixed. **************************************************************************/ #define CVT_LINUX_VERSION(V,P,S) (V * 65536 + P * 256 + S) @@ -171,7 +156,7 @@ #endif #ifdef DEBUG_i91u -unsigned int i91u_debug = DEBUG_DEFAULT; +unsigned int i91u_debug = DEBUG_DEFAULT; #endif #ifdef MODULE @@ -179,88 +164,82 @@ Scsi_Host_Template driver_template = INI9100U; #include "scsi_module.c" #endif -char *i91uCopyright = "Copyright (C) 1996-98"; -char *i91uInitioName = "by Initio Corporation"; -char *i91uProductName = "INI-9X00U/UW"; -char *i91uVersion = "v1.03f"; +char *i91uCopyright = "Copyright (C) 1996-98"; +char *i91uInitioName = "by Initio Corporation"; +char *i91uProductName= "INI-9X00U/UW"; +char *i91uVersion = "v1.03"; #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) struct proc_dir_entry proc_scsi_ini9100u = -{ - PROC_SCSI_INI9100U, 7, "INI9100U", + { + PROC_SCSI_INI9100U , 7, "INI9100U", S_IFDIR | S_IRUGO | S_IXUGO, 2, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL -}; + }; #endif +#if 1 /* <01> */ #define TULSZ(sz) (sizeof(sz) / sizeof(sz[0])) #define TUL_RDWORD(x,y) (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) )) +#endif /* set by i91_setup according to the command line */ -static int setup_called = 0; +static int setup_called = 0; -static int tul_num_ch = 4; /* Maximum 4 adapters */ -static int tul_num_scb; -static int tul_tag_enable = 1; -static SCB *tul_scb; +static int tul_num_ch = 4; /* Maximum 4 adapters */ +static int tul_num_scb; +static int tul_tag_enable = 1; +static SCB *tul_scb; #ifdef DEBUG_i91u -static int setup_debug = 0; +static int setup_debug = 0; #endif -static char *setup_str = (char *) NULL; +static char *setup_str = (char *)NULL; #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void i91u_intr0(int irq, void *dev_id, struct pt_regs *); -static void i91u_intr1(int irq, void *dev_id, struct pt_regs *); -static void i91u_intr2(int irq, void *dev_id, struct pt_regs *); -static void i91u_intr3(int irq, void *dev_id, struct pt_regs *); -static void i91u_intr4(int irq, void *dev_id, struct pt_regs *); -static void i91u_intr5(int irq, void *dev_id, struct pt_regs *); -static void i91u_intr6(int irq, void *dev_id, struct pt_regs *); -static void i91u_intr7(int irq, void *dev_id, struct pt_regs *); +static void i91u_intr0( int irq, void *dev_id, struct pt_regs * ); +static void i91u_intr1( int irq, void *dev_id, struct pt_regs * ); +static void i91u_intr2( int irq, void *dev_id, struct pt_regs * ); +static void i91u_intr3( int irq, void *dev_id, struct pt_regs * ); +static void i91u_intr4( int irq, void *dev_id, struct pt_regs * ); +static void i91u_intr5( int irq, void *dev_id, struct pt_regs * ); +static void i91u_intr6( int irq, void *dev_id, struct pt_regs * ); +static void i91u_intr7( int irq, void *dev_id, struct pt_regs * ); #else -static void i91u_intr0(int irq, struct pt_regs *); -static void i91u_intr1(int irq, struct pt_regs *); -static void i91u_intr2(int irq, struct pt_regs *); -static void i91u_intr3(int irq, struct pt_regs *); -static void i91u_intr4(int irq, struct pt_regs *); -static void i91u_intr5(int irq, struct pt_regs *); -static void i91u_intr6(int irq, struct pt_regs *); -static void i91u_intr7(int irq, struct pt_regs *); +static void i91u_intr0( int irq, struct pt_regs * ); +static void i91u_intr1( int irq, struct pt_regs * ); +static void i91u_intr2( int irq, struct pt_regs * ); +static void i91u_intr3( int irq, struct pt_regs * ); +static void i91u_intr4( int irq, struct pt_regs * ); +static void i91u_intr5( int irq, struct pt_regs * ); +static void i91u_intr6( int irq, struct pt_regs * ); +static void i91u_intr7( int irq, struct pt_regs * ); #endif -static void i91u_panic(char *msg); +static void i91u_panic(char *msg); -static void i91uSCBPost(BYTE * pHcb, BYTE * pScb); +static void i91uSCBPost(BYTE *pHcb, BYTE *pScb); /* ---- EXTERNAL FUNCTIONS ---- */ - /* Get total number of adapters */ -extern void init_i91uAdapter_table(void); -extern int Addi91u_into_Adapter_table(WORD, WORD, BYTE, BYTE, BYTE); -extern int tul_ReturnNumberOfAdapters(void); -extern void get_tulipPCIConfig(HCS * pHCB, int iChannel_index); -extern int init_tulip(HCS * pHCB, SCB * pSCB, int tul_num_scb, BYTE * pbBiosAdr, int reset_time); -extern SCB *tul_alloc_scb(HCS * pHCB); -extern int tul_abort_srb(HCS * pHCB, Scsi_Cmnd * pSRB); -extern void tul_exec_scb(HCS * pHCB, SCB * pSCB); -extern void tul_release_scb(HCS * pHCB, SCB * pSCB); -extern void tul_stop_bm(HCS * pHCB); -extern int tul_reset_scsi(HCS * pCurHcb, int seconds); -extern int tul_isr(HCS * pHCB); -extern int tul_reset(HCS * pHCB, Scsi_Cmnd * pSRB, unsigned char target); -extern int tul_reset_scsi_bus(HCS * pCurHcb); -extern int tul_device_reset(HCS * pCurHcb, ULONG pSrb, unsigned int target, unsigned int ResetFlags); + /* Get total number of adapters*/ +extern void init_i91uAdapter_table(void); +extern int Addi91u_into_Adapter_table(WORD, WORD, BYTE, BYTE, BYTE); +extern int tul_ReturnNumberOfAdapters(void); +extern void get_tulipPCIConfig(HCS *pHCB, int iChannel_index); +extern int init_tulip(HCS *pHCB, SCB *pSCB, int tul_num_scb, BYTE *pbBiosAdr, int reset_time); +extern SCB *tul_alloc_scb(HCS *pHCB); +extern int tul_abort_srb(HCS *pHCB, Scsi_Cmnd *pSRB); +extern void tul_exec_scb(HCS *pHCB, SCB *pSCB); +extern void tul_release_scb(HCS *pHCB, SCB *pSCB); +extern void tul_stop_bm(HCS *pHCB); +extern int tul_reset_scsi(HCS *pCurHcb, int seconds); +extern int tul_isr(HCS *pHCB); +extern int tul_reset(HCS *pHCB, Scsi_Cmnd *pSRB, unsigned char target); +extern int tul_reset_scsi_bus(HCS *pCurHcb); +extern int tul_device_reset(HCS *pCurHcb, ULONG pSrb, unsigned int target, unsigned int ResetFlags); /* ---- EXTERNAL VARIABLES ---- */ -extern HCS tul_hcs[]; - -const PCI_ID i91u_pci_devices[] = { - { INI_VENDOR_ID, I950_DEVICE_ID }, - { INI_VENDOR_ID, I940_DEVICE_ID }, - { INI_VENDOR_ID, I935_DEVICE_ID }, - { INI_VENDOR_ID, I920_DEVICE_ID }, - { DMX_VENDOR_ID, I920_DEVICE_ID }, -}; +extern HCS tul_hcs[]; /* * queue services: @@ -273,30 +252,24 @@ const PCI_ID i91u_pci_devices[] = { Output : None. Return : None. *****************************************************************************/ -static void i91uAppendSRBToQueue(HCS * pHCB, Scsi_Cmnd * pSRB) +static void i91uAppendSRBToQueue(HCS *pHCB, Scsi_Cmnd *pSRB) { - ULONG flags; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pHCB->pSRB_lock), flags); -#else - save_flags(flags); - cli(); -#endif + ULONG flags; - pSRB->next = NULL; /* Pointer to next */ + save_flags(flags); + cli(); - if (pHCB->pSRB_head == NULL) - pHCB->pSRB_head = pSRB; - else - pHCB->pSRB_tail->next = pSRB; /* Pointer to next */ - pHCB->pSRB_tail = pSRB; + pSRB->next = NULL; /* Pointer to next */ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags); -#else - restore_flags(flags); -#endif - return; + if (pHCB->pSRB_head == NULL) + pHCB->pSRB_head = pSRB; + else + pHCB->pSRB_tail->next = pSRB; /* Pointer to next */ + pHCB->pSRB_tail = pSRB; + + restore_flags(flags); + + return; } /***************************************************************************** @@ -306,79 +279,115 @@ static void i91uAppendSRBToQueue(HCS * pHCB, Scsi_Cmnd * pSRB) Output : None. Return : pSRB - Pointer to SCSI request block. *****************************************************************************/ -static Scsi_Cmnd *i91uPopSRBFromQueue(HCS * pHCB) +static Scsi_Cmnd *i91uPopSRBFromQueue(HCS *pHCB) { - Scsi_Cmnd *pSRB; - ULONG flags; + Scsi_Cmnd *pSRB; + ULONG flags; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pHCB->pSRB_lock), flags); -#else - save_flags(flags); - cli(); -#endif + save_flags(flags); + cli(); - if ((pSRB = pHCB->pSRB_head) != NULL) { - pHCB->pSRB_head = pHCB->pSRB_head->next; - pSRB->next = NULL; + if ((pSRB = pHCB->pSRB_head) != NULL) + { + pHCB->pSRB_head = pHCB->pSRB_head->next; + pSRB->next = NULL; } -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags); -#else - restore_flags(flags); -#endif - return (pSRB); + restore_flags(flags); + + return (pSRB); } /* called from init/main.c */ -void i91u_setup(char *str, int *ints) +void i91u_setup( char *str, int *ints) { - if (setup_called) - i91u_panic("i91u: i91u_setup called twice.\n"); + if (setup_called) + i91u_panic("i91u: i91u_setup called twice.\n"); - setup_called = ints[0]; - setup_str = str; + setup_called = ints[0]; + setup_str = str; #ifdef DEBUG_i91u - setup_debug = ints[0] >= 1 ? ints[1] : DEBUG_DEFAULT; + setup_debug = ints[0] >= 1 ? ints[1] : DEBUG_DEFAULT; #endif } #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,93) int tul_NewReturnNumberOfAdapters(void) { - struct pci_dev *pDev = NULL; /* Start from none */ - int iAdapters = 0; - long dRegValue; - WORD wBIOS; - int i = 0; + struct pci_dev *pDev = NULL; /* Start from none */ + int iAdapters = 0; + long dRegValue; + WORD wBIOS; - init_i91uAdapter_table(); + init_i91uAdapter_table(); - for (i = 0; i < TULSZ(i91u_pci_devices); i++) + while ((pDev = pci_find_device(INI_VENDOR_ID,I950_DEVICE_ID,pDev)) != NULL) { - while ((pDev = pci_find_device(i91u_pci_devices[i].vendor_id, i91u_pci_devices[i].device_id, pDev)) != NULL) { - pci_read_config_dword(pDev, 0x44, (u32 *) & dRegValue); - wBIOS = (UWORD) (dRegValue & 0xFF); - if (((dRegValue & 0xFF00) >> 8) == 0xFF) - dRegValue = 0; - wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8)); - if (Addi91u_into_Adapter_table(wBIOS, - (pDev->base_address[0] & 0xFFFE), - pDev->irq, - pDev->bus->number, - (pDev->devfn >> 3) - ) == 0) - iAdapters++; - } + pci_read_config_dword(pDev, 0x44, (u32 *) &dRegValue); + wBIOS = (UWORD) (dRegValue & 0xFF); + if (((dRegValue & 0xFF00) >> 8) == 0xFF) + dRegValue = 0; + wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8)); + if (Addi91u_into_Adapter_table( wBIOS, + (pDev->base_address[0] & 0xFFFE), + pDev->irq, + pDev->bus->number, + (pDev->devfn >> 3) + ) == 0) + iAdapters++; + } + while ((pDev = pci_find_device(INI_VENDOR_ID,I940_DEVICE_ID,pDev)) != NULL) + { + pci_read_config_dword(pDev, 0x44, (u32 *) &dRegValue); + wBIOS = (UWORD) (dRegValue & 0xFF); + if (((dRegValue & 0xFF00) >> 8) == 0xFF) + dRegValue = 0; + wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8)); + if (Addi91u_into_Adapter_table( wBIOS, + (pDev->base_address[0] & 0xFFFE), + pDev->irq, + pDev->bus->number, + (pDev->devfn >> 3) + ) == 0) + iAdapters++; + } + while ((pDev = pci_find_device(INI_VENDOR_ID,I935_DEVICE_ID,pDev)) != NULL) + { + pci_read_config_dword(pDev, 0x44, (u32 *) &dRegValue); + wBIOS = (UWORD) (dRegValue & 0xFF); + if (((dRegValue & 0xFF00) >> 8) == 0xFF) + dRegValue = 0; + wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8)); + if (Addi91u_into_Adapter_table( wBIOS, + (pDev->base_address[0] & 0xFFFE), + pDev->irq, + pDev->bus->number, + (pDev->devfn >> 3) + ) == 0) + iAdapters++; + } + while ((pDev = pci_find_device(INI_VENDOR_ID,0x0002,pDev)) != NULL) + { + pci_read_config_dword(pDev, 0x44, (u32 *) &dRegValue); + wBIOS = (UWORD) (dRegValue & 0xFF); + if (((dRegValue & 0xFF00) >> 8) == 0xFF) + dRegValue = 0; + wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8)); + if (Addi91u_into_Adapter_table( wBIOS, + (pDev->base_address[0] & 0xFFFE), + pDev->irq, + pDev->bus->number, + (pDev->devfn >> 3) + ) == 0) + iAdapters++; } - return (iAdapters); + return (iAdapters); } -#else /* <01> */ +#else /* <01> */ /***************************************************************************** Function name : tul_ReturnNumberOfAdapters @@ -390,378 +399,480 @@ int tul_NewReturnNumberOfAdapters(void) *****************************************************************************/ int tul_ReturnNumberOfAdapters(void) { - unsigned int i, iAdapters; - unsigned int dRegValue; - unsigned short command; - WORD wBIOS, wBASE; - BYTE bPCIBusNum, bInterrupt, bPCIDeviceNum; - - iAdapters = 0; - /* - * PCI-bus probe. - */ - if (pcibios_present()) { + unsigned int i, iAdapters; + unsigned int dRegValue; + unsigned short command; + WORD wBIOS, wBASE; + BYTE bPCIBusNum, bInterrupt, bPCIDeviceNum; + struct + { + unsigned short vendor_id; + unsigned short device_id; + } const i91u_pci_devices[] = { + {INI_VENDOR_ID, I935_DEVICE_ID}, + {INI_VENDOR_ID, I940_DEVICE_ID}, + {INI_VENDOR_ID, I950_DEVICE_ID}, + {INI_VENDOR_ID, I920_DEVICE_ID} + }; + + + iAdapters = 0; + /* + * PCI-bus probe. + */ + if (pcibios_present()) + { #ifdef MMAPIO - unsigned long page_offset, base; -#endif - - int index; - unsigned char pci_bus, pci_devfn; - - bPCIBusNum = 0; - bPCIDeviceNum = 0; - init_i91uAdapter_table(); - for (i = 0; i < TULSZ(i91u_pci_devices); i++) { - index = 0; - while (!(pcibios_find_device(i91u_pci_devices[i].vendor_id, - i91u_pci_devices[i].device_id, - index++, &pci_bus, &pci_devfn))) - { - if (i == 2) { - printk("i91u: The RAID controller is not supported by\n"); - printk("i91u: this driver, we are ignoring it.\n"); - } else { - /* - * Read sundry information from PCI BIOS. - */ - bPCIBusNum = pci_bus; - bPCIDeviceNum = pci_devfn; - pcibios_read_config_dword(pci_bus, pci_devfn, PCI_BASE_ADDRESS_0, - &dRegValue); - if (dRegValue == -1) { /* Check return code */ - printk("\n\ri91u: tulip read configuration error.\n"); - return (0); /* Read configuration space error */ - } - /* <02> read from base address + 0x50 offset to get the wBIOS balue. */ - wBASE = (WORD) dRegValue; - - /* Now read the interrupt line */ - pcibios_read_config_dword(pci_bus, pci_devfn, PCI_INTERRUPT_LINE, - &dRegValue); - bInterrupt = dRegValue & 0xFF; /* Assign interrupt line */ - pcibios_read_config_word(pci_bus, pci_devfn, PCI_COMMAND, &command); - pcibios_write_config_word(pci_bus, pci_devfn, PCI_COMMAND, - command | PCI_COMMAND_MASTER | PCI_COMMAND_IO); - wBASE &= PCI_BASE_ADDRESS_IO_MASK; - wBIOS = TUL_RDWORD(wBASE, 0x50); + unsigned long page_offset, base; +#endif + +#if LINUX_VERSION_CODE > CVT_LINUX_VERSION(2,1,92) + struct pci_dev *pdev = NULL; +#else + int index; + unsigned char pci_bus, pci_devfn; +#endif + + bPCIBusNum = 0; + bPCIDeviceNum = 0; + init_i91uAdapter_table(); + for (i = 0; i < TULSZ(i91u_pci_devices); i++) + { +#if LINUX_VERSION_CODE > CVT_LINUX_VERSION(2,1,92) + pdev = NULL; + while ((pdev = pci_find_device(i91u_pci_devices[i].vendor_id, + i91u_pci_devices[i].device_id, + pdev))) +#else + index = 0; + while (!(pcibios_find_device(i91u_pci_devices[i].vendor_id, + i91u_pci_devices[i].device_id, + index++, &pci_bus, &pci_devfn)) ) +#endif + { + if ( i == 0 ) + { + /* + printk("i91u: The RAID controller is not supported by\n"); + printk("i91u: this driver, we are ignoring it.\n"); + */ + } + else + { + /* + * Read sundry information from PCI BIOS. + */ +#if LINUX_VERSION_CODE > CVT_LINUX_VERSION(2,1,92) + bPCIBusNum = pdev->bus->number; + bPCIDeviceNum = pdev->devfn; + dRegValue = pdev->base_address[0]; + if (dRegValue == -1) + { /* Check return code */ + printk("\n\ri91u: tulip read configuration error.\n"); + return(0); /* Read configuration space error */ + } + /* <02> read from base address + 0x50 offset to get the wBIOS balue. */ + wBASE = (WORD) dRegValue; + + /* Now read the interrupt line */ + dRegValue = pdev->irq; + bInterrupt = dRegValue & 0xFF;/* Assign interrupt line */ + pci_read_config_word(pdev, PCI_COMMAND, &command); + pci_write_config_word(pdev, PCI_COMMAND, + command | PCI_COMMAND_MASTER | PCI_COMMAND_IO); + +#else + bPCIBusNum = pci_bus; + bPCIDeviceNum = pci_devfn; + pcibios_read_config_dword(pci_bus, pci_devfn, PCI_BASE_ADDRESS_0, + &dRegValue); + if (dRegValue == -1) + { /* Check return code */ + printk("\n\ri91u: tulip read configuration error.\n"); + return(0); /* Read configuration space error */ + } + /* <02> read from base address + 0x50 offset to get the wBIOS balue. */ + wBASE = (WORD) dRegValue; + + /* Now read the interrupt line */ + pcibios_read_config_dword(pci_bus, pci_devfn, PCI_INTERRUPT_LINE, + &dRegValue); + bInterrupt = dRegValue & 0xFF;/* Assign interrupt line */ + pcibios_read_config_word(pci_bus, pci_devfn, PCI_COMMAND, &command); + pcibios_write_config_word(pci_bus, pci_devfn, PCI_COMMAND, + command | PCI_COMMAND_MASTER | PCI_COMMAND_IO); +#endif + wBASE &= PCI_BASE_ADDRESS_IO_MASK; + wBIOS = TUL_RDWORD(wBASE, 0x50); #ifdef MMAPIO - base = wBASE & PAGE_MASK; - page_offset = wBASE - base; + base = wBASE & PAGE_MASK; + page_offset = wBASE - base; - /* - * replace the next line with this one if you are using 2.1.x: - * temp_p->maddr = ioremap(base, page_offset + 256); - */ + /* + * replace the next line with this one if you are using 2.1.x: + * temp_p->maddr = ioremap(base, page_offset + 256); + */ #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,0) - wBASE = ioremap(base, page_offset + 256); + wBASE = ioremap(base, page_offset + 256); #else - wBASE = (WORD) vremap(base, page_offset + 256); -#endif - if (wBASE) { - wBASE += page_offset; - } -#endif - - if (Addi91u_into_Adapter_table(wBIOS, wBASE, bInterrupt, bPCIBusNum, - bPCIDeviceNum) == 0x0) - iAdapters++; - } - } /* while(pdev=....) */ - } /* for PCI_DEVICES */ - } /* PCI BIOS present */ - return (iAdapters); + wBASE = (WORD)vremap(base, page_offset + 256); +#endif + if(wBASE) + { + wBASE += page_offset; + } +#endif + + if (Addi91u_into_Adapter_table(wBIOS, wBASE, bInterrupt, bPCIBusNum, + bPCIDeviceNum) == 0x0) + iAdapters++; + } + } /* while(pdev=....) */ + } /* for PCI_DEVICES */ + } /* PCI BIOS present */ + return (iAdapters); } #endif int i91u_detect(Scsi_Host_Template * tpnt) { - SCB *pSCB; - HCS *pHCB; - struct Scsi_Host *hreg; - unsigned long i; /* 01/14/98 */ - int ok = 0, iAdapters; - ULONG dBiosAdr; - BYTE *pbBiosAdr; - + SCB *pSCB; + HCS *pHCB; + struct Scsi_Host *hreg; + unsigned long i; /* 01/14/98 */ + int ok = 0, iAdapters; + ULONG dBiosAdr; + BYTE *pbBiosAdr; + #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - tpnt->proc_dir = &proc_scsi_ini9100u; + tpnt->proc_dir = &proc_scsi_ini9100u; #endif - if (setup_called) { /* Setup by i91u_setup */ - printk("i91u: processing commandline: "); - + if (setup_called) + { /* Setup by i91u_setup */ + printk("i91u: processing commandline: "); + #ifdef DEBUG_i91u - if (setup_called > 1) { - printk("\ni91u: %s\n", setup_str); - printk("i91u: usage: i91u[=]\n"); - i91u_panic("i91u panics in line %d", __LINE__); - } - i91u_debug = setup_debug; + if (setup_called > 1) + { + printk("\ni91u: %s\n", setup_str ); + printk("i91u: usage: i91u[=]\n"); + i91u_panic("i91u panics in line %d", __LINE__); + } + i91u_debug = setup_debug; #endif } - /* Get total number of adapters in the motherboard */ + + /* Get total number of adapters in the motherboard */ #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,93) -#ifdef CONFIG_PCI - iAdapters = tul_NewReturnNumberOfAdapters(); -#else - iAdapters = tul_ReturnNumberOfAdapters(); -#endif + #ifdef CONFIG_PCI + iAdapters = tul_NewReturnNumberOfAdapters(); + #else + iAdapters = tul_ReturnNumberOfAdapters(); + #endif #else - iAdapters = tul_ReturnNumberOfAdapters(); + iAdapters = tul_ReturnNumberOfAdapters(); #endif - if (iAdapters == 0) /* If no tulip founded, return */ - return (0); + if (iAdapters == 0) /* If no tulip founded, return*/ + return (0); - tul_num_ch = (iAdapters > tul_num_ch) ? tul_num_ch : iAdapters; - /* Update actually channel number */ - if (tul_tag_enable) { /* 1.01i */ - tul_num_scb = MAX_TARGETS * i91u_MAXQUEUE; - } else { - tul_num_scb = MAX_TARGETS + 3; /* 1-tape, 1-CD_ROM, 1- extra */ - } /* Update actually SCBs per adapter */ + tul_num_ch = (iAdapters > tul_num_ch)? tul_num_ch : iAdapters; + /* Update actually channel number */ + if (tul_tag_enable) /* 1.01i */ + { + tul_num_scb = MAX_TARGETS * i91u_MAXQUEUE; + } + else + { + tul_num_scb = MAX_TARGETS + 3; /* 1-tape, 1-CD_ROM, 1- extra */ + } /* Update actually SCBs per adapter */ - /* Get total memory needed for HCS */ - i = tul_num_ch * sizeof(HCS); - memset((unsigned char *) &tul_hcs[0], 0, i); /* Initialize tul_hcs 0 */ - /* Get total memory needed for SCB */ + /* Get total memory needed for HCS */ + i = tul_num_ch * sizeof(HCS); + memset((unsigned char *) &tul_hcs[0], 0, i);/* Initialize tul_hcs 0 */ + /* Get total memory needed for SCB */ #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - for (; tul_num_scb >= MAX_TARGETS + 3; tul_num_scb--) { - i = tul_num_ch * tul_num_scb * sizeof(SCB); - if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL) - break; + for (;tul_num_scb >= MAX_TARGETS+3; tul_num_scb--) + { + i = tul_num_ch * tul_num_scb * sizeof(SCB); + if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC|GFP_DMA)) != NULL) + break; } #else - i = tul_num_ch * tul_num_scb * sizeof(SCB); - tul_scb = (SCB *) scsi_init_malloc(i, GFP_ATOMIC | GFP_DMA); + i = tul_num_ch * tul_num_scb * sizeof(SCB); + tul_scb = (SCB *) scsi_init_malloc(i, GFP_ATOMIC|GFP_DMA); #endif - if (tul_scb == NULL) { - printk("i91u: SCB memory allocation error\n"); - return (0); + if (tul_scb == NULL) + { + printk("i91u: SCB memory allocation error\n"); + return (0); } - memset((unsigned char *) tul_scb, 0, i); - pSCB = tul_scb; - for (i = 0; i < tul_num_ch * tul_num_scb; i++, pSCB++) { + memset((unsigned char *) tul_scb, 0, i); + + pSCB = tul_scb; + for ( i = 0; i < tul_num_ch * tul_num_scb; i++, pSCB++) + { #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - pSCB->SCB_SGPAddr = (U32) VIRT_TO_BUS(&pSCB->SCB_SGList[0]); + pSCB->SCB_SGPAddr = (U32) VIRT_TO_BUS (&pSCB->SCB_SGList[0]); #else - pSCB->SCB_SGPAddr = (U32) (&pSCB->SCB_SGList[0]); + pSCB->SCB_SGPAddr = (U32) (&pSCB->SCB_SGList[0]); #endif } - for (i = 0, pHCB = &tul_hcs[0]; /* Get pointer for control block */ - i < tul_num_ch; - i++, pHCB++) { - pHCB->pSRB_head = NULL; /* Initial SRB save queue */ - pHCB->pSRB_tail = NULL; /* Initial SRB save queue */ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - pHCB->pSRB_lock = SPIN_LOCK_UNLOCKED; /* SRB save queue lock */ -#endif - request_region(pHCB->HCS_Base, 0x100, "i91u"); /* Register */ + for (i = 0, pHCB = &tul_hcs[0]; /* Get pointer for control block*/ + i < tul_num_ch; + i++, pHCB++) + { + pHCB->pSRB_head = NULL; /* Initial SRB save queue */ + pHCB->pSRB_tail = NULL; /* Initial SRB save queue */ + + request_region(pHCB->HCS_Base, 0x100, "i91u"); /* Register */ - get_tulipPCIConfig(pHCB, i); + get_tulipPCIConfig(pHCB, i); - dBiosAdr = pHCB->HCS_BIOS; - dBiosAdr = (dBiosAdr << 4); + dBiosAdr = pHCB->HCS_BIOS; + dBiosAdr = (dBiosAdr << 4); #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - pbBiosAdr = phys_to_virt(dBiosAdr); + pbBiosAdr = phys_to_virt (dBiosAdr); #endif - init_tulip(pHCB, tul_scb + (i * tul_num_scb), tul_num_scb, pbBiosAdr, 10); - pHCB->HCS_Index = i; /* 7/29/98 */ - hreg = scsi_register(tpnt, sizeof(HCS)); - hreg->io_port = pHCB->HCS_Base; - hreg->n_io_port = 0xff; - hreg->can_queue = tul_num_scb; /* 03/05/98 */ + init_tulip(pHCB, tul_scb + (i * tul_num_scb), tul_num_scb, pbBiosAdr, 10); + pHCB->HCS_Index = i; /* 7/29/98 */ + hreg = scsi_register(tpnt, sizeof(HCS)); + hreg->io_port = pHCB->HCS_Base; + hreg->n_io_port = 0xff; + hreg->can_queue = tul_num_scb; /* 03/05/98 */ #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - hreg->unique_id = pHCB->HCS_Base; - hreg->max_id = pHCB->HCS_MaxTar; + hreg->unique_id = pHCB->HCS_Base; + hreg->max_id = pHCB->HCS_MaxTar; +#endif + hreg->max_lun = 32; /* 10/21/97 */ +/* hreg->max_lun = 8; + hreg->max_channel = 1;*/ + hreg->irq = pHCB->HCS_Intr; + hreg->this_id = pHCB->HCS_SCSI_ID;/* Assign HCS index */ + hreg->base = (UCHAR *) pHCB; +#if 1 + hreg->sg_tablesize = TOTAL_SG_ENTRY; /* Maximun support is 32*/ +#else + hreg->sg_tablesize = SG_NONE; /* No SG */ #endif - hreg->max_lun = 32; /* 10/21/97 */ - hreg->irq = pHCB->HCS_Intr; - hreg->this_id = pHCB->HCS_SCSI_ID; /* Assign HCS index */ - hreg->base = (UCHAR *) pHCB; - hreg->sg_tablesize = TOTAL_SG_ENTRY; /* Maximun support is 32 */ +/* hreg->this_id = i; Assign HCS index */ - /* Initial tulip chip */ - switch (i) { + /* Initial tulip chip */ + switch (i) { #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - case 0: - ok = request_irq(pHCB->HCS_Intr, i91u_intr0, SA_INTERRUPT | SA_SHIRQ, "i91u", NULL); - break; - case 1: - ok = request_irq(pHCB->HCS_Intr, i91u_intr1, SA_INTERRUPT | SA_SHIRQ, "i91u", NULL); - break; - case 2: - ok = request_irq(pHCB->HCS_Intr, i91u_intr2, SA_INTERRUPT | SA_SHIRQ, "i91u", NULL); - break; - case 3: - ok = request_irq(pHCB->HCS_Intr, i91u_intr3, SA_INTERRUPT | SA_SHIRQ, "i91u", NULL); - break; - case 4: - ok = request_irq(pHCB->HCS_Intr, i91u_intr4, SA_INTERRUPT | SA_SHIRQ, "i91u", NULL); - break; - case 5: - ok = request_irq(pHCB->HCS_Intr, i91u_intr5, SA_INTERRUPT | SA_SHIRQ, "i91u", NULL); - break; - case 6: - ok = request_irq(pHCB->HCS_Intr, i91u_intr6, SA_INTERRUPT | SA_SHIRQ, "i91u", NULL); - break; - case 7: - ok = request_irq(pHCB->HCS_Intr, i91u_intr7, SA_INTERRUPT | SA_SHIRQ, "i91u", NULL); - break; - default: - i91u_panic("i91u: Too many host adapters\n"); - break; - } - if (ok < 0) { - if (ok == -EINVAL) { - printk("i91u: bad IRQ %d.\n", pHCB->HCS_Intr); - printk(" Contact author.\n"); - } else if (ok == -EBUSY) - printk("i91u: IRQ %d already in use. Configure another.\n", - pHCB->HCS_Intr); - else { - printk("\ni91u: Unexpected error code on requesting IRQ %d.\n", - pHCB->HCS_Intr); - printk(" Contact author.\n"); - } - i91u_panic("i91u: driver needs an IRQ.\n"); + case 0: + ok = request_irq(pHCB->HCS_Intr, i91u_intr0,SA_INTERRUPT | SA_SHIRQ,"i91u",NULL); + break; + case 1: + ok = request_irq(pHCB->HCS_Intr, i91u_intr1,SA_INTERRUPT | SA_SHIRQ,"i91u",NULL); + break; + case 2: + ok = request_irq(pHCB->HCS_Intr, i91u_intr2,SA_INTERRUPT | SA_SHIRQ,"i91u",NULL); + break; + case 3: + ok = request_irq(pHCB->HCS_Intr, i91u_intr3,SA_INTERRUPT | SA_SHIRQ,"i91u",NULL); + break; + case 4: + ok = request_irq(pHCB->HCS_Intr, i91u_intr4,SA_INTERRUPT | SA_SHIRQ,"i91u",NULL); + break; + case 5: + ok = request_irq(pHCB->HCS_Intr, i91u_intr5,SA_INTERRUPT | SA_SHIRQ,"i91u",NULL); + break; + case 6: + ok = request_irq(pHCB->HCS_Intr, i91u_intr6,SA_INTERRUPT | SA_SHIRQ,"i91u",NULL); + break; + case 7: + ok = request_irq(pHCB->HCS_Intr, i91u_intr7,SA_INTERRUPT | SA_SHIRQ,"i91u",NULL); + break; + default: + i91u_panic("i91u: Too many host adapters\n"); + break; + } + if (ok < 0) + { + if (ok == -EINVAL) + { + printk("i91u: bad IRQ %d.\n", pHCB->HCS_Intr); + printk(" Contact author.\n"); } + else + if( ok == -EBUSY) + printk( "i91u: IRQ %d already in use. Configure another.\n", + pHCB->HCS_Intr); + else + { + printk( "\ni91u: Unexpected error code on requesting IRQ %d.\n", + pHCB->HCS_Intr); + printk(" Contact author.\n"); + } + i91u_panic("i91u: driver needs an IRQ.\n"); + } #endif } - tpnt->this_id = -1; - tpnt->can_queue = 1; + tpnt->this_id = -1; +/* tpnt->can_queue=i91u_MAXQUEUE;*/ + tpnt->can_queue=1; - return 1; + return 1; } -static void i91uBuildSCB(HCS * pHCB, SCB * pSCB, Scsi_Cmnd * SCpnt) -{ /* Create corresponding SCB */ - struct scatterlist *pSrbSG; - SG *pSG; /* Pointer to SG list */ - int i; - long TotalLen; - - pSCB->SCB_Post = i91uSCBPost; /* i91u's callback routine */ - pSCB->SCB_Srb = SCpnt; - pSCB->SCB_Opcode = ExecSCSI; - pSCB->SCB_Flags = SCF_POST; /* After SCSI done, call post routine */ - pSCB->SCB_Target = SCpnt->target; - pSCB->SCB_Lun = SCpnt->lun; - pSCB->SCB_Ident = SCpnt->lun | DISC_ALLOW; - pSCB->SCB_Flags |= SCF_SENSE; /* Turn on auto request sense */ +static void i91uBuildSCB(HCS *pHCB, SCB *pSCB, Scsi_Cmnd *SCpnt) +{ /* Create corresponding SCB */ + struct scatterlist *pSrbSG; + SG *pSG; /* Pointer to SG list */ + int i; + long TotalLen; + + pSCB->SCB_Post = i91uSCBPost; /* i91u's callback routine */ + pSCB->SCB_Srb = SCpnt; + pSCB->SCB_Opcode = ExecSCSI; +#if 0 + pSCB->SCB_Flags = SCF_NO_DCHK; /* Clear done bit */ + pSCB->SCB_Flags |= SCF_POST; /* After SCSI done, call post routine*/ +#else + pSCB->SCB_Flags = SCF_POST; /* After SCSI done, call post routine*/ +#endif + pSCB->SCB_Target = SCpnt->target; + pSCB->SCB_Lun = SCpnt->lun; +/* pSCB->SCB_Ident = SCpnt->lun | DISC_NOT_ALLOW;*/ + pSCB->SCB_Ident = SCpnt->lun | DISC_ALLOW; +#if 1 + pSCB->SCB_Flags |= SCF_SENSE; /* Turn on auto request sense */ +/* memset((unsigned char *) &SCpnt->sense_buffer[0], 0, SENSE_SIZE); 7/22/98 */ +#endif + +#if 1 /* 7/22/98 */ #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - pSCB->SCB_SensePtr = (U32) VIRT_TO_BUS(SCpnt->sense_buffer); + pSCB->SCB_SensePtr = (U32) VIRT_TO_BUS (SCpnt->sense_buffer); #else pSCB->SCB_SensePtr = (U32) (SCpnt->sense_buffer); #endif - pSCB->SCB_SenseLen = SENSE_SIZE; +#else + pSCB->SCB_SensePtr = pSCB->SCB_SGPAddr; +#endif + + pSCB->SCB_SenseLen = SENSE_SIZE; - pSCB->SCB_CDBLen = SCpnt->cmd_len; - pSCB->SCB_HaStat = 0; - pSCB->SCB_TaStat = 0; - memcpy(&pSCB->SCB_CDB[0], &SCpnt->cmnd, SCpnt->cmd_len); + pSCB->SCB_CDBLen = SCpnt->cmd_len; + pSCB->SCB_HaStat = 0; + pSCB->SCB_TaStat = 0; + memcpy(&pSCB->SCB_CDB[0], &SCpnt->cmnd, SCpnt->cmd_len); - if (SCpnt->device->tagged_supported) { /* Tag Support */ - pSCB->SCB_TagMsg = SIMPLE_QUEUE_TAG; /* Do simple tag only */ - } else { - pSCB->SCB_TagMsg = 0; /* No tag support */ + if (SCpnt->device->tagged_supported) + { /* Tag Support */ + pSCB->SCB_TagMsg = SIMPLE_QUEUE_TAG; /* Do simple tag only */ + } + else + { + pSCB->SCB_TagMsg = 0; /* No tag support */ } - if (SCpnt->use_sg) { - pSrbSG = (struct scatterlist *) SCpnt->request_buffer; - if (SCpnt->use_sg == 1) { /* If only one entry in the list *//* treat it as regular I/O */ + if (SCpnt->use_sg) + { + pSrbSG = (struct scatterlist *) SCpnt->request_buffer; + if (SCpnt->use_sg == 1) /* If only one entry in the list*/ + { /* treat it as regular I/O */ #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(pSrbSG->address); + pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS (pSrbSG->address); #else - pSCB->SCB_BufPtr = (U32) (pSrbSG->address); -#endif - TotalLen = pSrbSG->length; - pSCB->SCB_SGLen = 0; - } else { /* Assign SG physical address */ - pSCB->SCB_BufPtr = pSCB->SCB_SGPAddr; - pSCB->SCB_Flags |= SCF_SG; /* Turn on SG list flag */ - for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0]; /* 1.01g */ - i < SCpnt->use_sg; - i++, pSG++, pSrbSG++) { + pSCB->SCB_BufPtr = (U32) (pSrbSG->address); +#endif + TotalLen = pSrbSG->length; + pSCB->SCB_SGLen = 0; + } + else + { /* Assign SG physical address */ + pSCB->SCB_BufPtr = pSCB->SCB_SGPAddr; + pSCB->SCB_Flags |= SCF_SG;/* Turn on SG list flag */ + for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0];/* 1.01g*/ + i < SCpnt->use_sg; + i++, pSG++, pSrbSG++) + { #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - pSG->SG_Ptr = (U32) VIRT_TO_BUS(pSrbSG->address); + pSG->SG_Ptr = (U32) VIRT_TO_BUS (pSrbSG->address); #else - pSG->SG_Ptr = (U32) (pSrbSG->address); + pSG->SG_Ptr = (U32) (pSrbSG->address); #endif - TotalLen += pSG->SG_Len = pSrbSG->length; - } - pSCB->SCB_SGLen = i; + TotalLen += pSG->SG_Len = pSrbSG->length; } - pSCB->SCB_BufLen = (SCpnt->request_bufflen > TotalLen) ? - TotalLen : SCpnt->request_bufflen; - } else { /* Non SG */ + pSCB->SCB_SGLen = i; + } + pSCB->SCB_BufLen = (SCpnt->request_bufflen > TotalLen) ? + TotalLen : SCpnt->request_bufflen; + } + else /* Non SG */ + { #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(SCpnt->request_buffer); + pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(SCpnt->request_buffer); #else - pSCB->SCB_BufPtr = (U32) (SCpnt->request_buffer); + pSCB->SCB_BufPtr = (U32) (SCpnt->request_buffer); #endif - pSCB->SCB_BufLen = SCpnt->request_bufflen; - pSCB->SCB_SGLen = 0; + pSCB->SCB_BufLen = SCpnt->request_bufflen; + pSCB->SCB_SGLen = 0; } - return; + return; } /* * Queue a command and setup interrupts for a free bus. */ -int i91u_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) +int i91u_queue( Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *)) { - register SCB *pSCB; - HCS *pHCB; /* Point to Host adapter control block */ + register SCB *pSCB; + HCS *pHCB; /* Point to Host adapter control block*/ - if (SCpnt->lun > 16) { /* 07/22/98 */ + if (SCpnt->lun > 16) { /* 07/22/98 */ - SCpnt->result = (DID_TIME_OUT << 16); - done(SCpnt); /* Notify system DONE */ - return (0); - } - pHCB = (HCS *) SCpnt->host->base; + SCpnt->result = (DID_TIME_OUT << 16); + done(SCpnt); /* Notify system DONE */ + return (0); + } - SCpnt->scsi_done = done; - /* Get free SCSI control block */ - if ((pSCB = tul_alloc_scb(pHCB)) == NULL) { - i91uAppendSRBToQueue(pHCB, SCpnt); /* Buffer this request */ - return (0); - } - i91uBuildSCB(pHCB, pSCB, SCpnt); - tul_exec_scb(pHCB, pSCB); /* Start execute SCB */ + pHCB = (HCS *) SCpnt->host->base; + + SCpnt->scsi_done = done; + /* Get free SCSI control block */ + if ((pSCB = tul_alloc_scb(pHCB)) == NULL) + { + i91uAppendSRBToQueue(pHCB, SCpnt); /* Buffer this request */ +/* printk("i91u_entry: can't allocate SCB\n");*/ return (0); + } + i91uBuildSCB(pHCB, pSCB, SCpnt); + tul_exec_scb(pHCB, pSCB); /* Start execute SCB */ + return (0); } /* * We only support command in interrupt-driven fashion */ -int i91u_command(Scsi_Cmnd * SCpnt) +int i91u_command( Scsi_Cmnd *SCpnt ) { - printk("i91u: interrupt driven driver; use i91u_queue()\n"); - return -1; + printk( "i91u: interrupt driven driver; use i91u_queue()\n" ); + return -1; } /* * Abort a queued command * (commands that are on the bus can't be aborted easily) */ -int i91u_abort(Scsi_Cmnd * SCpnt) +int i91u_abort( Scsi_Cmnd *SCpnt) { - HCS *pHCB; + HCS *pHCB; - pHCB = (HCS *) SCpnt->host->base; - return tul_abort_srb(pHCB, SCpnt); + pHCB = (HCS *) SCpnt->host->base; + return tul_abort_srb(pHCB, SCpnt); } /* @@ -769,57 +880,65 @@ int i91u_abort(Scsi_Cmnd * SCpnt) * kill active and disconnected commands for target w/o soft reset */ int i91u_reset(Scsi_Cmnd * SCpnt, unsigned int reset_flags) -{ /* I need Host Control Block Information */ - HCS *pHCB; +{ /* I need Host Control Block Information */ + HCS *pHCB; - pHCB = (HCS *) SCpnt->host->base; + pHCB = (HCS *) SCpnt->host->base; - if (reset_flags & (SCSI_RESET_SUGGEST_BUS_RESET | SCSI_RESET_SUGGEST_HOST_RESET)) - return tul_reset_scsi_bus(pHCB); - else - return tul_device_reset(pHCB, (ULONG) SCpnt, SCpnt->target, reset_flags); + if (reset_flags & (SCSI_RESET_SUGGEST_BUS_RESET|SCSI_RESET_SUGGEST_HOST_RESET)) + + return tul_reset_scsi_bus(pHCB); + else + return tul_device_reset(pHCB, (ULONG)SCpnt, SCpnt->target, reset_flags); } /* * Return the "logical geometry" */ #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -int i91u_biosparam(Scsi_Disk * disk, kdev_t dev, int *info_array) +int i91u_biosparam(Scsi_Disk *disk, kdev_t dev, int *info_array ) #else -int i91u_biosparam(Scsi_Disk * disk, int dev, int *info_array) +int i91u_biosparam(Scsi_Disk *disk, int dev, int *info_array ) #endif { - HCS *pHcb; /* Point to Host adapter control block */ - TCS *pTcb; - - pHcb = (HCS *) disk->device->host->base; - pTcb = &pHcb->HCS_Tcs[disk->device->id]; - - if (pTcb->TCS_DrvHead) { - info_array[0] = pTcb->TCS_DrvHead; - info_array[1] = pTcb->TCS_DrvSector; - info_array[2] = disk->capacity / pTcb->TCS_DrvHead / pTcb->TCS_DrvSector; - } else { - if (pTcb->TCS_DrvFlags & TCF_DRV_255_63) { - info_array[0] = 255; - info_array[1] = 63; - info_array[2] = disk->capacity / 255 / 63; - } else { - info_array[0] = 64; - info_array[1] = 32; - info_array[2] = disk->capacity >> 11; - } + HCS *pHcb; /* Point to Host adapter control block*/ + TCS *pTcb; + + pHcb = (HCS *) disk->device->host->base; + pTcb = &pHcb->HCS_Tcs[disk->device->id]; + + if (pTcb->TCS_DrvHead) + { + info_array[0] = pTcb->TCS_DrvHead; + info_array[1] = pTcb->TCS_DrvSector; + info_array[2] = disk->capacity / pTcb->TCS_DrvHead / pTcb->TCS_DrvSector; + } + else + { + if (pTcb->TCS_DrvFlags & TCF_DRV_255_63) + { + info_array[0] = 255; + info_array[1] = 63; + info_array[2] = disk->capacity / 255 / 63; + } + else + { + info_array[0] = 64; + info_array[1] = 32; + info_array[2] = disk->capacity >> 11; + } } #if defined(DEBUG_BIOSPARAM) - if (i91u_debug & debug_biosparam) { - printk("bios geometry: head=%d, sec=%d, cyl=%d\n", - info_array[0], info_array[1], info_array[2]); - printk("WARNING: check, if the bios geometry is correct.\n"); + if (i91u_debug & debug_biosparam) + { + printk("bios geometry: head=%d, sec=%d, cyl=%d\n", + info_array[0], info_array[1], info_array[2]); + printk("WARNING: check, if the bios geometry is correct.\n"); } #endif - return 0; + return 0; } /***************************************************************************** @@ -831,266 +950,276 @@ int i91u_biosparam(Scsi_Disk * disk, int dev, int *info_array) Output : None. Return : None. *****************************************************************************/ -static void i91uSCBPost(BYTE * pHcb, BYTE * pScb) +static void i91uSCBPost(BYTE *pHcb, BYTE *pScb) { - Scsi_Cmnd *pSRB; /* Pointer to SCSI request block */ - HCS *pHCB; - SCB *pSCB; + Scsi_Cmnd *pSRB; /* Pointer to SCSI request block */ + HCS *pHCB; + SCB *pSCB; - pHCB = (HCS *) pHcb; - pSCB = (SCB *) pScb; - if ((pSRB = pSCB->SCB_Srb) == 0) { - printk("i91uSCBPost: SRB pointer is empty\n"); + pHCB = (HCS *)pHcb; + pSCB = (SCB *)pScb; + if ((pSRB = pSCB->SCB_Srb) == 0) + { + printk("i91uSCBPost: SRB pointer is empty\n"); - tul_release_scb(pHCB, pSCB); /* Release SCB for current channel */ - return; + tul_release_scb(pHCB, pSCB); /* Release SCB for current channel */ + return; } - switch (pSCB->SCB_HaStat) { + switch (pSCB->SCB_HaStat) { case 0x0: - case 0xa: /* Linked command complete without error and linked normally */ - case 0xb: /* Linked command complete without error interrupt generated */ - pSCB->SCB_HaStat = 0; - break; - - case 0x11: /* Selection time out-The initiator selection or target - reselection was not complete within the SCSI Time out period */ - pSCB->SCB_HaStat = DID_TIME_OUT; - break; - - case 0x14: /* Target bus phase sequence failure-An invalid bus phase or bus - phase sequence was requested by the target. The host adapter - will generate a SCSI Reset Condition, notifying the host with - a SCRD interrupt */ - pSCB->SCB_HaStat = DID_RESET; - break; - - case 0x1a: /* SCB Aborted. 07/21/98 */ - pSCB->SCB_HaStat = DID_ABORT; - break; - - case 0x12: /* Data overrun/underrun-The target attempted to transfer more data - than was allocated by the Data Length field or the sum of the - Scatter / Gather Data Length fields. */ - case 0x13: /* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */ - case 0x16: /* Invalid SCB Operation Code. */ + case 0xa: /* Linked command complete without error and linked normally*/ + case 0xb: /* Linked command complete without error interrupt generated*/ + pSCB->SCB_HaStat = 0; + break; + + case 0x11: /* Selection time out-The initiator selection or target + reselection was not complete within the SCSI Time out period */ + pSCB->SCB_HaStat = DID_TIME_OUT; + break; + + case 0x14: /* Target bus phase sequence failure-An invalid bus phase or bus + phase sequence was requested by the target. The host adapter + will generate a SCSI Reset Condition, notifying the host with + a SCRD interrupt */ + pSCB->SCB_HaStat = DID_RESET; + break; + + case 0x1a: /* SCB Aborted. 07/21/98 */ + pSCB->SCB_HaStat = DID_ABORT; + break; + + case 0x12: /* Data overrun/underrun-The target attempted to transfer more data + than was allocated by the Data Length field or the sum of the + Scatter / Gather Data Length fields. */ + case 0x13: /* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */ + case 0x16: /* Invalid SCB Operation Code. */ default: - printk("ini9100u: %x %x\n", pSCB->SCB_HaStat, pSCB->SCB_TaStat); - pSCB->SCB_HaStat = DID_ERROR; /* Couldn't find any better */ - break; + printk("ini9100u: %x %x\n", pSCB->SCB_HaStat, pSCB->SCB_TaStat); + pSCB->SCB_HaStat = DID_ERROR; /* Couldn't find any better */ + break; + } + +#if 0 + if ((pSCB->SCB_TaStat == 2) && /* Check condition */ + (pSCB->SCB_Flags & SCF_SENSE)) /* Turn on auto request sense */ + { + memcpy((unsigned char *) &pSRB->sense_buffer[0], (unsigned char *) &pSCB->SCB_SGList[0], SENSE_SIZE); } +#endif + pSRB->result = pSCB->SCB_TaStat | (pSCB->SCB_HaStat << 16); - pSRB->result = pSCB->SCB_TaStat | (pSCB->SCB_HaStat << 16); - - if (pSRB == NULL) { - printk("pSRB is NULL\n"); + if (pSRB == NULL) + { + printk("pSRB is NULL\n"); } - pSRB->scsi_done(pSRB); /* Notify system DONE */ - if ((pSRB = i91uPopSRBFromQueue(pHCB)) != NULL) - /* Find the next pending SRB */ - { /* Assume resend will success */ - /* Reuse old SCB */ - i91uBuildSCB(pHCB, pSCB, pSRB); /* Create corresponding SCB */ - - tul_exec_scb(pHCB, pSCB); /* Start execute SCB */ - } else { /* No Pending SRB */ - tul_release_scb(pHCB, pSCB); /* Release SCB for current channel */ + pSRB->scsi_done(pSRB); /* Notify system DONE */ + if ((pSRB = i91uPopSRBFromQueue(pHCB)) != NULL) + /* Find the next pending SRB */ + { /* Assume resend will success */ + /* Reuse old SCB */ + i91uBuildSCB(pHCB, pSCB, pSRB); /* Create corresponding SCB */ + + tul_exec_scb(pHCB, pSCB); /* Start execute SCB */ } - return; + else + { /* No Pending SRB */ + tul_release_scb(pHCB, pSCB); /* Release SCB for current channel */ + } + return; } /* * Interrupts handler (main routine of the driver) */ #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void i91u_intr0(int irqno, void *dev_id, struct pt_regs *regs) +static void i91u_intr0( int irqno, void *dev_id, struct pt_regs * regs ) #else -static void i91u_intr0(int irqno, struct pt_regs *regs) +static void i91u_intr0( int irqno, struct pt_regs * regs ) #endif { #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - unsigned long flags; + unsigned long flags; #endif - if (tul_hcs[0].HCS_Intr != irqno) - return; + if (tul_hcs[0].HCS_Intr != irqno) + return; #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&io_request_lock, flags); + spin_lock_irqsave(&io_request_lock, flags); #endif - tul_isr(&tul_hcs[0]); + tul_isr(&tul_hcs[0]); #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&io_request_lock, flags); + spin_unlock_irqrestore(&io_request_lock, flags); #endif } #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void i91u_intr1(int irqno, void *dev_id, struct pt_regs *regs) +static void i91u_intr1( int irqno, void *dev_id, struct pt_regs * regs ) #else -static void i91u_intr1(int irqno, struct pt_regs *regs) +static void i91u_intr1( int irqno, struct pt_regs * regs ) #endif { #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - unsigned long flags; + unsigned long flags; #endif - if (tul_hcs[1].HCS_Intr != irqno) - return; + if (tul_hcs[1].HCS_Intr != irqno) + return; #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&io_request_lock, flags); + spin_lock_irqsave(&io_request_lock, flags); #endif - tul_isr(&tul_hcs[1]); + tul_isr(&tul_hcs[1]); #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&io_request_lock, flags); + spin_unlock_irqrestore(&io_request_lock, flags); #endif } #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void i91u_intr2(int irqno, void *dev_id, struct pt_regs *regs) +static void i91u_intr2( int irqno, void *dev_id, struct pt_regs * regs ) #else -static void i91u_intr2(int irqno, struct pt_regs *regs) +static void i91u_intr2( int irqno, struct pt_regs * regs ) #endif { #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - unsigned long flags; + unsigned long flags; #endif - if (tul_hcs[2].HCS_Intr != irqno) - return; + if (tul_hcs[2].HCS_Intr != irqno) + return; #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&io_request_lock, flags); + spin_lock_irqsave(&io_request_lock, flags); #endif - tul_isr(&tul_hcs[2]); + tul_isr(&tul_hcs[2]); #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&io_request_lock, flags); + spin_unlock_irqrestore(&io_request_lock, flags); #endif } #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void i91u_intr3(int irqno, void *dev_id, struct pt_regs *regs) +static void i91u_intr3( int irqno, void *dev_id, struct pt_regs * regs ) #else -static void i91u_intr3(int irqno, struct pt_regs *regs) +static void i91u_intr3( int irqno, struct pt_regs * regs ) #endif { #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - unsigned long flags; + unsigned long flags; #endif - if (tul_hcs[3].HCS_Intr != irqno) - return; + if (tul_hcs[3].HCS_Intr != irqno) + return; #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&io_request_lock, flags); + spin_lock_irqsave(&io_request_lock, flags); #endif - tul_isr(&tul_hcs[3]); + tul_isr(&tul_hcs[3]); #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&io_request_lock, flags); + spin_unlock_irqrestore(&io_request_lock, flags); #endif } #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void i91u_intr4(int irqno, void *dev_id, struct pt_regs *regs) +static void i91u_intr4( int irqno, void *dev_id, struct pt_regs * regs ) #else -static void i91u_intr4(int irqno, struct pt_regs *regs) +static void i91u_intr4( int irqno, struct pt_regs * regs ) #endif { #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - unsigned long flags; + unsigned long flags; #endif - if (tul_hcs[4].HCS_Intr != irqno) - return; + if (tul_hcs[4].HCS_Intr != irqno) + return; #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&io_request_lock, flags); + spin_lock_irqsave(&io_request_lock, flags); #endif - tul_isr(&tul_hcs[4]); + tul_isr(&tul_hcs[4]); #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&io_request_lock, flags); + spin_unlock_irqrestore(&io_request_lock, flags); #endif } #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void i91u_intr5(int irqno, void *dev_id, struct pt_regs *regs) +static void i91u_intr5( int irqno, void *dev_id, struct pt_regs * regs ) #else -static void i91u_intr5(int irqno, struct pt_regs *regs) +static void i91u_intr5( int irqno, struct pt_regs * regs ) #endif { #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - unsigned long flags; + unsigned long flags; #endif - if (tul_hcs[5].HCS_Intr != irqno) - return; + if (tul_hcs[5].HCS_Intr != irqno) + return; #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&io_request_lock, flags); + spin_lock_irqsave(&io_request_lock, flags); #endif - tul_isr(&tul_hcs[5]); + tul_isr(&tul_hcs[5]); #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&io_request_lock, flags); + spin_unlock_irqrestore(&io_request_lock, flags); #endif } #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void i91u_intr6(int irqno, void *dev_id, struct pt_regs *regs) +static void i91u_intr6( int irqno, void *dev_id, struct pt_regs * regs ) #else -static void i91u_intr6(int irqno, struct pt_regs *regs) +static void i91u_intr6( int irqno, struct pt_regs * regs ) #endif { #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - unsigned long flags; + unsigned long flags; #endif - if (tul_hcs[6].HCS_Intr != irqno) - return; + if (tul_hcs[6].HCS_Intr != irqno) + return; #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&io_request_lock, flags); + spin_lock_irqsave(&io_request_lock, flags); #endif - tul_isr(&tul_hcs[6]); + tul_isr(&tul_hcs[6]); #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&io_request_lock, flags); + spin_unlock_irqrestore(&io_request_lock, flags); #endif } - #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void i91u_intr7(int irqno, void *dev_id, struct pt_regs *regs) +static void i91u_intr7( int irqno, void *dev_id, struct pt_regs * regs ) #else -static void i91u_intr7(int irqno, struct pt_regs *regs) +static void i91u_intr7( int irqno, struct pt_regs * regs ) #endif { #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - unsigned long flags; + unsigned long flags; #endif - if (tul_hcs[7].HCS_Intr != irqno) - return; + if (tul_hcs[7].HCS_Intr != irqno) + return; #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&io_request_lock, flags); + spin_lock_irqsave(&io_request_lock, flags); #endif - tul_isr(&tul_hcs[7]); + tul_isr(&tul_hcs[7]); #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&io_request_lock, flags); + spin_unlock_irqrestore(&io_request_lock, flags); #endif } @@ -1099,6 +1228,7 @@ static void i91u_intr7(int irqno, struct pt_regs *regs) */ static void i91u_panic(char *msg) { - printk("\ni91u_panic: %s\n", msg); - panic("i91u panic"); + printk("\ni91u_panic: %s\n", msg); + panic("i91u panic"); } +/*#include "i91uscsi.c"*/ diff --git a/drivers/scsi/ini9100u.h b/drivers/scsi/ini9100u.h index e301f1afbcda..6e1526fe6162 100644 --- a/drivers/scsi/ini9100u.h +++ b/drivers/scsi/ini9100u.h @@ -1,3 +1,4 @@ + /************************************************************************** * Initio 9100 device driver for Linux. * @@ -59,13 +60,7 @@ * 06/18/96 Harry Chen, Initial Version 1.00A (Beta) * 06/23/98 hc - v1.01k * - Get it work for kernel version >= 2.1.75 - * 12/09/98 bv - v1.03a - * - Removed unused code - * 12/13/98 bv - v1.03b - * - Add spinlocks to HCS structure. - * 21/01/99 bv - v1.03e - * - Added PCI_ID structure - **************************************************************************/ +*******************************************************************************/ #ifndef CVT_LINUX_VERSION #define CVT_LINUX_VERSION(V,P,S) (((V) * 65536) + ((P) * 256) + (S)) @@ -77,20 +72,20 @@ #include "sd.h" -extern int i91u_detect(Scsi_Host_Template *); -extern int i91u_command(Scsi_Cmnd *); -extern int i91u_queue(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *)); -extern int i91u_abort(Scsi_Cmnd *); -extern int i91u_reset(Scsi_Cmnd *, unsigned int); +extern int i91u_detect(Scsi_Host_Template *); +extern int i91u_command(Scsi_Cmnd *); +extern int i91u_queue(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); +extern int i91u_abort(Scsi_Cmnd *); +extern int i91u_reset(Scsi_Cmnd *, unsigned int); #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1, 3, 0) -extern int i91u_biosparam(Scsi_Disk *, kdev_t, int *); /*for linux v2.0 */ +extern int i91u_biosparam(Scsi_Disk *, kdev_t, int *); /*for linux v2.0*/ extern struct proc_dir_entry proc_scsi_ini9100u; #else -extern int i91u_biosparam(Disk *, int, int *); /*for linux v1.13 */ +extern int i91u_biosparam(Disk *, int, int *); /*for linux v1.13 */ #endif -#define i91u_REVID "Initio INI-9X00U/UW SCSI device driver; Revision: 1.03f" +#define i91u_REVID "Initio INI-9X00U/UW SCSI device driver; Revision: 1.03" #if LINUX_VERSION_CODE < CVT_LINUX_VERSION(1, 3, 0) #define INI9100U { \ @@ -140,7 +135,7 @@ extern int i91u_biosparam(Disk *, int, int *); /*for linux v1.13 */ 0, \ ENABLE_CLUSTERING \ } -#else /* Version >= 2.1.75 */ +#else /* Version >= 2.1.75 */ #define INI9100U { \ next: NULL, \ module: NULL, \ @@ -191,72 +186,63 @@ extern int i91u_biosparam(Disk *, int, int *); /*for linux v1.13 */ #endif #ifndef NULL -#define NULL 0 /* zero */ +#define NULL 0 /* zero */ #endif #ifndef TRUE -#define TRUE (1) /* boolean true */ +#define TRUE (1) /* boolean true */ #endif #ifndef FALSE -#define FALSE (0) /* boolean false */ +#define FALSE (0) /* boolean false */ #endif #ifndef FAILURE #define FAILURE (-1) #endif -#define i91u_MAXQUEUE 2 +#define i91u_MAXQUEUE 2 #define TOTAL_SG_ENTRY 32 #define MAX_TARGETS 16 #define SENSE_SIZE 14 -#define INI_VENDOR_ID 0x1101 /* Initio's PCI vendor ID */ -#define DMX_VENDOR_ID 0x134a /* Domex's PCI vendor ID */ -#define I950_DEVICE_ID 0x9500 /* Initio's inic-950 product ID */ -#define I940_DEVICE_ID 0x9400 /* Initio's inic-940 product ID */ -#define I935_DEVICE_ID 0x9401 /* Initio's inic-935 product ID */ -#define I920_DEVICE_ID 0x0002 /* Initio's other product ID */ - -/************************************************************************/ -/* Vendor ID/Device ID Pair Structure */ -/************************************************************************/ -typedef struct PCI_ID_Struc { - unsigned short vendor_id; - unsigned short device_id; -} PCI_ID; +#define INI_VENDOR_ID 0x1101 /* Initio's PCI vendor ID */ +#define I950_DEVICE_ID 0x9500 /* Initio's inic-950 product ID */ +#define I940_DEVICE_ID 0x9400 /* Initio's inic-940 product ID */ +#define I935_DEVICE_ID 0x9401 /* Initio's inic-935 product ID */ +#define I920_DEVICE_ID 0x0002 /* Initio's other product ID */ /************************************************************************/ /* Scatter-Gather Element Structure */ /************************************************************************/ -typedef struct SG_Struc { - U32 SG_Ptr; /* Data Pointer */ - U32 SG_Len; /* Data Length */ +typedef struct SG_Struc { + U32 SG_Ptr; /* Data Pointer */ + U32 SG_Len; /* Data Length */ } SG; /*********************************************************************** SCSI Control Block ************************************************************************/ -typedef struct Scsi_Ctrl_Blk { - U32 SCB_InitioReserved[9]; /* 0 */ +typedef struct Scsi_Ctrl_Blk { + U32 SCB_InitioReserved[9]; /* 0 */ - UBYTE SCB_Opcode; /*24 SCB command code */ - UBYTE SCB_Flags; /*25 SCB Flags */ - UBYTE SCB_Target; /*26 Target Id */ - UBYTE SCB_Lun; /*27 Lun */ - U32 SCB_BufPtr; /*28 Data Buffer Pointer */ - U32 SCB_BufLen; /*2C Data Allocation Length */ - UBYTE SCB_SGLen; /*30 SG list # */ - UBYTE SCB_SenseLen; /*31 Sense Allocation Length */ - UBYTE SCB_HaStat; /*32 */ - UBYTE SCB_TaStat; /*33 */ - UBYTE SCB_CDBLen; /*34 CDB Length */ - UBYTE SCB_Ident; /*35 Identify */ - UBYTE SCB_TagMsg; /*36 Tag Message */ - UBYTE SCB_TagId; /*37 Queue Tag */ - UBYTE SCB_CDB[12]; /*38 */ - U32 SCB_SGPAddr; /*44 SG List/Sense Buf phy. Addr. */ - U32 SCB_SensePtr; /*48 Sense data pointer */ - void (*SCB_Post) (BYTE *, BYTE *); /*4C POST routine */ - Scsi_Cmnd *SCB_Srb; /*50 SRB Pointer */ - SG SCB_SGList[TOTAL_SG_ENTRY]; /*54 Start of SG list */ + UBYTE SCB_Opcode; /*24 SCB command code */ + UBYTE SCB_Flags; /*25 SCB Flags */ + UBYTE SCB_Target; /*26 Target Id */ + UBYTE SCB_Lun; /*27 Lun */ + U32 SCB_BufPtr; /*28 Data Buffer Pointer */ + U32 SCB_BufLen; /*2C Data Allocation Length */ + UBYTE SCB_SGLen; /*30 SG list # */ + UBYTE SCB_SenseLen; /*31 Sense Allocation Length */ + UBYTE SCB_HaStat; /*32 */ + UBYTE SCB_TaStat; /*33 */ + UBYTE SCB_CDBLen; /*34 CDB Length */ + UBYTE SCB_Ident; /*35 Identify */ + UBYTE SCB_TagMsg; /*36 Tag Message */ + UBYTE SCB_TagId; /*37 Queue Tag */ + UBYTE SCB_CDB[12]; /*38 */ + U32 SCB_SGPAddr; /*44 SG List/Sense Buf phy. Addr. */ + U32 SCB_SensePtr; /*48 Sense data pointer */ + void (* SCB_Post)(BYTE *, BYTE *); /*4C POST routine */ + Scsi_Cmnd *SCB_Srb; /*50 SRB Pointer */ + SG SCB_SGList[TOTAL_SG_ENTRY]; /*54 Start of SG list */ } SCB; /* Opcodes of SCB_Opcode */ @@ -299,11 +285,11 @@ typedef struct Scsi_Ctrl_Blk { **********************************************************************/ typedef struct Tar_Ctrl_Struc { - ULONG TCS_InitioReserved; /* 0 */ + ULONG TCS_InitioReserved; /* 0 */ - UWORD TCS_DrvFlags; /* 4 */ - UBYTE TCS_DrvHead; /* 6 */ - UBYTE TCS_DrvSector; /* 7 */ + UWORD TCS_DrvFlags; /* 4 */ + UBYTE TCS_DrvHead; /* 6 */ + UBYTE TCS_DrvSector; /* 7 */ } TCS; /*********************************************************************** @@ -316,30 +302,26 @@ typedef struct Tar_Ctrl_Struc { Host Adapter Control Structure ************************************************************************/ typedef struct Ha_Ctrl_Struc { - UWORD HCS_Base; /* 00 */ - UWORD HCS_BIOS; /* 02 */ - UBYTE HCS_Intr; /* 04 */ - UBYTE HCS_SCSI_ID; /* 05 */ - UBYTE HCS_MaxTar; /* 06 */ - UBYTE HCS_NumScbs; /* 07 */ + UWORD HCS_Base; /* 00 */ + UWORD HCS_BIOS; /* 02 */ + UBYTE HCS_Intr; /* 04 */ + UBYTE HCS_SCSI_ID; /* 05 */ + UBYTE HCS_MaxTar; /* 06 */ + UBYTE HCS_NumScbs; /* 07 */ - UBYTE HCS_Flags; /* 08 */ - UBYTE HCS_Index; /* 09 */ - UBYTE HCS_Reserved[2]; /* 0a */ - ULONG HCS_InitioReserved[27]; /* 0C */ - TCS HCS_Tcs[16]; /* 78 -> 16 Targets */ - Scsi_Cmnd *pSRB_head; /* SRB save queue header */ - Scsi_Cmnd *pSRB_tail; /* SRB save queue tail */ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spinlock_t HCS_AvailLock; - spinlock_t HCS_SemaphLock; - spinlock_t pSRB_lock; -#endif + UBYTE HCS_Flags; /* 08 */ + UBYTE HCS_Index; /* 09 */ + UBYTE HCS_Reserved[2]; /* 0a */ + ULONG HCS_InitioReserved[27]; /* 0C */ + + TCS HCS_Tcs[16]; /* 78 -> 16 Targets */ + Scsi_Cmnd *pSRB_head; /* SRB save queue header */ + Scsi_Cmnd *pSRB_tail; /* SRB save queue tail */ } HCS; /* Bit Definition for HCB_Flags */ #define HCF_EXPECT_RESET 0x10 /* SCSI related definition */ -#define DISC_NOT_ALLOW 0x80 /* Disconnect is not allowed */ -#define DISC_ALLOW 0xC0 /* Disconnect is allowed */ +#define DISC_NOT_ALLOW 0x80 /* Disconnect is not allowed */ +#define DISC_ALLOW 0xC0 /* Disconnect is allowed */ diff --git a/drivers/scsi/inia100.c b/drivers/scsi/inia100.c deleted file mode 100644 index ac0bf04b7168..000000000000 --- a/drivers/scsi/inia100.c +++ /dev/null @@ -1,953 +0,0 @@ -/************************************************************************** - * Initio A100 device driver for Linux. - * - * Copyright (c) 1994-1998 Initio Corporation - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * -------------------------------------------------------------------------- - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification, immediately at the beginning of the file. - * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * Where this Software is combined with software released under the terms of - * the GNU Public License ("GPL") and the terms of the GPL would require the - * combined work to also be released under the terms of the GPL, the terms - * and conditions of this License will apply in addition to those of the - * GPL with the exception of any terms or conditions of this License that - * conflict with, or are expressly prohibited by, the GPL. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - ************************************************************************** - * - * module: inia100.c - * DESCRIPTION: - * This is the Linux low-level SCSI driver for Initio INIA100 SCSI host - * adapters - * 09/24/98 hl - v1.02 initial production release. - * 12/19/98 bv - v1.02a Use spinlocks for 2.1.95 and up. - **************************************************************************/ - -#define CVT_LINUX_VERSION(V,P,S) (V * 65536 + P * 256 + S) - -#ifndef LINUX_VERSION_CODE -#include -#endif - -#ifdef MODULE -#include -#endif - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if LINUX_VERSION_CODE <= CVT_LINUX_VERSION(2,1,92) -#include -#endif -#include -#include -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,23) -#include -#endif -#include -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) -#include -#endif -#include "sd.h" -#include "scsi.h" -#include "hosts.h" -#include "inia100.h" -#include -#include -#include - - -#else - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include "../block/blk.h" -#include "scsi.h" -#include "sd.h" -#include "hosts.h" -#include -#include "inia100.h" -#endif - -#ifdef MODULE -Scsi_Host_Template driver_template = INIA100; -#include "scsi_module.c" -#endif - -#define ORC_RDWORD(x,y) (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) )) - -char *inia100_Copyright = "Copyright (C) 1998-99"; -char *inia100_InitioName = "by Initio Corporation"; -char *inia100_ProductName = "INI-A100U2W"; -char *inia100_Version = "v1.02a"; - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -struct proc_dir_entry proc_scsi_inia100 = -{ - PROC_SCSI_INIA100, 7, "INIA100", - S_IFDIR | S_IRUGO | S_IXUGO, 2, - 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL -}; -#endif - -/* set by inia100_setup according to the command line */ -static int setup_called = 0; -static int orc_num_ch = MAX_SUPPORTED_ADAPTERS; /* Maximum 4 adapters */ - -/* ---- INTERNAL VARIABLES ---- */ -#define NUMBER(arr) (sizeof(arr) / sizeof(arr[0])) -static char *setup_str = (char *) NULL; - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void inia100_intr0(int irq, void *dev_id, struct pt_regs *); -static void inia100_intr1(int irq, void *dev_id, struct pt_regs *); -static void inia100_intr2(int irq, void *dev_id, struct pt_regs *); -static void inia100_intr3(int irq, void *dev_id, struct pt_regs *); -static void inia100_intr4(int irq, void *dev_id, struct pt_regs *); -static void inia100_intr5(int irq, void *dev_id, struct pt_regs *); -static void inia100_intr6(int irq, void *dev_id, struct pt_regs *); -static void inia100_intr7(int irq, void *dev_id, struct pt_regs *); -#else -static void inia100_intr0(int irq, struct pt_regs *); -static void inia100_intr1(int irq, struct pt_regs *); -static void inia100_intr2(int irq, struct pt_regs *); -static void inia100_intr3(int irq, struct pt_regs *); -static void inia100_intr4(int irq, struct pt_regs *); -static void inia100_intr5(int irq, struct pt_regs *); -static void inia100_intr6(int irq, struct pt_regs *); -static void inia100_intr7(int irq, struct pt_regs *); -#endif - -static void inia100_panic(char *msg); -void inia100SCBPost(BYTE * pHcb, BYTE * pScb); - -/* ---- EXTERNAL VARIABLES ---- */ -extern int Addinia100_into_Adapter_table(WORD, WORD, BYTE, BYTE, BYTE); -extern void init_inia100Adapter_table(void); -extern ORC_SCB *orc_alloc_scb(ORC_HCS * hcsp); -extern void orc_exec_scb(ORC_HCS * hcsp, ORC_SCB * scbp); -extern void orc_release_scb(ORC_HCS * hcsp, ORC_SCB * scbp); -extern void orc_interrupt(ORC_HCS * hcsp); -extern int orc_device_reset(ORC_HCS * pHCB, ULONG SCpnt, unsigned int target, unsigned int ResetFlags); -extern int orc_reset_scsi_bus(ORC_HCS * pHCB); -extern int abort_SCB(ORC_HCS * hcsp, ORC_SCB * pScb); -extern int orc_abort_srb(ORC_HCS * hcsp, ULONG SCpnt); -extern void get_orcPCIConfig(ORC_HCS * pCurHcb, int ch_idx); -extern int init_orchid(ORC_HCS * hcsp); - -extern int orc_num_scb; -extern ORC_HCS orc_hcs[]; - -/***************************************************************************** - Function name : inia100AppendSRBToQueue - Description : This function will push current request into save list - Input : pSRB - Pointer to SCSI request block. - pHCB - Pointer to host adapter structure - Output : None. - Return : None. -*****************************************************************************/ -static void inia100AppendSRBToQueue(ORC_HCS * pHCB, Scsi_Cmnd * pSRB) -{ - ULONG flags; - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pHCB->pSRB_lock), flags); -#else - save_flags(flags); - cli(); -#endif - - pSRB->next = NULL; /* Pointer to next */ - if (pHCB->pSRB_head == NULL) - pHCB->pSRB_head = pSRB; - else - pHCB->pSRB_tail->next = pSRB; /* Pointer to next */ - pHCB->pSRB_tail = pSRB; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags); -#else - restore_flags(flags); -#endif - return; -} - -/***************************************************************************** - Function name : inia100PopSRBFromQueue - Description : This function will pop current request from save list - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -static Scsi_Cmnd *inia100PopSRBFromQueue(ORC_HCS * pHCB) -{ - Scsi_Cmnd *pSRB; - ULONG flags; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_lock_irqsave(&(pHCB->pSRB_lock), flags); -#else - save_flags(flags); - cli(); -#endif - - if ((pSRB = (Scsi_Cmnd *) pHCB->pSRB_head) != NULL) { - pHCB->pSRB_head = pHCB->pSRB_head->next; - pSRB->next = NULL; - } -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags); -#else - restore_flags(flags); -#endif - return (pSRB); -} - -/***************************************************************************** - Function name : inia100_setup - Description : - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -void inia100_setup(char *str, int *ints) -{ - if (setup_called) - inia100_panic("inia100: inia100_setup called twice.\n"); - - setup_called = ints[0]; - setup_str = str; -} - -/***************************************************************************** - Function name : orc_ReturnNumberOfAdapters - Description : This function will scan PCI bus to get all Orchid card - Input : None. - Output : None. - Return : SUCCESSFUL - Successful scan - ohterwise - No drives founded -*****************************************************************************/ -int orc_ReturnNumberOfAdapters(void) -{ - unsigned int i, iAdapters; - - iAdapters = 0; - /* - * PCI-bus probe. - */ - if (pcibios_present()) { - struct { - unsigned short vendor_id; - unsigned short device_id; - } const inia100_pci_devices[] = - { - {ORC_VENDOR_ID, I920_DEVICE_ID}, - {ORC_VENDOR_ID, ORC_DEVICE_ID} - }; - - unsigned int dRegValue; - unsigned short command; - WORD wBIOS, wBASE; - BYTE bPCIBusNum, bInterrupt, bPCIDeviceNum; - -#ifdef MMAPIO - unsigned long page_offset, base; -#endif - -#if LINUX_VERSION_CODE > CVT_LINUX_VERSION(2,1,92) - struct pci_dev *pdev = NULL; -#else - int index; - unsigned char pci_bus, pci_devfn; -#endif - - bPCIBusNum = 0; - bPCIDeviceNum = 0; - init_inia100Adapter_table(); - for (i = 0; i < NUMBER(inia100_pci_devices); i++) { -#if LINUX_VERSION_CODE > CVT_LINUX_VERSION(2,1,92) - pdev = NULL; - while ((pdev = pci_find_device(inia100_pci_devices[i].vendor_id, - inia100_pci_devices[i].device_id, - pdev))) -#else - index = 0; - while (!(pcibios_find_device(inia100_pci_devices[i].vendor_id, - inia100_pci_devices[i].device_id, - index++, &pci_bus, &pci_devfn))) -#endif - { - if (iAdapters >= MAX_SUPPORTED_ADAPTERS) - break; /* Never greater than maximum */ - - if (i == 0) { - /* - printk("inia100: The RAID controller is not supported by\n"); - printk("inia100: this driver, we are ignoring it.\n"); - */ - } else { - /* - * Read sundry information from PCI BIOS. - */ -#if LINUX_VERSION_CODE > CVT_LINUX_VERSION(2,1,92) - bPCIBusNum = pdev->bus->number; - bPCIDeviceNum = pdev->devfn; - dRegValue = pdev->base_address[0]; - if (dRegValue == -1) { /* Check return code */ - printk("\n\rinia100: orchid read configuration error.\n"); - return (0); /* Read configuration space error */ - } - /* <02> read from base address + 0x50 offset to get the wBIOS balue. */ - wBASE = (WORD) dRegValue; - - /* Now read the interrupt line */ - dRegValue = pdev->irq; - bInterrupt = dRegValue & 0xFF; /* Assign interrupt line */ - pci_read_config_word(pdev, PCI_COMMAND, &command); - pci_write_config_word(pdev, PCI_COMMAND, - command | PCI_COMMAND_MASTER | PCI_COMMAND_IO); - -#else - bPCIBusNum = pci_bus; - bPCIDeviceNum = pci_devfn; - pcibios_read_config_dword(pci_bus, pci_devfn, PCI_BASE_ADDRESS_0, - &dRegValue); - if (dRegValue == -1) { /* Check return code */ - printk("\n\rinia100: Orchid read configuration error.\n"); - return (0); /* Read configuration space error */ - } - /* <02> read from base address + 0x50 offset to get the wBIOS balue. */ - wBASE = (WORD) dRegValue; - - /* Now read the interrupt line */ - pcibios_read_config_dword(pci_bus, pci_devfn, PCI_INTERRUPT_LINE, - &dRegValue); - bInterrupt = dRegValue & 0xFF; /* Assign interrupt line */ - pcibios_read_config_word(pci_bus, pci_devfn, PCI_COMMAND, &command); - pcibios_write_config_word(pci_bus, pci_devfn, PCI_COMMAND, - command | PCI_COMMAND_MASTER | PCI_COMMAND_IO); -#endif - wBASE &= PCI_BASE_ADDRESS_IO_MASK; - wBIOS = ORC_RDWORD(wBASE, 0x50); - -#ifdef MMAPIO - base = wBASE & PAGE_MASK; - page_offset = wBASE - base; - - /* - * replace the next line with this one if you are using 2.1.x: - * temp_p->maddr = ioremap(base, page_offset + 256); - */ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,0) - wBASE = ioremap(base, page_offset + 256); -#else - wBASE = (WORD) vremap(base, page_offset + 256); -#endif - if (wBASE) { - wBASE += page_offset; - } -#endif - - if (Addinia100_into_Adapter_table(wBIOS, wBASE, bInterrupt, bPCIBusNum, - bPCIDeviceNum) == SUCCESSFUL) - iAdapters++; - } - } /* while(pdev=....) */ - } /* for PCI_DEVICES */ - } /* PCI BIOS present */ - return (iAdapters); -} - -/***************************************************************************** - Function name : inia100_detect - Description : - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -int inia100_detect(Scsi_Host_Template * tpnt) -{ - ORC_HCS *pHCB; - struct Scsi_Host *hreg; - U32 sz; - U32 i; /* 01/14/98 */ - int ok = 0, iAdapters; - ULONG dBiosAdr; - BYTE *pbBiosAdr; - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - tpnt->proc_dir = &proc_scsi_inia100; -#endif - if (setup_called) { - /* Setup by inia100_setup */ - printk("inia100: processing commandline: "); - } - /* Get total number of adapters in the motherboard */ - iAdapters = orc_ReturnNumberOfAdapters(); - - /* printk("inia100: Total Initio Adapters = %d\n", iAdapters); */ - if (iAdapters == 0) /* If no orc founded, return */ - return (0); - - orc_num_ch = (iAdapters > orc_num_ch) ? orc_num_ch : iAdapters; - orc_num_scb = ORC_MAXQUEUE; - - /* clear the memory needed for HCS */ - i = orc_num_ch * sizeof(ORC_HCS); - memset((unsigned char *) &orc_hcs[0], 0, i); /* Initialize orc_hcs 0 */ - -#if 0 - printk("orc_num_scb= %x orc_num_ch= %x hcsize= %x scbsize= %x escbsize= %x\n", - orc_num_scb, orc_num_ch, sizeof(ORC_HCS), sizeof(ORC_SCB), sizeof(ESCB)); -#endif - - for (i = 0, pHCB = &orc_hcs[0]; /* Get pointer for control block */ - i < orc_num_ch; - i++, pHCB++) { - - pHCB->pSRB_head = NULL; /* Initial SRB save queue */ - pHCB->pSRB_tail = NULL; /* Initial SRB save queue */ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - pHCB->pSRB_lock = SPIN_LOCK_UNLOCKED; /* SRB save queue lock */ -#endif - /* Get total memory needed for SCB */ - sz = orc_num_scb * sizeof(ORC_SCB); - if ((pHCB->HCS_virScbArray = (PVOID) kmalloc(sz, GFP_ATOMIC | GFP_DMA)) == NULL) { - printk("inia100: SCB memory allocation error\n"); - return (0); - } - memset((unsigned char *) pHCB->HCS_virScbArray, 0, sz); - pHCB->HCS_physScbArray = (U32) VIRT_TO_BUS(pHCB->HCS_virScbArray); - - /* Get total memory needed for ESCB */ - sz = orc_num_scb * sizeof(ESCB); - if ((pHCB->HCS_virEscbArray = (PVOID) kmalloc(sz, GFP_ATOMIC | GFP_DMA)) == NULL) { - printk("inia100: ESCB memory allocation error\n"); - return (0); - } - memset((unsigned char *) pHCB->HCS_virEscbArray, 0, sz); - pHCB->HCS_physEscbArray = (U32) VIRT_TO_BUS(pHCB->HCS_virEscbArray); - - request_region(pHCB->HCS_Base, 0x100, "inia100"); /* Register */ - get_orcPCIConfig(pHCB, i); - - dBiosAdr = pHCB->HCS_BIOS; - dBiosAdr = (dBiosAdr << 4); - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - pbBiosAdr = phys_to_virt(dBiosAdr); -#endif - - if (init_orchid(pHCB)) { /* Initial orchid chip */ - printk("inia100: initial orchid fail!!\n"); - return (0); - } - hreg = scsi_register(tpnt, sizeof(ORC_HCS)); - if (hreg == NULL) { - printk("Invalid scsi_register pointer.\n"); - } - hreg->io_port = pHCB->HCS_Base; - hreg->n_io_port = 0xff; - hreg->can_queue = orc_num_scb; /* 03/05/98 */ - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - hreg->unique_id = pHCB->HCS_Base; - hreg->max_id = pHCB->HCS_MaxTar; -#endif - - hreg->max_lun = 32; /* 10/21/97 */ -/* - hreg->max_lun = 8; - hreg->max_channel = 1; - */ - hreg->irq = pHCB->HCS_Intr; - hreg->this_id = pHCB->HCS_SCSI_ID; /* Assign HCS index */ - hreg->base = (UCHAR *) pHCB; - -#if 1 - hreg->sg_tablesize = TOTAL_SG_ENTRY; /* Maximun support is 32 */ -#else - hreg->sg_tablesize = SG_NONE; /* No SG */ -#endif - - /* Initial orc chip */ - switch (i) { -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - case 0: - ok = request_irq(pHCB->HCS_Intr, inia100_intr0, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); - break; - case 1: - ok = request_irq(pHCB->HCS_Intr, inia100_intr1, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); - break; - case 2: - ok = request_irq(pHCB->HCS_Intr, inia100_intr2, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); - break; - case 3: - ok = request_irq(pHCB->HCS_Intr, inia100_intr3, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); - break; - case 4: - ok = request_irq(pHCB->HCS_Intr, inia100_intr4, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); - break; - case 5: - ok = request_irq(pHCB->HCS_Intr, inia100_intr5, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); - break; - case 6: - ok = request_irq(pHCB->HCS_Intr, inia100_intr6, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); - break; - case 7: - ok = request_irq(pHCB->HCS_Intr, inia100_intr7, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); - break; - default: - inia100_panic("inia100: Too many host adapters\n"); - break; - } - - if (ok < 0) { - if (ok == -EINVAL) { - printk("inia100: bad IRQ %d.\n", pHCB->HCS_Intr); - printk(" Contact author.\n"); - } else { - if (ok == -EBUSY) - printk("inia100: IRQ %d already in use. Configure another.\n", pHCB->HCS_Intr); - else { - printk("\ninia100: Unexpected error code on requesting IRQ %d.\n", - pHCB->HCS_Intr); - printk(" Contact author.\n"); - } - } - inia100_panic("inia100: driver needs an IRQ.\n"); - } -#endif - } - - tpnt->this_id = -1; - tpnt->can_queue = 1; - return 1; -} - -/***************************************************************************** - Function name : inia100BuildSCB - Description : - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -static void inia100BuildSCB(ORC_HCS * pHCB, ORC_SCB * pSCB, Scsi_Cmnd * SCpnt) -{ /* Create corresponding SCB */ - struct scatterlist *pSrbSG; - ORC_SG *pSG; /* Pointer to SG list */ - int i; - U32 TotalLen; - ESCB *pEScb; - - pEScb = pSCB->SCB_EScb; - pEScb->SCB_Srb = SCpnt; - pSG = NULL; - - pSCB->SCB_Opcode = ORC_EXECSCSI; - pSCB->SCB_Flags = SCF_NO_DCHK; /* Clear done bit */ - pSCB->SCB_Target = SCpnt->target; - pSCB->SCB_Lun = SCpnt->lun; - pSCB->SCB_Reserved0 = 0; - pSCB->SCB_Reserved1 = 0; - pSCB->SCB_SGLen = 0; - - if ((pSCB->SCB_XferLen = (U32) SCpnt->request_bufflen)) { - pSG = (ORC_SG *) & pEScb->ESCB_SGList[0]; - if (SCpnt->use_sg) { - TotalLen = 0; - pSCB->SCB_SGLen = (U32) (SCpnt->use_sg * 8); - pSrbSG = (struct scatterlist *) SCpnt->request_buffer; - for (i = 0; i < SCpnt->use_sg; i++, pSG++, pSrbSG++) { -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - pSG->SG_Ptr = (U32) (VIRT_TO_BUS(pSrbSG->address)); -#else - pSG->SG_Ptr = (U32) pSrbSG->address; -#endif - pSG->SG_Len = (U32) pSrbSG->length; - TotalLen += (U32) pSrbSG->length; - } - } else { /* Non SG */ - pSCB->SCB_SGLen = 0x8; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) - pSG->SG_Ptr = (U32) (VIRT_TO_BUS(SCpnt->request_buffer)); -#else - pSG->SG_PTR = (U32) SCpnt->request_buffer; -#endif - pSG->SG_Len = (U32) SCpnt->request_bufflen; - } - } - pSCB->SCB_SGPAddr = (U32) pSCB->SCB_SensePAddr; - pSCB->SCB_HaStat = 0; - pSCB->SCB_TaStat = 0; - pSCB->SCB_Link = 0xFF; - pSCB->SCB_SenseLen = SENSE_SIZE; - pSCB->SCB_CDBLen = SCpnt->cmd_len; - if (pSCB->SCB_CDBLen >= IMAX_CDB) { - printk("max cdb length= %x\b", SCpnt->cmd_len); - pSCB->SCB_CDBLen = IMAX_CDB; - } - pSCB->SCB_Ident = SCpnt->lun | DISC_ALLOW; - if (SCpnt->device->tagged_supported) { /* Tag Support */ - pSCB->SCB_TagMsg = SIMPLE_QUEUE_TAG; /* Do simple tag only */ - } else { - pSCB->SCB_TagMsg = 0; /* No tag support */ - } - memcpy(&pSCB->SCB_CDB[0], &SCpnt->cmnd, pSCB->SCB_CDBLen); - return; -} - -/***************************************************************************** - Function name : inia100_queue - Description : Queue a command and setup interrupts for a free bus. - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -int inia100_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) -{ - register ORC_SCB *pSCB; - ORC_HCS *pHCB; /* Point to Host adapter control block */ - - if (SCpnt->lun > 16) { - SCpnt->result = (DID_TIME_OUT << 16); - done(SCpnt); /* Notify system DONE */ - return (0); - } - pHCB = (ORC_HCS *) SCpnt->host->base; - SCpnt->scsi_done = done; - /* Get free SCSI control block */ - if ((pSCB = orc_alloc_scb(pHCB)) == NULL) { - inia100AppendSRBToQueue(pHCB, SCpnt); /* Buffer this request */ - /* printk("inia100_entry: can't allocate SCB\n"); */ - return (0); - } - inia100BuildSCB(pHCB, pSCB, SCpnt); - orc_exec_scb(pHCB, pSCB); /* Start execute SCB */ - - return (0); -} - -/***************************************************************************** - Function name : inia100_command - Description : We only support command in interrupt-driven fashion - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -int inia100_command(Scsi_Cmnd * SCpnt) -{ - printk("inia100: interrupt driven driver; use inia100_queue()\n"); - return -1; -} - -/***************************************************************************** - Function name : inia100_abort - Description : Abort a queued command. - (commands that are on the bus can't be aborted easily) - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -int inia100_abort(Scsi_Cmnd * SCpnt) -{ - ORC_HCS *hcsp; - - hcsp = (ORC_HCS *) SCpnt->host->base; - return orc_abort_srb(hcsp, (ULONG) SCpnt); -} - -/***************************************************************************** - Function name : inia100_reset - Description : Reset registers, reset a hanging bus and - kill active and disconnected commands for target w/o soft reset - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -int inia100_reset(Scsi_Cmnd * SCpnt, unsigned int reset_flags) -{ /* I need Host Control Block Information */ - ORC_HCS *pHCB; - pHCB = (ORC_HCS *) SCpnt->host->base; - - if (reset_flags & (SCSI_RESET_SUGGEST_BUS_RESET | SCSI_RESET_SUGGEST_HOST_RESET)) - return orc_reset_scsi_bus(pHCB); - else - return orc_device_reset(pHCB, (ULONG) SCpnt, SCpnt->target, reset_flags); - -} - -/***************************************************************************** - Function name : inia100SCBPost - Description : This is callback routine be called when orc finish one - SCSI command. - Input : pHCB - Pointer to host adapter control block. - pSCB - Pointer to SCSI control block. - Output : None. - Return : None. -*****************************************************************************/ -void inia100SCBPost(BYTE * pHcb, BYTE * pScb) -{ - Scsi_Cmnd *pSRB; /* Pointer to SCSI request block */ - ORC_HCS *pHCB; - ORC_SCB *pSCB; - ESCB *pEScb; - - pHCB = (ORC_HCS *) pHcb; - pSCB = (ORC_SCB *) pScb; - pEScb = pSCB->SCB_EScb; - if ((pSRB = (Scsi_Cmnd *) pEScb->SCB_Srb) == 0) { - printk("inia100SCBPost: SRB pointer is empty\n"); - orc_release_scb(pHCB, pSCB); /* Release SCB for current channel */ - return; - } - pEScb->SCB_Srb = NULL; - - switch (pSCB->SCB_HaStat) { - case 0x0: - case 0xa: /* Linked command complete without error and linked normally */ - case 0xb: /* Linked command complete without error interrupt generated */ - pSCB->SCB_HaStat = 0; - break; - - case 0x11: /* Selection time out-The initiator selection or target - reselection was not complete within the SCSI Time out period */ - pSCB->SCB_HaStat = DID_TIME_OUT; - break; - - case 0x14: /* Target bus phase sequence failure-An invalid bus phase or bus - phase sequence was requested by the target. The host adapter - will generate a SCSI Reset Condition, notifying the host with - a SCRD interrupt */ - pSCB->SCB_HaStat = DID_RESET; - break; - - case 0x1a: /* SCB Aborted. 07/21/98 */ - pSCB->SCB_HaStat = DID_ABORT; - break; - - case 0x12: /* Data overrun/underrun-The target attempted to transfer more data - than was allocated by the Data Length field or the sum of the - Scatter / Gather Data Length fields. */ - case 0x13: /* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */ - case 0x16: /* Invalid CCB Operation Code-The first byte of the CCB was invalid. */ - - default: - printk("inia100: %x %x\n", pSCB->SCB_HaStat, pSCB->SCB_TaStat); - pSCB->SCB_HaStat = DID_ERROR; /* Couldn't find any better */ - break; - } - - if (pSCB->SCB_TaStat == 2) { /* Check condition */ - memcpy((unsigned char *) &pSRB->sense_buffer[0], - (unsigned char *) &pEScb->ESCB_SGList[0], SENSE_SIZE); - } - pSRB->result = pSCB->SCB_TaStat | (pSCB->SCB_HaStat << 16); - pSRB->scsi_done(pSRB); /* Notify system DONE */ - - /* Find the next pending SRB */ - if ((pSRB = inia100PopSRBFromQueue(pHCB)) != NULL) { /* Assume resend will success */ - /* Reuse old SCB */ - inia100BuildSCB(pHCB, pSCB, pSRB); /* Create corresponding SCB */ - orc_exec_scb(pHCB, pSCB); /* Start execute SCB */ - } else { /* No Pending SRB */ - orc_release_scb(pHCB, pSCB); /* Release SCB for current channel */ - } - return; -} - -/***************************************************************************** - Function name : inia100_biosparam - Description : Return the "logical geometry" - Input : pHCB - Pointer to host adapter structure - Output : None. - Return : pSRB - Pointer to SCSI request block. -*****************************************************************************/ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -int inia100_biosparam(Scsi_Disk * disk, kdev_t dev, int *info_array) -#else -int inia100_biosparam(Scsi_Disk * disk, int dev, int *info_array) -#endif -{ - ORC_HCS *pHcb; /* Point to Host adapter control block */ - ORC_TCS *pTcb; - - pHcb = (ORC_HCS *) disk->device->host->base; - pTcb = &pHcb->HCS_Tcs[disk->device->id]; - - if (pTcb->TCS_DrvHead) { - info_array[0] = pTcb->TCS_DrvHead; - info_array[1] = pTcb->TCS_DrvSector; - info_array[2] = disk->capacity / pTcb->TCS_DrvHead / pTcb->TCS_DrvSector; - } else { - if (pTcb->TCS_DrvFlags & TCF_DRV_255_63) { - info_array[0] = 255; - info_array[1] = 63; - info_array[2] = disk->capacity / 255 / 63; - } else { - info_array[0] = 64; - info_array[1] = 32; - info_array[2] = disk->capacity >> 11; - } - } - return 0; -} - - -static void subIntr(ORC_HCS * pHCB, int irqno) -{ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - unsigned long flags; - - spin_lock_irqsave(&io_request_lock, flags); -#endif - - if (pHCB->HCS_Intr != irqno) { -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&io_request_lock, flags); -#endif - return; - } - orc_interrupt(pHCB); - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spin_unlock_irqrestore(&io_request_lock, flags); -#endif -} - -/* - * Interrupts handler (main routine of the driver) - */ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void inia100_intr0(int irqno, void *dev_id, struct pt_regs *regs) -#else -static void inia100_intr0(int irqno, struct pt_regs *regs) -#endif -{ - subIntr(&orc_hcs[0], irqno); -} - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void inia100_intr1(int irqno, void *dev_id, struct pt_regs *regs) -#else -static void inia100_intr1(int irqno, struct pt_regs *regs) -#endif -{ - subIntr(&orc_hcs[1], irqno); -} - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void inia100_intr2(int irqno, void *dev_id, struct pt_regs *regs) -#else -static void inia100_intr2(int irqno, struct pt_regs *regs) -#endif -{ - subIntr(&orc_hcs[2], irqno); -} - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void inia100_intr3(int irqno, void *dev_id, struct pt_regs *regs) -#else -static void inia100_intr3(int irqno, struct pt_regs *regs) -#endif -{ - subIntr(&orc_hcs[3], irqno); -} - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void inia100_intr4(int irqno, void *dev_id, struct pt_regs *regs) -#else -static void inia100_intr4(int irqno, struct pt_regs *regs) -#endif -{ - subIntr(&orc_hcs[4], irqno); -} - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void inia100_intr5(int irqno, void *dev_id, struct pt_regs *regs) -#else -static void inia100_intr5(int irqno, struct pt_regs *regs) -#endif -{ - subIntr(&orc_hcs[5], irqno); -} - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void inia100_intr6(int irqno, void *dev_id, struct pt_regs *regs) -#else -static void inia100_intr6(int irqno, struct pt_regs *regs) -#endif -{ - subIntr(&orc_hcs[6], irqno); -} - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) -static void inia100_intr7(int irqno, void *dev_id, struct pt_regs *regs) -#else -static void inia100_intr7(int irqno, struct pt_regs *regs) -#endif -{ - subIntr(&orc_hcs[7], irqno); -} - -/* - * Dump the current driver status and panic... - */ -static void inia100_panic(char *msg) -{ - printk("\ninia100_panic: %s\n", msg); - panic("inia100 panic"); -} - -/*#include "inia100scsi.c" */ diff --git a/drivers/scsi/inia100.h b/drivers/scsi/inia100.h deleted file mode 100644 index e269ea7bcc68..000000000000 --- a/drivers/scsi/inia100.h +++ /dev/null @@ -1,503 +0,0 @@ -/************************************************************************** - * Initio A100 device driver for Linux. - * - * Copyright (c) 1994-1998 Initio Corporation - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * -------------------------------------------------------------------------- - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification, immediately at the beginning of the file. - * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * Where this Software is combined with software released under the terms of - * the GNU Public License ("GPL") and the terms of the GPL would require the - * combined work to also be released under the terms of the GPL, the terms - * and conditions of this License will apply in addition to those of the - * GPL with the exception of any terms or conditions of this License that - * conflict with, or are expressly prohibited by, the GPL. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - ************************************************************************** - * - * Module: inia100.h - * Description: INI-A100U2W LINUX device driver header - * Revision History: - * 06/18/98 HL, Initial production Version 1.02 - * 12/19/98 bv, Use spinlocks for 2.1.95 and up - ****************************************************************************/ - -#ifndef CVT_LINUX_VERSION -#define CVT_LINUX_VERSION(V,P,S) (((V) * 65536) + ((P) * 256) + (S)) -#endif - -#ifndef LINUX_VERSION_CODE -#include -#endif - -#include "sd.h" - -extern int inia100_detect(Scsi_Host_Template *); -extern int inia100_command(Scsi_Cmnd *); -extern int inia100_queue(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *)); -extern int inia100_abort(Scsi_Cmnd *); -extern int inia100_reset(Scsi_Cmnd *, unsigned int); - -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1, 3, 0) -extern int inia100_biosparam(Scsi_Disk *, kdev_t, int *); /*for linux v2.0 */ -extern struct proc_dir_entry proc_scsi_inia100; -#else -extern int inia100_biosparam(Disk *, int, int *); /*for linux v1.13 */ -#endif - -#define inia100_REVID "Initio INI-A100U2W SCSI device driver; Revision: 1.02a" - -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(1, 3, 0) -#define INIA100 { \ - NULL, \ - NULL, \ - inia100_REVID, \ - inia100_detect, \ - NULL, \ - NULL, \ - inia100_command, \ - inia100_queue, \ - inia100_abort, \ - inia100_reset, \ - NULL, \ - inia100_biosparam, \ - 1, \ -7, \ -SG_ALL, \ -1, \ -0, \ -0, \ -ENABLE_CLUSTERING \ -} - -#else - -#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2, 1, 75) -#define INIA100 { \ - NULL, \ - NULL, \ - &proc_scsi_inia100, \ - NULL, \ - inia100_REVID, \ - inia100_detect, \ - NULL, \ - NULL, \ - inia100_command, \ - inia100_queue, \ - inia100_abort, \ - inia100_reset, \ - NULL, \ - inia100_biosparam, \ - 1, \ - 7, \ - 0, \ - 1, \ - 0, \ - 0, \ - ENABLE_CLUSTERING \ -} -#else /* Version >= 2.1.75 */ -#define INIA100 { \ - next: NULL, \ - module: NULL, \ - proc_dir: &proc_scsi_inia100, \ - proc_info: NULL, \ - name: inia100_REVID, \ - detect: inia100_detect, \ - release: NULL, \ - info: NULL, \ - command: inia100_command, \ - queuecommand: inia100_queue, \ - eh_strategy_handler: NULL, \ - eh_abort_handler: NULL, \ - eh_device_reset_handler: NULL, \ - eh_bus_reset_handler: NULL, \ - eh_host_reset_handler: NULL, \ - abort: inia100_abort, \ - reset: inia100_reset, \ - slave_attach: NULL, \ - bios_param: inia100_biosparam, \ - can_queue: 1, \ - this_id: 1, \ - sg_tablesize: SG_ALL, \ - cmd_per_lun: 1, \ - present: 0, \ - unchecked_isa_dma: 0, \ - use_clustering: ENABLE_CLUSTERING, \ - use_new_eh_code: 0 \ -} -#endif -#endif - -#define VIRT_TO_BUS(i) (unsigned int) virt_to_bus((void *)(i)) -#define ULONG unsigned long -#define PVOID void * -#define USHORT unsigned short -#define UCHAR unsigned char -#define BYTE unsigned char -#define WORD unsigned short -#define DWORD unsigned long -#define UBYTE unsigned char -#define UWORD unsigned short -#define UDWORD unsigned long -#ifdef ALPHA -#define U32 unsigned int -#else -#define U32 unsigned long -#endif - -#ifndef NULL -#define NULL 0 /* zero */ -#endif -#ifndef TRUE -#define TRUE (1) /* boolean true */ -#endif -#ifndef FALSE -#define FALSE (0) /* boolean false */ -#endif -#ifndef FAILURE -#define FAILURE (-1) -#endif -#if 1 -#define ORC_MAXQUEUE 245 -#else -#define ORC_MAXQUEUE 25 -#endif - -#define TOTAL_SG_ENTRY 32 -#define MAX_TARGETS 16 -#define IMAX_CDB 15 -#define SENSE_SIZE 14 -#define MAX_SUPPORTED_ADAPTERS 4 -#define SUCCESSFUL 0x00 - -#define I920_DEVICE_ID 0x0002 /* Initio's inic-950 product ID */ - -/************************************************************************/ -/* Scatter-Gather Element Structure */ -/************************************************************************/ -typedef struct ORC_SG_Struc { - U32 SG_Ptr; /* Data Pointer */ - U32 SG_Len; /* Data Length */ -} ORC_SG; - - -/* SCSI related definition */ -#define DISC_NOT_ALLOW 0x80 /* Disconnect is not allowed */ -#define DISC_ALLOW 0xC0 /* Disconnect is allowed */ - - -#define ORC_OFFSET_SCB 16 -#define ORC_MAX_SCBS 250 -#define MAX_CHANNELS 2 -#define MAX_ESCB_ELE 64 -#define TCF_DRV_255_63 0x0400 - -/********************************************************/ -/* Orchid Configuration Register Set */ -/********************************************************/ -#define ORC_PVID 0x00 /* Vendor ID */ -#define ORC_VENDOR_ID 0x1101 /* Orchid vendor ID */ -#define ORC_PDID 0x02 /* Device ID */ -#define ORC_DEVICE_ID 0x1060 /* Orchid device ID */ -#define ORC_COMMAND 0x04 /* Command */ -#define BUSMS 0x04 /* BUS MASTER Enable */ -#define IOSPA 0x01 /* IO Space Enable */ -#define ORC_STATUS 0x06 /* Status register */ -#define ORC_REVISION 0x08 /* Revision number */ -#define ORC_BASE 0x10 /* Base address */ -#define ORC_BIOS 0x50 /* Expansion ROM base address */ -#define ORC_INT_NUM 0x3C /* Interrupt line */ -#define ORC_INT_PIN 0x3D /* Interrupt pin */ - -/********************************************************/ -/* Orchid Host Command Set */ -/********************************************************/ -#define ORC_CMD_NOP 0x00 /* Host command - NOP */ -#define ORC_CMD_VERSION 0x01 /* Host command - Get F/W version */ -#define ORC_CMD_ECHO 0x02 /* Host command - ECHO */ -#define ORC_CMD_SET_NVM 0x03 /* Host command - Set NVRAM */ -#define ORC_CMD_GET_NVM 0x04 /* Host command - Get NVRAM */ -#define ORC_CMD_GET_BUS_STATUS 0x05 /* Host command - Get SCSI bus status */ -#define ORC_CMD_ABORT_SCB 0x06 /* Host command - Abort SCB */ -#define ORC_CMD_ISSUE_SCB 0x07 /* Host command - Issue SCB */ - -/********************************************************/ -/* Orchid Register Set */ -/********************************************************/ -#define ORC_GINTS 0xA0 /* Global Interrupt Status */ -#define QINT 0x04 /* Reply Queue Interrupt */ -#define ORC_GIMSK 0xA1 /* Global Interrupt MASK */ -#define MQINT 0x04 /* Mask Reply Queue Interrupt */ -#define ORC_GCFG 0xA2 /* Global Configure */ -#define EEPRG 0x01 /* Enable EEPROM programming */ -#define ORC_GSTAT 0xA3 /* Global status */ -#define WIDEBUS 0x10 /* Wide SCSI Devices connected */ -#define ORC_HDATA 0xA4 /* Host Data */ -#define ORC_HCTRL 0xA5 /* Host Control */ -#define SCSIRST 0x80 /* SCSI bus reset */ -#define HDO 0x40 /* Host data out */ -#define HOSTSTOP 0x02 /* Host stop RISC engine */ -#define DEVRST 0x01 /* Device reset */ -#define ORC_HSTUS 0xA6 /* Host Status */ -#define HDI 0x02 /* Host data in */ -#define RREADY 0x01 /* RISC engine is ready to receive */ -#define ORC_NVRAM 0xA7 /* Nvram port address */ -#define SE2CS 0x008 -#define SE2CLK 0x004 -#define SE2DO 0x002 -#define SE2DI 0x001 -#define ORC_PQUEUE 0xA8 /* Posting queue FIFO */ -#define ORC_PQCNT 0xA9 /* Posting queue FIFO Cnt */ -#define ORC_RQUEUE 0xAA /* Reply queue FIFO */ -#define ORC_RQUEUECNT 0xAB /* Reply queue FIFO Cnt */ -#define ORC_FWBASEADR 0xAC /* Firmware base address */ - -#define ORC_EBIOSADR0 0xB0 /* External Bios address */ -#define ORC_EBIOSADR1 0xB1 /* External Bios address */ -#define ORC_EBIOSADR2 0xB2 /* External Bios address */ -#define ORC_EBIOSDATA 0xB3 /* External Bios address */ - -#define ORC_SCBSIZE 0xB7 /* SCB size register */ -#define ORC_SCBBASE0 0xB8 /* SCB base address 0 */ -#define ORC_SCBBASE1 0xBC /* SCB base address 1 */ - -#define ORC_RISCCTL 0xE0 /* RISC Control */ -#define PRGMRST 0x002 -#define DOWNLOAD 0x001 -#define ORC_PRGMCTR0 0xE2 /* RISC program counter */ -#define ORC_PRGMCTR1 0xE3 /* RISC program counter */ -#define ORC_RISCRAM 0xEC /* RISC RAM data port 4 bytes */ - -typedef struct orc_extended_scb { /* Extended SCB */ - ORC_SG ESCB_SGList[TOTAL_SG_ENTRY]; /*0 Start of SG list */ - Scsi_Cmnd *SCB_Srb; /*50 SRB Pointer */ -} ESCB; - -/*********************************************************************** - SCSI Control Block -************************************************************************/ -typedef struct orc_scb { /* Scsi_Ctrl_Blk */ - UBYTE SCB_Opcode; /*00 SCB command code&residual */ - UBYTE SCB_Flags; /*01 SCB Flags */ - UBYTE SCB_Target; /*02 Target Id */ - UBYTE SCB_Lun; /*03 Lun */ - U32 SCB_Reserved0; /*04 Reserved for ORCHID must 0 */ - U32 SCB_XferLen; /*08 Data Transfer Length */ - U32 SCB_Reserved1; /*0C Reserved for ORCHID must 0 */ - U32 SCB_SGLen; /*10 SG list # * 8 */ - U32 SCB_SGPAddr; /*14 SG List Buf physical Addr */ - U32 SCB_SGPAddrHigh; /*18 SG Buffer high physical Addr */ - UBYTE SCB_HaStat; /*1C Host Status */ - UBYTE SCB_TaStat; /*1D Target Status */ - UBYTE SCB_Status; /*1E SCB status */ - UBYTE SCB_Link; /*1F Link pointer, default 0xFF */ - UBYTE SCB_SenseLen; /*20 Sense Allocation Length */ - UBYTE SCB_CDBLen; /*21 CDB Length */ - UBYTE SCB_Ident; /*22 Identify */ - UBYTE SCB_TagMsg; /*23 Tag Message */ - UBYTE SCB_CDB[IMAX_CDB]; /*24 SCSI CDBs */ - UBYTE SCB_ScbIdx; /*3C Index for this ORCSCB */ - U32 SCB_SensePAddr; /*34 Sense Buffer physical Addr */ - - ESCB *SCB_EScb; /*38 Extended SCB Pointer */ -#ifndef ALPHA - UBYTE SCB_Reserved2[4]; /*3E Reserved for Driver use */ -#endif -} ORC_SCB; - -/* Opcodes of ORCSCB_Opcode */ -#define ORC_EXECSCSI 0x00 /* SCSI initiator command with residual */ -#define ORC_BUSDEVRST 0x01 /* SCSI Bus Device Reset */ - -/* Status of ORCSCB_Status */ -#define SCB_COMPLETE 0x00 /* SCB request completed */ -#define SCB_POST 0x01 /* SCB is posted by the HOST */ - -/* Bit Definition for ORCSCB_Flags */ -#define SCF_DISINT 0x01 /* Disable HOST interrupt */ -#define SCF_DIR 0x18 /* Direction bits */ -#define SCF_NO_DCHK 0x00 /* Direction determined by SCSI */ -#define SCF_DIN 0x08 /* From Target to Initiator */ -#define SCF_DOUT 0x10 /* From Initiator to Target */ -#define SCF_NO_XF 0x18 /* No data transfer */ -#define SCF_POLL 0x40 - -/* Error Codes for ORCSCB_HaStat */ -#define HOST_SEL_TOUT 0x11 -#define HOST_DO_DU 0x12 -#define HOST_BUS_FREE 0x13 -#define HOST_BAD_PHAS 0x14 -#define HOST_INV_CMD 0x16 -#define HOST_SCSI_RST 0x1B -#define HOST_DEV_RST 0x1C - - -/* Error Codes for ORCSCB_TaStat */ -#define TARGET_CHK_COND 0x02 -#define TARGET_BUSY 0x08 -#define TARGET_TAG_FULL 0x28 - - -/* Queue tag msg: Simple_quque_tag, Head_of_queue_tag, Ordered_queue_tag */ -#define MSG_STAG 0x20 -#define MSG_HTAG 0x21 -#define MSG_OTAG 0x22 - -#define MSG_IGNOREWIDE 0x23 - -#define MSG_IDENT 0x80 -#define MSG_DISC 0x40 /* Disconnect allowed */ - - -/* SCSI MESSAGE */ -#define MSG_EXTEND 0x01 -#define MSG_SDP 0x02 -#define MSG_ABORT 0x06 -#define MSG_REJ 0x07 -#define MSG_NOP 0x08 -#define MSG_PARITY 0x09 -#define MSG_DEVRST 0x0C -#define MSG_STAG 0x20 - -/*********************************************************************** - Target Device Control Structure -**********************************************************************/ - -typedef struct ORC_Tar_Ctrl_Struc { - UBYTE TCS_DrvDASD; /* 6 */ - UBYTE TCS_DrvSCSI; /* 7 */ - UBYTE TCS_DrvHead; /* 8 */ - UWORD TCS_DrvFlags; /* 4 */ - UBYTE TCS_DrvSector; /* 7 */ -} ORC_TCS, *PORC_TCS; - -/* Bit Definition for TCF_DrvFlags */ -#define TCS_DF_NODASD_SUPT 0x20 /* Suppress OS/2 DASD Mgr support */ -#define TCS_DF_NOSCSI_SUPT 0x40 /* Suppress OS/2 SCSI Mgr support */ - - -/*********************************************************************** - Host Adapter Control Structure -************************************************************************/ -typedef struct ORC_Ha_Ctrl_Struc { - USHORT HCS_Base; /* 00 */ - UBYTE HCS_Index; /* 02 */ - UBYTE HCS_Intr; /* 04 */ - UBYTE HCS_SCSI_ID; /* 06 H/A SCSI ID */ - UBYTE HCS_BIOS; /* 07 BIOS configuration */ - - UBYTE HCS_Flags; /* 0B */ - UBYTE HCS_HAConfig1; /* 1B SCSI0MAXTags */ - UBYTE HCS_MaxTar; /* 1B SCSI0MAXTags */ - - USHORT HCS_Units; /* Number of units this adapter */ - USHORT HCS_AFlags; /* Adapter info. defined flags */ - ULONG HCS_Timeout; /* Adapter timeout value */ - PVOID HCS_virScbArray; /* 28 Virtual Pointer to SCB array */ - U32 HCS_physScbArray; /* Scb Physical address */ - PVOID HCS_virEscbArray; /* Virtual pointer to ESCB Scatter list */ - U32 HCS_physEscbArray; /* scatter list Physical address */ - UBYTE TargetFlag[16]; /* 30 target configuration, TCF_EN_TAG */ - UBYTE MaximumTags[16]; /* 40 ORC_MAX_SCBS */ - UBYTE ActiveTags[16][16]; /* 50 */ - ORC_TCS HCS_Tcs[16]; /* 28 */ - U32 BitAllocFlag[MAX_CHANNELS][8]; /* Max STB is 256, So 256/32 */ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spinlock_t BitAllocFlagLock; -#endif - Scsi_Cmnd *pSRB_head; - Scsi_Cmnd *pSRB_tail; -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) - spinlock_t pSRB_lock; -#endif -} ORC_HCS; - -/* Bit Definition for HCS_Flags */ - -#define HCF_SCSI_RESET 0x01 /* SCSI BUS RESET */ -#define HCF_PARITY 0x02 /* parity card */ -#define HCF_LVDS 0x10 /* parity card */ - -/* Bit Definition for TargetFlag */ - -#define TCF_EN_255 0x08 -#define TCF_EN_TAG 0x10 -#define TCF_BUSY 0x20 -#define TCF_DISCONNECT 0x40 -#define TCF_SPIN_UP 0x80 - -/* Bit Definition for HCS_AFlags */ -#define HCS_AF_IGNORE 0x01 /* Adapter ignore */ -#define HCS_AF_DISABLE_RESET 0x10 /* Adapter disable reset */ -#define HCS_AF_DISABLE_ADPT 0x80 /* Adapter disable */ - - -/*---------------------------------------*/ -/* TimeOut for RESET to complete (30s) */ -/* */ -/* After a RESET the drive is checked */ -/* every 200ms. */ -/*---------------------------------------*/ -#define DELAYED_RESET_MAX (30*1000L) -#define DELAYED_RESET_INTERVAL 200L - -/*----------------------------------------------*/ -/* TimeOut for IRQ from last interrupt (5s) */ -/*----------------------------------------------*/ -#define IRQ_TIMEOUT_INTERVAL (5*1000L) - -/*----------------------------------------------*/ -/* Retry Delay interval (200ms) */ -/*----------------------------------------------*/ -#define DELAYED_RETRY_INTERVAL 200L - -#define INQUIRY_SIZE 36 -#define CAPACITY_SIZE 8 -#define DEFAULT_SENSE_LEN 14 - -#define DEVICE_NOT_FOUND 0x86 - -/*----------------------------------------------*/ -/* Definition for PCI device */ -/*----------------------------------------------*/ -#define MAX_PCI_DEVICES 21 -#define MAX_PCI_BUSES 8 diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 6802dcc88b2d..c375e0a3f1b1 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -1,27 +1,24 @@ /*=================================================================== * * Linux MegaRAID device driver - * + * * Copyright 1998 American Megatrends Inc. * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the 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.93 + * Version : 0.92 * * Description: Linux device driver for AMI MegaRAID controller * - * Supported controllers: MegaRAID 418, 428, 438, 466 - * - * Maintainer: Jeff L Jones - * * History: * * Version 0.90: - * Original source contributed by Dell; integrated it into the kernel and - * cleaned up some things. Added support for 438/466 controllers. + * Works and has been tested with the MegaRAID 428 controller, and + * the MegaRAID 438 controller. Probably works with the 466 also, + * but not tested. * * Version 0.91: * Aligned mailbox area on 16-byte boundry. @@ -38,33 +35,28 @@ * Removed setting of SA_INTERRUPT flag when requesting Irq. * * Version 0.92ac: - * Small changes to the comments/formatting. Plus a couple of - * added notes. Returned to the authors. No actual code changes - * save printk levels. - * 8 Oct 98 Alan Cox - * - * Merged with 2.1.131 source tree. - * 12 Dec 98 K. Baranowski - * - * Version 0.93: - * Added support for vendor specific ioctl commands (0x80+xxh) - * Changed some fields in MEGARAID struct to better values. - * Added signature check for Rp controllers under 2.0 kernels - * Changed busy-wait loop to be time-based - * Fixed SMP race condition in isr - * Added kfree (sgList) on release - * Added #include linux/version.h to megaraid.h for hosts.h - * Changed max_id to represent max logical drives instead of targets. - * + * Small changes to the comments/formatting. Plus a couple of + * added notes. Returned to the authors. No actual code changes + * save printk levels. + * 8 Oct 98 Alan Cox * * BUGS: - * Some older 2.1 kernels (eg. 2.1.90) have a bug in pci.c that - * fails to detect the controller as a pci device on the system. + * Tested with 2.1.90, but unfortunately there is a bug in pci.c which + * fails to detect our controller. Does work with 2.1.118--don't know + * which kernel in between it was fixed in. + * With SMP enabled under 2.1.118 with more than one processor, gets an + * error message "scsi_end_request: buffer-list destroyed" under heavy + * IO, but doesn't seem to affect operation, or data integrity. The + * message doesn't occur without SMP enabled, or with one proccessor with + * SMP enabled, or under any combination under 2.0 kernels. * *===================================================================*/ +#define QISR 1 #define CRLFSTR "\n" +#define MULTIQ 1 + #include #include @@ -74,8 +66,10 @@ #if LINUX_VERSION_CODE >= 0x20100 char kernel_version[] = UTS_RELEASE; -MODULE_AUTHOR ("American Megatrends Inc."); -MODULE_DESCRIPTION ("AMI MegaRAID driver"); +/* originally ported by Dell Corporation; updated, released, and maintained by + American Megatrends */ +MODULE_AUTHOR("American Megatrends Inc."); +MODULE_DESCRIPTION("AMI MegaRAID driver"); #endif #endif @@ -113,21 +107,18 @@ MODULE_DESCRIPTION ("AMI MegaRAID driver"); #include "megaraid.h" -//================================================================ -// -// #Defines -// -//================================================================ +/*================================================================ + * + * #Defines + * + *================================================================*/ #if LINUX_VERSION_CODE < 0x020100 #define ioremap vremap #define iounmap vfree /* simulate spin locks */ -typedef struct { - volatile char lock; -} spinlock_t; - +typedef struct {volatile char lock;} spinlock_t; #define spin_lock_init(x) { (x)->lock = 0;} #define spin_lock_irqsave(x,flags) { while ((x)->lock) barrier();\ (x)->lock=1; save_flags(flags);\ @@ -162,124 +153,125 @@ typedef struct { spin_unlock_irqrestore(&mega_lock,cpuflag);\ }; -u_long RDINDOOR (mega_host_config * megaCfg) +u_long RDINDOOR(mega_host_config *megaCfg) { - return readl (megaCfg->base + 0x20); + return readl(megaCfg->base + 0x20); } -void WRINDOOR (mega_host_config * megaCfg, u_long value) +void WRINDOOR(mega_host_config *megaCfg, u_long value) { - writel (value, megaCfg->base + 0x20); + writel(value,megaCfg->base+0x20); } -u_long RDOUTDOOR (mega_host_config * megaCfg) +u_long RDOUTDOOR(mega_host_config *megaCfg) { - return readl (megaCfg->base + 0x2C); + return readl(megaCfg->base+0x2C); } -void WROUTDOOR (mega_host_config * megaCfg, u_long value) +void WROUTDOOR(mega_host_config *megaCfg, u_long value) { - writel (value, megaCfg->base + 0x2C); + writel(value,megaCfg->base+0x2C); } -//================================================================ -// -// Function prototypes -// -//================================================================ -static int MegaIssueCmd (mega_host_config * megaCfg, - u_char * mboxData, - mega_scb * scb, +/*================================================================ + * + * Function prototypes + * + *================================================================*/ +static int MegaIssueCmd(mega_host_config *megaCfg, + u_char *mboxData, + mega_scb *scb, int intr); -static int build_sglist (mega_host_config * megaCfg, mega_scb * scb, - u_long * buffer, u_long * length); +static int build_sglist(mega_host_config *megaCfg, mega_scb *scb, + u_long *buffer, u_long *length); -static void mega_runque (void *); -static void mega_rundoneq (void); -static void mega_cmd_done (mega_host_config *, mega_scb *, int); -static mega_scb *mega_ioctl (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt); +static void mega_runque(void *); +static void mega_rundoneq(void); +static void mega_cmd_done(mega_host_config *,mega_scb *, int); /* set SERDEBUG to 1 to enable serial debugging */ #define SERDEBUG 0 #if SERDEBUG -static void ser_init (void); -static void ser_puts (char *str); -static void ser_putc (char c); -static int ser_printk (const char *fmt,...); +static void ser_init(void); +static void ser_puts(char *str); +static void ser_putc(char c); +static int ser_printk(const char *fmt, ...); #endif -//================================================================ -// -// Global variables -// -//================================================================ -static int numCtlrs = 0; -static mega_host_config *megaCtlrs[12] = {0}; +/*================================================================ + * + * Global variables + * + *================================================================*/ +static int numCtlrs = 0; +static mega_host_config *megaCtlrs[4] = { 0 }; /* Change this to 0 if you want to see the raw drives */ -static int use_raid = 1; +static int use_raid = 1; /* Queue of pending/completed SCBs */ -static mega_scb *qPending = NULL; +static mega_scb *qPending = NULL; static Scsi_Cmnd *qCompleted = NULL; volatile static spinlock_t mega_lock; -static struct tq_struct runq = {0, 0, mega_runque, NULL}; +static struct tq_struct runq = {0,0,mega_runque,NULL}; -struct proc_dir_entry proc_scsi_megaraid = -{ +struct proc_dir_entry proc_scsi_megaraid = { PROC_SCSI_MEGARAID, 8, "megaraid", S_IFDIR | S_IRUGO | S_IXUGO, 2 }; #if SERDEBUG -static char strbuf[MAX_SERBUF + 1]; +static char strbuf[MAX_SERBUF+1]; -static void ser_init () +static void ser_init() { - unsigned port = COM_BASE; - - outb (0x80, port + 3); - outb (0, port + 1); - /* 9600 Baud, if 19200: outb(6,port) */ - outb (12, port); - outb (3, port + 3); - outb (0, port + 1); + unsigned port=COM_BASE; + + outb(0x80,port+3); + outb(0,port+1); + /* 9600 Baud, if 19200: outb(6,port) */ + outb(12, port); + outb(3,port+3); + outb(0,port+1); } -static void ser_puts (char *str) +static void ser_puts(char *str) { - char *ptr; + char *ptr; - ser_init (); - for (ptr = str; *ptr; ++ptr) - ser_putc (*ptr); + ser_init(); + for (ptr=str;*ptr;++ptr) + ser_putc(*ptr); } -static void ser_putc (char c) +static void ser_putc(char c) { - unsigned port = COM_BASE; - - while ((inb (port + 5) & 0x20) == 0); - outb (c, port); - if (c == 0x0a) { - while ((inb (port + 5) & 0x20) == 0); - outb (0x0d, port); - } + unsigned port=COM_BASE; + + while ((inb(port+5) & 0x20)==0); + outb(c,port); + if (c==0x0a) + { + while ((inb(port+5) & 0x20)==0); + outb(0x0d,port); + } } -static int ser_printk (const char *fmt,...) +static int ser_printk(const char *fmt, ...) { - va_list args; - int i; - long flags; - - va_start (args, fmt); - i = vsprintf (strbuf, fmt, args); - ser_puts (strbuf); - va_end (args); + va_list args; + int i; + long flags; + + spin_lock_irqsave(mega_lock,flags); + va_start(args,fmt); + i = vsprintf(strbuf,fmt,args); + ser_puts(strbuf); + va_end(args); + spin_unlock_irqrestore(&mega_lock,flags); - return i; + return i; } #define TRACE(a) { ser_printk a;} @@ -288,14 +280,14 @@ static int ser_printk (const char *fmt,...) #define TRACE(A) #endif -void callDone (Scsi_Cmnd * SCpnt) +void callDone(Scsi_Cmnd *SCpnt) { if (SCpnt->result) { - TRACE (("*** %.08lx %.02x <%d.%d.%d> = %x\n", SCpnt->serial_number, - SCpnt->cmnd[0], SCpnt->channel, SCpnt->target, SCpnt->lun, - SCpnt->result)); + TRACE(("*** %.08lx %.02x <%d.%d.%d> = %x\n", SCpnt->serial_number, + SCpnt->cmnd[0], SCpnt->channel, SCpnt->target, SCpnt->lun, + SCpnt->result)); } - SCpnt->scsi_done (SCpnt); + SCpnt->scsi_done(SCpnt); } /*------------------------------------------------------------------------- @@ -304,79 +296,82 @@ void callDone (Scsi_Cmnd * SCpnt) * *-------------------------------------------------------------------------*/ -//================================================ -// Initialize SCB structures -//================================================ -static void initSCB (mega_host_config * megaCfg) +/*================================================ + * Initialize SCB structures + *================================================*/ +static void initSCB(mega_host_config *megaCfg) { int idx; - for (idx = 0; idx < megaCfg->max_cmds; idx++) { - megaCfg->scbList[idx].idx = -1; - megaCfg->scbList[idx].flag = 0; + for(idx=0; idxmax_cmds; idx++) { + megaCfg->scbList[idx].idx = -1; + megaCfg->scbList[idx].flag = 0; megaCfg->scbList[idx].sgList = NULL; - megaCfg->scbList[idx].SCpnt = NULL; + megaCfg->scbList[idx].SCpnt = NULL; } } -//=========================== -// Allocate a SCB structure -//=========================== -static mega_scb * allocateSCB (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt) +/*=========================== + * Allocate a SCB structure + *===========================*/ +static mega_scb *allocateSCB(mega_host_config *megaCfg,Scsi_Cmnd *SCpnt) { - int idx; - long flags; + int idx; + long flags; - spin_lock_irqsave (&mega_lock, flags); - for (idx = 0; idx < megaCfg->max_cmds; idx++) { + spin_lock_irqsave(&mega_lock,flags); + for(idx=0; idxmax_cmds; idx++) { if (megaCfg->scbList[idx].idx < 0) { - /* Set Index and SCB pointer */ - megaCfg->scbList[idx].flag = 0; - megaCfg->scbList[idx].idx = idx; + /* Set Index and SCB pointer */ + megaCfg->scbList[idx].flag = 0; + megaCfg->scbList[idx].idx = idx; megaCfg->scbList[idx].SCpnt = SCpnt; - megaCfg->scbList[idx].next = NULL; - spin_unlock_irqrestore (&mega_lock, flags); + megaCfg->scbList[idx].next = NULL; + spin_unlock_irqrestore(&mega_lock,flags); if (megaCfg->scbList[idx].sgList == NULL) { megaCfg->scbList[idx].sgList = - kmalloc (sizeof (mega_sglist) * MAX_SGLIST, GFP_ATOMIC | GFP_DMA); + kmalloc(sizeof(mega_sglist)*MAX_SGLIST,GFP_ATOMIC|GFP_DMA); } return &megaCfg->scbList[idx]; } } - spin_unlock_irqrestore (&mega_lock, flags); - - printk (KERN_WARNING "Megaraid: Could not allocate free SCB!!!\n"); + spin_unlock_irqrestore(&mega_lock,flags); + printk(KERN_WARNING "Megaraid: Could not allocate free SCB!!!\n"); + return NULL; } -//======================= -// Free a SCB structure -//======================= -static void freeSCB (mega_scb * scb) +/*======================= + * Free a SCB structure + *=======================*/ +static void freeSCB(mega_scb *scb) { - scb->flag = 0; - scb->idx = -1; - scb->next = NULL; + long flags; + + spin_lock_irqsave(&mega_lock,flags); + scb->flag = 0; + scb->idx = -1; + scb->next = NULL; scb->SCpnt = NULL; + spin_unlock_irqrestore(&mega_lock,flags); } /* Run through the list of completed requests */ -static void mega_rundoneq () +static void mega_rundoneq() { mega_host_config *megaCfg; - Scsi_Cmnd *SCpnt; - long islogical; + Scsi_Cmnd *SCpnt; + long islogical; - while (1) { - DEQUEUE (SCpnt, Scsi_Cmnd, qCompleted, host_scribble); - if (SCpnt == NULL) - return; + while(1) { + DEQUEUE(SCpnt, Scsi_Cmnd, qCompleted, host_scribble); + if (SCpnt == NULL) return; - megaCfg = (mega_host_config *) SCpnt->host->hostdata; + megaCfg = (mega_host_config *)SCpnt->host->hostdata; /* Check if we're allowing access to RAID drives or physical * if use_raid == 1 and this wasn't a disk on the max channel or @@ -385,15 +380,14 @@ static void mega_rundoneq () */ islogical = (SCpnt->channel == megaCfg->host->max_channel) ? 1 : 0; if (SCpnt->cmnd[0] == INQUIRY && - ((((u_char *) SCpnt->request_buffer)[0] & 0x1F) == TYPE_DISK) && + ((((u_char*)SCpnt->request_buffer)[0] & 0x1F) == TYPE_DISK) && (islogical != use_raid)) { - SCpnt->result = 0xF0; + SCpnt->result = 0xF0; } /* Convert result to error */ - switch (SCpnt->result) { - case 0x00: - case 0x02: + switch(SCpnt->result) { + case 0x00: case 0x02: SCpnt->result |= (DID_OK << 16); break; case 0x8: @@ -405,20 +399,16 @@ static void mega_rundoneq () } /* Callback */ - callDone (SCpnt); + callDone(SCpnt); } } /* Add command to the list of completed requests */ -static void mega_cmd_done (mega_host_config * megaCfg, mega_scb * pScb, int status) +static void mega_cmd_done(mega_host_config *megaCfg,mega_scb *pScb, int status) { - long flags; - pScb->SCpnt->result = status; - ENQUEUE (pScb->SCpnt, Scsi_Cmnd, qCompleted, host_scribble); - spin_lock_irqsave (&mega_lock, flags); - freeSCB (pScb); - spin_unlock_irqrestore (&mega_lock, flags); + ENQUEUE(pScb->SCpnt, Scsi_Cmnd, qCompleted, host_scribble); + freeSCB(pScb); } /*---------------------------------------------------- @@ -426,42 +416,45 @@ static void mega_cmd_done (mega_host_config * megaCfg, mega_scb * pScb, int stat * * Run as a scheduled task *----------------------------------------------------*/ -static void mega_runque (void *dummy) +static void mega_runque(void *dummy) { mega_host_config *megaCfg; - mega_scb *pScb; - long flags; + mega_scb *pScb; + long flags; /* Take care of any completed requests */ - mega_rundoneq (); + mega_rundoneq(); - DEQUEUE (pScb, mega_scb, qPending, next); + DEQUEUE(pScb,mega_scb,qPending,next); if (pScb) { - megaCfg = (mega_host_config *) pScb->SCpnt->host->hostdata; - - if (megaCfg->mbox->busy || megaCfg->flag & (IN_ISR | PENDING)) { - TRACE (("%.08lx %.02x <%d.%d.%d> busy%d isr%d pending%d\n", - pScb->SCpnt->serial_number, - pScb->SCpnt->cmnd[0], - pScb->SCpnt->channel, - pScb->SCpnt->target, - pScb->SCpnt->lun, - megaCfg->mbox->busy, - (megaCfg->flag & IN_ISR) ? 1 : 0, - (megaCfg->flag & PENDING) ? 1 : 0)); + megaCfg = (mega_host_config *)pScb->SCpnt->host->hostdata; + + if (megaCfg->mbox->busy || megaCfg->flag & (IN_ISR|PENDING)) { + printk(KERN_DEBUG "PENDING = %x, IN_ISR = %x, mbox.busy = %x\n",(u_int)(megaCfg->flag + & PENDING), (u_int)(megaCfg->flag & IN_ISR), megaCfg->mbox->busy); + TRACE(("%.08lx %.02x <%d.%d.%d> intr%d busy%d isr%d pending%d\n", + pScb->SCpnt->serial_number, + pScb->SCpnt->cmnd[0], + pScb->SCpnt->channel, + pScb->SCpnt->target, + pScb->SCpnt->lun, + intr_count, + megaCfg->mbox->busy, + (megaCfg->flag & IN_ISR) ? 1 : 0, + (megaCfg->flag & PENDING) ? 1 : 0)); } - if (MegaIssueCmd (megaCfg, pScb->mboxData, pScb, 1)) { + if (MegaIssueCmd(megaCfg, pScb->mboxData, pScb, 1)) { + printk(KERN_DEBUG "MegaIssueCmd returned BUSY. Rescheduling command.\n"); /* We're BUSY... come back later */ - spin_lock_irqsave (&mega_lock, flags); + spin_lock_irqsave(&mega_lock,flags); pScb->next = qPending; - qPending = pScb; - spin_unlock_irqrestore (&mega_lock, flags); + qPending = pScb; + spin_unlock_irqrestore(&mega_lock,flags); - if (!(megaCfg->flag & PENDING)) { - /* If PENDING, irq will schedule task */ - queue_task (&runq, &tq_scheduler); + if (!(megaCfg->flag & PENDING)) { /* If PENDING, irq will schedule task */ + queue_task(&runq, &tq_scheduler); } } } @@ -475,20 +468,17 @@ static void mega_runque (void *dummy) * If NULL is returned, the scsi_done function MUST have been called * *-------------------------------------------------------------------*/ -static mega_scb * mega_build_cmd (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt) +static mega_scb *mega_build_cmd(mega_host_config *megaCfg, Scsi_Cmnd *SCpnt) { - mega_scb *pScb; - mega_mailbox *mbox; + mega_scb *pScb; + mega_mailbox *mbox; mega_passthru *pthru; - long seg; - - if (SCpnt->cmnd[0] & 0x80) /* ioctl from megamgr */ - return mega_ioctl (megaCfg, SCpnt); + long seg; /* We don't support multi-luns */ if (SCpnt->lun != 0) { SCpnt->result = (DID_BAD_TARGET << 16); - callDone (SCpnt); + callDone(SCpnt); return NULL; } @@ -498,44 +488,44 @@ static mega_scb * mega_build_cmd (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt) * *-----------------------------------------------------*/ if (SCpnt->channel == megaCfg->host->max_channel) { - switch (SCpnt->cmnd[0]) { + switch(SCpnt->cmnd[0]) { case TEST_UNIT_READY: - memset (SCpnt->request_buffer, 0, SCpnt->request_bufflen); + memset(SCpnt->request_buffer, 0, SCpnt->request_bufflen); SCpnt->result = (DID_OK << 16); - callDone (SCpnt); + callDone(SCpnt); return NULL; case MODE_SENSE: - memset (SCpnt->request_buffer, 0, SCpnt->cmnd[4]); + memset(SCpnt->request_buffer, 0, SCpnt->cmnd[4]); SCpnt->result = (DID_OK << 16); - callDone (SCpnt); + callDone(SCpnt); return NULL; case READ_CAPACITY: case INQUIRY: /* Allocate a SCB and initialize passthru */ - if ((pScb = allocateSCB (megaCfg, SCpnt)) == NULL) { + if ((pScb = allocateSCB(megaCfg,SCpnt)) == NULL) { SCpnt->result = (DID_ERROR << 16); - callDone (SCpnt); + callDone(SCpnt); return NULL; } pthru = &pScb->pthru; - mbox = (mega_mailbox *) & pScb->mboxData; - - memset (mbox, 0, sizeof (pScb->mboxData)); - memset (pthru, 0, sizeof (mega_passthru)); - pthru->timeout = 0; - pthru->ars = 0; - pthru->islogical = 1; - pthru->logdrv = SCpnt->target; - pthru->cdblen = SCpnt->cmd_len; - pthru->dataxferaddr = virt_to_bus (SCpnt->request_buffer); - pthru->dataxferlen = SCpnt->request_bufflen; - memcpy (pthru->cdb, SCpnt->cmnd, SCpnt->cmd_len); + mbox = (mega_mailbox *)&pScb->mboxData; + + memset(mbox, 0, sizeof(pScb->mboxData)); + memset(pthru, 0, sizeof(mega_passthru)); + pthru->timeout = 0; + pthru->ars = 0; + pthru->islogical = 1; + pthru->logdrv = SCpnt->target; + pthru->cdblen = SCpnt->cmd_len; + pthru->dataxferaddr = virt_to_bus(SCpnt->request_buffer); + pthru->dataxferlen = SCpnt->request_bufflen; + memcpy(pthru->cdb, SCpnt->cmnd, SCpnt->cmd_len); /* Initialize mailbox area */ - mbox->cmd = MEGA_MBOXCMD_PASSTHRU; - mbox->xferaddr = virt_to_bus (pthru); + mbox->cmd = MEGA_MBOXCMD_PASSTHRU; + mbox->xferaddr = virt_to_bus(pthru); return pScb; @@ -544,51 +534,51 @@ static mega_scb * mega_build_cmd (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt) case READ_10: case WRITE_10: /* Allocate a SCB and initialize mailbox */ - if ((pScb = allocateSCB (megaCfg, SCpnt)) == NULL) { + if ((pScb = allocateSCB(megaCfg,SCpnt)) == NULL) { SCpnt->result = (DID_ERROR << 16); - callDone (SCpnt); + callDone(SCpnt); return NULL; } - mbox = (mega_mailbox *) & pScb->mboxData; + mbox = (mega_mailbox *)&pScb->mboxData; - memset (mbox, 0, sizeof (pScb->mboxData)); + memset(mbox, 0, sizeof(pScb->mboxData)); mbox->logdrv = SCpnt->target; - mbox->cmd = (*SCpnt->cmnd == READ_6 || *SCpnt->cmnd == READ_10) ? + mbox->cmd = (*SCpnt->cmnd == READ_6 || *SCpnt->cmnd == READ_10) ? MEGA_MBOXCMD_LREAD : MEGA_MBOXCMD_LWRITE; - + /* 6-byte */ if (*SCpnt->cmnd == READ_6 || *SCpnt->cmnd == WRITE_6) { - mbox->numsectors = - (u_long) SCpnt->cmnd[4]; - mbox->lba = - ((u_long) SCpnt->cmnd[1] << 16) | - ((u_long) SCpnt->cmnd[2] << 8) | - (u_long) SCpnt->cmnd[3]; + mbox->numsectors = + (u_long)SCpnt->cmnd[4]; + mbox->lba = + ((u_long)SCpnt->cmnd[1] << 16) | + ((u_long)SCpnt->cmnd[2] << 8) | + (u_long)SCpnt->cmnd[3]; mbox->lba &= 0x1FFFFF; } - + /* 10-byte */ if (*SCpnt->cmnd == READ_10 || *SCpnt->cmnd == WRITE_10) { - mbox->numsectors = - (u_long) SCpnt->cmnd[8] | - ((u_long) SCpnt->cmnd[7] << 8); + mbox->numsectors = + (u_long)SCpnt->cmnd[8] | + ((u_long)SCpnt->cmnd[7] << 8); mbox->lba = - ((u_long) SCpnt->cmnd[2] << 24) | - ((u_long) SCpnt->cmnd[3] << 16) | - ((u_long) SCpnt->cmnd[4] << 8) | - (u_long) SCpnt->cmnd[5]; + ((u_long)SCpnt->cmnd[2] << 24) | + ((u_long)SCpnt->cmnd[3] << 16) | + ((u_long)SCpnt->cmnd[4] << 8) | + (u_long)SCpnt->cmnd[5]; } - + /* Calculate Scatter-Gather info */ - mbox->numsgelements = build_sglist (megaCfg, pScb, - (u_long *) & mbox->xferaddr, - (u_long *) & seg); + mbox->numsgelements = build_sglist(megaCfg, pScb, + (u_long*)&mbox->xferaddr, + (u_long*)&seg); return pScb; - + default: SCpnt->result = (DID_BAD_TARGET << 16); - callDone (SCpnt); + callDone(SCpnt); return NULL; } } @@ -599,196 +589,113 @@ static mega_scb * mega_build_cmd (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt) *-----------------------------------------------------*/ else { /* Allocate a SCB and initialize passthru */ - if ((pScb = allocateSCB (megaCfg, SCpnt)) == NULL) { + if ((pScb = allocateSCB(megaCfg,SCpnt)) == NULL) { SCpnt->result = (DID_ERROR << 16); - callDone (SCpnt); + callDone(SCpnt); return NULL; } pthru = &pScb->pthru; - mbox = (mega_mailbox *) pScb->mboxData; - - memset (mbox, 0, sizeof (pScb->mboxData)); - memset (pthru, 0, sizeof (mega_passthru)); - pthru->timeout = 0; - pthru->ars = 0; + mbox = (mega_mailbox *)pScb->mboxData; + + memset(mbox, 0, sizeof(pScb->mboxData)); + memset(pthru, 0, sizeof(mega_passthru)); + pthru->timeout = 0; + pthru->ars = 0; pthru->islogical = 0; - pthru->channel = SCpnt->channel; - pthru->target = SCpnt->target; - pthru->cdblen = SCpnt->cmd_len; - memcpy (pthru->cdb, SCpnt->cmnd, SCpnt->cmd_len); - - pthru->numsgelements = build_sglist (megaCfg, pScb, - (u_long *) & pthru->dataxferaddr, - (u_long *) & pthru->dataxferlen); - + pthru->channel = SCpnt->channel; + pthru->target = SCpnt->target; + pthru->cdblen = SCpnt->cmd_len; + memcpy(pthru->cdb, SCpnt->cmnd, SCpnt->cmd_len); + + pthru->numsgelements = build_sglist(megaCfg, pScb, + (u_long *)&pthru->dataxferaddr, + (u_long *)&pthru->dataxferlen); + /* Initialize mailbox */ - mbox->cmd = MEGA_MBOXCMD_PASSTHRU; - mbox->xferaddr = virt_to_bus (pthru); + mbox->cmd = MEGA_MBOXCMD_PASSTHRU; + mbox->xferaddr = virt_to_bus(pthru); return pScb; } return NULL; } -/*-------------------------------------------------------------------- - * build RAID commands for controller, passed down through ioctl() - *--------------------------------------------------------------------*/ -static mega_scb * mega_ioctl (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt) -{ - mega_scb *pScb; - mega_ioctl_mbox *mbox; - mega_mailbox *mailbox; - mega_passthru *pthru; - long seg; - - if ((pScb = allocateSCB (megaCfg, SCpnt)) == NULL) { - SCpnt->result = (DID_ERROR << 16); - callDone (SCpnt); - return NULL; - } - - mbox = (mega_ioctl_mbox *) & pScb->mboxData; - mailbox = (mega_mailbox *) & pScb->mboxData; - memset (mailbox, 0, sizeof (pScb->mboxData)); - - if (SCpnt->cmnd[0] == 0x83) { /* passthrough command */ - char cdblen = SCpnt->cmnd[2]; - - pthru = &pScb->pthru; - memset (pthru, 0, sizeof (mega_passthru)); - pthru->islogical = SCpnt->cmnd[cdblen + 3] & 0x80; - pthru->timeout = SCpnt->cmnd[cdblen + 3] & 0x07; - pthru->reqsenselen = 10; /* ? MAX_SENSE; */ - pthru->ars = SCpnt->cmnd[cdblen + 3] & 0x08; - pthru->logdrv = SCpnt->cmnd[cdblen + 4]; - pthru->channel = SCpnt->cmnd[cdblen + 5]; - pthru->target = SCpnt->cmnd[cdblen + 6]; - pthru->cdblen = cdblen; - memcpy (pthru->cdb, SCpnt->cmnd, SCpnt->cmnd[2]); - - mailbox->cmd = MEGA_MBOXCMD_PASSTHRU; - mailbox->xferaddr = virt_to_bus (pthru); - - pthru->numsgelements = build_sglist (megaCfg, pScb, - (u_long *) & pthru->dataxferaddr, - (u_long *) & pthru->dataxferlen); - - return pScb; - } - /* else normal (nonpassthru) command */ - - mbox->cmd = SCpnt->cmnd[0] & 0x7F; - mbox->channel = SCpnt->cmnd[1]; - mbox->param = SCpnt->cmnd[2]; - mbox->pad[0] = SCpnt->cmnd[3]; - mbox->logdrv = SCpnt->cmnd[4]; - - mbox->numsgelements = build_sglist (megaCfg, pScb, - (u_long *) & mbox->xferaddr, - (u_long *) & seg); - - return (pScb); -} - - /*-------------------------------------------------------------------- * Interrupt service routine *--------------------------------------------------------------------*/ -static void megaraid_isr (int irq, void *devp, struct pt_regs *regs) +static void megaraid_isr(int irq, void *devp, struct pt_regs *regs) { - mega_host_config *megaCfg; - u_char byte, idx, sIdx; - u_long dword; - mega_mailbox *mbox; - mega_scb *pScb; - long flags; - int qCnt, qStatus; + mega_host_config *megaCfg; + u_char byte, idx, sIdx; + u_long dword; + mega_mailbox *mbox; + mega_scb *pScb; + long flags; + int qCnt, qStatus; - megaCfg = (mega_host_config *) devp; - mbox = (mega_mailbox *) megaCfg->mbox; + megaCfg = (mega_host_config *)devp; + mbox = (mega_mailbox *)megaCfg->mbox; if (megaCfg->host->irq == irq) { - -#if LINUX_VERSION_CODE >= 0x20100 - spin_lock_irqsave (&io_request_lock, flags); -#endif - - spin_lock_irqsave (&mega_lock, flags); + spin_lock_irqsave(&mega_lock,flags); if (megaCfg->flag & IN_ISR) { - TRACE (("ISR called reentrantly!!\n")); + TRACE(("ISR called reentrantly!!\n")); } megaCfg->flag |= IN_ISR; /* Check if a valid interrupt is pending */ if (megaCfg->flag & BOARD_QUARTZ) { - dword = RDOUTDOOR (megaCfg); - if (dword != 0x10001234) { - /* Spurious interrupt */ - megaCfg->flag &= ~IN_ISR; - spin_unlock_irqrestore (&mega_lock, flags); -#if LINUX_VERSION_CODE >= 0x20100 - spin_unlock_irqrestore (&io_request_lock, flags); -#endif - return; - } - WROUTDOOR (megaCfg, dword); - } - else { - byte = READ_PORT (megaCfg->host->io_port, INTR_PORT); - if ((byte & VALID_INTR_BYTE) == 0) { - /* Spurious interrupt */ - megaCfg->flag &= ~IN_ISR; - spin_unlock_irqrestore (&mega_lock, flags); -#if LINUX_VERSION_CODE >= 0x20100 - spin_unlock_irqrestore (&io_request_lock, flags); -#endif - return; - } - WRITE_PORT (megaCfg->host->io_port, INTR_PORT, byte); + dword = RDOUTDOOR(megaCfg); + if (dword != 0x10001234) { + /* Spurious interrupt */ + megaCfg->flag &= ~IN_ISR; + spin_unlock_irqrestore(&mega_lock,flags); + return; + } + WROUTDOOR(megaCfg,dword); + } else { + byte = READ_PORT(megaCfg->host->io_port, INTR_PORT); + if ((byte & VALID_INTR_BYTE) == 0) { + /* Spurious interrupt */ + megaCfg->flag &= ~IN_ISR; + spin_unlock_irqrestore(&mega_lock,flags); + return; + } + WRITE_PORT(megaCfg->host->io_port, INTR_PORT, byte); } - - qCnt = mbox->numstatus; + + qCnt = mbox->numstatus; qStatus = mbox->status; - if (qCnt > 1) { - TRACE (("ISR: Received %d status\n", qCnt)) - printk (KERN_DEBUG "Got numstatus = %d\n", qCnt); + if (qCnt > 1) {TRACE(("ISR: Received %d status\n", qCnt)) + printk(KERN_DEBUG "Got numstatus = %d\n",qCnt); } - - for (idx = 0; idx < qCnt; idx++) { + + for(idx=0; idxcompleted[idx]; if (sIdx > 0) { - pScb = &megaCfg->scbList[sIdx - 1]; - spin_unlock_irqrestore (&mega_lock, flags); /* megalock within cmd_done */ - mega_cmd_done (megaCfg, &megaCfg->scbList[sIdx - 1], qStatus); - spin_lock_irqsave (&mega_lock, flags); + pScb = &megaCfg->scbList[sIdx-1]; + spin_unlock_irqrestore(&mega_lock,flags); /* locks within cmd_done */ + mega_cmd_done(megaCfg,&megaCfg->scbList[sIdx-1], qStatus); + spin_lock_irqsave(&mega_lock,flags); } } if (megaCfg->flag & BOARD_QUARTZ) { - WRINDOOR (megaCfg, virt_to_bus (megaCfg->mbox) | 0x2); - while (RDINDOOR (megaCfg) & 0x02); - } - else { - CLEAR_INTR (megaCfg->host->io_port); + WRINDOOR(megaCfg,virt_to_bus(megaCfg->mbox)|0x2); + while (RDINDOOR(megaCfg) & 0x02); + } else { + CLEAR_INTR(megaCfg->host->io_port); } megaCfg->flag &= ~IN_ISR; megaCfg->flag &= ~PENDING; - spin_unlock_irqrestore (&mega_lock, flags); - mega_runque (NULL); - -#if LINUX_VERSION_CODE >= 0x20100 - spin_unlock_irqrestore (&io_request_lock, flags); -#endif - -#if 0 /* Queue as a delayed ISR routine */ - queue_task_irq_off (&runq, &tq_immediate); - mark_bh (IMMEDIATE_BH); -#endif + queue_task_irq_off(&runq, &tq_immediate); + mark_bh(IMMEDIATE_BH); + spin_unlock_irqrestore(&mega_lock,flags); } } @@ -796,128 +703,111 @@ static void megaraid_isr (int irq, void *devp, struct pt_regs *regs) /*==================================================*/ /* Wait until the controller's mailbox is available */ /*==================================================*/ -static int busyWaitMbox (mega_host_config * megaCfg) +static int busyWaitMbox(mega_host_config *megaCfg) { - mega_mailbox *mbox = (mega_mailbox *) megaCfg->mbox; - long counter; + mega_mailbox *mbox = (mega_mailbox *)megaCfg->mbox; + long counter; - for (counter = 0; counter < 30000; counter++) { - udelay (100); - if (!mbox->busy) - return 0; + for(counter=0; counter<0xFFFFFF; counter++) { + if (!mbox->busy) return 0; } - return -1; /* give up after 3 seconds */ + return -1; } -//===================================================== -// Post a command to the card -// -// Arguments: -// mega_host_config *megaCfg - Controller structure -// u_char *mboxData - Mailbox area, 16 bytes -// mega_scb *pScb - SCB posting (or NULL if N/A) -// int intr - if 1, interrupt, 0 is blocking -//===================================================== -static int MegaIssueCmd (mega_host_config * megaCfg, - u_char * mboxData, - mega_scb * pScb, - int intr) +/*===================================================== + * Post a command to the card + * + * Arguments: + * mega_host_config *megaCfg - Controller structure + * u_char *mboxData - Mailbox area, 16 bytes + * mega_scb *pScb - SCB posting (or NULL if N/A) + * int intr - if 1, interrupt, 0 is blocking + *=====================================================*/ +static int MegaIssueCmd(mega_host_config *megaCfg, + u_char *mboxData, + mega_scb *pScb, + int intr) { - mega_mailbox *mbox = (mega_mailbox *) megaCfg->mbox; - long flags; - u_char byte; - u_long cmdDone; - - mboxData[0x1] = (pScb ? pScb->idx + 1 : 0x00); /* Set cmdid */ - mboxData[0xF] = 1; /* Set busy */ + mega_mailbox *mbox = (mega_mailbox *)megaCfg->mbox; + long flags; + u_char byte; + u_long cmdDone; - spin_lock_irqsave(&mega_lock,flags); + mboxData[0x1] = (pScb ? pScb->idx+1 : 0x00); /* Set cmdid */ + mboxData[0xF] = 1; /* Set busy */ /* one bad report of problem when issuing a command while pending. * Wasn't able to duplicate, but it doesn't really affect performance * anyway, so don't allow command while PENDING */ - if (megaCfg->flag & PENDING) { - spin_unlock_irqrestore(&mega_lock,flags); return -1; } /* Wait until mailbox is free */ - if (busyWaitMbox (megaCfg)) { + if (busyWaitMbox(megaCfg)) { if (pScb) { - TRACE (("Mailbox busy %.08lx <%d.%d.%d>\n", pScb->SCpnt->serial_number, - pScb->SCpnt->channel, pScb->SCpnt->target, pScb->SCpnt->lun)); - } else { - TRACE(("pScb NULL in MegaIssueCmd!\n")); + TRACE(("Mailbox busy %.08lx <%d.%d.%d>\n", pScb->SCpnt->serial_number, + pScb->SCpnt->channel, pScb->SCpnt->target, pScb->SCpnt->lun)); } - spin_unlock_irqrestore(&mega_lock,flags); return -1; } /* Copy mailbox data into host structure */ - memset (mbox, 0, sizeof (mega_mailbox)); - memcpy (mbox, mboxData, 16); + spin_lock_irqsave(&mega_lock,flags); + memset(mbox, 0, sizeof(mega_mailbox)); + memcpy(mbox, mboxData, 16); + spin_unlock_irqrestore(&mega_lock,flags); /* Kick IO */ megaCfg->flag |= PENDING; if (intr) { /* Issue interrupt (non-blocking) command */ if (megaCfg->flag & BOARD_QUARTZ) { - mbox->mraid_poll = 0; - mbox->mraid_ack = 0; - WRINDOOR (megaCfg, virt_to_bus (megaCfg->mbox) | 0x1); - } - else { - ENABLE_INTR (megaCfg->host->io_port); - ISSUE_COMMAND (megaCfg->host->io_port); + mbox->mraid_poll = 0; + mbox->mraid_ack = 0; + WRINDOOR(megaCfg, virt_to_bus(megaCfg->mbox) | 0x1); + } else { + ENABLE_INTR(megaCfg->host->io_port); + ISSUE_COMMAND(megaCfg->host->io_port); } - spin_unlock_irqrestore(&mega_lock,flags); } - else { /* Issue non-ISR (blocking) command */ + else { /* Issue non-ISR (blocking) command */ if (megaCfg->flag & BOARD_QUARTZ) { - mbox->mraid_poll = 0; - mbox->mraid_ack = 0; - WRINDOOR (megaCfg, virt_to_bus (megaCfg->mbox) | 0x1); + mbox->mraid_poll = 0; + mbox->mraid_ack = 0; + WRINDOOR(megaCfg, virt_to_bus(megaCfg->mbox) | 0x1); - while ((cmdDone = RDOUTDOOR (megaCfg)) != 0x10001234); - WROUTDOOR (megaCfg, cmdDone); + while((cmdDone=RDOUTDOOR(megaCfg)) != 0x10001234); + WROUTDOOR(megaCfg, cmdDone); - spin_unlock_irqrestore(&mega_lock,flags); if (pScb) { - mega_cmd_done (megaCfg, pScb, mbox->status); - mega_rundoneq (); + mega_cmd_done(megaCfg,pScb, mbox->status); + mega_rundoneq(); } - WRINDOOR (megaCfg, virt_to_bus (megaCfg->mbox) | 0x2); - while (RDINDOOR (megaCfg) & 0x2); + WRINDOOR(megaCfg,virt_to_bus(megaCfg->mbox) | 0x2); + while(RDINDOOR(megaCfg) & 0x2); megaCfg->flag &= ~PENDING; - } else { - DISABLE_INTR (megaCfg->host->io_port); - ISSUE_COMMAND (megaCfg->host->io_port); - - while (!((byte = READ_PORT (megaCfg->host->io_port, INTR_PORT)) & INTR_VALID)); - WRITE_PORT (megaCfg->host->io_port, INTR_PORT, byte); - - - ENABLE_INTR (megaCfg->host->io_port); - CLEAR_INTR (megaCfg->host->io_port); - megaCfg->flag &= ~PENDING; - spin_unlock_irqrestore(&mega_lock,flags); - + DISABLE_INTR(megaCfg->host->io_port); + ISSUE_COMMAND(megaCfg->host->io_port); + + while(!((byte=READ_PORT(megaCfg->host->io_port,INTR_PORT))&INTR_VALID)); + WRITE_PORT(megaCfg->host->io_port, INTR_PORT, byte); + + ENABLE_INTR(megaCfg->host->io_port); + CLEAR_INTR(megaCfg->host->io_port); + if (pScb) { - mega_cmd_done (megaCfg, pScb, mbox->status); - mega_rundoneq (); - } - else { - TRACE (("Error: NULL pScb!\n")); + mega_cmd_done(megaCfg,pScb, mbox->status); + mega_rundoneq(); } - + megaCfg->flag &= ~PENDING; } } @@ -927,40 +817,40 @@ static int MegaIssueCmd (mega_host_config * megaCfg, /*------------------------------------------------------------------- * Copies data to SGLIST *-------------------------------------------------------------------*/ -static int build_sglist (mega_host_config * megaCfg, mega_scb * scb, - u_long * buffer, u_long * length) +static int build_sglist(mega_host_config *megaCfg, mega_scb *scb, + u_long *buffer, u_long *length) { struct scatterlist *sgList; int idx; /* Scatter-gather not used */ if (scb->SCpnt->use_sg == 0) { - *buffer = virt_to_bus (scb->SCpnt->request_buffer); - *length = (u_long) scb->SCpnt->request_bufflen; + *buffer = virt_to_bus(scb->SCpnt->request_buffer); + *length = (u_long)scb->SCpnt->request_bufflen; return 0; } - sgList = (struct scatterlist *) scb->SCpnt->buffer; + sgList = (struct scatterlist *)scb->SCpnt->buffer; if (scb->SCpnt->use_sg == 1) { - *buffer = virt_to_bus (sgList[0].address); - *length = (u_long) sgList[0].length; + *buffer = virt_to_bus(sgList[0].address); + *length = (u_long)sgList[0].length; return 0; } /* Copy Scatter-Gather list info into controller structure */ - for (idx = 0; idx < scb->SCpnt->use_sg; idx++) { - scb->sgList[idx].address = virt_to_bus (sgList[idx].address); - scb->sgList[idx].length = (u_long) sgList[idx].length; + for(idx=0; idxSCpnt->use_sg; idx++) { + scb->sgList[idx].address = virt_to_bus(sgList[idx].address); + scb->sgList[idx].length = (u_long)sgList[idx].length; } - + /* Reset pointer and length fields */ - *buffer = virt_to_bus (scb->sgList); + *buffer = virt_to_bus(scb->sgList); *length = 0; /* Return count of SG requests */ return scb->SCpnt->use_sg; } - + /*-------------------------------------------------------------------- * Initializes the adress of the controller's mailbox register * The mailbox register is used to issue commands to the card. @@ -977,25 +867,25 @@ static int build_sglist (mega_host_config * megaCfg, mega_scb * scb, * 10 01 numstatus byte * 11 01 status byte *--------------------------------------------------------------------*/ -static int mega_register_mailbox (mega_host_config * megaCfg, u_long paddr) +static int mega_register_mailbox(mega_host_config *megaCfg, u_long paddr) { /* align on 16-byte boundry */ megaCfg->mbox = &megaCfg->mailbox; - megaCfg->mbox = (mega_mailbox *) ((((ulong) megaCfg->mbox) + 16) & 0xfffffff0); - paddr = (paddr + 16) & 0xfffffff0; + megaCfg->mbox = (mega_mailbox *) ((((ulong)megaCfg->mbox) + 16)&0xfffffff0); + paddr = (paddr+16)&0xfffffff0; /* Register mailbox area with the firmware */ if (megaCfg->flag & BOARD_QUARTZ) { } else { - WRITE_PORT (megaCfg->host->io_port, MBOX_PORT0, paddr & 0xFF); - WRITE_PORT (megaCfg->host->io_port, MBOX_PORT1, (paddr >> 8) & 0xFF); - WRITE_PORT (megaCfg->host->io_port, MBOX_PORT2, (paddr >> 16) & 0xFF); - WRITE_PORT (megaCfg->host->io_port, MBOX_PORT3, (paddr >> 24) & 0xFF); - WRITE_PORT (megaCfg->host->io_port, ENABLE_MBOX_REGION, ENABLE_MBOX_BYTE); - - CLEAR_INTR (megaCfg->host->io_port); - ENABLE_INTR (megaCfg->host->io_port); + WRITE_PORT(megaCfg->host->io_port, MBOX_PORT0, paddr & 0xFF); + WRITE_PORT(megaCfg->host->io_port, MBOX_PORT1, (paddr >> 8) & 0xFF); + WRITE_PORT(megaCfg->host->io_port, MBOX_PORT2, (paddr >> 16) & 0xFF); + WRITE_PORT(megaCfg->host->io_port, MBOX_PORT3, (paddr >> 24) & 0xFF); + WRITE_PORT(megaCfg->host->io_port, ENABLE_MBOX_REGION, ENABLE_MBOX_BYTE); + + CLEAR_INTR(megaCfg->host->io_port); + ENABLE_INTR(megaCfg->host->io_port); } return 0; } @@ -1003,79 +893,77 @@ static int mega_register_mailbox (mega_host_config * megaCfg, u_long paddr) /*------------------------------------------------------------------- * Issue an adapter info query to the controller *-------------------------------------------------------------------*/ -static int mega_i_query_adapter (mega_host_config * megaCfg) +static int mega_i_query_adapter(mega_host_config *megaCfg) { mega_RAIDINQ *adapterInfo; mega_mailbox *mbox; - u_char mboxData[16]; - u_long paddr; + u_char mboxData[16]; + u_long paddr; - spin_lock_init (&mega_lock); + spin_lock_init(&mega_lock); /* Initialize adapter inquiry */ - paddr = virt_to_bus (megaCfg->mega_buffer); - mbox = (mega_mailbox *) mboxData; + paddr = virt_to_bus(megaCfg->mega_buffer); + mbox = (mega_mailbox *)mboxData; - memset ((void *) megaCfg->mega_buffer, 0, sizeof (megaCfg->mega_buffer)); - memset (mbox, 0, 16); + memset((void *)megaCfg->mega_buffer, 0, sizeof(megaCfg->mega_buffer)); + memset(mbox, 0, 16); /* Initialize mailbox registers */ - mbox->cmd = MEGA_MBOXCMD_ADAPTERINQ; + mbox->cmd = MEGA_MBOXCMD_ADAPTERINQ; mbox->xferaddr = paddr; /* Issue a blocking command to the card */ - MegaIssueCmd (megaCfg, mboxData, NULL, 0); - + MegaIssueCmd(megaCfg, mboxData, NULL, 0); + /* Initialize host/local structures with Adapter info */ - adapterInfo = (mega_RAIDINQ *) megaCfg->mega_buffer; + adapterInfo = (mega_RAIDINQ *)megaCfg->mega_buffer; megaCfg->host->max_channel = adapterInfo->AdpInfo.ChanPresent; -/* megaCfg->host->max_id = adapterInfo->AdpInfo.MaxTargPerChan; */ - megaCfg->host->max_id = 9; /* max logical drives + 1 */ - megaCfg->numldrv = adapterInfo->LogdrvInfo.NumLDrv; + megaCfg->host->max_id = adapterInfo->AdpInfo.MaxTargPerChan; + megaCfg->numldrv = adapterInfo->LogdrvInfo.NumLDrv; #if 0 - printk ("KERN_DEBUG ---- Logical drive info ----\n"); - for (i = 0; i < megaCfg->numldrv; i++) { - printk ("%d: size: %ld prop: %x state: %x\n", i, - adapterInfo->LogdrvInfo.LDrvSize[i], - adapterInfo->LogdrvInfo.LDrvProp[i], - adapterInfo->LogdrvInfo.LDrvState[i]); + printk(KERN_DEBUG "---- Logical drive info ----\n"); + for(i=0; inumldrv; i++) { + printk(KERN_DEBUG "%d: size: %ld prop: %x state: %x\n",i, + adapterInfo->LogdrvInfo.LDrvSize[i], + adapterInfo->LogdrvInfo.LDrvProp[i], + adapterInfo->LogdrvInfo.LDrvState[i]); } - printk (KERN_DEBUG "---- Physical drive info ----\n"); - for (i = 0; i < MAX_PHYSICAL_DRIVES; i++) { - if (i && !(i % 8)) - printk ("\n"); - printk ("%d: %x ", i, adapterInfo->PhysdrvInfo.PDrvState[i]); + printk(KERN_DEBUG "---- Physical drive info ----\n"); + for(i=0; iPhysdrvInfo.PDrvState[i]); } - printk ("\n"); + printk("\n"); #endif megaCfg->max_cmds = adapterInfo->AdpInfo.MaxConcCmds; -#ifdef HP /* use HP firmware and bios version encoding */ - sprintf (megaCfg->fwVer, "%c%d%d.%d%d", - adapterInfo->AdpInfo.FwVer[2], - adapterInfo->AdpInfo.FwVer[1] >> 8, - adapterInfo->AdpInfo.FwVer[1] & 0x0f, - adapterInfo->AdpInfo.FwVer[2] >> 8, - adapterInfo->AdpInfo.FwVer[2] & 0x0f); - sprintf (megaCfg->biosVer, "%c%d%d.%d%d", - adapterInfo->AdpInfo.BiosVer[2], - adapterInfo->AdpInfo.BiosVer[1] >> 8, - adapterInfo->AdpInfo.BiosVer[1] & 0x0f, - adapterInfo->AdpInfo.BiosVer[2] >> 8, - adapterInfo->AdpInfo.BiosVer[2] & 0x0f); +#ifdef HP /* use HP firmware and bios version encoding */ + sprintf(megaCfg->fwVer,"%c%d%d.%d%d", + adapterInfo->AdpInfo.FwVer[2], + adapterInfo->AdpInfo.FwVer[1] >> 8, + adapterInfo->AdpInfo.FwVer[1] & 0x0f, + adapterInfo->AdpInfo.FwVer[2] >> 8, + adapterInfo->AdpInfo.FwVer[2] & 0x0f); + sprintf(megaCfg->biosVer,"%c%d%d.%d%d", + adapterInfo->AdpInfo.BiosVer[2], + adapterInfo->AdpInfo.BiosVer[1] >> 8, + adapterInfo->AdpInfo.BiosVer[1] & 0x0f, + adapterInfo->AdpInfo.BiosVer[2] >> 8, + adapterInfo->AdpInfo.BiosVer[2] & 0x0f); #else - memcpy (megaCfg->fwVer, adapterInfo->AdpInfo.FwVer, 4); - megaCfg->fwVer[4] = 0; + memcpy(megaCfg->fwVer, adapterInfo->AdpInfo.FwVer, 4); + megaCfg->fwVer[4] = 0; - memcpy (megaCfg->biosVer, adapterInfo->AdpInfo.BiosVer, 4); - megaCfg->biosVer[4] = 0; + memcpy(megaCfg->biosVer, adapterInfo->AdpInfo.BiosVer, 4); + megaCfg->biosVer[4] = 0; #endif - printk (KERN_INFO "megaraid: [%s:%s] detected %d logical drives" CRLFSTR, - megaCfg->fwVer, - megaCfg->biosVer, - megaCfg->numldrv); + printk(KERN_INFO "megaraid: [%s:%s] detected %d logical drives" CRLFSTR, + megaCfg->fwVer, + megaCfg->biosVer, + megaCfg->numldrv); return 0; } @@ -1088,56 +976,47 @@ static int mega_i_query_adapter (mega_host_config * megaCfg) /*---------------------------------------------------------- * Returns data to be displayed in /proc/scsi/megaraid/X *----------------------------------------------------------*/ -int megaraid_proc_info (char *buffer, char **start, off_t offset, - int length, int inode, int inout) +int megaraid_proc_info(char *buffer, char **start, off_t offset, + int length, int inode, int inout) { *start = buffer; return 0; } -int findCard (Scsi_Host_Template * pHostTmpl, - u_short pciVendor, u_short pciDev, - long flag) +int findCard(Scsi_Host_Template *pHostTmpl, + u_short pciVendor, u_short pciDev, + long flag) { mega_host_config *megaCfg; struct Scsi_Host *host; - u_char pciBus, pciDevFun, megaIrq; - u_long megaBase; - u_short pciIdx = 0; + u_char pciBus, pciDevFun, megaIrq; + u_long megaBase; + u_short pciIdx = 0; #if LINUX_VERSION_CODE < 0x20100 - while (!pcibios_find_device (pciVendor, pciDev, pciIdx, &pciBus, &pciDevFun)) { - if (flag & BOARD_QUARTZ) { - u_int magic; - pcibios_read_config_dword (pciBus, pciDevFun, - PCI_CONF_AMISIG, - &magic); - if (magic != AMI_SIGNATURE) { - continue; /* not an AMI board */ - } - } + while(!pcibios_find_device(pciVendor, pciDev, pciIdx,&pciBus,&pciDevFun)) { #else - struct pci_dev *pdev = pci_devices; + struct pci_dev *pdev=pci_devices; - while ((pdev = pci_find_device (pciVendor, pciDev, pdev))) { + while((pdev = pci_find_device(pciVendor, pciDev, pdev))) { pciBus = pdev->bus->number; pciDevFun = pdev->devfn; #endif - printk (KERN_INFO "megaraid: found 0x%4.04x:0x%4.04x:idx %d:bus %d:slot %d:fun %d\n", - pciVendor, - pciDev, - pciIdx, pciBus, - PCI_SLOT (pciDevFun), - PCI_FUNC (pciDevFun)); - + printk(KERN_INFO "megaraid: found 0x%4.04x:0x%4.04x:idx %d:bus %d:slot %d:fun %d\n", + pciVendor, + pciDev, + pciIdx, pciBus, + PCI_SLOT(pciDevFun), + PCI_FUNC(pciDevFun)); + /* Read the base port and IRQ from PCI */ #if LINUX_VERSION_CODE < 0x20100 - pcibios_read_config_dword (pciBus, pciDevFun, - PCI_BASE_ADDRESS_0, - (u_int *) & megaBase); - pcibios_read_config_byte (pciBus, pciDevFun, - PCI_INTERRUPT_LINE, - &megaIrq); + pcibios_read_config_dword(pciBus, pciDevFun, + PCI_BASE_ADDRESS_0, + (u_int *)&megaBase); + pcibios_read_config_byte(pciBus, pciDevFun, + PCI_INTERRUPT_LINE, + &megaIrq); #else megaBase = pdev->base_address[0]; megaIrq = pdev->irq; @@ -1146,7 +1025,7 @@ int findCard (Scsi_Host_Template * pHostTmpl, if (flag & BOARD_QUARTZ) { megaBase &= PCI_BASE_ADDRESS_MEM_MASK; - megaBase = (long) ioremap (megaBase, 128); + megaBase = (long) ioremap(megaBase,128); } else { megaBase &= PCI_BASE_ADDRESS_IO_MASK; @@ -1154,47 +1033,47 @@ int findCard (Scsi_Host_Template * pHostTmpl, } /* Initialize SCSI Host structure */ - host = scsi_register (pHostTmpl, sizeof (mega_host_config)); - megaCfg = (mega_host_config *) host->hostdata; - memset (megaCfg, 0, sizeof (mega_host_config)); - - printk (KERN_INFO " scsi%d: Found a MegaRAID controller at 0x%x, IRQ: %d" CRLFSTR, - host->host_no, (u_int) megaBase, megaIrq); + host = scsi_register(pHostTmpl, sizeof(mega_host_config)); + megaCfg = (mega_host_config *)host->hostdata; + memset(megaCfg, 0, sizeof(mega_host_config)); + printk(KERN_INFO " scsi%d: Found a MegaRAID controller at 0x%x, IRQ: %d" CRLFSTR, + host->host_no, (u_int)megaBase, megaIrq); + /* Copy resource info into structure */ - megaCfg->flag = flag; - megaCfg->host = host; - megaCfg->base = megaBase; - megaCfg->host->irq = megaIrq; - megaCfg->host->io_port = megaBase; + megaCfg->flag = flag; + megaCfg->host = host; + megaCfg->base = megaBase; + megaCfg->host->irq = megaIrq; + megaCfg->host->io_port = megaBase; megaCfg->host->n_io_port = 16; megaCfg->host->unique_id = (pciBus << 8) | pciDevFun; - megaCtlrs[numCtlrs++] = megaCfg; + megaCtlrs[numCtlrs++] = megaCfg; if (flag != BOARD_QUARTZ) { /* Request our IO Range */ - if (check_region (megaBase, 16)) { - printk (KERN_WARNING "megaraid: Couldn't register I/O range!" CRLFSTR); - scsi_unregister (host); + if (check_region(megaBase, 16)) { + printk(KERN_WARNING "megaraid: Couldn't register I/O range!" CRLFSTR); + scsi_unregister(host); continue; } - request_region (megaBase, 16, "megaraid"); + request_region(megaBase, 16, "megaraid"); } /* Request our IRQ */ - if (request_irq (megaIrq, megaraid_isr, SA_SHIRQ, - "megaraid", megaCfg)) { - printk (KERN_WARNING "megaraid: Couldn't register IRQ %d!" CRLFSTR, - megaIrq); - scsi_unregister (host); + if (request_irq(megaIrq, megaraid_isr, SA_SHIRQ, + "megaraid", megaCfg)) { + printk(KERN_WARNING "megaraid: Couldn't register IRQ %d!" CRLFSTR, + megaIrq); + scsi_unregister(host); continue; } - mega_register_mailbox (megaCfg, virt_to_bus ((void *) &megaCfg->mailbox)); - mega_i_query_adapter (megaCfg); + mega_register_mailbox(megaCfg, virt_to_bus((void*)&megaCfg->mailbox)); + mega_i_query_adapter(megaCfg); /* Initialize SCBs */ - initSCB (megaCfg); + initSCB(megaCfg); } return pciIdx; @@ -1203,22 +1082,23 @@ int findCard (Scsi_Host_Template * pHostTmpl, /*--------------------------------------------------------- * Detects if a megaraid controller exists in this system *---------------------------------------------------------*/ -int megaraid_detect (Scsi_Host_Template * pHostTmpl) +int megaraid_detect(Scsi_Host_Template *pHostTmpl) { int count = 0; pHostTmpl->proc_dir = &proc_scsi_megaraid; #if LINUX_VERSION_CODE < 0x20100 - if (!pcibios_present ()) { - printk (KERN_WARNING "megaraid: PCI bios not present." CRLFSTR); - return 0; - } + if (!pcibios_present()) + { + printk(KERN_WARNING "megaraid: PCI bios not present." CRLFSTR); + return 0; + } #endif - count += findCard (pHostTmpl, 0x101E, 0x9010, 0); - count += findCard (pHostTmpl, 0x101E, 0x9060, 0); - count += findCard (pHostTmpl, 0x8086, 0x1960, BOARD_QUARTZ); + count += findCard(pHostTmpl, 0x101E, 0x9010, 0); + count += findCard(pHostTmpl, 0x101E, 0x9060, 0); + count += findCard(pHostTmpl, 0x8086, 0x1960, BOARD_QUARTZ); return count; } @@ -1226,40 +1106,33 @@ int megaraid_detect (Scsi_Host_Template * pHostTmpl) /*--------------------------------------------------------------------- * Release the controller's resources *---------------------------------------------------------------------*/ -int megaraid_release (struct Scsi_Host *pSHost) +int megaraid_release(struct Scsi_Host *pSHost) { mega_host_config *megaCfg; - mega_mailbox *mbox; - u_char mboxData[16]; - int i; + mega_mailbox *mbox; + u_char mboxData[16]; - megaCfg = (mega_host_config *) pSHost->hostdata; - mbox = (mega_mailbox *) mboxData; + megaCfg = (mega_host_config*)pSHost->hostdata; + mbox = (mega_mailbox *)mboxData; /* Flush cache to disk */ - memset (mbox, 0, 16); + memset(mbox, 0, 16); mboxData[0] = 0xA; /* Issue a blocking (interrupts disabled) command to the card */ - MegaIssueCmd (megaCfg, mboxData, NULL, 0); + MegaIssueCmd(megaCfg, mboxData, NULL, 0); - schedule (); + schedule(); /* Free our resources */ if (megaCfg->flag & BOARD_QUARTZ) { - iounmap ((void *) megaCfg->base); + iounmap((void *)megaCfg->base); + } else { + release_region(megaCfg->host->io_port, 16); } - else { - release_region (megaCfg->host->io_port, 16); - } - free_irq (megaCfg->host->irq, megaCfg); /* Must be freed first, otherwise - - extra interrupt is generated */ - for (i = 0; i < megaCfg->max_cmds; i++) { - if (megaCfg->scbList[i].sgList) - kfree (megaCfg->scbList[i].sgList); /* free sgList */ - } - scsi_unregister (pSHost); + free_irq(megaCfg->host->irq, megaCfg); /* Must be freed first, otherwise + extra interrupt is generated */ + scsi_unregister(pSHost); return 0; } @@ -1267,20 +1140,20 @@ int megaraid_release (struct Scsi_Host *pSHost) /*---------------------------------------------- * Get information about the card/driver *----------------------------------------------*/ -const char * megaraid_info (struct Scsi_Host *pSHost) +const char *megaraid_info(struct Scsi_Host *pSHost) { - static char buffer[512]; - mega_host_config *megaCfg; - mega_RAIDINQ *adapterInfo; + static char buffer[512]; + mega_host_config *megaCfg; + mega_RAIDINQ *adapterInfo; - megaCfg = (mega_host_config *) pSHost->hostdata; - adapterInfo = (mega_RAIDINQ *) megaCfg->mega_buffer; + megaCfg = (mega_host_config *)pSHost->hostdata; + adapterInfo = (mega_RAIDINQ *)megaCfg->mega_buffer; - sprintf (buffer, "AMI MegaRAID %s %d commands %d targs %d chans", - megaCfg->fwVer, - adapterInfo->AdpInfo.MaxConcCmds, - megaCfg->host->max_id, - megaCfg->host->max_channel); + sprintf(buffer, "AMI MegaRAID %s %d commands %d targs %d chans", + megaCfg->fwVer, + adapterInfo->AdpInfo.MaxConcCmds, + megaCfg->host->max_id, + megaCfg->host->max_channel); return buffer; } @@ -1299,29 +1172,29 @@ const char * megaraid_info (struct Scsi_Host *pSHost) * 10 01 numstatus byte * 11 01 status byte *-----------------------------------------------------------------*/ -int megaraid_queue (Scsi_Cmnd * SCpnt, void (*pktComp) (Scsi_Cmnd *)) +int megaraid_queue(Scsi_Cmnd *SCpnt, void (*pktComp)(Scsi_Cmnd *)) { mega_host_config *megaCfg; - mega_scb *pScb; + mega_scb *pScb; - megaCfg = (mega_host_config *) SCpnt->host->hostdata; + megaCfg = (mega_host_config *)SCpnt->host->hostdata; if (!(megaCfg->flag & (1L << SCpnt->channel))) { - printk (KERN_INFO "scsi%d: scanning channel %c for devices.\n", - megaCfg->host->host_no, - SCpnt->channel + 'A'); + printk(KERN_INFO "scsi%d: scanning channel %c for devices.\n", + megaCfg->host->host_no, + SCpnt->channel + 'A'); megaCfg->flag |= (1L << SCpnt->channel); } SCpnt->scsi_done = pktComp; /* Allocate and build a SCB request */ - if ((pScb = mega_build_cmd (megaCfg, SCpnt)) != NULL) { + if ((pScb = mega_build_cmd(megaCfg, SCpnt)) != NULL) { /* Add SCB to the head of the pending queue */ - ENQUEUE (pScb, mega_scb, qPending, next); + ENQUEUE(pScb, mega_scb, qPending, next); /* Issue the command to the card */ - mega_runque (NULL); + mega_runque(NULL); } return 0; @@ -1329,44 +1202,37 @@ int megaraid_queue (Scsi_Cmnd * SCpnt, void (*pktComp) (Scsi_Cmnd *)) /*---------------------------------------------------------------------- * Issue a blocking command to the controller + * + * Note - this isnt 2.0.x SMP safe *----------------------------------------------------------------------*/ -volatile static int internal_done_flag = 0; +volatile static int internal_done_flag = 0; volatile static int internal_done_errcode = 0; -static void internal_done (Scsi_Cmnd * SCpnt) +static void internal_done(Scsi_Cmnd *SCpnt) { internal_done_errcode = SCpnt->result; internal_done_flag++; } /* - * This seems dangerous in an SMP environment because - * while spinning on internal_done_flag in 2.0.x SMP - * no IRQ's will be taken, including those that might - * be needed to clear this. + * This seems dangerous in an SMP environment because + * while spinning on internal_done_flag in 2.0.x SMP + * no IRQ's will be taken, including those that might + * be needed to clear this. * - * I think this should be using a wait queue ? - * -- AC - */ - -/* - * I'll probably fix this in the next version, but - * megaraid_command() will never get called since can_queue is set, - * except maybe in a *really* old kernel in which case it's very - * unlikely they'd be using SMP anyway. Really this function is - * just here for completeness. - * - JLJ + * I think this should be using a wait queue ? + * -- AC */ - -int megaraid_command (Scsi_Cmnd * SCpnt) + +int megaraid_command(Scsi_Cmnd *SCpnt) { internal_done_flag = 0; /* Queue command, and wait until it has completed */ - megaraid_queue (SCpnt, internal_done); + megaraid_queue(SCpnt, internal_done); - while (!internal_done_flag) - barrier (); + while(!internal_done_flag) + barrier(); return internal_done_errcode; } @@ -1374,67 +1240,67 @@ int megaraid_command (Scsi_Cmnd * SCpnt) /*--------------------------------------------------------------------- * Abort a previous SCSI request *---------------------------------------------------------------------*/ -int megaraid_abort (Scsi_Cmnd * SCpnt) +int megaraid_abort(Scsi_Cmnd *SCpnt) { mega_host_config *megaCfg; - int idx; - long flags; + int idx; + long flags; - spin_lock_irqsave (&mega_lock, flags); + spin_lock_irqsave(&mega_lock,flags); - megaCfg = (mega_host_config *) SCpnt->host->hostdata; + megaCfg = (mega_host_config *)SCpnt->host->hostdata; - TRACE (("ABORT!!! %.08lx %.02x <%d.%d.%d>\n", - SCpnt->serial_number, SCpnt->cmnd[0], SCpnt->channel, SCpnt->target, - SCpnt->lun)); + TRACE(("ABORT!!! %.08lx %.02x <%d.%d.%d>\n", + SCpnt->serial_number, SCpnt->cmnd[0], SCpnt->channel, SCpnt->target, + SCpnt->lun)); /* * Walk list of SCBs for any that are still outstanding */ - for (idx = 0; idx < megaCfg->max_cmds; idx++) { + for(idx=0; idxmax_cmds; idx++) { if (megaCfg->scbList[idx].idx >= 0) { if (megaCfg->scbList[idx].SCpnt == SCpnt) { - freeSCB (&megaCfg->scbList[idx]); + freeSCB(&megaCfg->scbList[idx]); - SCpnt->result = (DID_RESET << 16) | (SUGGEST_RETRY << 24); - callDone (SCpnt); + SCpnt->result = (DID_RESET << 16) | (SUGGEST_RETRY<<24); + callDone(SCpnt); } } } - spin_unlock_irqrestore (&mega_lock, flags); + spin_unlock_irqrestore(&mega_lock,flags); return SCSI_ABORT_SNOOZE; } /*--------------------------------------------------------------------- * Reset a previous SCSI request *---------------------------------------------------------------------*/ -int megaraid_reset (Scsi_Cmnd * SCpnt, unsigned int rstflags) +int megaraid_reset(Scsi_Cmnd *SCpnt, unsigned int rstflags) { mega_host_config *megaCfg; - int idx; - long flags; + int idx; + long flags; - spin_lock_irqsave (&mega_lock, flags); + spin_lock_irqsave(&mega_lock,flags); - megaCfg = (mega_host_config *) SCpnt->host->hostdata; + megaCfg = (mega_host_config *)SCpnt->host->hostdata; - TRACE (("RESET: %.08lx %.02x <%d.%d.%d>\n", - SCpnt->serial_number, SCpnt->cmnd[0], SCpnt->channel, SCpnt->target, - SCpnt->lun)); + TRACE(("RESET: %.08lx %.02x <%d.%d.%d>\n", + SCpnt->serial_number, SCpnt->cmnd[0], SCpnt->channel, SCpnt->target, + SCpnt->lun)); /* * Walk list of SCBs for any that are still outstanding */ - for (idx = 0; idx < megaCfg->max_cmds; idx++) { + for(idx=0; idxmax_cmds; idx++) { if (megaCfg->scbList[idx].idx >= 0) { SCpnt = megaCfg->scbList[idx].SCpnt; - freeSCB (&megaCfg->scbList[idx]); - SCpnt->result = (DID_RESET << 16) | (SUGGEST_RETRY << 24); - callDone (SCpnt); + freeSCB(&megaCfg->scbList[idx]); + SCpnt->result = (DID_RESET << 16) | (SUGGEST_RETRY<<24); + callDone(SCpnt); } } - spin_unlock_irqrestore (&mega_lock, flags); + spin_unlock_irqrestore(&mega_lock,flags); return SCSI_RESET_PUNT; -} +} /*------------------------------------------------------------- * Return the disk geometry for a particular disk @@ -1446,23 +1312,23 @@ int megaraid_reset (Scsi_Cmnd * SCpnt, unsigned int rstflags) * geom[1] = sectors * geom[2] = cylinders *-------------------------------------------------------------*/ -int megaraid_biosparam (Disk * disk, kdev_t dev, int *geom) +int megaraid_biosparam(Disk *disk, kdev_t dev, int *geom) { - int heads, sectors, cylinders; + int heads, sectors, cylinders; mega_host_config *megaCfg; /* Get pointer to host config structure */ - megaCfg = (mega_host_config *) disk->device->host->hostdata; + megaCfg = (mega_host_config *)disk->device->host->hostdata; /* Default heads (64) & sectors (32) */ - heads = 64; - sectors = 32; + heads = 64; + sectors = 32; cylinders = disk->capacity / (heads * sectors); /* Handle extended translation size for logical drives > 1Gb */ if (disk->capacity >= 0x200000) { - heads = 255; - sectors = 63; + heads = 255; + sectors = 63; cylinders = disk->capacity / (heads * sectors); } diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h index f9449c32876d..544240732533 100644 --- a/drivers/scsi/megaraid.h +++ b/drivers/scsi/megaraid.h @@ -1,10 +1,6 @@ #ifndef __MEGARAID_H__ #define __MEGARAID_H__ -#ifndef LINUX_VERSION_CODE -#include -#endif - #define IN_ISR 0x80000000L #define NO_INTR 0x40000000L #define IN_TIMEOUT 0x20000000L @@ -22,7 +18,7 @@ #define MEGA_CMD_TIMEOUT 10 -#define MAX_SGLIST 17 +#define MAX_SGLIST 20 #define MAX_COMMANDS 254 #define MAX_LOGICAL_DRIVES 8 @@ -98,8 +94,6 @@ #define PCI_CONF_BASE_ADDR_OFFSET 0x10 #define PCI_CONF_IRQ_OFFSET 0x3c -#define PCI_CONF_AMISIG 0xa0 -#define AMI_SIGNATURE 0x11223344 #if LINUX_VERSION_CODE < 0x20100 #define MEGARAID \ @@ -117,14 +111,14 @@ megaraid_reset, /* Reset Command Function */\ NULL, /* Slave Attach Function */\ megaraid_biosparam, /* Disk BIOS Parameters */\ - 254, /* # of cmds that can be\ + 1, /* # of cmds that can be\ outstanding at any time */\ 7, /* HBA Target ID */\ MAX_SGLIST, /* Scatter/Gather Table Size */\ - 64, /* SCSI Commands per LUN */\ + 1, /* SCSI Commands per LUN */\ 0, /* Present */\ 0, /* Default Unchecked ISA DMA */\ - ENABLE_CLUSTERING } /* Enable Clustering */ + ENABLE_CLUSTERING } /* Enable Clustering */ #else #define MEGARAID \ {\ @@ -138,10 +132,10 @@ abort: megaraid_abort, /* Abort Command Function */\ reset: megaraid_reset, /* Reset Command Function */\ bios_param: megaraid_biosparam, /* Disk BIOS Parameters */\ - can_queue: 254, /* Can Queue */\ + can_queue: 255, /* Can Queue */\ this_id: 7, /* HBA Target ID */\ sg_tablesize: MAX_SGLIST, /* Scatter/Gather Table Size */\ - cmd_per_lun: 64, /* SCSI Commands per LUN */\ + cmd_per_lun: 1, /* SCSI Commands per LUN */\ present: 0, /* Present */\ unchecked_isa_dma:0, /* Default Unchecked ISA DMA */\ use_clustering: ENABLE_CLUSTERING /* Enable Clustering */\ @@ -149,150 +143,140 @@ #endif /* Structures */ -typedef struct _mega_ADP_INFO { - u_char MaxConcCmds; - u_char RbldRate; - u_char MaxTargPerChan; - u_char ChanPresent; - u_char FwVer[4]; - u_short AgeOfFlash; - u_char ChipSet; - u_char DRAMSize; - u_char CacheFlushInterval; - u_char BiosVer[4]; - u_char resvd[7]; +typedef struct _mega_ADP_INFO +{ + u_char MaxConcCmds; + u_char RbldRate; + u_char MaxTargPerChan; + u_char ChanPresent; + u_char FwVer[4]; + u_short AgeOfFlash; + u_char ChipSet; + u_char DRAMSize; + u_char CacheFlushInterval; + u_char BiosVer[4]; + u_char resvd[7]; } mega_ADP_INFO; -typedef struct _mega_LDRV_INFO { - u_char NumLDrv; - u_char resvd[3]; - u_long LDrvSize[MAX_LOGICAL_DRIVES]; - u_char LDrvProp[MAX_LOGICAL_DRIVES]; - u_char LDrvState[MAX_LOGICAL_DRIVES]; +typedef struct _mega_LDRV_INFO +{ + u_char NumLDrv; + u_char resvd[3]; + u_long LDrvSize[MAX_LOGICAL_DRIVES]; + u_char LDrvProp[MAX_LOGICAL_DRIVES]; + u_char LDrvState[MAX_LOGICAL_DRIVES]; } mega_LDRV_INFO; -typedef struct _mega_PDRV_INFO { - u_char PDrvState[MAX_PHYSICAL_DRIVES]; - u_char resvd; +typedef struct _mega_PDRV_INFO +{ + u_char PDrvState[MAX_PHYSICAL_DRIVES]; + u_char resvd; } mega_PDRV_INFO; // RAID inquiry: Mailbox command 0x5 -typedef struct _mega_RAIDINQ { - mega_ADP_INFO AdpInfo; - mega_LDRV_INFO LogdrvInfo; - mega_PDRV_INFO PhysdrvInfo; +typedef struct _mega_RAIDINQ +{ + mega_ADP_INFO AdpInfo; + mega_LDRV_INFO LogdrvInfo; + mega_PDRV_INFO PhysdrvInfo; } mega_RAIDINQ; // Passthrough command: Mailbox command 0x3 -typedef struct mega_passthru { - u_char timeout:3; /* 0=6sec/1=60sec/2=10min/3=3hrs */ - u_char ars:1; - u_char reserved:3; - u_char islogical:1; - u_char logdrv; /* if islogical == 1 */ - u_char channel; /* if islogical == 0 */ - u_char target; /* if islogical == 0 */ - u_char queuetag; /* unused */ - u_char queueaction; /* unused */ - u_char cdb[MAX_CDB_LEN]; - u_char cdblen; - u_char reqsenselen; - u_char reqsensearea[MAX_REQ_SENSE_LEN]; - u_char numsgelements; - u_char scsistatus; - u_long dataxferaddr; - u_long dataxferlen; +typedef struct mega_passthru +{ + u_char timeout:3; /* 0=6sec/1=60sec/2=10min/3=3hrs */ + u_char ars:1; + u_char reserved:3; + u_char islogical:1; + u_char logdrv; /* if islogical == 1 */ + u_char channel; /* if islogical == 0 */ + u_char target; /* if islogical == 0 */ + u_char queuetag; /* unused */ + u_char queueaction; /* unused */ + u_char cdb[MAX_CDB_LEN]; + u_char cdblen; + u_char reqsenselen; + u_char reqsensearea[MAX_REQ_SENSE_LEN]; + u_char numsgelements; + u_char scsistatus; + u_long dataxferaddr; + u_long dataxferlen; } mega_passthru; -typedef struct _mega_mailbox { - /* 0x0 */ u_char cmd; - /* 0x1 */ u_char cmdid; - /* 0x2 */ u_short numsectors; - /* 0x4 */ u_long lba; - /* 0x8 */ u_long xferaddr; - /* 0xC */ u_char logdrv; - /* 0xD */ u_char numsgelements; - /* 0xE */ u_char resvd; - /* 0xF */ u_char busy; - /* 0x10 */ u_char numstatus; - /* 0x11 */ u_char status; - /* 0x12 */ u_char completed[46]; - u_char mraid_poll; - u_char mraid_ack; - u_char pad[16]; +typedef struct _mega_mailbox +{ + /* 0x0 */ u_char cmd; + /* 0x1 */ u_char cmdid; + /* 0x2 */ u_short numsectors; + /* 0x4 */ u_long lba; + /* 0x8 */ u_long xferaddr; + /* 0xC */ u_char logdrv; + /* 0xD */ u_char numsgelements; + /* 0xE */ u_char resvd; + /* 0xF */ u_char busy; + /* 0x10*/ u_char numstatus; + /* 0x11*/ u_char status; + /* 0x12*/ u_char completed[46]; + u_char mraid_poll; + u_char mraid_ack; + u_char pad[16]; } mega_mailbox; -typedef struct _mega_ioctl_mbox { - /* 0x0 */ u_char cmd; - /* 0x1 */ u_char cmdid; - /* 0x2 */ u_char channel; - /* 0x3 */ u_char param; - /* 0x4 */ u_char pad[4]; - /* 0x8 */ u_long xferaddr; - /* 0xC */ u_char logdrv; - /* 0xD */ u_char numsgelements; - /* 0xE */ u_char resvd; - /* 0xF */ u_char busy; - /* 0x10 */ u_char numstatus; - /* 0x11 */ u_char status; - /* 0x12 */ u_char completed[46]; - u_char mraid_poll; - u_char mraid_ack; - u_char malign[16]; -} mega_ioctl_mbox; - -typedef struct _mega_sglist { - u_long address; - u_long length; +typedef struct _mega_sglist +{ + u_long address; + u_long length; } mega_sglist; /* Queued command data */ typedef struct _mega_scb mega_scb; -struct _mega_scb { - int idx; - u_long flag; - Scsi_Cmnd *SCpnt; - u_char mboxData[16]; - mega_passthru pthru; - mega_sglist *sgList; - mega_scb *next; +struct _mega_scb +{ + int idx; + u_long flag; + Scsi_Cmnd *SCpnt; + u_char mboxData[16]; + mega_passthru pthru; + mega_sglist *sgList; + mega_scb *next; }; /* Per-controller data */ -typedef struct _mega_host_config { - u_char numldrv; - u_long flag; - u_long base; +typedef struct _mega_host_config +{ + u_char numldrv; + u_long flag; + u_long base; - struct tq_struct megaTq; + struct tq_struct megaTq; - /* Host adapter parameters */ - u_char fwVer[7]; - u_char biosVer[7]; + /* Host adapter parameters */ + u_char fwVer[7]; + u_char biosVer[7]; - struct Scsi_Host *host; + struct Scsi_Host *host; - /* The following must be DMA-able!! */ - volatile mega_mailbox *mbox; - volatile mega_mailbox mailbox; - volatile u_char mega_buffer[2 * 1024L]; + /* The following must be DMA-able!! */ + volatile mega_mailbox *mbox; + volatile mega_mailbox mailbox; + volatile u_char mega_buffer[2*1024L]; - u_char max_cmds; - mega_scb scbList[MAX_COMMANDS]; + u_char max_cmds; + mega_scb scbList[MAX_COMMANDS]; } mega_host_config; extern struct proc_dir_entry proc_scsi_megaraid; -const char *megaraid_info(struct Scsi_Host *); -int megaraid_detect(Scsi_Host_Template *); -int megaraid_release(struct Scsi_Host *); -int megaraid_command(Scsi_Cmnd *); -int megaraid_abort(Scsi_Cmnd *); -int megaraid_reset(Scsi_Cmnd *, unsigned int); -int megaraid_queue(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *)); -int megaraid_biosparam(Disk *, kdev_t, int *); -int megaraid_proc_info(char *buffer, char **start, off_t offset, - int length, int hostno, int inout); +const char *megaraid_info( struct Scsi_Host * ); +int megaraid_detect( Scsi_Host_Template * ); +int megaraid_release(struct Scsi_Host *); +int megaraid_command( Scsi_Cmnd * ); +int megaraid_abort( Scsi_Cmnd * ); +int megaraid_reset( Scsi_Cmnd *, unsigned int); +int megaraid_queue( Scsi_Cmnd *, void (*done)(Scsi_Cmnd *) ); +int megaraid_biosparam( Disk *, kdev_t, int * ); +int megaraid_proc_info( char *buffer, char **start, off_t offset, + int length, int hostno, int inout ); #endif diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index 3ba908db165f..1be3d9fedf0b 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c @@ -63,17 +63,11 @@ ** August 18 1997 by Cort : ** Support for Power/PC (Big Endian). ** -** June 20 1998 by Gerard Roudier : -** Support for up to 64 tags per lun. -** O(1) everywhere (C and SCRIPTS) for normal cases. -** Low PCI traffic for command handling when on-chip RAM is present. -** Aggressive SCSI SCRIPTS optimizations. -** ******************************************************************************* */ /* -** December 14 1998, version 3.1e +** 30 January 1998, version 2.5f.1 ** ** Supported SCSI-II features: ** Synchronous negotiation @@ -98,7 +92,9 @@ ** Shared IRQ (since linux-1.3.72) */ -#define SCSI_NCR_DEBUG_FLAGS (0) +#define SCSI_NCR_DEBUG_FLAGS (0) + +#define NCR_GETCC_WITHMSG /*========================================================== ** @@ -116,13 +112,11 @@ #include #include #include -#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93) -#include -#endif #include #include #include #include +#include #include #include #include @@ -133,7 +127,11 @@ #include #include +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,0) #include +#else +#include "../block/blk.h" +#endif #if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,35) #include @@ -146,10 +144,6 @@ #endif #endif -#if LINUX_VERSION_CODE <= LinuxVersionCode(2,1,92) -#include -#endif - #include "scsi.h" #include "hosts.h" #include "constants.h" @@ -158,178 +152,12 @@ #include /* -** Define BITS_PER_LONG for earlier linux versions. -*/ -#ifndef BITS_PER_LONG -#if (~0UL) == 0xffffffffUL -#define BITS_PER_LONG 32 -#else -#define BITS_PER_LONG 64 -#endif -#endif - -/* -** Define the BSD style u_int32 and u_int64 type. -** Are in fact u_int32_t and u_int64_t :-) +** Define the BSD style u_int32 type */ typedef u32 u_int32; -typedef u64 u_int64; #include "ncr53c8xx.h" -/*========================================================== -** -** A la VMS/CAM-3 queue management. -** Implemented from linux list management. -** -**========================================================== -*/ - -typedef struct xpt_quehead { - struct xpt_quehead *flink; /* Forward pointer */ - struct xpt_quehead *blink; /* Backward pointer */ -} XPT_QUEHEAD; - -#define xpt_que_init(ptr) do { \ - (ptr)->flink = (ptr); (ptr)->blink = (ptr); \ -} while (0) - -static inline void __xpt_que_add(struct xpt_quehead * new, - struct xpt_quehead * blink, - struct xpt_quehead * flink) -{ - flink->blink = new; - new->flink = flink; - new->blink = blink; - blink->flink = new; -} - -static inline void __xpt_que_del(struct xpt_quehead * blink, - struct xpt_quehead * flink) -{ - flink->blink = blink; - blink->flink = flink; -} - -static inline int xpt_que_empty(struct xpt_quehead *head) -{ - return head->flink == head; -} - -static inline void xpt_que_splice(struct xpt_quehead *list, - struct xpt_quehead *head) -{ - struct xpt_quehead *first = list->flink; - - if (first != list) { - struct xpt_quehead *last = list->blink; - struct xpt_quehead *at = head->flink; - - first->blink = head; - head->flink = first; - - last->flink = at; - at->blink = last; - } -} - -#define xpt_que_entry(ptr, type, member) \ - ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) - - -#define xpt_insque(new, pos) __xpt_que_add(new, pos, (pos)->flink) - -#define xpt_remque(el) __xpt_que_del((el)->blink, (el)->flink) - -#define xpt_insque_head(new, head) __xpt_que_add(new, head, (head)->flink) - -static inline struct xpt_quehead *xpt_remque_head(struct xpt_quehead *head) -{ - struct xpt_quehead *elem = head->flink; - - if (elem != head) - __xpt_que_del(head, elem->flink); - else - elem = 0; - return elem; -} - -#define xpt_insque_tail(new, head) __xpt_que_add(new, (head)->blink, head) - -static inline struct xpt_quehead *xpt_remque_tail(struct xpt_quehead *head) -{ - struct xpt_quehead *elem = head->blink; - - if (elem != head) - __xpt_que_del(elem->blink, head); - else - elem = 0; - return elem; -} - -/*========================================================== -** -** The CCB done queue uses an array of CCB virtual -** addresses. Empty entries are flagged using the bogus -** virtual address 0xffffffff. -** -** Since PCI ensures that only aligned DWORDs are accessed -** atomically, 64 bit little-endian architecture requires -** to test the high order DWORD of the entry to determine -** if it is empty or valid. -** -** BTW, I will make things differently as soon as I will -** have a better idea, but this is simple and should work. -** -**========================================================== -*/ - -#define SCSI_NCR_CCB_DONE_SUPPORT -#ifdef SCSI_NCR_CCB_DONE_SUPPORT - -#define MAX_DONE 24 -#define CCB_DONE_EMPTY 0xffffffffUL - -/* All 32 bit architectures */ -#if BITS_PER_LONG == 32 -#define CCB_DONE_VALID(cp) (((u_long) cp) != CCB_DONE_EMPTY) - -/* All > 32 bit (64 bit) architectures regardless endian-ness */ -#else -#define CCB_DONE_VALID(cp) \ - ((((u_long) cp) & 0xffffffff00000000ul) && \ - (((u_long) cp) & 0xfffffffful) != CCB_DONE_EMPTY) -#endif - -#endif /* SCSI_NCR_CCB_DONE_SUPPORT */ - -/*========================================================== -** -** On x86 architecture, write buffers management does -** not reorder writes to memory. So, using compiler -** optimization barriers is enough to guarantee some -** ordering when the CPU is writing data accessed by -** the NCR. -** On Alpha architecture, explicit memory barriers have -** to be used. -** Other architectures are defaulted to mb() macro if -** defined, otherwise use compiler barrier. -** -**========================================================== -*/ - -#if defined(__i386__) -#define MEMORY_BARRIER() barrier() -#elif defined(__alpha__) -#define MEMORY_BARRIER() mb() -#else -# ifdef mb -# define MEMORY_BARRIER() mb() -# else -# define MEMORY_BARRIER() barrier() -# endif -#endif - /*========================================================== ** ** Configuration and Debugging @@ -353,33 +181,13 @@ static inline struct xpt_quehead *xpt_remque_tail(struct xpt_quehead *head) */ #ifndef SCSI_NCR_MAX_TAGS -#define SCSI_NCR_MAX_TAGS (8) -#endif - -/* -** TAGS are actually limited to 64 tags/lun. -** We need to deal with power of 2, for alignment constraints. -*/ -#if SCSI_NCR_MAX_TAGS > 64 -#undef SCSI_NCR_MAX_TAGS -#define SCSI_NCR_MAX_TAGS (64) -#endif - -#define NO_TAG (255) - -/* -** Choose appropriate type for tag bitmap. -*/ -#if SCSI_NCR_MAX_TAGS > 32 -typedef u_int64 tagmap_t; -#else -typedef u_int32 tagmap_t; +#define SCSI_NCR_MAX_TAGS (4) #endif /* ** Number of targets supported by the driver. ** n permits target numbers 0..n-1. -** Default is 16, meaning targets #0..#15. +** Default is 7, meaning targets #0..#6. ** #7 .. is myself. */ @@ -425,23 +233,10 @@ typedef u_int32 tagmap_t; /* ** The maximum number of segments a transfer is split into. -** We support up to 127 segments for both read and write. -** The data scripts are broken into 2 sub-scripts. -** 80 (MAX_SCATTERL) segments are moved from a sub-script -** in on-chip RAM. This makes data transfers shorter than -** 80k (assuming 1k fs) as fast as possible. */ #define MAX_SCATTER (SCSI_NCR_MAX_SCATTER) -#if (MAX_SCATTER > 80) -#define MAX_SCATTERL 80 -#define MAX_SCATTERH (MAX_SCATTER - MAX_SCATTERL) -#else -#define MAX_SCATTERL (MAX_SCATTER-1) -#define MAX_SCATTERH 1 -#endif - /* ** Io mapped or memory mapped. */ @@ -471,6 +266,7 @@ typedef u_int32 tagmap_t; ** Obvious definitions */ +#define printf printk #define u_char unsigned char #define u_short unsigned short #define u_int unsigned int @@ -479,83 +275,27 @@ typedef u_int32 tagmap_t; typedef u_long vm_offset_t; typedef int vm_size_t; -#ifndef bcopy #define bcopy(s, d, n) memcpy((d), (s), (n)) -#endif -#ifndef bzero #define bzero(d, n) memset((d), 0, (n)) -#endif - + #ifndef offsetof #define offsetof(t, m) ((size_t) (&((t *)0)->m)) #endif -/* -** SMP threading. -** -** Assuming that SMP systems are generally high end systems and may -** use several SCSI adapters, we are using one lock per controller -** instead of some global one. For the moment (linux-2.1.95), driver's -** entry points are called with the 'io_request_lock' lock held, so: -** - We are uselessly loosing a couple of micro-seconds to lock the -** controller data structure. -** - But the driver is not broken by design for SMP and so can be -** more resistant to bugs or bad changes in the IO sub-system code. -** - A small advantage could be that the interrupt code is grained as -** wished (e.g.: threaded by controller). -*/ - -#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93) - -#if 0 /* not yet needed */ -static spinlock_t driver_lock; -#define NCR_LOCK_DRIVER(flags) spin_lock_irqsave(&driver_lock, flags) -#define NCR_UNLOCK_DRIVER(flags) spin_unlock_irqrestore(&driver_lock, flags) -#endif - -#define NCR_INIT_LOCK_NCB(np) spin_lock_init(&np->smp_lock); -#define NCR_LOCK_NCB(np, flags) spin_lock_irqsave(&np->smp_lock, flags) -#define NCR_UNLOCK_NCB(np, flags) spin_unlock_irqrestore(&np->smp_lock, flags) - -# if LINUX_VERSION_CODE < LinuxVersionCode(2,3,99) - -# define NCR_LOCK_SCSI_DONE(np, flags) \ - spin_lock_irqsave(&io_request_lock, flags) -# define NCR_UNLOCK_SCSI_DONE(np, flags) \ - spin_unlock_irqrestore(&io_request_lock, flags) - -# else - -# define NCR_LOCK_SCSI_DONE(np, flags) do {;} while (0) -# define NCR_UNLOCK_SCSI_DONE(np, flags) do {;} while (0) - -# endif - -#else - -#if 0 /* not yet needed */ -#define NCR_LOCK_DRIVER(flags) do {;} while (0) -#define NCR_UNLOCK_DRIVER(flags) do {;} while (0) -#endif - -#define NCR_INIT_LOCK_NCB(np) do { } while (0) -#define NCR_LOCK_NCB(np, flags) do { save_flags(flags); cli(); } while (0) -#define NCR_UNLOCK_NCB(np, flags) do { restore_flags(flags); } while (0) - -#define NCR_LOCK_SCSI_DONE(np, flags) do {;} while (0) -#define NCR_UNLOCK_SCSI_DONE(np, flags) do {;} while (0) - -#endif - /* ** Address translation ** -** The driver has to provide physical memory addresses to -** the script processor. Because some architectures use -** different physical addresses from the PCI BUS, we must -** use virt_to_bus instead of virt_to_phys. +** On Linux 1.3.X, virt_to_bus() must be used to translate +** virtual memory addresses of the kernel data segment into +** IO bus adresses. +** On i386 architecture, IO bus addresses match the physical +** addresses. But on other architectures they can be different. +** In the original Bsd driver, vtophys() is called to translate +** data addresses to IO bus addresses. In order to minimize +** change, I decide to define vtophys() as virt_to_bus(). */ +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,0) #define vtophys(p) virt_to_bus(p) /* @@ -569,29 +309,20 @@ static spinlock_t driver_lock; ** architecture. */ -#if LINUX_VERSION_CODE < LinuxVersionCode(2,1,0) -#define ioremap vremap -#define iounmap vfree -#endif - -#if defined (__sparc__) -#include -#elif defined (__alpha__) -#define bus_dvma_to_mem(p) ((p) & 0xfffffffful) -#else -#define bus_dvma_to_mem(p) (p) -#endif - -#if defined(__i386__) || !defined(NCR_IOMAPPED) +#ifndef NCR_IOMAPPED __initfunc( static vm_offset_t remap_pci_mem(u_long base, u_long size) ) { u_long page_base = ((u_long) base) & PAGE_MASK; u_long page_offs = ((u_long) base) - page_base; +#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,0) u_long page_remapped = (u_long) ioremap(page_base, page_offs+size); +#else + u_long page_remapped = (u_long) vremap(page_base, page_offs+size); +#endif - return (vm_offset_t) (page_remapped? (page_remapped + page_offs) : 0UL); + return (vm_offset_t) (page_remapped ? (page_remapped + page_offs) : 0UL); } __initfunc( @@ -599,29 +330,37 @@ static void unmap_pci_mem(vm_offset_t vaddr, u_long size) ) { if (vaddr) +#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,0) iounmap((void *) (vaddr & PAGE_MASK)); +#else + vfree((void *) (vaddr & PAGE_MASK)); +#endif } -#endif /* __i386__ || !NCR_IOMAPPED */ +#endif /* !NCR_IOMAPPED */ + +#else /* linux-1.2.13 */ /* -** Insert a delay in micro-seconds and milli-seconds. -** ------------------------------------------------- -** Under Linux, udelay() is restricted to delay < 1 milli-second. -** In fact, it generally works for up to 1 second delay. -** Since 2.1.105, the mdelay() function is provided for delays -** in milli-seconds. -** Under 2.0 kernels, udelay() is an inline function that is very -** inaccurate on Pentium processors. -*/ - -#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,105) -#define UDELAY udelay -#define MDELAY mdelay -#else -static void UDELAY(long us) { udelay(us); } -static void MDELAY(long ms) { while (ms--) UDELAY(1000); } +** Linux 1.2.X assumes that addresses (virtual, physical, bus) +** are the same. +** +** I have not found how to do MMIO. It seems that only processes can +** map high physical pages to virtual (Xservers can do MMIO). +*/ + +#define vtophys(p) ((u_long) (p)) #endif +/* +** Insert a delay in micro-seconds. +*/ + +static void DELAY(long us) +{ + for (;us>1000;us-=1000) udelay(1000); + if (us) udelay(us); +} + /* ** Internal data structure allocation. ** @@ -629,10 +368,13 @@ static void MDELAY(long ms) { while (ms--) UDELAY(1000); } ** middle-level scsi driver. ** We allocate our control blocks in the kernel memory pool ** to avoid scsi pool shortage. +** I notice that kmalloc() returns NULL during host attach under +** Linux 1.2.13. But this ncr driver is reliable enough to +** accomodate with this joke. ** -** kmalloc() only ensures 8 bytes boundary alignment. +** kmalloc() only ensure 8 bytes boundary alignment. ** The NCR need better alignment for cache line bursting. -** The global header is moved between the NCB and CCBs and needs +** The global header is moved betewen the NCB and CCBs and need ** origin and destination addresses to have same lower four bits. ** ** We use 32 boundary alignment for NCB and CCBs and offset multiple @@ -642,9 +384,17 @@ static void MDELAY(long ms) { while (ms--) UDELAY(1000); } #define ALIGN_SIZE(shift) (1UL << shift) #define ALIGN_MASK(shift) (~(ALIGN_SIZE(shift)-1)) -#define CACHE_LINE_SHIFT 5 -#define CACHE_LINE_SIZE ALIGN_SIZE(CACHE_LINE_SHIFT) -#define CACHE_LINE_MASK ALIGN_MASK(CACHE_LINE_SHIFT) +#define NCB_ALIGN_SHIFT 5 +#define CCB_ALIGN_SHIFT 5 +#define LCB_ALIGN_SHIFT 5 +#define SCR_ALIGN_SHIFT 5 + +#define NCB_ALIGN_SIZE ALIGN_SIZE(NCB_ALIGN_SHIFT) +#define NCB_ALIGN_MASK ALIGN_MASK(NCB_ALIGN_SHIFT) +#define CCB_ALIGN_SIZE ALIGN_SIZE(CCB_ALIGN_SHIFT) +#define CCB_ALIGN_MASK ALIGN_MASK(CCB_ALIGN_SHIFT) +#define SCR_ALIGN_SIZE ALIGN_SIZE(SCR_ALIGN_SHIFT) +#define SCR_ALIGN_MASK ALIGN_MASK(SCR_ALIGN_SHIFT) static void *m_alloc(int size, int a_shift) { @@ -698,8 +448,11 @@ static void m_free(void *ptr, int size) ** be able to transfer data in the direction choosen by the target. */ -#define XFER_IN (1) -#define XFER_OUT (2) +#define XferNone 0 +#define XferIn 1 +#define XferOut 2 +#define XferBoth 3 +static int guess_xfer_direction(int opcode); /* ** Head of list of NCR boards @@ -717,15 +470,30 @@ static Scsi_Host_Template *the_template = NULL; ** /proc directory entry and proc_info function */ +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,0) struct proc_dir_entry proc_scsi_ncr53c8xx = { PROC_SCSI_NCR53C8XX, 9, "ncr53c8xx", S_IFDIR | S_IRUGO | S_IXUGO, 2 }; -#ifdef SCSI_NCR_PROC_INFO_SUPPORT +# ifdef SCSI_NCR_PROC_INFO_SUPPORT int ncr53c8xx_proc_info(char *buffer, char **start, off_t offset, int length, int hostno, int func); +# endif #endif +/* +** Table of target capabilities. +** +** This bitmap is anded with the byte 7 of inquiry data on completion of +** INQUIRY command. +** The driver never see zeroed bits and will ignore the corresponding +** capabilities of the target. +*/ + +static struct { + unsigned char and_map[MAX_TARGET]; +} target_capabilities[SCSI_NCR_MAX_HOST] = { NCR53C8XX_TARGET_CAPABILITIES }; + /* ** Driver setup. ** @@ -733,14 +501,14 @@ int ncr53c8xx_proc_info(char *buffer, char **start, off_t offset, ** It can be overridden at boot-up by the boot command line. */ struct ncr_driver_setup { - u_char master_parity; - u_char scsi_parity; - u_char disconnection; - u_char special_features; - u_char ultra_scsi; - u_char force_sync_nego; - u_char reverse_probe; - u_char pci_fix_up; + unsigned master_parity : 1; + unsigned scsi_parity : 1; + unsigned disconnection : 1; + unsigned special_features : 2; + unsigned ultra_scsi : 2; + unsigned force_sync_nego: 1; + unsigned reverse_probe: 1; + unsigned pci_fix_up: 4; u_char use_nvram; u_char verbose; u_char default_tags; @@ -753,7 +521,6 @@ struct ncr_driver_setup { u_char diff_support; u_char irqm; u_char bus_check; - char tag_ctrl[100]; }; static struct ncr_driver_setup @@ -762,12 +529,9 @@ static struct ncr_driver_setup #ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT static struct ncr_driver_setup driver_safe_setup __initdata = SCSI_NCR_DRIVER_SAFE_SETUP; -# ifdef MODULE +#ifdef MODULE char *ncr53c8xx = 0; /* command line passed by insmod */ -# if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,30) -MODULE_PARM(ncr53c8xx, "s"); -# endif -# endif +#endif #endif /* @@ -776,9 +540,16 @@ MODULE_PARM(ncr53c8xx, "s"); #define ScsiResult(host_code, scsi_code) (((host_code) << 16) + ((scsi_code) & 0x7f)) -static void ncr53c8xx_select_queue_depths( - struct Scsi_Host *host, struct scsi_device *devlist); +#if LINUX_VERSION_CODE >= LinuxVersionCode(2,0,0) +static void ncr53c8xx_select_queue_depths(struct Scsi_Host *host, struct scsi_device *devlist); +#endif + +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,70) static void ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs); +#else +static void ncr53c8xx_intr(int irq, struct pt_regs * regs); +#endif + static void ncr53c8xx_timeout(unsigned long np); #define initverbose (driver_setup.verbose) @@ -805,7 +576,6 @@ struct Symbios_nvram { #define SYMBIOS_SCAM_ENABLE (1) #define SYMBIOS_PARITY_ENABLE (1<<1) #define SYMBIOS_VERBOSE_MSGS (1<<2) -#define SYMBIOS_CHS_MAPPING (1<<3) u_short flags1; #define SYMBIOS_SCAN_HI_LO (1) u_short word10; /* 0x00 */ @@ -896,13 +666,13 @@ static u_char Tekram_sync[12] __initdata = {25,31,37,43,50,62,75,125,12,15,18,21 typedef struct { int bus; u_char device_fn; - u_long base; - u_long base_2; - u_long io_port; + u_int base; + u_int base_2; + u_int io_port; int irq; /* port and reg fields to use INB, OUTB macros */ - u_long port; - volatile struct ncr_reg *reg; + u_int port; + volatile struct ncr_reg *reg; } ncr_slot; typedef struct { @@ -975,7 +745,7 @@ typedef struct { #define assert(expression) { \ if (!(expression)) { \ - (void)printk(KERN_ERR \ + (void)printf(\ "assertion \"%s\" failed: file \"%s\", line %d\n", \ #expression, \ __FILE__, __LINE__); \ @@ -1038,12 +808,7 @@ typedef struct { ** ** Access to the controller chip. ** -** If NCR_IOMAPPED is defined, the driver will use -** normal IOs instead of the MEMORY MAPPED IO method -** recommended by PCI specifications. -** If all PCI bridges, host brigdes and architectures -** would have been correctly designed for PCI, this -** option would be useless. +** If NCR_IOMAPPED is defined, only IO are used by the driver. ** **========================================================== */ @@ -1163,31 +928,15 @@ typedef struct { #define HS_NEGOTIATE (2) /* sync/wide data transfer*/ #define HS_DISCONNECT (3) /* Disconnected by target */ -#define HS_DONEMASK (0x80) -#define HS_COMPLETE (4|HS_DONEMASK) -#define HS_SEL_TIMEOUT (5|HS_DONEMASK) /* Selection timeout */ -#define HS_RESET (6|HS_DONEMASK) /* SCSI reset */ -#define HS_ABORTED (7|HS_DONEMASK) /* Transfer aborted */ -#define HS_TIMEOUT (8|HS_DONEMASK) /* Software timeout */ -#define HS_FAIL (9|HS_DONEMASK) /* SCSI or PCI bus errors */ -#define HS_UNEXPECTED (10|HS_DONEMASK)/* Unexpected disconnect */ - -/* -** Invalid host status values used by the SCRIPTS processor -** when the nexus is not fully identified. -** Shall never appear in a CCB. -*/ - -#define HS_INVALMASK (0x40) -#define HS_SELECTING (0|HS_INVALMASK) -#define HS_IN_RESELECT (1|HS_INVALMASK) -#define HS_STARTING (2|HS_INVALMASK) +#define HS_COMPLETE (4) +#define HS_SEL_TIMEOUT (5) /* Selection timeout */ +#define HS_RESET (6) /* SCSI reset */ +#define HS_ABORTED (7) /* Transfer aborted */ +#define HS_TIMEOUT (8) /* Software timeout */ +#define HS_FAIL (9) /* SCSI or PCI bus errors */ +#define HS_UNEXPECTED (10) /* Unexpected disconnect */ -/* -** Flags set by the SCRIPT processor for commands -** that have been skipped. -*/ -#define HS_SKIPMASK (0x20) +#define HS_DONEMASK (0xfc) /*========================================================== ** @@ -1196,24 +945,21 @@ typedef struct { **========================================================== */ -#define SIR_BAD_STATUS (1) -#define SIR_XXXXXXXXXX (2) -#define SIR_NEGO_SYNC (3) -#define SIR_NEGO_WIDE (4) -#define SIR_NEGO_FAILED (5) -#define SIR_NEGO_PROTO (6) -#define SIR_REJECT_RECEIVED (7) -#define SIR_REJECT_SENT (8) -#define SIR_IGN_RESIDUE (9) -#define SIR_MISSING_SAVE (10) -#define SIR_RESEL_NO_MSG_IN (11) -#define SIR_RESEL_NO_IDENTIFY (12) -#define SIR_RESEL_BAD_LUN (13) -#define SIR_RESEL_BAD_TARGET (14) -#define SIR_RESEL_BAD_I_T_L (15) -#define SIR_RESEL_BAD_I_T_L_Q (16) -#define SIR_DONE_OVERFLOW (17) -#define SIR_MAX (17) +#define SIR_SENSE_RESTART (1) +#define SIR_SENSE_FAILED (2) +#define SIR_STALL_RESTART (3) +#define SIR_STALL_QUEUE (4) +#define SIR_NEGO_SYNC (5) +#define SIR_NEGO_WIDE (6) +#define SIR_NEGO_FAILED (7) +#define SIR_NEGO_PROTO (8) +#define SIR_REJECT_RECEIVED (9) +#define SIR_REJECT_SENT (10) +#define SIR_IGN_RESIDUE (11) +#define SIR_MISSING_SAVE (12) +#define SIR_DATA_IO_IS_OUT (13) +#define SIR_DATA_IO_IS_IN (14) +#define SIR_MAX (14) /*========================================================== ** @@ -1251,6 +997,7 @@ typedef struct { #define QUIRK_NOMSG (0x02) #define QUIRK_NOSYNC (0x10) #define QUIRK_NOWIDE16 (0x20) +#define QUIRK_UPDATE (0x80) /*========================================================== ** @@ -1309,7 +1056,10 @@ struct usrcmd { #define UC_SETWIDE 14 #define UC_SETFLAG 15 #define UC_CLEARPROF 16 -#define UC_SETVERBOSE 17 + +#ifdef SCSI_NCR_DEBUG_ERROR_RECOVERY_SUPPORT +#define UC_DEBUG_ERROR_RECOVERY 17 +#endif #define UF_TRACE (0x01) #define UF_NODISC (0x02) @@ -1322,11 +1072,10 @@ struct usrcmd { **--------------------------------------- */ -#ifdef SCSI_NCR_PROFILE_SUPPORT - struct tstamp { u_long start; u_long end; + u_long select; u_long command; u_long status; u_long disconnect; @@ -1350,257 +1099,263 @@ struct profile { u_long ms_disc; u_long ms_post; }; -#endif -/*======================================================================== +/*========================================================== ** ** Declaration of structs: target control block ** -**======================================================================== +**========================================================== */ + struct tcb { - /*---------------------------------------------------------------- - ** During reselection the ncr jumps to this point with SFBR - ** set to the encoded target number with bit 7 set. + /* + ** during reselection the ncr jumps to this point + ** with SFBR set to the encoded target number + ** with bit 7 set. ** if it's not this target, jump to the next. ** - ** JUMP IF (SFBR != #target#), @(next tcb) - **---------------------------------------------------------------- + ** JUMP IF (SFBR != #target#) + ** @(next tcb) */ + struct link jump_tcb; - /*---------------------------------------------------------------- - ** Load the actual values for the sxfer and the scntl3 + /* + ** load the actual values for the sxfer and the scntl3 ** register (sync/wide mode). ** - ** SCR_COPY (1), @(sval field of this tcb), @(sxfer register) - ** SCR_COPY (1), @(wval field of this tcb), @(scntl3 register) - **---------------------------------------------------------------- + ** SCR_COPY (1); + ** @(sval field of this tcb) + ** @(sxfer register) + ** SCR_COPY (1); + ** @(wval field of this tcb) + ** @(scntl3 register) */ + ncrcmd getscr[6]; - /*---------------------------------------------------------------- - ** Get the IDENTIFY message and load the LUN to SFBR. + /* + ** if next message is "identify" + ** then load the message to SFBR, + ** else load 0 to SFBR. ** - ** CALL, - **---------------------------------------------------------------- + ** CALL + ** */ + struct link call_lun; - /*---------------------------------------------------------------- - ** Now look for the right lun. - ** - ** For i = 0 to 3 - ** SCR_JUMP ^ IFTRUE(MASK(i, 3)), @(first lcb mod. i) + /* + ** now look for the right lun. ** - ** Recent chips will prefetch the 4 JUMPS using only 1 burst. - ** It is kind of hashcoding. - **---------------------------------------------------------------- - */ - struct link jump_lcb[4]; /* JUMPs for reselection */ - lcb_p lp[MAX_LUN]; /* The lcb's of this tcb */ - u_char inq_done; /* Target capabilities received */ - u_char inq_byte7; /* Contains these capabilities */ - - /*---------------------------------------------------------------- - ** Pointer to the ccb used for negotiation. - ** Prevent from starting a negotiation for all queued commands + ** JUMP + ** @(first ccb of this lun) + */ + + struct link jump_lcb; + + /* + ** pointer to interrupted getcc ccb + */ + + ccb_p hold_cp; + + /* + ** pointer to ccb used for negotiating. + ** Avoid to start a nego for all queued commands ** when tagged command queuing is enabled. - **---------------------------------------------------------------- */ + ccb_p nego_cp; - /*---------------------------------------------------------------- + /* ** statistical data - **---------------------------------------------------------------- */ + u_long transfers; u_long bytes; - /*---------------------------------------------------------------- - ** negotiation of wide and synch transfer and device quirks. - **---------------------------------------------------------------- + /* + ** user settable limits for sync transfer + ** and tagged commands. + ** These limits are read from the NVRAM if present. + */ + + u_char usrsync; + u_char usrwide; + u_char usrtags; + u_char usrflag; + + u_char numtags; + u_char maxtags; + u_short num_good; + + /* + ** negotiation of wide and synch transfer. + ** device quirks. */ + /*0*/ u_char minsync; /*1*/ u_char sval; /*2*/ u_short period; /*0*/ u_char maxoffs; + /*1*/ u_char quirks; + /*2*/ u_char widedone; /*3*/ u_char wval; + /* + ** inquire data + */ +#define MAX_INQUIRE 36 + u_char inqdata[MAX_INQUIRE]; - /*---------------------------------------------------------------- - ** User settable limits and options. - ** These limits are read from the NVRAM if present. - **---------------------------------------------------------------- + /* + ** the lcb's of this tcb */ - u_char usrsync; - u_char usrwide; - u_char usrtags; - u_char usrflag; + + lcb_p lp[MAX_LUN]; }; -/*======================================================================== +/*========================================================== ** ** Declaration of structs: lun control block ** -**======================================================================== +**========================================================== */ + struct lcb { - /*---------------------------------------------------------------- - ** During reselection the ncr jumps to this point + /* + ** during reselection the ncr jumps to this point ** with SFBR set to the "Identify" message. ** if it's not this lun, jump to the next. ** - ** JUMP IF (SFBR != #lun#), @(next lcb of this target) + ** JUMP IF (SFBR != #lun#) + ** @(next lcb of this target) + */ + + struct link jump_lcb; + + /* + ** if next message is "simple tag", + ** then load the tag to SFBR, + ** else load 0 to SFBR. ** - ** It is this lun. Load TEMP with the nexus jumps table - ** address and jump to RESEL_TAG (or RESEL_NOTAG). + ** CALL + ** + */ + + struct link call_tag; + + /* + ** now look for the right ccb. ** - ** SCR_COPY (4), p_jump_ccb, TEMP, - ** SCR_JUMP, - **---------------------------------------------------------------- + ** JUMP + ** @(first ccb of this lun) */ - struct link jump_lcb; - ncrcmd load_jump_ccb[3]; - struct link jump_tag; - ncrcmd p_jump_ccb; /* Jump table bus address */ - - /*---------------------------------------------------------------- - ** Jump table used by the script processor to directly jump - ** to the CCB corresponding to the reselected nexus. - ** Address is allocated on 256 bytes boundary in order to - ** allow 8 bit calculation of the tag jump entry for up to - ** 64 possible tags. - **---------------------------------------------------------------- - */ - u_int32 jump_ccb_0; /* Default table if no tags */ - u_int32 *jump_ccb; /* Virtual address */ - - /*---------------------------------------------------------------- - ** CCB queue management. - **---------------------------------------------------------------- - */ - XPT_QUEHEAD free_ccbq; /* Queue of available CCBs */ - XPT_QUEHEAD busy_ccbq; /* Queue of busy CCBs */ - XPT_QUEHEAD wait_ccbq; /* Queue of waiting for IO CCBs */ - XPT_QUEHEAD skip_ccbq; /* Queue of skipped CCBs */ - u_char actccbs; /* Number of allocated CCBs */ - u_char busyccbs; /* CCBs busy for this lun */ - u_char queuedccbs; /* CCBs queued to the controller*/ - u_char queuedepth; /* Queue depth for this lun */ - u_char scdev_depth; /* SCSI device queue depth */ - u_char maxnxs; /* Max possible nexuses */ - - /*---------------------------------------------------------------- - ** Control of tagged command queuing. - ** Tags allocation is performed using a circular buffer. - ** This avoids using a loop for tag allocation. - **---------------------------------------------------------------- - */ - u_char ia_tag; /* Allocation index */ - u_char if_tag; /* Freeing index */ - u_char cb_tags[SCSI_NCR_MAX_TAGS]; /* Circular tags buffer */ - u_char usetags; /* Command queuing is active */ - u_char maxtags; /* Max nr of tags asked by user */ - u_char numtags; /* Current number of tags */ - u_char inq_byte7; /* Store unit CmdQ capabitility */ - - /*---------------------------------------------------------------- - ** QUEUE FULL control and ORDERED tag control. - **---------------------------------------------------------------- - */ - /*---------------------------------------------------------------- - ** QUEUE FULL and ORDERED tag control. - **---------------------------------------------------------------- - */ - u_short num_good; /* Nr of GOOD since QUEUE FULL */ - tagmap_t tags_umap; /* Used tags bitmap */ - tagmap_t tags_smap; /* Tags in use at 'tag_stime' */ - u_long tags_stime; /* Last time we set smap=umap */ - ccb_p held_ccb; /* CCB held for QUEUE FULL */ -}; -/*======================================================================== -** -** Declaration of structs: the launch script. -** -**======================================================================== -** -** It is part of the CCB and is called by the scripts processor to -** start or restart the data structure (nexus). -** This 6 DWORDs mini script makes use of prefetching. -** -**------------------------------------------------------------------------ -*/ -struct launch { - /*---------------------------------------------------------------- - ** SCR_COPY(4), @(p_phys), @(dsa register) - ** SCR_JUMP, @(scheduler_point) - **---------------------------------------------------------------- + struct link jump_ccb; + + /* + ** start of the ccb chain + */ + + ccb_p next_ccb; + + /* + ** Control of tagged queueing + */ + + u_char reqccbs; + u_char actccbs; + u_char reqlink; + u_char actlink; + u_char usetags; + u_char lasttag; + + /* + ** Linux specific fields: + ** Number of active commands and current credit. + ** Should be managed by the generic scsi driver + */ + + u_char active; + u_char opennings; + + /*----------------------------------------------- + ** Flag to force M_ORDERED_TAG on next command + ** in order to avoid spurious timeout when + ** M_SIMPLE_TAG is used for all operations. + **----------------------------------------------- */ - ncrcmd setup_dsa[3]; /* Copy 'phys' address to dsa */ - struct link schedule; /* Jump to scheduler point */ - ncrcmd p_phys; /* 'phys' header bus address */ + u_char force_ordered_tag; +#define NCR_TIMEOUT_INCREASE (5*HZ) }; -/*======================================================================== +/*========================================================== ** -** Declaration of structs: global HEADER. +** Declaration of structs: COMMAND control block ** -**======================================================================== +**========================================================== ** -** This substructure is copied from the ccb to a global address after -** selection (or reselection) and copied back before disconnect. +** This substructure is copied from the ccb to a +** global address after selection (or reselection) +** and copied back before disconnect. ** ** These fields are accessible to the script processor. ** -**------------------------------------------------------------------------ +**---------------------------------------------------------- */ struct head { - /*---------------------------------------------------------------- + /* + ** Execution of a ccb starts at this point. + ** It's a jump to the "SELECT" label + ** of the script. + ** + ** After successful selection the script + ** processor overwrites it with a jump to + ** the IDLE label of the script. + */ + + struct link launch; + + /* ** Saved data pointer. - ** Points to the position in the script responsible for the - ** actual transfer transfer of data. - ** It's written after reception of a SAVE_DATA_POINTER message. - ** The goalpointer points after the last transfer command. - **---------------------------------------------------------------- + ** Points to the position in the script + ** responsible for the actual transfer + ** of data. + ** It's written after reception of a + ** "SAVE_DATA_POINTER" message. + ** The goalpointer points after + ** the last transfer command. */ + u_int32 savep; u_int32 lastp; u_int32 goalp; - /*---------------------------------------------------------------- - ** Alternate data pointer. - ** They are copied back to savep/lastp/goalp by the SCRIPTS - ** when the direction is unknown and the device claims data out. - **---------------------------------------------------------------- + /* + ** The virtual address of the ccb + ** containing this header. */ - u_int32 wlastp; - u_int32 wgoalp; - /*---------------------------------------------------------------- - ** The virtual address of the ccb containing this header. - **---------------------------------------------------------------- - */ ccb_p cp; -#ifdef SCSI_NCR_PROFILE_SUPPORT - /*---------------------------------------------------------------- - ** Space for some timestamps to gather profiling data. - **---------------------------------------------------------------- + /* + ** space for some timestamps to gather + ** profiling data about devices and this driver. */ + struct tstamp stamp; -#endif - /*---------------------------------------------------------------- - ** Status fields. - **---------------------------------------------------------------- + /* + ** status fields. */ - u_char scr_st[4]; /* script status */ - u_char status[4]; /* host status. must be the */ - /* last DWORD of the header. */ + + u_char scr_st[4]; /* script status */ + u_char status[4]; /* host status. Must be the last */ + /* DWORD of the CCB header */ }; /* @@ -1633,7 +1388,6 @@ struct head { #define HS_REG scr1 #define HS_PRT nc_scr1 #define SS_REG scr2 -#define SS_PRT nc_scr2 #define PS_REG scr3 /* @@ -1656,12 +1410,9 @@ struct head { ** First four bytes (host) */ #define xerr_status phys.xerr_st -#define nego_status phys.nego_st - -#if 0 #define sync_status phys.sync_st +#define nego_status phys.nego_st #define wide_status phys.wide_st -#endif /*========================================================== ** @@ -1683,6 +1434,9 @@ struct dsb { /* ** Header. + ** Has to be the first entry, + ** because it's jumped to by the + ** script processor */ struct head header; @@ -1693,276 +1447,403 @@ struct dsb { struct scr_tblsel select; struct scr_tblmove smsg ; + struct scr_tblmove smsg2 ; struct scr_tblmove cmd ; + struct scr_tblmove scmd ; struct scr_tblmove sense ; struct scr_tblmove data [MAX_SCATTER]; }; - -/*======================================================================== +/*========================================================== ** ** Declaration of structs: Command control block. ** -**======================================================================== +**========================================================== +** +** During execution of a ccb by the script processor, +** the DSA (data structure address) register points +** to this substructure of the ccb. +** This substructure contains the header with +** the script-processor-changable data and then +** data blocks for the indirect move commands. +** +**---------------------------------------------------------- */ + + struct ccb { - /*---------------------------------------------------------------- - ** This is the data structure which is pointed by the DSA - ** register when it is executed by the script processor. - ** It must be the first entry because it contains the header - ** as first entry that must be cache line aligned. - **---------------------------------------------------------------- + /* + ** This field forces 32 bytes alignement for phys.header, + ** in order to use cache line bursting when copying it + ** to the ncb. + */ + + struct link filler[2]; + + /* + ** during reselection the ncr jumps to this point. + ** If a "SIMPLE_TAG" message was received, + ** then SFBR is set to the tag. + ** else SFBR is set to 0 + ** If looking for another tag, jump to the next ccb. + ** + ** JUMP IF (SFBR != #TAG#) + ** @(next ccb of this lun) */ - struct dsb phys; - /*---------------------------------------------------------------- - ** Mini-script used at CCB execution start-up. - ** Load the DSA with the data structure address (phys) and - ** jump to SELECT. Jump to CANCEL if CCB is to be canceled. - **---------------------------------------------------------------- + struct link jump_ccb; + + /* + ** After execution of this call, the return address + ** (in the TEMP register) points to the following + ** data structure block. + ** So copy it to the DSA register, and start + ** processing of this data structure. + ** + ** CALL + ** */ - struct launch start; - /*---------------------------------------------------------------- - ** Mini-script used at CCB relection to restart the nexus. - ** Load the DSA with the data structure address (phys) and - ** jump to RESEL_DSA. Jump to ABORT if CCB is to be aborted. - **---------------------------------------------------------------- + struct link call_tmp; + + /* + ** This is the data structure which is + ** to be executed by the script processor. */ - struct launch restart; - /*---------------------------------------------------------------- + struct dsb phys; + + /* ** If a data transfer phase is terminated too early ** (after reception of a message (i.e. DISCONNECT)), ** we have to prepare a mini script to transfer ** the rest of the data. - **---------------------------------------------------------------- */ - ncrcmd patch[8]; - /*---------------------------------------------------------------- + ncrcmd patch[8]; + + /* ** The general SCSI driver provides a ** pointer to a control block. - **---------------------------------------------------------------- */ - Scsi_Cmnd *cmd; /* SCSI command */ - u_long tlimit; /* Deadline for this job */ - int data_len; /* Total data length */ - /*---------------------------------------------------------------- - ** Message areas. - ** We prepare a message to be sent after selection. - ** We may use a second one if the command is rescheduled - ** due to GETCC or QFULL. + Scsi_Cmnd *cmd; + int data_len; + + /* + ** We prepare a message to be sent after selection, + ** and a second one to be sent after getcc selection. ** Contents are IDENTIFY and SIMPLE_TAG. ** While negotiating sync or wide transfer, - ** a SDTR or WDTR message is appended. - **---------------------------------------------------------------- - */ - u_char scsi_smsg [8]; - u_char scsi_smsg2[8]; - - /*---------------------------------------------------------------- - ** Other fields. - **---------------------------------------------------------------- - */ - u_long p_ccb; /* BUS address of this CCB */ - u_char sensecmd[6]; /* Sense command */ - u_char tag; /* Tag for this transfer */ - /* 255 means no tag */ - u_char target; - u_char lun; - u_char queued; - u_char auto_sense; - ccb_p link_ccb; /* Host adapter CCB chain */ - XPT_QUEHEAD link_ccbq; /* Link to unit CCB queue */ - u_int32 startp; /* Initial data pointer */ - u_long magic; /* Free / busy CCB flag */ + ** a SDTM or WDTM message is appended. + */ + + u_char scsi_smsg [8]; + u_char scsi_smsg2[8]; + + /* + ** Lock this ccb. + ** Flag is used while looking for a free ccb. + */ + + u_long magic; + + /* + ** Physical address of this instance of ccb + */ + + u_long p_ccb; + + /* + ** Completion time out for this job. + ** It's set to time of start + allowed number of seconds. + */ + + u_long tlimit; + + /* + ** All ccbs of one hostadapter are chained. + */ + + ccb_p link_ccb; + + /* + ** All ccbs of one target/lun are chained. + */ + + ccb_p next_ccb; + + /* + ** Sense command + */ + + u_char sensecmd[6]; + + /* + ** Tag for this transfer. + ** It's patched into jump_ccb. + ** If it's not zero, a SIMPLE_TAG + ** message is included in smsg. + */ + + u_char tag; + + /* + ** Number of segments of the scatter list. + ** Used for recalculation of savep/goalp/lastp on + ** SIR_DATA_IO_IS_OUT interrupt. + */ + + u_char segments; }; #define CCB_PHYS(cp,lbl) (cp->p_ccb + offsetof(struct ccb, lbl)) - -/*======================================================================== +/*========================================================== ** ** Declaration of structs: NCR device descriptor ** -**======================================================================== +**========================================================== */ + struct ncb { - /*---------------------------------------------------------------- + /* ** The global header. - ** It is accessible to both the host and the script processor. - ** Must be cache line size aligned (32 for x86) in order to - ** allow cache line bursting when it is copied to/from CCB. - **---------------------------------------------------------------- + ** Accessible to both the host and the + ** script-processor. + ** Is 32 bytes aligned since ncb is, in order to + ** allow cache line bursting when copying it from or + ** to ccbs. */ struct head header; - /*---------------------------------------------------------------- - ** CCBs management queues. - **---------------------------------------------------------------- + /*----------------------------------------------- + ** Specific Linux fields + **----------------------------------------------- + */ + int unit; /* Unit number */ + char chip_name[8]; /* Chip name */ + char inst_name[16]; /* Instance name */ + struct timer_list timer; /* Timer link header */ + int ncr_cache; /* Cache test variable */ + Scsi_Cmnd *waiting_list; /* Waiting list header for commands */ + /* that we can't put into the squeue */ + u_long settle_time; /* Reset in progess */ + u_char release_stage; /* Synchronisation stage on release */ + u_char verbose; /* Boot verbosity for this controller*/ +#ifdef SCSI_NCR_DEBUG_ERROR_RECOVERY_SUPPORT + u_char debug_error_recovery; + u_char stalling; + u_char assert_atn; +#endif + + /*----------------------------------------------- + ** Added field to support differences + ** between ncr chips. + ** sv_xxx are some io register bit value at start-up and + ** so assumed to have been set by the sdms bios. + ** rv_xxx are the bit fields of io register that will keep + ** the features used by the driver. + **----------------------------------------------- + */ + u_short device_id; + u_char revision_id; + + u_char sv_scntl0; + u_char sv_scntl3; + u_char sv_dmode; + u_char sv_dcntl; + u_char sv_ctest3; + u_char sv_ctest4; + u_char sv_ctest5; + u_char sv_gpcntl; + u_char sv_stest2; + u_char sv_stest4; + + u_char rv_scntl0; + u_char rv_scntl3; + u_char rv_dmode; + u_char rv_dcntl; + u_char rv_ctest3; + u_char rv_ctest4; + u_char rv_ctest5; + u_char rv_stest2; + + u_char scsi_mode; + + /*----------------------------------------------- + ** Scripts .. + **----------------------------------------------- + ** + ** During reselection the ncr jumps to this point. + ** The SFBR register is loaded with the encoded target id. + ** + ** Jump to the first target. + ** + ** JUMP + ** @(next tcb) + */ + struct link jump_tcb; + + /*----------------------------------------------- + ** Configuration .. + **----------------------------------------------- + ** + ** virtual and physical addresses + ** of the 53c810 chip. */ - Scsi_Cmnd *waiting_list; /* Commands waiting for a CCB */ - /* when lcb is not allocated. */ - Scsi_Cmnd *done_list; /* Commands waiting for done() */ - /* callback to be invoked. */ -#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93) - spinlock_t smp_lock; /* Lock for SMP threading */ -#endif + vm_offset_t vaddr; + vm_offset_t paddr; + + vm_offset_t vaddr2; + vm_offset_t paddr2; + + /* + ** pointer to the chip's registers. + */ + volatile + struct ncr_reg* reg; - /*---------------------------------------------------------------- - ** Chip and controller indentification. - **---------------------------------------------------------------- + /* + ** A copy of the scripts, relocated for this ncb. */ - int unit; /* Unit number */ - char chip_name[8]; /* Chip name */ - char inst_name[16]; /* ncb instance name */ + struct script *script0; + struct scripth *scripth0; - /*---------------------------------------------------------------- - ** Initial value of some IO register bits. - ** These values are assumed to have been set by BIOS, and may - ** be used for probing adapter implementation differences. - **---------------------------------------------------------------- + /* + ** Scripts instance virtual address. */ - u_char sv_scntl0, sv_scntl3, sv_dmode, sv_dcntl, sv_ctest3, sv_ctest4, - sv_ctest5, sv_gpcntl, sv_stest2, sv_stest4; + struct script *script; + struct scripth *scripth; - /*---------------------------------------------------------------- - ** Actual initial value of IO register bits used by the - ** driver. They are loaded at initialisation according to - ** features that are to be enabled. - **---------------------------------------------------------------- + /* + ** Scripts instance physical address. */ - u_char rv_scntl0, rv_scntl3, rv_dmode, rv_dcntl, rv_ctest3, rv_ctest4, - rv_ctest5, rv_stest2; + u_long p_script; + u_long p_scripth; - /*---------------------------------------------------------------- - ** Targets management. - ** During reselection the ncr jumps to jump_tcb. - ** The SFBR register is loaded with the encoded target id. - ** For i = 0 to 3 - ** SCR_JUMP ^ IFTRUE(MASK(i, 3)), @(next tcb mod. i) - ** - ** Recent chips will prefetch the 4 JUMPS using only 1 burst. - ** It is kind of hashcoding. - **---------------------------------------------------------------- - */ - struct link jump_tcb[4]; /* JUMPs for reselection */ - struct tcb target[MAX_TARGET]; /* Target data */ - - /*---------------------------------------------------------------- - ** Virtual and physical bus addresses of the chip. - **---------------------------------------------------------------- - */ - vm_offset_t vaddr; /* Virtual and bus address of */ - vm_offset_t paddr; /* chip's IO registers. */ - vm_offset_t paddr2; /* On-chip RAM bus address. */ - volatile /* Pointer to volatile for */ - struct ncr_reg *reg; /* memory mapped IO. */ - - /*---------------------------------------------------------------- - ** SCRIPTS virtual and physical bus addresses. - ** 'script' is loaded in the on-chip RAM if present. - ** 'scripth' stays in main memory. - **---------------------------------------------------------------- - */ - struct script *script0; /* Copies of script and scripth */ - struct scripth *scripth0; /* relocated for this ncb. */ - struct scripth *scripth; /* Actual scripth virt. address */ - u_long p_script; /* Actual script and scripth */ - u_long p_scripth; /* bus addresses. */ - - /*---------------------------------------------------------------- - ** General controller parameters and configuration. - **---------------------------------------------------------------- - */ - u_short device_id; /* PCI device id */ - u_char revision_id; /* PCI device revision id */ - u_long port; /* IO space base address */ - u_int irq; /* IRQ level */ - u_int features; /* Chip features map */ - u_char myaddr; /* SCSI id of the adapter */ + /* + ** The SCSI address of the host adapter. + */ + u_char myaddr; + + /* + ** Max dwords burst supported by the adapter. + */ u_char maxburst; /* log base 2 of dwords burst */ - u_char maxwide; /* Maximum transfer width */ + + /* + ** timing parameters + */ u_char minsync; /* Minimum sync period factor */ u_char maxsync; /* Maximum sync period factor */ u_char maxoffs; /* Max scsi offset */ u_char multiplier; /* Clock multiplier (1,2,4) */ u_char clock_divn; /* Number of clock divisors */ u_long clock_khz; /* SCSI clock frequency in KHz */ + u_int features; /* Chip features map */ + + + /*----------------------------------------------- + ** Link to the generic SCSI driver + **----------------------------------------------- + */ + + /* struct scsi_link sc_link; */ + + /*----------------------------------------------- + ** Job control + **----------------------------------------------- + ** + ** Commands from user + */ + struct usrcmd user; + u_char order; - /*---------------------------------------------------------------- - ** Start queue management. - ** It is filled up by the host processor and accessed by the - ** SCRIPTS processor in order to start SCSI commands. - **---------------------------------------------------------------- + /* + ** Target data + */ + struct tcb target[MAX_TARGET]; + + /* + ** Start queue. */ - u_short squeueput; /* Next free slot of the queue */ - u_short actccbs; /* Number of allocated CCBs */ - u_short queuedccbs; /* Number of CCBs in start queue*/ - u_short queuedepth; /* Start queue depth */ + u_int32 squeue [MAX_START]; + u_short squeueput; + u_short actccbs; - /*---------------------------------------------------------------- - ** Timeout handler. - **---------------------------------------------------------------- + /* + ** Timeout handler */ - struct timer_list timer; /* Timer handler link header */ +#if 0 + u_long heartbeat; + u_short ticks; + u_short latetime; +#endif u_long lasttime; - u_long settle_time; /* Resetting the SCSI BUS */ - /*---------------------------------------------------------------- - ** Debugging and profiling. - **---------------------------------------------------------------- + /*----------------------------------------------- + ** Debug and profiling + **----------------------------------------------- + ** + ** register dump + */ + struct ncr_reg regdump; + u_long regtime; + + /* + ** Profiling data */ - struct ncr_reg regdump; /* Register dump */ - u_long regtime; /* Time it has been done */ -#ifdef SCSI_NCR_PROFILE_SUPPORT - struct profile profile; /* Profiling data */ - u_int disc_phys; /* Disconnection counters */ - u_int disc_ref; -#endif - - /*---------------------------------------------------------------- - ** Miscellaneous buffers accessed by the scripts-processor. - ** They shall be DWORD aligned, because they may be read or - ** written with a SCR_COPY script command. - **---------------------------------------------------------------- - */ - u_char msgout[8]; /* Buffer for MESSAGE OUT */ - u_char msgin [8]; /* Buffer for MESSAGE IN */ - u_int32 lastmsg; /* Last SCSI message sent */ - u_char scratch; /* Scratch for SCSI receive */ - - /*---------------------------------------------------------------- - ** Miscellaneous configuration and status parameters. - **---------------------------------------------------------------- - */ - u_char disc; /* Diconnection allowed */ - u_char scsi_mode; /* Current SCSI BUS mode */ - u_char order; /* Tag order to use */ - u_char verbose; /* Verbosity for this controller*/ - int ncr_cache; /* Used for cache test at init. */ - - /*---------------------------------------------------------------- - ** Command completion handling. - **---------------------------------------------------------------- - */ -#ifdef SCSI_NCR_CCB_DONE_SUPPORT - struct ccb *(ccb_done[MAX_DONE]); - int ccb_done_ic; -#endif - /*---------------------------------------------------------------- - ** Fields that should be removed or changed. - **---------------------------------------------------------------- - */ - struct ccb *ccb; /* Global CCB */ - struct usrcmd user; /* Command from user */ - u_char release_stage; /* Synchronisation stage on release */ + struct profile profile; + u_long disc_phys; + u_long disc_ref; + + /* + ** The global control block. + ** It's used only during the configuration phase. + ** A target control block will be created + ** after the first successful transfer. + */ + struct ccb *ccb; + + /* + ** message buffers. + ** Should be longword aligned, + ** because they're written with a + ** COPY script command. + */ + u_char msgout[8]; + u_char msgin [8]; + u_int32 lastmsg; + + /* + ** Buffer for STATUS_IN phase. + */ + u_char scratch; + + /* + ** controller chip dependent maximal transfer width. + */ + u_char maxwide; + + /* + ** option for M_IDENTIFY message: enables disconnecting + */ + u_char disc; + + /* + ** address of the ncr control registers in io space + */ + u_int port; + + /* + ** irq level + */ + u_short irq; }; #define NCB_SCRIPT_PHYS(np,lbl) (np->p_script + offsetof (struct script, lbl)) -#define NCB_SCRIPTH_PHYS(np,lbl) (np->p_scripth + offsetof (struct scripth,lbl)) +#define NCB_SCRIPTH_PHYS(np,lbl) (np->p_scripth + offsetof (struct scripth, lbl)) /*========================================================== ** @@ -1980,129 +1861,84 @@ struct ncb { ** we reach them (for forward jumps). ** Therefore we declare a struct here. ** If you make changes inside the script, -** DONT FORGET TO CHANGE THE LENGTHS HERE! +** DON'T FORGET TO CHANGE THE LENGTHS HERE! ** **---------------------------------------------------------- */ /* -** Script fragments which are loaded into the on-chip RAM +** Script fragments which are loaded into the on-board RAM ** of 825A, 875 and 895 chips. */ struct script { - ncrcmd start [ 5]; + ncrcmd start [ 4]; + ncrcmd start0 [ 2]; + ncrcmd start1 [ 3]; ncrcmd startpos [ 1]; - ncrcmd select [ 6]; - ncrcmd select2 [ 9]; - ncrcmd loadpos [ 4]; - ncrcmd send_ident [ 9]; - ncrcmd prepare [ 6]; - ncrcmd prepare2 [ 7]; -#ifdef SCSI_NCR_PROFILE_SUPPORT - ncrcmd command [ 9]; -#else - ncrcmd command [ 6]; -#endif - ncrcmd dispatch [ 32]; - ncrcmd clrack [ 4]; + ncrcmd trysel [ 8]; + ncrcmd skip [ 8]; + ncrcmd skip2 [ 3]; + ncrcmd idle [ 2]; + ncrcmd select [ 22]; + ncrcmd prepare [ 4]; + ncrcmd loadpos [ 14]; + ncrcmd prepare2 [ 24]; + ncrcmd setmsg [ 5]; + ncrcmd clrack [ 2]; + ncrcmd dispatch [ 38]; ncrcmd no_data [ 17]; -#ifdef SCSI_NCR_PROFILE_SUPPORT - ncrcmd status [ 11]; -#else - ncrcmd status [ 8]; -#endif - ncrcmd msg_in [ 2]; - ncrcmd msg_in2 [ 16]; - ncrcmd msg_bad [ 4]; - ncrcmd setmsg [ 7]; - ncrcmd cleanup [ 6]; - ncrcmd complete [ 9]; - ncrcmd cleanup_ok [ 8]; - ncrcmd cleanup0 [ 1]; -#ifndef SCSI_NCR_CCB_DONE_SUPPORT - ncrcmd signal [ 12]; -#else - ncrcmd signal [ 9]; - ncrcmd done_pos [ 1]; - ncrcmd done_plug [ 2]; - ncrcmd done_end [ 7]; -#endif - ncrcmd save_dp [ 7]; + ncrcmd checkatn [ 10]; + ncrcmd command [ 15]; + ncrcmd status [ 27]; + ncrcmd msg_in [ 26]; + ncrcmd msg_bad [ 6]; + ncrcmd complete [ 13]; + ncrcmd cleanup [ 12]; + ncrcmd cleanup0 [ 11]; + ncrcmd signal [ 10]; + ncrcmd save_dp [ 5]; ncrcmd restore_dp [ 5]; -#ifdef SCSI_NCR_PROFILE_SUPPORT - ncrcmd disconnect [ 28]; -#else - ncrcmd disconnect [ 17]; -#endif + ncrcmd disconnect [ 12]; + ncrcmd disconnect0 [ 5]; + ncrcmd disconnect1 [ 23]; ncrcmd msg_out [ 9]; ncrcmd msg_out_done [ 7]; - ncrcmd idle [ 2]; + ncrcmd badgetcc [ 6]; ncrcmd reselect [ 8]; - ncrcmd reselected [ 8]; - ncrcmd resel_dsa [ 6]; -#ifdef SCSI_NCR_PROFILE_SUPPORT - ncrcmd loadpos1 [ 7]; -#else - ncrcmd loadpos1 [ 4]; -#endif - ncrcmd resel_lun [ 6]; - ncrcmd resel_tag [ 6]; - ncrcmd jump_to_nexus [ 4]; - ncrcmd nexus_indirect [ 4]; - ncrcmd resel_notag [ 4]; - ncrcmd data_in [MAX_SCATTERL * 4]; - ncrcmd data_in2 [ 4]; - ncrcmd data_out [MAX_SCATTERL * 4]; - ncrcmd data_out2 [ 4]; + ncrcmd reselect1 [ 8]; + ncrcmd reselect2 [ 8]; + ncrcmd resel_tmp [ 5]; + ncrcmd resel_lun [ 18]; + ncrcmd resel_tag [ 24]; + ncrcmd data_io [ 6]; + ncrcmd data_in [MAX_SCATTER * 4 + 4]; }; /* ** Script fragments which stay in main memory for all chips. */ struct scripth { - ncrcmd tryloop [MAX_START*2]; - ncrcmd tryloop2 [ 2]; -#ifdef SCSI_NCR_CCB_DONE_SUPPORT - ncrcmd done_queue [MAX_DONE*5]; - ncrcmd done_queue2 [ 2]; -#endif - ncrcmd select_no_atn [ 8]; - ncrcmd cancel [ 4]; - ncrcmd skip [ 9]; - ncrcmd skip2 [ 19]; - ncrcmd par_err_data_in [ 6]; - ncrcmd par_err_other [ 4]; + ncrcmd tryloop [MAX_START*5+2]; + ncrcmd msg_parity [ 6]; ncrcmd msg_reject [ 8]; - ncrcmd msg_ign_residue [ 24]; - ncrcmd msg_extended [ 10]; - ncrcmd msg_ext_2 [ 10]; - ncrcmd msg_wdtr [ 14]; - ncrcmd send_wdtr [ 7]; - ncrcmd msg_ext_3 [ 10]; - ncrcmd msg_sdtr [ 14]; - ncrcmd send_sdtr [ 7]; + ncrcmd msg_ign_residue [ 32]; + ncrcmd msg_extended [ 18]; + ncrcmd msg_ext_2 [ 18]; + ncrcmd msg_wdtr [ 27]; + ncrcmd msg_ext_3 [ 18]; + ncrcmd msg_sdtr [ 27]; ncrcmd msg_out_abort [ 10]; - ncrcmd hdata_in [MAX_SCATTERH * 4]; - ncrcmd hdata_in2 [ 2]; - ncrcmd hdata_out [MAX_SCATTERH * 4]; - ncrcmd hdata_out2 [ 2]; - ncrcmd reset [ 4]; + ncrcmd getcc [ 4]; + ncrcmd getcc1 [ 5]; +#ifdef NCR_GETCC_WITHMSG + ncrcmd getcc2 [ 33]; +#else + ncrcmd getcc2 [ 14]; +#endif + ncrcmd getcc3 [ 10]; + ncrcmd data_out [MAX_SCATTER * 4 + 4]; ncrcmd aborttag [ 4]; - ncrcmd abort [ 2]; - ncrcmd abort_resel [ 20]; - ncrcmd resend_ident [ 4]; - ncrcmd clratn_go_on [ 3]; - ncrcmd nxtdsp_go_on [ 1]; - ncrcmd sdata_in [ 8]; - ncrcmd data_io [ 18]; - ncrcmd bad_identify [ 12]; - ncrcmd bad_i_t_l [ 4]; - ncrcmd bad_i_t_l_q [ 4]; - ncrcmd bad_target [ 8]; - ncrcmd bad_status [ 8]; - ncrcmd start_ram [ 4]; - ncrcmd start_ram0 [ 4]; - ncrcmd sto_restart [ 5]; + ncrcmd abort [ 22]; ncrcmd snooptest [ 9]; ncrcmd snoopend [ 2]; }; @@ -2116,18 +1952,13 @@ struct scripth { **========================================================== */ -static void ncr_alloc_ccb (ncb_p np, u_char tn, u_char ln); +static void ncr_alloc_ccb (ncb_p np, u_long t, u_long l); static void ncr_complete (ncb_p np, ccb_p cp); static void ncr_exception (ncb_p np); -static void ncr_free_ccb (ncb_p np, ccb_p cp); -static void ncr_init_ccb (ncb_p np, ccb_p cp); -static void ncr_init_tcb (ncb_p np, u_char tn); -static lcb_p ncr_alloc_lcb (ncb_p np, u_char tn, u_char ln); -static lcb_p ncr_setup_lcb (ncb_p np, u_char tn, u_char ln, - u_char *inq_data); +static void ncr_free_ccb (ncb_p np, ccb_p cp, u_long t, u_long l); static void ncr_getclock (ncb_p np, int mult); static void ncr_selectclock (ncb_p np, u_char scntl3); -static ccb_p ncr_get_ccb (ncb_p np, u_char tn, u_char ln); +static ccb_p ncr_get_ccb (ncb_p np, u_long t,u_long l); static void ncr_init (ncb_p np, int reset, char * msg, u_long code); static int ncr_int_sbmc (ncb_p np); static int ncr_int_par (ncb_p np); @@ -2136,6 +1967,7 @@ static void ncr_int_sir (ncb_p np); static void ncr_int_sto (ncb_p np); static u_long ncr_lookup (char* id); static void ncr_negotiate (struct ncb* np, struct tcb* tp); +static void ncr_opennings (ncb_p np, lcb_p lp, Scsi_Cmnd * xp); #ifdef SCSI_NCR_PROFILE_SUPPORT static void ncb_profile (ncb_p np, ccb_p cp); @@ -2145,18 +1977,16 @@ static void ncr_script_copy_and_bind (ncb_p np, ncrcmd *src, ncrcmd *dst, int len); static void ncr_script_fill (struct script * scr, struct scripth * scripth); static int ncr_scatter (ccb_p cp, Scsi_Cmnd *cmd); +static void ncr_setmaxtags (ncb_p np, tcb_p tp, u_long numtags); static void ncr_getsync (ncb_p np, u_char sfac, u_char *fakp, u_char *scntl3p); static void ncr_setsync (ncb_p np, ccb_p cp, u_char scntl3, u_char sxfer); -static void ncr_setup_tags (ncb_p np, u_char tn, u_char ln); +static void ncr_settags (tcb_p tp, lcb_p lp); static void ncr_setwide (ncb_p np, ccb_p cp, u_char wide, u_char ack); static int ncr_show_msg (u_char * msg); static int ncr_snooptest (ncb_p np); static void ncr_timeout (ncb_p np); static void ncr_wakeup (ncb_p np, u_long code); -static void ncr_wakeup_done (ncb_p np); -static void ncr_start_next_ccb (ncb_p np, lcb_p lp, int maxn); -static void ncr_put_start_queue(ncb_p np, ccb_p cp); -static void ncr_start_reset (ncb_p np); +static void ncr_start_reset (ncb_p np, int settle_delay); static int ncr_reset_scsi_bus (ncb_p np, int enab_int, int settle_delay); #ifdef SCSI_NCR_USER_COMMAND_SUPPORT @@ -2245,17 +2075,38 @@ static void *script_kvars[] __initdata = static struct script script0 __initdata = { /*--------------------------< START >-----------------------*/ { +#if 0 /* - ** This NOP will be patched with LED ON - ** SCR_REG_REG (gpreg, SCR_AND, 0xfe) + ** Claim to be still alive ... */ - SCR_NO_OP, - 0, + SCR_COPY (sizeof (((struct ncb *)0)->heartbeat)), + KVAR(SCRIPT_KVAR_JIFFIES), + NADDR (heartbeat), +#endif /* - ** Clear SIGP. + ** Make data structure address invalid. + ** clear SIGP. */ + SCR_LOAD_REG (dsa, 0xff), + 0, SCR_FROM_REG (ctest2), 0, +}/*-------------------------< START0 >----------------------*/,{ + /* + ** Hook for interrupted GetConditionCode. + ** Will be patched to ... IFTRUE by + ** the interrupt handler. + */ + SCR_INT ^ IFFALSE (0), + SIR_SENSE_RESTART, + +}/*-------------------------< START1 >----------------------*/,{ + /* + ** Hook for stalled start queue. + ** Will be patched to IFTRUE by the interrupt handler. + */ + SCR_INT ^ IFFALSE (0), + SIR_STALL_RESTART, /* ** Then jump to a certain point in tryloop. ** Due to the lack of indirect addressing the code @@ -2264,6 +2115,76 @@ static struct script script0 __initdata = { SCR_JUMP, }/*-------------------------< STARTPOS >--------------------*/,{ PADDRH(tryloop), +}/*-------------------------< TRYSEL >----------------------*/,{ + /* + ** Now: + ** DSA: Address of a Data Structure + ** or Address of the IDLE-Label. + ** + ** TEMP: Address of a script, which tries to + ** start the NEXT entry. + ** + ** Save the TEMP register into the SCRATCHA register. + ** Then copy the DSA to TEMP and RETURN. + ** This is kind of an indirect jump. + ** (The script processor has NO stack, so the + ** CALL is actually a jump and link, and the + ** RETURN is an indirect jump.) + ** + ** If the slot was empty, DSA contains the address + ** of the IDLE part of this script. The processor + ** jumps to IDLE and waits for a reselect. + ** It will wake up and try the same slot again + ** after the SIGP bit becomes set by the host. + ** + ** If the slot was not empty, DSA contains + ** the address of the phys-part of a ccb. + ** The processor jumps to this address. + ** phys starts with head, + ** head starts with launch, + ** so actually the processor jumps to + ** the lauch part. + ** If the entry is scheduled for execution, + ** then launch contains a jump to SELECT. + ** If it's not scheduled, it contains a jump to IDLE. + */ + SCR_COPY (4), + RADDR (temp), + RADDR (scratcha), + SCR_COPY (4), + RADDR (dsa), + RADDR (temp), + SCR_RETURN, + 0 + +}/*-------------------------< SKIP >------------------------*/,{ + /* + ** This entry has been canceled. + ** Next time use the next slot. + */ + SCR_COPY (4), + RADDR (scratcha), + PADDR (startpos), + /* + ** patch the launch field. + ** should look like an idle process. + */ + SCR_COPY_F (4), + RADDR (dsa), + PADDR (skip2), + SCR_COPY (8), + PADDR (idle), +}/*-------------------------< SKIP2 >-----------------------*/,{ + 0, + SCR_JUMP, + PADDR(start), +}/*-------------------------< IDLE >------------------------*/,{ + /* + ** Nothing to do? + ** Wait for reselect. + */ + SCR_JUMP, + PADDR(reselect), }/*-------------------------< SELECT >----------------------*/,{ /* @@ -2280,7 +2201,7 @@ static struct script script0 __initdata = { SCR_CLR (SCR_TRG), 0, - SCR_LOAD_REG (HS_REG, HS_SELECTING), + SCR_LOAD_REG (HS_REG, 0xff), 0, /* @@ -2289,7 +2210,6 @@ static struct script script0 __initdata = { SCR_SEL_TBL_ATN ^ offsetof (struct dsb, select), PADDR (reselect), -}/*-------------------------< SELECT2 >----------------------*/,{ /* ** Now there are 4 possibilities: ** @@ -2302,31 +2222,50 @@ static struct script script0 __initdata = { ** Then the script processor takes the jump ** to the RESELECT label. ** - ** (3) The ncr wins arbitration. - ** Then it will execute SCRIPTS instruction until - ** the next instruction that checks SCSI phase. - ** Then will stop and wait for selection to be - ** complete or selection time-out to occur. - ** As a result the SCRIPTS instructions until - ** LOADPOS + 2 should be executed in parallel with - ** the SCSI core performing selection. + ** (3) The ncr completes the selection. + ** Then it will execute the next statement. + ** + ** (4) There is a selection timeout. + ** Then the ncr should interrupt the host and stop. + ** Unfortunately, it seems to continue execution + ** of the script. But it will fail with an + ** IID-interrupt on the next WHEN. */ + SCR_JUMPR ^ IFTRUE (WHEN (SCR_MSG_IN)), + 0, + /* - ** The M_REJECT problem seems to be due to a selection - ** timing problem. - ** Wait immediately for the selection to complete. - ** (2.5x behaves so) + ** Save target id to ctest0 register */ - SCR_JUMPR ^ IFFALSE (WHEN (SCR_MSG_OUT)), - 0, + SCR_FROM_REG (sdid), + 0, + SCR_TO_REG (ctest0), + 0, + /* + ** Send the IDENTIFY and SIMPLE_TAG messages + ** (and the M_X_SYNC_REQ message) + */ + SCR_MOVE_TBL ^ SCR_MSG_OUT, + offsetof (struct dsb, smsg), +#ifdef undef /* XXX better fail than try to deal with this ... */ + SCR_JUMPR ^ IFTRUE (WHEN (SCR_MSG_OUT)), + -16, +#endif + SCR_CLR (SCR_ATN), + 0, + SCR_COPY (1), + RADDR (sfbr), + NADDR (lastmsg), /* + ** Selection complete. ** Next time use the next slot. */ SCR_COPY (4), - RADDR (temp), + RADDR (scratcha), PADDR (startpos), +}/*-------------------------< PREPARE >----------------------*/,{ /* ** The ncr doesn't have an indirect load ** or store command. So we have to @@ -2346,32 +2285,22 @@ static struct script script0 __initdata = { /* ** continued after the next label ... */ + }/*-------------------------< LOADPOS >---------------------*/,{ 0, NADDR (header), /* - ** Wait for the next phase or the selection - ** to complete or time-out. + ** Mark this ccb as not scheduled. */ - SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_OUT)), - PADDR (prepare), - -}/*-------------------------< SEND_IDENT >----------------------*/,{ + SCR_COPY (8), + PADDR (idle), + NADDR (header.launch), /* - ** Selection complete. - ** Send the IDENTIFY and SIMPLE_TAG messages - ** (and the M_X_SYNC_REQ message) + ** Set a time stamp for this selection */ - SCR_MOVE_TBL ^ SCR_MSG_OUT, - offsetof (struct dsb, smsg), - SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_OUT)), - PADDRH (resend_ident), - SCR_LOAD_REG (scratcha, 0x80), - 0, - SCR_COPY (1), - RADDR (scratcha), - NADDR (lastmsg), -}/*-------------------------< PREPARE >----------------------*/,{ + SCR_COPY (sizeof (u_long)), + KVAR(SCRIPT_KVAR_JIFFIES), + NADDR (header.stamp.select), /* ** load the savep (saved pointer) into ** the TEMP register (actual pointer) @@ -2385,8 +2314,21 @@ static struct script script0 __initdata = { SCR_COPY (4), NADDR (header.status), RADDR (scr0), + }/*-------------------------< PREPARE2 >---------------------*/,{ /* + ** Load the synchronous mode register + */ + SCR_COPY (1), + NADDR (sync_st), + RADDR (sxfer), + /* + ** Load the wide mode and timing register + */ + SCR_COPY (1), + NADDR (wide_st), + RADDR (scntl3), + /* ** Initialize the msgout buffer with a NOOP message. */ SCR_LOAD_REG (scratcha, M_NOOP), @@ -2394,52 +2336,52 @@ static struct script script0 __initdata = { SCR_COPY (1), RADDR (scratcha), NADDR (msgout), -#if 0 SCR_COPY (1), RADDR (scratcha), NADDR (msgin), -#endif /* - ** Anticipate the COMMAND phase. - ** This is the normal case for initial selection. + ** Message in phase ? */ - SCR_JUMP ^ IFFALSE (WHEN (SCR_COMMAND)), + SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)), PADDR (dispatch), - -}/*-------------------------< COMMAND >--------------------*/,{ -#ifdef SCSI_NCR_PROFILE_SUPPORT /* - ** ... set a timestamp ... + ** Extended or reject message ? */ - SCR_COPY (sizeof (u_long)), - KVAR(SCRIPT_KVAR_JIFFIES), - NADDR (header.stamp.command), -#endif + SCR_FROM_REG (sbdl), + 0, + SCR_JUMP ^ IFTRUE (DATA (M_EXTENDED)), + PADDR (msg_in), + SCR_JUMP ^ IFTRUE (DATA (M_REJECT)), + PADDRH (msg_reject), /* - ** ... and send the command + ** normal processing */ - SCR_MOVE_TBL ^ SCR_COMMAND, - offsetof (struct dsb, cmd), + SCR_JUMP, + PADDR (dispatch), +}/*-------------------------< SETMSG >----------------------*/,{ + SCR_COPY (1), + RADDR (scratcha), + NADDR (msgout), + SCR_SET (SCR_ATN), + 0, +}/*-------------------------< CLRACK >----------------------*/,{ /* - ** If status is still HS_NEGOTIATE, negotiation failed. - ** We check this here, since we want to do that - ** only once. + ** Terminate possible pending message phase. */ + SCR_CLR (SCR_ACK), + 0, + +}/*-----------------------< DISPATCH >----------------------*/,{ SCR_FROM_REG (HS_REG), 0, SCR_INT ^ IFTRUE (DATA (HS_NEGOTIATE)), SIR_NEGO_FAILED, - -}/*-----------------------< DISPATCH >----------------------*/,{ /* - ** MSG_IN is the only phase that shall be - ** entered at least once for each (re)selection. - ** So we test it first. + ** remove bogus output signals */ - SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)), - PADDR (msg_in), - - SCR_RETURN ^ IFTRUE (IF (SCR_DATA_OUT)), + SCR_REG_REG (socl, SCR_AND, CACK|CATN), + 0, + SCR_RETURN ^ IFTRUE (WHEN (SCR_DATA_OUT)), 0, /* ** DEL 397 - 53C875 Rev 3 - Part Number 609-0392410 - ITEM 4. @@ -2454,13 +2396,16 @@ static struct script script0 __initdata = { RADDR (scratcha), RADDR (scratcha), SCR_RETURN, - 0, - SCR_JUMP ^ IFTRUE (IF (SCR_STATUS)), - PADDR (status), - SCR_JUMP ^ IFTRUE (IF (SCR_COMMAND)), - PADDR (command), + 0, + SCR_JUMP ^ IFTRUE (IF (SCR_MSG_OUT)), PADDR (msg_out), + SCR_JUMP ^ IFTRUE (IF (SCR_MSG_IN)), + PADDR (msg_in), + SCR_JUMP ^ IFTRUE (IF (SCR_COMMAND)), + PADDR (command), + SCR_JUMP ^ IFTRUE (IF (SCR_STATUS)), + PADDR (status), /* ** Discard one illegal phase byte, if required. */ @@ -2480,15 +2425,6 @@ static struct script script0 __initdata = { SCR_JUMP, PADDR (dispatch), -}/*-------------------------< CLRACK >----------------------*/,{ - /* - ** Terminate possible pending message phase. - */ - SCR_CLR (SCR_ACK), - 0, - SCR_JUMP, - PADDR (dispatch), - }/*-------------------------< NO_DATA >--------------------*/,{ /* ** The target wants to tranfer too much data @@ -2518,31 +2454,116 @@ static struct script script0 __initdata = { PADDR (dispatch), SCR_JUMP, PADDR (no_data), +}/*-------------------------< CHECKATN >--------------------*/,{ + /* + ** If AAP (bit 1 of scntl0 register) is set + ** and a parity error is detected, + ** the script processor asserts ATN. + ** + ** The target should switch to a MSG_OUT phase + ** to get the message. + */ + SCR_FROM_REG (socl), + 0, + SCR_JUMP ^ IFFALSE (MASK (CATN, CATN)), + PADDR (dispatch), + /* + ** count it + */ + SCR_REG_REG (PS_REG, SCR_ADD, 1), + 0, + /* + ** Prepare a M_ID_ERROR message + ** (initiator detected error). + ** The target should retry the transfer. + */ + SCR_LOAD_REG (scratcha, M_ID_ERROR), + 0, + SCR_JUMP, + PADDR (setmsg), + +}/*-------------------------< COMMAND >--------------------*/,{ + /* + ** If this is not a GETCC transfer ... + */ + SCR_FROM_REG (SS_REG), + 0, +/*<<<*/ SCR_JUMPR ^ IFTRUE (DATA (S_CHECK_COND)), + 28, + /* + ** ... set a timestamp ... + */ + SCR_COPY (sizeof (u_long)), + KVAR(SCRIPT_KVAR_JIFFIES), + NADDR (header.stamp.command), + /* + ** ... and send the command + */ + SCR_MOVE_TBL ^ SCR_COMMAND, + offsetof (struct dsb, cmd), + SCR_JUMP, + PADDR (dispatch), + /* + ** Send the GETCC command + */ +/*>>>*/ SCR_MOVE_TBL ^ SCR_COMMAND, + offsetof (struct dsb, scmd), + SCR_JUMP, + PADDR (dispatch), }/*-------------------------< STATUS >--------------------*/,{ -#ifdef SCSI_NCR_PROFILE_SUPPORT /* ** set the timestamp. */ SCR_COPY (sizeof (u_long)), KVAR(SCRIPT_KVAR_JIFFIES), NADDR (header.stamp.status), -#endif + /* + ** If this is a GETCC transfer, + */ + SCR_FROM_REG (SS_REG), + 0, +/*<<<*/ SCR_JUMPR ^ IFFALSE (DATA (S_CHECK_COND)), + 40, /* ** get the status */ SCR_MOVE_ABS (1) ^ SCR_STATUS, NADDR (scratch), /* - ** save status to scsi_status. - ** mark as complete. + ** Save status to scsi_status. + ** Mark as complete. + ** And wait for disconnect. */ SCR_TO_REG (SS_REG), 0, + SCR_REG_REG (SS_REG, SCR_OR, S_SENSE), + 0, SCR_LOAD_REG (HS_REG, HS_COMPLETE), 0, SCR_JUMP, - PADDR (dispatch), + PADDR (checkatn), + /* + ** If it was no GETCC transfer, + ** save the status to scsi_status. + */ +/*>>>*/ SCR_MOVE_ABS (1) ^ SCR_STATUS, + NADDR (scratch), + SCR_TO_REG (SS_REG), + 0, + /* + ** if it was no check condition ... + */ + SCR_JUMP ^ IFTRUE (DATA (S_CHECK_COND)), + PADDR (checkatn), + /* + ** ... mark as complete. + */ + SCR_LOAD_REG (HS_REG, HS_COMPLETE), + 0, + SCR_JUMP, + PADDR (checkatn), + }/*-------------------------< MSG_IN >--------------------*/,{ /* ** Get the first byte of the message @@ -2553,18 +2574,28 @@ static struct script script0 __initdata = { */ SCR_MOVE_ABS (1) ^ SCR_MSG_IN, NADDR (msgin[0]), -}/*-------------------------< MSG_IN2 >--------------------*/,{ /* - ** Handle this message. + ** Check for message parity error. + */ + SCR_TO_REG (scratcha), + 0, + SCR_FROM_REG (socl), + 0, + SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), + PADDRH (msg_parity), + SCR_FROM_REG (scratcha), + 0, + /* + ** Parity was ok, handle this message. */ SCR_JUMP ^ IFTRUE (DATA (M_COMPLETE)), PADDR (complete), - SCR_JUMP ^ IFTRUE (DATA (M_DISCONNECT)), - PADDR (disconnect), SCR_JUMP ^ IFTRUE (DATA (M_SAVE_DP)), PADDR (save_dp), SCR_JUMP ^ IFTRUE (DATA (M_RESTORE_DP)), PADDR (restore_dp), + SCR_JUMP ^ IFTRUE (DATA (M_DISCONNECT)), + PADDR (disconnect), SCR_JUMP ^ IFTRUE (DATA (M_EXTENDED)), PADDRH (msg_extended), SCR_JUMP ^ IFTRUE (DATA (M_NOOP)), @@ -2588,42 +2619,24 @@ static struct script script0 __initdata = { SIR_REJECT_SENT, SCR_LOAD_REG (scratcha, M_REJECT), 0, -}/*-------------------------< SETMSG >----------------------*/,{ - SCR_COPY (1), - RADDR (scratcha), - NADDR (msgout), - SCR_SET (SCR_ATN), - 0, - SCR_JUMP, - PADDR (clrack), -}/*-------------------------< CLEANUP >-------------------*/,{ - /* - ** dsa: Pointer to ccb - ** or xxxxxxFF (no ccb) - ** - ** HS_REG: Host-Status (<>0!) - */ - SCR_FROM_REG (dsa), - 0, - SCR_JUMP ^ IFTRUE (DATA (0xff)), - PADDR (start), - /* - ** dsa is valid. - ** complete the cleanup. - */ SCR_JUMP, - PADDR (cleanup_ok), + PADDR (setmsg), }/*-------------------------< COMPLETE >-----------------*/,{ /* ** Complete message. ** - ** Copy TEMP register to LASTP in header. + ** If it's not the get condition code, + ** copy TEMP register to LASTP in header. */ + SCR_FROM_REG (SS_REG), + 0, +/*<<<*/ SCR_JUMPR ^ IFTRUE (MASK (S_SENSE, S_SENSE)), + 12, SCR_COPY (4), RADDR (temp), NADDR (header.lastp), - /* +/*>>>*/ /* ** When we terminate the cycle by clearing ACK, ** the target may disconnect immediately. ** @@ -2643,9 +2656,20 @@ static struct script script0 __initdata = { */ SCR_WAIT_DISC, 0, -}/*-------------------------< CLEANUP_OK >----------------*/,{ +}/*-------------------------< CLEANUP >-------------------*/,{ + /* + ** dsa: Pointer to ccb + ** or xxxxxxFF (no ccb) + ** + ** HS_REG: Host-Status (<>0!) + */ + SCR_FROM_REG (dsa), + 0, + SCR_JUMP ^ IFTRUE (DATA (0xff)), + PADDR (signal), /* - ** Save host status to header. + ** dsa is valid. + ** save the status registers */ SCR_COPY (4), RADDR (scr0), @@ -2660,32 +2684,43 @@ static struct script script0 __initdata = { NADDR (header), }/*-------------------------< CLEANUP0 >--------------------*/,{ 0, -}/*-------------------------< SIGNAL >----------------------*/,{ + /* - ** if job not completed ... + ** If command resulted in "check condition" + ** status and is not yet completed, + ** try to get the condition code. */ SCR_FROM_REG (HS_REG), 0, +/*<<<*/ SCR_JUMPR ^ IFFALSE (MASK (0, HS_DONEMASK)), + 16, + SCR_FROM_REG (SS_REG), + 0, + SCR_JUMP ^ IFTRUE (DATA (S_CHECK_COND)), + PADDRH(getcc2), /* - ** ... start the next command. + ** And make the DSA register invalid. */ - SCR_JUMP ^ IFTRUE (MASK (0, (HS_DONEMASK|HS_SKIPMASK))), - PADDR(start), +/*>>>*/ SCR_LOAD_REG (dsa, 0xff), /* invalid */ + 0, +}/*-------------------------< SIGNAL >----------------------*/,{ /* - ** If command resulted in not GOOD status, - ** call the C code if needed. + ** if status = queue full, + ** reinsert in startqueue and stall queue. */ SCR_FROM_REG (SS_REG), 0, - SCR_CALL ^ IFFALSE (DATA (S_GOOD)), - PADDRH (bad_status), - -#ifndef SCSI_NCR_CCB_DONE_SUPPORT - + SCR_INT ^ IFTRUE (DATA (S_QUEUE_FULL)), + SIR_STALL_QUEUE, + /* + ** if job completed ... + */ + SCR_FROM_REG (HS_REG), + 0, /* ** ... signal completion to the host */ - SCR_INT_FLY, + SCR_INT_FLY ^ IFFALSE (MASK (0, HS_DONEMASK)), 0, /* ** Auf zu neuen Schandtaten! @@ -2693,28 +2728,6 @@ static struct script script0 __initdata = { SCR_JUMP, PADDR(start), -#else /* defined SCSI_NCR_CCB_DONE_SUPPORT */ - - /* - ** ... signal completion to the host - */ - SCR_JUMP, -}/*------------------------< DONE_POS >---------------------*/,{ - PADDRH (done_queue), -}/*------------------------< DONE_PLUG >--------------------*/,{ - SCR_INT, - SIR_DONE_OVERFLOW, -}/*------------------------< DONE_END >---------------------*/,{ - SCR_INT_FLY, - 0, - SCR_COPY (4), - RADDR (temp), - PADDR (done_pos), - SCR_JUMP, - PADDR (start), - -#endif /* SCSI_NCR_CCB_DONE_SUPPORT */ - }/*-------------------------< SAVE_DP >------------------*/,{ /* ** SAVE_DP message: @@ -2723,10 +2736,8 @@ static struct script script0 __initdata = { SCR_COPY (4), RADDR (temp), NADDR (header.savep), - SCR_CLR (SCR_ACK), - 0, SCR_JUMP, - PADDR (dispatch), + PADDR (clrack), }/*-------------------------< RESTORE_DP >---------------*/,{ /* ** RESTORE_DP message: @@ -2739,6 +2750,56 @@ static struct script script0 __initdata = { PADDR (clrack), }/*-------------------------< DISCONNECT >---------------*/,{ + /* + ** If QUIRK_AUTOSAVE is set, + ** do an "save pointer" operation. + */ + SCR_FROM_REG (QU_REG), + 0, +/*<<<*/ SCR_JUMPR ^ IFFALSE (MASK (QUIRK_AUTOSAVE, QUIRK_AUTOSAVE)), + 12, + /* + ** like SAVE_DP message: + ** Copy TEMP register to SAVEP in header. + */ + SCR_COPY (4), + RADDR (temp), + NADDR (header.savep), +/*>>>*/ /* + ** Check if temp==savep or temp==goalp: + ** if not, log a missing save pointer message. + ** In fact, it's a comparison mod 256. + ** + ** Hmmm, I hadn't thought that I would be urged to + ** write this kind of ugly self modifying code. + ** + ** It's unbelievable, but the ncr53c8xx isn't able + ** to subtract one register from another. + */ + SCR_FROM_REG (temp), + 0, + /* + ** You are not expected to understand this .. + ** + ** CAUTION: only little endian architectures supported! XXX + */ + SCR_COPY_F (1), + NADDR (header.savep), + PADDR (disconnect0), +}/*-------------------------< DISCONNECT0 >--------------*/,{ +/*<<<*/ SCR_JUMPR ^ IFTRUE (DATA (1)), + 20, + /* + ** neither this + */ + SCR_COPY_F (1), + NADDR (header.goalp), + PADDR (disconnect1), +}/*-------------------------< DISCONNECT1 >--------------*/,{ + SCR_INT ^ IFFALSE (DATA (1)), + SIR_MISSING_SAVE, +/*>>>*/ + /* ** DISCONNECTing ... ** @@ -2754,7 +2815,6 @@ static struct script script0 __initdata = { */ SCR_WAIT_DISC, 0, -#ifdef SCSI_NCR_PROFILE_SUPPORT /* ** Profiling: ** Set a time stamp, @@ -2765,35 +2825,19 @@ static struct script script0 __initdata = { NADDR (header.stamp.disconnect), SCR_COPY (4), NADDR (disc_phys), - RADDR (scratcha), - SCR_REG_REG (scratcha, SCR_ADD, 0x01), + RADDR (temp), + SCR_REG_REG (temp, SCR_ADD, 0x01), 0, SCR_COPY (4), - RADDR (scratcha), + RADDR (temp), NADDR (disc_phys), -#endif /* ** Status is: DISCONNECTED. */ SCR_LOAD_REG (HS_REG, HS_DISCONNECT), 0, - /* - ** If QUIRK_AUTOSAVE is set, - ** do an "save pointer" operation. - */ - SCR_FROM_REG (QU_REG), - 0, - SCR_JUMP ^ IFFALSE (MASK (QUIRK_AUTOSAVE, QUIRK_AUTOSAVE)), - PADDR (cleanup_ok), - /* - ** like SAVE_DP message: - ** Copy TEMP register to SAVEP in header. - */ - SCR_COPY (4), - RADDR (temp), - NADDR (header.savep), SCR_JUMP, - PADDR (cleanup_ok), + PADDR (cleanup), }/*-------------------------< MSG_OUT >-------------------*/,{ /* @@ -2802,7 +2846,7 @@ static struct script script0 __initdata = { SCR_MOVE_ABS (1) ^ SCR_MSG_OUT, NADDR (msgout), SCR_COPY (1), - NADDR (msgout), + RADDR (sfbr), NADDR (lastmsg), /* ** If it was no ABORT message ... @@ -2829,16 +2873,23 @@ static struct script script0 __initdata = { */ SCR_JUMP, PADDR (dispatch), -}/*-------------------------< IDLE >------------------------*/,{ +}/*------------------------< BADGETCC >---------------------*/,{ + /* + ** If SIGP was set, clear it and try again. + */ + SCR_FROM_REG (ctest2), + 0, + SCR_JUMP ^ IFTRUE (MASK (CSIGP,CSIGP)), + PADDRH (getcc2), + SCR_INT, + SIR_SENSE_FAILED, +}/*-------------------------< RESELECT >--------------------*/,{ /* - ** Nothing to do? - ** Wait for reselect. ** This NOP will be patched with LED OFF ** SCR_REG_REG (gpreg, SCR_OR, 0x01) */ SCR_NO_OP, 0, -}/*-------------------------< RESELECT >--------------------*/,{ /* ** make the DSA invalid. */ @@ -2846,8 +2897,6 @@ static struct script script0 __initdata = { 0, SCR_CLR (SCR_TRG), 0, - SCR_LOAD_REG (HS_REG, HS_IN_RESELECT), - 0, /* ** Sleep waiting for a reselection. ** If SIGP is set, special treatment. @@ -2855,8 +2904,8 @@ static struct script script0 __initdata = { ** Zu allem bereit .. */ SCR_WAIT_RESEL, - PADDR(start), -}/*-------------------------< RESELECTED >------------------*/,{ + PADDR(reselect2), +}/*-------------------------< RESELECT1 >--------------------*/,{ /* ** This NOP will be patched with LED ON ** SCR_REG_REG (gpreg, SCR_AND, 0xfe) @@ -2878,51 +2927,38 @@ static struct script script0 __initdata = { */ SCR_REG_SFBR (ssid, SCR_AND, 0x8F), 0, - SCR_TO_REG (sdid), + SCR_TO_REG (ctest0), 0, SCR_JUMP, NADDR (jump_tcb), - -}/*-------------------------< RESEL_DSA >-------------------*/,{ +}/*-------------------------< RESELECT2 >-------------------*/,{ /* - ** Ack the IDENTIFY or TAG previously received. + ** This NOP will be patched with LED ON + ** SCR_REG_REG (gpreg, SCR_AND, 0xfe) */ - SCR_CLR (SCR_ACK), + SCR_NO_OP, 0, /* - ** The ncr doesn't have an indirect load - ** or store command. So we have to - ** copy part of the control block to a - ** fixed place, where we can access it. - ** - ** We patch the address part of a - ** COPY command with the DSA-register. - */ - SCR_COPY_F (4), - RADDR (dsa), - PADDR (loadpos1), - /* - ** then we do the actual copy. + ** If it's not connected :( + ** -> interrupted by SIGP bit. + ** Jump to start. */ - SCR_COPY (sizeof (struct head)), - /* - ** continued after the next label ... - */ - -}/*-------------------------< LOADPOS1 >-------------------*/,{ + SCR_FROM_REG (ctest2), 0, - NADDR (header), -#ifdef SCSI_NCR_PROFILE_SUPPORT - /* - ** Set a time stamp for this reselection - */ - SCR_COPY (sizeof (u_long)), - KVAR(SCRIPT_KVAR_JIFFIES), - NADDR (header.stamp.reselect), -#endif + SCR_JUMP ^ IFTRUE (MASK (CSIGP,CSIGP)), + PADDR (start), + SCR_JUMP, + PADDR (reselect), + +}/*-------------------------< RESEL_TMP >-------------------*/,{ /* - ** The DSA contains the data structure address. + ** The return address in TEMP + ** is in fact the data structure address, + ** so copy it to the DSA register. */ + SCR_COPY (4), + RADDR (temp), + RADDR (dsa), SCR_JUMP, PADDR (prepare), @@ -2932,111 +2968,133 @@ static struct script script0 __initdata = { ** to get an IDENTIFY message ** Wait for a msg_in phase. */ - SCR_INT ^ IFFALSE (WHEN (SCR_MSG_IN)), - SIR_RESEL_NO_MSG_IN, +/*<<<*/ SCR_JUMPR ^ IFFALSE (WHEN (SCR_MSG_IN)), + 48, /* - ** message phase. - ** Read the data directly from the BUS DATA lines. - ** This helps to support very old SCSI devices that - ** may reselect without sending an IDENTIFY. + ** message phase + ** It's not a sony, it's a trick: + ** read the data without acknowledging it. */ SCR_FROM_REG (sbdl), 0, +/*<<<*/ SCR_JUMPR ^ IFFALSE (MASK (M_IDENTIFY, 0x98)), + 32, /* - ** It should be an Identify message. + ** It WAS an Identify message. + ** get it and ack it! */ + SCR_MOVE_ABS (1) ^ SCR_MSG_IN, + NADDR (msgin), + SCR_CLR (SCR_ACK), + 0, + /* + ** Mask out the lun. + */ + SCR_REG_REG (sfbr, SCR_AND, 0x07), + 0, SCR_RETURN, 0, + /* + ** No message phase or no IDENTIFY message: + ** return 0. + */ +/*>>>*/ SCR_LOAD_SFBR (0), + 0, + SCR_RETURN, + 0, + }/*-------------------------< RESEL_TAG >-------------------*/,{ /* - ** Read IDENTIFY + SIMPLE + TAG using a single MOVE. - ** Agressive optimization, is'nt it? - ** No need to test the SIMPLE TAG message, since the - ** driver only supports conformant devices for tags. ;-) + ** come back to this point + ** to get a SIMPLE_TAG message + ** Wait for a MSG_IN phase. */ - SCR_MOVE_ABS (3) ^ SCR_MSG_IN, - NADDR (msgin), +/*<<<*/ SCR_JUMPR ^ IFFALSE (WHEN (SCR_MSG_IN)), + 64, /* - ** Read the TAG from the SIDL. - ** Still an aggressive optimization. ;-) - ** Compute the CCB indirect jump address which - ** is (#TAG*2 & 0xfc) due to tag numbering using - ** 1,3,5..MAXTAGS*2+1 actual values. + ** message phase + ** It's a trick - read the data + ** without acknowledging it. */ - SCR_REG_SFBR (sidl, SCR_SHL, 0), + SCR_FROM_REG (sbdl), 0, - SCR_SFBR_REG (temp, SCR_AND, 0xfc), +/*<<<*/ SCR_JUMPR ^ IFFALSE (DATA (M_SIMPLE_TAG)), + 48, + /* + ** It WAS a SIMPLE_TAG message. + ** get it and ack it! + */ + SCR_MOVE_ABS (1) ^ SCR_MSG_IN, + NADDR (msgin), + SCR_CLR (SCR_ACK), 0, -}/*-------------------------< JUMP_TO_NEXUS >-------------------*/,{ - SCR_COPY_F (4), - RADDR (temp), - PADDR (nexus_indirect), - SCR_COPY (4), -}/*-------------------------< NEXUS_INDIRECT >-------------------*/,{ + /* + ** Wait for the second byte (the tag) + */ +/*<<<*/ SCR_JUMPR ^ IFFALSE (WHEN (SCR_MSG_IN)), + 24, + /* + ** Get it and ack it! + */ + SCR_MOVE_ABS (1) ^ SCR_MSG_IN, + NADDR (msgin), + SCR_CLR (SCR_ACK|SCR_CARRY), 0, - RADDR (temp), SCR_RETURN, 0, -}/*-------------------------< RESEL_NOTAG >-------------------*/,{ /* - ** No tag expected. - ** Read an throw away the IDENTIFY. + ** No message phase or no SIMPLE_TAG message + ** or no second byte: return 0. */ - SCR_MOVE_ABS (1) ^ SCR_MSG_IN, - NADDR (msgin), +/*>>>*/ SCR_LOAD_SFBR (0), + 0, + SCR_SET (SCR_CARRY), + 0, + SCR_RETURN, + 0, + +}/*-------------------------< DATA_IO >--------------------*/,{ +/* +** Because Linux does not provide xfer data direction +** to low-level scsi drivers, we must trust the target +** for actual data direction when we cannot guess it. +** The programmed interrupt patches savep, lastp, goalp, +** etc.., and restarts the scsi script at data_out/in. +*/ + SCR_INT ^ IFTRUE (WHEN (SCR_DATA_OUT)), + SIR_DATA_IO_IS_OUT, + SCR_INT ^ IFTRUE (WHEN (SCR_DATA_IN)), + SIR_DATA_IO_IS_IN, SCR_JUMP, - PADDR (jump_to_nexus), + PADDR (no_data), + }/*-------------------------< DATA_IN >--------------------*/,{ /* ** Because the size depends on the -** #define MAX_SCATTERL parameter, +** #define MAX_SCATTER parameter, ** it is filled in at runtime. ** -** ##===========< i=0; i========= +** ##===========< i=0; i========= ** || SCR_CALL ^ IFFALSE (WHEN (SCR_DATA_IN)), -** || PADDR (dispatch), +** || PADDR (checkatn), ** || SCR_MOVE_TBL ^ SCR_DATA_IN, ** || offsetof (struct dsb, data[ i]), ** ##========================================== ** -**--------------------------------------------------------- +** SCR_CALL, +** PADDR (checkatn), +** SCR_JUMP, +** PADDR (no_data), */ 0 -}/*-------------------------< DATA_IN2 >-------------------*/,{ - SCR_CALL, - PADDR (dispatch), - SCR_JUMP, - PADDR (no_data), -}/*-------------------------< DATA_OUT >--------------------*/,{ -/* -** Because the size depends on the -** #define MAX_SCATTERL parameter, -** it is filled in at runtime. -** -** ##===========< i=0; i========= -** || SCR_CALL ^ IFFALSE (WHEN (SCR_DATA_OUT)), -** || PADDR (dispatch), -** || SCR_MOVE_TBL ^ SCR_DATA_OUT, -** || offsetof (struct dsb, data[ i]), -** ##========================================== -** -**--------------------------------------------------------- -*/ -0 -}/*-------------------------< DATA_OUT2 >-------------------*/,{ - SCR_CALL, - PADDR (dispatch), - SCR_JUMP, - PADDR (no_data), }/*--------------------------------------------------------*/ }; static struct scripth scripth0 __initdata = { /*-------------------------< TRYLOOP >---------------------*/{ /* -** Start the next entry. -** Called addresses point to the launch script in the CCB. -** They are patched by the main processor. +** Load an entry of the start queue into dsa +** and try to start it by jumping to TRYSEL. ** ** Because the size depends on the ** #define MAX_START parameter, it is filled @@ -3045,142 +3103,32 @@ static struct scripth scripth0 __initdata = { **----------------------------------------------------------- ** ** ##===========< I=0; i=========== +** || SCR_COPY (4), +** || NADDR (squeue[i]), +** || RADDR (dsa), ** || SCR_CALL, -** || PADDR (idle), +** || PADDR (trysel), ** ##========================================== ** -**----------------------------------------------------------- -*/ -0 -}/*------------------------< TRYLOOP2 >---------------------*/,{ - SCR_JUMP, - PADDRH(tryloop), - -#ifdef SCSI_NCR_CCB_DONE_SUPPORT - -}/*------------------------< DONE_QUEUE >-------------------*/,{ -/* -** Copy the CCB address to the next done entry. -** Because the size depends on the -** #define MAX_DONE parameter, it is filled -** in at runtime. -** -**----------------------------------------------------------- -** -** ##===========< I=0; i=========== -** || SCR_COPY (sizeof(ccb_p)), -** || NADDR (header.cp), -** || NADDR (ccb_done[i]), -** || SCR_CALL, -** || PADDR (done_end), -** ##========================================== +** SCR_JUMP, +** PADDRH(tryloop), ** **----------------------------------------------------------- */ 0 -}/*------------------------< DONE_QUEUE2 >------------------*/,{ - SCR_JUMP, - PADDRH (done_queue), - -#endif /* SCSI_NCR_CCB_DONE_SUPPORT */ -}/*------------------------< SELECT_NO_ATN >-----------------*/,{ - /* - ** Set Initiator mode. - ** And try to select this target without ATN. - */ - - SCR_CLR (SCR_TRG), - 0, - SCR_LOAD_REG (HS_REG, HS_SELECTING), - 0, - SCR_SEL_TBL ^ offsetof (struct dsb, select), - PADDR (reselect), - SCR_JUMP, - PADDR (select2), - -}/*-------------------------< CANCEL >------------------------*/,{ - - SCR_LOAD_REG (scratcha, HS_ABORTED), - 0, - SCR_JUMPR, - 8, -}/*-------------------------< SKIP >------------------------*/,{ - SCR_LOAD_REG (scratcha, 0), - 0, - /* - ** This entry has been canceled. - ** Next time use the next slot. - */ - SCR_COPY (4), - RADDR (temp), - PADDR (startpos), +},/*-------------------------< MSG_PARITY >---------------*/{ /* - ** The ncr doesn't have an indirect load - ** or store command. So we have to - ** copy part of the control block to a - ** fixed place, where we can access it. - ** - ** We patch the address part of a - ** COPY command with the DSA-register. - */ - SCR_COPY_F (4), - RADDR (dsa), - PADDRH (skip2), - /* - ** then we do the actual copy. - */ - SCR_COPY (sizeof (struct head)), - /* - ** continued after the next label ... - */ -}/*-------------------------< SKIP2 >---------------------*/,{ - 0, - NADDR (header), - /* - ** Initialize the status registers - */ - SCR_COPY (4), - NADDR (header.status), - RADDR (scr0), - /* - ** Force host status. - */ - SCR_FROM_REG (scratcha), - 0, - SCR_JUMPR ^ IFFALSE (MASK (0, HS_DONEMASK)), - 16, - SCR_REG_REG (HS_REG, SCR_OR, HS_SKIPMASK), - 0, - SCR_JUMPR, - 8, - SCR_TO_REG (HS_REG), - 0, - SCR_LOAD_REG (SS_REG, S_GOOD), - 0, - SCR_JUMP, - PADDR (cleanup_ok), - -},/*-------------------------< PAR_ERR_DATA_IN >---------------*/{ - /* - ** Ignore all data in byte, until next phase - */ - SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN)), - PADDRH (par_err_other), - SCR_MOVE_ABS (1) ^ SCR_DATA_IN, - NADDR (scratch), - SCR_JUMPR, - -24, -},/*-------------------------< PAR_ERR_OTHER >------------------*/{ - /* - ** count it. + ** count it */ SCR_REG_REG (PS_REG, SCR_ADD, 0x01), 0, /* - ** jump to dispatcher. + ** send a "message parity error" message. */ + SCR_LOAD_REG (scratcha, M_PARITY), + 0, SCR_JUMP, - PADDR (dispatch), + PADDR (setmsg), }/*-------------------------< MSG_REJECT >---------------*/,{ /* ** If a negotiation was in progress, @@ -3212,6 +3160,17 @@ static struct scripth scripth0 __initdata = { SCR_MOVE_ABS (1) ^ SCR_MSG_IN, NADDR (msgin[1]), /* + ** Check for message parity error. + */ + SCR_TO_REG (scratcha), + 0, + SCR_FROM_REG (socl), + 0, + SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), + PADDRH (msg_parity), + SCR_FROM_REG (scratcha), + 0, + /* ** Size is 0 .. ignore message. */ SCR_JUMP ^ IFTRUE (DATA (0)), @@ -3219,14 +3178,14 @@ static struct scripth scripth0 __initdata = { /* ** Size is not 1 .. have to interrupt. */ - SCR_JUMPR ^ IFFALSE (DATA (1)), +/*<<<*/ SCR_JUMPR ^ IFFALSE (DATA (1)), 40, /* ** Check for residue byte in swide register */ SCR_FROM_REG (scntl2), 0, - SCR_JUMPR ^ IFFALSE (MASK (WSR, WSR)), +/*<<<*/ SCR_JUMPR ^ IFFALSE (MASK (WSR, WSR)), 16, /* ** There IS data in the swide register. @@ -3239,9 +3198,9 @@ static struct scripth scripth0 __initdata = { /* ** Load again the size to the sfbr register. */ - SCR_FROM_REG (scratcha), +/*>>>*/ SCR_FROM_REG (scratcha), 0, - SCR_INT, +/*>>>*/ SCR_INT, SIR_IGN_RESIDUE, SCR_JUMP, PADDR (clrack), @@ -3260,6 +3219,17 @@ static struct scripth scripth0 __initdata = { SCR_MOVE_ABS (1) ^ SCR_MSG_IN, NADDR (msgin[1]), /* + ** Check for message parity error. + */ + SCR_TO_REG (scratcha), + 0, + SCR_FROM_REG (socl), + 0, + SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), + PADDRH (msg_parity), + SCR_FROM_REG (scratcha), + 0, + /* */ SCR_JUMP ^ IFTRUE (DATA (3)), PADDRH (msg_ext_3), @@ -3275,6 +3245,17 @@ static struct scripth scripth0 __initdata = { */ SCR_MOVE_ABS (1) ^ SCR_MSG_IN, NADDR (msgin[2]), + /* + ** Check for message parity error. + */ + SCR_TO_REG (scratcha), + 0, + SCR_FROM_REG (socl), + 0, + SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), + PADDRH (msg_parity), + SCR_FROM_REG (scratcha), + 0, SCR_JUMP ^ IFTRUE (DATA (M_X_WIDE_REQ)), PADDRH (msg_wdtr), /* @@ -3292,6 +3273,10 @@ static struct scripth scripth0 __initdata = { */ SCR_MOVE_ABS (1) ^ SCR_MSG_IN, NADDR (msgin[3]), + SCR_FROM_REG (socl), + 0, + SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), + PADDRH (msg_parity), /* ** let the host do the real work. */ @@ -3305,17 +3290,17 @@ static struct scripth scripth0 __initdata = { SCR_CLR (SCR_ACK), 0, -/* CHECK THE SOURCE FOR 'send_wdtr' IF YOU INTEND TO CHANGE SOMETHING HERE */ SCR_INT ^ IFFALSE (WHEN (SCR_MSG_OUT)), SIR_NEGO_PROTO, -}/*-------------------------< SEND_WDTR >----------------*/,{ /* ** Send the M_X_WIDE_REQ */ SCR_MOVE_ABS (4) ^ SCR_MSG_OUT, NADDR (msgout), + SCR_CLR (SCR_ATN), + 0, SCR_COPY (1), - NADDR (msgout), + RADDR (sfbr), NADDR (lastmsg), SCR_JUMP, PADDR (msg_out_done), @@ -3330,6 +3315,17 @@ static struct scripth scripth0 __initdata = { */ SCR_MOVE_ABS (1) ^ SCR_MSG_IN, NADDR (msgin[2]), + /* + ** Check for message parity error. + */ + SCR_TO_REG (scratcha), + 0, + SCR_FROM_REG (socl), + 0, + SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), + PADDRH (msg_parity), + SCR_FROM_REG (scratcha), + 0, SCR_JUMP ^ IFTRUE (DATA (M_X_SYNC_REQ)), PADDRH (msg_sdtr), /* @@ -3348,6 +3344,10 @@ static struct scripth scripth0 __initdata = { */ SCR_MOVE_ABS (2) ^ SCR_MSG_IN, NADDR (msgin[3]), + SCR_FROM_REG (socl), + 0, + SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), + PADDRH (msg_parity), /* ** let the host do the real work. */ @@ -3361,17 +3361,17 @@ static struct scripth scripth0 __initdata = { SCR_CLR (SCR_ACK), 0, -/* CHECK THE SOURCE FOR 'send_sdtr' IF YOU INTEND TO CHANGE SOMETHING HERE */ SCR_INT ^ IFFALSE (WHEN (SCR_MSG_OUT)), SIR_NEGO_PROTO, -}/*-------------------------< SEND_SDTR >-------------*/,{ /* ** Send the M_X_SYNC_REQ */ SCR_MOVE_ABS (5) ^ SCR_MSG_OUT, NADDR (msgout), + SCR_CLR (SCR_ATN), + 0, SCR_COPY (1), - NADDR (msgout), + RADDR (sfbr), NADDR (lastmsg), SCR_JUMP, PADDR (msg_out_done), @@ -3396,259 +3396,203 @@ static struct scripth scripth0 __initdata = { SCR_JUMP, PADDR (cleanup), -}/*-------------------------< HDATA_IN >-------------------*/,{ -/* -** Because the size depends on the -** #define MAX_SCATTERH parameter, -** it is filled in at runtime. -** -** ##==< i=MAX_SCATTERL; i== -** || SCR_CALL ^ IFFALSE (WHEN (SCR_DATA_IN)), -** || PADDR (dispatch), -** || SCR_MOVE_TBL ^ SCR_DATA_IN, -** || offsetof (struct dsb, data[ i]), -** ##=================================================== -** -**--------------------------------------------------------- -*/ -0 -}/*-------------------------< HDATA_IN2 >------------------*/,{ - SCR_JUMP, - PADDR (data_in), - -}/*-------------------------< HDATA_OUT >-------------------*/,{ -/* -** Because the size depends on the -** #define MAX_SCATTERH parameter, -** it is filled in at runtime. -** -** ##==< i=MAX_SCATTERL; i== -** || SCR_CALL ^ IFFALSE (WHEN (SCR_DATA_OUT)), -** || PADDR (dispatch), -** || SCR_MOVE_TBL ^ SCR_DATA_OUT, -** || offsetof (struct dsb, data[ i]), -** ##=================================================== -** -**--------------------------------------------------------- -*/ -0 -}/*-------------------------< HDATA_OUT2 >------------------*/,{ - SCR_JUMP, - PADDR (data_out), - -}/*-------------------------< RESET >----------------------*/,{ +}/*-------------------------< GETCC >-----------------------*/,{ /* - ** Send a M_RESET message if bad IDENTIFY - ** received on reselection. + ** The ncr doesn't have an indirect load + ** or store command. So we have to + ** copy part of the control block to a + ** fixed place, where we can modify it. + ** + ** We patch the address part of a COPY command + ** with the address of the dsa register ... */ - SCR_LOAD_REG (scratcha, M_ABORT_TAG), - 0, - SCR_JUMP, - PADDRH (abort_resel), -}/*-------------------------< ABORTTAG >-------------------*/,{ + SCR_COPY_F (4), + RADDR (dsa), + PADDRH (getcc1), /* - ** Abort a wrong tag received on reselection. + ** ... then we do the actual copy. */ - SCR_LOAD_REG (scratcha, M_ABORT_TAG), + SCR_COPY (sizeof (struct head)), +}/*-------------------------< GETCC1 >----------------------*/,{ 0, - SCR_JUMP, - PADDRH (abort_resel), -}/*-------------------------< ABORT >----------------------*/,{ + NADDR (header), /* - ** Abort a reselection when no active CCB. + ** Initialize the status registers */ - SCR_LOAD_REG (scratcha, M_ABORT), - 0, -}/*-------------------------< ABORT_RESEL >----------------*/,{ - SCR_COPY (1), - RADDR (scratcha), - NADDR (msgout), - SCR_SET (SCR_ATN), - 0, - SCR_CLR (SCR_ACK), - 0, + SCR_COPY (4), + NADDR (header.status), + RADDR (scr0), +}/*-------------------------< GETCC2 >----------------------*/,{ /* - ** and send it. - ** we expect an immediate disconnect + ** Get the condition code from a target. + ** + ** DSA points to a data structure. + ** Set TEMP to the script location + ** that receives the condition code. + ** + ** Because there is no script command + ** to load a longword into a register, + ** we use a CALL command. */ - SCR_REG_REG (scntl2, SCR_AND, 0x7f), - 0, - SCR_MOVE_ABS (1) ^ SCR_MSG_OUT, - NADDR (msgout), - SCR_COPY (1), - NADDR (msgout), - NADDR (lastmsg), - SCR_CLR (SCR_ACK|SCR_ATN), - 0, - SCR_WAIT_DISC, - 0, - SCR_JUMP, - PADDR (start), -}/*-------------------------< RESEND_IDENT >-------------------*/,{ +/*<<<*/ SCR_CALLR, + 24, /* - ** The target stays in MSG OUT phase after having acked - ** Identify [+ Tag [+ Extended message ]]. Targets shall - ** behave this way on parity error. - ** We must send it again all the messages. + ** Get the condition code. */ - SCR_SET (SCR_ATN), /* Shall be asserted 2 deskew delays before the */ - 0, /* 1rst ACK = 90 ns. Hope the NCR is'nt too fast */ - SCR_JUMP, - PADDR (send_ident), -}/*-------------------------< CLRATN_GO_ON >-------------------*/,{ - SCR_CLR (SCR_ATN), - 0, - SCR_JUMP, -}/*-------------------------< NXTDSP_GO_ON >-------------------*/,{ - 0, -}/*-------------------------< SDATA_IN >-------------------*/,{ - SCR_CALL ^ IFFALSE (WHEN (SCR_DATA_IN)), - PADDR (dispatch), SCR_MOVE_TBL ^ SCR_DATA_IN, offsetof (struct dsb, sense), + /* + ** No data phase may follow! + */ SCR_CALL, - PADDR (dispatch), + PADDR (checkatn), SCR_JUMP, PADDR (no_data), -}/*-------------------------< DATA_IO >--------------------*/,{ - /* - ** We jump here if the data direction was unknown at the - ** time we had to queue the command to the scripts processor. - ** Pointers had been set as follow in this situation: - ** savep --> DATA_IO - ** lastp --> start pointer when DATA_IN - ** goalp --> goal pointer when DATA_IN - ** wlastp --> start pointer when DATA_OUT - ** wgoalp --> goal pointer when DATA_OUT - ** This script sets savep/lastp/goalp according to the - ** direction chosen by the target. - */ - SCR_JUMPR ^ IFTRUE (WHEN (SCR_DATA_OUT)), - 32, +/*>>>*/ + /* - ** Direction is DATA IN. - ** Warning: we jump here, even when phase is DATA OUT. + ** The CALL jumps to this point. + ** Prepare for a RESTORE_POINTER message. + ** Save the TEMP register into the saved pointer. */ SCR_COPY (4), - NADDR (header.lastp), + RADDR (temp), NADDR (header.savep), - /* - ** Jump to the SCRIPTS according to actual direction. + ** Load scratcha, because in case of a selection timeout, + ** the host will expect a new value for startpos in + ** the scratcha register. */ SCR_COPY (4), - NADDR (header.savep), - RADDR (temp), - SCR_RETURN, + PADDR (startpos), + RADDR (scratcha), +#ifdef NCR_GETCC_WITHMSG + /* + ** If QUIRK_NOMSG is set, select without ATN. + ** and don't send a message. + */ + SCR_FROM_REG (QU_REG), 0, + SCR_JUMP ^ IFTRUE (MASK (QUIRK_NOMSG, QUIRK_NOMSG)), + PADDRH(getcc3), /* - ** Direction is DATA OUT. + ** Then try to connect to the target. + ** If we are reselected, special treatment + ** of the current job is required before + ** accepting the reselection. */ - SCR_COPY (4), - NADDR (header.wlastp), - NADDR (header.lastp), - SCR_COPY (4), - NADDR (header.wgoalp), - NADDR (header.goalp), - SCR_JUMPR, - -64, -}/*-------------------------< BAD_IDENTIFY >---------------*/,{ + SCR_SEL_TBL_ATN ^ offsetof (struct dsb, select), + PADDR(badgetcc), /* - ** If message phase but not an IDENTIFY, - ** get some help from the C code. - ** Old SCSI device may behave so. + ** save target id. */ - SCR_JUMPR ^ IFTRUE (MASK (0x80, 0x80)), - 16, - SCR_INT, - SIR_RESEL_NO_IDENTIFY, - SCR_JUMP, - PADDRH (reset), + SCR_FROM_REG (sdid), + 0, + SCR_TO_REG (ctest0), + 0, /* - ** Message is an IDENTIFY, but lun is unknown. - ** Read the message, since we got it directly - ** from the SCSI BUS data lines. - ** Signal problem to C code for logging the event. - ** Send a M_ABORT to clear all pending tasks. + ** Send the IDENTIFY message. + ** In case of short transfer, remove ATN. */ - SCR_INT, - SIR_RESEL_BAD_LUN, - SCR_MOVE_ABS (1) ^ SCR_MSG_IN, - NADDR (msgin), - SCR_JUMP, - PADDRH (abort), -}/*-------------------------< BAD_I_T_L >------------------*/,{ + SCR_MOVE_TBL ^ SCR_MSG_OUT, + offsetof (struct dsb, smsg2), + SCR_CLR (SCR_ATN), + 0, /* - ** We donnot have a task for that I_T_L. - ** Signal problem to C code for logging the event. - ** Send a M_ABORT message. + ** save the first byte of the message. */ - SCR_INT, - SIR_RESEL_BAD_I_T_L, + SCR_COPY (1), + RADDR (sfbr), + NADDR (lastmsg), SCR_JUMP, - PADDRH (abort), -}/*-------------------------< BAD_I_T_L_Q >----------------*/,{ + PADDR (prepare2), + +#endif +}/*-------------------------< GETCC3 >----------------------*/,{ /* - ** We donnot have a task that matches the tag. - ** Signal problem to C code for logging the event. - ** Send a M_ABORTTAG message. + ** Try to connect to the target. + ** If we are reselected, special treatment + ** of the current job is required before + ** accepting the reselection. + ** + ** Silly target won't accept a message. + ** Select without ATN. */ - SCR_INT, - SIR_RESEL_BAD_I_T_L_Q, - SCR_JUMP, - PADDRH (aborttag), -}/*-------------------------< BAD_TARGET >-----------------*/,{ + SCR_SEL_TBL ^ offsetof (struct dsb, select), + PADDR(badgetcc), /* - ** We donnot know the target that reselected us. - ** Grab the first message if any (IDENTIFY). - ** Signal problem to C code for logging the event. - ** M_RESET message. + ** save target id. */ - SCR_INT, - SIR_RESEL_BAD_TARGET, - SCR_JUMPR ^ IFFALSE (WHEN (SCR_MSG_IN)), - 8, - SCR_MOVE_ABS (1) ^ SCR_MSG_IN, - NADDR (msgin), - SCR_JUMP, - PADDRH (reset), -}/*-------------------------< BAD_STATUS >-----------------*/,{ + SCR_FROM_REG (sdid), + 0, + SCR_TO_REG (ctest0), + 0, /* - ** If command resulted in either QUEUE FULL, - ** CHECK CONDITION or COMMAND TERMINATED, - ** call the C code. + ** Force error if selection timeout */ - SCR_INT ^ IFTRUE (DATA (S_QUEUE_FULL)), - SIR_BAD_STATUS, - SCR_INT ^ IFTRUE (DATA (S_CHECK_COND)), - SIR_BAD_STATUS, - SCR_INT ^ IFTRUE (DATA (S_TERMINATED)), - SIR_BAD_STATUS, - SCR_RETURN, + SCR_JUMPR ^ IFTRUE (WHEN (SCR_MSG_IN)), 0, -}/*-------------------------< START_RAM >-------------------*/,{ /* - ** Load the script into on-chip RAM, - ** and jump to start point. + ** don't negotiate. + */ + SCR_JUMP, + PADDR (prepare2), + +}/*-------------------------< DATA_OUT >-------------------*/,{ +/* +** Because the size depends on the +** #define MAX_SCATTER parameter, +** it is filled in at runtime. +** +** ##===========< i=0; i========= +** || SCR_CALL ^ IFFALSE (WHEN (SCR_DATA_OUT)), +** || PADDR (dispatch), +** || SCR_MOVE_TBL ^ SCR_DATA_OUT, +** || offsetof (struct dsb, data[ i]), +** ##========================================== +** +** SCR_CALL, +** PADDR (dispatch), +** SCR_JUMP, +** PADDR (no_data), +** +**--------------------------------------------------------- +*/ +0 +}/*-------------------------< ABORTTAG >-------------------*/,{ + /* + ** Abort a bad reselection. + ** Set the message to ABORT vs. ABORT_TAG */ - SCR_COPY_F (4), + SCR_LOAD_REG (scratcha, M_ABORT_TAG), + 0, + SCR_JUMPR ^ IFFALSE (CARRYSET), + 8, +}/*-------------------------< ABORT >----------------------*/,{ + SCR_LOAD_REG (scratcha, M_ABORT), + 0, + SCR_COPY (1), RADDR (scratcha), - PADDRH (start_ram0), - SCR_COPY (sizeof (struct script)), -}/*-------------------------< START_RAM0 >--------------------*/,{ + NADDR (msgout), + SCR_SET (SCR_ATN), + 0, + SCR_CLR (SCR_ACK), 0, - PADDR (start), - SCR_JUMP, - PADDR (start), -}/*-------------------------< STO_RESTART >-------------------*/,{ /* - ** - ** Repair start queue (e.g. next time use the next slot) - ** and jump to start point. + ** and send it. + ** we expect an immediate disconnect */ - SCR_COPY (4), - RADDR (temp), - PADDR (startpos), + SCR_REG_REG (scntl2, SCR_AND, 0x7f), + 0, + SCR_MOVE_ABS (1) ^ SCR_MSG_OUT, + NADDR (msgout), + SCR_COPY (1), + RADDR (sfbr), + NADDR (lastmsg), + SCR_CLR (SCR_ACK|SCR_ATN), + 0, + SCR_WAIT_DISC, + 0, SCR_JUMP, PADDR (start), }/*-------------------------< SNOOPTEST >-------------------*/,{ @@ -3697,63 +3641,48 @@ void ncr_script_fill (struct script * scr, struct scripth * scrh) p = scrh->tryloop; for (i=0; itryloop + sizeof (scrh->tryloop)); -#ifdef SCSI_NCR_CCB_DONE_SUPPORT - - p = scrh->done_queue; - for (i = 0; idone_queue+sizeof(scrh->done_queue)); - -#endif /* SCSI_NCR_CCB_DONE_SUPPORT */ + p = scr->data_in; - p = scrh->hdata_in; - for (i=0; ihdata_in + sizeof (scrh->hdata_in)); - p = scr->data_in; - for (i=MAX_SCATTERH; idata_in + sizeof (scr->data_in)); - p = scrh->hdata_out; - for (i=0; ihdata_out + sizeof (scrh->hdata_out)); + p = scrh->data_out; - p = scr->data_out; - for (i=MAX_SCATTERH; idata_out + sizeof (scr->data_out)); + *p++ =SCR_CALL; + *p++ =PADDR (dispatch); + *p++ =SCR_JUMP; + *p++ =PADDR (no_data); + + assert ((u_long)p == (u_long)&scrh->data_out + sizeof (scrh->data_out)); } /*========================================================== @@ -3790,13 +3719,13 @@ static void ncr_script_copy_and_bind (ncb_p np, ncrcmd *src, ncrcmd *dst, int le */ if (opcode == 0) { - printk (KERN_ERR "%s: ERROR0 IN SCRIPT at %d.\n", + printf ("%s: ERROR0 IN SCRIPT at %d.\n", ncr_name(np), (int) (src-start-1)); - MDELAY (1000); + DELAY (1000000); }; if (DEBUG_FLAGS & DEBUG_SCRIPT) - printk (KERN_DEBUG "%p: <%x>\n", + printf ("%p: <%x>\n", (src-1), (unsigned)opcode); /* @@ -3816,9 +3745,9 @@ static void ncr_script_copy_and_bind (ncb_p np, ncrcmd *src, ncrcmd *dst, int le if ((tmp2 & RELOC_MASK) == RELOC_KVAR) tmp2 = 0; if ((tmp1 ^ tmp2) & 3) { - printk (KERN_ERR"%s: ERROR1 IN SCRIPT at %d.\n", + printf ("%s: ERROR1 IN SCRIPT at %d.\n", ncr_name(np), (int) (src-start-1)); - MDELAY (1000); + DELAY (1000000); } /* ** If PREFETCH feature not enabled, remove @@ -3840,7 +3769,7 @@ static void ncr_script_copy_and_bind (ncb_p np, ncrcmd *src, ncrcmd *dst, int le case 0x8: /* ** JUMP / CALL - ** dont't relocate if relative :-) + ** don't relocate if relative :-) */ if (opcode & 0x00800000) relocs = 0; @@ -3866,8 +3795,7 @@ static void ncr_script_copy_and_bind (ncb_p np, ncrcmd *src, ncrcmd *dst, int le switch (old & RELOC_MASK) { case RELOC_REGISTER: - new = (old & ~RELOC_MASK) - + bus_dvma_to_mem(np->paddr); + new = (old & ~RELOC_MASK) + np->paddr; break; case RELOC_LABEL: new = (old & ~RELOC_MASK) + np->p_script; @@ -3905,6 +3833,9 @@ static void ncr_script_copy_and_bind (ncb_p np, ncrcmd *src, ncrcmd *dst, int le *dst++ = cpu_to_scr(*src++); }; + if (bootverbose > 1 && opchanged) + printf("%s: NO FLUSH bit removed from %d script instructions\n", + ncr_name(np), opchanged); } /*========================================================== @@ -3927,37 +3858,31 @@ static void ncr_script_copy_and_bind (ncb_p np, ncrcmd *src, ncrcmd *dst, int le struct host_data { struct ncb *ncb; - char ncb_align[CACHE_LINE_SIZE-1]; /* Filler for alignment */ + char ncb_align[NCB_ALIGN_SIZE-1]; /* Filler for alignment */ struct ncb _ncb_data; - char ccb_align[CACHE_LINE_SIZE-1]; /* Filler for alignment */ + char ccb_align[CCB_ALIGN_SIZE-1]; /* Filler for alignment */ struct ccb _ccb_data; - char scr_align[CACHE_LINE_SIZE-1]; /* Filler for alignment */ + char scr_align[SCR_ALIGN_SIZE-1]; /* Filler for alignment */ struct script script_data; struct scripth scripth_data; }; /* -** Print something which allows to retrieve the controler type, unit, +** Print something which allow to retrieve the controler type, unit, ** target, lun concerned by a kernel message. */ -static void PRINT_TARGET(ncb_p np, int target) -{ - printk(KERN_INFO "%s-<%d,*>: ", ncr_name(np), target); -} - -static void PRINT_LUN(ncb_p np, int target, int lun) -{ - printk(KERN_INFO "%s-<%d,%d>: ", ncr_name(np), target, lun); -} +#define PRINT_LUN(np, target, lun) \ +printf(KERN_INFO "%s-<%d,%d>: ", ncr_name(np), (int) (target), (int) (lun)) static void PRINT_ADDR(Scsi_Cmnd *cmd) { struct host_data *host_data = (struct host_data *) cmd->host->hostdata; - PRINT_LUN(host_data->ncb, cmd->target, cmd->lun); + ncb_p np = host_data->ncb; + if (np) PRINT_LUN(np, cmd->target, cmd->lun); } /*========================================================== @@ -4064,6 +3989,8 @@ static void if (tn->flags & TEKRAM_TAGGED_COMMANDS) { tp->usrtags = 2 << nvram->max_tags_index; + if (tp->usrtags > SCSI_NCR_MAX_TAGS) + tp->usrtags = SCSI_NCR_MAX_TAGS; } if (!(tn->flags & TEKRAM_DISCONNECT_ENABLE)) @@ -4126,7 +4053,8 @@ static int ncr_prepare_setting(ncb_p np, ncr_nvram *nvram) * Divisor to be used for async (timer pre-scaler). */ i = np->clock_divn - 1; - while (--i >= 0) { + while (i >= 0) { + --i; if (10ul * SCSI_NCR_MIN_ASYNC * np->clock_khz > div_10M[i]) { ++i; break; @@ -4318,7 +4246,7 @@ static int ncr_prepare_setting(ncb_p np, ncr_nvram *nvram) #endif tp->usrsync = driver_setup.default_sync; tp->usrwide = driver_setup.max_wide; - tp->usrtags = SCSI_NCR_MAX_TAGS; + tp->usrtags = driver_setup.default_tags; if (!driver_setup.disconnection) np->target[i].usrflag = UF_NODISC; } @@ -4329,7 +4257,7 @@ static int ncr_prepare_setting(ncb_p np, ncr_nvram *nvram) */ i = nvram ? nvram->type : 0; - printk(KERN_INFO "%s: %sID %d, Fast-%d%s%s\n", ncr_name(np), + printf(KERN_INFO "%s: %sID %d, Fast-%d%s%s\n", ncr_name(np), i == SCSI_NCR_SYMBIOS_NVRAM ? "Symbios format NVRAM, " : (i == SCSI_NCR_TEKRAM_NVRAM ? "Tekram format NVRAM, " : ""), np->myaddr, @@ -4338,19 +4266,19 @@ static int ncr_prepare_setting(ncb_p np, ncr_nvram *nvram) (np->rv_stest2 & 0x20) ? ", Differential" : ""); if (bootverbose > 1) { - printk (KERN_INFO "%s: initial SCNTL3/DMODE/DCNTL/CTEST3/4/5 = " + printf ("%s: initial SCNTL3/DMODE/DCNTL/CTEST3/4/5 = " "(hex) %02x/%02x/%02x/%02x/%02x/%02x\n", ncr_name(np), np->sv_scntl3, np->sv_dmode, np->sv_dcntl, np->sv_ctest3, np->sv_ctest4, np->sv_ctest5); - printk (KERN_INFO "%s: final SCNTL3/DMODE/DCNTL/CTEST3/4/5 = " + printf ("%s: final SCNTL3/DMODE/DCNTL/CTEST3/4/5 = " "(hex) %02x/%02x/%02x/%02x/%02x/%02x\n", ncr_name(np), np->rv_scntl3, np->rv_dmode, np->rv_dcntl, np->rv_ctest3, np->rv_ctest4, np->rv_ctest5); } if (bootverbose && np->paddr2) - printk (KERN_INFO "%s: on-chip RAM at 0x%lx\n", + printf (KERN_INFO "%s: on-board RAM at 0x%lx\n", ncr_name(np), np->paddr2); return 0; @@ -4366,18 +4294,17 @@ void ncr_display_Symbios_nvram(ncb_p np, Symbios_nvram *nvram) int i; /* display Symbios nvram host data */ - printk(KERN_DEBUG "%s: HOST ID=%d%s%s%s%s%s\n", + printf("%s: HOST ID=%d%s%s%s%s\n", ncr_name(np), nvram->host_id & 0x0f, (nvram->flags & SYMBIOS_SCAM_ENABLE) ? " SCAM" :"", (nvram->flags & SYMBIOS_PARITY_ENABLE) ? " PARITY" :"", - (nvram->flags & SYMBIOS_VERBOSE_MSGS) ? " VERBOSE" :"", - (nvram->flags & SYMBIOS_CHS_MAPPING) ? " CHS_ALT" :"", + (nvram->flags & SYMBIOS_VERBOSE_MSGS) ? " VERSBOSE" :"", (nvram->flags1 & SYMBIOS_SCAN_HI_LO) ? " HI_LO" :""); /* display Symbios nvram drive data */ for (i = 0 ; i < 15 ; i++) { struct Symbios_target *tn = &nvram->target[i]; - printk(KERN_DEBUG "%s-%d:%s%s%s%s WIDTH=%d SYNC=%d TMO=%d\n", + printf("%s-%d:%s%s%s%s WIDTH=%d SYNC=%d TMO=%d\n", ncr_name(np), i, (tn->flags & SYMBIOS_DISCONNECT_ENABLE) ? " DISC" : "", (tn->flags & SYMBIOS_SCAN_AT_BOOT_TIME) ? " SCAN_BOOT" : "", @@ -4410,8 +4337,7 @@ void ncr_display_Tekram_nvram(ncb_p np, Tekram_nvram *nvram) case 2: rem = " REMOVABLE=all"; break; } - printk(KERN_DEBUG - "%s: HOST ID=%d%s%s%s%s%s%s%s%s%s BOOT DELAY=%d tags=%d\n", + printf("%s: HOST ID=%d%s%s%s%s%s%s%s%s%s BOOT DELAY=%d tags=%d\n", ncr_name(np), nvram->host_id & 0x0f, (nvram->flags1 & SYMBIOS_SCAM_ENABLE) ? " SCAM" :"", (nvram->flags & TEKRAM_MORE_THAN_2_DRIVES) ? " >2DRIVES" :"", @@ -4429,7 +4355,7 @@ void ncr_display_Tekram_nvram(ncb_p np, Tekram_nvram *nvram) struct Tekram_target *tn = &nvram->target[i]; j = tn->sync_index & 0xf; sync = j < 12 ? Tekram_sync[j] : 255; - printk(KERN_DEBUG "%s-%d:%s%s%s%s%s%s PERIOD=%d\n", + printf("%s-%d:%s%s%s%s%s%s PERIOD=%d\n", ncr_name(np), i, (tn->flags & TEKRAM_PARITY_CHECK) ? " PARITY" : "", (tn->flags & TEKRAM_SYNC_NEGO) ? " SYNC" : "", @@ -4461,18 +4387,11 @@ static int ncr_attach (Scsi_Host_Template *tpnt, int unit, ncr_device *device) struct Scsi_Host *instance = 0; u_long flags = 0; ncr_nvram *nvram = device->nvram; - int i; -#ifdef __sparc__ -printk(KERN_INFO "ncr53c%s-%d: rev=0x%02x, base=0x%lx, io_port=0x%lx, irq=%s\n", - device->chip.name, unit, device->chip.revision_id, device->slot.base, - device->slot.io_port, __irq_itoa(device->slot.irq)); -#else -printk(KERN_INFO "ncr53c%s-%d: rev=0x%02x, base=0x%lx, io_port=0x%lx, irq=%d\n", +printf(KERN_INFO "ncr53c%s-%d: rev=0x%02x, base=0x%x, io_port=0x%x, irq=%d\n", device->chip.name, unit, device->chip.revision_id, device->slot.base, device->slot.io_port, device->slot.irq); -#endif - + /* ** Allocate host_data structure */ @@ -4483,16 +4402,17 @@ printk(KERN_INFO "ncr53c%s-%d: rev=0x%02x, base=0x%lx, io_port=0x%lx, irq=%d\n", ** Initialize structure. */ host_data = (struct host_data *) instance->hostdata; - bzero (host_data, sizeof(*host_data)); /* ** Align np and first ccb to 32 boundary for cache line ** bursting when copying the global header. */ - np = (ncb_p) (((u_long) &host_data->_ncb_data) & CACHE_LINE_MASK); - NCR_INIT_LOCK_NCB(np); + np = (ncb_p) (((u_long) &host_data->_ncb_data) & NCB_ALIGN_MASK); host_data->ncb = np; - np->ccb = (ccb_p) (((u_long) &host_data->_ccb_data) & CACHE_LINE_MASK); + bzero (np, sizeof (*np)); + + np->ccb = (ccb_p) (((u_long) &host_data->_ccb_data) & CCB_ALIGN_MASK); + bzero (np->ccb, sizeof (*np->ccb)); /* ** Store input informations in the host data structure. @@ -4508,8 +4428,8 @@ printk(KERN_INFO "ncr53c%s-%d: rev=0x%02x, base=0x%lx, io_port=0x%lx, irq=%d\n", np->maxoffs = device->chip.offset_max; np->maxburst = device->chip.burst_max; - np->script0 = (struct script *) - (((u_long) &host_data->script_data) & CACHE_LINE_MASK); + np->script0 = + (struct script *) (((u_long) &host_data->script_data) & SCR_ALIGN_MASK); np->scripth0 = &host_data->scripth_data; /* @@ -4531,14 +4451,12 @@ printk(KERN_INFO "ncr53c%s-%d: rev=0x%02x, base=0x%lx, io_port=0x%lx, irq=%d\n", #ifndef NCR_IOMAPPED np->vaddr = remap_pci_mem((u_long) np->paddr, (u_long) 128); if (!np->vaddr) { - printk(KERN_ERR - "%s: can't map memory mapped IO region\n",ncr_name(np)); + printf("%s: can't map memory mapped IO region\n", ncr_name(np)); goto attach_error; } else if (bootverbose > 1) - printk(KERN_INFO - "%s: using memory mapped IO at virtual address 0x%lx\n", ncr_name(np), (u_long) np->vaddr); + printf("%s: using memory mapped IO at virtual address 0x%lx\n", ncr_name(np), (u_long) np->vaddr); /* ** Make the controller's registers available. @@ -4573,7 +4491,7 @@ printk(KERN_INFO "ncr53c%s-%d: rev=0x%02x, base=0x%lx, io_port=0x%lx, irq=%d\n", default: nvram = 0; #ifdef SCSI_NCR_DEBUG_NVRAM - printk(KERN_DEBUG "%s: NVRAM: None or invalid data.\n", ncr_name(np)); + printf("%s: NVRAM: None or invalid data.\n", ncr_name(np)); #endif } } @@ -4584,27 +4502,37 @@ printk(KERN_INFO "ncr53c%s-%d: rev=0x%02x, base=0x%lx, io_port=0x%lx, irq=%d\n", */ (void)ncr_prepare_setting(np, nvram); - if (np->paddr2 && sizeof(struct script) > 4096) { - np->paddr2 = 0; - printk(KERN_WARNING "%s: script too large, NOT using on chip RAM.\n", - ncr_name(np)); +#ifndef NCR_IOMAPPED + if (np->paddr2 && sizeof(struct script) <= 4096) { + np->vaddr2 = remap_pci_mem((u_long) np->paddr2, (u_long) 4096); + if (!np->vaddr2) { + printf("%s: can't map memory mapped IO region\n", ncr_name(np)); + goto attach_error; + } + else + if (bootverbose > 1) + printf("%s: on-board ram mapped at virtual address 0x%lx\n", ncr_name(np), (u_long) np->vaddr2); } +#endif /* !defined NCR_IOMAPPED */ /* ** Fill Linux host instance structure */ +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,0) instance->max_channel = 0; instance->max_id = np->maxwide ? 16 : 8; instance->max_lun = SCSI_NCR_MAX_LUN; +#endif #ifndef NCR_IOMAPPED instance->base = (char *) np->reg; #endif instance->irq = device->slot.irq; - instance->unique_id = device->slot.io_port; instance->io_port = device->slot.io_port; instance->n_io_port = 128; instance->dma_channel = 0; +#if LINUX_VERSION_CODE >= LinuxVersionCode(2,0,0) instance->select_queue_depths = ncr53c8xx_select_queue_depths; +#endif /* ** Patch script to physical addresses @@ -4614,7 +4542,8 @@ printk(KERN_INFO "ncr53c%s-%d: rev=0x%02x, base=0x%lx, io_port=0x%lx, irq=%d\n", np->scripth = np->scripth0; np->p_scripth = vtophys(np->scripth); - np->p_script = (np->paddr2) ? bus_dvma_to_mem(np->paddr2) : vtophys(np->script0); + np->script = (np->vaddr2) ? (struct script *) np->vaddr2 : np->script0; + np->p_script = (np->vaddr2) ? np->paddr2 : vtophys(np->script0); ncr_script_copy_and_bind (np, (ncrcmd *) &script0, (ncrcmd *) np->script0, sizeof(struct script)); ncr_script_copy_and_bind (np, (ncrcmd *) &scripth0, (ncrcmd *) np->scripth0, sizeof(struct scripth)); @@ -4625,32 +4554,27 @@ printk(KERN_INFO "ncr53c%s-%d: rev=0x%02x, base=0x%lx, io_port=0x%lx, irq=%d\n", */ if (np->features & FE_LED0) { - np->script0->idle[0] = + np->script0->reselect[0] = cpu_to_scr(SCR_REG_REG(gpreg, SCR_OR, 0x01)); - np->script0->reselected[0] = + np->script0->reselect1[0] = cpu_to_scr(SCR_REG_REG(gpreg, SCR_AND, 0xfe)); - np->script0->start[0] = + np->script0->reselect2[0] = cpu_to_scr(SCR_REG_REG(gpreg, SCR_AND, 0xfe)); } /* - ** Look for the target control block of this nexus. - ** For i = 0 to 3 - ** JUMP ^ IFTRUE (MASK (i, 3)), @(next_lcb) + ** init data structure */ - for (i = 0 ; i < 4 ; i++) { - np->jump_tcb[i].l_cmd = - cpu_to_scr((SCR_JUMP ^ IFTRUE (MASK (i, 3)))); - np->jump_tcb[i].l_paddr = - cpu_to_scr(NCB_SCRIPTH_PHYS (np, bad_target)); - } + + np->jump_tcb.l_cmd = cpu_to_scr(SCR_JUMP); + np->jump_tcb.l_paddr = cpu_to_scr(NCB_SCRIPTH_PHYS (np, abort)); /* ** Reset chip. */ OUTB (nc_istat, SRST); - UDELAY (100); + DELAY (1000); OUTB (nc_istat, 0 ); /* @@ -4658,44 +4582,33 @@ printk(KERN_INFO "ncr53c%s-%d: rev=0x%02x, base=0x%lx, io_port=0x%lx, irq=%d\n", */ if (ncr_snooptest (np)) { - printk (KERN_ERR "CACHE INCORRECTLY CONFIGURED.\n"); + printf ("CACHE INCORRECTLY CONFIGURED.\n"); goto attach_error; }; /* ** Install the interrupt handler. */ -#ifdef SCSI_NCR_SHARE_IRQ -#define NCR_SA_INTERRUPT_FLAGS (SA_INTERRUPT | SA_SHIRQ) +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,70) +#ifdef SCSI_NCR_SHARE_IRQ if (bootverbose > 1) -#ifdef __sparc__ - printk(KERN_INFO "%s: requesting shared irq %s (dev_id=0x%lx)\n", - ncr_name(np), __irq_itoa(device->slot.irq), (u_long) np); -#else - printk(KERN_INFO "%s: requesting shared irq %d (dev_id=0x%lx)\n", + printf("%s: requesting shared irq %d (dev_id=0x%lx)\n", ncr_name(np), device->slot.irq, (u_long) np); -#endif + if (request_irq(device->slot.irq, ncr53c8xx_intr, + SA_INTERRUPT|SA_SHIRQ, "ncr53c8xx", np)) { #else -#define NCR_SA_INTERRUPT_FLAGS SA_INTERRUPT -#endif if (request_irq(device->slot.irq, ncr53c8xx_intr, - NCR_SA_INTERRUPT_FLAGS, "ncr53c8xx", np)) { -#ifdef __sparc__ - printk(KERN_ERR "%s: request irq %s failure\n", - ncr_name(np), __irq_itoa(device->slot.irq)); + SA_INTERRUPT, "ncr53c8xx", np)) { +#endif #else - printk(KERN_ERR "%s: request irq %d failure\n", - ncr_name(np), device->slot.irq); + if (request_irq(device->slot.irq, ncr53c8xx_intr, + SA_INTERRUPT, "ncr53c8xx")) { #endif + printf("%s: request irq %d failure\n", ncr_name(np), device->slot.irq); goto attach_error; } np->irq = device->slot.irq; - /* - ** Initialize the fixed part of the default ccb. - */ - ncr_init_ccb(np, np->ccb); - /* ** After SCSI devices have been opened, we cannot ** reset the bus safely, so we do it here. @@ -4704,26 +4617,26 @@ printk(KERN_INFO "ncr53c%s-%d: rev=0x%02x, base=0x%lx, io_port=0x%lx, irq=%d\n", ** if interrupts are not enabled yet. ** Then enable disconnects. */ - NCR_LOCK_NCB(np, flags); + save_flags(flags); cli(); if (ncr_reset_scsi_bus(np, 0, driver_setup.settle_delay) != 0) { - printk(KERN_ERR "%s: FATAL ERROR: CHECK SCSI BUS - CABLES, TERMINATION, DEVICE POWER etc.!\n", ncr_name(np)); - - NCR_UNLOCK_NCB(np, flags); + printf("%s: FATAL ERROR: CHECK SCSI BUS - CABLES, TERMINATION, DEVICE POWER etc.!\n", ncr_name(np)); + restore_flags(flags); goto attach_error; } ncr_exception (np); + restore_flags(flags); np->disc = 1; /* ** The middle-level SCSI driver does not - ** wait for devices to settle. + ** wait devices to settle. ** Wait synchronously if more than 2 seconds. */ if (driver_setup.settle_delay > 2) { - printk(KERN_INFO "%s: waiting %d seconds for scsi devices to settle...\n", + printf("%s: waiting %d seconds for scsi devices to settle...\n", ncr_name(np), driver_setup.settle_delay); - MDELAY (1000 * driver_setup.settle_delay); + DELAY(1000000UL * driver_setup.settle_delay); } /* @@ -4752,81 +4665,46 @@ printk(KERN_INFO "ncr53c%s-%d: rev=0x%02x, base=0x%lx, io_port=0x%lx, irq=%d\n", first_host = instance; } - NCR_UNLOCK_NCB(np, flags); - return 0; attach_error: if (!instance) return -1; - printk(KERN_INFO "%s: detaching...\n", ncr_name(np)); + printf("%s: detaching...\n", ncr_name(np)); #ifndef NCR_IOMAPPED if (np->vaddr) { #ifdef DEBUG_NCR53C8XX - printk(KERN_DEBUG "%s: releasing memory mapped IO region %lx[%d]\n", ncr_name(np), (u_long) np->vaddr, 128); + printf("%s: releasing memory mapped IO region %lx[%d]\n", ncr_name(np), (u_long) np->vaddr, 128); #endif unmap_pci_mem((vm_offset_t) np->vaddr, (u_long) 128); } -#endif /* !NCR_IOMAPPED */ + if (np->vaddr2) { +#ifdef DEBUG_NCR53C8XX + printf("%s: releasing memory mapped IO region %lx[%d]\n", ncr_name(np), (u_long) np->vaddr2, 4096); +#endif + unmap_pci_mem((vm_offset_t) np->vaddr2, (u_long) 4096); + } +#endif if (np->port) { #ifdef DEBUG_NCR53C8XX - printk(KERN_DEBUG "%s: releasing IO region %x[%d]\n", ncr_name(np), np->port, 128); + printf("%s: releasing IO region %x[%d]\n", ncr_name(np), np->port, 128); #endif release_region(np->port, 128); } if (np->irq) { #ifdef DEBUG_NCR53C8XX -#ifdef __sparc__ - printk(KERN_INFO "%s: freeing irq %s\n", ncr_name(np), - __irq_itoa(np->irq)); -#else - printk(KERN_INFO "%s: freeing irq %d\n", ncr_name(np), np->irq); -#endif + printf("%s: freeing irq %d\n", ncr_name(np), np->irq); #endif +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,70) free_irq(np->irq, np); +#else + free_irq(np->irq); +#endif } scsi_unregister(instance); return -1; } - -/*========================================================== -** -** -** Done SCSI commands list management. -** -** We donnot enter the scsi_done() callback immediately -** after a command has been seen as completed but we -** insert it into a list which is flushed outside any kind -** of driver critical section. -** This allows to do minimal stuff under interrupt and -** inside critical sections and to also avoid locking up -** on recursive calls to driver entry points under SMP. -** In fact, the only kernel point which is entered by the -** driver with a driver lock set is kmalloc(GFP_ATOMIC) -** that shall not reenter the driver under any circumstances, -** AFAIK. -** -**========================================================== -*/ -static inline void ncr_queue_done_cmd(ncb_p np, Scsi_Cmnd *cmd) -{ - cmd->host_scribble = (char *) np->done_list; - np->done_list = cmd; -} - -static inline void ncr_flush_done_cmds(Scsi_Cmnd *lcmd) -{ - Scsi_Cmnd *cmd; - - while (lcmd) { - cmd = lcmd; - lcmd = (Scsi_Cmnd *) cmd->host_scribble; - cmd->scsi_done(cmd); - } -} - - /*========================================================== ** ** @@ -4836,18 +4714,27 @@ static inline void ncr_flush_done_cmds(Scsi_Cmnd *lcmd) ** **========================================================== */ -int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) +int ncr_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *)) { + struct Scsi_Host *host = cmd->host; /* Scsi_Device *device = cmd->device; */ + struct host_data *host_data = (struct host_data *) host->hostdata; + ncb_p np = host_data->ncb; tcb_p tp = &np->target[cmd->target]; - lcb_p lp = tp->lp[cmd->lun]; + ccb_p cp; + lcb_p lp; int segments; - u_char nego, idmsg, *msgptr; - u_int msglen; - int direction; - u_int32 lastp, goalp; + u_char qidx, nego, idmsg, *msgptr; + u_int msglen, msglen2; + u_long flags; + int xfer_direction; + + cmd->scsi_done = done; + cmd->host_scribble = NULL; + cmd->SCp.ptr = NULL; + cmd->SCp.buffer = NULL; /*--------------------------------------------- ** @@ -4877,7 +4764,7 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) if (DEBUG_FLAGS & DEBUG_TINY) { PRINT_ADDR(cmd); - printk ("CMD=%x ", cmd->cmnd[0]); + printf ("CMD=%x ", cmd->cmnd[0]); } /*--------------------------------------------------- @@ -4890,6 +4777,8 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) ** **---------------------------------------------------- */ + save_flags(flags); cli(); + if (np->settle_time && cmd->timeout_per_command >= HZ && np->settle_time > jiffies + cmd->timeout_per_command - HZ) { np->settle_time = jiffies + cmd->timeout_per_command - HZ; @@ -4897,6 +4786,7 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) if (np->settle_time || !(cp=ncr_get_ccb (np, cmd->target, cmd->lun))) { insert_into_waiting_list(np, cmd); + restore_flags(flags); return(DID_OK); } cp->cmd = cmd; @@ -4907,12 +4797,10 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) ** **---------------------------------------------------- */ -#if 0 /* This stuff was only usefull for linux-1.2.13 */ - if (lp && !lp->numtags && cmd->device && cmd->device->tagged_queue) { - lp->numtags = tp->usrtags; - ncr_setup_tags (np, cmd->target, cmd->lun); + if (!tp->usrtags && cmd->device && cmd->device->tagged_queue) { + tp->usrtags = SCSI_NCR_MAX_TAGS; + ncr_setmaxtags (np, tp, SCSI_NCR_MAX_TAGS); } -#endif /*--------------------------------------------------- ** @@ -4925,23 +4813,47 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) cp->phys.header.stamp.start = jiffies; #endif + /*---------------------------------------------------- + ** + ** Get device quirks from a speciality table. + ** + ** @GENSCSI@ + ** This should be a part of the device table + ** in "scsi_conf.c". + ** + **---------------------------------------------------- + */ + if (tp->quirks & QUIRK_UPDATE) { + tp->quirks = ncr_lookup ((char*) &tp->inqdata[0]); +#ifndef NCR_GETCC_WITHMSG + if (tp->quirks) { + PRINT_ADDR(cmd); + printf ("quirks=%x.\n", tp->quirks); + } +#endif + } + /*--------------------------------------------------- ** ** negotiation required? ** - **--------------------------------------------------- + ** Only SCSI-II devices. + ** To negotiate with SCSI-I devices is dangerous, since + ** Synchronous Negotiation protocol is optional, and + ** INQUIRY data do not contains capabilities in byte 7. + **---------------------------------------------------- */ nego = 0; - if ((!tp->widedone || !tp->period) && !tp->nego_cp && tp->inq_done && lp) { - + if (cmd->lun == 0 && !tp->nego_cp && + (tp->inqdata[2] & 0x7) >= 2 && tp->inqdata[7]) { /* ** negotiate wide transfers ? */ if (!tp->widedone) { - if (tp->inq_byte7 & INQ7_WIDE16) { + if (tp->inqdata[7] & INQ7_WIDE16) { nego = NS_WIDE; } else tp->widedone=1; @@ -4952,13 +4864,17 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) */ if (!nego && !tp->period) { - if (tp->inq_byte7 & INQ7_SYNC) { + if ( 1 +#if defined (CDROM_ASYNC) + && ((tp->inqdata[0] & 0x1f) != 5) +#endif + && (tp->inqdata[7] & INQ7_SYNC)) { nego = NS_SYNC; } else { tp->period =0xffff; tp->sval = 0xe0; - PRINT_TARGET(np, cmd->target); - printk ("SYNC transfers not supported.\n"); + PRINT_ADDR(cmd); + printf ("asynchronous.\n"); }; }; @@ -4972,6 +4888,33 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) tp->nego_cp = cp; }; + /*--------------------------------------------------- + ** + ** choose a new tag ... + ** + **---------------------------------------------------- + */ + + if ((lp = tp->lp[cmd->lun]) && (lp->usetags)) { + /* + ** assign a tag to this ccb! + */ + while (!cp->tag) { + ccb_p cp2 = lp->next_ccb; + lp->lasttag = lp->lasttag % 255 + 1; + while (cp2 && cp2->tag != lp->lasttag) + cp2 = cp2->next_ccb; + if (cp2) continue; + cp->tag=lp->lasttag; + if (DEBUG_FLAGS & DEBUG_TAGS) { + PRINT_ADDR(cmd); + printf ("using tag #%d.\n", cp->tag); + } + } + } else { + cp->tag=0; + } + /*---------------------------------------------------- ** ** Build the identify / tag / sdtr message @@ -4981,54 +4924,44 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) idmsg = M_IDENTIFY | cmd->lun; - if (cp ->tag != NO_TAG || - (cp != np->ccb && np->disc && !(tp->usrflag & UF_NODISC))) + if (cp != np->ccb && ((np->disc && !(tp->usrflag & UF_NODISC)) || cp->tag)) idmsg |= 0x40; msgptr = cp->scsi_smsg; msglen = 0; msgptr[msglen++] = idmsg; - if (cp->tag != NO_TAG) { - char order = np->order; + if (cp->tag) { + char tag; + tag = np->order; + if (tag == 0) { /* - ** Force ordered tag if necessary to avoid timeouts - ** and to preserve interactivity. + ** Ordered write ops, unordered read ops. */ - if (lp && lp->tags_stime + (3*HZ) <= jiffies) { - if (lp->tags_smap) { - order = M_ORDERED_TAG; - if ((DEBUG_FLAGS & DEBUG_TAGS)||bootverbose>2){ - PRINT_ADDR(cmd); - printk("ordered tag forced.\n"); - } - } - lp->tags_stime = jiffies; - lp->tags_smap = lp->tags_umap; + switch (cmd->cmnd[0]) { + case 0x08: /* READ_SMALL (6) */ + case 0x28: /* READ_BIG (10) */ + case 0xa8: /* READ_HUGE (12) */ + tag = M_SIMPLE_TAG; + break; + default: + tag = M_ORDERED_TAG; } - - if (order == 0) { - /* - ** Ordered write ops, unordered read ops. - */ - switch (cmd->cmnd[0]) { - case 0x08: /* READ_SMALL (6) */ - case 0x28: /* READ_BIG (10) */ - case 0xa8: /* READ_HUGE (12) */ - order = M_SIMPLE_TAG; - break; - default: - order = M_ORDERED_TAG; - } + } + /* + ** Have to force ordered tag to avoid timeouts + */ + if ((lp = tp->lp[cmd->lun]) && (lp->force_ordered_tag)) { + tag = M_ORDERED_TAG; + lp->force_ordered_tag = 0; + if (DEBUG_FLAGS & DEBUG_TAGS) { + PRINT_ADDR(cmd); + printf ("Ordered Queue Tag forced\n"); } - msgptr[msglen++] = order; - /* - ** Actual tags are numbered 1,3,5,..2*MAXTAGS+1, - ** since we may have to deal with devices that have - ** problems with #TAG 0 or too great #TAG numbers. - */ - msgptr[msglen++] = (cp->tag << 1) + 1; + } + msgptr[msglen++] = tag; + msgptr[msglen++] = cp -> tag; } switch (nego) { @@ -5040,9 +4973,9 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) msgptr[msglen++] = tp->maxoffs; if (DEBUG_FLAGS & DEBUG_NEGO) { PRINT_ADDR(cp->cmd); - printk ("sync msgout: "); + printf ("sync msgout: "); ncr_show_msg (&cp->scsi_smsg [msglen-5]); - printk (".\n"); + printf (".\n"); }; break; case NS_WIDE: @@ -5052,13 +4985,23 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) msgptr[msglen++] = tp->usrwide; if (DEBUG_FLAGS & DEBUG_NEGO) { PRINT_ADDR(cp->cmd); - printk ("wide msgout: "); + printf ("wide msgout: "); ncr_show_msg (&cp->scsi_smsg [msglen-4]); - printk (".\n"); + printf (".\n"); }; break; }; + /*---------------------------------------------------- + ** + ** Build the identify message for getcc. + ** + **---------------------------------------------------- + */ + + cp -> scsi_smsg2 [0] = idmsg; + msglen2 = 1; + /*---------------------------------------------------- ** ** Build the data descriptors @@ -5069,7 +5012,8 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) segments = ncr_scatter (cp, cp->cmd); if (segments < 0) { - ncr_free_ccb(np, cp); + ncr_free_ccb(np, cp, cmd->target, cmd->lun); + restore_flags(flags); return(DID_ERROR); } @@ -5080,24 +5024,20 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) ** **---------------------------------------------------- */ - if (!cp->data_len) - direction = 0; - else { - switch((int) cmd->cmnd[0]) { - case 0x08: /* READ(6) 08 */ - case 0x28: /* READ(10) 28 */ - case 0xA8: /* READ(12) A8 */ - direction = XFER_IN; - break; - case 0x0A: /* WRITE(6) 0A */ - case 0x2A: /* WRITE(10) 2A */ - case 0xAA: /* WRITE(12) AA */ - direction = XFER_OUT; - break; - default: - direction = (XFER_IN|XFER_OUT); - break; - } + switch((int) cmd->cmnd[0]) { + case 0x08: /* READ(6) 08 */ + case 0x28: /* READ(10) 28 */ + case 0xA8: /* READ(12) A8 */ + xfer_direction = XferIn; + break; + case 0x0A: /* WRITE(6) 0A */ + case 0x2A: /* WRITE(10) 2A */ + case 0xAA: /* WRITE(12) AA */ + xfer_direction = XferOut; + break; + default: + xfer_direction = guess_xfer_direction((int) cmd->cmnd[0]); + break; } /*---------------------------------------------------- @@ -5107,64 +5047,36 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) **---------------------------------------------------- */ - /* - ** Default to no data transfer. - */ - lastp = goalp = NCB_SCRIPT_PHYS (np, no_data); - - /* - ** Compute data out pointers, if needed. - */ - if (direction & XFER_OUT) { - goalp = NCB_SCRIPT_PHYS (np, data_out2) + 8; - if (segments <= MAX_SCATTERL) - lastp = goalp - 8 - (segments * 16); - else { - lastp = NCB_SCRIPTH_PHYS (np, hdata_out2); - lastp -= (segments - MAX_SCATTERL) * 16; - } - /* - ** If actual data direction is unknown, save pointers - ** in header. The SCRIPTS will swap them to current - ** if target decision will be data out. - */ - if (direction & XFER_IN) { - cp->phys.header.wgoalp = cpu_to_scr(goalp); - cp->phys.header.wlastp = cpu_to_scr(lastp); - } - } + cp->segments = segments; + if (!cp->data_len) + xfer_direction = XferNone; - /* - ** Compute data in pointers, if needed. - */ - if (direction & XFER_IN) { - goalp = NCB_SCRIPT_PHYS (np, data_in2) + 8; - if (segments <= MAX_SCATTERL) - lastp = goalp - 8 - (segments * 16); - else { - lastp = NCB_SCRIPTH_PHYS (np, hdata_in2); - lastp -= (segments - MAX_SCATTERL) * 16; - } + switch (xfer_direction) { + u_long endp; + default: + case XferBoth: + cp->phys.header.savep = + cpu_to_scr(NCB_SCRIPT_PHYS (np, data_io)); + cp->phys.header.goalp = cp->phys.header.savep; + break; + case XferIn: + endp = NCB_SCRIPT_PHYS (np, data_in) + MAX_SCATTER*16; + cp->phys.header.goalp = cpu_to_scr(endp + 8); + cp->phys.header.savep = cpu_to_scr(endp - segments*16); + break; + case XferOut: + endp = NCB_SCRIPTH_PHYS (np, data_out) + MAX_SCATTER*16; + cp->phys.header.goalp = cpu_to_scr(endp + 8); + cp->phys.header.savep = cpu_to_scr(endp - segments*16); + break; + case XferNone: + cp->phys.header.savep = + cpu_to_scr(NCB_SCRIPT_PHYS (np, no_data)); + cp->phys.header.goalp = cp->phys.header.savep; + break; } - /* - ** Set all pointers values needed by SCRIPTS. - ** If direction is unknown, start at data_io. - */ - cp->phys.header.lastp = cpu_to_scr(lastp); - cp->phys.header.goalp = cpu_to_scr(goalp); - - if ((direction & (XFER_IN|XFER_OUT)) == (XFER_IN|XFER_OUT)) - cp->phys.header.savep = - cpu_to_scr(NCB_SCRIPTH_PHYS (np, data_io)); - else - cp->phys.header.savep= cpu_to_scr(lastp); - - /* - ** Save the initial data pointer in order to be able - ** to redo the command. - */ - cp->startp = cp->phys.header.savep; + cp->phys.header.lastp = cp->phys.header.savep; /*---------------------------------------------------- ** @@ -5176,12 +5088,13 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) ** physical -> virtual backlink ** Generic SCSI command */ - + cp->phys.header.cp = cp; /* ** Startqueue */ - cp->start.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); - cp->restart.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_dsa)); + cp->phys.header.launch.l_paddr = + cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); + cp->phys.header.launch.l_cmd = cpu_to_scr(SCR_JUMP); /* ** select */ @@ -5194,124 +5107,100 @@ int ncr_queue_command (ncb_p np, Scsi_Cmnd *cmd) cp->phys.smsg.addr = cpu_to_scr(CCB_PHYS (cp, scsi_smsg)); cp->phys.smsg.size = cpu_to_scr(msglen); + cp->phys.smsg2.addr = cpu_to_scr(CCB_PHYS (cp, scsi_smsg2)); + cp->phys.smsg2.size = cpu_to_scr(msglen2); /* ** command */ cp->phys.cmd.addr = cpu_to_scr(vtophys (&cmd->cmnd[0])); cp->phys.cmd.size = cpu_to_scr(cmd->cmd_len); - /* - ** status - */ - cp->actualquirks = tp->quirks; - cp->host_status = nego ? HS_NEGOTIATE : HS_BUSY; - cp->scsi_status = S_ILLEGAL; - cp->parity_status = 0; - - cp->xerr_status = XE_OK; - cp->nego_status = nego; -#if 0 - cp->sync_status = tp->sval; - cp->wide_status = tp->wval; -#endif - - /*---------------------------------------------------- - ** - ** Critical region: start this job. - ** - **---------------------------------------------------- + ** sense command */ - + cp->phys.scmd.addr = cpu_to_scr(CCB_PHYS (cp, sensecmd)); + cp->phys.scmd.size = cpu_to_scr(6); /* - ** activate this job. + ** patch requested size into sense command */ - - /* Compute a time limit greater than the middle-level driver one */ - if (cmd->timeout_per_command > 0) - cp->tlimit = jiffies + cmd->timeout_per_command + HZ; - else - cp->tlimit = jiffies + 86400 * HZ;/* No timeout=24 hours */ - cp->magic = CCB_MAGIC; - + cp->sensecmd[0] = 0x03; + cp->sensecmd[1] = cmd->lun << 5; + cp->sensecmd[4] = sizeof(cmd->sense_buffer); /* - ** insert next CCBs into start queue. - ** 2 max at a time is enough to flush the CCB wait queue. + ** sense data */ - cp->auto_sense = 0; - if (lp) - ncr_start_next_ccb(np, lp, 2); - else - ncr_put_start_queue(np, cp); - + cp->phys.sense.addr = + cpu_to_scr(vtophys (&cmd->sense_buffer[0])); + cp->phys.sense.size = cpu_to_scr(sizeof(cmd->sense_buffer)); /* - ** Command is successfully queued. + ** status */ + cp->actualquirks = tp->quirks; + cp->host_status = nego ? HS_NEGOTIATE : HS_BUSY; + cp->scsi_status = S_ILLEGAL; + cp->parity_status = 0; - return(DID_OK); -} - - -/*========================================================== -** -** -** Insert a CCB into the start queue and wake up the -** SCRIPTS processor. -** -** -**========================================================== -*/ - -static void ncr_start_next_ccb(ncb_p np, lcb_p lp, int maxn) -{ - XPT_QUEHEAD *qp; - ccb_p cp; + cp->xerr_status = XE_OK; + cp->sync_status = tp->sval; + cp->nego_status = nego; + cp->wide_status = tp->wval; - if (lp->held_ccb) - return; + /*---------------------------------------------------- + ** + ** Critical region: start this job. + ** + **---------------------------------------------------- + */ - while (maxn-- && lp->queuedccbs < lp->queuedepth) { - qp = xpt_remque_head(&lp->wait_ccbq); - if (!qp) - break; - ++lp->queuedccbs; - cp = xpt_que_entry(qp, struct ccb, link_ccbq); - xpt_insque_tail(qp, &lp->busy_ccbq); - lp->jump_ccb[cp->tag == NO_TAG ? 0 : cp->tag] = - cpu_to_scr(CCB_PHYS (cp, restart)); - ncr_put_start_queue(np, cp); - } -} + /* + ** reselect pattern and activate this job. + */ -static void ncr_put_start_queue(ncb_p np, ccb_p cp) -{ - u_short qidx; + cp->jump_ccb.l_cmd = + cpu_to_scr((SCR_JUMP ^ IFFALSE (DATA (cp->tag)))); + + /* Compute a time limit greater than the middle-level driver one */ + if (cmd->timeout_per_command > 0) + cp->tlimit = jiffies + cmd->timeout_per_command + NCR_TIMEOUT_INCREASE; + else + cp->tlimit = jiffies + 3600 * HZ; /* No timeout=one hour */ + cp->magic = CCB_MAGIC; /* ** insert into start queue. */ - if (!np->squeueput) np->squeueput = 1; - qidx = np->squeueput + 2; - if (qidx >= MAX_START + MAX_START) qidx = 1; - - np->scripth->tryloop [qidx] = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); - MEMORY_BARRIER(); - np->scripth->tryloop [np->squeueput] = cpu_to_scr(CCB_PHYS (cp, start)); + qidx = np->squeueput + 1; + if (qidx >= MAX_START) qidx=0; + np->squeue [qidx ] = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); + np->squeue [np->squeueput] = cpu_to_scr(CCB_PHYS (cp, phys)); np->squeueput = qidx; - ++np->queuedccbs; - cp->queued = 1; - if (DEBUG_FLAGS & DEBUG_QUEUE) - printk ("%s: queuepos=%d.\n", ncr_name (np), np->squeueput); + if(DEBUG_FLAGS & DEBUG_QUEUE) + printf ("%s: queuepos=%d tryoffset=%d.\n", ncr_name (np), + np->squeueput, + (unsigned)(scr_to_cpu(np->script->startpos[0]) - + (NCB_SCRIPTH_PHYS (np, tryloop)))); /* ** Script processor may be waiting for reselect. ** Wake it up. */ - MEMORY_BARRIER(); +#ifdef SCSI_NCR_DEBUG_ERROR_RECOVERY_SUPPORT + if (!np->stalling) +#endif OUTB (nc_istat, SIGP); -} + /* + ** and reenable interrupts + */ + restore_flags(flags); + + /* + ** Command is successfully queued. + */ + + return(DID_OK); +} /*========================================================== ** @@ -5325,13 +5214,18 @@ static void ncr_put_start_queue(ncb_p np, ccb_p cp) ** **========================================================== */ -static void ncr_start_reset(ncb_p np) +static void ncr_start_reset(ncb_p np, int settle_delay) { + u_long flags; + + save_flags(flags); cli(); + if (!np->settle_time) { - (void) ncr_reset_scsi_bus(np, 1, driver_setup.settle_delay); - } - } - + (void) ncr_reset_scsi_bus(np, 1, settle_delay); + } + restore_flags(flags); +} + static int ncr_reset_scsi_bus(ncb_p np, int enab_int, int settle_delay) { u_int32 term; @@ -5340,14 +5234,13 @@ static int ncr_reset_scsi_bus(ncb_p np, int enab_int, int settle_delay) np->settle_time = jiffies + settle_delay * HZ; if (bootverbose > 1) - printk("%s: resetting, " + printf("%s: resetting, " "command processing suspended for %d seconds\n", ncr_name(np), settle_delay); OUTB (nc_istat, SRST); - UDELAY (100); + DELAY (1000); OUTB (nc_istat, 0); - UDELAY (2000); /* The 895 needs time for the bus mode to settle */ if (enab_int) OUTW (nc_sien, RST); /* @@ -5357,7 +5250,7 @@ static int ncr_reset_scsi_bus(ncb_p np, int enab_int, int settle_delay) OUTB (nc_stest3, TE); OUTB (nc_dcntl, (np->rv_dcntl & IRQM)); OUTB (nc_scntl1, CRST); - UDELAY (200); + DELAY (100); if (!driver_setup.bus_check) goto out; @@ -5377,9 +5270,9 @@ static int ncr_reset_scsi_bus(ncb_p np, int enab_int, int settle_delay) term &= 0x3ffff; if (term != (2<<7)) { - printk("%s: suspicious SCSI data while resetting the BUS.\n", + printf("%s: suspicious SCSI data while resetting the BUS.\n", ncr_name(np)); - printk("%s: %sdp0,d7-0,rst,req,ack,bsy,sel,atn,msg,c/d,i/o = " + printf("%s: %sdp0,d7-0,rst,req,ack,bsy,sel,atn,msg,c/d,i/o = " "0x%lx, expecting 0x%lx\n", ncr_name(np), (np->features & FE_WIDE) ? "dp1,d15-8," : "", @@ -5401,16 +5294,27 @@ out: ** **========================================================== */ -int ncr_reset_bus (ncb_p np, Scsi_Cmnd *cmd, int sync_reset) +int ncr_reset_bus (Scsi_Cmnd *cmd, int sync_reset) { + struct Scsi_Host *host = cmd->host; /* Scsi_Device *device = cmd->device; */ + struct host_data *host_data = (struct host_data *) host->hostdata; + ncb_p np = host_data->ncb; ccb_p cp; + u_long flags; int found; +#ifdef SCSI_NCR_DEBUG_ERROR_RECOVERY_SUPPORT + if (np->stalling) + np->stalling = 0; +#endif + + save_flags(flags); cli(); /* * Return immediately if reset is in progress. */ if (np->settle_time) { + restore_flags(flags); return SCSI_RESET_PUNT; } /* @@ -5419,7 +5323,7 @@ int ncr_reset_bus (ncb_p np, Scsi_Cmnd *cmd, int sync_reset) * Commands will now be queued in the waiting list until a settle * delay of 2 seconds will be completed. */ - ncr_start_reset(np); + ncr_start_reset(np, driver_setup.settle_delay); /* * First, look in the wakeup list */ @@ -5454,9 +5358,11 @@ int ncr_reset_bus (ncb_p np, Scsi_Cmnd *cmd, int sync_reset) */ if (!found && sync_reset && !retrieve_from_waiting_list(0, np, cmd)) { cmd->result = ScsiResult(DID_RESET, 0); - ncr_queue_done_cmd(np, cmd); + cmd->scsi_done(cmd); } + restore_flags(flags); + return SCSI_RESET_SUCCESS; } @@ -5469,19 +5375,30 @@ int ncr_reset_bus (ncb_p np, Scsi_Cmnd *cmd, int sync_reset) ** **========================================================== */ -static int ncr_abort_command (ncb_p np, Scsi_Cmnd *cmd) +static int ncr_abort_command (Scsi_Cmnd *cmd) { + struct Scsi_Host *host = cmd->host; /* Scsi_Device *device = cmd->device; */ + struct host_data *host_data = (struct host_data *) host->hostdata; + ncb_p np = host_data->ncb; ccb_p cp; + u_long flags; int found; int retv; +#ifdef SCSI_NCR_DEBUG_ERROR_RECOVERY_SUPPORT + if (np->stalling == 2) + np->stalling = 0; +#endif + + save_flags(flags); cli(); /* * First, look for the scsi command in the waiting list */ if (remove_from_waiting_list(np, cmd)) { cmd->result = ScsiResult(DID_ABORT, 0); - ncr_queue_done_cmd(np, cmd); + cmd->scsi_done(cmd); + restore_flags(flags); return SCSI_ABORT_SUCCESS; } @@ -5500,45 +5417,45 @@ static int ncr_abort_command (ncb_p np, Scsi_Cmnd *cmd) } if (!found) { + restore_flags(flags); return SCSI_ABORT_NOT_RUNNING; } if (np->settle_time) { + restore_flags(flags); return SCSI_ABORT_SNOOZE; } /* - ** If the CCB is active, patch schedule jumps for the - ** script to abort the command. + ** Disable reselect. + ** Remove it from startqueue. + ** Set cp->tlimit to 0. The ncr_timeout() handler will use + ** this condition in order to complete the canceled command + ** after the script skipped the ccb, if necessary. */ + cp->jump_ccb.l_cmd = cpu_to_scr(SCR_JUMP); + if (cp->phys.header.launch.l_paddr == + cpu_to_scr(NCB_SCRIPT_PHYS (np, select))) { + printf ("%s: abort ccb=%p (skip)\n", ncr_name (np), cp); + cp->phys.header.launch.l_paddr = + cpu_to_scr(NCB_SCRIPT_PHYS (np, skip)); + } cp->tlimit = 0; - switch(cp->host_status) { - case HS_BUSY: - case HS_NEGOTIATE: - printk ("%s: abort ccb=%p (cancel)\n", ncr_name (np), cp); - cp->start.schedule.l_paddr = - cpu_to_scr(NCB_SCRIPTH_PHYS (np, cancel)); - retv = SCSI_ABORT_PENDING; - break; - case HS_DISCONNECT: - cp->restart.schedule.l_paddr = - cpu_to_scr(NCB_SCRIPTH_PHYS (np, abort)); - retv = SCSI_ABORT_PENDING; - break; - default: - retv = SCSI_ABORT_NOT_RUNNING; - break; - - } + retv = SCSI_ABORT_PENDING; /* ** If there are no requests, the script ** processor will sleep on SEL_WAIT_RESEL. ** Let's wake it up, since it may have to work. */ +#ifdef SCSI_NCR_DEBUG_ERROR_RECOVERY_SUPPORT + if (!np->stalling) +#endif OUTB (nc_istat, SIGP); + restore_flags(flags); + return retv; } @@ -5562,7 +5479,7 @@ static int ncr_detach(ncb_p np) int target, lun; int i; - printk("%s: releasing host resources\n", ncr_name(np)); + printf("%s: releasing host resources\n", ncr_name(np)); /* ** Stop the ncr_timeout process @@ -5570,12 +5487,12 @@ static int ncr_detach(ncb_p np) */ #ifdef DEBUG_NCR53C8XX - printk("%s: stopping the timer\n", ncr_name(np)); + printf("%s: stopping the timer\n", ncr_name(np)); #endif np->release_stage = 1; - for (i = 50 ; i && np->release_stage != 2 ; i--) MDELAY (100); + for (i = 50 ; i && np->release_stage != 2 ; i--) DELAY(100000); if (np->release_stage != 2) - printk("%s: the timer seems to be already stopped\n", ncr_name(np)); + printf("%s: the timer seems to be already stopped\n", ncr_name(np)); else np->release_stage = 2; /* @@ -5583,7 +5500,7 @@ static int ncr_detach(ncb_p np) */ #ifdef DEBUG_NCR53C8XX - printk("%s: disabling chip interrupts\n", ncr_name(np)); + printf("%s: disabling chip interrupts\n", ncr_name(np)); #endif OUTW (nc_sien , 0); OUTB (nc_dien , 0); @@ -5593,22 +5510,22 @@ static int ncr_detach(ncb_p np) */ #ifdef DEBUG_NCR53C8XX -#ifdef __sparc__ - printk("%s: freeing irq %s\n", ncr_name(np), __irq_itoa(np->irq)); -#else - printk("%s: freeing irq %d\n", ncr_name(np), np->irq); -#endif + printf("%s: freeing irq %d\n", ncr_name(np), np->irq); #endif +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,70) free_irq(np->irq, np); +#else + free_irq(np->irq); +#endif /* ** Reset NCR chip ** Restore bios setting for automatic clock detection. */ - printk("%s: resetting chip\n", ncr_name(np)); + printf("%s: resetting chip\n", ncr_name(np)); OUTB (nc_istat, SRST); - UDELAY (100); + DELAY (1000); OUTB (nc_istat, 0 ); OUTB(nc_dmode, np->sv_dmode); @@ -5627,13 +5544,17 @@ static int ncr_detach(ncb_p np) #ifndef NCR_IOMAPPED #ifdef DEBUG_NCR53C8XX - printk("%s: releasing memory mapped IO region %lx[%d]\n", ncr_name(np), (u_long) np->vaddr, 128); + printf("%s: releasing memory mapped IO region %lx[%d]\n", ncr_name(np), (u_long) np->vaddr, 128); #endif unmap_pci_mem((vm_offset_t) np->vaddr, (u_long) 128); -#endif /* !NCR_IOMAPPED */ +#ifdef DEBUG_NCR53C8XX + printf("%s: releasing memory mapped IO region %lx[%d]\n", ncr_name(np), (u_long) np->vaddr2, 4096); +#endif + unmap_pci_mem((vm_offset_t) np->vaddr2, (u_long) 4096); +#endif #ifdef DEBUG_NCR53C8XX - printk("%s: releasing IO region %x[%d]\n", ncr_name(np), np->port, 128); + printf("%s: releasing IO region %x[%d]\n", ncr_name(np), np->port, 128); #endif release_region(np->port, 128); @@ -5644,11 +5565,11 @@ static int ncr_detach(ncb_p np) while ((cp=np->ccb->link_ccb) != NULL) { np->ccb->link_ccb = cp->link_ccb; if (cp->host_status) { - printk("%s: shall free an active ccb (host_status=%d)\n", + printf("%s: shall free an active ccb (host_status=%d)\n", ncr_name(np), cp->host_status); } #ifdef DEBUG_NCR53C8XX - printk("%s: freeing ccb (%lx)\n", ncr_name(np), (u_long) cp); + printf("%s: freeing ccb (%lx)\n", ncr_name(np), (u_long) cp); #endif m_free(cp, sizeof(*cp)); } @@ -5663,16 +5584,14 @@ static int ncr_detach(ncb_p np) lp = tp->lp[lun]; if (lp) { #ifdef DEBUG_NCR53C8XX - printk("%s: freeing lp (%lx)\n", ncr_name(np), (u_long) lp); + printf("%s: freeing lp (%lx)\n", ncr_name(np), (u_long) lp); #endif - if (lp->jump_ccb != &lp->jump_ccb_0) - m_free(lp->jump_ccb, 256); m_free(lp, sizeof(*lp)); } } } - printk("%s: host resources successfully released\n", ncr_name(np)); + printf("%s: host resources successfully released\n", ncr_name(np)); return 1; } @@ -5698,8 +5617,20 @@ void ncr_complete (ncb_p np, ccb_p cp) ** Sanity check */ - if (!cp || cp->magic != CCB_MAGIC || !cp->cmd) - return; + if (!cp || (cp->magic!=CCB_MAGIC) || !cp->cmd) return; + cp->magic = 1; + cp->tlimit= 0; + cmd = cp->cmd; + + /* + ** No Reselect anymore. + */ + cp->jump_ccb.l_cmd = cpu_to_scr(SCR_JUMP); + + /* + ** No starting. + */ + cp->phys.header.launch.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); /* ** timestamp @@ -5710,13 +5641,9 @@ void ncr_complete (ncb_p np, ccb_p cp) #endif if (DEBUG_FLAGS & DEBUG_TINY) - printk ("CCB=%lx STAT=%x/%x\n", (unsigned long)cp & 0xfff, + printf ("CCB=%lx STAT=%x/%x\n", (unsigned long)cp & 0xfff, cp->host_status,cp->scsi_status); - /* - ** Get command, target and lun pointers. - */ - cmd = cp->cmd; cp->cmd = NULL; tp = &np->target[cmd->target]; @@ -5731,33 +5658,18 @@ void ncr_complete (ncb_p np, ccb_p cp) if (cp == tp->nego_cp) tp->nego_cp = 0; - /* - ** If auto-sense performed, change scsi status. - */ - if (cp->auto_sense) { - cp->scsi_status = cp->auto_sense; - } - - /* - ** If we were recovering from queue full or performing - ** auto-sense, requeue skipped CCBs to the wait queue. - */ - - if (lp && lp->held_ccb) { - if (cp == lp->held_ccb) { - xpt_que_splice(&lp->skip_ccbq, &lp->wait_ccbq); - xpt_que_init(&lp->skip_ccbq); - lp->held_ccb = 0; - } - } - /* ** Check for parity errors. */ - if (cp->parity_status > 1) { + if (cp->parity_status) { PRINT_ADDR(cmd); - printk ("%d parity error(s).\n",cp->parity_status); + printf ("%d parity error(s), fallback.\n", cp->parity_status); + /* + ** fallback to asynch transfer. + */ + tp->usrsync=255; + tp->period = 0; } /* @@ -5768,84 +5680,109 @@ void ncr_complete (ncb_p np, ccb_p cp) PRINT_ADDR(cmd); switch (cp->xerr_status) { case XE_EXTRA_DATA: - printk ("extraneous data discarded.\n"); + printf ("extraneous data discarded.\n"); break; case XE_BAD_PHASE: - printk ("illegal scsi phase (4/5).\n"); + printf ("illegal scsi phase (4/5).\n"); break; default: - printk ("extended error %d.\n", cp->xerr_status); + printf ("extended error %d.\n", cp->xerr_status); break; } if (cp->host_status==HS_COMPLETE) cp->host_status = HS_FAIL; } - /* - ** Print out any error for debugging purpose. - */ - if (DEBUG_FLAGS & (DEBUG_RESULT|DEBUG_TINY)) { - if (cp->host_status!=HS_COMPLETE || cp->scsi_status!=S_GOOD) { - PRINT_ADDR(cmd); - printk ("ERROR: cmd=%x host_status=%x scsi_status=%x\n", - cmd->cmnd[0], cp->host_status, cp->scsi_status); - } - } - /* ** Check the status. */ if ( (cp->host_status == HS_COMPLETE) && (cp->scsi_status == S_GOOD || cp->scsi_status == S_COND_MET)) { - /* + /* ** All went well (GOOD status). ** CONDITION MET status is returned on - ** `Pre-Fetch' or `Search data' success. - */ + ** `Pre-Fetch' or `Search data' success. + */ cmd->result = ScsiResult(DID_OK, cp->scsi_status); /* + ** if (cp->phys.header.lastp != cp->phys.header.goalp)... + ** ** @RESID@ ** Could dig out the correct value for resid, ** but it would be quite complicated. + ** + ** The ah1542.c driver sets it to 0 too ... */ - /* if (cp->phys.header.lastp != cp->phys.header.goalp) */ /* - ** Allocate the lcb if not yet. + ** Try to assign a ccb to this nexus */ - if (!lp) - ncr_alloc_lcb (np, cmd->target, cmd->lun); + ncr_alloc_ccb (np, cmd->target, cmd->lun); /* - ** On standard INQUIRY response (EVPD and CmDt - ** not set), setup logical unit according to - ** announced capabilities (we need the 1rst 7 bytes). + ** On inquire cmd (0x12) save some data. + ** Clear questionnable capacities. */ - if (cmd->cmnd[0] == 0x12 && !(cmd->cmnd[1] & 0x3) && - cmd->cmnd[4] >= 7) { - ncr_setup_lcb (np, cmd->target, cmd->lun, - (char *) cmd->request_buffer); + if (cmd->lun == 0 && cmd->cmnd[0] == 0x12) { + if (np->unit < SCSI_NCR_MAX_HOST) { + if (driver_setup.force_sync_nego) + ((char *) cmd->request_buffer)[7] |= INQ7_SYNC; + else + ((char *) cmd->request_buffer)[7] &= + (target_capabilities[np->unit].and_map[cmd->target]); + } + bcopy ( cmd->request_buffer, + &tp->inqdata, + sizeof (tp->inqdata)); + + /* + ** set number of tags + */ + ncr_setmaxtags (np, tp, driver_setup.default_tags); + /* + ** prepare negotiation of synch and wide. + */ + ncr_negotiate (np, tp); + + /* + ** force quirks update before next command start + */ + tp->quirks |= QUIRK_UPDATE; } + /* + ** Announce changes to the generic driver. + */ + if (lp) { + ncr_settags (tp, lp); + if (lp->reqlink != lp->actlink) + ncr_opennings (np, lp, cmd); + }; + tp->bytes += cp->data_len; tp->transfers ++; /* ** If tags was reduced due to queue full, - ** increase tags if 1000 good status received. + ** increase tags if 100 good status received. */ - if (lp && lp->usetags && lp->numtags < lp->maxtags) { - ++lp->num_good; - if (lp->num_good >= 1000) { - lp->num_good = 0; - ++lp->numtags; - ncr_setup_tags (np, cmd->target, cmd->lun); + if (tp->numtags < tp->maxtags) { + ++tp->num_good; + if (tp->num_good >= 100) { + tp->num_good = 0; + ++tp->numtags; + if (tp->numtags == 1) { + PRINT_ADDR(cmd); + printf("tagged command queueing resumed\n"); + } } } } else if ((cp->host_status == HS_COMPLETE) - && (cp->scsi_status == S_CHECK_COND)) { + && (cp->scsi_status == (S_SENSE|S_GOOD) || + cp->scsi_status == (S_SENSE|S_CHECK_COND))) { + /* ** Check condition code */ @@ -5854,21 +5791,43 @@ void ncr_complete (ncb_p np, ccb_p cp) if (DEBUG_FLAGS & (DEBUG_RESULT|DEBUG_TINY)) { u_char * p = (u_char*) & cmd->sense_buffer; int i; - PRINT_ADDR(cmd); - printk ("sense data:"); - for (i=0; i<14; i++) printk (" %x", *p++); - printk (".\n"); + printf ("\n%s: sense data:", ncr_name (np)); + for (i=0; i<14; i++) printf (" %x", *p++); + printf (".\n"); } } else if ((cp->host_status == HS_COMPLETE) && (cp->scsi_status == S_BUSY || - cp->scsi_status == S_QUEUE_FULL)) { + cp->scsi_status == S_CONFLICT)) { /* ** Target is busy. */ cmd->result = ScsiResult(DID_OK, cp->scsi_status); + } else if ((cp->host_status == HS_COMPLETE) + && (cp->scsi_status == S_QUEUE_FULL)) { + + /* + ** Target is stuffed. + */ + cmd->result = ScsiResult(DID_OK, cp->scsi_status); + + /* + ** Suspend tagged queuing and start good status counter. + ** Announce changes to the generic driver. + */ + if (tp->numtags) { + PRINT_ADDR(cmd); + printf("QUEUE FULL! suspending tagged command queueing\n"); + tp->numtags = 0; + tp->num_good = 0; + if (lp) { + ncr_settags (tp, lp); + if (lp->reqlink != lp->actlink) + ncr_opennings (np, lp, cmd); + }; + } } else if ((cp->host_status == HS_SEL_TIMEOUT) || (cp->host_status == HS_TIMEOUT)) { @@ -5897,7 +5856,7 @@ void ncr_complete (ncb_p np, ccb_p cp) ** Other protocol messes */ PRINT_ADDR(cmd); - printk ("COMMAND FAILED (%x %x) @%p.\n", + printf ("COMMAND FAILED (%x %x) @%p.\n", cp->host_status, cp->scsi_status, cp); cmd->result = ScsiResult(DID_ERROR, cp->scsi_status); @@ -5911,51 +5870,43 @@ void ncr_complete (ncb_p np, ccb_p cp) u_char * p; int i; PRINT_ADDR(cmd); - printk (" CMD:"); + printf (" CMD:"); p = (u_char*) &cmd->cmnd[0]; - for (i=0; icmd_len; i++) printk (" %x", *p++); + for (i=0; icmd_len; i++) printf (" %x", *p++); if (cp->host_status==HS_COMPLETE) { switch (cp->scsi_status) { case S_GOOD: - printk (" GOOD"); + printf (" GOOD"); break; case S_CHECK_COND: - printk (" SENSE:"); + printf (" SENSE:"); p = (u_char*) &cmd->sense_buffer; for (i=0; i<14; i++) - printk (" %x", *p++); + printf (" %x", *p++); break; default: - printk (" STAT: %x\n", cp->scsi_status); + printf (" STAT: %x\n", cp->scsi_status); break; } - } else printk (" HOSTERROR: %x", cp->host_status); - printk ("\n"); + } else printf (" HOSTERROR: %x", cp->host_status); + printf ("\n"); } /* ** Free this ccb */ - ncr_free_ccb (np, cp); - - /* - ** requeue awaiting scsi commands for this lun. - */ - if (lp && lp->queuedccbs < lp->queuedepth && - !xpt_que_empty(&lp->wait_ccbq)) - ncr_start_next_ccb(np, lp, 2); + ncr_free_ccb (np, cp, cmd->target, cmd->lun); /* - ** requeue awaiting scsi commands for this controller. + ** requeue awaiting scsi commands */ - if (np->waiting_list) - requeue_waiting_list(np); + if (np->waiting_list) requeue_waiting_list(np); /* ** signal completion to generic driver. */ - ncr_queue_done_cmd(np, cmd); + cmd->scsi_done (cmd); } /*========================================================== @@ -5967,92 +5918,41 @@ void ncr_complete (ncb_p np, ccb_p cp) **========================================================== */ -/* -** This CCB has been skipped by the NCR. -** Queue it in the correponding unit queue. -*/ -void ncr_ccb_skipped(ncb_p np, ccb_p cp) -{ - tcb_p tp = &np->target[cp->target]; - lcb_p lp = tp->lp[cp->lun]; - - if (lp && cp != np->ccb) { - cp->host_status &= ~HS_SKIPMASK; - cp->start.schedule.l_paddr = - cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); - xpt_remque(&cp->link_ccbq); - xpt_insque_tail(&cp->link_ccbq, &lp->skip_ccbq); - if (cp->queued) { - --lp->queuedccbs; - } - } - if (cp->queued) { - --np->queuedccbs; - cp->queued = 0; - } -} - -/* -** The NCR has completed CCBs. -** Look at the DONE QUEUE if enabled, otherwise scan all CCBs -*/ -void ncr_wakeup_done (ncb_p np) +void ncr_wakeup (ncb_p np, u_long code) { - ccb_p cp; -#ifdef SCSI_NCR_CCB_DONE_SUPPORT - int i, j; + /* + ** Starting at the default ccb and following + ** the links, complete all jobs with a + ** host_status greater than "disconnect". + ** + ** If the "code" parameter is not zero, + ** complete all jobs that are not IDLE. + */ - i = np->ccb_done_ic; - while (1) { - j = i+1; - if (j >= MAX_DONE) - j = 0; + ccb_p cp = np->ccb; + while (cp) { + switch (cp->host_status) { - cp = np->ccb_done[j]; - if (!CCB_DONE_VALID(cp)) + case HS_IDLE: break; - np->ccb_done[j] = (ccb_p) CCB_DONE_EMPTY; - np->scripth->done_queue[5*j + 4] = - cpu_to_scr(NCB_SCRIPT_PHYS (np, done_plug)); - MEMORY_BARRIER(); - np->scripth->done_queue[5*i + 4] = - cpu_to_scr(NCB_SCRIPT_PHYS (np, done_end)); - - if (cp->host_status & HS_DONEMASK) - ncr_complete (np, cp); - else if (cp->host_status & HS_SKIPMASK) - ncr_ccb_skipped (np, cp); + case HS_DISCONNECT: + if(DEBUG_FLAGS & DEBUG_TINY) printf ("D"); + /* fall through */ - i = j; - } - np->ccb_done_ic = i; -#else - cp = np->ccb; - while (cp) { - if (cp->host_status & HS_DONEMASK) - ncr_complete (np, cp); - else if (cp->host_status & HS_SKIPMASK) - ncr_ccb_skipped (np, cp); - cp = cp->link_ccb; - } -#endif -} + case HS_BUSY: + case HS_NEGOTIATE: + if (!code) break; + cp->host_status = code; -/* -** Complete all active CCBs. -*/ -void ncr_wakeup (ncb_p np, u_long code) -{ - ccb_p cp = np->ccb; + /* fall through */ - while (cp) { - if (cp->host_status != HS_IDLE) { - cp->host_status = code; + default: ncr_complete (np, cp); - } - cp = cp->link_ccb; - } + break; + }; + cp = cp -> link_ccb; + }; } /*========================================================== @@ -6066,57 +5966,38 @@ void ncr_wakeup (ncb_p np, u_long code) void ncr_init (ncb_p np, int reset, char * msg, u_long code) { - int i; + int i; - /* + /* ** Reset chip if asked, otherwise just clear fifos. - */ - + */ if (reset) { OUTB (nc_istat, SRST); - UDELAY (100); + DELAY (10000); } else { OUTB (nc_stest3, TE|CSF); OUTONB (nc_ctest3, CLF); } - + /* ** Message. */ - if (msg) printk (KERN_INFO "%s: restart (%s).\n", ncr_name (np), msg); + if (msg) printf (KERN_INFO "%s: restart (%s).\n", ncr_name (np), msg); /* ** Clear Start Queue */ - np->queuedepth = MAX_START - 1; /* 1 entry needed as end marker */ - for (i = 1; i < MAX_START + MAX_START; i += 2) - np->scripth0->tryloop[i] = - cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); + for (i=0;i squeue [i] = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); /* ** Start at first entry. */ np->squeueput = 0; np->script0->startpos[0] = cpu_to_scr(NCB_SCRIPTH_PHYS (np, tryloop)); - - /* - ** Clear Done Queue - */ - for (i = 0; i < MAX_DONE; i++) { - np->ccb_done[i] = (ccb_p) CCB_DONE_EMPTY; - np->scripth0->done_queue[5*i + 4] = - cpu_to_scr(NCB_SCRIPT_PHYS (np, done_end)); - } - - /* - ** Start at first entry. - */ - np->script0->done_pos[0] = cpu_to_scr(NCB_SCRIPTH_PHYS (np,done_queue)); - np->ccb_done_ic = MAX_DONE-1; - np->scripth0->done_queue[5*(MAX_DONE-1) + 4] = - cpu_to_scr(NCB_SCRIPT_PHYS (np, done_plug)); + np->script0->start0 [0] = cpu_to_scr(SCR_INT ^ IFFALSE (0)); /* ** Wakeup all pending jobs. @@ -6128,8 +6009,6 @@ void ncr_init (ncb_p np, int reset, char * msg, u_long code) */ OUTB (nc_istat, 0x00 ); /* Remove Reset, abort */ - UDELAY (2000); /* The 895 needs time for the bus mode to settle */ - OUTB (nc_scntl0, np->rv_scntl0 | 0xc0); /* full arb., ena parity, par->ATN */ OUTB (nc_scntl1, 0x00); /* odd parity, and remove CRST!! */ @@ -6148,7 +6027,7 @@ void ncr_init (ncb_p np, int reset, char * msg, u_long code) OUTB (nc_stest2, EXT|np->rv_stest2); /* Extended Sreq/Sack filtering */ OUTB (nc_stest3, TE); /* TolerANT enable */ - OUTB (nc_stime0, 0x0c ); /* HTH disabled STO 0.25 sec */ + OUTB (nc_stime0, 0x0d ); /* HTH disabled STO 0.4 sec. */ /* ** Disable disconnects. @@ -6164,11 +6043,24 @@ void ncr_init (ncb_p np, int reset, char * msg, u_long code) OUTOFFB (nc_gpcntl, 0x01); } + /* + ** Upload the script into on-board RAM + */ + if (np->vaddr2) { + if (bootverbose) + printf ("%s: copying script fragments into the on-board RAM ...\n", ncr_name(np)); +#if LINUX_VERSION_CODE >= LinuxVersionCode(2,0,0) + memcpy_toio(np->script, np->script0, sizeof(struct script)); +#else + memcpy(np->script, np->script0, sizeof(struct script)); +#endif + } + /* ** enable ints */ - OUTW (nc_sien , STO|HTH|MA|SGE|UDC|RST|PAR); + OUTW (nc_sien , STO|HTH|MA|SGE|UDC|RST); OUTB (nc_dien , MDPE|BF|ABRT|SSI|SIR|IID); /* @@ -6179,18 +6071,6 @@ void ncr_init (ncb_p np, int reset, char * msg, u_long code) np->scsi_mode = INB (nc_stest4) & SMODE; } - /* - ** DEL 441 - 53C876 Rev 5 - Part Number 609-0392787/2788 - ITEM 2. - ** Disable overlapped arbitration. - ** The 896 Rev 1 is also affected by this errata. - */ - if (np->device_id == PCI_DEVICE_ID_NCR_53C875 && - np->revision_id >= 0x10 && np->revision_id <= 0x15) - OUTB (nc_ctest0, (1<<5)); - else if (np->device_id == PCI_DEVICE_ID_NCR_53C896 && - np->revision_id <= 0x1) - OUTB (nc_ccntl0, DPR); - /* ** Fill in target structure. ** Reinitialize usrsync. @@ -6223,16 +6103,8 @@ void ncr_init (ncb_p np, int reset, char * msg, u_long code) /* ** Start script processor. */ - MEMORY_BARRIER(); - if (np->paddr2) { - if (bootverbose) - printk ("%s: Downloading SCSI SCRIPTS.\n", - ncr_name(np)); - OUTL (nc_scratcha, vtophys(np->script0)); - OUTL (nc_dsp, NCB_SCRIPTH_PHYS (np, start_ram)); - } - else - OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, start)); + + OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, start)); } /*========================================================== @@ -6259,6 +6131,14 @@ static void ncr_negotiate (struct ncb* np, struct tcb* tp) if (minsync < 12) minsync = 12; } + /* + ** if not scsi 2 + ** don't believe FAST! + */ + + if ((minsync < 50) && (tp->inqdata[2] & 0x0f) < 2) + minsync=50; + /* ** our limit .. */ @@ -6335,7 +6215,7 @@ static void ncr_getsync(ncb_p np, u_char sfac, u_char *fakp, u_char *scntl3p) /* ** Why not to try the immediate lower divisor and to choose ** the one that allows the fastest output speed ? - ** We dont want input speed too much greater than output speed. + ** We don't want input speed too much greater than output speed. */ if (div >= 1 && fak < 8) { u_long fak2, per2; @@ -6386,12 +6266,8 @@ static void ncr_set_sync_wide_status (ncb_p np, u_char target) for (cp = np->ccb; cp; cp = cp->link_ccb) { if (!cp->cmd) continue; if (cp->cmd->target != target) continue; -#if 0 cp->sync_status = tp->sval; cp->wide_status = tp->wval; -#endif - cp->phys.select.sel_scntl3 = tp->wval; - cp->phys.select.sel_sxfer = tp->sval; }; } @@ -6406,15 +6282,15 @@ static void ncr_setsync (ncb_p np, ccb_p cp, u_char scntl3, u_char sxfer) { Scsi_Cmnd *cmd; tcb_p tp; - u_char target = INB (nc_sdid) & 0x0f; + u_char target = INB (nc_ctest0) & 0x0f; u_char idiv; - assert (cp && cp->cmd); + assert (cp); if (!cp) return; cmd = cp->cmd; + assert (cmd); if (!cmd) return; - assert (target == (cmd->target & 0xf)); tp = &np->target[target]; @@ -6444,7 +6320,7 @@ static void ncr_setsync (ncb_p np, ccb_p cp, u_char scntl3, u_char sxfer) /* ** Bells and whistles ;-) */ - PRINT_TARGET(np, target); + PRINT_ADDR(cmd); if (sxfer & 0x01f) { unsigned f10 = 100000 << (tp->widedone ? tp->widedone -1 : 0); unsigned mb10 = (f10 + tp->period/2) / tp->period; @@ -6463,11 +6339,11 @@ static void ncr_setsync (ncb_p np, ccb_p cp, u_char scntl3, u_char sxfer) else if (tp->period < 2000) scsi = "FAST-10"; else scsi = "FAST-5"; - printk ("%s %sSCSI %d.%d MB/s (%d ns, offset %d)\n", scsi, + printf ("%s %sSCSI %d.%d MB/s (%d ns, offset %d)\n", scsi, tp->widedone > 1 ? "WIDE " : "", mb10 / 10, mb10 % 10, tp->period / 10, sxfer & 0x1f); } else - printk ("%sasynchronous.\n", tp->widedone > 1 ? "wide " : ""); + printf ("%sasynchronous.\n", tp->widedone > 1 ? "wide " : ""); /* ** set actual value and sync_status @@ -6489,17 +6365,17 @@ static void ncr_setsync (ncb_p np, ccb_p cp, u_char scntl3, u_char sxfer) static void ncr_setwide (ncb_p np, ccb_p cp, u_char wide, u_char ack) { Scsi_Cmnd *cmd; - u_short target = INB (nc_sdid) & 0x0f; + u_short target = INB (nc_ctest0) & 0x0f; tcb_p tp; u_char scntl3; u_char sxfer; - assert (cp && cp->cmd); + assert (cp); if (!cp) return; cmd = cp->cmd; + assert (cmd); if (!cmd) return; - assert (target == (cmd->target & 0xf)); tp = &np->target[target]; @@ -6519,11 +6395,11 @@ static void ncr_setwide (ncb_p np, ccb_p cp, u_char wide, u_char ack) ** Bells and whistles ;-) */ if (bootverbose >= 2) { - PRINT_TARGET(np, target); + PRINT_ADDR(cmd); if (scntl3 & EWS) - printk ("WIDE SCSI (16 bit) enabled.\n"); + printf ("WIDE SCSI (16 bit) enabled.\n"); else - printk ("WIDE SCSI disabled.\n"); + printf ("WIDE SCSI disabled.\n"); } /* @@ -6540,91 +6416,73 @@ static void ncr_setwide (ncb_p np, ccb_p cp, u_char wide, u_char ack) **========================================================== */ -static void ncr_setup_tags (ncb_p np, u_char tn, u_char ln) +static void ncr_setmaxtags (ncb_p np, tcb_p tp, u_long numtags) { - tcb_p tp = &np->target[tn]; - lcb_p lp = tp->lp[ln]; - u_char reqtags, maxdepth; + int l; + if (numtags > tp->usrtags) + numtags = tp->usrtags; + tp->numtags = numtags; + tp->maxtags = numtags; - /* - ** Just in case ... - */ - if ((!tp) || (!lp)) - return; + for (l=0; lscdev_depth) - return; + if (!tp) break; + lp=tp->lp[l]; + if (!lp) continue; - /* - ** Donnot allow more tags than the SCSI driver can queue - ** for this device. - ** Donnot allow more tags than we can handle. - */ - maxdepth = lp->scdev_depth; - if (maxdepth > lp->maxnxs) maxdepth = lp->maxnxs; - if (lp->maxtags > maxdepth) lp->maxtags = maxdepth; - if (lp->numtags > maxdepth) lp->numtags = maxdepth; + wastags = lp->usetags; + ncr_settags (tp, lp); + + if (numtags > 1 && lp->reqccbs > 1) { + PRINT_LUN(np, tp - np->target, l); + printf("using tagged command queueing, up to %ld cmds/lun\n", numtags); + } + else if (numtags <= 1 && wastags) { + PRINT_LUN(np, tp - np->target, l); + printf("disabling tagged command queueing\n"); + } + }; +} + +static void ncr_settags (tcb_p tp, lcb_p lp) +{ + u_char reqtags, tmp; + + if ((!tp) || (!lp)) return; /* ** only devices conformant to ANSI Version >= 2 - ** only devices capable of tagged commands + ** only devices capable of tagges commands + ** only disk devices ** only if enabled by user .. */ - if ((lp->inq_byte7 & INQ7_QUEUE) && lp->numtags > 1) { - reqtags = lp->numtags; + if (( tp->inqdata[2] & 0x7) >= 2 && + ( tp->inqdata[7] & INQ7_QUEUE) && ((tp->inqdata[0] & 0x1f)==0x00) + && tp->numtags > 1) { + reqtags = tp->numtags; + if (lp->actlink <= 1) + lp->usetags=reqtags; } else { reqtags = 1; + if (lp->actlink <= 1) + lp->usetags=0; }; /* - ** Update max number of tags - */ - lp->numtags = reqtags; - if (lp->numtags > lp->maxtags) - lp->maxtags = lp->numtags; - - /* - ** If we want to switch tag mode, we must wait - ** for no CCB to be active. + ** don't announce more than available. */ - if (reqtags > 1 && lp->usetags) { /* Stay in tagged mode */ - if (lp->queuedepth == reqtags) /* Already announced */ - return; - lp->queuedepth = reqtags; - } - else if (reqtags <= 1 && !lp->usetags) { /* Stay in untagged mode */ - lp->queuedepth = reqtags; - return; - } - else { /* Want to switch tag mode */ - if (lp->busyccbs) /* If not yet safe, return */ - return; - lp->queuedepth = reqtags; - lp->usetags = reqtags > 1 ? 1 : 0; - } - - /* - ** Patch the lun mini-script, according to tag mode. - */ - lp->jump_tag.l_paddr = lp->usetags? - cpu_to_scr(NCB_SCRIPT_PHYS(np, resel_tag)) : - cpu_to_scr(NCB_SCRIPT_PHYS(np, resel_notag)); - - /* - ** Announce change to user. - */ - if (bootverbose) { - PRINT_LUN(np, tn, ln); - if (lp->usetags) { - printk("tagged command queue depth set to %d\n", reqtags); - } - else { - printk("tagged command queueing disabled\n"); - } - } + tmp = lp->actccbs; + if (tmp > reqtags) tmp = reqtags; + lp->reqlink = tmp; + + /* + ** don't discard if announced. + */ + tmp = lp->actlink; + if (tmp < reqtags) tmp = reqtags; + lp->reqccbs = tmp; } /*---------------------------------------------------- @@ -6655,18 +6513,13 @@ static void ncr_usercmd (ncb_p np) break; case UC_SETTAGS: + if (np->user.data > SCSI_NCR_MAX_TAGS) + np->user.data = SCSI_NCR_MAX_TAGS; for (t=0; tuser.target>>t)&1)) continue; np->target[t].usrtags = np->user.data; - for (ln = 0; ln < MAX_LUN; ln++) { - lcb_p lp = np->target[t].lp[ln]; - if (!lp) - continue; - lp->maxtags = lp->numtags = np->user.data; - ncr_setup_tags (np, t, ln); - } - }; + ncr_setmaxtags (np, &np->target[t], np->user.data); + }; break; case UC_SETDEBUG: @@ -6679,10 +6532,6 @@ static void ncr_usercmd (ncb_p np) np->order = np->user.data; break; - case UC_SETVERBOSE: - np->verbose = np->user.data; - break; - case UC_SETWIDE: for (t=0; tprofile, sizeof(np->profile)); break; +#ifdef UC_DEBUG_ERROR_RECOVERY + case UC_DEBUG_ERROR_RECOVERY: + np->debug_error_recovery = np->user.data; + break; #endif } np->user.cmd=0; } #endif + +/*===================================================================== +** +** Embedded error recovery debugging code. +** +**===================================================================== +** +** This code is conditionned by SCSI_NCR_DEBUG_ERROR_RECOVERY_SUPPORT. +** It only can be enabled after boot-up with a control command. +** +** Every 30 seconds the timer handler of the driver decides to +** change the behaviour of the driver in order to trigger errors. +** +** If last command was "debug_error_recovery sge", the driver +** sets sync offset of all targets that use sync transfers to 2, +** and so hopes a SCSI gross error at the next read operation. +** +** If last command was "debug_error_recovery abort", the driver +** does not signal new scsi commands to the script processor, until +** it is asked to abort or reset a command by the mid-level driver. +** +** If last command was "debug_error_recovery reset", the driver +** does not signal new scsi commands to the script processor, until +** it is asked to reset a command by the mid-level driver. +** +** If last command was "debug_error_recovery parity", the driver +** will assert ATN on the next DATA IN phase mismatch, and so will +** behave as if a parity error had been detected. +** +** The command "debug_error_recovery none" makes the driver behave +** normaly. +** +**===================================================================== +*/ + +#ifdef SCSI_NCR_DEBUG_ERROR_RECOVERY_SUPPORT +static void ncr_trigger_errors (ncb_p np) +{ + /* + ** If np->debug_error_recovery is not zero, we want to + ** simulate common errors in order to test error recovery. + */ + do { + static u_long last = 0l; + + if (!np->debug_error_recovery) + break; + if (!last) + last = jiffies; + else if (jiffies < last + 30*HZ) + break; + last = jiffies; + /* + * This one triggers SCSI gross errors. + */ + if (np->debug_error_recovery == 1) { + int i; + printf("%s: testing error recovery from SCSI gross error...\n", ncr_name(np)); + for (i = 0 ; i < MAX_TARGET ; i++) { + if (np->target[i].sval & 0x1f) { + np->target[i].sval &= ~0x1f; + np->target[i].sval += 2; + } + } + } + /* + * This one triggers abort from the mid-level driver. + */ + else if (np->debug_error_recovery == 2) { + printf("%s: testing error recovery from mid-level driver abort()...\n", ncr_name(np)); + np->stalling = 2; + } + /* + * This one triggers reset from the mid-level driver. + */ + else if (np->debug_error_recovery == 3) { + printf("%s: testing error recovery from mid-level driver reset()...\n", ncr_name(np)); + np->stalling = 3; + } + /* + * This one set ATN on phase mismatch in DATA IN phase and so + * will behave as on scsi parity error detected. + */ + else if (np->debug_error_recovery == 4) { + printf("%s: testing data in parity error...\n", ncr_name(np)); + np->assert_atn = 1; + } + } while (0); +} +#endif + /*========================================================== ** ** @@ -6730,6 +6673,9 @@ static void ncr_usercmd (ncb_p np) static void ncr_timeout (ncb_p np) { u_long thistime = jiffies; + u_long count = 0; + ccb_p cp; + u_long flags; /* ** If release process in progress, let's go @@ -6742,9 +6688,18 @@ static void ncr_timeout (ncb_p np) return; } - np->timer.expires = jiffies + SCSI_NCR_TIMER_INTERVAL; + np->timer.expires = +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,0) + jiffies + +#endif + SCSI_NCR_TIMER_INTERVAL; + add_timer(&np->timer); +#ifdef SCSI_NCR_DEBUG_ERROR_RECOVERY_SUPPORT + ncr_trigger_errors (np); +#endif + /* ** If we are resetting the ncr, wait for settle_time before ** clearing it. Then command processing will be resumed. @@ -6752,10 +6707,12 @@ static void ncr_timeout (ncb_p np) if (np->settle_time) { if (np->settle_time <= thistime) { if (bootverbose > 1) - printk("%s: command processing resumed\n", ncr_name(np)); + printf("%s: command processing resumed\n", ncr_name(np)); + save_flags(flags); cli(); np->settle_time = 0; np->disc = 1; requeue_waiting_list(np); + restore_flags(flags); } return; } @@ -6765,20 +6722,99 @@ static void ncr_timeout (ncb_p np) ** to perform abort of a command, we must look at ccbs about ** every 0.25 second. */ - if (np->lasttime + 4*HZ < thistime) { + if (np->lasttime + (HZ>>2) <= thistime) { /* ** block ncr interrupts */ + save_flags(flags); cli(); + np->lasttime = thistime; -#ifdef SCSI_NCR_PROFILE_SUPPORT /* ** Reset profile data to avoid ugly overflow ** (Limited to 1024 GB for 32 bit architecture) */ if (np->profile.num_kbytes > (~0UL >> 2)) bzero(&np->profile, sizeof(np->profile)); + + /*---------------------------------------------------- + ** + ** handle ncr chip timeouts + ** + ** Assumption: + ** We have a chance to arbitrate for the + ** SCSI bus at least every 10 seconds. + ** + **---------------------------------------------------- + */ +#if 0 + if (thistime < np->heartbeat + HZ + HZ) + np->latetime = 0; + else + np->latetime++; +#endif + + /*---------------------------------------------------- + ** + ** handle ccb timeouts + ** + **---------------------------------------------------- + */ + + for (cp=np->ccb; cp; cp=cp->link_ccb) { + /* + ** look for timed out ccbs. + */ + if (!cp->host_status) continue; + count++; + /* + ** Have to force ordered tag to avoid timeouts + */ + if (cp->cmd && cp->tlimit && cp->tlimit <= + thistime + NCR_TIMEOUT_INCREASE + SCSI_NCR_TIMEOUT_ALERT) { + lcb_p lp; + lp = np->target[cp->cmd->target].lp[cp->cmd->lun]; + if (lp && !lp->force_ordered_tag) { + lp->force_ordered_tag = 1; + } + } + /* + ** ncr_abort_command() cannot complete canceled + ** commands immediately. It sets tlimit to zero + ** and ask the script to skip the scsi process if + ** necessary. We have to complete this work here. + */ + + if (cp->tlimit) continue; + + switch (cp->host_status) { + + case HS_BUSY: + case HS_NEGOTIATE: + /* + ** still in start queue ? + */ + if (cp->phys.header.launch.l_paddr == + cpu_to_scr(NCB_SCRIPT_PHYS (np, skip))) + continue; + + /* fall through */ + case HS_DISCONNECT: + cp->host_status=HS_ABORTED; + }; + cp->tag = 0; + + /* + ** wakeup this ccb. + */ + ncr_complete (np, cp); + +#ifdef SCSI_NCR_DEBUG_ERROR_RECOVERY_SUPPORT + if (!np->stalling) #endif + OUTB (nc_istat, SIGP); + } + restore_flags(flags); } #ifdef SCSI_NCR_BROKEN_INTR @@ -6787,9 +6823,11 @@ static void ncr_timeout (ncb_p np) /* ** Process pending interrupts. */ - if (DEBUG_FLAGS & DEBUG_TINY) printk ("{"); + save_flags(flags); cli(); + if (DEBUG_FLAGS & DEBUG_TINY) printf ("{"); ncr_exception (np); - if (DEBUG_FLAGS & DEBUG_TINY) printk ("}"); + if (DEBUG_FLAGS & DEBUG_TINY) printf ("}"); + restore_flags(flags); } #endif /* SCSI_NCR_BROKEN_INTR */ } @@ -6838,14 +6876,14 @@ static void ncr_log_hard_error(ncb_p np, u_short sist, u_char dstat) if (dsp > np->p_script && dsp <= np->p_script + sizeof(struct script)) { script_ofs = dsp - np->p_script; script_size = sizeof(struct script); - script_base = (u_char *) np->script0; + script_base = (u_char *) np->script; script_name = "script"; } else if (np->p_scripth < dsp && dsp <= np->p_scripth + sizeof(struct scripth)) { script_ofs = dsp - np->p_scripth; script_size = sizeof(struct scripth); - script_base = (u_char *) np->scripth0; + script_base = (u_char *) np->scripth; script_name = "scripth"; } else { script_ofs = dsp; @@ -6854,22 +6892,22 @@ static void ncr_log_hard_error(ncb_p np, u_short sist, u_char dstat) script_name = "mem"; } - printk ("%s:%d: ERROR (%x:%x) (%x-%x-%x) (%x/%x) @ (%s %x:%08x).\n", - ncr_name (np), (unsigned)INB (nc_sdid)&0x0f, dstat, sist, + printf ("%s:%d: ERROR (%x:%x) (%x-%x-%x) (%x/%x) @ (%s %x:%08x).\n", + ncr_name (np), (unsigned)INB (nc_ctest0)&0x0f, dstat, sist, (unsigned)INB (nc_socl), (unsigned)INB (nc_sbcl), (unsigned)INB (nc_sbdl), (unsigned)INB (nc_sxfer),(unsigned)INB (nc_scntl3), script_name, script_ofs, (unsigned)INL (nc_dbc)); if (((script_ofs & 3) == 0) && (unsigned)script_ofs < script_size) { - printk ("%s: script cmd = %08x\n", ncr_name(np), - scr_to_cpu((int) *(ncrcmd *)(script_base + script_ofs))); + printf ("%s: script cmd = %08x\n", ncr_name(np), + (int) *(ncrcmd *)(script_base + script_ofs)); } - printk ("%s: regdump:", ncr_name(np)); + printf ("%s: regdump:", ncr_name(np)); for (i=0; i<16;i++) - printk (" %02x", (unsigned)INB_OFF(i)); - printk (".\n"); + printf (" %02x", (unsigned)INB_OFF(i)); + printf (".\n"); } /*============================================================ @@ -6915,25 +6953,23 @@ void ncr_exception (ncb_p np) ** Since the global header may be copied back to a CCB ** using a posted PCI memory write, the last operation on ** the istat register is a READ in order to flush posted - ** PCI write commands. + ** PCI commands (Btw, the 'do' loop is probably useless). */ istat = INB (nc_istat); if (istat & INTF) { - OUTB (nc_istat, (istat & SIGP) | INTF); - istat = INB (nc_istat); - if (DEBUG_FLAGS & DEBUG_TINY) printk ("F "); -#ifdef SCSI_NCR_PROFILE_SUPPORT + do { + OUTB (nc_istat, (istat & SIGP) | INTF); + istat = INB (nc_istat); + } while (istat & INTF); + if (DEBUG_FLAGS & DEBUG_TINY) printf ("F "); np->profile.num_fly++; -#endif - ncr_wakeup_done (np); + ncr_wakeup (np, 0); }; if (!(istat & (SIP|DIP))) return; -#ifdef SCSI_NCR_PROFILE_SUPPORT np->profile.num_int++; -#endif if (istat & CABRT) OUTB (nc_istat, CABRT); @@ -6947,7 +6983,7 @@ void ncr_exception (ncb_p np) dstat = (istat & DIP) ? INB (nc_dstat) : 0; if (DEBUG_FLAGS & DEBUG_TINY) - printk ("<%d|%x:%x|%x:%x>", + printf ("<%d|%x:%x|%x:%x>", (int)INB(nc_scr0), dstat,sist, (unsigned)INL(nc_dsp), @@ -6984,11 +7020,12 @@ void ncr_exception (ncb_p np) ** DEL 397 - 53C875 Rev 3 - Part Number 609-0392410 - ITEM 2. */ if (!(sist & (SBMC|PAR)) && !(dstat & SSI)) { - printk( "%s: unknown interrupt(s) ignored, " + printf( "%s: unknown interrupt(s) ignored, " "ISTAT=%x DSTAT=%x SIST=%x\n", ncr_name(np), istat, dstat, sist); return; } + OUTONB (nc_dcntl, (STD|NOCOM)); return; }; @@ -7046,26 +7083,29 @@ void ncr_exception (ncb_p np) ncr_log_hard_error(np, sist, dstat); - printk ("%s: have to clear fifos.\n", ncr_name (np)); + printf ("%s: have to clear fifos.\n", ncr_name (np)); OUTB (nc_stest3, TE|CSF); OUTONB (nc_ctest3, CLF); if ((sist & (SGE)) || (dstat & (MDPE|BF|ABORT|IID))) { - ncr_start_reset(np); + ncr_start_reset(np, driver_setup.settle_delay); return; }; if (sist & HTH) { - printk ("%s: handshake timeout\n", ncr_name(np)); - ncr_start_reset(np); + printf ("%s: handshake timeout\n", ncr_name(np)); + ncr_start_reset(np, driver_setup.settle_delay); return; }; if (sist & UDC) { - printk ("%s: unexpected disconnect\n", ncr_name(np)); - OUTB (HS_PRT, HS_UNEXPECTED); - OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, cleanup)); + printf ("%s: unexpected disconnect\n", ncr_name(np)); + if (INB (nc_scr1) != 0xff) { + OUTB (nc_scr1, HS_UNEXPECTED); + OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, cleanup)); + }; + ncr_start_reset(np, driver_setup.settle_delay); return; }; @@ -7074,7 +7114,7 @@ void ncr_exception (ncb_p np) ** Print a message. The timeout will do the real work. **========================================================= */ - printk ("%s: unknown interrupt\n", ncr_name(np)); + printf ("%s: unknown interrupt\n", ncr_name(np)); } /*========================================================== @@ -7095,9 +7135,9 @@ void ncr_exception (ncb_p np) void ncr_int_sto (ncb_p np) { - u_long dsa; + u_long dsa, scratcha, diff; ccb_p cp; - if (DEBUG_FLAGS & DEBUG_TINY) printk ("T"); + if (DEBUG_FLAGS & DEBUG_TINY) printf ("T"); /* ** look for ccb and set the status. @@ -7114,11 +7154,21 @@ void ncr_int_sto (ncb_p np) }; /* - ** repair start queue and jump to start point. + ** repair start queue */ - OUTL (nc_dsp, NCB_SCRIPTH_PHYS (np, sto_restart)); - return; + scratcha = INL (nc_scratcha); + diff = scratcha - NCB_SCRIPTH_PHYS (np, tryloop); + +/* assert ((diff <= MAX_START * 20) && !(diff % 20));*/ + + if ((diff <= MAX_START * 20) && !(diff % 20)) { + np->script->startpos[0] = cpu_to_scr(scratcha); + OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, start)); + return; + }; + ncr_init (np, 1, "selection timeout", HS_FAIL); + np->disc = 1; } /*========================================================== @@ -7142,22 +7192,19 @@ static int ncr_int_sbmc (ncb_p np) { u_char scsi_mode = INB (nc_stest4) & SMODE; - if (scsi_mode != np->scsi_mode) { - printk("%s: SCSI bus mode change from %x to %x.\n", - ncr_name(np), np->scsi_mode, scsi_mode); + printf("%s: SCSI bus mode change from %x to %x.\n", + ncr_name(np), np->scsi_mode, scsi_mode); - np->scsi_mode = scsi_mode; + np->scsi_mode = scsi_mode; + /* + ** Suspend command processing for 1 second and + ** reinitialize all except the chip. + */ + np->settle_time = jiffies + HZ; + ncr_init (np, 0, bootverbose ? "scsi mode change" : NULL, HS_RESET); - /* - ** Suspend command processing for 1 second and - ** reinitialize all except the chip. - */ - np->settle_time = jiffies + HZ; - ncr_init (np, 0, bootverbose ? "scsi mode change" : NULL, HS_RESET); - return 1; - } - return 0; + return 1; } /*========================================================== @@ -7166,73 +7213,16 @@ static int ncr_int_sbmc (ncb_p np) ** **========================================================== ** +** SCSI parity errors are handled by the SCSI script. +** So, we just print some message. ** **---------------------------------------------------------- */ static int ncr_int_par (ncb_p np) { - u_char hsts = INB (HS_PRT); - u_int32 dbc = INL (nc_dbc); - u_char sstat1 = INB (nc_sstat1); - int phase = -1; - int msg = -1; - u_int32 jmp; - - printk("%s: SCSI parity error detected: SCR1=%d DBC=%x SSTAT1=%x\n", - ncr_name(np), hsts, dbc, sstat1); - - /* - * Ignore the interrupt if the NCR is not connected - * to the SCSI bus, since the right work should have - * been done on unexpected disconnection handling. - */ - if (!(INB (nc_scntl1) & ISCON)) - return 0; - - /* - * If the nexus is not clearly identified, reset the bus. - * We will try to do better later. - */ - if (hsts & HS_INVALMASK) - goto reset_all; - - /* - * If the SCSI parity error occurs in MSG IN phase, prepare a - * MSG PARITY message. Otherwise, prepare a INITIATOR DETECTED - * ERROR message and let the device decide to retry the command - * or to terminate with check condition. If we were in MSG IN - * phase waiting for the response of a negotiation, we will - * get SIR_NEGO_FAILED at dispatch. - */ - if (!(dbc & 0xc0000000)) - phase = (dbc >> 24) & 7; - if (phase == 7) - msg = M_PARITY; - else - msg = M_ID_ERROR; - - /* - * If the NCR stopped on a MOVE ^ DATA_IN, we jump to a - * script that will ignore all data in bytes until phase - * change, since we are not sure the chip will wait the phase - * change prior to delivering the interrupt. - */ - if (phase == 1) - jmp = NCB_SCRIPTH_PHYS (np, par_err_data_in); - else - jmp = NCB_SCRIPTH_PHYS (np, par_err_other); - - OUTONB (nc_ctest3, CLF ); /* clear dma fifo */ - OUTB (nc_stest3, TE|CSF); /* clear scsi fifo */ - - np->msgout[0] = msg; - OUTL (nc_dsp, jmp); - return 1; - -reset_all: - ncr_start_reset(np); - return 1; + printf("%s: SCSI parity error detected\n", ncr_name(np)); + return 0; } /*========================================================== @@ -7302,88 +7292,71 @@ static void ncr_int_ma (ncb_p np) if (ss2 & ORF1) rest++; }; + OUTONB (nc_ctest3, CLF ); /* clear dma fifo */ + OUTB (nc_stest3, TE|CSF); /* clear scsi fifo */ + if (DEBUG_FLAGS & (DEBUG_TINY|DEBUG_PHASE)) - printk ("P%x%x RL=%d D=%d SS0=%x ", cmd&7, sbcl&7, + printf ("P%x%x RL=%d D=%d SS0=%x ", cmd&7, sbcl&7, (unsigned) rest, (unsigned) delta, ss0); } else { if (DEBUG_FLAGS & (DEBUG_TINY|DEBUG_PHASE)) - printk ("P%x%x RL=%d ", cmd&7, sbcl&7, rest); + printf ("P%x%x RL=%d ", cmd&7, sbcl&7, rest); + if ((cmd & 7) != 1) { + OUTONB (nc_ctest3, CLF ); + OUTB (nc_stest3, TE|CSF); + } } /* - ** Clear fifos. - */ - OUTONB (nc_ctest3, CLF ); /* clear dma fifo */ - OUTB (nc_stest3, TE|CSF); /* clear scsi fifo */ - - /* - ** locate matching cp. - ** if the interrupted phase is DATA IN or DATA OUT, - ** trust the global header. + ** locate matching cp */ dsa = INL (nc_dsa); - if (!(cmd & 6)) { - cp = np->header.cp; - if (CCB_PHYS(cp, phys) != dsa) - cp = 0; - } else { - cp = np->ccb; - while (cp && (CCB_PHYS (cp, phys) != dsa)) - cp = cp->link_ccb; + cp = np->ccb; + while (cp && (CCB_PHYS (cp, phys) != dsa)) + cp = cp->link_ccb; + + if (!cp) { + printf ("%s: SCSI phase error fixup: CCB already dequeued (0x%08lx)\n", + ncr_name (np), (u_long) np->header.cp); + return; + } + if (cp != np->header.cp) { + printf ("%s: SCSI phase error fixup: CCB address mismatch (0x%08lx != 0x%08lx)\n", + ncr_name (np), (u_long) cp, (u_long) np->header.cp); +/* return;*/ } /* - ** try to find the interrupted script command, + ** find the interrupted script command, ** and the address at which to continue. */ - vdsp = 0; - nxtdsp = 0; - if (dsp > np->p_script && - dsp <= np->p_script + sizeof(struct script)) { - vdsp = (u_int32 *)((char*)np->script0 + (dsp-np->p_script-8)); + + if (dsp == vtophys (&cp->patch[2])) { + vdsp = &cp->patch[0]; + nxtdsp = vdsp[3]; + } else if (dsp == vtophys (&cp->patch[6])) { + vdsp = &cp->patch[4]; + nxtdsp = vdsp[3]; + } else if (dsp > np->p_script && dsp <= np->p_script + sizeof(struct script)) { + vdsp = (u_int32 *) ((char*)np->script - np->p_script + dsp -8); nxtdsp = dsp; - } - else if (dsp > np->p_scripth && - dsp <= np->p_scripth + sizeof(struct scripth)) { - vdsp = (u_int32 *)((char*)np->scripth0 + (dsp-np->p_scripth-8)); + } else { + vdsp = (u_int32 *) ((char*)np->scripth - np->p_scripth + dsp -8); nxtdsp = dsp; - } - else if (cp) { - if (dsp == vtophys (&cp->patch[2])) { - vdsp = &cp->patch[0]; - nxtdsp = scr_to_cpu(vdsp[3]); - } - else if (dsp == vtophys (&cp->patch[6])) { - vdsp = &cp->patch[4]; - nxtdsp = scr_to_cpu(vdsp[3]); - } - } + }; /* ** log the information */ if (DEBUG_FLAGS & DEBUG_PHASE) { - printk ("\nCP=%p CP2=%p DSP=%x NXT=%x VDSP=%p CMD=%x ", + printf ("\nCP=%p CP2=%p DSP=%x NXT=%x VDSP=%p CMD=%x ", cp, np->header.cp, (unsigned)dsp, (unsigned)nxtdsp, vdsp, cmd); }; - /* - ** cp=0 means that the DSA does not point to a valid control - ** block. This should not happen since we donnot use multi-byte - ** move while we are being reselected ot after command complete. - ** We are not able to recover from such a phase error. - */ - if (!cp) { - printk ("%s: SCSI phase error fixup: " - "CCB already dequeued (0x%08lx)\n", - ncr_name (np), (u_long) np->header.cp); - goto reset_all; - } - /* ** get old startaddress and old length. */ @@ -7400,7 +7373,7 @@ static void ncr_int_ma (ncb_p np) }; if (DEBUG_FLAGS & DEBUG_PHASE) { - printk ("OCMD=%x\nTBLP=%p OLEN=%x OADR=%x\n", + printf ("OCMD=%x\nTBLP=%p OLEN=%x OADR=%x\n", (unsigned) (scr_to_cpu(vdsp[0]) >> 24), tblp, (unsigned) olen, @@ -7413,23 +7386,18 @@ static void ncr_int_ma (ncb_p np) if (cmd != (scr_to_cpu(vdsp[0]) >> 24)) { PRINT_ADDR(cp->cmd); - printk ("internal error: cmd=%02x != %02x=(vdsp[0] >> 24)\n", + printf ("internal error: cmd=%02x != %02x=(vdsp[0] >> 24)\n", (unsigned)cmd, (unsigned)scr_to_cpu(vdsp[0]) >> 24); - - goto reset_all; + + return; } - /* - ** cp != np->header.cp means that the header of the CCB - ** currently being processed has not yet been copied to - ** the global header area. That may happen if the device did - ** not accept all our messages after having been selected. - */ - if (cp != np->header.cp) { - printk ("%s: SCSI phase error fixup: " - "CCB address mismatch (0x%08lx != 0x%08lx)\n", - ncr_name (np), (u_long) cp, (u_long) np->header.cp); +#ifdef SCSI_NCR_DEBUG_ERROR_RECOVERY_SUPPORT + if ((cmd & 7) == 1 && np->assert_atn) { + np->assert_atn = 0; + OUTONB(nc_socl, CATN); } +#endif /* ** if old phase not dataphase, leave here. @@ -7437,10 +7405,12 @@ static void ncr_int_ma (ncb_p np) if (cmd & 0x06) { PRINT_ADDR(cp->cmd); - printk ("phase change %x-%x %d@%08x resid=%d.\n", + printf ("phase change %x-%x %d@%08x resid=%d.\n", cmd&7, sbcl&7, (unsigned)olen, (unsigned)oadr, (unsigned)rest); - goto unexpected_phase; + + OUTONB (nc_dcntl, (STD|NOCOM)); + return; }; /* @@ -7451,247 +7421,36 @@ static void ncr_int_ma (ncb_p np) newcmd = cp->patch; if (cp->phys.header.savep == cpu_to_scr(vtophys (newcmd))) newcmd+=4; - /* - ** fillin the commands - */ - - newcmd[0] = cpu_to_scr(((cmd & 0x0f) << 24) | rest); - newcmd[1] = cpu_to_scr(oadr + olen - rest); - newcmd[2] = cpu_to_scr(SCR_JUMP); - newcmd[3] = cpu_to_scr(nxtdsp); - - if (DEBUG_FLAGS & DEBUG_PHASE) { - PRINT_ADDR(cp->cmd); - printk ("newcmd[%d] %x %x %x %x.\n", - (int) (newcmd - cp->patch), - (unsigned)scr_to_cpu(newcmd[0]), - (unsigned)scr_to_cpu(newcmd[1]), - (unsigned)scr_to_cpu(newcmd[2]), - (unsigned)scr_to_cpu(newcmd[3])); - } - /* - ** fake the return address (to the patch). - ** and restart script processor at dispatcher. - */ -#ifdef SCSI_NCR_PROFILE_SUPPORT - np->profile.num_break++; -#endif - OUTL (nc_temp, vtophys (newcmd)); - OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, dispatch)); - return; - - /* - ** Unexpected phase changes that occurs when the current phase - ** is not a DATA IN or DATA OUT phase are due to error conditions. - ** Such event may only happen when the SCRIPTS is using a - ** multibyte SCSI MOVE. - ** - ** Phase change Some possible cause - ** - ** COMMAND --> MSG IN SCSI parity error detected by target. - ** COMMAND --> STATUS Bad command or refused by target. - ** MSG OUT --> MSG IN Message rejected by target. - ** MSG OUT --> COMMAND Bogus target that discards extended - ** negotiation messages. - ** - ** The code below does not care of the new phase and so - ** trusts the target. Why to annoy it ? - ** If the interrupted phase is COMMAND phase, we restart at - ** dispatcher. - ** If a target does not get all the messages after selection, - ** the code assumes blindly that the target discards extended - ** messages and clears the negotiation status. - ** If the target does not want all our response to negotiation, - ** we force a SIR_NEGO_PROTO interrupt (it is a hack that avoids - ** bloat for such a should_not_happen situation). - ** In all other situation, we reset the BUS. - ** Are these assumptions reasonnable ? (Wait and see ...) - */ -unexpected_phase: - dsp -= 8; - nxtdsp = 0; - - switch (cmd & 7) { - case 2: /* COMMAND phase */ - nxtdsp = NCB_SCRIPT_PHYS (np, dispatch); - break; -#if 0 - case 3: /* STATUS phase */ - nxtdsp = NCB_SCRIPT_PHYS (np, dispatch); - break; -#endif - case 6: /* MSG OUT phase */ - np->scripth->nxtdsp_go_on[0] = cpu_to_scr(dsp + 8); - if (dsp == NCB_SCRIPT_PHYS (np, send_ident)) { - cp->host_status = HS_BUSY; - nxtdsp = NCB_SCRIPTH_PHYS (np, clratn_go_on); - } - else if (dsp == NCB_SCRIPTH_PHYS (np, send_wdtr) || - dsp == NCB_SCRIPTH_PHYS (np, send_sdtr)) { - nxtdsp = dsp - 8; /* Should raise SIR_NEGO_PROTO */ - } - break; -#if 0 - case 7: /* MSG IN phase */ - nxtdsp = NCB_SCRIPT_PHYS (np, clrack); - break; -#endif - } - - if (nxtdsp) { - OUTL (nc_dsp, nxtdsp); - return; - } - -reset_all: - ncr_start_reset(np); -} - - -static void ncr_sir_to_redo(ncb_p np, int num, ccb_p cp) -{ - Scsi_Cmnd *cmd = cp->cmd; - tcb_p tp = &np->target[cmd->target]; - lcb_p lp = tp->lp[cmd->lun]; - XPT_QUEHEAD *qp; - ccb_p cp2; - int disc_cnt = 0; - int busy_cnt = 0; - u_int32 startp; - u_char s_status = INB (SS_PRT); - - /* - ** Let the SCRIPTS processor skip all not yet started CCBs, - ** and count disconnected CCBs. Since the busy queue is in - ** the same order as the chip start queue, disconnected CCBs - ** are before cp and busy ones after. - */ - if (lp) { - qp = lp->busy_ccbq.blink; - while (qp != &lp->busy_ccbq) { - cp2 = xpt_que_entry(qp, struct ccb, link_ccbq); - qp = qp->blink; - ++busy_cnt; - if (cp2 == cp) - break; - cp2->start.schedule.l_paddr = - cpu_to_scr(NCB_SCRIPTH_PHYS (np, skip)); - } - lp->held_ccb = cp; /* Requeue when this one completes */ - disc_cnt = lp->queuedccbs - busy_cnt; - } - - switch(s_status) { - default: /* Just for safety, should never happen */ - case S_QUEUE_FULL: - /* - ** Decrease number of tags to the number of - ** disconnected commands. - */ - if (!lp) - goto out; - if (bootverbose >= 1) { - PRINT_ADDR(cmd); - printk ("QUEUE FULL! %d busy, %d disconnected CCBs\n", - busy_cnt, disc_cnt); - } - if (disc_cnt < lp->numtags) { - lp->numtags = disc_cnt > 2 ? disc_cnt : 2; - lp->num_good = 0; - ncr_setup_tags (np, cmd->target, cmd->lun); - } - /* - ** Requeue the command to the start queue. - ** If any disconnected commands, - ** Clear SIGP. - ** Jump to reselect. - */ - cp->phys.header.savep = cp->startp; - cp->host_status = HS_BUSY; - cp->scsi_status = S_ILLEGAL; - - ncr_put_start_queue(np, cp); - if (disc_cnt) - INB (nc_ctest2); /* Clear SIGP */ - OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, reselect)); - return; - case S_TERMINATED: - case S_CHECK_COND: - /* - ** If we were requesting sense, give up. - */ - if (cp->auto_sense) - goto out; - - /* - ** Device returned CHECK CONDITION status. - ** Prepare all needed data strutures for getting - ** sense data. - ** - ** identify message - */ - cp->scsi_smsg2[0] = M_IDENTIFY | cmd->lun; - cp->phys.smsg.addr = cpu_to_scr(CCB_PHYS (cp, scsi_smsg2)); - cp->phys.smsg.size = cpu_to_scr(1); - - /* - ** sense command - */ - cp->phys.cmd.addr = cpu_to_scr(CCB_PHYS (cp, sensecmd)); - cp->phys.cmd.size = cpu_to_scr(6); - - /* - ** patch requested size into sense command - */ - cp->sensecmd[0] = 0x03; - cp->sensecmd[1] = cmd->lun << 5; - cp->sensecmd[4] = sizeof(cmd->sense_buffer); - - /* - ** sense data - */ - cp->phys.sense.addr = - cpu_to_scr(vtophys (&cmd->sense_buffer[0])); - cp->phys.sense.size = - cpu_to_scr(sizeof(cmd->sense_buffer)); - - /* - ** requeue the command. - */ - startp = cpu_to_scr(NCB_SCRIPTH_PHYS (np, sdata_in)); - - cp->phys.header.savep = startp; - cp->phys.header.goalp = startp + 24; - cp->phys.header.lastp = startp; - cp->phys.header.wgoalp = startp + 24; - cp->phys.header.wlastp = startp; - - cp->host_status = HS_BUSY; - cp->scsi_status = S_ILLEGAL; - cp->auto_sense = s_status; - - cp->start.schedule.l_paddr = - cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); - - /* - ** Select without ATN for quirky devices. - */ - if (tp->quirks & QUIRK_NOMSG) - cp->start.schedule.l_paddr = - cpu_to_scr(NCB_SCRIPTH_PHYS (np, select_no_atn)); + /* + ** fillin the commands + */ - ncr_put_start_queue(np, cp); + newcmd[0] = cpu_to_scr(((cmd & 0x0f) << 24) | rest); + newcmd[1] = cpu_to_scr(oadr + olen - rest); + newcmd[2] = cpu_to_scr(SCR_JUMP); + newcmd[3] = cpu_to_scr(nxtdsp); - OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, start)); - return; + if (DEBUG_FLAGS & DEBUG_PHASE) { + PRINT_ADDR(cp->cmd); + printf ("newcmd[%d] %x %x %x %x.\n", + (int) (newcmd - cp->patch), + (unsigned)scr_to_cpu(newcmd[0]), + (unsigned)scr_to_cpu(newcmd[1]), + (unsigned)scr_to_cpu(newcmd[2]), + (unsigned)scr_to_cpu(newcmd[3])); } - -out: - OUTONB (nc_dcntl, (STD|NOCOM)); - return; + /* + ** fake the return address (to the patch). + ** and restart script processor at dispatcher. + */ + np->profile.num_break++; + OUTL (nc_temp, vtophys (newcmd)); + if ((cmd & 7) == 0) + OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, dispatch)); + else + OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, checkatn)); } - /*========================================================== ** ** @@ -7704,79 +7463,159 @@ out: static int ncr_show_msg (u_char * msg) { u_char i; - printk ("%x",*msg); + printf ("%x",*msg); if (*msg==M_EXTENDED) { for (i=1;i<8;i++) { if (i-1>msg[1]) break; - printk ("-%x",msg[i]); + printf ("-%x",msg[i]); }; return (i+1); } else if ((*msg & 0xf0) == 0x20) { - printk ("-%x",msg[1]); + printf ("-%x",msg[1]); return (2); }; return (1); } - void ncr_int_sir (ncb_p np) { u_char scntl3; u_char chg, ofs, per, fak, wide; u_char num = INB (nc_dsps); ccb_p cp=0; - u_long dsa = INL (nc_dsa); - u_char target = INB (nc_sdid) & 0x0f; + u_long dsa; + u_char target = INB (nc_ctest0) & 0x0f; tcb_p tp = &np->target[target]; - - if (DEBUG_FLAGS & DEBUG_TINY) printk ("I#%d", num); + int i; + if (DEBUG_FLAGS & DEBUG_TINY) printf ("I#%d", num); switch (num) { - case SIR_RESEL_NO_MSG_IN: - case SIR_RESEL_NO_IDENTIFY: - /* - ** If devices reselecting without sending an IDENTIFY - ** message still exist, this should help. - ** We just assume lun=0, 1 CCB, no tag. - */ - if (tp->lp[0]) { - OUTL (nc_dsp, scr_to_cpu(tp->lp[0]->jump_ccb[0])); - return; - } - case SIR_RESEL_BAD_TARGET: /* Will send a TARGET RESET message */ - case SIR_RESEL_BAD_LUN: /* Will send a TARGET RESET message */ - case SIR_RESEL_BAD_I_T_L_Q: /* Will send an ABORT TAG message */ - case SIR_RESEL_BAD_I_T_L: /* Will send an ABORT message */ - printk ("%s:%d: SIR %d, " - "incorrect nexus identification on reselection\n", - ncr_name (np), target, num); - goto out; - case SIR_DONE_OVERFLOW: - printk ("%s:%d: SIR %d, " - "CCB done queue overflow\n", - ncr_name (np), target, num); + case SIR_SENSE_RESTART: + case SIR_STALL_RESTART: + break; + case SIR_STALL_QUEUE: /* Ignore, just restart the script */ goto out; - case SIR_BAD_STATUS: - cp = np->header.cp; - if (!cp || CCB_PHYS (cp, phys) != dsa) - goto out; - ncr_sir_to_redo(np, num, cp); - return; + default: /* ** lookup the ccb */ + dsa = INL (nc_dsa); cp = np->ccb; while (cp && (CCB_PHYS (cp, phys) != dsa)) cp = cp->link_ccb; - assert (cp && cp == np->header.cp); - - if (!cp || cp != np->header.cp) + assert (cp); + if (!cp) + goto out; + assert (cp == np->header.cp); + if (cp != np->header.cp) goto out; } switch (num) { + u_long endp; + case SIR_DATA_IO_IS_OUT: + case SIR_DATA_IO_IS_IN: +/* +** We did not guess the direction of transfer. We have to wait for +** actual data direction driven by the target before setting +** pointers. We must patch the global header too. +*/ + if (num == SIR_DATA_IO_IS_OUT) { + endp = NCB_SCRIPTH_PHYS (np, data_out) + MAX_SCATTER*16; + cp->phys.header.goalp = cpu_to_scr(endp + 8); + cp->phys.header.savep = + cpu_to_scr(endp - cp->segments*16); + } else { + endp = NCB_SCRIPT_PHYS (np, data_in) + MAX_SCATTER*16; + cp->phys.header.goalp = cpu_to_scr(endp + 8); + cp->phys.header.savep = + cpu_to_scr(endp - cp->segments*16); + } + + cp->phys.header.lastp = cp->phys.header.savep; + np->header.savep = cp->phys.header.savep; + np->header.goalp = cp->phys.header.goalp; + np->header.lastp = cp->phys.header.lastp; + + OUTL (nc_temp, scr_to_cpu(np->header.savep)); + OUTL (nc_dsp, scr_to_cpu(np->header.savep)); + return; + /* break; */ + +/*-------------------------------------------------------------------- +** +** Processing of interrupted getcc selects +** +**-------------------------------------------------------------------- +*/ + + case SIR_SENSE_RESTART: + /*------------------------------------------ + ** Script processor is idle. + ** Look for interrupted "check cond" + **------------------------------------------ + */ + + if (DEBUG_FLAGS & DEBUG_RESTART) + printf ("%s: int#%d",ncr_name (np),num); + cp = (ccb_p) 0; + for (i=0; itarget[i]; + if (DEBUG_FLAGS & DEBUG_RESTART) printf ("+"); + cp = tp->hold_cp; + if (!cp) continue; + if (DEBUG_FLAGS & DEBUG_RESTART) printf ("+"); + if ((cp->host_status==HS_BUSY) && + (cp->scsi_status==S_CHECK_COND)) + break; + if (DEBUG_FLAGS & DEBUG_RESTART) printf ("- (remove)"); + tp->hold_cp = cp = (ccb_p) 0; + }; + + if (cp) { + if (DEBUG_FLAGS & DEBUG_RESTART) + printf ("+ restart job ..\n"); + OUTL (nc_dsa, CCB_PHYS (cp, phys)); + OUTL (nc_dsp, NCB_SCRIPTH_PHYS (np, getcc)); + return; + }; + + /* + ** no job, resume normal processing + */ + if (DEBUG_FLAGS & DEBUG_RESTART) printf (" -- remove trap\n"); + np->script->start0[0] = cpu_to_scr(SCR_INT ^ IFFALSE (0)); + break; + + case SIR_SENSE_FAILED: + /*------------------------------------------- + ** While trying to select for + ** getting the condition code, + ** a target reselected us. + **------------------------------------------- + */ + if (DEBUG_FLAGS & DEBUG_RESTART) { + PRINT_ADDR(cp->cmd); + printf ("in getcc reselect by t%d.\n", + (int)INB(nc_ssid) & 0x0f); + } + + /* + ** Mark this job + */ + cp->host_status = HS_BUSY; + cp->scsi_status = S_CHECK_COND; + np->target[cp->cmd->target].hold_cp = cp; + + /* + ** And patch code to restart it. + */ + np->script->start0[0] = cpu_to_scr(SCR_INT); + break; + /*----------------------------------------------------------------------------- ** ** Was Sie schon immer ueber transfermode negotiation wissen wollten ... @@ -7860,7 +7699,7 @@ void ncr_int_sir (ncb_p np) if (DEBUG_FLAGS & DEBUG_NEGO) { PRINT_ADDR(cp->cmd); - printk ("negotiation failed sir=%x status=%x.\n", + printf ("negotiation failed sir=%x status=%x.\n", num, cp->nego_status); }; @@ -7883,8 +7722,7 @@ void ncr_int_sir (ncb_p np) np->msgout[0] = M_NOOP; cp->nego_status = 0; OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, dispatch)); - return; -/* break; */ + break; case SIR_NEGO_SYNC: /* @@ -7893,9 +7731,9 @@ void ncr_int_sir (ncb_p np) if (DEBUG_FLAGS & DEBUG_NEGO) { PRINT_ADDR(cp->cmd); - printk ("sync msgin: "); + printf ("sync msgin: "); (void) ncr_show_msg (np->msgin); - printk (".\n"); + printf (".\n"); }; /* @@ -7913,7 +7751,7 @@ void ncr_int_sir (ncb_p np) */ if (ofs) - tp->inq_byte7 |= INQ7_SYNC; + tp->inqdata[7] |= INQ7_SYNC; /* ** check values against driver limits. @@ -7947,7 +7785,7 @@ void ncr_int_sir (ncb_p np) if (DEBUG_FLAGS & DEBUG_NEGO) { PRINT_ADDR(cp->cmd); - printk ("sync: per=%d scntl3=0x%x ofs=%d fak=%d chg=%d.\n", + printf ("sync: per=%d scntl3=0x%x ofs=%d fak=%d chg=%d.\n", per, scntl3, ofs, fak, chg); } @@ -7980,6 +7818,20 @@ void ncr_int_sir (ncb_p np) }; }; + /* + ** It was a request. + ** Check against the table of target capabilities. + ** If target not capable force M_REJECT and asynchronous. + */ + if (np->unit < SCSI_NCR_MAX_HOST) { + tp->inqdata[7] &= + (target_capabilities[np->unit].and_map[target]); + if (!(tp->inqdata[7] & INQ7_SYNC)) { + ofs = 0; + fak = 7; + } + } + /* ** It was a request. Set value and ** prepare an answer message @@ -7997,9 +7849,9 @@ void ncr_int_sir (ncb_p np) if (DEBUG_FLAGS & DEBUG_NEGO) { PRINT_ADDR(cp->cmd); - printk ("sync msgout: "); + printf ("sync msgout: "); (void) ncr_show_msg (np->msgout); - printk (".\n"); + printf (".\n"); } if (!ofs) { @@ -8016,9 +7868,9 @@ void ncr_int_sir (ncb_p np) */ if (DEBUG_FLAGS & DEBUG_NEGO) { PRINT_ADDR(cp->cmd); - printk ("wide msgin: "); + printf ("wide msgin: "); (void) ncr_show_msg (np->msgin); - printk (".\n"); + printf (".\n"); }; /* @@ -8034,7 +7886,7 @@ void ncr_int_sir (ncb_p np) */ if (wide) - tp->inq_byte7 |= INQ7_WIDE16; + tp->inqdata[7] |= INQ7_WIDE16; /* ** check values against driver limits. @@ -8045,7 +7897,7 @@ void ncr_int_sir (ncb_p np) if (DEBUG_FLAGS & DEBUG_NEGO) { PRINT_ADDR(cp->cmd); - printk ("wide: wide=%d chg=%d.\n", wide, chg); + printf ("wide: wide=%d chg=%d.\n", wide, chg); } if (INB (HS_PRT) == HS_NEGOTIATE) { @@ -8095,9 +7947,9 @@ void ncr_int_sir (ncb_p np) if (DEBUG_FLAGS & DEBUG_NEGO) { PRINT_ADDR(cp->cmd); - printk ("wide msgout: "); + printf ("wide msgout: "); (void) ncr_show_msg (np->msgin); - printk (".\n"); + printf (".\n"); } break; @@ -8117,7 +7969,7 @@ void ncr_int_sir (ncb_p np) */ PRINT_ADDR(cp->cmd); - printk ("M_REJECT received (%x:%x).\n", + printf ("M_REJECT received (%x:%x).\n", (unsigned)scr_to_cpu(np->lastmsg), np->msgout[0]); break; @@ -8130,9 +7982,9 @@ void ncr_int_sir (ncb_p np) */ PRINT_ADDR(cp->cmd); - printk ("M_REJECT sent for "); + printf ("M_REJECT sent for "); (void) ncr_show_msg (np->msgin); - printk (".\n"); + printf (".\n"); break; /*-------------------------------------------------------------------- @@ -8152,9 +8004,9 @@ void ncr_int_sir (ncb_p np) */ PRINT_ADDR(cp->cmd); - printk ("M_IGN_RESIDUE received, but not yet implemented.\n"); + printf ("M_IGN_RESIDUE received, but not yet implemented.\n"); break; -#if 0 + case SIR_MISSING_SAVE: /*----------------------------------------------- ** @@ -8165,13 +8017,92 @@ void ncr_int_sir (ncb_p np) */ PRINT_ADDR(cp->cmd); - printk ("M_DISCONNECT received, but datapointer not saved: " + printf ("M_DISCONNECT received, but datapointer not saved: " "data=%x save=%x goal=%x.\n", (unsigned) INL (nc_temp), (unsigned) scr_to_cpu(np->header.savep), (unsigned) scr_to_cpu(np->header.goalp)); break; -#endif + +#if 0 /* This stuff does not work */ +/*-------------------------------------------------------------------- +** +** Processing of a "S_QUEUE_FULL" status. +** +** The current command has been rejected, +** because there are too many in the command queue. +** We have started too many commands for that target. +** +** If possible, reinsert at head of queue. +** Stall queue until there are no disconnected jobs +** (ncr is REALLY idle). Then restart processing. +** +** We should restart the current job after the controller +** has become idle. But this is not yet implemented. +** +**-------------------------------------------------------------------- +*/ + case SIR_STALL_QUEUE: + /*----------------------------------------------- + ** + ** Stall the start queue. + ** + **----------------------------------------------- + */ + PRINT_ADDR(cp->cmd); + printf ("queue full.\n"); + + np->script->start1[0] = cpu_to_scr(SCR_INT); + + /* + ** Try to disable tagged transfers. + */ + ncr_setmaxtags (np, &np->target[target], 0); + + /* + ** @QUEUE@ + ** + ** Should update the launch field of the + ** current job to be able to restart it. + ** Then prepend it to the start queue. + */ + + /* fall through */ + + case SIR_STALL_RESTART: + /*----------------------------------------------- + ** + ** Enable selecting again, + ** if NO disconnected jobs. + ** + **----------------------------------------------- + */ + /* + ** Look for a disconnected job. + */ + cp = np->ccb; + while (cp && cp->host_status != HS_DISCONNECT) + cp = cp->link_ccb; + + /* + ** if there is one, ... + */ + if (cp) { + /* + ** wait for reselection + */ + OUTL (nc_dsp, NCB_SCRIPT_PHYS (np, reselect)); + return; + }; + + /* + ** else remove the interrupt. + */ + + printf ("%s: queue empty.\n", ncr_name (np)); + np->script->start1[0] = cpu_to_scr(SCR_INT ^ IFFALSE (0)); + break; +#endif /* This stuff does not work */ }; out: @@ -8187,71 +8118,48 @@ out: **========================================================== */ -static ccb_p ncr_get_ccb (ncb_p np, u_char tn, u_char ln) +static ccb_p ncr_get_ccb + (ncb_p np, u_long target, u_long lun) { - tcb_p tp = &np->target[tn]; - lcb_p lp = tp->lp[ln]; - u_char tag = NO_TAG; + lcb_p lp; ccb_p cp = (ccb_p) 0; /* ** Lun structure available ? */ - if (lp) { - XPT_QUEHEAD *qp; - /* - ** Keep from using more tags than we can handle. - */ - if (lp->usetags && lp->busyccbs >= lp->maxnxs) - return (ccb_p) 0; - /* - ** Allocate a new CCB if needed. - */ - if (xpt_que_empty(&lp->free_ccbq)) - ncr_alloc_ccb(np, tn, ln); + lp = np->target[target].lp[lun]; + + if (lp && lp->opennings && (!lp->active || lp->active < lp->reqlink)) { + + cp = lp->next_ccb; - /* - ** Tune tag mode if asked by user. - */ - if (lp->queuedepth != lp->numtags) { - ncr_setup_tags(np, tn, ln); - } - /* ** Look for free CCB */ - qp = xpt_remque_head(&lp->free_ccbq); - if (qp) { - cp = xpt_que_entry(qp, struct ccb, link_ccbq); - if (cp->magic) { - PRINT_LUN(np, tn, ln); - printk ("ccb free list corrupted (@%p)\n", cp); - cp = 0; - } - else { - xpt_insque_tail(qp, &lp->wait_ccbq); - ++lp->busyccbs; - } - } + + while (cp && cp->magic) cp = cp->next_ccb; /* - ** If a CCB is available, - ** Get a tag for this nexus if required. + ** Increment active commands and decrement credit. */ + if (cp) { - if (lp->usetags) - tag = lp->cb_tags[lp->ia_tag]; + ++lp->active; + --lp->opennings; } - else if (lp->actccbs > 0) - return (ccb_p) 0; } /* ** if nothing available, take the default. + ** DANGEROUS, because this ccb is not suitable for + ** reselection. + ** If lp->actccbs > 0 wait for a suitable ccb to be free. */ - if (!cp) - cp = np->ccb; + if ((!cp) && lp && lp->actccbs > 0) + return ((ccb_p) 0); + + if (!cp) cp = np->ccb; /* ** Wait until available. @@ -8268,32 +8176,7 @@ static ccb_p ncr_get_ccb (ncb_p np, u_char tn, u_char ln) return ((ccb_p) 0); cp->magic = 1; - - /* - ** Move to next available tag if tag used. - */ - if (lp) { - if (tag != NO_TAG) { - ++lp->ia_tag; - if (lp->ia_tag == SCSI_NCR_MAX_TAGS) - lp->ia_tag = 0; - lp->tags_umap |= (((tagmap_t) 1) << tag); - } - } - - /* - ** Remember all informations needed to free this CCB. - */ - cp->tag = tag; - cp->target = tn; - cp->lun = ln; - - if (DEBUG_FLAGS & DEBUG_TAGS) { - PRINT_LUN(np, tn, ln); - printk ("ccb @%p using tag %d.\n", cp, tag); - } - - return cp; + return (cp); } /*========================================================== @@ -8305,417 +8188,252 @@ static ccb_p ncr_get_ccb (ncb_p np, u_char tn, u_char ln) **========================================================== */ -static void ncr_free_ccb (ncb_p np, ccb_p cp) +void ncr_free_ccb (ncb_p np, ccb_p cp, u_long target, u_long lun) { - tcb_p tp = &np->target[cp->target]; - lcb_p lp = tp->lp[cp->lun]; - - if (DEBUG_FLAGS & DEBUG_TAGS) { - PRINT_LUN(np, cp->target, cp->lun); - printk ("ccb @%p freeing tag %d.\n", cp, cp->tag); - } + lcb_p lp; /* - ** If lun control block available, - ** decrement active commands and increment credit, - ** free the tag if any and remove the JUMP for reselect. + ** sanity */ - if (lp) { - if (cp->tag != NO_TAG) { - lp->cb_tags[lp->if_tag++] = cp->tag; - if (lp->if_tag == SCSI_NCR_MAX_TAGS) - lp->if_tag = 0; - lp->tags_umap &= ~(((tagmap_t) 1) << cp->tag); - lp->tags_smap &= lp->tags_umap; - lp->jump_ccb[cp->tag] = - cpu_to_scr(NCB_SCRIPTH_PHYS(np, bad_i_t_l_q)); - } else { - lp->jump_ccb[0] = - cpu_to_scr(NCB_SCRIPTH_PHYS(np, bad_i_t_l)); - } - } + + assert (cp != NULL); /* - ** Make this CCB available. + ** Decrement active commands and increment credit. */ + lp = np->target[target].lp[lun]; if (lp) { - if (cp != np->ccb) { - xpt_remque(&cp->link_ccbq); - xpt_insque_head(&cp->link_ccbq, &lp->free_ccbq); - } - --lp->busyccbs; - if (cp->queued) { - --lp->queuedccbs; - } + --lp->active; + ++lp->opennings; } + cp -> host_status = HS_IDLE; cp -> magic = 0; - if (cp->queued) { - --np->queuedccbs; - cp->queued = 0; - } - #if 0 if (cp == np->ccb) wakeup ((caddr_t) cp); #endif } - -#define ncr_reg_bus_addr(r) \ - (bus_dvma_to_mem(np->paddr) + offsetof (struct ncr_reg, r)) - -/*------------------------------------------------------------------------ -** Initialize the fixed part of a CCB structure. -**------------------------------------------------------------------------ -**------------------------------------------------------------------------ +/*========================================================== +** +** +** Allocation of resources for Targets/Luns/Tags. +** +** +**========================================================== */ -static void ncr_init_ccb(ncb_p np, ccb_p cp) + +static void ncr_alloc_ccb (ncb_p np, u_long target, u_long lun) { - ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); + tcb_p tp; + lcb_p lp; + ccb_p cp; - /* - ** Remember virtual and bus address of this ccb. - */ - cp->p_ccb = vtophys(cp); - cp->phys.header.cp = cp; + assert (np != NULL); - /* - ** This allows xpt_remque to work for the default ccb. - */ - xpt_que_init(&cp->link_ccbq); + if (target>=MAX_TARGET) return; + if (lun >=MAX_LUN ) return; - /* - ** Initialyze the start and restart launch script. - ** - ** COPY(4) @(...p_phys), @(dsa) - ** JUMP @(sched_point) - */ - cp->start.setup_dsa[0] = cpu_to_scr(copy_4); - cp->start.setup_dsa[1] = cpu_to_scr(vtophys(&cp->start.p_phys)); - cp->start.setup_dsa[2] = cpu_to_scr(ncr_reg_bus_addr(nc_dsa)); - cp->start.schedule.l_cmd = cpu_to_scr(SCR_JUMP); - cp->start.p_phys = cpu_to_scr(vtophys(&cp->phys)); + tp=&np->target[target]; - bcopy(&cp->start, &cp->restart, sizeof(cp->restart)); + if (!tp->jump_tcb.l_cmd) { + /* + ** initialize it. + */ + tp->jump_tcb.l_cmd = + cpu_to_scr((SCR_JUMP^IFFALSE (DATA (0x80 + target)))); + tp->jump_tcb.l_paddr = np->jump_tcb.l_paddr; - cp->start.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); - cp->restart.schedule.l_paddr = cpu_to_scr(NCB_SCRIPTH_PHYS (np, abort)); -} + tp->getscr[0] = (np->features & FE_PFEN) ? + cpu_to_scr(SCR_COPY(1)):cpu_to_scr(SCR_COPY_F(1)); + tp->getscr[1] = cpu_to_scr(vtophys (&tp->sval)); + tp->getscr[2] = + cpu_to_scr(np->paddr + offsetof (struct ncr_reg, nc_sxfer)); + tp->getscr[3] = (np->features & FE_PFEN) ? + cpu_to_scr(SCR_COPY(1)):cpu_to_scr(SCR_COPY_F(1)); + tp->getscr[4] = cpu_to_scr(vtophys (&tp->wval)); + tp->getscr[5] = + cpu_to_scr(np->paddr + offsetof (struct ncr_reg, nc_scntl3)); -/*------------------------------------------------------------------------ -** Allocate a CCB and initialize its fixed part. -**------------------------------------------------------------------------ -**------------------------------------------------------------------------ -*/ -static void ncr_alloc_ccb(ncb_p np, u_char tn, u_char ln) -{ - tcb_p tp = &np->target[tn]; - lcb_p lp = tp->lp[ln]; - ccb_p cp = 0; + assert (( (offsetof(struct ncr_reg, nc_sxfer) ^ + offsetof(struct tcb , sval )) &3) == 0); + assert (( (offsetof(struct ncr_reg, nc_scntl3) ^ + offsetof(struct tcb , wval )) &3) == 0); - /* - ** Allocate memory for this CCB. - */ - cp = m_alloc(sizeof(struct ccb), 5); - if (!cp) - return; + tp->call_lun.l_cmd = cpu_to_scr(SCR_CALL); + tp->call_lun.l_paddr = + cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_lun)); - if (DEBUG_FLAGS & DEBUG_ALLOC) { - PRINT_LUN(np, tn, ln); - printk ("new ccb @%p.\n", cp); + tp->jump_lcb.l_cmd = cpu_to_scr(SCR_JUMP); + tp->jump_lcb.l_paddr = cpu_to_scr(NCB_SCRIPTH_PHYS (np, abort)); + np->jump_tcb.l_paddr = cpu_to_scr(vtophys (&tp->jump_tcb)); } /* - ** Count it and initialyze it. + ** Logic unit control block */ - lp->actccbs++; - np->actccbs++; - bzero (cp, sizeof (*cp)); - ncr_init_ccb(np, cp); - - /* - ** Chain into wakeup list and free ccb queue and take it - ** into account for tagged commands. - */ - cp->link_ccb = np->ccb->link_ccb; - np->ccb->link_ccb = cp; + lp = tp->lp[lun]; + if (!lp) { + /* + ** Allocate a lcb + */ + lp = (lcb_p) m_alloc (sizeof (struct lcb), LCB_ALIGN_SHIFT); + if (!lp) return; - xpt_insque_head(&cp->link_ccbq, &lp->free_ccbq); - ncr_setup_tags (np, tn, ln); -} + if (DEBUG_FLAGS & DEBUG_ALLOC) { + PRINT_LUN(np, target, lun); + printf ("new lcb @%p.\n", lp); + } -/*========================================================== -** -** -** Allocation of resources for Targets/Luns/Tags. -** -** -**========================================================== -*/ + /* + ** Initialize it + */ + bzero (lp, sizeof (*lp)); + lp->jump_lcb.l_cmd = + cpu_to_scr(SCR_JUMP ^ IFFALSE (DATA (lun))); + lp->jump_lcb.l_paddr = tp->jump_lcb.l_paddr; + lp->call_tag.l_cmd = cpu_to_scr(SCR_CALL); + lp->call_tag.l_paddr = + cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_tag)); -/*------------------------------------------------------------------------ -** Target control block initialisation. -**------------------------------------------------------------------------ -** This data structure is fully initialized after a SCSI command -** has been successfully completed for this target. -** It contains a SCRIPT that is called on target reselection. -**------------------------------------------------------------------------ -*/ -static void ncr_init_tcb (ncb_p np, u_char tn) -{ - tcb_p tp = &np->target[tn]; - ncrcmd copy_1 = np->features & FE_PFEN ? SCR_COPY(1) : SCR_COPY_F(1); - int th = tn & 3; - int i; + lp->jump_ccb.l_cmd = cpu_to_scr(SCR_JUMP); + lp->jump_ccb.l_paddr = + cpu_to_scr(NCB_SCRIPTH_PHYS (np, aborttag)); - /* - ** Jump to next tcb if SFBR does not match this target. - ** JUMP IF (SFBR != #target#), @(next tcb) - */ - tp->jump_tcb.l_cmd = - cpu_to_scr((SCR_JUMP ^ IFFALSE (DATA (0x80 + tn)))); - tp->jump_tcb.l_paddr = np->jump_tcb[th].l_paddr; + lp->actlink = 1; - /* - ** Load the synchronous transfer register. - ** COPY @(tp->sval), @(sxfer) - */ - tp->getscr[0] = cpu_to_scr(copy_1); - tp->getscr[1] = cpu_to_scr(vtophys (&tp->sval)); - tp->getscr[2] = cpu_to_scr(ncr_reg_bus_addr(nc_sxfer)); - - /* - ** Load the timing register. - ** COPY @(tp->wval), @(scntl3) - */ - tp->getscr[3] = cpu_to_scr(copy_1); - tp->getscr[4] = cpu_to_scr(vtophys (&tp->wval)); - tp->getscr[5] = cpu_to_scr(ncr_reg_bus_addr(nc_scntl3)); + lp->active = 1; - /* - ** Get the IDENTIFY message and the lun. - ** CALL @script(resel_lun) - */ - tp->call_lun.l_cmd = cpu_to_scr(SCR_CALL); - tp->call_lun.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_lun)); + /* + ** Chain into LUN list + */ + tp->jump_lcb.l_paddr = cpu_to_scr(vtophys (&lp->jump_lcb)); + tp->lp[lun] = lp; - /* - ** Look for the lun control block of this nexus. - ** For i = 0 to 3 - ** JUMP ^ IFTRUE (MASK (i, 3)), @(next_lcb) - */ - for (i = 0 ; i < 4 ; i++) { - tp->jump_lcb[i].l_cmd = - cpu_to_scr((SCR_JUMP ^ IFTRUE (MASK (i, 3)))); - tp->jump_lcb[i].l_paddr = - cpu_to_scr(NCB_SCRIPTH_PHYS (np, bad_identify)); + ncr_setmaxtags (np, tp, driver_setup.default_tags); } /* - ** Link this target control block to the JUMP chain. - */ - np->jump_tcb[th].l_paddr = cpu_to_scr(vtophys (&tp->jump_tcb)); - - /* - ** These assert's should be moved at driver initialisations. + ** Allocate ccbs up to lp->reqccbs. */ - assert (( (offsetof(struct ncr_reg, nc_sxfer) ^ - offsetof(struct tcb , sval )) &3) == 0); - assert (( (offsetof(struct ncr_reg, nc_scntl3) ^ - offsetof(struct tcb , wval )) &3) == 0); -} - - -/*------------------------------------------------------------------------ -** Lun control block allocation and initialization. -**------------------------------------------------------------------------ -** This data structure is allocated and initialized after a SCSI -** command has been successfully completed for this target/lun. -**------------------------------------------------------------------------ -*/ -static lcb_p ncr_alloc_lcb (ncb_p np, u_char tn, u_char ln) -{ - tcb_p tp = &np->target[tn]; - lcb_p lp = tp->lp[ln]; - ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); - int lh = ln & 3; /* - ** Already done, return. + ** Limit possible number of ccbs. + ** + ** If tagged command queueing is enabled, + ** can use more than one ccb. */ - if (lp) - return lp; + if (np->actccbs >= MAX_START-2) return; + if (lp->actccbs && (lp->actccbs >= lp->reqccbs)) + return; /* - ** Allocate the lcb. + ** Allocate a ccb */ - lp = m_alloc(sizeof(struct lcb), 3); - if (!lp) - goto fail; - bzero(lp, sizeof(*lp)); - tp->lp[ln] = lp; + cp = (ccb_p) m_alloc (sizeof (struct ccb), CCB_ALIGN_SHIFT); + if (!cp) + return; if (DEBUG_FLAGS & DEBUG_ALLOC) { - PRINT_LUN(np, tn, ln); - printk ("new lcb @%p.\n", lp); + PRINT_LUN(np, target, lun); + printf ("new ccb @%p.\n", cp); } /* - ** Initialize the target control block if not yet. + ** Count it */ - if (!tp->jump_tcb.l_cmd) - ncr_init_tcb(np, tn); + lp->actccbs++; + np->actccbs++; /* - ** Initialize the CCB queue headers. + ** Initialize it */ - xpt_que_init(&lp->free_ccbq); - xpt_que_init(&lp->busy_ccbq); - xpt_que_init(&lp->wait_ccbq); - xpt_que_init(&lp->skip_ccbq); + bzero (cp, sizeof (*cp)); /* - ** Set max CCBs to 1 and use the default 1 entry - ** jump table by default. + ** Fill in physical addresses */ - lp->maxnxs = 1; - lp->jump_ccb = &lp->jump_ccb_0; - lp->p_jump_ccb = cpu_to_scr(vtophys(lp->jump_ccb)); + + cp->p_ccb = vtophys (cp); /* - ** Initilialyze the reselect script: - ** - ** Jump to next lcb if SFBR does not match this lun. - ** Load TEMP with the CCB direct jump table bus address. - ** Get the SIMPLE TAG message and the tag. - ** - ** JUMP IF (SFBR != #lun#), @(next lcb) - ** COPY @(lp->p_jump_ccb), @(temp) - ** JUMP @script(resel_notag) + ** Chain into reselect list */ - lp->jump_lcb.l_cmd = - cpu_to_scr((SCR_JUMP ^ IFFALSE (MASK (0x80+ln, 0xff)))); - lp->jump_lcb.l_paddr = tp->jump_lcb[lh].l_paddr; - - lp->load_jump_ccb[0] = cpu_to_scr(copy_4); - lp->load_jump_ccb[1] = cpu_to_scr(vtophys (&lp->p_jump_ccb)); - lp->load_jump_ccb[2] = cpu_to_scr(ncr_reg_bus_addr(nc_temp)); - - lp->jump_tag.l_cmd = cpu_to_scr(SCR_JUMP); - lp->jump_tag.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_notag)); + cp->jump_ccb.l_cmd = cpu_to_scr(SCR_JUMP); + cp->jump_ccb.l_paddr = lp->jump_ccb.l_paddr; + lp->jump_ccb.l_paddr = cpu_to_scr(CCB_PHYS (cp, jump_ccb)); + cp->call_tmp.l_cmd = cpu_to_scr(SCR_CALL); + cp->call_tmp.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_tmp)); /* - ** Link this lun control block to the JUMP chain. + ** Chain into wakeup list */ - tp->jump_lcb[lh].l_paddr = cpu_to_scr(vtophys (&lp->jump_lcb)); + cp->link_ccb = np->ccb->link_ccb; + np->ccb->link_ccb = cp; /* - ** Initialize command queuing control. + ** Chain into CCB list */ - lp->busyccbs = 1; - lp->queuedccbs = 1; - lp->queuedepth = 1; -fail: - return lp; + cp->next_ccb = lp->next_ccb; + lp->next_ccb = cp; } - -/*------------------------------------------------------------------------ -** Lun control block setup on INQUIRY data received. -**------------------------------------------------------------------------ -** We only support WIDE, SYNC for targets and CMDQ for logical units. -** This setup is done on each INQUIRY since we are expecting user -** will play with CHANGE DEFINITION commands. :-) -**------------------------------------------------------------------------ +/*========================================================== +** +** +** Announce the number of ccbs/tags to the scsi driver. +** +** +**========================================================== */ -static lcb_p ncr_setup_lcb (ncb_p np, u_char tn, u_char ln, u_char *inq_data) -{ - tcb_p tp = &np->target[tn]; - lcb_p lp = tp->lp[ln]; - u_char inq_byte7; +static void ncr_opennings (ncb_p np, lcb_p lp, Scsi_Cmnd * cmd) +{ /* - ** If no lcb, try to allocate it. + ** want to reduce the number ... */ - if (!lp && !(lp = ncr_alloc_lcb(np, tn, ln))) - goto fail; + if (lp->actlink > lp->reqlink) { - /* - ** Get device quirks from a speciality table. - */ - tp->quirks = ncr_lookup (inq_data); - if (tp->quirks && bootverbose) { - PRINT_LUN(np, tn, ln); - printk ("quirks=%x.\n", tp->quirks); - } + /* + ** Try to reduce the count. + ** We assume to run at splbio .. + */ + u_char diff = lp->actlink - lp->reqlink; - /* - ** Evaluate trustable target/unit capabilities. - ** We only believe device version >= SCSI-2 that - ** use appropriate response data format (2). - */ - inq_byte7 = 0; - if ((inq_data[2] & 0x7) >= 2 && (inq_data[3] & 0xf) == 2) - inq_byte7 = inq_data[7]; + if (!diff) return; - /* - ** Throw away announced LUN capabilities if we are told - ** that there is no real device supported by the logical unit. - */ - if ((inq_data[0] & 0xe0) > 0x20 || (inq_data[0] & 0x1f) == 0x1f) - inq_byte7 &= (INQ7_SYNC | INQ7_WIDE16); + if (diff > lp->opennings) + diff = lp->opennings; - /* - ** If user is wanting SYNC, force this feature. - */ - if (driver_setup.force_sync_nego) - inq_byte7 |= INQ7_SYNC; + lp->opennings -= diff; - /* - ** Prepare negotiation if SIP capabilities have changed. - */ - tp->inq_done = 1; - if ((inq_byte7 ^ tp->inq_byte7) & (INQ7_SYNC | INQ7_WIDE16)) { - tp->inq_byte7 = inq_byte7; - ncr_negotiate(np, tp); - } + lp->actlink -= diff; + if (DEBUG_FLAGS & DEBUG_TAGS) + printf ("%s: actlink: diff=%d, new=%d, req=%d\n", + ncr_name(np), diff, lp->actlink, lp->reqlink); + return; + }; /* - ** If unit supports tagged commands, allocate the - ** CCB JUMP table if not yet. + ** want to increase the number ? */ - if ((inq_byte7 & INQ7_QUEUE) && lp->jump_ccb == &lp->jump_ccb_0) { - int i; - lp->jump_ccb = m_alloc(256, 8); - if (!lp->jump_ccb) { - lp->jump_ccb = &lp->jump_ccb_0; - goto fail; - } - lp->p_jump_ccb = cpu_to_scr(vtophys(lp->jump_ccb)); - for (i = 0 ; i < 64 ; i++) - lp->jump_ccb[i] = - cpu_to_scr(NCB_SCRIPTH_PHYS (np, bad_i_t_l_q)); - for (i = 0 ; i < SCSI_NCR_MAX_TAGS ; i++) - lp->cb_tags[i] = i; - lp->maxnxs = SCSI_NCR_MAX_TAGS; - lp->tags_stime = jiffies; - } + if (lp->reqlink > lp->actlink) { + u_char diff = lp->reqlink - lp->actlink; - /* - ** Adjust tagged queueing status if needed. - */ - if ((inq_byte7 ^ lp->inq_byte7) & INQ7_QUEUE) { - lp->inq_byte7 = inq_byte7; - lp->numtags = lp->maxtags; - ncr_setup_tags (np, tn, ln); - } + lp->opennings += diff; -fail: - return lp; + lp->actlink += diff; +#if 0 + wakeup ((caddr_t) xp->sc_link); +#endif + if (DEBUG_FLAGS & DEBUG_TAGS) + printf ("%s: actlink: diff=%d, new=%d, req=%d\n", + ncr_name(np), diff, lp->actlink, lp->reqlink); + }; } /*========================================================== @@ -8753,6 +8471,9 @@ static int ncr_scatter(ccb_p cp, Scsi_Cmnd *cmd) int segment = 0; int use_sg = (int) cmd->use_sg; +#if 0 + bzero (cp->phys.data, sizeof (cp->phys.data)); +#endif data = cp->phys.data; cp->data_len = 0; @@ -8801,7 +8522,7 @@ __initfunc( static int ncr_regtest (struct ncb* np) ) { - register volatile u_int32 data; + register volatile u_long data; /* ** ncr registers may NOT be cached. ** write 0xffffffff to a read only register area, @@ -8815,7 +8536,7 @@ static int ncr_regtest (struct ncb* np) #else if ((data & 0xe2f0fffd) != 0x02000080) { #endif - printk ("CACHE TEST FAILED: reg dstat-sstat2 readback %x.\n", + printf ("CACHE TEST FAILED: reg dstat-sstat2 readback %x.\n", (unsigned) data); return (0x10); }; @@ -8827,8 +8548,8 @@ __initfunc( static int ncr_snooptest (struct ncb* np) ) { - u_int32 ncr_rd, ncr_wr, ncr_bk, host_rd, host_wr, pc; - int i, err=0; + u_long ncr_rd, ncr_wr, ncr_bk, host_rd, host_wr, pc, err=0; + int i; #ifndef NCR_IOMAPPED if (np->reg) { err |= ncr_regtest (np); @@ -8870,22 +8591,22 @@ static int ncr_snooptest (struct ncb* np) ** Reset ncr chip */ OUTB (nc_istat, SRST); - UDELAY (100); + DELAY (1000); OUTB (nc_istat, 0 ); /* ** check for timeout */ if (i>=NCR_SNOOP_TIMEOUT) { - printk ("CACHE TEST FAILED: timeout.\n"); + printf ("CACHE TEST FAILED: timeout.\n"); return (0x20); }; /* ** Check termination position. */ if (pc != NCB_SCRIPTH_PHYS (np, snoopend)+8) { - printk ("CACHE TEST FAILED: script execution failed.\n"); - printk ("start=%08lx, pc=%08lx, end=%08lx\n", - (u_long) NCB_SCRIPTH_PHYS (np, snooptest), (u_long) pc, + printf ("CACHE TEST FAILED: script execution failed.\n"); + printf ("start=%08lx, pc=%08lx, end=%08lx\n", + (u_long) NCB_SCRIPTH_PHYS (np, snooptest), pc, (u_long) NCB_SCRIPTH_PHYS (np, snoopend) +8); return (0x40); }; @@ -8893,17 +8614,17 @@ static int ncr_snooptest (struct ncb* np) ** Show results. */ if (host_wr != ncr_rd) { - printk ("CACHE TEST FAILED: host wrote %d, ncr read %d.\n", + printf ("CACHE TEST FAILED: host wrote %d, ncr read %d.\n", (int) host_wr, (int) ncr_rd); err |= 1; }; if (host_rd != ncr_wr) { - printk ("CACHE TEST FAILED: ncr wrote %d, host read %d.\n", + printf ("CACHE TEST FAILED: ncr wrote %d, host read %d.\n", (int) ncr_wr, (int) host_rd); err |= 2; }; if (ncr_bk != ncr_wr) { - printk ("CACHE TEST FAILED: ncr wrote %d, read back %d.\n", + printf ("CACHE TEST FAILED: ncr wrote %d, read back %d.\n", (int) ncr_wr, (int) ncr_bk); err |= 4; }; @@ -8931,8 +8652,8 @@ static int ncr_snooptest (struct ncb* np) #define PROFILE cp->phys.header.stamp static void ncb_profile (ncb_p np, ccb_p cp) { - long co, st, en, di, re, post, work, disc; - u_int diff; + int co, st, en, di, se, post,work,disc; + u_long diff; PROFILE.end = jiffies; @@ -8944,18 +8665,18 @@ static void ncb_profile (ncb_p np, ccb_p cp) en = ncr_delta (PROFILE.start,PROFILE.end), di = ncr_delta (PROFILE.start,PROFILE.disconnect), - re = ncr_delta (PROFILE.start,PROFILE.reselect); + se = ncr_delta (PROFILE.start,PROFILE.select); post = en - st; /* ** @PROFILE@ Disconnect time invalid if multiple disconnects */ - if (di>=0) disc = re - di; else disc = 0; + if (di>=0) disc = se-di; else disc = 0; work = (st - co) - disc; - diff = (scr_to_cpu(np->disc_phys) - np->disc_ref) & 0xff; + diff = (np->disc_phys - np->disc_ref) & 0xff; np->disc_ref += diff; np->profile.num_trans += 1; @@ -8997,13 +8718,13 @@ struct table_entry { static struct table_entry device_tab[] = { -#if 0 +#ifdef NCR_GETCC_WITHMSG {"", "", "", QUIRK_NOMSG}, -#endif {"SONY", "SDT-5000", "3.17", QUIRK_NOMSG}, {"WangDAT", "Model 2600", "01.7", QUIRK_NOMSG}, {"WangDAT", "Model 3200", "02.2", QUIRK_NOMSG}, {"WangDAT", "Model 1300", "02.4", QUIRK_NOMSG}, +#endif {"", "", "", 0} /* catch all: must be last entry. */ }; @@ -9067,21 +8788,21 @@ static void ncr_selectclock(ncb_p np, u_char scntl3) } if (bootverbose >= 2) - printk ("%s: enabling clock multiplier\n", ncr_name(np)); + printf ("%s: enabling clock multiplier\n", ncr_name(np)); OUTB(nc_stest1, DBLEN); /* Enable clock multiplier */ if (np->multiplier > 2) { /* Poll bit 5 of stest4 for quadrupler */ int i = 20; while (!(INB(nc_stest4) & LCKFRQ) && --i > 0) - UDELAY (20); + DELAY(20); if (!i) - printk("%s: the chip cannot lock the frequency\n", ncr_name(np)); + printf("%s: the chip cannot lock the frequency\n", ncr_name(np)); } else /* Wait 20 micro-seconds for doubler */ - UDELAY (20); + DELAY(20); OUTB(nc_stest3, HSC); /* Halt the scsi clock */ OUTB(nc_scntl3, scntl3); OUTB(nc_stest1, (DBLEN|DBLSEL));/* Select clock multiplier */ - OUTB(nc_stest3, 0x00); /* Restart scsi clock */ + OUTB(nc_stest3, 0x00|TE); /* Restart scsi clock */ } @@ -9118,7 +8839,7 @@ static unsigned ncrgetfreq (ncb_p np, int gen) OUTB (nc_stime1, 0); /* disable general purpose timer */ OUTB (nc_stime1, gen); /* set to nominal delay of 1<= 2) - printk ("%s: Delay (GEN=%d): %u msec\n", ncr_name(np), gen, ms); + printf ("%s: Delay (GEN=%d): %u msec\n", ncr_name(np), gen, ms); /* * adjust for prescaler, and convert into KHz */ @@ -9154,7 +8875,7 @@ static void ncr_getclock (ncb_p np, int mult) */ if (mult > 1 && (stest1 & (DBLEN+DBLSEL)) == DBLEN+DBLSEL) { if (bootverbose >= 2) - printk ("%s: clock multiplier found\n", ncr_name(np)); + printf ("%s: clock multiplier found\n", ncr_name(np)); np->multiplier = mult; } @@ -9166,14 +8887,14 @@ static void ncr_getclock (ncb_p np, int mult) if (np->multiplier != mult || (scntl3 & 7) < 3 || !(scntl3 & 1)) { unsigned f2; - OUTB(nc_istat, SRST); UDELAY (5); OUTB(nc_istat, 0); + OUTB(nc_istat, SRST); DELAY(5); OUTB(nc_istat, 0); (void) ncrgetfreq (np, 11); /* throw away first result */ f1 = ncrgetfreq (np, 11); f2 = ncrgetfreq (np, 11); if (bootverbose) - printk ("%s: NCR clock is %uKHz, %uKHz\n", ncr_name(np), f1, f2); + printf ("%s: NCR clock is %uKHz, %uKHz\n", ncr_name(np), f1, f2); if (f1 > f2) f1 = f2; /* trust lower result */ @@ -9183,7 +8904,7 @@ static void ncr_getclock (ncb_p np, int mult) if (f1 < 80000 && mult > 1) { if (bootverbose >= 2) - printk ("%s: clock multiplier assumed\n", ncr_name(np)); + printf ("%s: clock multiplier assumed\n", ncr_name(np)); np->multiplier = mult; } } else { @@ -9222,12 +8943,6 @@ static void ncr_getclock (ncb_p np, int mult) ** --------------------------------------------------------------------- */ -#ifdef MODULE -#define ARG_SEP ' ' -#else -#define ARG_SEP ',' -#endif - __initfunc( void ncr53c8xx_setup(char *str, int *ints) ) @@ -9240,33 +8955,33 @@ void ncr53c8xx_setup(char *str, int *ints) int c; while (cur != NULL && (pc = strchr(cur, ':')) != NULL) { - char *pe; - val = 0; pv = pc; c = *++pv; - if (c == 'n') val = 0; else if (c == 'y') val = 1; else { base = 0; - val = (int) simple_strtoul(pv, &pe, base); - } - if (!strncmp(cur, "tags:", 5)) { - int i; - driver_setup.default_tags = val; - if (pe && *pe == '/') { - i = 0; - while (*pe && *pe != ARG_SEP && - i < sizeof(driver_setup.tag_ctrl)-1) { - driver_setup.tag_ctrl[i++] = *pe++; - } - driver_setup.tag_ctrl[i] = '\0'; +#if 0 + if (c == '0') { + c = *pv++; + base = 8; } + if (c == 'x') { + ++pv; + base = 16; + } + else if (c >= '0' && c <= '9') + base = 10; + else + break; +#endif + val = (int) simple_strtoul(pv, NULL, base); } - else if (!strncmp(cur, "mpar:", 5)) + + if (!strncmp(cur, "mpar:", 5)) driver_setup.master_parity = val; else if (!strncmp(cur, "spar:", 5)) driver_setup.scsi_parity = val; @@ -9280,6 +8995,11 @@ void ncr53c8xx_setup(char *str, int *ints) driver_setup.force_sync_nego = val; else if (!strncmp(cur, "revprob:", 8)) driver_setup.reverse_probe = val; + else if (!strncmp(cur, "tags:", 5)) { + if (val > SCSI_NCR_MAX_TAGS) + val = SCSI_NCR_MAX_TAGS; + driver_setup.default_tags = val; + } else if (!strncmp(cur, "sync:", 5)) driver_setup.default_sync = val; else if (!strncmp(cur, "verb:", 5)) @@ -9310,9 +9030,13 @@ void ncr53c8xx_setup(char *str, int *ints) else if (!strncmp(cur, "safe:", 5) && val) memcpy(&driver_setup, &driver_safe_setup, sizeof(driver_setup)); else - printk("ncr53c8xx_setup: unexpected boot option '%.*s' ignored\n", (int)(pc-cur+1), cur); + printf("ncr53c8xx_setup: unexpected boot option '%.*s' ignored\n", (int)(pc-cur+1), cur); - if ((cur = strchr(cur, ARG_SEP)) != NULL) +#ifdef MODULE + if ((cur = strchr(cur, ' ')) != NULL) +#else + if ((cur = strchr(cur, ',')) != NULL) +#endif ++cur; } #endif /* SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT */ @@ -9341,31 +9065,24 @@ static void ncr_print_driver_setup(void) ) { #define YesNo(y) y ? 'y' : 'n' - printk ("ncr53c8xx: setup=disc:%c,specf:%d,ultra:%d,tags:%d,sync:%d," - "burst:%d,wide:%c,diff:%d,revprob:%c,buschk:0x%x\n", - YesNo(driver_setup.disconnection), - driver_setup.special_features, - driver_setup.ultra_scsi, - driver_setup.default_tags, - driver_setup.default_sync, - driver_setup.burst_max, - YesNo(driver_setup.max_wide), - driver_setup.diff_support, - YesNo(driver_setup.reverse_probe), - driver_setup.bus_check); - - printk ("ncr53c8xx: setup=mpar:%c,spar:%c,fsn=%c,verb:%d,debug:0x%x," - "led:%c,settle:%d,irqm:%d,nvram:0x%x,pcifix:0x%x\n", - YesNo(driver_setup.master_parity), - YesNo(driver_setup.scsi_parity), - YesNo(driver_setup.force_sync_nego), - driver_setup.verbose, - driver_setup.debug, - YesNo(driver_setup.led_pin), - driver_setup.settle_delay, - driver_setup.irqm, - driver_setup.use_nvram, - driver_setup.pci_fix_up); + printk("ncr53c8xx: setup=disc:%c,specf:%d,ultra:%c,tags:%d,sync:%d,burst:%d,wide:%c,diff:%d\n", + YesNo(driver_setup.disconnection), + driver_setup.special_features, + YesNo(driver_setup.ultra_scsi), + driver_setup.default_tags, + driver_setup.default_sync, + driver_setup.burst_max, + YesNo(driver_setup.max_wide), + driver_setup.diff_support); + printk("ncr53c8xx: setup=mpar:%c,spar:%c,fsn=%c,verb:%d,debug:0x%x,led:%c,settle:%d,irqm:%d\n", + YesNo(driver_setup.master_parity), + YesNo(driver_setup.scsi_parity), + YesNo(driver_setup.force_sync_nego), + driver_setup.verbose, + driver_setup.debug, + YesNo(driver_setup.led_pin), + driver_setup.settle_delay, + driver_setup.irqm); #undef YesNo } @@ -9385,7 +9102,7 @@ ncr_attach_using_nvram(Scsi_Host_Template *tpnt, int nvram_index, int count, ncr int i, j; int attach_count = 0; ncr_nvram *nvram; - ncr_device *devp = 0; /* to shut up gcc */ + ncr_device *devp; if (!nvram_index) return 0; @@ -9400,13 +9117,13 @@ ncr_attach_using_nvram(Scsi_Host_Template *tpnt, int nvram_index, int count, ncr if (nvram_index == -1) nvram_index = i; #ifdef SCSI_NCR_DEBUG_NVRAM - printk("ncr53c8xx: NVRAM: Symbios format Boot Block, 53c%s, PCI bus %d, device %d, function %d\n", + printf("ncr53c8xx: NVRAM: Symbios format Boot Block, 53c%s, PCI bus %d, device %d, function %d\n", devp->chip.name, devp->slot.bus, (int) (devp->slot.device_fn & 0xf8) >> 3, (int) devp->slot.device_fn & 7); for (j = 0 ; j < 4 ; j++) { Symbios_host *h = &nvram->data.Symbios.host[j]; - printk("ncr53c8xx: BOOT[%d] device_id=%04x vendor_id=%04x device_fn=%02x io_port=%04x %s\n", + printf("ncr53c8xx: BOOT[%d] device_id=%04x vendor_id=%04x device_fn=%02x io_port=%04x %s\n", j, h->device_id, h->vendor_id, h->device_fn, h->io_port, (h->flags & SYMBIOS_INIT_SCAN_AT_BOOT) ? "SCAN AT BOOT" : ""); @@ -9414,7 +9131,7 @@ ncr_attach_using_nvram(Scsi_Host_Template *tpnt, int nvram_index, int count, ncr } else if (nvram->type == SCSI_NCR_TEKRAM_NVRAM) { /* display Tekram nvram data */ - printk("ncr53c8xx: NVRAM: Tekram format data, 53c%s, PCI bus %d, device %d, function %d\n", + printf("ncr53c8xx: NVRAM: Tekram format data, 53c%s, PCI bus %d, device %d, function %d\n", devp->chip.name, devp->slot.bus, (int) (devp->slot.device_fn & 0xf8) >> 3, (int) devp->slot.device_fn & 7); @@ -9481,14 +9198,18 @@ int ncr53c8xx_detect(Scsi_Host_Template *tpnt) #ifdef SCSI_NCR_NVRAM_SUPPORT int nvram_index = 0; #endif + if (initverbose >= 2) + ncr_print_driver_setup(); #ifdef SCSI_NCR_DEBUG_INFO_SUPPORT ncr_debug = driver_setup.debug; #endif +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,0) tpnt->proc_dir = &proc_scsi_ncr53c8xx; -#ifdef SCSI_NCR_PROC_INFO_SUPPORT +# ifdef SCSI_NCR_PROC_INFO_SUPPORT tpnt->proc_info = ncr53c8xx_proc_info; +# endif #endif #if defined(SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT) && defined(MODULE) @@ -9496,9 +9217,6 @@ if (ncr53c8xx) ncr53c8xx_setup(ncr53c8xx, (int *) 0); #endif - if (initverbose >= 2) - ncr_print_driver_setup(); - /* ** Detect all 53c8xx hosts and then attach them. ** @@ -9510,11 +9228,7 @@ if (ncr53c8xx) ** the order they are detected. */ -#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,92) - if (!pci_present()) -#else if (!pcibios_present()) -#endif return 0; chips = sizeof(ncr_chip_ids) / sizeof(ncr_chip_ids[0]); @@ -9562,7 +9276,7 @@ if (ncr53c8xx) } } #endif - printk(KERN_INFO "ncr53c8xx: 53c%s detected %s\n", + printf(KERN_INFO "ncr53c8xx: 53c%s detected %s\n", device[count].chip.name, msg); ++count; } @@ -9578,7 +9292,7 @@ if (ncr53c8xx) for (i= 0; i < count; i++) { if (!device[i].attach_done && !ncr_attach (tpnt, attach_count, &device[i])) { - attach_count++; + attach_count++; } } @@ -9598,14 +9312,11 @@ static int ncr53c8xx_pci_init(Scsi_Host_Template *tpnt, { ushort vendor_id, device_id, command; uchar cache_line_size, latency_timer; - uchar revision; -#if LINUX_VERSION_CODE > LinuxVersionCode(2,1,92) - struct pci_dev *pdev; - ulong base, base_2, io_port; - uint irq; -#else - uchar irq; + uchar irq, revision; +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,0) uint base, base_2, io_port; +#else + ulong base, base_2; #endif int i; @@ -9614,6 +9325,8 @@ static int ncr53c8xx_pci_init(Scsi_Host_Template *tpnt, #endif ncr_chip *chip; + printk(KERN_INFO "ncr53c8xx: at PCI bus %d, device %d, function %d\n", + bus, (int) (device_fn & 0xf8) >> 3, (int) device_fn & 7); /* * Read info from the PCI config space. * pcibios_read_config_xxx() functions are assumed to be used for @@ -9627,29 +9340,16 @@ static int ncr53c8xx_pci_init(Scsi_Host_Template *tpnt, PCI_DEVICE_ID, &device_id); (void) pcibios_read_config_word(bus, device_fn, PCI_COMMAND, &command); -#if LINUX_VERSION_CODE > LinuxVersionCode(2,1,92) - pdev = pci_find_slot(bus, device_fn); - io_port = pdev->base_address[0]; - base = pdev->base_address[1]; - base_2 = pdev->base_address[2]; - irq = pdev->irq; -#else (void) pcibios_read_config_dword(bus, device_fn, PCI_BASE_ADDRESS_0, &io_port); (void) pcibios_read_config_dword(bus, device_fn, PCI_BASE_ADDRESS_1, &base); (void) pcibios_read_config_dword(bus, device_fn, PCI_BASE_ADDRESS_2, &base_2); - - /* Handle 64bit base adresses for 53C896. */ - if ((base & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == PCI_BASE_ADDRESS_MEM_TYPE_64) - (void) pcibios_read_config_dword(bus, device_fn, - PCI_BASE_ADDRESS_3, &base_2); - (void) pcibios_read_config_byte(bus, device_fn, - PCI_INTERRUPT_LINE, &irq); -#endif (void) pcibios_read_config_byte(bus, device_fn, PCI_CLASS_REVISION,&revision); + (void) pcibios_read_config_byte(bus, device_fn, + PCI_INTERRUPT_LINE, &irq); (void) pcibios_read_config_byte(bus, device_fn, PCI_CACHE_LINE_SIZE, &cache_line_size); (void) pcibios_read_config_byte(bus, device_fn, @@ -9669,34 +9369,6 @@ static int ncr53c8xx_pci_init(Scsi_Host_Template *tpnt, chip->revision_id = revision; break; } - -#if defined(__i386__) - /* - * Ignore Symbios chips controlled by SISL RAID controller. - */ - if (chip && (base_2 & PCI_BASE_ADDRESS_MEM_MASK)) { - unsigned int ScriptsSize, MagicValue; - vm_offset_t ScriptsRAM; - - if (chip->features & FE_RAM8K) - ScriptsSize = 8192; - else - ScriptsSize = 4096; - - ScriptsRAM = remap_pci_mem(base_2 & PCI_BASE_ADDRESS_MEM_MASK, - ScriptsSize); - if (ScriptsRAM) { - MagicValue = readl(ScriptsRAM + ScriptsSize - 16); - unmap_pci_mem(ScriptsRAM, ScriptsSize); - if (MagicValue == 0x52414944) - return -1; - } - } -#endif - - printk(KERN_INFO "ncr53c8xx: at PCI bus %d, device %d, function %d\n", - bus, (int) (device_fn & 0xf8) >> 3, (int) device_fn & 7); - if (!chip) { printk("ncr53c8xx: not initializing, device not supported\n"); return -1; @@ -9704,111 +9376,25 @@ static int ncr53c8xx_pci_init(Scsi_Host_Template *tpnt, #ifdef __powerpc__ /* - * Several fix-up for power/pc. + * Severall fix-up for power/pc. * Should not be performed by the driver. */ - if (!(command & PCI_COMMAND_MASTER)) { - printk("ncr53c8xx: attempting to force PCI_COMMAND_MASTER..."); - command |= PCI_COMMAND_MASTER; - pcibios_write_config_word(bus, device_fn, PCI_COMMAND, command); - pcibios_read_config_word(bus, device_fn, PCI_COMMAND, &command); - if (!(command & PCI_COMMAND_MASTER)) { - printk("failed!\n"); - } else { - printk("succeeded.\n"); - } - } - - if (!(command & PCI_COMMAND_IO)) { - printk("ncr53c8xx: attempting to force PCI_COMMAND_IO..."); - command |= PCI_COMMAND_IO; - pcibios_write_config_word(bus, device_fn, PCI_COMMAND, command); - pcibios_read_config_word(bus, device_fn, PCI_COMMAND, &command); - if (!(command & PCI_COMMAND_IO)) { - printk("failed!\n"); - } else { - printk("succeeded.\n"); - } - } - - if (!(command & PCI_COMMAND_MEMORY)) { - printk("ncr53c8xx: attempting to force PCI_COMMAND_MEMORY..."); - command |= PCI_COMMAND_MEMORY; - pcibios_write_config_word(bus, device_fn, PCI_COMMAND, command); - pcibios_read_config_word(bus, device_fn, PCI_COMMAND, &command); - if (!(command & PCI_COMMAND_MEMORY)) { - printk("failed!\n"); - } else { - printk("succeeded.\n"); - } - } - - if ( is_prep ) { - if (io_port >= 0x10000000) { - printk("ncr53c8xx: reallocating io_port (Wacky IBM)"); - io_port = (io_port & 0x00FFFFFF) | 0x01000000; - pcibios_write_config_dword(bus, device_fn, PCI_BASE_ADDRESS_0, io_port); - } - if (base >= 0x10000000) { - printk("ncr53c8xx: reallocating base (Wacky IBM)"); - base = (base & 0x00FFFFFF) | 0x01000000; - pcibios_write_config_dword(bus, device_fn, PCI_BASE_ADDRESS_1, base); - } - if (base_2 >= 0x10000000) { - printk("ncr53c8xx: reallocating base2 (Wacky IBM)"); - base_2 = (base_2 & 0x00FFFFFF) | 0x01000000; - pcibios_write_config_dword(bus, device_fn, PCI_BASE_ADDRESS_2, base_2); - } - } -#endif /* __powerpc__ */ - -#ifdef __sparc__ - /* - * Severall fix-ups for sparc. - * - * Should not be performed by the driver, but how can OBP know - * each and every PCI card, if they don't use Fcode? - */ - - base = __pa(base); - base_2 = __pa(base_2); - - if (!(command & PCI_COMMAND_MASTER)) { - if (initverbose >= 2) - printk("ncr53c8xx: setting PCI_COMMAND_MASTER bit (fixup)\n"); - command |= PCI_COMMAND_MASTER; - pcibios_write_config_word(bus, device_fn, PCI_COMMAND, command); - pcibios_read_config_word(bus, device_fn, PCI_COMMAND, &command); - } - - if ((chip->features & FE_WRIE) && !(command & PCI_COMMAND_INVALIDATE)) { - if (initverbose >= 2) - printk("ncr53c8xx: setting PCI_COMMAND_INVALIDATE bit (fixup)\n"); - command |= PCI_COMMAND_INVALIDATE; + if ((command & + (PCI_COMMAND_MASTER|PCI_COMMAND_IO|PCI_COMMAND_MEMORY)) != + (PCI_COMMAND_MASTER|PCI_COMMAND_IO|PCI_COMMAND_MEMORY)) { + printk("ncr53c8xx : setting PCI master/io/command bit\n"); + command |= PCI_COMMAND_MASTER|PCI_COMMAND_IO|PCI_COMMAND_MEMORY; pcibios_write_config_word(bus, device_fn, PCI_COMMAND, command); - pcibios_read_config_word(bus, device_fn, PCI_COMMAND, &command); } - - if ((chip->features & FE_CLSE) && !cache_line_size) { - cache_line_size = CACHE_LINE_SIZE; - if (initverbose >= 2) - printk("ncr53c8xx: setting PCI_CACHE_LINE_SIZE to %d (fixup)\n", cache_line_size); - pcibios_write_config_byte(bus, device_fn, - PCI_CACHE_LINE_SIZE, cache_line_size); - pcibios_read_config_byte(bus, device_fn, - PCI_CACHE_LINE_SIZE, &cache_line_size); + if (io_port >= 0x10000000) { + io_port = (io_port & 0x00FFFFFF) | 0x01000000; + pcibios_write_config_dword(bus, device_fn, PCI_BASE_ADDRESS_0, io_port); } - - if (!latency_timer) { - latency_timer = 248; - if (initverbose >= 2) - printk("ncr53c8xx: setting PCI_LATENCY_TIMER to %d bus clocks (fixup)\n", latency_timer); - pcibios_write_config_byte(bus, device_fn, - PCI_LATENCY_TIMER, latency_timer); - pcibios_read_config_byte(bus, device_fn, - PCI_LATENCY_TIMER, &latency_timer); + if (base >= 0x10000000) { + base = (base & 0x00FFFFFF) | 0x01000000; + pcibios_write_config_dword(bus, device_fn, PCI_BASE_ADDRESS_1, base); } -#endif /* __sparc__ */ +#endif /* * Check availability of IO space, memory space and master capability. @@ -9845,13 +9431,8 @@ static int ncr53c8xx_pci_init(Scsi_Host_Template *tpnt, base_2 &= PCI_BASE_ADDRESS_MEM_MASK; if (io_port && check_region (io_port, 128)) { -#ifdef __sparc__ - printk("ncr53c8xx: IO region 0x%lx to 0x%lx is in use\n", - io_port, (io_port + 127)); -#else printk("ncr53c8xx: IO region 0x%x to 0x%x is in use\n", (int) io_port, (int) (io_port + 127)); -#endif return -1; } @@ -9884,7 +9465,7 @@ static int ncr53c8xx_pci_init(Scsi_Host_Template *tpnt, /* * Try to fix up PCI config according to wished features. */ -#if defined(__i386__) && !defined(MODULE) +#if defined(__i386) && !defined(MODULE) if ((driver_setup.pci_fix_up & 1) && (chip->features & FE_CLSE) && cache_line_size == 0) { #if LINUX_VERSION_CODE < LinuxVersionCode(2,1,75) @@ -9894,7 +9475,6 @@ static int ncr53c8xx_pci_init(Scsi_Host_Template *tpnt, switch(boot_cpu_data.x86) { #endif case 4: cache_line_size = 4; break; - case 6: case 5: cache_line_size = 8; break; } if (cache_line_size) @@ -10030,111 +9610,35 @@ out: return 0; } +#if LINUX_VERSION_CODE >= LinuxVersionCode(2,0,0) /* ** Linux select queue depths function */ - -#define DEF_DEPTH (driver_setup.default_tags) -#define ALL_TARGETS -2 -#define NO_TARGET -1 -#define ALL_LUNS -2 -#define NO_LUN -1 - -static int device_queue_depth(ncb_p np, int target, int lun) -{ - int c, h, t, u, v; - char *p = driver_setup.tag_ctrl; - char *ep; - - h = -1; - t = NO_TARGET; - u = NO_LUN; - while ((c = *p++) != 0) { - v = simple_strtoul(p, &ep, 0); - switch(c) { - case '/': - ++h; - t = ALL_TARGETS; - u = ALL_LUNS; - break; - case 't': - if (t != target) - t = (target == v) ? v : NO_TARGET; - u = ALL_LUNS; - break; - case 'u': - if (u != lun) - u = (lun == v) ? v : NO_LUN; - break; - case 'q': - if (h == np->unit && - (t == ALL_TARGETS || t == target) && - (u == ALL_LUNS || u == lun)) - return v; - break; - case '-': - t = ALL_TARGETS; - u = ALL_LUNS; - break; - default: - break; - } - p = ep; - } - return DEF_DEPTH; -} - static void ncr53c8xx_select_queue_depths(struct Scsi_Host *host, struct scsi_device *devlist) { struct scsi_device *device; for (device = devlist; device; device = device->next) { - ncb_p np; - tcb_p tp; - lcb_p lp; - int numtags; - - if (device->host != host) - continue; - - np = ((struct host_data *) host->hostdata)->ncb; - tp = &np->target[device->id]; - lp = tp->lp[device->lun]; - - /* - ** Select queue depth from driver setup. - ** Donnot use more than configured by user. - ** Use at least 2. - ** Donnot use more than our maximum. - */ - numtags = device_queue_depth(np, device->id, device->lun); - if (numtags > tp->usrtags) - numtags = tp->usrtags; - if (!device->tagged_supported) - numtags = 1; - device->queue_depth = numtags; - if (device->queue_depth < 2) - device->queue_depth = 2; - if (device->queue_depth > SCSI_NCR_MAX_TAGS) - device->queue_depth = SCSI_NCR_MAX_TAGS; - - /* - ** Since the queue depth is not tunable under Linux, - ** we need to know this value in order not to - ** announce stupid things to user. - */ - if (lp) { - lp->numtags = lp->maxtags = numtags; - lp->scdev_depth = device->queue_depth; - } - ncr_setup_tags (np, device->id, device->lun); + if (device->host == host) { +#if SCSI_NCR_MAX_TAGS > 1 + if (device->tagged_supported) { + device->queue_depth = SCSI_NCR_MAX_TAGS; + } + else { + device->queue_depth = 2; + } +#else + device->queue_depth = 1; +#endif #ifdef DEBUG_NCR53C8XX -printk("ncr53c8xx_select_queue_depth: host=%d, id=%d, lun=%d, depth=%d\n", - np->unit, device->id, device->lun, device->queue_depth); +printk("ncr53c8xx_select_queue_depth: id=%d, lun=%d, queue_depth=%d\n", + device->id, device->lun, device->queue_depth); #endif + } } } +#endif /* ** Linux entry point of queuecommand() function @@ -10142,96 +9646,69 @@ printk("ncr53c8xx_select_queue_depth: host=%d, id=%d, lun=%d, depth=%d\n", int ncr53c8xx_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *)) { - ncb_p np = ((struct host_data *) cmd->host->hostdata)->ncb; - unsigned long flags; int sts; - #ifdef DEBUG_NCR53C8XX printk("ncr53c8xx_queue_command\n"); #endif - cmd->scsi_done = done; - cmd->host_scribble = NULL; - cmd->SCp.ptr = NULL; - cmd->SCp.buffer = NULL; - - NCR_LOCK_NCB(np, flags); - - if ((sts = ncr_queue_command(np, cmd)) != DID_OK) { + if ((sts = ncr_queue_command(cmd, done)) != DID_OK) { cmd->result = ScsiResult(sts, 0); + done(cmd); #ifdef DEBUG_NCR53C8XX printk("ncr53c8xx : command not queued - result=%d\n", sts); #endif + return sts; } #ifdef DEBUG_NCR53C8XX - else printk("ncr53c8xx : command successfully queued\n"); #endif - - NCR_UNLOCK_NCB(np, flags); - - if (sts != DID_OK) - done(cmd); - return sts; } /* ** Linux entry point of the interrupt handler. -** Since linux versions > 1.3.70, we trust the kernel for +** Fort linux versions > 1.3.70, we trust the kernel for ** passing the internal host descriptor as 'dev_id'. ** Otherwise, we scan the host list and call the interrupt ** routine for each host that uses this IRQ. */ +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,70) static void ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs) { - unsigned long flags; - ncb_p np = (ncb_p) dev_id; - Scsi_Cmnd *done_list; - #ifdef DEBUG_NCR53C8XX printk("ncr53c8xx : interrupt received\n"); #endif - if (DEBUG_FLAGS & DEBUG_TINY) printk ("["); - - NCR_LOCK_NCB(np, flags); - ncr_exception(np); - done_list = np->done_list; - np->done_list = 0; - NCR_UNLOCK_NCB(np, flags); - - if (DEBUG_FLAGS & DEBUG_TINY) printk ("]\n"); + if (DEBUG_FLAGS & DEBUG_TINY) printf ("["); + ncr_exception((ncb_p) dev_id); + if (DEBUG_FLAGS & DEBUG_TINY) printf ("]\n"); +} - if (done_list) { - NCR_LOCK_SCSI_DONE(np, flags); - ncr_flush_done_cmds(done_list); - NCR_UNLOCK_SCSI_DONE(np, flags); +#else +static void ncr53c8xx_intr(int irq, struct pt_regs * regs) +{ + struct Scsi_Host *host; + struct host_data *host_data; + + for (host = first_host; host; host = host->next) { + if (host->hostt == the_template && host->irq == irq) { + host_data = (struct host_data *) host->hostdata; + if (DEBUG_FLAGS & DEBUG_TINY) printf ("["); + ncr_exception(host_data->ncb); + if (DEBUG_FLAGS & DEBUG_TINY) printf ("]\n"); + } } } +#endif /* ** Linux entry point of the timer handler */ -static void ncr53c8xx_timeout(unsigned long npref) +static void ncr53c8xx_timeout(unsigned long np) { - ncb_p np = (ncb_p) npref; - unsigned long flags; - Scsi_Cmnd *done_list; - - NCR_LOCK_NCB(np, flags); ncr_timeout((ncb_p) np); - done_list = np->done_list; - np->done_list = 0; - NCR_UNLOCK_NCB(np, flags); - - if (done_list) { - NCR_LOCK_SCSI_DONE(np, flags); - ncr_flush_done_cmds(done_list); - NCR_UNLOCK_SCSI_DONE(np, flags); - } } /* @@ -10239,24 +9716,16 @@ static void ncr53c8xx_timeout(unsigned long npref) */ #if defined SCSI_RESET_SYNCHRONOUS && defined SCSI_RESET_ASYNCHRONOUS + int ncr53c8xx_reset(Scsi_Cmnd *cmd, unsigned int reset_flags) -#else -int ncr53c8xx_reset(Scsi_Cmnd *cmd) -#endif { - ncb_p np = ((struct host_data *) cmd->host->hostdata)->ncb; int sts; unsigned long flags; - Scsi_Cmnd *done_list; -#if defined SCSI_RESET_SYNCHRONOUS && defined SCSI_RESET_ASYNCHRONOUS printk("ncr53c8xx_reset: pid=%lu reset_flags=%x serial_number=%ld serial_number_at_timeout=%ld\n", cmd->pid, reset_flags, cmd->serial_number, cmd->serial_number_at_timeout); -#else - printk("ncr53c8xx_reset: command pid %lu\n", cmd->pid); -#endif - NCR_LOCK_NCB(np, flags); + save_flags(flags); cli(); /* * We have to just ignore reset requests in some situations. @@ -10274,13 +9743,8 @@ int ncr53c8xx_reset(Scsi_Cmnd *cmd) * before returning SCSI_RESET_SUCCESS. */ -#if defined SCSI_RESET_SYNCHRONOUS && defined SCSI_RESET_ASYNCHRONOUS - sts = ncr_reset_bus(np, cmd, + sts = ncr_reset_bus(cmd, (reset_flags & (SCSI_RESET_SYNCHRONOUS | SCSI_RESET_ASYNCHRONOUS)) == SCSI_RESET_SYNCHRONOUS); -#else - sts = ncr_reset_bus(np, cmd, 0); -#endif - /* * Since we always reset the controller, when we return success, * we add this information to the return code. @@ -10291,36 +9755,33 @@ int ncr53c8xx_reset(Scsi_Cmnd *cmd) #endif out: - done_list = np->done_list; - np->done_list = 0; - NCR_UNLOCK_NCB(np, flags); - - ncr_flush_done_cmds(done_list); - + restore_flags(flags); return sts; } +#else +int ncr53c8xx_reset(Scsi_Cmnd *cmd) +{ + printk("ncr53c8xx_reset: command pid %lu\n", cmd->pid); + return ncr_reset_bus(cmd, 1); +} +#endif /* ** Linux entry point of abort() function */ +#if defined SCSI_RESET_SYNCHRONOUS && defined SCSI_RESET_ASYNCHRONOUS + int ncr53c8xx_abort(Scsi_Cmnd *cmd) { - ncb_p np = ((struct host_data *) cmd->host->hostdata)->ncb; int sts; unsigned long flags; - Scsi_Cmnd *done_list; -#if defined SCSI_RESET_SYNCHRONOUS && defined SCSI_RESET_ASYNCHRONOUS printk("ncr53c8xx_abort: pid=%lu serial_number=%ld serial_number_at_timeout=%ld\n", cmd->pid, cmd->serial_number, cmd->serial_number_at_timeout); -#else - printk("ncr53c8xx_abort: command pid %lu\n", cmd->pid); -#endif - NCR_LOCK_NCB(np, flags); + save_flags(flags); cli(); -#if defined SCSI_RESET_SYNCHRONOUS && defined SCSI_RESET_ASYNCHRONOUS /* * We have to just ignore abort requests in some situations. */ @@ -10328,19 +9789,19 @@ int ncr53c8xx_abort(Scsi_Cmnd *cmd) sts = SCSI_ABORT_NOT_RUNNING; goto out; } -#endif - sts = ncr_abort_command(np, cmd); + sts = ncr_abort_command(cmd); out: - done_list = np->done_list; - np->done_list = 0; - NCR_UNLOCK_NCB(np, flags); - - ncr_flush_done_cmds(done_list); - + restore_flags(flags); return sts; } - +#else +int ncr53c8xx_abort(Scsi_Cmnd *cmd) +{ + printk("ncr53c8xx_abort: command pid %lu\n", cmd->pid); + return ncr_abort_command(cmd); +} +#endif #ifdef MODULE int ncr53c8xx_release(struct Scsi_Host *host) @@ -10375,7 +9836,7 @@ static void insert_into_waiting_list(ncb_p np, Scsi_Cmnd *cmd) Scsi_Cmnd *wcmd; #ifdef DEBUG_WAITING_LIST - printk("%s: cmd %lx inserted into waiting list\n", ncr_name(np), (u_long) cmd); + printf("%s: cmd %lx inserted into waiting list\n", ncr_name(np), (u_long) cmd); #endif cmd->next_wcmd = 0; if (!(wcmd = np->waiting_list)) np->waiting_list = cmd; @@ -10398,7 +9859,7 @@ static Scsi_Cmnd *retrieve_from_waiting_list(int to_remove, ncb_p np, Scsi_Cmnd cmd->next_wcmd = 0; } #ifdef DEBUG_WAITING_LIST - printk("%s: cmd %lx retrieved from waiting list\n", ncr_name(np), (u_long) cmd); + printf("%s: cmd %lx retrieved from waiting list\n", ncr_name(np), (u_long) cmd); #endif return cmd; } @@ -10414,29 +9875,70 @@ static void process_waiting_list(ncb_p np, int sts) np->waiting_list = 0; #ifdef DEBUG_WAITING_LIST - if (waiting_list) printk("%s: waiting_list=%lx processing sts=%d\n", ncr_name(np), (u_long) waiting_list, sts); + if (waiting_list) printf("%s: waiting_list=%lx processing sts=%d\n", ncr_name(np), (u_long) waiting_list, sts); #endif while ((wcmd = waiting_list) != 0) { waiting_list = (Scsi_Cmnd *) wcmd->next_wcmd; wcmd->next_wcmd = 0; if (sts == DID_OK) { #ifdef DEBUG_WAITING_LIST - printk("%s: cmd %lx trying to requeue\n", ncr_name(np), (u_long) wcmd); + printf("%s: cmd %lx trying to requeue\n", ncr_name(np), (u_long) wcmd); #endif - sts = ncr_queue_command(np, wcmd); + sts = ncr_queue_command(wcmd, wcmd->scsi_done); } if (sts != DID_OK) { #ifdef DEBUG_WAITING_LIST - printk("%s: cmd %lx done forced sts=%d\n", ncr_name(np), (u_long) wcmd, sts); + printf("%s: cmd %lx done forced sts=%d\n", ncr_name(np), (u_long) wcmd, sts); #endif wcmd->result = ScsiResult(sts, 0); - ncr_queue_done_cmd(np, wcmd); + wcmd->scsi_done(wcmd); } } } #undef next_wcmd +/* +** Returns data transfer direction for common op-codes. +*/ + +static int guess_xfer_direction(int opcode) +{ + int d; + + switch(opcode) { + case 0x12: /* INQUIRY 12 */ + case 0x4D: /* LOG SENSE 4D */ + case 0x5A: /* MODE SENSE(10) 5A */ + case 0x1A: /* MODE SENSE(6) 1A */ + case 0x3C: /* READ BUFFER 3C */ + case 0x1C: /* RECEIVE DIAGNOSTIC RESULTS 1C */ + case 0x03: /* REQUEST SENSE 03 */ + d = XferIn; + break; + case 0x39: /* COMPARE 39 */ + case 0x3A: /* COPY AND VERIFY 3A */ + case 0x18: /* COPY 18 */ + case 0x4C: /* LOG SELECT 4C */ + case 0x55: /* MODE SELECT(10) 55 */ + case 0x3B: /* WRITE BUFFER 3B */ + case 0x1D: /* SEND DIAGNOSTIC 1D */ + case 0x40: /* CHANGE DEFINITION 40 */ + case 0x15: /* MODE SELECT(6) 15 */ + d = XferOut; + break; + case 0x00: /* TEST UNIT READY 00 */ + d = XferNone; + break; + default: + d = XferBoth; + break; + } + + return d; +} + + #ifdef SCSI_NCR_PROC_INFO_SUPPORT /*========================================================================= @@ -10524,8 +10026,6 @@ static int ncr_user_command(ncb_p np, char *buffer, int length) uc->cmd = UC_SETTAGS; else if ((arg_len = is_keyword(ptr, len, "setorder")) != 0) uc->cmd = UC_SETORDER; - else if ((arg_len = is_keyword(ptr, len, "setverbose")) != 0) - uc->cmd = UC_SETVERBOSE; else if ((arg_len = is_keyword(ptr, len, "setwide")) != 0) uc->cmd = UC_SETWIDE; else if ((arg_len = is_keyword(ptr, len, "setdebug")) != 0) @@ -10534,11 +10034,15 @@ static int ncr_user_command(ncb_p np, char *buffer, int length) uc->cmd = UC_SETFLAG; else if ((arg_len = is_keyword(ptr, len, "clearprof")) != 0) uc->cmd = UC_CLEARPROF; +#ifdef UC_DEBUG_ERROR_RECOVERY + else if ((arg_len = is_keyword(ptr, len, "debug_error_recovery")) != 0) + uc->cmd = UC_DEBUG_ERROR_RECOVERY; +#endif else arg_len = 0; #ifdef DEBUG_PROC_INFO -printk("ncr_user_command: arg_len=%d, cmd=%ld\n", arg_len, uc->cmd); +printf("ncr_user_command: arg_len=%d, cmd=%ld\n", arg_len, uc->cmd); #endif if (!arg_len) @@ -10558,21 +10062,20 @@ printk("ncr_user_command: arg_len=%d, cmd=%ld\n", arg_len, uc->cmd); GET_INT_ARG(target); uc->target = (1<cmd) { - case UC_SETVERBOSE: case UC_SETSYNC: case UC_SETTAGS: case UC_SETWIDE: SKIP_SPACES(1); GET_INT_ARG(uc->data); #ifdef DEBUG_PROC_INFO -printk("ncr_user_command: data=%ld\n", uc->data); +printf("ncr_user_command: data=%ld\n", uc->data); #endif break; case UC_SETORDER: @@ -10620,7 +10123,7 @@ printk("ncr_user_command: data=%ld\n", uc->data); ptr += arg_len; len -= arg_len; } #ifdef DEBUG_PROC_INFO -printk("ncr_user_command: data=%ld\n", uc->data); +printf("ncr_user_command: data=%ld\n", uc->data); #endif break; case UC_SETFLAG: @@ -10635,6 +10138,24 @@ printk("ncr_user_command: data=%ld\n", uc->data); ptr += arg_len; len -= arg_len; } break; +#ifdef UC_DEBUG_ERROR_RECOVERY + case UC_DEBUG_ERROR_RECOVERY: + SKIP_SPACES(1); + if ((arg_len = is_keyword(ptr, len, "sge"))) + uc->data = 1; + else if ((arg_len = is_keyword(ptr, len, "abort"))) + uc->data = 2; + else if ((arg_len = is_keyword(ptr, len, "reset"))) + uc->data = 3; + else if ((arg_len = is_keyword(ptr, len, "parity"))) + uc->data = 4; + else if ((arg_len = is_keyword(ptr, len, "none"))) + uc->data = 0; + else + return -EINVAL; + ptr += arg_len; len -= arg_len; + break; +#endif default: break; } @@ -10644,9 +10165,9 @@ printk("ncr_user_command: data=%ld\n", uc->data); else { long flags; - NCR_LOCK_NCB(np, flags); + save_flags(flags); cli(); ncr_usercmd (np); - NCR_UNLOCK_NCB(np, flags); + restore_flags(flags); } return length; } @@ -10718,11 +10239,7 @@ static int ncr_host_info(ncb_p np, char *ptr, off_t offset, int len) copy_info(&info, "revision id 0x%x\n", np->revision_id); copy_info(&info, " IO port address 0x%lx, ", (u_long) np->port); -#ifdef __sparc__ - copy_info(&info, "IRQ number %s\n", __irq_itoa(np->irq)); -#else copy_info(&info, "IRQ number %d\n", (int) np->irq); -#endif #ifndef NCR_IOMAPPED if (np->reg) @@ -10771,7 +10288,7 @@ int ncr53c8xx_proc_info(char *buffer, char **start, off_t offset, int retv; #ifdef DEBUG_PROC_INFO -printk("ncr53c8xx_proc_info: hostno=%d, func=%d\n", hostno, func); +printf("ncr53c8xx_proc_info: hostno=%d, func=%d\n", hostno, func); #endif for (host = first_host; host; host = host->next) { @@ -10909,7 +10426,7 @@ static int ncr_get_Symbios_nvram (ncr_slot *np, Symbios_nvram *nvram) nvram_stop(np, &gpreg); #ifdef SCSI_NCR_DEBUG_NVRAM -printk("ncr53c8xx: NvRAM marker=%x trailer=%x %x %x %x %x %x byte_count=%d/%d checksum=%x/%x\n", +printf("ncr53c8xx: NvRAM marker=%x trailer=%x %x %x %x %x %x byte_count=%d/%d checksum=%x/%x\n", nvram->start_marker, nvram->trailer[0], nvram->trailer[1], nvram->trailer[2], nvram->trailer[3], nvram->trailer[4], nvram->trailer[5], @@ -11059,7 +10576,7 @@ __initfunc( static void nvram_setBit(ncr_slot *np, u_char write_bit, u_char *gpreg, int bit_mode) ) { - UDELAY (5); + DELAY(5); switch (bit_mode){ case SET_BIT: *gpreg |= write_bit; @@ -11076,7 +10593,7 @@ static void nvram_setBit(ncr_slot *np, u_char write_bit, u_char *gpreg, int bit_ } OUTB (nc_gpreg, *gpreg); - UDELAY (5); + DELAY(5); } #undef SET_BIT 0 @@ -11213,7 +10730,7 @@ __initfunc( static void Tnvram_Read_Bit(ncr_slot *np, u_char *read_bit, u_char *gpreg) ) { - UDELAY (2); + DELAY(2); Tnvram_Clk(np, gpreg); *read_bit = INB (nc_gpreg); } @@ -11233,7 +10750,7 @@ static void Tnvram_Write_Bit(ncr_slot *np, u_char write_bit, u_char *gpreg) *gpreg |= 0x10; OUTB (nc_gpreg, *gpreg); - UDELAY (2); + DELAY(2); Tnvram_Clk(np, gpreg); } @@ -11247,7 +10764,7 @@ static void Tnvram_Stop(ncr_slot *np, u_char *gpreg) { *gpreg &= 0xef; OUTB (nc_gpreg, *gpreg); - UDELAY (2); + DELAY(2); Tnvram_Clk(np, gpreg); } @@ -11260,7 +10777,7 @@ static void Tnvram_Clk(ncr_slot *np, u_char *gpreg) ) { OUTB (nc_gpreg, *gpreg | 0x04); - UDELAY (2); + DELAY(2); OUTB (nc_gpreg, *gpreg); } diff --git a/drivers/scsi/ncr53c8xx.h b/drivers/scsi/ncr53c8xx.h index 39d0a3c399f9..cc009ca64360 100644 --- a/drivers/scsi/ncr53c8xx.h +++ b/drivers/scsi/ncr53c8xx.h @@ -45,7 +45,7 @@ /* ** Name and revision of the driver */ -#define SCSI_NCR_DRIVER_NAME "ncr53c8xx - revision 3.1e" +#define SCSI_NCR_DRIVER_NAME "ncr53c8xx - revision 2.5f.1" /* ** Check supported Linux versions @@ -56,34 +56,51 @@ #endif #include +/* +** During make dep of linux-1.2.13, LINUX_VERSION_CODE is undefined +** Under linux-1.3.X, all seems to be OK. +** So, we have only to define it under 1.2.13 +*/ + #define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s)) -/* - * No more an option, enabled by default. - */ -#ifndef CONFIG_SCSI_NCR53C8XX_NVRAM_DETECT -#define CONFIG_SCSI_NCR53C8XX_NVRAM_DETECT +#if !defined(LINUX_VERSION_CODE) +#define LINUX_VERSION_CODE LinuxVersionCode(1,2,13) #endif /* -** These options are not tunable from 'make config' +** Normal IO or memory mapped IO. +** +** Memory mapped IO only works with linux-1.3.X +** If your motherboard does not work with memory mapped IO, +** define SCSI_NCR_IOMAPPED for PATCHLEVEL 3 too. */ -#define SCSI_NCR_PROC_INFO_SUPPORT -#define SCSI_NCR_SHARE_IRQ + +#if LINUX_VERSION_CODE < LinuxVersionCode(1,3,0) +# define SCSI_NCR_IOMAPPED +#endif + +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,0) +# define SCSI_NCR_PROC_INFO_SUPPORT +#endif + +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,72) +# define SCSI_NCR_SHARE_IRQ +#endif /* ** If you want a driver as small as possible, donnot define the ** following options. */ + #define SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT #define SCSI_NCR_DEBUG_INFO_SUPPORT #define SCSI_NCR_PCI_FIX_UP_SUPPORT #ifdef SCSI_NCR_PROC_INFO_SUPPORT -# ifdef CONFIG_SCSI_NCR53C8XX_PROFILE -# define SCSI_NCR_PROFILE_SUPPORT -# endif +# define SCSI_NCR_PROFILE_SUPPORT # define SCSI_NCR_USER_COMMAND_SUPPORT # define SCSI_NCR_USER_INFO_SUPPORT +/* # define SCSI_NCR_DEBUG_ERROR_RECOVERY_SUPPORT */ #endif /*========================================================== @@ -113,27 +130,25 @@ #define SCSI_NCR_MAX_SYNC (40) /* - * Allow tags from 2 to 64, default 8 + * Allow tags from 2 to 12, default 4 */ #ifdef CONFIG_SCSI_NCR53C8XX_MAX_TAGS #if CONFIG_SCSI_NCR53C8XX_MAX_TAGS < 2 #define SCSI_NCR_MAX_TAGS (2) -#elif CONFIG_SCSI_NCR53C8XX_MAX_TAGS > 64 -#define SCSI_NCR_MAX_TAGS (64) +#elif CONFIG_SCSI_NCR53C8XX_MAX_TAGS > 12 +#define SCSI_NCR_MAX_TAGS (12) #else #define SCSI_NCR_MAX_TAGS CONFIG_SCSI_NCR53C8XX_MAX_TAGS #endif #else -#define SCSI_NCR_MAX_TAGS (8) +#define SCSI_NCR_MAX_TAGS (4) #endif /* * Allow tagged command queuing support if configured with default number * of tags set to max (see above). */ -#ifdef CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS -#define SCSI_NCR_SETUP_DEFAULT_TAGS CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS -#elif defined CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE +#ifdef CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE #define SCSI_NCR_SETUP_DEFAULT_TAGS SCSI_NCR_MAX_TAGS #else #define SCSI_NCR_SETUP_DEFAULT_TAGS (0) @@ -146,19 +161,16 @@ #define SCSI_NCR_IOMAPPED #elif defined(__alpha__) || defined(__powerpc__) #define SCSI_NCR_IOMAPPED -#elif defined(__sparc__) -#undef SCSI_NCR_IOMAPPED #endif /* * Sync transfer frequency at startup. - * Allow from 5Mhz to 40Mhz default 20 Mhz. + * Allow from 5Mhz to 40Mhz default 10 Mhz. */ #ifndef CONFIG_SCSI_NCR53C8XX_SYNC -#define CONFIG_SCSI_NCR53C8XX_SYNC (20) +#define CONFIG_SCSI_NCR53C8XX_SYNC (5) #elif CONFIG_SCSI_NCR53C8XX_SYNC > SCSI_NCR_MAX_SYNC -#undef CONFIG_SCSI_NCR53C8XX_SYNC -#define CONFIG_SCSI_NCR53C8XX_SYNC SCSI_NCR_MAX_SYNC +#define SCSI_NCR_SETUP_DEFAULT_SYNC SCSI_NCR_MAX_SYNC #endif #if CONFIG_SCSI_NCR53C8XX_SYNC == 0 @@ -233,18 +245,14 @@ #define SCSI_NCR_ALWAYS_SIMPLE_TAG #define SCSI_NCR_MAX_SCATTER (127) #define SCSI_NCR_MAX_TARGET (16) +#define SCSI_NCR_MAX_HOST (2) +#define SCSI_NCR_TIMEOUT_ALERT (3*HZ) -/* No need to use a too large adapter queue */ -#if SCSI_NCR_MAX_TAGS <= 32 #define SCSI_NCR_CAN_QUEUE (7*SCSI_NCR_MAX_TAGS) -#else -#define SCSI_NCR_CAN_QUEUE (250) -#endif - #define SCSI_NCR_CMD_PER_LUN (SCSI_NCR_MAX_TAGS) #define SCSI_NCR_SG_TABLESIZE (SCSI_NCR_MAX_SCATTER) -#define SCSI_NCR_TIMER_INTERVAL (HZ) +#define SCSI_NCR_TIMER_INTERVAL ((HZ+5-1)/5) #if 1 /* defined CONFIG_SCSI_MULTI_LUN */ #define SCSI_NCR_MAX_LUN (8) @@ -260,12 +268,21 @@ #if defined(HOSTS_C) || defined(MODULE) +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,98) #include +#else +#include +#endif int ncr53c8xx_abort(Scsi_Cmnd *); int ncr53c8xx_detect(Scsi_Host_Template *tpnt); int ncr53c8xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); + +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,98) int ncr53c8xx_reset(Scsi_Cmnd *, unsigned int); +#else +int ncr53c8xx_reset(Scsi_Cmnd *); +#endif #ifdef MODULE int ncr53c8xx_release(struct Scsi_Host *); @@ -287,22 +304,34 @@ int ncr53c8xx_release(struct Scsi_Host *); sg_tablesize: SCSI_NCR_SG_TABLESIZE, \ cmd_per_lun: SCSI_NCR_CMD_PER_LUN, \ use_clustering: DISABLE_CLUSTERING} + +#elif LINUX_VERSION_CODE >= LinuxVersionCode(1,3,0) + +#define NCR53C8XX { NULL, NULL, NULL, NULL, \ + SCSI_NCR_DRIVER_NAME, ncr53c8xx_detect, \ + ncr53c8xx_release, NULL, NULL, \ + ncr53c8xx_queue_command,ncr53c8xx_abort, \ + ncr53c8xx_reset, NULL, scsicam_bios_param, \ + SCSI_NCR_CAN_QUEUE, 7, \ + SCSI_NCR_SG_TABLESIZE, SCSI_NCR_CMD_PER_LUN, \ + 0, 0, DISABLE_CLUSTERING} #else -#define NCR53C8XX { NULL, NULL, NULL, NULL, \ +#define NCR53C8XX { NULL, NULL, \ SCSI_NCR_DRIVER_NAME, ncr53c8xx_detect, \ - ncr53c8xx_release, NULL, NULL, \ + ncr53c8xx_release, NULL, NULL, \ ncr53c8xx_queue_command,ncr53c8xx_abort, \ ncr53c8xx_reset, NULL, scsicam_bios_param, \ SCSI_NCR_CAN_QUEUE, 7, \ SCSI_NCR_SG_TABLESIZE, SCSI_NCR_CMD_PER_LUN, \ 0, 0, DISABLE_CLUSTERING} - + #endif /* LINUX_VERSION_CODE */ #endif /* defined(HOSTS_C) || defined(MODULE) */ + #ifndef HOSTS_C /* @@ -318,18 +347,13 @@ int ncr53c8xx_release(struct Scsi_Host *); #error "BIG ENDIAN byte ordering needs kernel version >= 2.1.0" #endif -#if defined(__powerpc__) +#ifdef __powerpc__ #define inw_l2b inw #define inl_l2b inl #define outw_b2l outw #define outl_b2l outl -#elif defined(__sparc__) -#define readw_l2b readw -#define readl_l2b readl -#define writew_b2l writew -#define writel_b2l writel #else -#error "Support for BIG ENDIAN is only available for PowerPC and SPARC" +#error "Support for BIG ENDIAN is only available for the PowerPC" #endif #else /* Assumed x86 or alpha */ @@ -424,10 +448,6 @@ typedef struct { #define FE_LDSTR (1<<13) #define FE_RAM (1<<14) #define FE_CLK80 (1<<15) -#define FE_RAM8K (1<<16) -#define FE_64BIT (1<<17) -#define FE_IO256 (1<<18) -#define FE_NOPM (1<<19) #define FE_CACHE_SET (FE_ERL|FE_CLSE|FE_WRIE|FE_ERMP) #define FE_SCSI_SET (FE_WIDE|FE_ULTRA|FE_ULTRA2|FE_DBLR|FE_QUAD|F_CLK80) #define FE_SPECIAL_SET (FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM) @@ -472,10 +492,7 @@ typedef struct { {PCI_DEVICE_ID_NCR_53C875, 0x01, "875", 6, 16, 5, \ FE_WIDE|FE_ULTRA|FE_CLK80|FE_CACHE0_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM}\ , \ - {PCI_DEVICE_ID_NCR_53C875, 0x0f, "875", 6, 16, 5, \ - FE_WIDE|FE_ULTRA|FE_DBLR|FE_CACHE0_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM}\ - , \ - {PCI_DEVICE_ID_NCR_53C875, 0xff, "876", 6, 16, 5, \ + {PCI_DEVICE_ID_NCR_53C875, 0xff, "875", 6, 16, 5, \ FE_WIDE|FE_ULTRA|FE_DBLR|FE_CACHE0_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM}\ , \ {PCI_DEVICE_ID_NCR_53C875J,0xff, "875J", 6, 16, 5, \ @@ -488,8 +505,7 @@ typedef struct { FE_WIDE|FE_ULTRA2|FE_QUAD|FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM}\ , \ {PCI_DEVICE_ID_NCR_53C896, 0xff, "896", 7, 31, 7, \ - FE_WIDE|FE_ULTRA2|FE_QUAD|FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM|\ - FE_RAM8K|FE_64BIT|FE_IO256|FE_NOPM}\ + FE_WIDE|FE_ULTRA2|FE_QUAD|FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM}\ } /* @@ -566,6 +582,94 @@ typedef struct { 1 \ } +/* +** Define the table of target capabilities by host and target +** +** If you have problems with a scsi device, note the host unit and the +** corresponding target number. +** +** Edit the corresponding entry of the table below and try successively: +** NQ7_Questionnable +** NQ7_IdeLike +** +** This bitmap is anded with the byte 7 of inquiry data on completion of +** INQUIRY command. +** The driver never see the zeroed bits and will ignore the corresponding +** capabilities of the target. +*/ + +#define INQ7_SftRe 1 +#define INQ7_CmdQueue (1<<1) /* Tagged Command */ +#define INQ7_Reserved (1<<2) +#define INQ7_Linked (1<<3) +#define INQ7_Sync (1<<4) /* Synchronous Negotiation */ +#define INQ7_WBus16 (1<<5) +#define INQ7_WBus32 (1<<6) +#define INQ7_RelAdr (1<<7) + +#define INQ7_IdeLike 0 +#define INQ7_Scsi1Like INQ7_IdeLike +#define INQ7_Perfect 0xff +#define INQ7_Questionnable ~(INQ7_CmdQueue|INQ7_Sync) +#define INQ7_VeryQuestionnable \ + ~(INQ7_CmdQueue|INQ7_Sync|INQ7_WBus16|INQ7_WBus32) + +#define INQ7_Default INQ7_Perfect + +#define NCR53C8XX_TARGET_CAPABILITIES \ +/* Host 0 */ \ +{ \ + { \ + /* Target 0 */ INQ7_Default, \ + /* Target 1 */ INQ7_Default, \ + /* Target 2 */ INQ7_Default, \ + /* Target 3 */ INQ7_Default, \ + /* Target 4 */ INQ7_Default, \ + /* Target 5 */ INQ7_Default, \ + /* Target 6 */ INQ7_Default, \ + /* Target 7 */ INQ7_Default, \ + /* Target 8 */ INQ7_Default, \ + /* Target 9 */ INQ7_Default, \ + /* Target 10 */ INQ7_Default, \ + /* Target 11 */ INQ7_Default, \ + /* Target 12 */ INQ7_Default, \ + /* Target 13 */ INQ7_Default, \ + /* Target 14 */ INQ7_Default, \ + /* Target 15 */ INQ7_Default, \ + } \ +}, \ +/* Host 1 */ \ +{ \ + { \ + /* Target 0 */ INQ7_Default, \ + /* Target 1 */ INQ7_Default, \ + /* Target 2 */ INQ7_Default, \ + /* Target 3 */ INQ7_Default, \ + /* Target 4 */ INQ7_Default, \ + /* Target 5 */ INQ7_Default, \ + /* Target 6 */ INQ7_Default, \ + /* Target 7 */ INQ7_Default, \ + /* Target 8 */ INQ7_Default, \ + /* Target 9 */ INQ7_Default, \ + /* Target 10 */ INQ7_Default, \ + /* Target 11 */ INQ7_Default, \ + /* Target 12 */ INQ7_Default, \ + /* Target 13 */ INQ7_Default, \ + /* Target 14 */ INQ7_Default, \ + /* Target 15 */ INQ7_Default, \ + } \ +} + +/* +** Replace the proc_dir_entry of the standard ncr driver. +*/ + +#if LINUX_VERSION_CODE >= LinuxVersionCode(1,3,0) +#if defined(CONFIG_SCSI_NCR53C7xx) || !defined(CONFIG_SCSI_NCR53C8XX) +#define PROC_SCSI_NCR53C8XX PROC_SCSI_NCR53C7xx +#endif +#endif + /**************** ORIGINAL CONTENT of ncrreg.h from FreeBSD ******************/ /*----------------------------------------------------------------- @@ -690,11 +794,7 @@ struct ncr_reg { /*28*/ u_int32 nc_dnad; /* ### Next command register */ /*2c*/ u_int32 nc_dsp; /* --> Script Pointer */ /*30*/ u_int32 nc_dsps; /* --> Script pointer save/opcode#2 */ - -/*34*/ u_char nc_scratcha; /* Temporary register a */ -/*35*/ u_char nc_scratcha1; -/*36*/ u_char nc_scratcha2; -/*37*/ u_char nc_scratcha3; +/*34*/ u_int32 nc_scratcha; /* ??? Temporary register a */ /*38*/ u_char nc_dmode; #define BL_2 0x80 /* mod: burst length shift value +2 */ @@ -768,20 +868,7 @@ struct ncr_reg { /*53*/ u_char nc_53_; /*54*/ u_short nc_sodl; /* Lowlevel: data out to scsi data */ -/*56*/ u_char nc_ccntl0; /* Chip Control 0 (896) */ - #define ENPMJ 0x80 /* Enable Phase Mismatch Jump */ - #define PMJCTL 0x40 /* Phase Mismatch Jump Control */ - #define ENNDJ 0x20 /* Enable Non Data PM Jump */ - #define DISFC 0x10 /* Disable Auto FIFO Clear */ - #define DILS 0x02 /* Disable Internal Load/Store */ - #define DPR 0x01 /* Disable Pipe Req */ - -/*57*/ u_char nc_ccntl1; /* Chip Control 1 (896) */ - #define ZMOD 0x80 /* High Impedance Mode */ - #define DDAC 0x08 /* Disable Dual Address Cycle */ - #define XTIMOD 0x04 /* 64-bit Table Ind. Indexing Mode */ - #define EXTIBMV 0x02 /* Enable 64-bit Table Ind. BMOV */ - #define EXDBMV 0x01 /* Enable 64-bit Direct BMOV */ +/*56*/ u_short nc_56_; /*58*/ u_short nc_sbdl; /* Lowlevel: data from scsi data */ /*5a*/ u_short nc_5a_; /*5c*/ u_char nc_scr0; /* Working register B */ @@ -986,10 +1073,10 @@ struct scr_tblsel { /*----------------------------------------------------------- ** -** FROM_REG (reg) SFBR = reg +** FROM_REG (reg) reg = SFBR ** << 0 >> ** -** TO_REG (reg) reg = SFBR +** TO_REG (reg) SFBR = reg ** << 0 >> ** ** LOAD_REG (reg, data) reg = @@ -1013,42 +1100,6 @@ struct scr_tblsel { #define SCR_LOAD_SFBR(data) \ (SCR_REG_SFBR (gpreg, SCR_LOAD, data)) -/*----------------------------------------------------------- -** -** LOAD from memory to register. -** STORE from register to memory. -** -**----------------------------------------------------------- -** -** LOAD_ABS (LEN) -** <> -** -** LOAD_REL (LEN) (DSA relative) -** <> -** -**----------------------------------------------------------- -*/ - -#define SCR_NO_FLUSH2 0x02000000 -#define SCR_DSA_REL2 0x10000000 - -#define SCR_LOAD_R(reg, how, n) \ - (0xe1000000 | how | (SCR_REG_OFS(REG(reg))) | (n)) - -#define SCR_STORE_R(reg, how, n) \ - (0xe0000000 | how | (SCR_REG_OFS(REG(reg))) | (n)) - -#define SCR_LOAD_ABS(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2, n) -#define SCR_LOAD_REL(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n) -#define SCR_LOAD_ABS_F(reg, n) SCR_LOAD_R(reg, 0, n) -#define SCR_LOAD_REL_F(reg, n) SCR_LOAD_R(reg, SCR_DSA_REL2, n) - -#define SCR_STORE_ABS(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2, n) -#define SCR_STORE_REL(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n) -#define SCR_STORE_ABS_F(reg, n) SCR_STORE_R(reg, 0, n) -#define SCR_STORE_REL_F(reg, n) SCR_STORE_R(reg, SCR_DSA_REL2, n) - - /*----------------------------------------------------------- ** ** Waiting for Disconnect or Reselect @@ -1085,7 +1136,7 @@ struct scr_tblsel { **----------------------------------------------------------- */ -#define SCR_NO_OP 0x80000000 +#define SCR_NO_OP 0x80000000 #define SCR_JUMP 0x80080000 #define SCR_JUMPR 0x80880000 #define SCR_CALL 0x88080000 diff --git a/drivers/scsi/pci2000.c b/drivers/scsi/pci2000.c deleted file mode 100644 index c6a13d832033..000000000000 --- a/drivers/scsi/pci2000.c +++ /dev/null @@ -1,716 +0,0 @@ -/*+M************************************************************************* - * Perceptive Solutions, Inc. PCI-2000 device driver proc support for Linux. - * - * Copyright (c) 1997 Perceptive Solutions, 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; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * File Name: pci2000i.c - * - * Revisions 1.10 Jan-21-1999 - * - * - Fixed sign on message to reflect proper controller name. - * - Added support for RAID status monitoring and control. - * - *-M*************************************************************************/ -#define PCI2000_VERSION "1.10" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "scsi.h" -#include "hosts.h" - -#include "pci2000.h" -#include "psi_roy.h" - -#include - -struct proc_dir_entry Proc_Scsi_Pci2000 = - { PROC_SCSI_PCI2000, 7, "pci2000", S_IFDIR | S_IRUGO | S_IXUGO, 2 }; - -//#define DEBUG 1 - -#ifdef DEBUG -#define DEB(x) x -#define STOP_HERE {int st;for(st=0;st<100;st++){st=1;}} -#else -#define DEB(x) -#define STOP_HERE -#endif - -typedef struct - { - ULONG address; - ULONG length; - } SCATGATH, *PSCATGATH; - -typedef struct - { - Scsi_Cmnd *SCpnt; - SCATGATH scatGath[16]; - UCHAR tag; - } DEV2000, *PDEV2000; - -typedef struct - { - USHORT basePort; - USHORT mb0; - USHORT mb1; - USHORT mb2; - USHORT mb3; - USHORT mb4; - USHORT cmd; - USHORT tag; - DEV2000 dev[MAX_BUS][MAX_UNITS]; - } ADAPTER2000, *PADAPTER2000; - -#define HOSTDATA(host) ((PADAPTER2000)&host->hostdata) - - -static struct Scsi_Host *PsiHost[MAXADAPTER] = {NULL,}; // One for each adapter -static int NumAdapters = 0; -/**************************************************************** - * Name: WaitReady :LOCAL - * - * Description: Wait for controller ready. - * - * Parameters: padapter - Pointer adapter data structure. - * - * Returns: TRUE on not ready. - * - ****************************************************************/ -static int WaitReady (PADAPTER2000 padapter) - { - ULONG timer; - - timer = jiffies + TIMEOUT_COMMAND; // calculate the timeout value - do { - if ( !inb_p (padapter->cmd) ) - return FALSE; - } while ( timer > jiffies ); // test for timeout - return TRUE; - } -/**************************************************************** - * Name: OpDone :LOCAL - * - * Description: Clean up operation and issue done to caller. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * status - Caller status. - * - * Returns: Nothing. - * - ****************************************************************/ -static void OpDone (Scsi_Cmnd *SCpnt, ULONG status) - { - SCpnt->result = status; - SCpnt->scsi_done (SCpnt); - } -/**************************************************************** - * Name: Command :LOCAL - * - * Description: Issue queued command to the PCI-2000. - * - * Parameters: padapter - Pointer to adapter information structure. - * cmd - PCI-2000 command byte. - * - * Returns: Non-zero command tag if operation is accepted. - * - ****************************************************************/ -static UCHAR Command (PADAPTER2000 padapter, UCHAR cmd) - { - outb_p (cmd, padapter->cmd); - if ( WaitReady (padapter) ) - return 0; - - if ( inw_p (padapter->mb0) ) - return 0; - - return inb_p (padapter->mb1); - } -/**************************************************************** - * Name: BuildSgList :LOCAL - * - * Description: Build the scatter gather list for controller. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * padapter - Pointer to adapter information structure. - * pdev - Pointer to adapter device structure. - * - * Returns: Non-zero in not scatter gather. - * - ****************************************************************/ -static int BuildSgList (Scsi_Cmnd *SCpnt, PADAPTER2000 padapter, PDEV2000 pdev) - { - int z; - - if ( SCpnt->use_sg ) - { - for ( z = 0; z < SCpnt->use_sg; z++ ) - { - pdev->scatGath[z].address = virt_to_bus (((struct scatterlist *)SCpnt->request_buffer)[z].address); - pdev->scatGath[z].length = ((struct scatterlist *)SCpnt->request_buffer)[z].length; - } - outl (virt_to_bus (pdev->scatGath), padapter->mb2); - outl ((SCpnt->use_sg << 24) | SCpnt->request_bufflen, padapter->mb3); - return FALSE; - } - outl (virt_to_bus (SCpnt->request_buffer), padapter->mb2); - outl (SCpnt->request_bufflen, padapter->mb3); - return TRUE; - } -/********************************************************************* - * Name: PsiRaidCmd - * - * Description: Execute a simple command. - * - * Parameters: padapter - Pointer to adapter control structure. - * cmd - Roy command byte. - * - * Returns: Return error status. - * - ********************************************************************/ -static int PsiRaidCmd (PADAPTER2000 padapter, char cmd) - { - if ( WaitReady (padapter) ) // test for command register ready - return DID_TIME_OUT; - outb_p (cmd, padapter->cmd); // issue command - if ( WaitReady (padapter) ) // wait for adapter ready - return DID_TIME_OUT; - return DID_OK; - } -/**************************************************************** - * Name: Irq_Handler :LOCAL - * - * Description: Interrupt handler. - * - * Parameters: irq - Hardware IRQ number. - * dev_id - - * regs - - * - * Returns: TRUE if drive is not ready in time. - * - ****************************************************************/ -static void Irq_Handler (int irq, void *dev_id, struct pt_regs *regs) - { - struct Scsi_Host *shost = NULL; // Pointer to host data block - PADAPTER2000 padapter; // Pointer to adapter control structure - PDEV2000 pdev; - Scsi_Cmnd *SCpnt; - UCHAR tag = 0; - UCHAR tag0; - ULONG error; - int pun; - int bus; - int z; - - DEB(printk ("\npci2000 recieved interrupt ")); - for ( z = 0; z < NumAdapters; z++ ) // scan for interrupt to process - { - if ( PsiHost[z]->irq == (UCHAR)(irq & 0xFF) ) - { - tag = inb_p (HOSTDATA(PsiHost[z])->tag); - if ( tag ) - { - shost = PsiHost[z]; - break; - } - } - } - - if ( !shost ) - { - DEB (printk ("\npci2000: not my interrupt")); - return; - } - - padapter = HOSTDATA(shost); - - tag0 = tag & 0x7F; // mask off the error bit - for ( bus = 0; bus < MAX_BUS; bus++ ) // scan the busses - { - for ( pun = 0; pun < MAX_UNITS; pun++ ) // scan the targets - { - pdev = &padapter->dev[bus][pun]; - if ( !pdev->tag ) - continue; - if ( pdev->tag == tag0 ) // is this it? - { - pdev->tag = 0; - SCpnt = pdev->SCpnt; - goto irqProceed; - } - } - } - - outb_p (0xFF, padapter->tag); // clear the op interrupt - outb_p (CMD_DONE, padapter->cmd); // complete the op - return; // done, but, with what? - -irqProceed:; - if ( tag & ERR08_TAGGED ) // is there an error here? - { - if ( WaitReady (padapter) ) - { - OpDone (SCpnt, DID_TIME_OUT << 16); - return; - } - - outb_p (tag0, padapter->mb0); // get real error code - outb_p (CMD_ERROR, padapter->cmd); - if ( WaitReady (padapter) ) // wait for controller to suck up the op - { - OpDone (SCpnt, DID_TIME_OUT << 16); - return; - } - - error = inl (padapter->mb0); // get error data - outb_p (0xFF, padapter->tag); // clear the op interrupt - outb_p (CMD_DONE, padapter->cmd); // complete the op - - DEB (printk ("status: %lX ", error)); - if ( error == 0x00020002 ) // is this error a check condition? - { - if ( bus ) // are we doint SCSI commands? - { - OpDone (SCpnt, (DID_OK << 16) | 2); - return; - } - if ( *SCpnt->cmnd == SCSIOP_TEST_UNIT_READY ) - OpDone (SCpnt, (DRIVER_SENSE << 24) | (DID_OK << 16) | 2); // test caller we have sense data too - else - OpDone (SCpnt, DID_ERROR << 16); - return; - } - OpDone (SCpnt, DID_ERROR << 16); - return; - } - - outb_p (0xFF, padapter->tag); // clear the op interrupt - outb_p (CMD_DONE, padapter->cmd); // complete the op - OpDone (SCpnt, DID_OK << 16); - } -/**************************************************************** - * Name: Pci2220i_QueueCommand - * - * Description: Process a queued command from the SCSI manager. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * done - Pointer to done function to call. - * - * Returns: Status code. - * - ****************************************************************/ -int Pci2000_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) - { - UCHAR *cdb = (UCHAR *)SCpnt->cmnd; // Pointer to SCSI CDB - PADAPTER2000 padapter = HOSTDATA(SCpnt->host); // Pointer to adapter control structure - int rc = -1; // command return code - UCHAR bus = SCpnt->channel; - UCHAR pun = SCpnt->target; - UCHAR lun = SCpnt->lun; - UCHAR cmd; - PDEV2000 pdev = &padapter->dev[bus][pun]; - - if ( !done ) - { - printk("pci2000_queuecommand: %02X: done can't be NULL\n", *cdb); - return 0; - } - - SCpnt->scsi_done = done; - pdev->SCpnt = SCpnt; // Save this command data - - if ( WaitReady (padapter) ) - { - rc = DID_ERROR; - goto finished; - } - - outw_p (pun | (lun << 8), padapter->mb0); - - if ( bus ) - { - DEB (if(*cdb) printk ("\nCDB: %X- %X %X %X %X %X %X %X %X %X %X ", SCpnt->cmd_len, cdb[0], cdb[1], cdb[2], cdb[3], cdb[4], cdb[5], cdb[6], cdb[7], cdb[8], cdb[9])); - DEB (if(*cdb) printk ("\ntimeout_per_command: %d, timeout_total: %d, timeout: %d, internal_timout: %d", SCpnt->timeout_per_command, - SCpnt->timeout_total, SCpnt->timeout, SCpnt->internal_timeout)); - outl (SCpnt->timeout_per_command, padapter->mb1); - outb_p (CMD_SCSI_TIMEOUT, padapter->cmd); - if ( WaitReady (padapter) ) - { - rc = DID_ERROR; - goto finished; - } - - outw_p (pun | (lun << 8), padapter->mb0); - outw_p (SCpnt->cmd_len << 8, padapter->mb0 + 2); - outl (virt_to_bus (cdb), padapter->mb1); - if ( BuildSgList (SCpnt, padapter, pdev) ) - cmd = CMD_SCSI_THRU; - else - cmd = CMD_SCSI_THRU_SG; - if ( (pdev->tag = Command (padapter, cmd)) == 0 ) - rc = DID_TIME_OUT; - goto finished; - } - else - { - if ( lun ) - { - rc = DID_BAD_TARGET; - goto finished; - } - } - - switch ( *cdb ) - { - case SCSIOP_INQUIRY: // inquiry CDB - if ( cdb[2] == SC_MY_RAID ) - { - switch ( cdb[3] ) - { - case MY_SCSI_REBUILD: - OpDone (SCpnt, PsiRaidCmd (padapter, CMD_RAID_REBUILD) << 16); - return 0; - case MY_SCSI_ALARMMUTE: - OpDone (SCpnt, PsiRaidCmd (padapter, CMD_RAID_MUTE) << 16); - return 0; - case MY_SCSI_DEMOFAIL: - OpDone (SCpnt, PsiRaidCmd (padapter, CMD_RAID_FAIL) << 16); - return 0; - default: - if ( SCpnt->use_sg ) - { - rc = DID_ERROR; - goto finished; - } - else - outl (virt_to_bus (SCpnt->request_buffer), padapter->mb2); - outl (cdb[5], padapter->mb0); - outl (cdb[3], padapter->mb3); - cmd = CMD_DASD_RAID_RQ; - break; - } - break; - } - - if ( SCpnt->use_sg ) - { - outl (virt_to_bus (((struct scatterlist *)(SCpnt->request_buffer))->address), padapter->mb2); - } - else - { - outl (virt_to_bus (SCpnt->request_buffer), padapter->mb2); - } - outl (SCpnt->request_bufflen, padapter->mb3); - cmd = CMD_DASD_SCSI_INQ; - break; - - case SCSIOP_TEST_UNIT_READY: // test unit ready CDB - outl (virt_to_bus (SCpnt->sense_buffer), padapter->mb2); - outl (sizeof (SCpnt->sense_buffer), padapter->mb3); - cmd = CMD_TEST_READY; - break; - - case SCSIOP_READ_CAPACITY: // read capctiy CDB - if ( SCpnt->use_sg ) - { - outl (virt_to_bus (((struct scatterlist *)(SCpnt->request_buffer))->address), padapter->mb2); - } - else - { - outl (virt_to_bus (SCpnt->request_buffer), padapter->mb2); - } - outl (8, padapter->mb3); - cmd = CMD_DASD_CAP; - break; - case SCSIOP_VERIFY: // verify CDB - outw_p ((USHORT)cdb[8] | ((USHORT)cdb[7] << 8), padapter->mb0 + 2); - outl (XSCSI2LONG (&cdb[2]), padapter->mb1); - cmd = CMD_READ_SG; - break; - case SCSIOP_READ: // read10 CDB - outw_p ((USHORT)cdb[8] | ((USHORT)cdb[7] << 8), padapter->mb0 + 2); - outl (XSCSI2LONG (&cdb[2]), padapter->mb1); - if ( BuildSgList (SCpnt, padapter, pdev) ) - cmd = CMD_READ; - else - cmd = CMD_READ_SG; - break; - case SCSIOP_READ6: // read6 CDB - outw_p (cdb[4], padapter->mb0 + 2); - outl ((SCSI2LONG (&cdb[1])) & 0x001FFFFF, padapter->mb1); - if ( BuildSgList (SCpnt, padapter, pdev) ) - cmd = CMD_READ; - else - cmd = CMD_READ_SG; - break; - case SCSIOP_WRITE: // write10 CDB - outw_p ((USHORT)cdb[8] | ((USHORT)cdb[7] << 8), padapter->mb0 + 2); - outl (XSCSI2LONG (&cdb[2]), padapter->mb1); - if ( BuildSgList (SCpnt, padapter, pdev) ) - cmd = CMD_WRITE; - else - cmd = CMD_WRITE_SG; - break; - case SCSIOP_WRITE6: // write6 CDB - outw_p (cdb[4], padapter->mb0 + 2); - outl ((SCSI2LONG (&cdb[1])) & 0x001FFFFF, padapter->mb1); - if ( BuildSgList (SCpnt, padapter, pdev) ) - cmd = CMD_WRITE; - else - cmd = CMD_WRITE_SG; - break; - case SCSIOP_START_STOP_UNIT: - cmd = CMD_EJECT_MEDIA; - break; - case SCSIOP_MEDIUM_REMOVAL: - switch ( cdb[4] ) - { - case 0: - cmd = CMD_UNLOCK_DOOR; - break; - case 1: - cmd = CMD_LOCK_DOOR; - break; - default: - cmd = 0; - break; - } - if ( cmd ) - break; - default: - DEB (printk ("pci2220i_queuecommand: Unsupported command %02X\n", *cdb)); - OpDone (SCpnt, DID_ERROR << 16); - return 0; - } - - if ( (pdev->tag = Command (padapter, cmd)) == 0 ) - rc = DID_TIME_OUT; -finished:; - if ( rc != -1 ) - OpDone (SCpnt, rc << 16); - return 0; - } -/**************************************************************** - * Name: internal_done :LOCAL - * - * Description: Done handler for non-queued commands - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * - * Returns: Nothing. - * - ****************************************************************/ -static void internal_done (Scsi_Cmnd * SCpnt) - { - SCpnt->SCp.Status++; - } -/**************************************************************** - * Name: Pci2220i_Command - * - * Description: Process a command from the SCSI manager. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * - * Returns: Status code. - * - ****************************************************************/ -int Pci2000_Command (Scsi_Cmnd *SCpnt) - { - DEB(printk("pci2000_command: ..calling pci2000_queuecommand\n")); - - Pci2000_QueueCommand (SCpnt, internal_done); - - SCpnt->SCp.Status = 0; - while (!SCpnt->SCp.Status) - barrier (); - return SCpnt->result; - } -/**************************************************************** - * Name: Pci2220i_Detect - * - * Description: Detect and initialize our boards. - * - * Parameters: tpnt - Pointer to SCSI host template structure. - * - * Returns: Number of adapters found. - * - ****************************************************************/ -int Pci2000_Detect (Scsi_Host_Template *tpnt) - { - int pci_index = 0; - struct Scsi_Host *pshost; - PADAPTER2000 padapter; - int z, zz; - int setirq; - - if ( pcibios_present () ) - { - for ( pci_index = 0; pci_index <= MAXADAPTER; ++pci_index ) - { - UCHAR pci_bus, pci_device_fn; - - if ( pcibios_find_device (VENDOR_PSI, DEVICE_ROY_1, pci_index, &pci_bus, &pci_device_fn) != 0 ) - break; - - pshost = scsi_register (tpnt, sizeof(ADAPTER2000)); - padapter = HOSTDATA(pshost); - - pcibios_read_config_word (pci_bus, pci_device_fn, PCI_BASE_ADDRESS_1, &padapter->basePort); - padapter->basePort &= 0xFFFE; - DEB (printk ("\nBase Regs = %#04X", padapter->basePort)); // get the base I/O port address - padapter->mb0 = padapter->basePort + RTR_MAILBOX; // get the 32 bit mail boxes - padapter->mb1 = padapter->basePort + RTR_MAILBOX + 4; - padapter->mb2 = padapter->basePort + RTR_MAILBOX + 8; - padapter->mb3 = padapter->basePort + RTR_MAILBOX + 12; - padapter->mb4 = padapter->basePort + RTR_MAILBOX + 16; - padapter->cmd = padapter->basePort + RTR_LOCAL_DOORBELL; // command register - padapter->tag = padapter->basePort + RTR_PCI_DOORBELL; // tag/response register - - if ( WaitReady (padapter) ) - goto unregister; - outb_p (0x84, padapter->mb0); - outb_p (CMD_SPECIFY, padapter->cmd); - if ( WaitReady (padapter) ) - goto unregister; - - pcibios_read_config_byte (pci_bus, pci_device_fn, PCI_INTERRUPT_LINE, &pshost->irq); - setirq = 1; - for ( z = 0; z < pci_index; z++ ) // scan for shared interrupts - { - if ( PsiHost[z]->irq == pshost->irq ) // if shared then, don't posses - setirq = 0; - } - if ( setirq ) // if not shared, posses - { - if ( request_irq (pshost->irq, Irq_Handler, 0, "pci2000", NULL) ) - { - printk ("Unable to allocate IRQ for PSI-2000 controller.\n"); - goto unregister; - } - } - PsiHost[pci_index] = pshost; // save SCSI_HOST pointer - - pshost->unique_id = padapter->basePort; - pshost->max_id = 16; - pshost->max_channel = 1; - - for ( zz = 0; zz < MAX_BUS; zz++ ) - for ( z = 0; z < MAX_UNITS; z++ ) - padapter->dev[zz][z].tag = 0; - - printk("\nPSI-2000 Intelligent Storage SCSI CONTROLLER: at I/O = %X IRQ = %d\n", padapter->basePort, pshost->irq); - printk("Version %s, Compiled %s %s\n\n", PCI2000_VERSION, __DATE__, __TIME__); - continue; -unregister:; - scsi_unregister (pshost); - } - } - NumAdapters = pci_index; - return pci_index; - } -/**************************************************************** - * Name: Pci2220i_Abort - * - * Description: Process the Abort command from the SCSI manager. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * - * Returns: Allways snooze. - * - ****************************************************************/ -int Pci2000_Abort (Scsi_Cmnd *SCpnt) - { - DEB (printk ("pci2000_abort\n")); - return SCSI_ABORT_SNOOZE; - } -/**************************************************************** - * Name: Pci2220i_Reset - * - * Description: Process the Reset command from the SCSI manager. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * flags - Flags about the reset command - * - * Returns: No active command at this time, so this means - * that each time we got some kind of response the - * last time through. Tell the mid-level code to - * request sense information in order to decide what - * to do next. - * - ****************************************************************/ -int Pci2000_Reset (Scsi_Cmnd *SCpnt, unsigned int reset_flags) - { - return SCSI_RESET_PUNT; - } - -#include "sd.h" - -/**************************************************************** - * Name: Pci2220i_BiosParam - * - * Description: Process the biosparam request from the SCSI manager to - * return C/H/S data. - * - * Parameters: disk - Pointer to SCSI disk structure. - * dev - Major/minor number from kernel. - * geom - Pointer to integer array to place geometry data. - * - * Returns: zero. - * - ****************************************************************/ -int Pci2000_BiosParam (Scsi_Disk *disk, kdev_t dev, int geom[]) - { - PADAPTER2000 padapter; - - padapter = HOSTDATA(disk->device->host); - - if ( WaitReady (padapter) ) - return 0; - outb_p (disk->device->id, padapter->mb0); - outb_p (CMD_GET_PARMS, padapter->cmd); - if ( WaitReady (padapter) ) - return 0; - - geom[0] = inb_p (padapter->mb2 + 3); - geom[1] = inb_p (padapter->mb2 + 2); - geom[2] = inw_p (padapter->mb2); - return 0; - } - - -#ifdef MODULE -/* Eventually this will go into an include file, but this will be later */ -Scsi_Host_Template driver_template = PCI2000; - -#include "scsi_module.c" -#endif - diff --git a/drivers/scsi/pci2000.h b/drivers/scsi/pci2000.h deleted file mode 100644 index ded993958ec5..000000000000 --- a/drivers/scsi/pci2000.h +++ /dev/null @@ -1,226 +0,0 @@ -/*+M************************************************************************* - * Perceptive Solutions, Inc. PCI-2000 device driver proc support for Linux. - * - * Copyright (c) 1997 Perceptive Solutions, 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; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * File Name: pci2000.h - * - * Description: Header file for the SCSI driver for the PCI-2000 - * interface card. - * - *-M*************************************************************************/ -#ifndef _PCI2000_H -#define _PCI2000_H - -#include -#include - -#ifndef PSI_EIDE_SCSIOP -#define PSI_EIDE_SCSIOP 1 - -/************************************************/ -/* definition of standard data types */ -/************************************************/ -#define CHAR char -#define UCHAR unsigned char -#define SHORT short -#define USHORT unsigned short -#define BOOL long -#define LONG long -#define ULONG unsigned long -#define VOID void - -typedef CHAR *PCHAR; -typedef UCHAR *PUCHAR; -typedef SHORT *PSHORT; -typedef USHORT *PUSHORT; -typedef BOOL *PBOOL; -typedef LONG *PLONG; -typedef ULONG *PULONG; -typedef VOID *PVOID; - - -/************************************************/ -/* Misc. macros */ -/************************************************/ -#define ANY2SCSI(up, p) \ -((UCHAR *)up)[0] = (((ULONG)(p)) >> 8); \ -((UCHAR *)up)[1] = ((ULONG)(p)); - -#define SCSI2LONG(up) \ -( (((long)*(((UCHAR *)up))) << 16) \ -+ (((long)(((UCHAR *)up)[1])) << 8) \ -+ ((long)(((UCHAR *)up)[2])) ) - -#define XANY2SCSI(up, p) \ -((UCHAR *)up)[0] = ((long)(p)) >> 24; \ -((UCHAR *)up)[1] = ((long)(p)) >> 16; \ -((UCHAR *)up)[2] = ((long)(p)) >> 8; \ -((UCHAR *)up)[3] = ((long)(p)); - -#define XSCSI2LONG(up) \ -( (((long)(((UCHAR *)up)[0])) << 24) \ -+ (((long)(((UCHAR *)up)[1])) << 16) \ -+ (((long)(((UCHAR *)up)[2])) << 8) \ -+ ((long)(((UCHAR *)up)[3])) ) - -/************************************************/ -/* SCSI CDB operation codes */ -/************************************************/ -#define SCSIOP_TEST_UNIT_READY 0x00 -#define SCSIOP_REZERO_UNIT 0x01 -#define SCSIOP_REWIND 0x01 -#define SCSIOP_REQUEST_BLOCK_ADDR 0x02 -#define SCSIOP_REQUEST_SENSE 0x03 -#define SCSIOP_FORMAT_UNIT 0x04 -#define SCSIOP_READ_BLOCK_LIMITS 0x05 -#define SCSIOP_REASSIGN_BLOCKS 0x07 -#define SCSIOP_READ6 0x08 -#define SCSIOP_RECEIVE 0x08 -#define SCSIOP_WRITE6 0x0A -#define SCSIOP_PRINT 0x0A -#define SCSIOP_SEND 0x0A -#define SCSIOP_SEEK6 0x0B -#define SCSIOP_TRACK_SELECT 0x0B -#define SCSIOP_SLEW_PRINT 0x0B -#define SCSIOP_SEEK_BLOCK 0x0C -#define SCSIOP_PARTITION 0x0D -#define SCSIOP_READ_REVERSE 0x0F -#define SCSIOP_WRITE_FILEMARKS 0x10 -#define SCSIOP_FLUSH_BUFFER 0x10 -#define SCSIOP_SPACE 0x11 -#define SCSIOP_INQUIRY 0x12 -#define SCSIOP_VERIFY6 0x13 -#define SCSIOP_RECOVER_BUF_DATA 0x14 -#define SCSIOP_MODE_SELECT 0x15 -#define SCSIOP_RESERVE_UNIT 0x16 -#define SCSIOP_RELEASE_UNIT 0x17 -#define SCSIOP_COPY 0x18 -#define SCSIOP_ERASE 0x19 -#define SCSIOP_MODE_SENSE 0x1A -#define SCSIOP_START_STOP_UNIT 0x1B -#define SCSIOP_STOP_PRINT 0x1B -#define SCSIOP_LOAD_UNLOAD 0x1B -#define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C -#define SCSIOP_SEND_DIAGNOSTIC 0x1D -#define SCSIOP_MEDIUM_REMOVAL 0x1E -#define SCSIOP_READ_CAPACITY 0x25 -#define SCSIOP_READ 0x28 -#define SCSIOP_WRITE 0x2A -#define SCSIOP_SEEK 0x2B -#define SCSIOP_LOCATE 0x2B -#define SCSIOP_WRITE_VERIFY 0x2E -#define SCSIOP_VERIFY 0x2F -#define SCSIOP_SEARCH_DATA_HIGH 0x30 -#define SCSIOP_SEARCH_DATA_EQUAL 0x31 -#define SCSIOP_SEARCH_DATA_LOW 0x32 -#define SCSIOP_SET_LIMITS 0x33 -#define SCSIOP_READ_POSITION 0x34 -#define SCSIOP_SYNCHRONIZE_CACHE 0x35 -#define SCSIOP_COMPARE 0x39 -#define SCSIOP_COPY_COMPARE 0x3A -#define SCSIOP_WRITE_DATA_BUFF 0x3B -#define SCSIOP_READ_DATA_BUFF 0x3C -#define SCSIOP_CHANGE_DEFINITION 0x40 -#define SCSIOP_READ_SUB_CHANNEL 0x42 -#define SCSIOP_READ_TOC 0x43 -#define SCSIOP_READ_HEADER 0x44 -#define SCSIOP_PLAY_AUDIO 0x45 -#define SCSIOP_PLAY_AUDIO_MSF 0x47 -#define SCSIOP_PLAY_TRACK_INDEX 0x48 -#define SCSIOP_PLAY_TRACK_RELATIVE 0x49 -#define SCSIOP_PAUSE_RESUME 0x4B -#define SCSIOP_LOG_SELECT 0x4C -#define SCSIOP_LOG_SENSE 0x4D -#define SCSIOP_MODE_SELECT10 0x55 -#define SCSIOP_MODE_SENSE10 0x5A -#define SCSIOP_LOAD_UNLOAD_SLOT 0xA6 -#define SCSIOP_MECHANISM_STATUS 0xBD -#define SCSIOP_READ_CD 0xBE - -// SCSI read capacity structure -typedef struct _READ_CAPACITY_DATA - { - ULONG blks; /* total blocks (converted to little endian) */ - ULONG blksiz; /* size of each (converted to little endian) */ - } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA; - -// SCSI inquiry data -typedef struct _INQUIRYDATA - { - UCHAR DeviceType :5; - UCHAR DeviceTypeQualifier :3; - UCHAR DeviceTypeModifier :7; - UCHAR RemovableMedia :1; - UCHAR Versions; - UCHAR ResponseDataFormat; - UCHAR AdditionalLength; - UCHAR Reserved[2]; - UCHAR SoftReset :1; - UCHAR CommandQueue :1; - UCHAR Reserved2 :1; - UCHAR LinkedCommands :1; - UCHAR Synchronous :1; - UCHAR Wide16Bit :1; - UCHAR Wide32Bit :1; - UCHAR RelativeAddressing :1; - UCHAR VendorId[8]; - UCHAR ProductId[16]; - UCHAR ProductRevisionLevel[4]; - UCHAR VendorSpecific[20]; - UCHAR Reserved3[40]; - } INQUIRYDATA, *PINQUIRYDATA; - -#endif - -// function prototypes -int Pci2000_Detect (Scsi_Host_Template *tpnt); -int Pci2000_Command (Scsi_Cmnd *SCpnt); -int Pci2000_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)); -int Pci2000_Abort (Scsi_Cmnd *SCpnt); -int Pci2000_Reset (Scsi_Cmnd *SCpnt, unsigned int flags); -int Pci2000_BiosParam (Disk *disk, kdev_t dev, int geom[]); - -#ifndef NULL - #define NULL 0 -#endif - -extern struct proc_dir_entry Proc_Scsi_Pci2000; - -#define PCI2000 { NULL, NULL, \ - &Proc_Scsi_Pci2000,/* proc_dir_entry */ \ - NULL, \ - "PCI-2000 SCSI Intelligent Disk Controller",\ - Pci2000_Detect, \ - NULL, \ - NULL, \ - Pci2000_Command, \ - Pci2000_QueueCommand, \ - Pci2000_Abort, \ - Pci2000_Reset, \ - NULL, \ - Pci2000_BiosParam, \ - 16, \ - -1, \ - 16, \ - 1, \ - 0, \ - 0, \ - DISABLE_CLUSTERING } - -#endif diff --git a/drivers/scsi/pci2220i.c b/drivers/scsi/pci2220i.c deleted file mode 100644 index a45bafbd6cb4..000000000000 --- a/drivers/scsi/pci2220i.c +++ /dev/null @@ -1,819 +0,0 @@ -/*+M************************************************************************* - * Perceptive Solutions, Inc. PCI-2000 device driver proc support for Linux. - * - * Copyright (c) 1997 Perceptive Solutions, 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; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * File Name: pci2220i.c - * - * Description: SCSI driver for the PCI2220I EIDE interface card. - * - *-M*************************************************************************/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "scsi.h" -#include "hosts.h" - -#include "pci2220i.h" -#include "psi_dale.h" - -#include - -struct proc_dir_entry Proc_Scsi_Pci2220i = - { PROC_SCSI_PCI2220I, 7, "pci2220i", S_IFDIR | S_IRUGO | S_IXUGO, 2 }; - -//#define DEBUG 1 - -#ifdef DEBUG -#define DEB(x) x -#define STOP_HERE {int st;for(st=0;st<100;st++){st=1;}} -#else -#define DEB(x) -#define STOP_HERE -#endif - -#define MAXADAPTER 4 /* Increase this and the sizes of the arrays below, if you need more. */ - -#define MAX_BUS_MASTER_BLOCKS 1 // This is the maximum we can bus master for (1024 bytes) - -#define PORT_DATA 0 -#define PORT_ERROR 1 -#define PORT_SECTOR_COUNT 2 -#define PORT_LBA_0 3 -#define PORT_LBA_8 4 -#define PORT_LBA_16 5 -#define PORT_LBA_24 6 -#define PORT_STAT_CMD 7 -#define PORT_STAT_SEL 8 -#define PORT_FAIL 9 -#define PORT_ALT_STAT 10 - -typedef struct - { - UCHAR device; // device code - UCHAR byte6; // device select register image - UCHAR spigot; // spigot number - UCHAR sparebyte; // placeholder - USHORT sectors; // number of sectors per track - USHORT heads; // number of heads - USHORT cylinders; // number of cylinders for this device - USHORT spareword; // placeholder - ULONG blocks; // number of blocks on device - } OUR_DEVICE, *POUR_DEVICE; - -typedef struct - { - USHORT ports[12]; - USHORT regDmaDesc; // address of the DMA discriptor register for direction of transfer - USHORT regDmaCmdStat; // Byte #1 of DMA command status register - USHORT regDmaAddrPci; // 32 bit register for PCI address of DMA - USHORT regDmaAddrLoc; // 32 bit register for local bus address of DMA - USHORT regDmaCount; // 32 bit register for DMA transfer count - USHORT regDmaMode; // 32 bit register for DMA mode control - USHORT regRemap; // 32 bit local space remap - USHORT regDesc; // 32 bit local region descriptor - USHORT regRange; // 32 bit local range - USHORT regIrqControl; // 16 bit Interrupt enable/disable and status - USHORT regScratchPad; // scratch pad I/O base address - USHORT regBase; // Base I/O register for data space - USHORT basePort; // PLX base I/O port - USHORT timingMode; // timing mode currently set for adapter - ULONG timingAddress; // address to use on adapter for current timing mode - OUR_DEVICE device[4]; - IDE_STRUCT ide; - ULONG startSector; - USHORT sectorCount; - Scsi_Cmnd *SCpnt; - VOID *buffer; - USHORT expectingIRQ; - USHORT readPhase; - } ADAPTER2220I, *PADAPTER2220I; - -#define HOSTDATA(host) ((PADAPTER2220I)&host->hostdata) - - -static struct Scsi_Host *PsiHost[MAXADAPTER] = {NULL,}; // One for each adapter -static int NumAdapters = 0; -static IDENTIFY_DATA identifyData; -static SETUP DaleSetup; - -/**************************************************************** - * Name: WriteData :LOCAL - * - * Description: Write data to device. - * - * Parameters: padapter - Pointer adapter data structure. - * - * Returns: TRUE if drive does not assert DRQ in time. - * - ****************************************************************/ -static int WriteData (PADAPTER2220I padapter) - { - ULONG timer; - USHORT *pports = padapter->ports; - - timer = jiffies + TIMEOUT_DRQ; // calculate the timeout value - do { - if ( inb_p (pports[PORT_STAT_CMD]) & IDE_STATUS_DRQ ) - { - outb_p (0, padapter->regDmaDesc); // write operation - outl (padapter->timingAddress, padapter->regDmaAddrLoc); - outl (virt_to_bus (padapter->buffer), padapter->regDmaAddrPci); - outl ((ULONG)padapter->ide.ide.ide[2] * (ULONG)512, padapter->regDmaCount); - outb_p (1, padapter->regDmaMode); // interrupts off - outb_p (0x03, padapter->regDmaCmdStat); // kick the DMA engine in gear - return 0; - } - } while ( timer > jiffies ); // test for timeout - - padapter->ide.ide.ides.cmd = 0; // null out the command byte - return 1; - } -/**************************************************************** - * Name: IdeCmd :LOCAL - * - * Description: Process a queued command from the SCSI manager. - * - * Parameters: padapter - Pointer adapter data structure. - * - * Returns: Zero if no error or status register contents on error. - * - ****************************************************************/ -static UCHAR IdeCmd (PADAPTER2220I padapter) - { - ULONG timer; - USHORT *pports = padapter->ports; - UCHAR status; - - outb_p (padapter->ide.ide.ides.spigot, pports[PORT_STAT_SEL]); // select the spigot - outb_p (padapter->ide.ide.ide[6], pports[PORT_LBA_24]); // select the drive - timer = jiffies + TIMEOUT_READY; // calculate the timeout value - DEB(printk ("\npci2220i Issueing new command: 0x%X",padapter->ide.ide.ides.cmd)); - do { - status = inb_p (padapter->ports[PORT_STAT_CMD]); - if ( status & IDE_STATUS_DRDY ) - { - outb_p (padapter->ide.ide.ide[2], pports[PORT_SECTOR_COUNT]); - outb_p (padapter->ide.ide.ide[3], pports[PORT_LBA_0]); - outb_p (padapter->ide.ide.ide[4], pports[PORT_LBA_8]); - outb_p (padapter->ide.ide.ide[5], pports[PORT_LBA_16]); - padapter->expectingIRQ = 1; - outb_p (padapter->ide.ide.ide[7], pports[PORT_STAT_CMD]); - - if ( padapter->ide.ide.ides.cmd == IDE_CMD_WRITE_MULTIPLE ) - return (WriteData (padapter)); - return 0; - } - } while ( timer > jiffies ); // test for timeout - - padapter->ide.ide.ides.cmd = 0; // null out the command byte - return status; - } -/**************************************************************** - * Name: SetupTransfer :LOCAL - * - * Description: Setup a data transfer command. - * - * Parameters: padapter - Pointer adapter data structure. - * drive - Drive/head register upper nibble only. - * - * Returns: TRUE if no data to transfer. - * - ****************************************************************/ -static int SetupTransfer (PADAPTER2220I padapter, UCHAR drive) - { - if ( padapter->sectorCount ) - { - *(ULONG *)padapter->ide.ide.ides.lba = padapter->startSector; - padapter->ide.ide.ide[6] |= drive; -// padapter->ide.ide.ides.sectors = ( padapter->sectorCount > SECTORSXFER ) ? SECTORSXFER : padapter->sectorCount; - padapter->ide.ide.ides.sectors = ( padapter->sectorCount > MAX_BUS_MASTER_BLOCKS ) ? MAX_BUS_MASTER_BLOCKS : padapter->sectorCount; - padapter->sectorCount -= padapter->ide.ide.ides.sectors; // bump the start and count for next xfer - padapter->startSector += padapter->ide.ide.ides.sectors; - return 0; - } - else - { - padapter->ide.ide.ides.cmd = 0; // null out the command byte - padapter->SCpnt = NULL; - return 1; - } - } -/**************************************************************** - * Name: DecodeError :LOCAL - * - * Description: Decode and process device errors. - * - * Parameters: pshost - Pointer to host data block. - * status - Status register code. - * - * Returns: The driver status code. - * - ****************************************************************/ -static ULONG DecodeError (struct Scsi_Host *pshost, UCHAR status) - { - PADAPTER2220I padapter = HOSTDATA(pshost); - UCHAR error; - - padapter->expectingIRQ = 0; - padapter->SCpnt = NULL; - if ( status & IDE_STATUS_WRITE_FAULT ) - { - return DID_PARITY << 16; - } - if ( status & IDE_STATUS_BUSY ) - return DID_BUS_BUSY << 16; - - error = inb_p (padapter->ports[PORT_ERROR]); - DEB(printk ("\npci2220i error register: %x", error)); - switch ( error ) - { - case IDE_ERROR_AMNF: - case IDE_ERROR_TKONF: - case IDE_ERROR_ABRT: - case IDE_ERROR_IDFN: - case IDE_ERROR_UNC: - case IDE_ERROR_BBK: - default: - return DID_ERROR << 16; - } - return DID_ERROR << 16; - } -/**************************************************************** - * Name: Irq_Handler :LOCAL - * - * Description: Interrupt handler. - * - * Parameters: irq - Hardware IRQ number. - * dev_id - - * regs - - * - * Returns: TRUE if drive is not ready in time. - * - ****************************************************************/ -static void Irq_Handler (int irq, void *dev_id, struct pt_regs *regs) - { - struct Scsi_Host *shost = NULL; // Pointer to host data block - PADAPTER2220I padapter; // Pointer to adapter control structure - USHORT *pports; // I/O port array - Scsi_Cmnd *SCpnt; - UCHAR status; - int z; - -// DEB(printk ("\npci2220i recieved interrupt\n")); - - for ( z = 0; z < NumAdapters; z++ ) // scan for interrupt to process - { - if ( PsiHost[z]->irq == (UCHAR)(irq & 0xFF) ) - { - if ( inw_p (HOSTDATA(PsiHost[z])->regIrqControl) & 0x8000 ) - { - shost = PsiHost[z]; - break; - } - } - } - - if ( !shost ) - { - DEB (printk ("\npci2220i: not my interrupt")); - return; - } - - padapter = HOSTDATA(shost); - pports = padapter->ports; - SCpnt = padapter->SCpnt; - - if ( !padapter->expectingIRQ ) - { - DEB(printk ("\npci2220i Unsolicited interrupt\n")); - return; - } - padapter->expectingIRQ = 0; - - status = inb_p (padapter->ports[PORT_STAT_CMD]); // read the device status - if ( status & (IDE_STATUS_ERROR | IDE_STATUS_WRITE_FAULT) ) - goto irqerror; - - switch ( padapter->ide.ide.ides.cmd ) // decide how to handle the interrupt - { - case IDE_CMD_READ_MULTIPLE: - if ( padapter->readPhase == 1 ) // is this a bus master channel complete? - { - DEB(printk ("\npci2220i processing read interrupt cleanup")); - outb_p (0x08, padapter->regDmaCmdStat); // cancel interrupt from DMA engine - padapter->buffer += padapter->ide.ide.ides.sectors * 512; - if ( SetupTransfer (padapter, padapter->ide.ide.ide[6] & 0xF0) ) - { - SCpnt->result = DID_OK << 16; - padapter->SCpnt = NULL; - SCpnt->scsi_done (SCpnt); - return; - } - padapter->readPhase = 0; - if ( !(status = IdeCmd (padapter)) ) - { - DEB (printk ("\npci2220i interrupt complete, waiting for another")); - return; - } - } - if ( status & IDE_STATUS_DRQ ) - { - DEB(printk ("\npci2220i processing read interrupt start bus master cycle")); - outb_p (8, padapter->regDmaDesc); // read operation - padapter->readPhase = 1; - padapter->expectingIRQ = 1; - outl (padapter->timingAddress, padapter->regDmaAddrLoc); - outl (virt_to_bus (padapter->buffer), padapter->regDmaAddrPci); - outl ((ULONG)padapter->ide.ide.ides.sectors * (ULONG)512, padapter->regDmaCount); - outb_p (5, padapter->regDmaMode); // interrupt enable/disable - outb_p (0x03, padapter->regDmaCmdStat); // kick the DMA engine in gear - return; - } - break; - - case IDE_CMD_WRITE_MULTIPLE: - DEB(printk ("\npci2220i processing write interrupt cleanup")); - padapter->buffer += padapter->ide.ide.ides.sectors * 512; - if ( SetupTransfer (padapter, padapter->ide.ide.ide[6] & 0xF0) ) - { - SCpnt->result = DID_OK << 16; - padapter->SCpnt = NULL; - SCpnt->scsi_done (SCpnt); - return; - } - if ( !(status = IdeCmd (padapter)) ) - { - DEB (printk ("\npci2220i interrupt complete, waiting for another")); - return; - } - break; - - case IDE_COMMAND_IDENTIFY: - { - PINQUIRYDATA pinquiryData = SCpnt->request_buffer; - - DEB(printk ("\npci2220i processing verify interrupt cleanup")); - if ( status & IDE_STATUS_DRQ ) - { - insw (pports[PORT_DATA], &identifyData, sizeof (identifyData) >> 1); - - memset (pinquiryData, 0, SCpnt->request_bufflen); // Zero INQUIRY data structure. - pinquiryData->DeviceType = 0; - pinquiryData->Versions = 2; - pinquiryData->AdditionalLength = 35 - 4; - - // Fill in vendor identification fields. - for ( z = 0; z < 20; z += 2 ) - { - pinquiryData->VendorId[z] = ((UCHAR *)identifyData.ModelNumber)[z + 1]; - pinquiryData->VendorId[z + 1] = ((UCHAR *)identifyData.ModelNumber)[z]; - } - - // Initialize unused portion of product id. - for ( z = 0; z < 4; z++ ) - pinquiryData->ProductId[12 + z] = ' '; - - // Move firmware revision from IDENTIFY data to - // product revision in INQUIRY data. - for ( z = 0; z < 4; z += 2 ) - { - pinquiryData->ProductRevisionLevel[z] = ((UCHAR *)identifyData.FirmwareRevision)[z + 1]; - pinquiryData->ProductRevisionLevel[z + 1] = ((UCHAR *)identifyData.FirmwareRevision)[z]; - } - - SCpnt->result = DID_OK << 16; - padapter->SCpnt = NULL; - SCpnt->scsi_done (SCpnt); - return; - } - break; - } - - default: - DEB(printk ("\npci2220i no real process here!")); - SCpnt->result = DID_OK << 16; - padapter->SCpnt = NULL; - SCpnt->scsi_done (SCpnt); - return; - } - -irqerror:; - DEB(printk ("\npci2220i error Device Status: %X\n", status)); - SCpnt->result = DecodeError (shost, status); - SCpnt->scsi_done (SCpnt); - } -/**************************************************************** - * Name: Pci2220i_QueueCommand - * - * Description: Process a queued command from the SCSI manager. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * done - Pointer to done function to call. - * - * Returns: Status code. - * - ****************************************************************/ -int Pci2220i_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) - { - UCHAR *cdb = (UCHAR *)SCpnt->cmnd; // Pointer to SCSI CDB - PADAPTER2220I padapter = HOSTDATA(SCpnt->host); // Pointer to adapter control structure - POUR_DEVICE pdev = &padapter->device[SCpnt->target];// Pointer to device information - UCHAR rc; // command return code - - SCpnt->scsi_done = done; - padapter->ide.ide.ides.spigot = pdev->spigot; - padapter->buffer = SCpnt->request_buffer; - if (done) - { - if ( !pdev->device || SCpnt->lun ) - { - SCpnt->result = DID_BAD_TARGET << 16; - done (SCpnt); - return 0; - } - } - else - { - printk("pci2220i_queuecommand: %02X: done can't be NULL\n", *cdb); - return 0; - } - - DEB (if(*cdb) printk ("\nCDB: %X- %X %X %X %X %X %X %X %X %X %X ", SCpnt->cmd_len, cdb[0], cdb[1], cdb[2], cdb[3], cdb[4], cdb[5], cdb[6], cdb[7], cdb[8], cdb[9])); - switch ( *cdb ) - { - case SCSIOP_INQUIRY: // inquiry CDB - { - padapter->ide.ide.ide[6] = pdev->byte6; - padapter->ide.ide.ides.cmd = IDE_COMMAND_IDENTIFY; - break; - } - - case SCSIOP_TEST_UNIT_READY: // test unit ready CDB - SCpnt->result = DID_OK << 16; - done (SCpnt); - return 0; - - case SCSIOP_READ_CAPACITY: // read capctiy CDB - { - PREAD_CAPACITY_DATA pdata = (PREAD_CAPACITY_DATA)SCpnt->request_buffer; - - pdata->blksiz = 0x20000; - XANY2SCSI ((UCHAR *)&pdata->blks, pdev->blocks); - SCpnt->result = DID_OK << 16; - done (SCpnt); - return 0; - } - - case SCSIOP_VERIFY: // verify CDB - *(ULONG *)padapter->ide.ide.ides.lba = XSCSI2LONG (&cdb[2]); - padapter->ide.ide.ide[6] |= pdev->byte6; - padapter->ide.ide.ide[2] = (UCHAR)((USHORT)cdb[8] | ((USHORT)cdb[7] << 8)); - padapter->ide.ide.ides.cmd = IDE_COMMAND_VERIFY; - break; - - case SCSIOP_READ: // read10 CDB - padapter->startSector = XSCSI2LONG (&cdb[2]); - padapter->sectorCount = (USHORT)cdb[8] | ((USHORT)cdb[7] << 8); - SetupTransfer (padapter, pdev->byte6); - padapter->ide.ide.ides.cmd = IDE_CMD_READ_MULTIPLE; - padapter->readPhase = 0; - break; - - case SCSIOP_READ6: // read6 CDB - padapter->startSector = SCSI2LONG (&cdb[1]); - padapter->sectorCount = cdb[4]; - SetupTransfer (padapter, pdev->byte6); - padapter->ide.ide.ides.cmd = IDE_CMD_READ_MULTIPLE; - padapter->readPhase = 0; - break; - - case SCSIOP_WRITE: // write10 CDB - padapter->startSector = XSCSI2LONG (&cdb[2]); - padapter->sectorCount = (USHORT)cdb[8] | ((USHORT)cdb[7] << 8); - SetupTransfer (padapter, pdev->byte6); - padapter->ide.ide.ides.cmd = IDE_CMD_WRITE_MULTIPLE; - break; - case SCSIOP_WRITE6: // write6 CDB - padapter->startSector = SCSI2LONG (&cdb[1]); - padapter->sectorCount = cdb[4]; - SetupTransfer (padapter, pdev->byte6); - padapter->ide.ide.ides.cmd = IDE_CMD_WRITE_MULTIPLE; - break; - - default: - DEB (printk ("pci2220i_queuecommand: Unsupported command %02X\n", *cdb)); - SCpnt->result = DID_ERROR << 16; - done (SCpnt); - return 0; - } - - padapter->SCpnt = SCpnt; // Save this command data - - rc = IdeCmd (padapter); - if ( rc ) - { - padapter->expectingIRQ = 0; - DEB (printk ("pci2220i_queuecommand: %02X, %02X: Device failed to respond for command\n", *cdb, padapter->ide.ide.ides.cmd)); - SCpnt->result = DID_ERROR << 16; - done (SCpnt); - return 0; - } - if ( padapter->ide.ide.ides.cmd == IDE_CMD_WRITE_MULTIPLE ) - { - if ( WriteData (padapter) ) - { - padapter->expectingIRQ = 0; - DEB (printk ("pci2220i_queuecommand: %02X, %02X: Device failed to accept data\n", *cdb, padapter->ide.ide.ides.cmd)); - SCpnt->result = DID_ERROR << 16; - done (SCpnt); - return 0; - } - } - DEB (printk(" now waiting for initial interrupt ")); - return 0; - } - -static void internal_done(Scsi_Cmnd * SCpnt) - { - SCpnt->SCp.Status++; - } -/**************************************************************** - * Name: Pci2220i_Command - * - * Description: Process a command from the SCSI manager. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * - * Returns: Status code. - * - ****************************************************************/ -int Pci2220i_Command (Scsi_Cmnd *SCpnt) - { - DEB(printk("pci2220i_command: ..calling pci2220i_queuecommand\n")); - - Pci2220i_QueueCommand (SCpnt, internal_done); - - SCpnt->SCp.Status = 0; - while (!SCpnt->SCp.Status) - barrier (); - return SCpnt->result; - } -/**************************************************************** - * Name: ReadFlash - * - * Description: Read information from controller Flash memory. - * - * Parameters: hostdata - Pointer to host interface data structure. - * pdata - Pointer to data structures. - * base - base address in Flash. - * length - lenght of data space in bytes. - * - * Returns: Nothing. - * - ****************************************************************/ -VOID ReadFlash (PADAPTER2220I hostdata, VOID *pdata, ULONG base, ULONG length) - { - ULONG oldremap; - UCHAR olddesc; - ULONG z; - UCHAR *pd = (UCHAR *)pdata; - - oldremap = inl (hostdata->regRemap); // save values to restore later - olddesc = inb_p (hostdata->regDesc); - - outl (base | 1, hostdata->regRemap); // remap to Flash space as specified - outb_p (0x40, hostdata->regDesc); // describe remap region as 8 bit - for ( z = 0; z < length; z++) // get "length" data count - *pd++ = inb_p (hostdata->regBase + z); // read in the data - - outl (oldremap, hostdata->regRemap); // restore remap register values - outb_p (olddesc, hostdata->regDesc); - } - -/**************************************************************** - * Name: Pci2220i_Detect - * - * Description: Detect and initialize our boards. - * - * Parameters: tpnt - Pointer to SCSI host template structure. - * - * Returns: Number of adapters found. - * - ****************************************************************/ -int Pci2220i_Detect (Scsi_Host_Template *tpnt) - { - int pci_index = 0; - struct Scsi_Host *pshost; - PADAPTER2220I hostdata; - ULONG modearray[] = {DALE_DATA_MODE2, DALE_DATA_MODE3, DALE_DATA_MODE4, DALE_DATA_MODE4P}; - int unit; - int z; - int setirq; - - if ( pcibios_present () ) - { - for ( pci_index = 0; pci_index <= MAXADAPTER; ++pci_index ) - { - UCHAR pci_bus, pci_device_fn; - - if ( pcibios_find_device (VENDOR_PSI, DEVICE_DALE_1, pci_index, &pci_bus, &pci_device_fn) != 0 ) - break; - - pshost = scsi_register (tpnt, sizeof(ADAPTER2220I)); - hostdata = HOSTDATA(pshost); - - pcibios_read_config_word (pci_bus, pci_device_fn, PCI_BASE_ADDRESS_1, &hostdata->basePort); - hostdata->basePort &= 0xFFFE; - DEB (printk ("\nBase Regs = %#04X", hostdata->basePort)); - hostdata->regRemap = hostdata->basePort + RTR_LOCAL_REMAP; // 32 bit local space remap - DEB (printk (" %#04X", hostdata->regRemap)); - hostdata->regDesc = hostdata->basePort + RTR_REGIONS; // 32 bit local region descriptor - DEB (printk (" %#04X", hostdata->regDesc)); - hostdata->regRange = hostdata->basePort + RTR_LOCAL_RANGE; // 32 bit local range - DEB (printk (" %#04X", hostdata->regRange)); - hostdata->regIrqControl = hostdata->basePort + RTR_INT_CONTROL_STATUS; // 16 bit interupt control and status - DEB (printk (" %#04X", hostdata->regIrqControl)); - hostdata->regScratchPad = hostdata->basePort + RTR_MAILBOX; // 16 byte scratchpad I/O base address - DEB (printk (" %#04X", hostdata->regScratchPad)); - - pcibios_read_config_word (pci_bus, pci_device_fn, PCI_BASE_ADDRESS_2, &hostdata->regBase); - hostdata->regBase &= 0xFFFE; - for ( z = 0; z < 9; z++ ) // build regester address array - hostdata->ports[z] = hostdata->regBase + 0x80 + (z * 4); - hostdata->ports[PORT_FAIL] = hostdata->regBase + REG_FAIL; - hostdata->ports[PORT_ALT_STAT] = hostdata->regBase + REG_ALT_STAT; - DEB (printk ("\nPorts =")); - DEB (for (z=0;z<11;z++) printk(" %#04X", hostdata->ports[z]);); - - hostdata->regDmaDesc = hostdata->regBase + RTL_DMA1_DESC_PTR; // address of the DMA discriptor register for direction of transfer - DEB (printk ("\nDMA Regs = %#04X", hostdata->regDmaDesc)); - hostdata->regDmaCmdStat = hostdata->regBase + RTL_DMA_COMMAND_STATUS + 1; // Byte #1 of DMA command status register - DEB (printk (" %#04X", hostdata->regDmaCmdStat)); - hostdata->regDmaAddrPci = hostdata->regBase + RTL_DMA1_PCI_ADDR; // 32 bit register for PCI address of DMA - DEB (printk (" %#04X", hostdata->regDmaAddrPci)); - hostdata->regDmaAddrLoc = hostdata->regBase + RTL_DMA1_LOCAL_ADDR; // 32 bit register for local bus address of DMA - DEB (printk (" %#04X", hostdata->regDmaAddrLoc)); - hostdata->regDmaCount = hostdata->regBase + RTL_DMA1_COUNT; // 32 bit register for DMA transfer count - DEB (printk (" %#04X", hostdata->regDmaCount)); - hostdata->regDmaMode = hostdata->regBase + RTL_DMA1_MODE + 1; // 32 bit register for DMA mode control - DEB (printk (" %#04X", hostdata->regDmaMode)); - - if ( !inb_p (hostdata->regScratchPad + DALE_NUM_DRIVES) ) // if no devices on this board - goto unregister; - - pcibios_read_config_byte (pci_bus, pci_device_fn, PCI_INTERRUPT_LINE, &pshost->irq); - setirq = 1; - for ( z = 0; z < pci_index; z++ ) // scan for shared interrupts - { - if ( PsiHost[z]->irq == pshost->irq ) // if shared then, don't posses - setirq = 0; - } - if ( setirq ) // if not shared, posses - { - if ( request_irq (pshost->irq, Irq_Handler, 0, "pci2220i", NULL) ) - { - printk ("Unable to allocate IRQ for PSI-2220I controller.\n"); - goto unregister; - } - } - PsiHost[pci_index] = pshost; // save SCSI_HOST pointer - - pshost->unique_id = hostdata->regBase; - pshost->max_id = 4; - - outb_p (0x01, hostdata->regRange); // fix our range register because other drivers want to tromp on it - - hostdata->timingMode = inb_p (hostdata->regScratchPad + DALE_TIMING_MODE); - hostdata->timingAddress = modearray[hostdata->timingMode - 2]; - ReadFlash (hostdata, &DaleSetup, DALE_FLASH_SETUP, sizeof (SETUP)); - - for ( z = 0; z < inb_p (hostdata->regScratchPad + DALE_NUM_DRIVES); ++z ) - { - unit = inb_p (hostdata->regScratchPad + DALE_CHANNEL_DEVICE_0 + z) & 0x0F; - hostdata->device[unit].device = inb_p (hostdata->regScratchPad + DALE_SCRATH_DEVICE_0 + unit); - hostdata->device[unit].byte6 = (UCHAR)(((unit & 1) << 4) | 0xE0); - hostdata->device[unit].spigot = (UCHAR)(1 << (unit >> 1)); - hostdata->device[unit].sectors = DaleSetup.setupDevice[unit].sectors; - hostdata->device[unit].heads = DaleSetup.setupDevice[unit].heads; - hostdata->device[unit].cylinders = DaleSetup.setupDevice[unit].cylinders; - hostdata->device[unit].blocks = DaleSetup.setupDevice[unit].blocks; - DEB (printk ("\nHOSTDATA->device = %X", hostdata->device[unit].device)); - DEB (printk ("\n byte6 = %X", hostdata->device[unit].byte6)); - DEB (printk ("\n spigot = %X", hostdata->device[unit].spigot)); - DEB (printk ("\n sectors = %X", hostdata->device[unit].sectors)); - DEB (printk ("\n heads = %X", hostdata->device[unit].heads)); - DEB (printk ("\n cylinders = %X", hostdata->device[unit].cylinders)); - DEB (printk ("\n blocks = %lX", hostdata->device[unit].blocks)); - } - - printk("\nPSI-2220I EIDE CONTROLLER: at I/O = %X/%X IRQ = %d\n", hostdata->basePort, hostdata->regBase, pshost->irq); - printk("(C) 1997 Perceptive Solutions, Inc. All rights reserved\n\n"); - - NumAdapters++; - continue; -unregister:; - scsi_unregister (pshost); - } - } - return NumAdapters; - } -/**************************************************************** - * Name: Pci2220i_Abort - * - * Description: Process the Abort command from the SCSI manager. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * - * Returns: Allways snooze. - * - ****************************************************************/ -int Pci2220i_Abort (Scsi_Cmnd *SCpnt) - { - DEB (printk ("pci2220i_abort\n")); - return SCSI_ABORT_SNOOZE; - } -/**************************************************************** - * Name: Pci2220i_Reset - * - * Description: Process the Reset command from the SCSI manager. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * flags - Flags about the reset command - * - * Returns: No active command at this time, so this means - * that each time we got some kind of response the - * last time through. Tell the mid-level code to - * request sense information in order to decide what - * to do next. - * - ****************************************************************/ -int Pci2220i_Reset (Scsi_Cmnd *SCpnt, unsigned int reset_flags) - { - return SCSI_RESET_PUNT; - } - -#include "sd.h" - -/**************************************************************** - * Name: Pci2220i_BiosParam - * - * Description: Process the biosparam request from the SCSI manager to - * return C/H/S data. - * - * Parameters: disk - Pointer to SCSI disk structure. - * dev - Major/minor number from kernel. - * geom - Pointer to integer array to place geometry data. - * - * Returns: zero. - * - ****************************************************************/ -int Pci2220i_BiosParam (Scsi_Disk *disk, kdev_t dev, int geom[]) - { - POUR_DEVICE pdev; - - pdev = &(HOSTDATA(disk->device->host)->device[disk->device->id]); - - geom[0] = pdev->heads; - geom[1] = pdev->sectors; - geom[2] = pdev->cylinders; - return 0; - } - - -#ifdef MODULE -/* Eventually this will go into an include file, but this will be later */ -Scsi_Host_Template driver_template = PCI2220I; - -#include "scsi_module.c" -#endif - diff --git a/drivers/scsi/pci2220i.h b/drivers/scsi/pci2220i.h deleted file mode 100644 index 0fafc26489ac..000000000000 --- a/drivers/scsi/pci2220i.h +++ /dev/null @@ -1,345 +0,0 @@ -/*+M************************************************************************* - * Perceptive Solutions, Inc. PCI-2000 device driver proc support for Linux. - * - * Copyright (c) 1997 Perceptive Solutions, 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; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * File Name: pci2220i.h - * - * Description: Header file for the SCSI driver for the PCI2220I - * EIDE interface card. - * - *-M*************************************************************************/ - -#ifndef _PCI2220I_H -#define _PCI2220I_H - -#include -#include - -#ifndef PSI_EIDE_SCSIOP -#define PSI_EIDE_SCSIOP 1 - -/************************************************/ -/* Some defines that we like */ -/************************************************/ -#define CHAR char -#define UCHAR unsigned char -#define SHORT short -#define USHORT unsigned short -#define BOOL unsigned short -#define LONG long -#define ULONG unsigned long -#define VOID void - -/************************************************/ -/* Timeout konstants */ -/************************************************/ -#define TIMEOUT_READY 10 // 100 mSec -#define TIMEOUT_DRQ 40 // 400 mSec - -/************************************************/ -/* Misc. macros */ -/************************************************/ -#define ANY2SCSI(up, p) \ -((UCHAR *)up)[0] = (((ULONG)(p)) >> 8); \ -((UCHAR *)up)[1] = ((ULONG)(p)); - -#define SCSI2LONG(up) \ -( (((long)*(((UCHAR *)up))) << 16) \ -+ (((long)(((UCHAR *)up)[1])) << 8) \ -+ ((long)(((UCHAR *)up)[2])) ) - -#define XANY2SCSI(up, p) \ -((UCHAR *)up)[0] = ((long)(p)) >> 24; \ -((UCHAR *)up)[1] = ((long)(p)) >> 16; \ -((UCHAR *)up)[2] = ((long)(p)) >> 8; \ -((UCHAR *)up)[3] = ((long)(p)); - -#define XSCSI2LONG(up) \ -( (((long)(((UCHAR *)up)[0])) << 24) \ -+ (((long)(((UCHAR *)up)[1])) << 16) \ -+ (((long)(((UCHAR *)up)[2])) << 8) \ -+ ((long)(((UCHAR *)up)[3])) ) - -/************************************************/ -/* SCSI CDB operation codes */ -/************************************************/ -#define SCSIOP_TEST_UNIT_READY 0x00 -#define SCSIOP_REZERO_UNIT 0x01 -#define SCSIOP_REWIND 0x01 -#define SCSIOP_REQUEST_BLOCK_ADDR 0x02 -#define SCSIOP_REQUEST_SENSE 0x03 -#define SCSIOP_FORMAT_UNIT 0x04 -#define SCSIOP_READ_BLOCK_LIMITS 0x05 -#define SCSIOP_REASSIGN_BLOCKS 0x07 -#define SCSIOP_READ6 0x08 -#define SCSIOP_RECEIVE 0x08 -#define SCSIOP_WRITE6 0x0A -#define SCSIOP_PRINT 0x0A -#define SCSIOP_SEND 0x0A -#define SCSIOP_SEEK6 0x0B -#define SCSIOP_TRACK_SELECT 0x0B -#define SCSIOP_SLEW_PRINT 0x0B -#define SCSIOP_SEEK_BLOCK 0x0C -#define SCSIOP_PARTITION 0x0D -#define SCSIOP_READ_REVERSE 0x0F -#define SCSIOP_WRITE_FILEMARKS 0x10 -#define SCSIOP_FLUSH_BUFFER 0x10 -#define SCSIOP_SPACE 0x11 -#define SCSIOP_INQUIRY 0x12 -#define SCSIOP_VERIFY6 0x13 -#define SCSIOP_RECOVER_BUF_DATA 0x14 -#define SCSIOP_MODE_SELECT 0x15 -#define SCSIOP_RESERVE_UNIT 0x16 -#define SCSIOP_RELEASE_UNIT 0x17 -#define SCSIOP_COPY 0x18 -#define SCSIOP_ERASE 0x19 -#define SCSIOP_MODE_SENSE 0x1A -#define SCSIOP_START_STOP_UNIT 0x1B -#define SCSIOP_STOP_PRINT 0x1B -#define SCSIOP_LOAD_UNLOAD 0x1B -#define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C -#define SCSIOP_SEND_DIAGNOSTIC 0x1D -#define SCSIOP_MEDIUM_REMOVAL 0x1E -#define SCSIOP_READ_CAPACITY 0x25 -#define SCSIOP_READ 0x28 -#define SCSIOP_WRITE 0x2A -#define SCSIOP_SEEK 0x2B -#define SCSIOP_LOCATE 0x2B -#define SCSIOP_WRITE_VERIFY 0x2E -#define SCSIOP_VERIFY 0x2F -#define SCSIOP_SEARCH_DATA_HIGH 0x30 -#define SCSIOP_SEARCH_DATA_EQUAL 0x31 -#define SCSIOP_SEARCH_DATA_LOW 0x32 -#define SCSIOP_SET_LIMITS 0x33 -#define SCSIOP_READ_POSITION 0x34 -#define SCSIOP_SYNCHRONIZE_CACHE 0x35 -#define SCSIOP_COMPARE 0x39 -#define SCSIOP_COPY_COMPARE 0x3A -#define SCSIOP_WRITE_DATA_BUFF 0x3B -#define SCSIOP_READ_DATA_BUFF 0x3C -#define SCSIOP_CHANGE_DEFINITION 0x40 -#define SCSIOP_READ_SUB_CHANNEL 0x42 -#define SCSIOP_READ_TOC 0x43 -#define SCSIOP_READ_HEADER 0x44 -#define SCSIOP_PLAY_AUDIO 0x45 -#define SCSIOP_PLAY_AUDIO_MSF 0x47 -#define SCSIOP_PLAY_TRACK_INDEX 0x48 -#define SCSIOP_PLAY_TRACK_RELATIVE 0x49 -#define SCSIOP_PAUSE_RESUME 0x4B -#define SCSIOP_LOG_SELECT 0x4C -#define SCSIOP_LOG_SENSE 0x4D -#define SCSIOP_MODE_SELECT10 0x55 -#define SCSIOP_MODE_SENSE10 0x5A -#define SCSIOP_LOAD_UNLOAD_SLOT 0xA6 -#define SCSIOP_MECHANISM_STATUS 0xBD -#define SCSIOP_READ_CD 0xBE - -// IDE command definitions -#define IDE_COMMAND_ATAPI_RESET 0x08 -#define IDE_COMMAND_READ 0x20 -#define IDE_COMMAND_WRITE 0x30 -#define IDE_COMMAND_RECALIBRATE 0x10 -#define IDE_COMMAND_SEEK 0x70 -#define IDE_COMMAND_SET_PARAMETERS 0x91 -#define IDE_COMMAND_VERIFY 0x40 -#define IDE_COMMAND_ATAPI_PACKET 0xA0 -#define IDE_COMMAND_ATAPI_IDENTIFY 0xA1 -#define IDE_CMD_READ_MULTIPLE 0xC4 -#define IDE_CMD_WRITE_MULTIPLE 0xC5 -#define IDE_CMD_SET_MULTIPLE 0xC6 -#define IDE_COMMAND_WRITE_DMA 0xCA -#define IDE_COMMAND_READ_DMA 0xC8 -#define IDE_COMMAND_IDENTIFY 0xEC - -// IDE status definitions -#define IDE_STATUS_ERROR 0x01 -#define IDE_STATUS_INDEX 0x02 -#define IDE_STATUS_CORRECTED_ERROR 0x04 -#define IDE_STATUS_DRQ 0x08 -#define IDE_STATUS_DSC 0x10 -#define IDE_STATUS_WRITE_FAULT 0x20 -#define IDE_STATUS_DRDY 0x40 -#define IDE_STATUS_BUSY 0x80 - -// IDE error definitions -#define IDE_ERROR_AMNF 0x01 -#define IDE_ERROR_TKONF 0x02 -#define IDE_ERROR_ABRT 0x04 -#define IDE_ERROR_MCR 0x08 -#define IDE_ERROR_IDFN 0x10 -#define IDE_ERROR_MC 0x20 -#define IDE_ERROR_UNC 0x40 -#define IDE_ERROR_BBK 0x80 - -// IDE interface structure -typedef struct _IDE_STRUCT - { - union - { - UCHAR ide[9]; - struct - { - USHORT data; - UCHAR sectors; - UCHAR lba[4]; - UCHAR cmd; - UCHAR spigot; - } ides; - } ide; - } IDE_STRUCT; - -// SCSI read capacity structure -typedef struct _READ_CAPACITY_DATA - { - ULONG blks; /* total blocks (converted to little endian) */ - ULONG blksiz; /* size of each (converted to little endian) */ - } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA; - -// SCSI inquiry data -typedef struct _INQUIRYDATA - { - UCHAR DeviceType :5; - UCHAR DeviceTypeQualifier :3; - UCHAR DeviceTypeModifier :7; - UCHAR RemovableMedia :1; - UCHAR Versions; - UCHAR ResponseDataFormat; - UCHAR AdditionalLength; - UCHAR Reserved[2]; - UCHAR SoftReset :1; - UCHAR CommandQueue :1; - UCHAR Reserved2 :1; - UCHAR LinkedCommands :1; - UCHAR Synchronous :1; - UCHAR Wide16Bit :1; - UCHAR Wide32Bit :1; - UCHAR RelativeAddressing :1; - UCHAR VendorId[8]; - UCHAR ProductId[16]; - UCHAR ProductRevisionLevel[4]; - UCHAR VendorSpecific[20]; - UCHAR Reserved3[40]; - } INQUIRYDATA, *PINQUIRYDATA; - -// IDE IDENTIFY data -typedef struct _IDENTIFY_DATA - { - USHORT GeneralConfiguration; // 00 - USHORT NumberOfCylinders; // 02 - USHORT Reserved1; // 04 - USHORT NumberOfHeads; // 06 - USHORT UnformattedBytesPerTrack; // 08 - USHORT UnformattedBytesPerSector; // 0A - USHORT SectorsPerTrack; // 0C - USHORT VendorUnique1[3]; // 0E - USHORT SerialNumber[10]; // 14 - USHORT BufferType; // 28 - USHORT BufferSectorSize; // 2A - USHORT NumberOfEccBytes; // 2C - USHORT FirmwareRevision[4]; // 2E - USHORT ModelNumber[20]; // 36 - UCHAR MaximumBlockTransfer; // 5E - UCHAR VendorUnique2; // 5F - USHORT DoubleWordIo; // 60 - USHORT Capabilities; // 62 - USHORT Reserved2; // 64 - UCHAR VendorUnique3; // 66 - UCHAR PioCycleTimingMode; // 67 - UCHAR VendorUnique4; // 68 - UCHAR DmaCycleTimingMode; // 69 - USHORT TranslationFieldsValid:1; // 6A - USHORT Reserved3:15; - USHORT NumberOfCurrentCylinders; // 6C - USHORT NumberOfCurrentHeads; // 6E - USHORT CurrentSectorsPerTrack; // 70 - ULONG CurrentSectorCapacity; // 72 - USHORT Reserved4[197]; // 76 - } IDENTIFY_DATA, *PIDENTIFY_DATA; - -// Identify data without the Reserved4. -typedef struct _IDENTIFY_DATA2 { - USHORT GeneralConfiguration; // 00 - USHORT NumberOfCylinders; // 02 - USHORT Reserved1; // 04 - USHORT NumberOfHeads; // 06 - USHORT UnformattedBytesPerTrack; // 08 - USHORT UnformattedBytesPerSector; // 0A - USHORT SectorsPerTrack; // 0C - USHORT VendorUnique1[3]; // 0E - USHORT SerialNumber[10]; // 14 - USHORT BufferType; // 28 - USHORT BufferSectorSize; // 2A - USHORT NumberOfEccBytes; // 2C - USHORT FirmwareRevision[4]; // 2E - USHORT ModelNumber[20]; // 36 - UCHAR MaximumBlockTransfer; // 5E - UCHAR VendorUnique2; // 5F - USHORT DoubleWordIo; // 60 - USHORT Capabilities; // 62 - USHORT Reserved2; // 64 - UCHAR VendorUnique3; // 66 - UCHAR PioCycleTimingMode; // 67 - UCHAR VendorUnique4; // 68 - UCHAR DmaCycleTimingMode; // 69 - USHORT TranslationFieldsValid:1; // 6A - USHORT Reserved3:15; - USHORT NumberOfCurrentCylinders; // 6C - USHORT NumberOfCurrentHeads; // 6E - USHORT CurrentSectorsPerTrack; // 70 - ULONG CurrentSectorCapacity; // 72 - } IDENTIFY_DATA2, *PIDENTIFY_DATA2; - -#endif // PSI_EIDE_SCSIOP - -// function prototypes -int Pci2220i_Detect (Scsi_Host_Template *tpnt); -int Pci2220i_Command (Scsi_Cmnd *SCpnt); -int Pci2220i_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)); -int Pci2220i_Abort (Scsi_Cmnd *SCpnt); -int Pci2220i_Reset (Scsi_Cmnd *SCpnt, unsigned int flags); -int Pci2220i_BiosParam (Disk *disk, kdev_t dev, int geom[]); - -#ifndef NULL - #define NULL 0 -#endif - -extern struct proc_dir_entry Proc_Scsi_Pci2220i; - -#define PCI2220I { NULL, NULL, \ - &Proc_Scsi_Pci2220i,/* proc_dir_entry */ \ - NULL, \ - "PCI-2220I EIDE Disk Controller", \ - Pci2220i_Detect, \ - NULL, \ - NULL, \ - Pci2220i_Command, \ - Pci2220i_QueueCommand, \ - Pci2220i_Abort, \ - Pci2220i_Reset, \ - NULL, \ - Pci2220i_BiosParam, \ - 1, \ - -1, \ - SG_NONE, \ - 1, \ - 0, \ - 0, \ - DISABLE_CLUSTERING } - -#endif diff --git a/drivers/scsi/psi240i.c b/drivers/scsi/psi240i.c deleted file mode 100644 index 2fc31cad852d..000000000000 --- a/drivers/scsi/psi240i.c +++ /dev/null @@ -1,717 +0,0 @@ -/*+M************************************************************************* - * Perceptive Solutions, Inc. PSI-240I device driver proc support for Linux. - * - * Copyright (c) 1997 Perceptive Solutions, 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; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * File Name: psi240i.c - * - * Description: SCSI driver for the PSI240I EIDE interface card. - * - *-M*************************************************************************/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "scsi.h" -#include "hosts.h" - -#include "psi240i.h" -#include "psi_chip.h" - -#include - -struct proc_dir_entry Proc_Scsi_Psi240i = - { PROC_SCSI_PSI240I, 7, "psi240i", S_IFDIR | S_IRUGO | S_IXUGO, 2 }; - -//#define DEBUG 1 - -#ifdef DEBUG -#define DEB(x) x -#else -#define DEB(x) -#endif - -#define MAXBOARDS 2 /* Increase this and the sizes of the arrays below, if you need more. */ - -#define PORT_DATA 0 -#define PORT_ERROR 1 -#define PORT_SECTOR_COUNT 2 -#define PORT_LBA_0 3 -#define PORT_LBA_8 4 -#define PORT_LBA_16 5 -#define PORT_LBA_24 6 -#define PORT_STAT_CMD 7 -#define PORT_SEL_FAIL 8 -#define PORT_IRQ_STATUS 9 -#define PORT_ADDRESS 10 -#define PORT_FAIL 11 -#define PORT_ALT_STAT 12 - -typedef struct - { - UCHAR device; // device code - UCHAR byte6; // device select register image - UCHAR spigot; // spigot number - UCHAR expectingIRQ; // flag for expecting and interrupt - USHORT sectors; // number of sectors per track - USHORT heads; // number of heads - USHORT cylinders; // number of cylinders for this device - USHORT spareword; // placeholder - ULONG blocks; // number of blocks on device - } OUR_DEVICE, *POUR_DEVICE; - -typedef struct - { - USHORT ports[13]; - OUR_DEVICE device[8]; - Scsi_Cmnd *pSCmnd; - IDE_STRUCT ide; - ULONG startSector; - USHORT sectorCount; - Scsi_Cmnd *SCpnt; - VOID *buffer; - USHORT expectingIRQ; - } ADAPTER240I, *PADAPTER240I; - -#define HOSTDATA(host) ((PADAPTER240I)&host->hostdata) - -static struct Scsi_Host *PsiHost[6] = {NULL,}; /* One for each IRQ level (10-15) */ -static IDENTIFY_DATA identifyData; -static SETUP ChipSetup; - -static USHORT portAddr[6] = {CHIP_ADRS_0, CHIP_ADRS_1, CHIP_ADRS_2, CHIP_ADRS_3, CHIP_ADRS_4, CHIP_ADRS_5}; - -/**************************************************************** - * Name: WriteData :LOCAL - * - * Description: Write data to device. - * - * Parameters: padapter - Pointer adapter data structure. - * - * Returns: TRUE if drive does not assert DRQ in time. - * - ****************************************************************/ -static int WriteData (PADAPTER240I padapter) - { - ULONG timer; - USHORT *pports = padapter->ports; - - timer = jiffies + TIMEOUT_DRQ; // calculate the timeout value - do { - if ( inb_p (pports[PORT_STAT_CMD]) & IDE_STATUS_DRQ ) - { - outsw (pports[PORT_DATA], padapter->buffer, (USHORT)padapter->ide.ide.ide[2] * 256); - return 0; - } - } while ( timer > jiffies ); // test for timeout - - padapter->ide.ide.ides.cmd = 0; // null out the command byte - return 1; - } -/**************************************************************** - * Name: IdeCmd :LOCAL - * - * Description: Process a queued command from the SCSI manager. - * - * Parameters: padapter - Pointer adapter data structure. - * - * Returns: Zero if no error or status register contents on error. - * - ****************************************************************/ -static UCHAR IdeCmd (PADAPTER240I padapter) - { - ULONG timer; - USHORT *pports = padapter->ports; - UCHAR status; - - outb_p (padapter->ide.ide.ides.spigot, pports[PORT_SEL_FAIL]); // select the spigot - outb_p (padapter->ide.ide.ide[6], pports[PORT_LBA_24]); // select the drive - timer = jiffies + TIMEOUT_READY; // calculate the timeout value - do { - status = inb_p (padapter->ports[PORT_STAT_CMD]); - if ( status & IDE_STATUS_DRDY ) - { - outb_p (padapter->ide.ide.ide[2], pports[PORT_SECTOR_COUNT]); - outb_p (padapter->ide.ide.ide[3], pports[PORT_LBA_0]); - outb_p (padapter->ide.ide.ide[4], pports[PORT_LBA_8]); - outb_p (padapter->ide.ide.ide[5], pports[PORT_LBA_16]); - padapter->expectingIRQ = 1; - outb_p (padapter->ide.ide.ide[7], pports[PORT_STAT_CMD]); - - if ( padapter->ide.ide.ides.cmd == IDE_CMD_WRITE_MULTIPLE ) - return (WriteData (padapter)); - - return 0; - } - } while ( timer > jiffies ); // test for timeout - - padapter->ide.ide.ides.cmd = 0; // null out the command byte - return status; - } -/**************************************************************** - * Name: SetupTransfer :LOCAL - * - * Description: Setup a data transfer command. - * - * Parameters: padapter - Pointer adapter data structure. - * drive - Drive/head register upper nibble only. - * - * Returns: TRUE if no data to transfer. - * - ****************************************************************/ -static int SetupTransfer (PADAPTER240I padapter, UCHAR drive) - { - if ( padapter->sectorCount ) - { - *(ULONG *)padapter->ide.ide.ides.lba = padapter->startSector; - padapter->ide.ide.ide[6] |= drive; - padapter->ide.ide.ides.sectors = ( padapter->sectorCount > SECTORSXFER ) ? SECTORSXFER : padapter->sectorCount; - padapter->sectorCount -= padapter->ide.ide.ides.sectors; // bump the start and count for next xfer - padapter->startSector += padapter->ide.ide.ides.sectors; - return 0; - } - else - { - padapter->ide.ide.ides.cmd = 0; // null out the command byte - padapter->SCpnt = NULL; - return 1; - } - } -/**************************************************************** - * Name: DecodeError :LOCAL - * - * Description: Decode and process device errors. - * - * Parameters: pshost - Pointer to host data block. - * status - Status register code. - * - * Returns: The driver status code. - * - ****************************************************************/ -static ULONG DecodeError (struct Scsi_Host *pshost, UCHAR status) - { - PADAPTER240I padapter = HOSTDATA(pshost); - UCHAR error; - - padapter->expectingIRQ = 0; - padapter->SCpnt = NULL; - if ( status & IDE_STATUS_WRITE_FAULT ) - { - return DID_PARITY << 16; - } - if ( status & IDE_STATUS_BUSY ) - return DID_BUS_BUSY << 16; - - error = inb_p (padapter->ports[PORT_ERROR]); - DEB(printk ("\npsi240i error register: %x", error)); - switch ( error ) - { - case IDE_ERROR_AMNF: - case IDE_ERROR_TKONF: - case IDE_ERROR_ABRT: - case IDE_ERROR_IDFN: - case IDE_ERROR_UNC: - case IDE_ERROR_BBK: - default: - return DID_ERROR << 16; - } - return DID_ERROR << 16; - } -/**************************************************************** - * Name: Irq_Handler :LOCAL - * - * Description: Interrupt handler. - * - * Parameters: irq - Hardware IRQ number. - * dev_id - - * regs - - * - * Returns: TRUE if drive is not ready in time. - * - ****************************************************************/ -static void Irq_Handler (int irq, void *dev_id, struct pt_regs *regs) - { - struct Scsi_Host *shost; // Pointer to host data block - PADAPTER240I padapter; // Pointer to adapter control structure - USHORT *pports; // I/O port array - Scsi_Cmnd *SCpnt; - UCHAR status; - int z; - - DEB(printk ("\npsi240i recieved interrupt\n")); - - shost = PsiHost[irq - 10]; - if ( !shost ) - panic ("Splunge!"); - - padapter = HOSTDATA(shost); - pports = padapter->ports; - SCpnt = padapter->SCpnt; - - if ( !padapter->expectingIRQ ) - { - DEB(printk ("\npsi240i Unsolicited interrupt\n")); - return; - } - padapter->expectingIRQ = 0; - - status = inb_p (padapter->ports[PORT_STAT_CMD]); // read the device status - if ( status & (IDE_STATUS_ERROR | IDE_STATUS_WRITE_FAULT) ) - goto irqerror; - - DEB(printk ("\npsi240i processing interrupt")); - switch ( padapter->ide.ide.ides.cmd ) // decide how to handle the interrupt - { - case IDE_CMD_READ_MULTIPLE: - if ( status & IDE_STATUS_DRQ ) - { - insw (pports[PORT_DATA], padapter->buffer, (USHORT)padapter->ide.ide.ides.sectors * 256); - padapter->buffer += padapter->ide.ide.ides.sectors * 512; - if ( SetupTransfer (padapter, padapter->ide.ide.ide[6] & 0xF0) ) - { - SCpnt->result = DID_OK << 16; - padapter->SCpnt = NULL; - SCpnt->scsi_done (SCpnt); - return; - } - if ( !(status = IdeCmd (padapter)) ) - return; - } - break; - - case IDE_CMD_WRITE_MULTIPLE: - padapter->buffer += padapter->ide.ide.ides.sectors * 512; - if ( SetupTransfer (padapter, padapter->ide.ide.ide[6] & 0xF0) ) - { - SCpnt->result = DID_OK << 16; - padapter->SCpnt = NULL; - SCpnt->scsi_done (SCpnt); - return; - } - if ( !(status = IdeCmd (padapter)) ) - return; - break; - - case IDE_COMMAND_IDENTIFY: - { - PINQUIRYDATA pinquiryData = SCpnt->request_buffer; - - if ( status & IDE_STATUS_DRQ ) - { - insw (pports[PORT_DATA], &identifyData, sizeof (identifyData) >> 1); - - memset (pinquiryData, 0, SCpnt->request_bufflen); // Zero INQUIRY data structure. - pinquiryData->DeviceType = 0; - pinquiryData->Versions = 2; - pinquiryData->AdditionalLength = 35 - 4; - - // Fill in vendor identification fields. - for ( z = 0; z < 20; z += 2 ) - { - pinquiryData->VendorId[z] = ((UCHAR *)identifyData.ModelNumber)[z + 1]; - pinquiryData->VendorId[z + 1] = ((UCHAR *)identifyData.ModelNumber)[z]; - } - - // Initialize unused portion of product id. - for ( z = 0; z < 4; z++ ) - pinquiryData->ProductId[12 + z] = ' '; - - // Move firmware revision from IDENTIFY data to - // product revision in INQUIRY data. - for ( z = 0; z < 4; z += 2 ) - { - pinquiryData->ProductRevisionLevel[z] = ((UCHAR *)identifyData.FirmwareRevision)[z + 1]; - pinquiryData->ProductRevisionLevel[z + 1] = ((UCHAR *)identifyData.FirmwareRevision)[z]; - } - - SCpnt->result = DID_OK << 16; - padapter->SCpnt = NULL; - SCpnt->scsi_done (SCpnt); - return; - } - break; - } - - default: - SCpnt->result = DID_OK << 16; - padapter->SCpnt = NULL; - SCpnt->scsi_done (SCpnt); - return; - } - -irqerror:; - DEB(printk ("\npsi240i error Device Status: %X\n", status)); - SCpnt->result = DecodeError (shost, status); - SCpnt->scsi_done (SCpnt); - } -/**************************************************************** - * Name: Psi240i_QueueCommand - * - * Description: Process a queued command from the SCSI manager. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * done - Pointer to done function to call. - * - * Returns: Status code. - * - ****************************************************************/ -int Psi240i_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) - { - UCHAR *cdb = (UCHAR *)SCpnt->cmnd; // Pointer to SCSI CDB - PADAPTER240I padapter = HOSTDATA(SCpnt->host); // Pointer to adapter control structure - POUR_DEVICE pdev = &padapter->device[SCpnt->target];// Pointer to device information - UCHAR rc; // command return code - - SCpnt->scsi_done = done; - padapter->ide.ide.ides.spigot = pdev->spigot; - padapter->buffer = SCpnt->request_buffer; - if (done) - { - if ( !pdev->device || SCpnt->lun ) - { - SCpnt->result = DID_BAD_TARGET << 16; - done (SCpnt); - return 0; - } - } - else - { - printk("psi240i_queuecommand: %02X: done can't be NULL\n", *cdb); - return 0; - } - - switch ( *cdb ) - { - case SCSIOP_INQUIRY: // inquiry CDB - { - padapter->ide.ide.ide[6] = pdev->byte6; - padapter->ide.ide.ides.cmd = IDE_COMMAND_IDENTIFY; - break; - } - - case SCSIOP_TEST_UNIT_READY: // test unit ready CDB - SCpnt->result = DID_OK << 16; - done (SCpnt); - return 0; - - case SCSIOP_READ_CAPACITY: // read capctiy CDB - { - PREAD_CAPACITY_DATA pdata = (PREAD_CAPACITY_DATA)SCpnt->request_buffer; - - pdata->blksiz = 0x20000; - XANY2SCSI ((UCHAR *)&pdata->blks, pdev->blocks); - SCpnt->result = DID_OK << 16; - done (SCpnt); - return 0; - } - - case SCSIOP_VERIFY: // verify CDB - *(ULONG *)padapter->ide.ide.ides.lba = XSCSI2LONG (&cdb[2]); - padapter->ide.ide.ide[6] |= pdev->byte6; - padapter->ide.ide.ide[2] = (UCHAR)((USHORT)cdb[8] | ((USHORT)cdb[7] << 8)); - padapter->ide.ide.ides.cmd = IDE_COMMAND_VERIFY; - break; - - case SCSIOP_READ: // read10 CDB - padapter->startSector = XSCSI2LONG (&cdb[2]); - padapter->sectorCount = (USHORT)cdb[8] | ((USHORT)cdb[7] << 8); - SetupTransfer (padapter, pdev->byte6); - padapter->ide.ide.ides.cmd = IDE_CMD_READ_MULTIPLE; - break; - - case SCSIOP_READ6: // read6 CDB - padapter->startSector = SCSI2LONG (&cdb[1]); - padapter->sectorCount = cdb[4]; - SetupTransfer (padapter, pdev->byte6); - padapter->ide.ide.ides.cmd = IDE_CMD_READ_MULTIPLE; - break; - - case SCSIOP_WRITE: // write10 CDB - padapter->startSector = XSCSI2LONG (&cdb[2]); - padapter->sectorCount = (USHORT)cdb[8] | ((USHORT)cdb[7] << 8); - SetupTransfer (padapter, pdev->byte6); - padapter->ide.ide.ides.cmd = IDE_CMD_WRITE_MULTIPLE; - break; - case SCSIOP_WRITE6: // write6 CDB - padapter->startSector = SCSI2LONG (&cdb[1]); - padapter->sectorCount = cdb[4]; - SetupTransfer (padapter, pdev->byte6); - padapter->ide.ide.ides.cmd = IDE_CMD_WRITE_MULTIPLE; - break; - - default: - DEB (printk ("psi240i_queuecommand: Unsupported command %02X\n", *cdb)); - SCpnt->result = DID_ERROR << 16; - done (SCpnt); - return 0; - } - - padapter->SCpnt = SCpnt; // Save this command data - - rc = IdeCmd (padapter); - if ( rc ) - { - padapter->expectingIRQ = 0; - DEB (printk ("psi240i_queuecommand: %02X, %02X: Device failed to respond for command\n", *cdb, padapter->ide.ide.ides.cmd)); - SCpnt->result = DID_ERROR << 16; - done (SCpnt); - return 0; - } - DEB (printk("psi240i_queuecommand: %02X, %02X now waiting for interrupt ", *cdb, padapter->ide.ide.ides.cmd)); - return 0; - } - -static void internal_done(Scsi_Cmnd * SCpnt) - { - SCpnt->SCp.Status++; - } -/**************************************************************** - * Name: Psi240i_Command - * - * Description: Process a command from the SCSI manager. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * - * Returns: Status code. - * - ****************************************************************/ -int Psi240i_Command (Scsi_Cmnd *SCpnt) - { - DEB(printk("psi240i_command: ..calling psi240i_queuecommand\n")); - - Psi240i_QueueCommand (SCpnt, internal_done); - - SCpnt->SCp.Status = 0; - while (!SCpnt->SCp.Status) - barrier (); - return SCpnt->result; - } -/*************************************************************************** - * Name: ReadChipMemory - * - * Description: Read information from controller memory. - * - * Parameters: psetup - Pointer to memory image of setup information. - * base - base address of memory. - * length - lenght of data space in bytes. - * port - I/O address of data port. - * - * Returns: Nothing. - * - **************************************************************************/ -void ReadChipMemory (void *pdata, USHORT base, USHORT length, USHORT port) - { - USHORT z, zz; - UCHAR *pd = (UCHAR *)pdata; - outb_p (SEL_NONE, port + REG_SEL_FAIL); // setup data port - zz = 0; - while ( zz < length ) - { - outw_p (base, port + REG_ADDRESS); // setup address - - for ( z = 0; z < 8; z++ ) - { - if ( (zz + z) < length ) - *pd++ = inb_p (port + z); // read data byte - } - zz += 8; - base += 8; - } - } -/**************************************************************** - * Name: Psi240i_Detect - * - * Description: Detect and initialize our boards. - * - * Parameters: tpnt - Pointer to SCSI host template structure. - * - * Returns: Number of adapters found. - * - ****************************************************************/ -int Psi240i_Detect (Scsi_Host_Template *tpnt) - { - int board; - int count = 0; - int unit; - int z; - USHORT port; - CHIP_CONFIG_N chipConfig; - CHIP_DEVICE_N chipDevice[8]; - struct Scsi_Host *pshost; - ULONG flags; - - for ( board = 0; board < 6; board++ ) // scan for I/O ports - { - port = portAddr[board]; // get base address to test - if ( check_region (port, 16) ) // test for I/O addresses available - continue; // nope - if ( inb_p (port + REG_FAIL) != CHIP_ID ) // do the first test for likley hood that it is us - continue; - outb_p (SEL_NONE, port + REG_SEL_FAIL); // setup EEPROM/RAM access - outw (0, port + REG_ADDRESS); // setup EEPROM address zero - if ( inb_p (port) != 0x55 ) // test 1st byte - continue; // nope - if ( inb_p (port + 1) != 0xAA ) // test 2nd byte - continue; // nope - - // at this point our board is found and can be accessed. Now we need to initialize - // our informatation and register with the kernel. - - - ReadChipMemory (&chipConfig, CHIP_CONFIG, sizeof (chipConfig), port); - ReadChipMemory (&chipDevice, CHIP_DEVICE, sizeof (chipDevice), port); - ReadChipMemory (&ChipSetup, CHIP_EEPROM_DATA, sizeof (ChipSetup), port); - - if ( !chipConfig.numDrives ) // if no devices on this board - continue; - - pshost = scsi_register (tpnt, sizeof(ADAPTER240I)); - - save_flags (flags); - cli (); - if ( request_irq (chipConfig.irq, Irq_Handler, 0, "psi240i", NULL) ) - { - printk ("Unable to allocate IRQ for PSI-240I controller.\n"); - restore_flags (flags); - goto unregister; - } - - PsiHost[chipConfig.irq - 10] = pshost; - pshost->unique_id = port; - pshost->io_port = port; - pshost->n_io_port = 16; /* Number of bytes of I/O space used */ - pshost->irq = chipConfig.irq; - - for ( z = 0; z < 11; z++ ) // build regester address array - HOSTDATA(pshost)->ports[z] = port + z; - HOSTDATA(pshost)->ports[11] = port + REG_FAIL; - HOSTDATA(pshost)->ports[12] = port + REG_ALT_STAT; - DEB (printk ("\nPorts =")); - DEB (for (z=0;z<13;z++) printk(" %#04X",HOSTDATA(pshost)->ports[z]);); - - for ( z = 0; z < chipConfig.numDrives; ++z ) - { - unit = chipDevice[z].channel & 0x0F; - HOSTDATA(pshost)->device[unit].device = ChipSetup.setupDevice[unit].device; - HOSTDATA(pshost)->device[unit].byte6 = (UCHAR)(((unit & 1) << 4) | 0xE0); - HOSTDATA(pshost)->device[unit].spigot = (UCHAR)(1 << (unit >> 1)); - HOSTDATA(pshost)->device[unit].sectors = ChipSetup.setupDevice[unit].sectors; - HOSTDATA(pshost)->device[unit].heads = ChipSetup.setupDevice[unit].heads; - HOSTDATA(pshost)->device[unit].cylinders = ChipSetup.setupDevice[unit].cylinders; - HOSTDATA(pshost)->device[unit].blocks = ChipSetup.setupDevice[unit].blocks; - DEB (printk ("\nHOSTDATA->device = %X", HOSTDATA(pshost)->device[unit].device)); - DEB (printk ("\n byte6 = %X", HOSTDATA(pshost)->device[unit].byte6)); - DEB (printk ("\n spigot = %X", HOSTDATA(pshost)->device[unit].spigot)); - DEB (printk ("\n sectors = %X", HOSTDATA(pshost)->device[unit].sectors)); - DEB (printk ("\n heads = %X", HOSTDATA(pshost)->device[unit].heads)); - DEB (printk ("\n cylinders = %X", HOSTDATA(pshost)->device[unit].cylinders)); - DEB (printk ("\n blocks = %lX", HOSTDATA(pshost)->device[unit].blocks)); - } - - restore_flags (flags); - printk("\nPSI-240I EIDE CONTROLLER: at I/O = %x IRQ = %d\n", port, chipConfig.irq); - printk("(C) 1997 Perceptive Solutions, Inc. All rights reserved\n\n"); - count++; - continue; - -unregister:; - scsi_unregister (pshost); - } - return count; - } -/**************************************************************** - * Name: Psi240i_Abort - * - * Description: Process the Abort command from the SCSI manager. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * - * Returns: Allways snooze. - * - ****************************************************************/ -int Psi240i_Abort (Scsi_Cmnd *SCpnt) - { - DEB (printk ("psi240i_abort\n")); - return SCSI_ABORT_SNOOZE; - } -/**************************************************************** - * Name: Psi240i_Reset - * - * Description: Process the Reset command from the SCSI manager. - * - * Parameters: SCpnt - Pointer to SCSI command structure. - * flags - Flags about the reset command - * - * Returns: No active command at this time, so this means - * that each time we got some kind of response the - * last time through. Tell the mid-level code to - * request sense information in order to decide what - * to do next. - * - ****************************************************************/ -int Psi240i_Reset (Scsi_Cmnd *SCpnt, unsigned int reset_flags) - { - return SCSI_RESET_PUNT; - } - -#include "sd.h" - -/**************************************************************** - * Name: Psi240i_BiosParam - * - * Description: Process the biosparam request from the SCSI manager to - * return C/H/S data. - * - * Parameters: disk - Pointer to SCSI disk structure. - * dev - Major/minor number from kernel. - * geom - Pointer to integer array to place geometry data. - * - * Returns: zero. - * - ****************************************************************/ -int Psi240i_BiosParam (Scsi_Disk *disk, kdev_t dev, int geom[]) - { - POUR_DEVICE pdev; - - pdev = &(HOSTDATA(disk->device->host)->device[disk->device->id]); - - geom[0] = pdev->heads; - geom[1] = pdev->sectors; - geom[2] = pdev->cylinders; - return 0; - } - - -#ifdef MODULE -/* Eventually this will go into an include file, but this will be later */ -Scsi_Host_Template driver_template = PSI240I; - -#include "scsi_module.c" -#endif - diff --git a/drivers/scsi/psi240i.h b/drivers/scsi/psi240i.h deleted file mode 100644 index 282ee1bb0f0d..000000000000 --- a/drivers/scsi/psi240i.h +++ /dev/null @@ -1,344 +0,0 @@ -/*+M************************************************************************* - * Perceptive Solutions, Inc. PSI-240I device driver proc support for Linux. - * - * Copyright (c) 1997 Perceptive Solutions, 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; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * File Name: psi240i.h - * - * Description: Header file for the SCSI driver for the PSI240I - * EIDE interface card. - * - *-M*************************************************************************/ -#ifndef _PSI240I_H -#define _PSI240I_H - -#include -#include - -#ifndef PSI_EIDE_SCSIOP -#define PSI_EIDE_SCSIOP 1 - -/************************************************/ -/* Some defines that we like */ -/************************************************/ -#define CHAR char -#define UCHAR unsigned char -#define SHORT short -#define USHORT unsigned short -#define BOOL unsigned short -#define LONG long -#define ULONG unsigned long -#define VOID void - -/************************************************/ -/* Timeout konstants */ -/************************************************/ -#define TIMEOUT_READY 10 // 100 mSec -#define TIMEOUT_DRQ 40 // 400 mSec - -/************************************************/ -/* Misc. macros */ -/************************************************/ -#define ANY2SCSI(up, p) \ -((UCHAR *)up)[0] = (((ULONG)(p)) >> 8); \ -((UCHAR *)up)[1] = ((ULONG)(p)); - -#define SCSI2LONG(up) \ -( (((long)*(((UCHAR *)up))) << 16) \ -+ (((long)(((UCHAR *)up)[1])) << 8) \ -+ ((long)(((UCHAR *)up)[2])) ) - -#define XANY2SCSI(up, p) \ -((UCHAR *)up)[0] = ((long)(p)) >> 24; \ -((UCHAR *)up)[1] = ((long)(p)) >> 16; \ -((UCHAR *)up)[2] = ((long)(p)) >> 8; \ -((UCHAR *)up)[3] = ((long)(p)); - -#define XSCSI2LONG(up) \ -( (((long)(((UCHAR *)up)[0])) << 24) \ -+ (((long)(((UCHAR *)up)[1])) << 16) \ -+ (((long)(((UCHAR *)up)[2])) << 8) \ -+ ((long)(((UCHAR *)up)[3])) ) - -/************************************************/ -/* SCSI CDB operation codes */ -/************************************************/ -#define SCSIOP_TEST_UNIT_READY 0x00 -#define SCSIOP_REZERO_UNIT 0x01 -#define SCSIOP_REWIND 0x01 -#define SCSIOP_REQUEST_BLOCK_ADDR 0x02 -#define SCSIOP_REQUEST_SENSE 0x03 -#define SCSIOP_FORMAT_UNIT 0x04 -#define SCSIOP_READ_BLOCK_LIMITS 0x05 -#define SCSIOP_REASSIGN_BLOCKS 0x07 -#define SCSIOP_READ6 0x08 -#define SCSIOP_RECEIVE 0x08 -#define SCSIOP_WRITE6 0x0A -#define SCSIOP_PRINT 0x0A -#define SCSIOP_SEND 0x0A -#define SCSIOP_SEEK6 0x0B -#define SCSIOP_TRACK_SELECT 0x0B -#define SCSIOP_SLEW_PRINT 0x0B -#define SCSIOP_SEEK_BLOCK 0x0C -#define SCSIOP_PARTITION 0x0D -#define SCSIOP_READ_REVERSE 0x0F -#define SCSIOP_WRITE_FILEMARKS 0x10 -#define SCSIOP_FLUSH_BUFFER 0x10 -#define SCSIOP_SPACE 0x11 -#define SCSIOP_INQUIRY 0x12 -#define SCSIOP_VERIFY6 0x13 -#define SCSIOP_RECOVER_BUF_DATA 0x14 -#define SCSIOP_MODE_SELECT 0x15 -#define SCSIOP_RESERVE_UNIT 0x16 -#define SCSIOP_RELEASE_UNIT 0x17 -#define SCSIOP_COPY 0x18 -#define SCSIOP_ERASE 0x19 -#define SCSIOP_MODE_SENSE 0x1A -#define SCSIOP_START_STOP_UNIT 0x1B -#define SCSIOP_STOP_PRINT 0x1B -#define SCSIOP_LOAD_UNLOAD 0x1B -#define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C -#define SCSIOP_SEND_DIAGNOSTIC 0x1D -#define SCSIOP_MEDIUM_REMOVAL 0x1E -#define SCSIOP_READ_CAPACITY 0x25 -#define SCSIOP_READ 0x28 -#define SCSIOP_WRITE 0x2A -#define SCSIOP_SEEK 0x2B -#define SCSIOP_LOCATE 0x2B -#define SCSIOP_WRITE_VERIFY 0x2E -#define SCSIOP_VERIFY 0x2F -#define SCSIOP_SEARCH_DATA_HIGH 0x30 -#define SCSIOP_SEARCH_DATA_EQUAL 0x31 -#define SCSIOP_SEARCH_DATA_LOW 0x32 -#define SCSIOP_SET_LIMITS 0x33 -#define SCSIOP_READ_POSITION 0x34 -#define SCSIOP_SYNCHRONIZE_CACHE 0x35 -#define SCSIOP_COMPARE 0x39 -#define SCSIOP_COPY_COMPARE 0x3A -#define SCSIOP_WRITE_DATA_BUFF 0x3B -#define SCSIOP_READ_DATA_BUFF 0x3C -#define SCSIOP_CHANGE_DEFINITION 0x40 -#define SCSIOP_READ_SUB_CHANNEL 0x42 -#define SCSIOP_READ_TOC 0x43 -#define SCSIOP_READ_HEADER 0x44 -#define SCSIOP_PLAY_AUDIO 0x45 -#define SCSIOP_PLAY_AUDIO_MSF 0x47 -#define SCSIOP_PLAY_TRACK_INDEX 0x48 -#define SCSIOP_PLAY_TRACK_RELATIVE 0x49 -#define SCSIOP_PAUSE_RESUME 0x4B -#define SCSIOP_LOG_SELECT 0x4C -#define SCSIOP_LOG_SENSE 0x4D -#define SCSIOP_MODE_SELECT10 0x55 -#define SCSIOP_MODE_SENSE10 0x5A -#define SCSIOP_LOAD_UNLOAD_SLOT 0xA6 -#define SCSIOP_MECHANISM_STATUS 0xBD -#define SCSIOP_READ_CD 0xBE - -// IDE command definitions -#define IDE_COMMAND_ATAPI_RESET 0x08 -#define IDE_COMMAND_READ 0x20 -#define IDE_COMMAND_WRITE 0x30 -#define IDE_COMMAND_RECALIBRATE 0x10 -#define IDE_COMMAND_SEEK 0x70 -#define IDE_COMMAND_SET_PARAMETERS 0x91 -#define IDE_COMMAND_VERIFY 0x40 -#define IDE_COMMAND_ATAPI_PACKET 0xA0 -#define IDE_COMMAND_ATAPI_IDENTIFY 0xA1 -#define IDE_CMD_READ_MULTIPLE 0xC4 -#define IDE_CMD_WRITE_MULTIPLE 0xC5 -#define IDE_CMD_SET_MULTIPLE 0xC6 -#define IDE_COMMAND_WRITE_DMA 0xCA -#define IDE_COMMAND_READ_DMA 0xC8 -#define IDE_COMMAND_IDENTIFY 0xEC - -// IDE status definitions -#define IDE_STATUS_ERROR 0x01 -#define IDE_STATUS_INDEX 0x02 -#define IDE_STATUS_CORRECTED_ERROR 0x04 -#define IDE_STATUS_DRQ 0x08 -#define IDE_STATUS_DSC 0x10 -#define IDE_STATUS_WRITE_FAULT 0x20 -#define IDE_STATUS_DRDY 0x40 -#define IDE_STATUS_BUSY 0x80 - -// IDE error definitions -#define IDE_ERROR_AMNF 0x01 -#define IDE_ERROR_TKONF 0x02 -#define IDE_ERROR_ABRT 0x04 -#define IDE_ERROR_MCR 0x08 -#define IDE_ERROR_IDFN 0x10 -#define IDE_ERROR_MC 0x20 -#define IDE_ERROR_UNC 0x40 -#define IDE_ERROR_BBK 0x80 - -// IDE interface structure -typedef struct _IDE_STRUCT - { - union - { - UCHAR ide[9]; - struct - { - USHORT data; - UCHAR sectors; - UCHAR lba[4]; - UCHAR cmd; - UCHAR spigot; - } ides; - } ide; - } IDE_STRUCT; - -// SCSI read capacity structure -typedef struct _READ_CAPACITY_DATA - { - ULONG blks; /* total blocks (converted to little endian) */ - ULONG blksiz; /* size of each (converted to little endian) */ - } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA; - -// SCSI inquiry data -typedef struct _INQUIRYDATA - { - UCHAR DeviceType :5; - UCHAR DeviceTypeQualifier :3; - UCHAR DeviceTypeModifier :7; - UCHAR RemovableMedia :1; - UCHAR Versions; - UCHAR ResponseDataFormat; - UCHAR AdditionalLength; - UCHAR Reserved[2]; - UCHAR SoftReset :1; - UCHAR CommandQueue :1; - UCHAR Reserved2 :1; - UCHAR LinkedCommands :1; - UCHAR Synchronous :1; - UCHAR Wide16Bit :1; - UCHAR Wide32Bit :1; - UCHAR RelativeAddressing :1; - UCHAR VendorId[8]; - UCHAR ProductId[16]; - UCHAR ProductRevisionLevel[4]; - UCHAR VendorSpecific[20]; - UCHAR Reserved3[40]; - } INQUIRYDATA, *PINQUIRYDATA; - -// IDE IDENTIFY data -typedef struct _IDENTIFY_DATA - { - USHORT GeneralConfiguration; // 00 - USHORT NumberOfCylinders; // 02 - USHORT Reserved1; // 04 - USHORT NumberOfHeads; // 06 - USHORT UnformattedBytesPerTrack; // 08 - USHORT UnformattedBytesPerSector; // 0A - USHORT SectorsPerTrack; // 0C - USHORT VendorUnique1[3]; // 0E - USHORT SerialNumber[10]; // 14 - USHORT BufferType; // 28 - USHORT BufferSectorSize; // 2A - USHORT NumberOfEccBytes; // 2C - USHORT FirmwareRevision[4]; // 2E - USHORT ModelNumber[20]; // 36 - UCHAR MaximumBlockTransfer; // 5E - UCHAR VendorUnique2; // 5F - USHORT DoubleWordIo; // 60 - USHORT Capabilities; // 62 - USHORT Reserved2; // 64 - UCHAR VendorUnique3; // 66 - UCHAR PioCycleTimingMode; // 67 - UCHAR VendorUnique4; // 68 - UCHAR DmaCycleTimingMode; // 69 - USHORT TranslationFieldsValid:1; // 6A - USHORT Reserved3:15; - USHORT NumberOfCurrentCylinders; // 6C - USHORT NumberOfCurrentHeads; // 6E - USHORT CurrentSectorsPerTrack; // 70 - ULONG CurrentSectorCapacity; // 72 - USHORT Reserved4[197]; // 76 - } IDENTIFY_DATA, *PIDENTIFY_DATA; - -// Identify data without the Reserved4. -typedef struct _IDENTIFY_DATA2 { - USHORT GeneralConfiguration; // 00 - USHORT NumberOfCylinders; // 02 - USHORT Reserved1; // 04 - USHORT NumberOfHeads; // 06 - USHORT UnformattedBytesPerTrack; // 08 - USHORT UnformattedBytesPerSector; // 0A - USHORT SectorsPerTrack; // 0C - USHORT VendorUnique1[3]; // 0E - USHORT SerialNumber[10]; // 14 - USHORT BufferType; // 28 - USHORT BufferSectorSize; // 2A - USHORT NumberOfEccBytes; // 2C - USHORT FirmwareRevision[4]; // 2E - USHORT ModelNumber[20]; // 36 - UCHAR MaximumBlockTransfer; // 5E - UCHAR VendorUnique2; // 5F - USHORT DoubleWordIo; // 60 - USHORT Capabilities; // 62 - USHORT Reserved2; // 64 - UCHAR VendorUnique3; // 66 - UCHAR PioCycleTimingMode; // 67 - UCHAR VendorUnique4; // 68 - UCHAR DmaCycleTimingMode; // 69 - USHORT TranslationFieldsValid:1; // 6A - USHORT Reserved3:15; - USHORT NumberOfCurrentCylinders; // 6C - USHORT NumberOfCurrentHeads; // 6E - USHORT CurrentSectorsPerTrack; // 70 - ULONG CurrentSectorCapacity; // 72 - } IDENTIFY_DATA2, *PIDENTIFY_DATA2; - -#endif // PSI_EIDE_SCSIOP - -// function prototypes -int Psi240i_Detect (Scsi_Host_Template *tpnt); -int Psi240i_Command (Scsi_Cmnd *SCpnt); -int Psi240i_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)); -int Psi240i_Abort (Scsi_Cmnd *SCpnt); -int Psi240i_Reset (Scsi_Cmnd *SCpnt, unsigned int flags); -int Psi240i_BiosParam (Disk *disk, kdev_t dev, int geom[]); - -#ifndef NULL - #define NULL 0 -#endif - -extern struct proc_dir_entry Proc_Scsi_Psi240i; - -#define PSI240I { NULL, NULL, \ - &Proc_Scsi_Psi240i,/* proc_dir_entry */ \ - NULL, \ - "PSI-240I EIDE Disk Controller", \ - Psi240i_Detect, \ - NULL, \ - NULL, \ - Psi240i_Command, \ - Psi240i_QueueCommand, \ - Psi240i_Abort, \ - Psi240i_Reset, \ - NULL, \ - Psi240i_BiosParam, \ - 1, \ - -1, \ - SG_NONE, \ - 1, \ - 0, \ - 0, \ - DISABLE_CLUSTERING } - -#endif diff --git a/drivers/scsi/psi_chip.h b/drivers/scsi/psi_chip.h deleted file mode 100644 index 644c42fe178c..000000000000 --- a/drivers/scsi/psi_chip.h +++ /dev/null @@ -1,194 +0,0 @@ -/*+M************************************************************************* - * Perceptive Solutions, Inc. PSI-240I device driver proc support for Linux. - * - * Copyright (c) 1997 Perceptive Solutions, 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; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * File Name: psi_chip.h - * - * Description: This file contains the interface defines and - * error codes. - * - *-M*************************************************************************/ -#ifndef PSI_CHIP -#define PSI_CHIP - -/************************************************/ -/* Misc konstants */ -/************************************************/ -#define CHIP_MAXDRIVES 8 - -/************************************************/ -/* Chip I/O addresses */ -/************************************************/ -#define CHIP_ADRS_0 0x0130 -#define CHIP_ADRS_1 0x0150 -#define CHIP_ADRS_2 0x0190 -#define CHIP_ADRS_3 0x0210 -#define CHIP_ADRS_4 0x0230 -#define CHIP_ADRS_5 0x0250 - -/************************************************/ -/* EEPROM locations */ -/************************************************/ -#define CHIP_EEPROM_BIOS 0x0000 // BIOS base address -#define CHIP_EEPROM_DATA 0x2000 // SETUP data base address -#define CHIP_EEPROM_FACTORY 0x2400 // FACTORY data base address -#define CHIP_EEPROM_SETUP 0x3000 // SETUP PROGRAM base address - -#define CHIP_EEPROM_SIZE 32768U // size of the entire EEPROM -#define CHIP_EEPROM_BIOS_SIZE 8192 // size of the BIOS in bytes -#define CHIP_EEPROM_DATA_SIZE 4096 // size of factory, setup, log data block in bytes -#define CHIP_EEPROM_SETUP_SIZE 20480U // size of the setup program in bytes - -/************************************************/ -/* Chip Interrupts */ -/************************************************/ -#define CHIP_IRQ_10 0x72 -#define CHIP_IRQ_11 0x73 -#define CHIP_IRQ_12 0x74 - -/************************************************/ -/* Chip Setup addresses */ -/************************************************/ -#define CHIP_SETUP_BASE 0x0000C000L - -/************************************************/ -/* Chip Register address offsets */ -/************************************************/ -#define REG_DATA 0x00 -#define REG_ERROR 0x01 -#define REG_SECTOR_COUNT 0x02 -#define REG_LBA_0 0x03 -#define REG_LBA_8 0x04 -#define REG_LBA_16 0x05 -#define REG_LBA_24 0x06 -#define REG_STAT_CMD 0x07 -#define REG_SEL_FAIL 0x08 -#define REG_IRQ_STATUS 0x09 -#define REG_ADDRESS 0x0A -#define REG_FAIL 0x0C -#define REG_ALT_STAT 0x0E -#define REG_DRIVE_ADRS 0x0F - -/************************************************/ -/* Chip RAM locations */ -/************************************************/ -#define CHIP_DEVICE 0x8000 -#define CHIP_DEVICE_0 0x8000 -#define CHIP_DEVICE_1 0x8008 -#define CHIP_DEVICE_2 0x8010 -#define CHIP_DEVICE_3 0x8018 -#define CHIP_DEVICE_4 0x8020 -#define CHIP_DEVICE_5 0x8028 -#define CHIP_DEVICE_6 0x8030 -#define CHIP_DEVICE_7 0x8038 -typedef struct - { - UCHAR channel; // channel of this device (0-8). - UCHAR spt; // Sectors Per Track. - ULONG spc; // Sectors Per Cylinder. - } CHIP_DEVICE_N; - -#define CHIP_CONFIG 0x8100 // address of boards configuration. -typedef struct - { - UCHAR irq; // interrupt request channel number - UCHAR numDrives; // Number of accessable drives - UCHAR fastFormat; // Boolean for fast format enable - } CHIP_CONFIG_N; - -#define CHIP_MAP 0x8108 // eight byte device type map. - - -#define CHIP_RAID 0x8120 // array of RAID signature structures and LBA -#define CHIP_RAID_1 0x8120 -#define CHIP_RAID_2 0x8130 -#define CHIP_RAID_3 0x8140 -#define CHIP_RAID_4 0x8150 - -/************************************************/ -/* Chip Register Masks */ -/************************************************/ -#define CHIP_ID 0x7B -#define SEL_RAM 0x8000 -#define MASK_FAIL 0x80 - -/************************************************/ -/* Chip cable select bits */ -/************************************************/ -#define SECTORSXFER 8 - -/************************************************/ -/* Chip cable select bits */ -/************************************************/ -#define SEL_NONE 0x00 -#define SEL_1 0x01 -#define SEL_2 0x02 -#define SEL_3 0x04 -#define SEL_4 0x08 - -/************************************************/ -/* Programmable Interrupt Controller*/ -/************************************************/ -#define PIC1 0x20 // first 8259 base port address -#define PIC2 0xA0 // second 8259 base port address -#define INT_OCW1 1 // Operation Control Word 1: IRQ mask -#define EOI 0x20 // non-specific end-of-interrupt - -/************************************************/ -/* Device/Geometry controls */ -/************************************************/ -#define GEOMETRY_NONE 0x0 // No device -#define GEOMETRY_AUTO 0x1 // Geometry set automatically -#define GEOMETRY_USER 0x2 // User supplied geometry - -#define DEVICE_NONE 0x0 // No device present -#define DEVICE_INACTIVE 0x1 // device present but not registered active -#define DEVICE_ATAPI 0x2 // ATAPI device (CD_ROM, Tape, Etc...) -#define DEVICE_DASD_NONLBA 0x3 // Non LBA incompatible device -#define DEVICE_DASD_LBA 0x4 // LBA compatible device - -/************************************************/ -/* Setup Structure Definitions */ -/************************************************/ -typedef struct // device setup parameters - { - UCHAR geometryControl; // geometry control flags - UCHAR device; // device code - USHORT sectors; // number of sectors per track - USHORT heads; // number of heads - USHORT cylinders; // number of cylinders for this device - ULONG blocks; // number of blocks on device - USHORT spare1; - USHORT spare2; - } SETUP_DEVICE, *PSETUP_DEVICE; - -typedef struct // master setup structure - { - USHORT startupDelay; - USHORT promptBIOS; - USHORT fastFormat; - USHORT spare2; - USHORT spare3; - USHORT spare4; - USHORT spare5; - USHORT spare6; - SETUP_DEVICE setupDevice[8]; - } SETUP, *PSETUP; - -#endif \ No newline at end of file diff --git a/drivers/scsi/psi_dale.h b/drivers/scsi/psi_dale.h deleted file mode 100644 index d8a407f3daf8..000000000000 --- a/drivers/scsi/psi_dale.h +++ /dev/null @@ -1,187 +0,0 @@ -/*+M************************************************************************* - * Perceptive Solutions, Inc. PCI-2000 device driver proc support for Linux. - * - * Copyright (c) 1997 Perceptive Solutions, 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; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * File Name: psi_dale.h - * - * Description: This file contains the interface defines and - * error codes. - * - *-M*************************************************************************/ - -#ifndef PSI_DALE -#define PSI_DALE - -/************************************************/ -/* Dale PCI setup */ -/************************************************/ -#define VENDOR_PSI 0x1256 -#define DEVICE_DALE_1 0x4401 /* 'D1' */ - -/************************************************/ -/* Misc konstants */ -/************************************************/ -#define DALE_MAXDRIVES 4 -#define SECTORSXFER 8 -#define BYTES_PER_SECTOR 512 -#define DEFAULT_TIMING_MODE 5 - -/************************************************/ -/* EEPROM locations */ -/************************************************/ -#define DALE_FLASH_PAGE_SIZE 128 // number of bytes per page -#define DALE_FLASH_SIZE 65536L - -#define DALE_FLASH_BIOS 0x00080000L // BIOS base address -#define DALE_FLASH_SETUP 0x00088000L // SETUP PROGRAM base address offset from BIOS -#define DALE_FLASH_RAID 0x00088400L // RAID signature storage -#define DALE_FLASH_FACTORY 0x00089000L // FACTORY data base address offset from BIOS - -#define DALE_FLASH_BIOS_SIZE 32768U // size of FLASH BIOS REGION - -/************************************************/ -/* DALE Register address offsets */ -/************************************************/ -#define REG_DATA 0x80 -#define REG_ERROR 0x84 -#define REG_SECTOR_COUNT 0x88 -#define REG_LBA_0 0x8C -#define REG_LBA_8 0x90 -#define REG_LBA_16 0x94 -#define REG_LBA_24 0x98 -#define REG_STAT_CMD 0x9C -#define REG_STAT_SEL 0xA0 -#define REG_FAIL 0xB0 -#define REG_ALT_STAT 0xB8 -#define REG_DRIVE_ADRS 0xBC - -#define DALE_DATA_SLOW 0x00040000L -#define DALE_DATA_MODE2 0x00040000L -#define DALE_DATA_MODE3 0x00050000L -#define DALE_DATA_MODE4 0x00060000L -#define DALE_DATA_MODE4P 0x00070000L - -#define RTR_LOCAL_RANGE 0x000 -#define RTR_LOCAL_REMAP 0x004 -#define RTR_EXP_RANGE 0x010 -#define RTR_EXP_REMAP 0x014 -#define RTR_REGIONS 0x018 -#define RTR_DM_MASK 0x01C -#define RTR_DM_LOCAL_BASE 0x020 -#define RTR_DM_IO_BASE 0x024 -#define RTR_DM_PCI_REMAP 0x028 -#define RTR_DM_IO_CONFIG 0x02C -#define RTR_MAILBOX 0x040 -#define RTR_LOCAL_DOORBELL 0x060 -#define RTR_PCI_DOORBELL 0x064 -#define RTR_INT_CONTROL_STATUS 0x068 -#define RTR_EEPROM_CONTROL_STATUS 0x06C - -#define RTL_DMA0_MODE 0x00 -#define RTL_DMA0_PCI_ADDR 0x04 -#define RTL_DMA0_LOCAL_ADDR 0x08 -#define RTL_DMA0_COUNT 0x0C -#define RTL_DMA0_DESC_PTR 0x10 -#define RTL_DMA1_MODE 0x14 -#define RTL_DMA1_PCI_ADDR 0x18 -#define RTL_DMA1_LOCAL_ADDR 0x1C -#define RTL_DMA1_COUNT 0x20 -#define RTL_DMA1_DESC_PTR 0x24 -#define RTL_DMA_COMMAND_STATUS 0x28 -#define RTL_DMA_ARB0 0x2C -#define RTL_DMA_ARB1 0x30 - -/************************************************/ -/* Dale Scratchpad locations */ -/************************************************/ -#define DALE_CHANNEL_DEVICE_0 0 // device channel locations -#define DALE_CHANNEL_DEVICE_1 1 -#define DALE_CHANNEL_DEVICE_2 2 -#define DALE_CHANNEL_DEVICE_3 3 - -#define DALE_SCRATH_DEVICE_0 4 // device type codes -#define DALE_SCRATH_DEVICE_1 5 -#define DALE_SCRATH_DEVICE_2 6 -#define DALE_SCRATH_DEVICE_3 7 - -#define DALE_RAID_0_STATUS 8 -#define DALE_RAID_1_STATUS 9 - -#define DALE_TIMING_MODE 12 // bus master timing mode (2, 3, 4, 5) -#define DALE_NUM_DRIVES 13 // number of addressable drives on this board -#define DALE_RAID_ON 14 // RAID status On -#define DALE_LAST_ERROR 15 // Last error code from BIOS - -/************************************************/ -/* Dale cable select bits */ -/************************************************/ -#define SEL_NONE 0x00 -#define SEL_1 0x01 -#define SEL_2 0x02 - -/************************************************/ -/* Programmable Interrupt Controller */ -/************************************************/ -#define PIC1 0x20 // first 8259 base port address -#define PIC2 0xA0 // second 8259 base port address -#define INT_OCW1 1 // Operation Control Word 1: IRQ mask -#define EOI 0x20 // non-specific end-of-interrupt - -/************************************************/ -/* Device/Geometry controls */ -/************************************************/ -#define GEOMETRY_NONE 0x0 // No device -#define GEOMETRY_SET 0x1 // Geometry set -#define GEOMETRY_LBA 0x2 // Geometry set in default LBA mode -#define GEOMETRY_PHOENIX 0x3 // Geometry set in Pheonix BIOS compatibility mode - -#define DEVICE_NONE 0x0 // No device present -#define DEVICE_INACTIVE 0x1 // device present but not registered active -#define DEVICE_ATAPI 0x2 // ATAPI device (CD_ROM, Tape, Etc...) -#define DEVICE_DASD_NONLBA 0x3 // Non LBA incompatible device -#define DEVICE_DASD_LBA 0x4 // LBA compatible device - -/************************************************/ -/* Setup Structure Definitions */ -/************************************************/ -typedef struct // device setup parameters - { - UCHAR geometryControl; // geometry control flags - UCHAR device; // device code - USHORT sectors; // number of sectors per track - USHORT heads; // number of heads - USHORT cylinders; // number of cylinders for this device - ULONG blocks; // number of blocks on device - ULONG realCapacity; // number of real blocks on this device for drive changed testing - } SETUP_DEVICE, *PSETUP_DEVICE; - -typedef struct // master setup structure - { - USHORT startupDelay; - BOOL promptBIOS; - BOOL fastFormat; - BOOL shareInterrupt; - BOOL rebootRebuil; - USHORT timingMode; - USHORT spare5; - USHORT spare6; - SETUP_DEVICE setupDevice[4]; - } SETUP, *PSETUP; - -#endif diff --git a/drivers/scsi/psi_roy.h b/drivers/scsi/psi_roy.h deleted file mode 100644 index 0b7f3377b153..000000000000 --- a/drivers/scsi/psi_roy.h +++ /dev/null @@ -1,337 +0,0 @@ -/*+M************************************************************************* - * Perceptive Solutions, Inc. PCI-2000 device driver proc support for Linux. - * - * Copyright (c) 1997 Perceptive Solutions, 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; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * File Name: psi_roy.h - * - * Description: This file contains the host interface command and - * error codes. - * - *-M*************************************************************************/ - -#ifndef ROY_HOST -#define ROY_HOST - -/************************************************/ -/* PCI setup */ -/************************************************/ -#define VENDOR_PSI 0x1256 -#define DEVICE_ROY_1 0x5201 /* 'R1' */ - -/************************************************/ -/* controller constants */ -/************************************************/ -#define MAXADAPTER 4 // Increase this and the sizes of the arrays below, if you need more. -#define MAX_BUS 2 -#define MAX_UNITS 16 -#define TIMEOUT_COMMAND 30 // number of jiffies for command busy timeout - -/************************************************/ -/* I/O address offsets */ -/************************************************/ -#define RTR_MAILBOX 0x040 -#define RTR_LOCAL_DOORBELL 0x060 -#define RTR_PCI_DOORBELL 0x064 - -/************************************************/ -/* */ -/* Host command codes */ -/* */ -/************************************************/ -#define CMD_READ_CHS 0x01 /* read sectors as specified (CHS mode) */ -#define CMD_READ 0x02 /* read sectors as specified (RBA mode) */ -#define CMD_READ_SG 0x03 /* read sectors using scatter/gather list */ -#define CMD_WRITE_CHS 0x04 /* write sectors as specified (CHS mode) */ -#define CMD_WRITE 0x05 /* write sectors as specified (RBA mode) */ -#define CMD_WRITE_SG 0x06 /* write sectors using scatter/gather list (LBA mode) */ -#define CMD_READ_CHS_SG 0x07 /* read sectors using scatter/gather list (CHS mode) */ -#define CMD_WRITE_CHS_SG 0x08 /* write sectors using scatter/gather list (CHS mode) */ -#define CMD_VERIFY_CHS 0x09 /* verify data on sectors as specified (CHS mode) */ -#define CMD_VERIFY 0x0A /* verify data on sectors as specified (RBA mode) */ -#define CMD_DASD_CDB 0x0B /* process CDB for a DASD device */ -#define CMD_DASD_CDB_SG 0x0C /* process CDB for a DASD device with scatter/gather */ - -#define CMD_READ_ABS 0x10 /* read absolute disk */ -#define CMD_WRITE_ABS 0x11 /* write absolute disk */ -#define CMD_VERIFY_ABS 0x12 /* verify absolute disk */ -#define CMD_TEST_READY 0x13 /* test unit ready and return status code */ -#define CMD_LOCK_DOOR 0x14 /* lock device door */ -#define CMD_UNLOCK_DOOR 0x15 /* unlock device door */ -#define CMD_EJECT_MEDIA 0x16 /* eject the media */ -#define CMD_UPDATE_CAP 0x17 /* update capacity information */ -#define CMD_TEST_PRIV 0x18 /* test and setup private format media */ - - -#define CMD_SCSI_THRU 0x30 /* SCSI pass through CDB */ -#define CMD_SCSI_THRU_SG 0x31 /* SCSI pass through CDB with scatter/gather */ -#define CMD_SCSI_REQ_SENSE 0x32 /* SCSI pass through request sense after check condition */ - -#define CMD_DASD_RAID_RQ 0x35 /* request DASD RAID drive data */ -#define CMD_DASD_RAID_RQ0 0x31 /* byte 1 subcommand to query for RAID 0 informatation */ -#define CMD_DASD_RAID_RQ1 0x32 /* byte 1 subcommand to query for RAID 1 informatation */ -#define CMD_DASD_RAID_RQ5 0x33 /* byte 1 subcommand to query for RAID 5 informatation */ - -#define CMD_DASD_SCSI_INQ 0x36 /* do DASD inquire and return in SCSI format */ -#define CMD_DASD_CAP 0x37 /* read DASD capacity */ -#define CMD_DASD_INQ 0x38 /* do DASD inquire for type data and return SCSI/EIDE inquiry */ -#define CMD_SCSI_INQ 0x39 /* do SCSI inquire */ -#define CMD_READ_SETUP 0x3A /* Get setup structures from controller */ -#define CMD_WRITE_SETUP 0x3B /* Put setup structures in controller and burn in flash */ -#define CMD_READ_CONFIG 0x3C /* Get the entire configuration and setup structures */ -#define CMD_WRITE_CONFIG 0x3D /* Put the entire configuration and setup structures in flash */ - -#define CMD_TEXT_DEVICE 0x3E /* obtain device text */ -#define CMD_TEXT_SIGNON 0x3F /* get sign on banner */ - -#define CMD_QUEUE 0x40 /* any command below this generates a queue tag interrupt to host*/ - -#define CMD_PREFETCH 0x40 /* prefetch sectors as specified */ -#define CMD_TEST_WRITE 0x41 /* Test a device for write protect */ -#define CMD_LAST_STATUS 0x42 /* get last command status and error data*/ -#define CMD_ABORT 0x43 /* abort command as specified */ -#define CMD_ERROR 0x44 /* fetch error code from a tagged op */ -#define CMD_DONE 0x45 /* done with operation */ -#define CMD_DIAGNOSTICS 0x46 /* execute controller diagnostics and wait for results */ -#define CMD_FEATURE_MODE 0x47 /* feature mode control word */ -#define CMD_DASD_INQUIRE 0x48 /* inquire as to DASD SCSI device (32 possible) */ -#define CMD_FEATURE_QUERY 0x49 /* query the feature control word */ -#define CMD_DASD_EJECT 0x4A /* Eject removable media for DASD type */ -#define CMD_DASD_LOCK 0x4B /* Lock removable media for DASD type */ -#define CMD_DASD_TYPE 0x4C /* obtain DASD device type */ -#define CMD_NUM_DEV 0x4D /* obtain the number of devices connected to the controller */ -#define CMD_GET_PARMS 0x4E /* obtain device parameters */ -#define CMD_SPECIFY 0x4F /* specify operating system for scatter/gather operations */ - -#define CMD_RAID_GET_DEV 0x50 /* read RAID device geometry */ -#define CMD_RAID_READ 0x51 /* read RAID 1 parameter block */ -#define CMD_RAID_WRITE 0x52 /* write RAID 1 parameter block */ -#define CMD_RAID_LITEUP 0x53 /* Light up the drive light for identification */ -#define CMD_RAID_REBUILD 0x54 /* issue a RAID 1 pair rebuild */ -#define CMD_RAID_MUTE 0x55 /* mute RAID failure alarm */ -#define CMD_RAID_FAIL 0x56 /* induce a RAID failure */ -#define CMD_RAID_STATUS 0x57 /* get status of RAID pair */ -#define CMD_RAID_STOP 0x58 /* stop any reconstruct in progress */ -#define CMD_RAID_START 0x59 /* start reconstruct */ -#define CMD_RAID0_READ 0x5A /* read RAID 0 parameter block */ -#define CMD_RAID0_WRITE 0x5B /* write RAID 0 parameter block */ -#define CMD_RAID5_READ 0x5C /* read RAID 5 parameter block */ -#define CMD_RAID5_WRITE 0x5D /* write RAID 5 parameter block */ - -#define CMD_ERASE_TABLES 0x5F /* erase partition table and RAID signatutures */ - -#define CMD_SCSI_GET 0x60 /* get SCSI pass through devices */ -#define CMD_SCSI_TIMEOUT 0x61 /* set SCSI pass through timeout */ -#define CMD_SCSI_ERROR 0x62 /* get SCSI pass through request sense length and residual data count */ -#define CMD_GET_SPARMS 0x63 /* get SCSI bus and user parms */ -#define CMD_SCSI_ABORT 0x64 /* abort by setting time-out to zero */ - -#define CMD_CHIRP_CHIRP 0x77 /* make a chirp chirp sound */ -#define CMD_GET_LAST_DONE 0x78 /* get tag of last done in progress */ -#define CMD_GET_FEATURES 0x79 /* get feature code and ESN */ -#define CMD_CLEAR_CACHE 0x7A /* Clear cache on specified device */ -#define CMD_BIOS_TEST 0x7B /* Test whether or not to load BIOS */ -#define CMD_WAIT_FLUSH 0x7C /* wait for cache flushed and invalidate read cache */ -#define CMD_RESET_BUS 0x7D /* reset the SCSI bus */ -#define CMD_STARTUP_QRY 0x7E /* startup in progress query */ -#define CMD_RESET 0x7F /* reset the controller */ - -#define CMD_RESTART_RESET 0x80 /* reload and restart the controller at any reset issued */ -#define CMD_SOFT_RESET 0x81 /* do a soft reset NOW! */ - -/************************************************/ -/* */ -/* Host return errors */ -/* */ -/************************************************/ -#define ERR08_TAGGED 0x80 /* doorbell error ored with tag */ - -#define ERR16_NONE 0x0000 /* no errors */ -#define ERR16_SC_COND_MET 0x0004 /* SCSI status - Condition Met */ -#define ERR16_CMD 0x0101 /* command error */ -#define ERR16_SC_CHECK_COND 0x0002 /* SCSI status - Check Condition */ -#define ERR16_CMD_NOT 0x0201 /* command not supported */ -#define ERR16_NO_DEVICE 0x0301 /* invalid device selection */ -#define ERR16_SECTOR 0x0202 /* bad sector */ -#define ERR16_PROTECT 0x0303 /* write protected */ -#define ERR16_NOSECTOR 0x0404 /* sector not found */ -#define ERR16_MEDIA 0x0C0C /* invalid media */ -#define ERR16_CONTROL 0x2020 /* controller error */ -#define ERR16_CONTROL_DMA 0x2120 /* controller DMA engine error */ -#define ERR16_NO_ALARM 0x2220 /* alarm is not active */ -#define ERR16_OP_BUSY 0x2320 /* operation busy */ -#define ERR16_SEEK 0x4040 /* seek failure */ -#define ERR16_DEVICE_FAIL 0x4140 /* device has failed */ -#define ERR16_TIMEOUT 0x8080 /* timeout error */ -#define ERR16_DEV_NOT_READY 0xAAAA /* drive not ready */ -#define ERR16_UNDEFINED 0xBBBB /* undefined error */ -#define ERR16_WRITE_FAULT 0xCCCC /* write fault */ -#define ERR16_INVALID_DEV 0x4001 /* invalid device access */ -#define ERR16_DEVICE_BUSY 0x4002 /* device is busy */ -#define ERR16_MEMORY 0x4003 /* device pass thru requires too much memory */ -#define ERR16_NO_FEATURE 0x40FA /* feature no implemented */ -#define ERR16_NOTAG 0x40FD /* no tag space available */ -#define ERR16_NOT_READY 0x40FE /* controller not ready error */ -#define ERR16_SETUP_FLASH 0x5050 /* error when writing setup to flash memory */ -#define ERR16_SETUP_SIZE 0x5051 /* setup block size error */ -#define ERR16_SENSE 0xFFFF /* sense opereration failed */ -#define ERR16_SC_BUSY 0x0008 /* SCSI status - Busy */ -#define ERR16_SC_RES_CONFL 0x0018 /* SCSI status - Reservation Conflict */ -#define ERR16_SC_CMD_TERM 0x0022 /* SCSI status - Command Terminated */ -#define ERR16_SC_OTHER 0x00FF /* SCSI status - not recognized (any value masked) */ -#define ERR16_MEDIA_CHANGED 0x8001 /* devices media has been changed */ - -#define ERR32_NONE 0x00000000 /* no errors */ -#define ERR32_SC_COND_MET 0x00000004 /* SCSI status - Condition Met */ -#define ERR32_CMD 0x00010101 /* command error */ -#define ERR32_SC_CHECK_COND 0x00020002 /* SCSI status - Check Condition */ -#define ERR32_CMD_NOT 0x00030201 /* command not supported */ -#define ERR32_NO_DEVICE 0x00040301 /* invalid device selection */ -#define ERR32_SECTOR 0x00050202 /* bad sector */ -#define ERR32_PROTECT 0x00060303 /* write protected */ -#define ERR32_NOSECTOR 0x00070404 /* sector not found */ -#define ERR32_MEDIA 0x00080C0C /* invalid media */ -#define ERR32_CONTROL 0x00092020 /* controller error */ -#define ERR32_CONTROL_DMA 0x000A2120 /* Controller DMA error */ -#define ERR32_NO_ALARM 0x000B2220 /* alarm is not active */ -#define ERR32_OP_BUSY 0x000C2320 /* operation busy */ -#define ERR32_SEEK 0x000D4040 /* seek failure */ -#define ERR32_DEVICE_FAIL 0x000E4140 /* device has failed */ -#define ERR32_TIMEOUT 0x000F8080 /* timeout error */ -#define ERR32_DEV_NOT_READY 0x0010AAAA /* drive not ready */ -#define ERR32_UNDEFINED 0x0011BBBB /* undefined error */ -#define ERR32_WRITE_FAULT 0x0012CCCC /* write fault */ -#define ERR32_INVALID_DEV 0x00134001 /* invalid device access */ -#define ERR32_DEVICE_BUSY 0x00144002 /* device is busy */ -#define ERR32_MEMORY 0x00154003 /* device pass thru requires too much memory */ -#define ERR32_NO_FEATURE 0x001640FA /* feature no implemented */ -#define ERR32_NOTAG 0x001740FD /* no tag space available */ -#define ERR32_NOT_READY 0x001840FE /* controller not ready error */ -#define ERR32_SETUP_FLASH 0x00195050 /* error when writing setup to flash memory */ -#define ERR32_SETUP_SIZE 0x001A5051 /* setup block size error */ -#define ERR32_SENSE 0x001BFFFF /* sense opereration failed */ -#define ERR32_SC_BUSY 0x001C0008 /* SCSI status - Busy */ -#define ERR32_SC_RES_CONFL 0x001D0018 /* SCSI status - Reservation Conflict */ -#define ERR32_SC_CMD_TERM 0x001E0022 /* SCSI status - Command Terminated */ -#define ERR32_SC_OTHER 0x001F00FF /* SCSI status - not recognized (any value masked) */ -#define ERR32_MEDIA_CHANGED 0x00208001 /* devices media has been changed */ - -/************************************************/ -/* */ -/* Host Operating System specification codes */ -/* */ -/************************************************/ -#define SPEC_INTERRUPT 0x80 /* specification requires host interrupt */ -#define SPEC_BACKWARD_SG 0x40 /* specification requires scatter/gather items reversed */ -#define SPEC_DOS_BLOCK 0x01 /* DOS DASD blocking on pass through */ -#define SPEC_OS2_V3 0x02 /* OS/2 Warp */ -#define SPCE_SCO_3242 0x04 /* SCO 3.4.2.2 */ -#define SPEC_QNX_4X 0x05 /* QNX 4.XX */ -#define SPEC_NOVELL_NWPA 0x08 /* Novell NWPA scatter/gather support */ - -/************************************************/ -/* */ -/* Inquire structures */ -/* */ -/************************************************/ -typedef struct _CNT_SCSI_INQ - { - UCHAR devt; /* 00: device type */ - UCHAR devtm; /* 01: device type modifier */ - UCHAR svers; /* 02: SCSI version */ - UCHAR rfmt; /* 03: response data format */ - UCHAR adlen; /* 04: additional length of data */ - UCHAR res1; /* 05: */ - UCHAR res2; /* 06: */ - UCHAR fncs; /* 07: functional capabilities */ - UCHAR vid[8]; /* 08: vendor ID */ - UCHAR pid[16]; /* 10: product ID */ - UCHAR rev[4]; /* 20: product revision */ - } CNT_SCSI_INQ; - -typedef struct _CNT_IDE_INQ - { - USHORT GeneralConfiguration; /* 00 */ - USHORT NumberOfCylinders; /* 02 */ - USHORT Reserved1; /* 04 */ - USHORT NumberOfHeads; /* 06 */ - USHORT UnformattedBytesPerTrack; /* 08 */ - USHORT UnformattedBytesPerSector; /* 0A */ - USHORT SectorsPerTrack; /* 0C */ - USHORT VendorUnique1[3]; /* 0E */ - USHORT SerialNumber[10]; /* 14 */ - USHORT BufferType; /* 28 */ - USHORT BufferSectorSize; /* 2A */ - USHORT NumberOfEccBytes; /* 2C */ - USHORT FirmwareRevision[4]; /* 2E */ - USHORT ModelNumber[20]; /* 36 */ - UCHAR MaximumBlockTransfer; /* 5E */ - UCHAR VendorUnique2; /* 5F */ - USHORT DoubleWordIo; /* 60 */ - USHORT Capabilities; /* 62 */ - USHORT Reserved2; /* 64 */ - UCHAR VendorUnique3; /* 66 */ - UCHAR PioCycleTimingMode; /* 67 */ - UCHAR VendorUnique4; /* 68 */ - UCHAR DmaCycleTimingMode; /* 69 */ - USHORT TranslationFieldsValid; /* 6A */ - USHORT NumberOfCurrentCylinders; /* 6C */ - USHORT NumberOfCurrentHeads; /* 6E */ - USHORT CurrentSectorsPerTrack; /* 70 */ - ULONG CurrentSectorCapacity; /* 72 */ - } CNT_IDE_INQ; - -typedef struct _DASD_INQUIRE - { - ULONG type; /* 0 = SCSI, 1 = IDE */ - union - { - CNT_SCSI_INQ scsi; /* SCSI inquire data */ - CNT_IDE_INQ ide; /* IDE inquire data */ - } inq; - } DASD_INQUIRE; - -/************************************************/ -/* */ -/* Device Codes */ -/* */ -/************************************************/ -#define DEVC_DASD 0x00 /* Direct-access Storage Device */ -#define DEVC_SEQACESS 0x01 /* Sequential-access device */ -#define DEVC_PRINTER 0x02 /* Printer device */ -#define DEVC_PROCESSOR 0x03 /* Processor device */ -#define DEVC_WRITEONCE 0x04 /* Write-once device */ -#define DEVC_CDROM 0x05 /* CD-ROM device */ -#define DEVC_SCANNER 0x06 /* Scanner device */ -#define DEVC_OPTICAL 0x07 /* Optical memory device */ -#define DEVC_MEDCHGR 0x08 /* Medium changer device */ -#define DEVC_DASD_REMOVABLE 0x80 /* Direct-access storage device, Removable */ -#define DEVC_NONE 0xFF /* no device */ - -// SCSI controls for RAID -#define SC_MY_RAID 0xBF // our special CDB command byte for Win95... interface -#define MY_SCSI_QUERY0 0x31 // byte 1 subcommand to query driver for RAID 0 informatation -#define MY_SCSI_QUERY1 0x32 // byte 1 subcommand to query driver for RAID 1 informatation -#define MY_SCSI_QUERY5 0x33 // byte 1 subcommand to query driver for RAID 5 informatation -#define MY_SCSI_REBUILD 0x40 // byte 1 subcommand to reconstruct a mirrored pair -#define MY_SCSI_DEMOFAIL 0x54 // byte 1 subcommand for RAID failure demonstration -#define MY_SCSI_ALARMMUTE 0x60 // byte 1 subcommand to mute any alarm currently on - - -#endif - diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 6a3d7d4d7c0e..b21272cd56aa 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -295,7 +295,6 @@ static struct dev_info device_list[] = {"YAMAHA","CDR100","1.00", BLIST_NOLUN}, /* Locks up if polled for lun != 0 */ {"YAMAHA","CDR102","1.00", BLIST_NOLUN}, /* Locks up if polled for lun != 0 */ {"nCipher","Fastness Crypto","*", BLIST_FORCELUN}, -{"iomega","jaz 1GB","J.86", BLIST_NOTQ | BLIST_NOLUN}, /* * Must be at end of list... */ diff --git a/drivers/scsi/scsi_syms.c b/drivers/scsi/scsi_syms.c index 6b3a7c9a89a7..985b3eaaa39c 100644 --- a/drivers/scsi/scsi_syms.c +++ b/drivers/scsi/scsi_syms.c @@ -26,11 +26,13 @@ #include "constants.h" #include "sd.h" -#include /* * This source file contains the symbol table used by scsi loadable * modules. */ +extern int scsicam_bios_param (Disk * disk, + int dev, int *ip ); + extern void print_command (unsigned char *command); extern void print_sense(const char * devclass, Scsi_Cmnd * SCpnt); @@ -45,7 +47,6 @@ struct symbol_table scsi_symbol_table = { X(scsi_register), X(scsi_unregister), X(scsicam_bios_param), - X(scsi_partsize), X(allocate_device), X(scsi_do_cmd), X(scsi_command_size), diff --git a/drivers/scsi/scsicam.c b/drivers/scsi/scsicam.c index c3fb8792514c..2c6f63772b82 100644 --- a/drivers/scsi/scsicam.c +++ b/drivers/scsi/scsicam.c @@ -26,8 +26,9 @@ #include "scsi.h" #include "hosts.h" #include "sd.h" -#include +static int partsize(struct buffer_head *bh, unsigned long capacity, + unsigned int *cyls, unsigned int *hds, unsigned int *secs); static int setsize(unsigned long capacity,unsigned int *cyls,unsigned int *hds, unsigned int *secs); @@ -55,7 +56,7 @@ int scsicam_bios_param (Disk *disk, /* SCSI disk */ return -1; /* try to infer mapping from partition table */ - ret_code = scsi_partsize (bh, (unsigned long) size, (unsigned int *) ip + 2, + ret_code = partsize (bh, (unsigned long) size, (unsigned int *) ip + 2, (unsigned int *) ip + 0, (unsigned int *) ip + 1); brelse (bh); @@ -84,7 +85,7 @@ int scsicam_bios_param (Disk *disk, /* SCSI disk */ } /* - * Function : static int scsi_partsize(struct buffer_head *bh, unsigned long + * Function : static int partsize(struct buffer_head *bh, unsigned long * capacity,unsigned int *cyls, unsigned int *hds, unsigned int *secs); * * Purpose : to determine the BIOS mapping used to create the partition @@ -94,7 +95,7 @@ int scsicam_bios_param (Disk *disk, /* SCSI disk */ * */ -int scsi_partsize(struct buffer_head *bh, unsigned long capacity, +static int partsize(struct buffer_head *bh, unsigned long capacity, unsigned int *cyls, unsigned int *hds, unsigned int *secs) { struct partition *p, *largest = NULL; int i, largest_cyl; diff --git a/drivers/scsi/scsiiom.c b/drivers/scsi/scsiiom.c index 4b7d4af49362..1287fe000b77 100644 --- a/drivers/scsi/scsiiom.c +++ b/drivers/scsi/scsiiom.c @@ -4,7 +4,7 @@ * Description: Device Driver for Tekram DC-390 (T) PCI SCSI * * Bus Master Host Adapter * ***********************************************************************/ -/* $Id: scsiiom.c,v 2.15 1998/12/25 17:33:27 garloff Exp $ */ +/* $Id: scsiiom.c,v 2.4 1998/11/05 10:16:43 garloff Exp $ */ UCHAR dc390_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ) @@ -36,7 +36,7 @@ dc390_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ) DC390_write8 (ScsiFifo, bval); bval1 = SEL_W_ATN; pSRB->SRBState = SRB_START_; - DEBUG1(printk (KERN_DEBUG "DC390: No DisCn, No TagQ (%02x, %02x)\n", bval, bval1);) + DEBUG1(printk ("DC390: No DisCn, No TagQ (%02x, %02x)\n", bval, bval1);) if( pDCB->SyncMode & SYNC_ENABLE ) { if( !(pDCB->IdentifyMsg & 7) || /* LUN == 0 || Cmd != INQUIRY */ @@ -53,21 +53,21 @@ dc390_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ) if(pDCB->SyncMode & EN_TAG_QUEUEING) { DC390_write8 (ScsiFifo, MSG_SIMPLE_QTAG); - DEBUG1(printk (KERN_DEBUG "DC390: %sDisCn, TagQ (%02x, %02x, %08lx)\n", (bval&0x40?"":"No "), bval, SEL_W_ATN3, pDCB->TagMask);) + DEBUG1(printk ("DC390: %sDisCn, TagQ (%02x, %02x, %08lx)\n", (bval&0x40?"":"No "), bval, SEL_W_ATN3, pDCB->TagMask);) bval = 0; wlval = 1; while (wlval & pDCB->TagMask) { bval++; wlval <<= 1; }; pDCB->TagMask |= wlval; DC390_write8 (ScsiFifo, bval); pSRB->TagNumber = bval; - DEBUG1(printk (KERN_DEBUG "DC390: SRB %p (Cmd %li), Tag %02x queued\n", pSRB, pSRB->pcmd->pid, bval);) + DEBUG1(printk ("DC390: SRB %p (Cmd %li), Tag %02x queued\n", pSRB, pSRB->pcmd->pid, bval);) bval1 = SEL_W_ATN3; pSRB->SRBState = SRB_START_; } else /* No TagQ */ { bval1 = SEL_W_ATN; - DEBUG1(printk (KERN_DEBUG "DC390: %sDisCn, No TagQ (%02x, %02x, %08lx)\n", (bval&0x40?"":"No "), bval, bval1, pDCB->TagMask);) + DEBUG1(printk ("DC390: %sDisCn, No TagQ (%02x, %02x, %08lx)\n", (bval&0x40?"":"No "), bval, bval1, pDCB->TagMask);) pSRB->SRBState = SRB_START_; } } @@ -82,7 +82,7 @@ dc390_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ) bval &= 0xBF; /* No DisConn */ DC390_write8 (ScsiFifo, bval); bval1 = SEL_W_ATN; - DEBUG1(printk (KERN_DEBUG "DC390: No DisCn, No TagQ (%02x, %02x)\n", bval, bval1);) + DEBUG1(printk ("DC390: No DisCn, No TagQ (%02x, %02x)\n", bval, bval1);) pSRB->SRBState = SRB_START_; /* ??? */ if( pDCB->SyncMode & SYNC_ENABLE ) @@ -101,13 +101,13 @@ dc390_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ) if(pDCB->SyncMode & EN_TAG_QUEUEING) { pSRB->MsgOutBuf[0] = MSG_SIMPLE_QTAG; - DEBUG1(printk (KERN_DEBUG "DC390: %sDisCn, TagQ (%02x, %02x, %08lx)\n", (bval&0x40?"":"No "), bval, SEL_W_ATN_STOP, pDCB->TagMask);) + DEBUG1(printk ("DC390: %sDisCn, TagQ (%02x, %02x, %08lx)\n", (bval&0x40?"":"No "), bval, SEL_W_ATN_STOP, pDCB->TagMask);) bval = 0; wlval = 1; while (wlval & pDCB->TagMask) { bval++; wlval <<= 1; }; pDCB->TagMask |= wlval; pSRB->TagNumber = bval; - DEBUG1(printk (KERN_DEBUG "DC390: SRB %p (Cmd %li), Tag %02x queued\n", pSRB, pSRB->pcmd->pid, bval);) + DEBUG1(printk ("DC390: SRB %p (Cmd %li), Tag %02x queued\n", pSRB, pSRB->pcmd->pid, bval);) pSRB->MsgOutBuf[1] = bval; pSRB->MsgCnt = 2; bval1 = SEL_W_ATN_STOP; @@ -119,7 +119,7 @@ dc390_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ) pSRB->MsgCnt = 1; pSRB->SRBState = SRB_START_; bval1 = SEL_W_ATN_STOP; - DEBUG1(printk (KERN_DEBUG "DC390: %sDisCn, No TagQ (%02x, %02x, %08lx)\n", (bval&0x40?"":"No "), bval, bval1, pDCB->TagMask);) + DEBUG1(printk ("DC390: %sDisCn, No TagQ (%02x, %02x, %08lx)\n", (bval&0x40?"":"No "), bval, bval1, pDCB->TagMask);) }; } } @@ -134,7 +134,7 @@ dc390_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ) DC390_write8 (ScsiFifo, bval); DC390_write8 (ScsiFifo, sizeof(pSRB->pcmd->sense_buffer)); DC390_write8 (ScsiFifo, bval); - DEBUG1(printk (KERN_DEBUG "DC390: AutoReqSense !\n");) + DEBUG1(printk ("DC390: AutoReqSense !\n");) } else /* write cmnd to bus */ { @@ -150,16 +150,16 @@ dc390_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ) { pSRB->SRBState = SRB_READY; pDCB->TagMask &= ~( 1 << pSRB->TagNumber ); - DEBUG0(printk (KERN_WARNING "DC390: Interrupt during StartSCSI!\n");) + DEBUG0(printk ("DC390: Interrupt during StartSCSI!\n");) return 1; } else { pSRB->ScsiPhase = SCSI_NOP1; DEBUG0(if (pACB->pActiveDCB) \ - printk (KERN_WARNING "DC390: ActiveDCB != 0\n");) + printk ("DC390: ActiveDCB != 0\n");) DEBUG0(if (pDCB->pActiveSRB) \ - printk (KERN_WARNING "DC390: ActiveSRB != 0\n");) + printk ("DC390: ActiveSRB != 0\n");) pACB->pActiveDCB = pDCB; pDCB->pActiveSRB = pSRB; //DC390_write8 (DMA_Cmd, DMA_IDLE_CMD); @@ -183,10 +183,12 @@ dc390_dma_intr (PACB pACB) DEBUG0(PDEVSET1;) DEBUG0(PCI_READ_CONFIG_WORD (PDEV, PCI_STATUS, &pstate);) DEBUG0(if (pstate & (PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY))\ - { printk(KERN_WARNING "DC390: PCI state = %04x!\n", pstate); \ + { printk("DC390: PCI state = %04x!\n", pstate); \ PCI_WRITE_CONFIG_WORD (PDEV, PCI_STATUS, (PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY));};) - dstate = DC390_read8 (DMA_Status); + dstate = DC390_read8 (DMA_Status); + DC390_write8 (DMA_Status, dstate); /* clear */ + //DC390_write8 (DMA_Status, DMA_XFER_DONE | DMA_XFER_ABORT | DMA_XFER_ERROR | PCI_MS_ABORT); /* clear */ if (! pACB->pActiveDCB || ! pACB->pActiveDCB->pActiveSRB) return dstate; else pSRB = pACB->pActiveDCB->pActiveSRB; @@ -205,11 +207,12 @@ dc390_dma_intr (PACB pACB) { DEBUG1(printk (KERN_DEBUG "DC390: read residual bytes ... \n");) dstate = DC390_read8 (DMA_Status); + DC390_write8 (DMA_Status, dstate); /* clear */ residual = DC390_read8 (CtcReg_Low) | DC390_read8 (CtcReg_Mid) << 8 | DC390_read8 (CtcReg_High) << 16; residual += DC390_read8 (Current_Fifo) & 0x1f; } while (residual && ! (dstate & SCSI_INTERRUPT) && --ctr); - if (!ctr) printk (KERN_CRIT "DC390: dma_intr: DMA aborted unfinished: %06x bytes remain!!\n", DC390_read32 (DMA_Wk_ByteCntr)); + if (!ctr) printk (KERN_CRIT "DC390: dma_intr: DMA aborted unfinished: %06x bytes remain!\n", DC390_read32 (DMA_Wk_ByteCntr)); /* residual = ... */ } else @@ -228,7 +231,6 @@ dc390_dma_intr (PACB pACB) DC390_write8 (DMA_Cmd, DMA_IDLE_CMD); } - dc390_laststatus &= ~0xff000000; dc390_laststatus |= dstate << 24; return dstate; }; #endif @@ -243,9 +245,7 @@ DC390_Interrupt( int irq, void *dev_id, struct pt_regs *regs) UCHAR phase, i; void (*stateV)( PACB, PSRB, PUCHAR ); UCHAR istate, istatus; -#if DMA_INT UCHAR dstatus; -#endif DC390_AFLAGS DC390_IFLAGS DC390_DFLAGS pACB = dc390_pACB_start; @@ -276,7 +276,7 @@ DC390_Interrupt( int irq, void *dev_id, struct pt_regs *regs) DEBUG1(printk (KERN_DEBUG "sstatus=%02x,", sstatus);) if( !pACB ) { DC390_UNLOCK_DRV; return; }; - + #if DMA_INT DC390_LOCK_IO; DC390_LOCK_ACB; @@ -284,17 +284,15 @@ DC390_Interrupt( int irq, void *dev_id, struct pt_regs *regs) DC390_UNLOCK_ACB; DC390_UNLOCK_IO; - DEBUG1(printk (KERN_DEBUG "dstatus=%02x,", dstatus);) + DEBUG1(printk ("dstatus=%02x,", dstatus);) if (! (dstatus & SCSI_INTERRUPT)) { - DEBUG0(printk (KERN_WARNING "DC390 Int w/o SCSI actions (only DMA?)\n");) + DEBUG0(printk ("DC390 Int w/o SCSI actions (only DMA?)\n");) DC390_UNLOCK_DRV; return; }; #else - //DC390_write32 (DMA_ScsiBusCtrl, WRT_ERASE_DMA_STAT | EN_INT_ON_PCI_ABORT); - //dstatus = DC390_read8 (DMA_Status); - //DC390_write32 (DMA_ScsiBusCtrl, EN_INT_ON_PCI_ABORT); + dstatus = DC390_read8 (DMA_Status); #endif DC390_LOCK_IO; @@ -304,15 +302,14 @@ DC390_Interrupt( int irq, void *dev_id, struct pt_regs *regs) istate = DC390_read8 (Intern_State); istatus = DC390_read8 (INT_Status); /* This clears Scsi_Status, Intern_State and INT_Status ! */ - DEBUG1(printk (KERN_INFO "Istatus(Res,Inv,Dis,Serv,Succ,ReS,SelA,Sel)=%02x,",istatus);) - dc390_laststatus &= ~0x00ffffff; - dc390_laststatus |= /* dstatus<<24 | */ sstatus<<16 | istate<<8 | istatus; + DEBUG1(printk ("Istatus(Res,Inv,Dis,Serv,Succ,ReS,SelA,Sel)=%02x,",istatus);) + dc390_laststatus = dstatus<<24 | sstatus<<16 | istate<<8 | istatus; if (sstatus & ILLEGAL_OP_ERR) - { - printk ("DC390: Illegal Operation detected (%08lx)!\n", dc390_laststatus); - dc390_dumpinfo (pACB, pACB->pActiveDCB, pACB->pActiveDCB->pActiveSRB); - }; + { + printk ("DC390: Illegal Operation detected (%08lx)!\n", dc390_laststatus); + dc390_dumpinfo (pACB, pACB->pActiveDCB, pACB->pActiveDCB->pActiveSRB); + }; if(istatus & DISCONNECTED) { @@ -326,6 +323,18 @@ DC390_Interrupt( int irq, void *dev_id, struct pt_regs *regs) goto unlock; } + if(istatus & INVALID_CMD) + { + dc390_InvalidCmd( pACB ); + goto unlock; + } + + if(istatus & SCSI_RESET) + { + dc390_ScsiRstDetect( pACB ); + goto unlock; + } + if( istatus & (SUCCESSFUL_OP|SERVICE_REQUEST) ) { pDCB = pACB->pActiveDCB; @@ -336,7 +345,7 @@ DC390_Interrupt( int irq, void *dev_id, struct pt_regs *regs) }; pSRB = pDCB->pActiveSRB; if( pDCB->DCBFlag & ABORT_DEV_ ) - dc390_EnableMsgOut_Abort (pACB, pSRB); + dc390_EnableMsgOut( pACB, pSRB ); phase = pSRB->ScsiPhase; DEBUG1(printk (KERN_INFO "DC390: [%i]%s(0) (%02x)\n", phase, dc390_p0_str[phase], sstatus);) @@ -348,21 +357,7 @@ DC390_Interrupt( int irq, void *dev_id, struct pt_regs *regs) DEBUG1(printk (KERN_INFO "DC390: [%i]%s(1) (%02x)\n", phase, dc390_p1_str[phase], sstatus);) stateV = (void *) dc390_phase1[phase]; ( *stateV )( pACB, pSRB, &sstatus ); - goto unlock; } - - if(istatus & INVALID_CMD) - { - dc390_InvalidCmd( pACB ); - goto unlock; - } - - if(istatus & SCSI_RESET) - { - dc390_ScsiRstDetect( pACB ); - goto unlock; - } - unlock: DC390_LOCK_DRV_NI; DC390_UNLOCK_ACB; @@ -385,7 +380,6 @@ dc390_DataOut_0( PACB pACB, PSRB pSRB, PUCHAR psstatus) UCHAR sstatus; PSGL psgl; ULONG ResidCnt, xferCnt; - UCHAR dstate = 0; sstatus = *psstatus; @@ -397,9 +391,10 @@ dc390_DataOut_0( PACB pACB, PSRB pSRB, PUCHAR psstatus) if( sstatus & COUNT_2_ZERO ) { int ctr = 5000000; /* only try for about a tenth of a second */ - while( --ctr && !((dstate = DC390_read8 (DMA_Status)) & DMA_XFER_DONE) && pSRB->SGToBeXferLen ); - if (!ctr) printk (KERN_CRIT "DC390: Deadlock in DataOut_0: DMA aborted unfinished: %06x bytes remain!!\n", DC390_read32 (DMA_Wk_ByteCntr)); - dc390_laststatus &= ~0xff000000; dc390_laststatus |= dstate << 24; + while( --ctr && !(DC390_read8 (DMA_Status) & DMA_XFER_DONE) && pSRB->SGToBeXferLen ) + DC390_write8 (DMA_Status, DMA_XFER_DONE | DMA_XFER_ABORT | DMA_XFER_ERROR | PCI_MS_ABORT); /* clear */ + if (!ctr) printk (KERN_CRIT "DC390: DataOut_0: DMA aborted unfinished: %06x bytes remain!!\n", DC390_read32 (DMA_Wk_ByteCntr)); + DC390_write8 (DMA_Status, DMA_XFER_DONE | DMA_XFER_ABORT | DMA_XFER_ERROR | PCI_MS_ABORT); /* clear */ pSRB->TotalXferredLen += pSRB->SGToBeXferLen; pSRB->SGIndex++; if( pSRB->SGIndex < pSRB->SGcount ) @@ -448,14 +443,15 @@ dc390_DataIn_0( PACB pACB, PSRB pSRB, PUCHAR psstatus) { int ctr = 5000000; /* only try for about a tenth of a second */ int dstate = 0; - while( --ctr && !((dstate = DC390_read8 (DMA_Status)) & DMA_XFER_DONE) && pSRB->SGToBeXferLen ); - if (!ctr) printk (KERN_CRIT "DC390: Deadlock in DataIn_0: DMA aborted unfinished: %06x bytes remain!!\n", DC390_read32 (DMA_Wk_ByteCntr)); + while( --ctr && !((dstate = DC390_read8 (DMA_Status)) & DMA_XFER_DONE) && pSRB->SGToBeXferLen ) + DC390_write8 (DMA_Status, DMA_XFER_DONE | DMA_XFER_ABORT | DMA_XFER_ERROR | PCI_MS_ABORT); /* clear */ + if (!ctr) printk (KERN_CRIT "DC390: DataIn_0: DMA aborted unfinished: %06x bytes remain!!\n", DC390_read32 (DMA_Wk_ByteCntr)); if (!ctr) printk (KERN_CRIT "DC390: DataIn_0: DMA State: %i\n", dstate); - dc390_laststatus &= ~0xff000000; dc390_laststatus |= dstate << 24; DEBUG1(ResidCnt = ((ULONG) DC390_read8 (CtcReg_High) << 16) \ + ((ULONG) DC390_read8 (CtcReg_Mid) << 8) \ + ((ULONG) DC390_read8 (CtcReg_Low));) - DEBUG1(printk (KERN_DEBUG "Count_2_Zero (ResidCnt=%li,ToBeXfer=%li),", ResidCnt, pSRB->SGToBeXferLen);) + DEBUG1(printk ("Count_2_Zero (ResidCnt=%li,ToBeXfer=%li),", ResidCnt, pSRB->SGToBeXferLen);) + DC390_write8 (DMA_Status, DMA_XFER_DONE | DMA_XFER_ABORT | DMA_XFER_ERROR | PCI_MS_ABORT); /* clear */ DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */ @@ -478,7 +474,7 @@ dc390_DataIn_0( PACB pACB, PSRB pSRB, PUCHAR psstatus) bval = DC390_read8 (Current_Fifo); while( bval & 0x1f ) { - DEBUG1(printk (KERN_DEBUG "Check for residuals,");) + DEBUG1(printk ("Check for residuals,");) if( (bval & 0x1f) == 1 ) { for(i=0; i < 0x100; i++) @@ -498,18 +494,17 @@ dc390_DataIn_0( PACB pACB, PSRB pSRB, PUCHAR psstatus) } din_1: DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_BLAST_CMD); - for (i = 0xa000; i; i--) + for (i=0; i<0x8000; i++) { bval = DC390_read8 (DMA_Status); + DC390_write8 (DMA_Status, BLAST_COMPLETE | DMA_XFER_DONE | DMA_XFER_ABORT | DMA_XFER_ERROR | PCI_MS_ABORT); /* clear */ if (bval & BLAST_COMPLETE) break; } - /* It seems a DMA Blast abort isn't that bad ... */ - if (!i) printk (KERN_ERR "DC390: DMA Blast aborted unfinished!\n"); + if (i == 0x8000) printk (KERN_CRIT "DC390: DMA Blast aborted unfinished!!\n"); //DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */ - dc390_laststatus &= ~0xff000000; dc390_laststatus |= bval << 24; - DEBUG1(printk (KERN_DEBUG "Blast: Read %li times DMA_Status %02x", 0xa000-i, bval);) + DEBUG1(printk ("Blast: Read %i times DMA_Status %02x", i, bval);) ResidCnt = (ULONG) DC390_read8 (CtcReg_High); ResidCnt <<= 8; ResidCnt |= (ULONG) DC390_read8 (CtcReg_Mid); @@ -530,7 +525,7 @@ din_1: pSRB->TotalXferredLen++; pSRB->SGToBeXferLen--; } - DEBUG1(printk (KERN_DEBUG "Xfered: %li, Total: %li, Remaining: %li\n", xferCnt,\ + DEBUG1(printk ("Xfered: %li, Total: %li, Remaining: %li\n", xferCnt,\ pSRB->TotalXferredLen, pSRB->SGToBeXferLen);) } @@ -563,278 +558,164 @@ dc390_MsgOut_0( PACB pACB, PSRB pSRB, PUCHAR psstatus) //DC390_write8 (DMA_Cmd, DMA_IDLE_CMD); } - -static void __inline__ -dc390_reprog (PACB pACB, PDCB pDCB) -{ - DC390_write8 (Sync_Period, pDCB->SyncPeriod); - DC390_write8 (Sync_Offset, pDCB->SyncOffset); - DC390_write8 (CtrlReg3, pDCB->CtrlR3); - DC390_write8 (CtrlReg4, pDCB->CtrlR4); - dc390_SetXferRate (pACB, pDCB); -}; - - -#ifdef DC390_DEBUG0 -static void -dc390_printMsg (UCHAR *MsgBuf, UCHAR len) -{ - int i; - printk (" %02x", MsgBuf[0]); - for (i = 1; i < len; i++) - printk (" %02x", MsgBuf[i]); - printk ("\n"); -}; -#endif - -#define DC390_ENABLE_MSGOUT DC390_write8 (ScsiCmd, SET_ATN_CMD) - -/* reject_msg */ -static void __inline__ -dc390_MsgIn_reject (PACB pACB, PSRB pSRB) -{ - pSRB->MsgOutBuf[0] = MSG_REJECT_; - pSRB->MsgCnt = 1; DC390_ENABLE_MSGOUT; - DEBUG0 (printk (KERN_INFO "DC390: Reject message\n");) -} - -/* abort command */ -static void __inline__ -dc390_EnableMsgOut_Abort ( PACB pACB, PSRB pSRB ) +void +dc390_MsgIn_0( PACB pACB, PSRB pSRB, PUCHAR psstatus) { - pSRB->MsgOutBuf[0] = MSG_ABORT; - pSRB->MsgCnt = 1; DC390_ENABLE_MSGOUT; - pSRB->pSRBDCB->DCBFlag &= ~ABORT_DEV_; -} + UCHAR bval; + USHORT wval, wval1; + PDCB pDCB; + PSRB psrb; -static PSRB -dc390_MsgIn_QTag (PACB pACB, PDCB pDCB, UCHAR tag) -{ - PSRB lastSRB = pDCB->pGoingLast; - PSRB pSRB = pDCB->pGoingSRB; + pDCB = pACB->pActiveDCB; - if (pSRB) + bval = DC390_read8 (ScsiFifo); + if( !(pSRB->SRBState & SRB_MSGIN_MULTI) ) { - for( ;pSRB ; ) + if(bval == MSG_DISCONNECT) { - if (pSRB->TagNumber == tag) break; - if (pSRB == lastSRB) goto mingx0; - pSRB = pSRB->pNextSRB; + pSRB->SRBState = SRB_DISCONNECT; } - - if( pDCB->DCBFlag & ABORT_DEV_ ) + else if( bval == MSG_SAVE_PTR ) + goto min6; + else if( (bval == MSG_EXTENDED) || ((bval >= MSG_SIMPLE_QTAG) && + (bval <= MSG_ORDER_QTAG)) ) { - pSRB->SRBState = SRB_ABORT_SENT; - dc390_EnableMsgOut_Abort( pACB, pSRB ); - } - - if( !(pSRB->SRBState & SRB_DISCONNECT) ) - goto mingx0; - - pDCB->pActiveSRB = pSRB; - pSRB->SRBState = SRB_DATA_XFER; - } - else - { - mingx0: - pSRB = pACB->pTmpSRB; - pSRB->SRBState = SRB_UNEXPECT_RESEL; - pDCB->pActiveSRB = pSRB; - pSRB->MsgOutBuf[0] = MSG_ABORT_TAG; - pSRB->MsgCnt = 1; DC390_ENABLE_MSGOUT; - } - return pSRB; -} - - -/* set async transfer mode */ -static void -dc390_MsgIn_set_async (PACB pACB, PSRB pSRB) -{ - PDCB pDCB = pSRB->pSRBDCB; - if (!(pSRB->SRBState & DO_SYNC_NEGO)) - printk ("DC390: Target %i initiates Non-Sync?\n", pDCB->UnitSCSIID); - pSRB->SRBState &= ~DO_SYNC_NEGO; - pDCB->SyncMode &= ~(SYNC_ENABLE+SYNC_NEGO_DONE); - pDCB->SyncPeriod = 0; - pDCB->SyncOffset = 0; - //pDCB->NegoPeriod = 50; /* 200ns <=> 5 MHz */ - pDCB->CtrlR3 = FAST_CLK; /* fast clock / normal scsi */ - pDCB->CtrlR4 &= 0x3f; - pDCB->CtrlR4 |= pACB->glitch_cfg; /* glitch eater */ - dc390_reprog (pACB, pDCB); -} - -/* set sync transfer mode */ -static void -dc390_MsgIn_set_sync (PACB pACB, PSRB pSRB) -{ - UCHAR bval; - USHORT wval, wval1; - PDCB pDCB = pSRB->pSRBDCB; - UCHAR oldsyncperiod = pDCB->SyncPeriod; - UCHAR oldsyncoffset = pDCB->SyncOffset; - - if (!(pSRB->SRBState & DO_SYNC_NEGO)) - { - printk ("DC390: Target %i initiates Sync: %ins %i ... answer ...\n", - pDCB->UnitSCSIID, pSRB->MsgInBuf[3]<<2, pSRB->MsgInBuf[4]); - - /* reject */ - //dc390_MsgIn_reject (pACB, pSRB); - //return dc390_MsgIn_set_async (pACB, pSRB); - - /* Reply with corrected SDTR Message */ - if (pSRB->MsgInBuf[4] > 15) - { - printk ("DC390: Lower Sync Offset to 15\n"); - pSRB->MsgInBuf[4] = 15; + pSRB->SRBState |= SRB_MSGIN_MULTI; + pSRB->MsgInBuf[0] = bval; + pSRB->MsgCnt = 1; + pSRB->pMsgPtr = &(pSRB->MsgInBuf[1]); } - if (pSRB->MsgInBuf[3] < pDCB->NegoPeriod) + else if(bval == MSG_REJECT_) { - printk ("DC390: Set sync nego period to %ins\n", pDCB->NegoPeriod << 2); - pSRB->MsgInBuf[3] = pDCB->NegoPeriod; - }; - memcpy (pSRB->MsgOutBuf, pSRB->MsgInBuf, 5); - pSRB->MsgCnt = 5; - DC390_ENABLE_MSGOUT; - }; - - pSRB->SRBState &= ~DO_SYNC_NEGO; - pDCB->SyncMode |= SYNC_ENABLE+SYNC_NEGO_DONE; - pDCB->SyncOffset &= 0x0f0; - pDCB->SyncOffset |= pSRB->MsgInBuf[4]; - pDCB->NegoPeriod = pSRB->MsgInBuf[3]; - - wval = (USHORT) pSRB->MsgInBuf[3]; - wval = wval << 2; wval -= 3; wval1 = wval / 25; /* compute speed */ - if( (wval1 * 25) != wval) wval1++; - bval = FAST_CLK+FAST_SCSI; /* fast clock / fast scsi */ - - pDCB->CtrlR4 &= 0x3f; /* Glitch eater: 12ns less than normal */ - if (pACB->glitch_cfg != NS_TO_GLITCH(0)) - pDCB->CtrlR4 |= NS_TO_GLITCH(((GLITCH_TO_NS(pACB->glitch_cfg)) - 1)); - else - pDCB->CtrlR4 |= NS_TO_GLITCH(0); - if (wval1 < 4) pDCB->CtrlR4 |= NS_TO_GLITCH(0); /* Ultra */ - - if (wval1 >= 8) - { - wval1--; /* Timing computation differs by 1 from FAST_SCSI */ - bval = FAST_CLK; /* fast clock / normal scsi */ - pDCB->CtrlR4 |= pACB->glitch_cfg; /* glitch eater */ - } - - pDCB->CtrlR3 = bval; - pDCB->SyncPeriod = (UCHAR)wval1; - - if ((oldsyncperiod != wval1 || oldsyncoffset != pDCB->SyncOffset) && pDCB->UnitSCSILUN == 0) - { - if (! (bval & FAST_SCSI)) wval1++; - printk ("DC390: Target %i: Sync transfer %i.%1i MHz, Offset %i\n", pDCB->UnitSCSIID, - 40/wval1, ((40%wval1)*10+wval1/2)/wval1, pDCB->SyncOffset & 0x0f); - } - - dc390_reprog (pACB, pDCB); -}; - - -/* According to the docs, the AM53C974 reads the message and - * generates a Succesful Operation IRQ before asserting ACK for - * the last byte (how does it know whether it's the last ?) */ -/* The old code handled it in another way, indicating, that on - * every message byte an IRQ is generated and every byte has to - * be manually ACKed. Hmmm ? (KG, 98/11/28) */ -/* The old implementation was correct. Sigh! */ - -/* Check if the message is complete */ -static UCHAR __inline__ -dc390_MsgIn_complete (UCHAR *msgbuf, ULONG len) -{ - if (*msgbuf == MSG_EXTENDED) - { - if (len < 2) return 0; - if (len < msgbuf[1] + 2) return 0; - } - else if (*msgbuf >= 0x20 && *msgbuf <= 0x2f) // two byte messages - if (len < 2) return 0; - return 1; -} - - - -/* read and eval received messages */ -void -dc390_MsgIn_0( PACB pACB, PSRB pSRB, PUCHAR psstatus) -{ - PDCB pDCB = pACB->pActiveDCB; - - /* Read the msg */ - - pSRB->MsgInBuf[pACB->MsgLen++] = DC390_read8 (ScsiFifo); - //pSRB->SRBState = 0; - - /* Msg complete ? */ - if (dc390_MsgIn_complete (pSRB->MsgInBuf, pACB->MsgLen)) - { - DEBUG0 (printk (KERN_INFO "DC390: MsgIn:"); dc390_printMsg (pSRB->MsgInBuf, pACB->MsgLen);) - /* Now eval the msg */ - switch (pSRB->MsgInBuf[0]) - { - case MSG_DISCONNECT: - pSRB->SRBState = SRB_DISCONNECT; break; - - case MSG_SIMPLE_QTAG: - case MSG_HEAD_QTAG: - case MSG_ORDER_QTAG: - pSRB = dc390_MsgIn_QTag (pACB, pDCB, pSRB->MsgInBuf[1]); - break; - - case MSG_REJECT_: DC390_write8 (ScsiCmd, RESET_ATN_CMD); - pDCB->NegoPeriod = 50; /* 200ns <=> 5 MHz */ + pDCB->NegoPeriod = 50; if( pSRB->SRBState & DO_SYNC_NEGO) - dc390_MsgIn_set_async (pACB, pSRB); - break; - - case MSG_EXTENDED: - /* reject every extended msg but SDTR */ - if (pSRB->MsgInBuf[1] != 3 || pSRB->MsgInBuf[2] != EXTENDED_SDTR) - dc390_MsgIn_reject (pACB, pSRB); + goto set_async; + } + else if( bval == MSG_RESTORE_PTR) + goto min6; + else + goto min6; + } + else + { /* minx: */ + + *pSRB->pMsgPtr = bval; + pSRB->MsgCnt++; + pSRB->pMsgPtr++; + if( (pSRB->MsgInBuf[0] >= MSG_SIMPLE_QTAG) && + (pSRB->MsgInBuf[0] <= MSG_ORDER_QTAG) ) + { + if( pSRB->MsgCnt == 2) + { + pSRB->SRBState = 0; + bval = pSRB->MsgInBuf[1]; + pSRB = pDCB->pGoingSRB; + psrb = pDCB->pGoingLast; + if( pSRB ) + { + for( ;pSRB ; ) + { + if(pSRB->TagNumber != bval) + { + if( pSRB == psrb ) + goto mingx0; + pSRB = pSRB->pNextSRB; + } + else + break; + } + if( pDCB->DCBFlag & ABORT_DEV_ ) + { + pSRB->SRBState = SRB_ABORT_SENT; + dc390_EnableMsgOut( pACB, pSRB ); + } + if( !(pSRB->SRBState & SRB_DISCONNECT) ) + goto mingx0; + pDCB->pActiveSRB = pSRB; + pSRB->SRBState = SRB_DATA_XFER; + } + else + { +mingx0: + pSRB = pACB->pTmpSRB; + pSRB->SRBState = SRB_UNEXPECT_RESEL; + pDCB->pActiveSRB = pSRB; + pSRB->MsgOutBuf[0] = MSG_ABORT_TAG; + dc390_EnableMsgOut2( pACB, pSRB ); + } + } + } + else if( (pSRB->MsgInBuf[0] == MSG_EXTENDED) && (pSRB->MsgCnt == 5) ) + { /* Note: This will fail for target initiated SDTR ? */ + pSRB->SRBState &= ~(SRB_MSGIN_MULTI); + if( (pSRB->MsgInBuf[1] != 3) || (pSRB->MsgInBuf[2] != EXTENDED_SDTR) ) + { /* reject_msg: */ + pSRB->MsgCnt = 1; + pSRB->MsgInBuf[0] = MSG_REJECT_; + DC390_write8 (ScsiCmd, SET_ATN_CMD); + } + else if( !(pSRB->MsgInBuf[3]) || !(pSRB->MsgInBuf[4]) ) + { +set_async: + pDCB = pSRB->pSRBDCB; + if (!(pSRB->SRBState & DO_SYNC_NEGO)) + printk ("DC390: Target (%i,%i) initiates Non-Sync?\n", pDCB->UnitSCSIID, pDCB->UnitSCSILUN); + pSRB->SRBState &= ~DO_SYNC_NEGO; + pDCB->SyncMode &= ~(SYNC_ENABLE+SYNC_NEGO_DONE); + pDCB->SyncPeriod = 0; + pDCB->SyncOffset = 0; + pDCB->CtrlR3 = FAST_CLK; /* fast clock / normal scsi */ + pDCB->CtrlR4 &= 0x3f; + pDCB->CtrlR4 |= pACB->glitch_cfg; /* glitch eater */ + goto re_prog; + } else - { - if (pSRB->MsgInBuf[3] == 0 || pSRB->MsgInBuf[4] == 0) - dc390_MsgIn_set_async (pACB, pSRB); + { /* set_sync: */ + + pDCB = pSRB->pSRBDCB; + if (!(pSRB->SRBState & DO_SYNC_NEGO)) + printk ("DC390: Target (%i,%i) initiates Sync: %ins %i ?\n", + pDCB->UnitSCSIID, pDCB->UnitSCSILUN, pSRB->MsgInBuf[3]<<2, pSRB->MsgInBuf[4]); + pSRB->SRBState &= ~DO_SYNC_NEGO; + pDCB->SyncMode |= SYNC_ENABLE+SYNC_NEGO_DONE; + pDCB->SyncOffset &= 0x0f0; + pDCB->SyncOffset |= pSRB->MsgInBuf[4]; + pDCB->NegoPeriod = pSRB->MsgInBuf[3]; + wval = (USHORT) pSRB->MsgInBuf[3]; + wval = wval << 2; wval -= 3; wval1 = wval / 25; /* compute speed */ + if( (wval1 * 25) != wval) + wval1++; + bval = FAST_CLK+FAST_SCSI; /* fast clock / fast scsi */ + pDCB->CtrlR4 &= 0x3f; /* Glitch eater: 12ns less than normal */ + if (pACB->glitch_cfg != NS_TO_GLITCH(0)) + pDCB->CtrlR4 |= NS_TO_GLITCH(((GLITCH_TO_NS(pACB->glitch_cfg)) - 1)); else - dc390_MsgIn_set_sync (pACB, pSRB); - }; - - // nothing has to be done - case MSG_COMPLETE: break; - - // SAVE POINTER my be ignored as we have the PSRB associated with the - // scsi command. Thanks, Gerard, for pointing it out. - case MSG_SAVE_PTR: break; - // The device might want to restart transfer with a RESTORE - case MSG_RESTORE_PTR: - printk ("DC390: RESTORE POINTER message received ... reject\n"); - // fall through - - // reject unknown messages - default: dc390_MsgIn_reject (pACB, pSRB); - } - - /* Clear counter and MsgIn state */ - pSRB->SRBState &= ~SRB_MSGIN; - pACB->MsgLen = 0; - }; - + pDCB->CtrlR4 |= NS_TO_GLITCH(0); + if (wval1 < 4) pDCB->CtrlR4 |= NS_TO_GLITCH(0); /* Ultra */ + if (wval1 >= 8) + { + wval1--; /* Timing computation differs by 1 from FAST_SCSI */ + bval = FAST_CLK; /* fast clock / normal scsi */ + pDCB->CtrlR4 |= pACB->glitch_cfg; /* glitch eater */ + } + pDCB->CtrlR3 = bval; + pDCB->SyncPeriod = (UCHAR)wval1; +re_prog: + DC390_write8 (Sync_Period, pDCB->SyncPeriod); + DC390_write8 (Sync_Offset, pDCB->SyncOffset); + DC390_write8 (CtrlReg3, pDCB->CtrlR3); + DC390_write8 (CtrlReg4, pDCB->CtrlR4); + dc390_SetXferRate (pACB, pDCB); + } + } + } +min6: *psstatus = SCSI_NOP0; DC390_write8 (ScsiCmd, MSG_ACCEPTED_CMD); //DC390_write8 (DMA_Cmd, DMA_IDLE_CMD); } - void dc390_DataIO_Comm( PACB pACB, PSRB pSRB, UCHAR ioDir) { @@ -849,10 +730,10 @@ dc390_DataIO_Comm( PACB pACB, PSRB pSRB, UCHAR ioDir) psgl = pSRB->pSegmentList; pSRB->SGBusAddr = virt_to_bus( psgl->address ); pSRB->SGToBeXferLen = (ULONG) psgl->length; - DEBUG1(printk (KERN_DEBUG " DC390: Next SG segment.");) + DEBUG1(printk (" DC390: Next SG segment.");) } lval = pSRB->SGToBeXferLen; - DEBUG1(printk (KERN_DEBUG " DC390: Transfer %li bytes (address %08lx)\n", lval, pSRB->SGBusAddr);) + DEBUG1(printk (" DC390: Transfer %li bytes (address %08lx)\n", lval, pSRB->SGBusAddr);) DC390_write8 (CtcReg_Low, (UCHAR) lval); lval >>= 8; DC390_write8 (CtcReg_Mid, (UCHAR) lval); @@ -868,22 +749,21 @@ dc390_DataIO_Comm( PACB pACB, PSRB pSRB, UCHAR ioDir) DC390_write8 (ScsiCmd, DMA_COMMAND+INFO_XFER_CMD); DC390_write8 (DMA_Cmd, DMA_START_CMD | ioDir | DMA_INT); - //DEBUG1(DC390_write32 (DMA_ScsiBusCtrl, WRT_ERASE_DMA_STAT | EN_INT_ON_PCI_ABORT);) - //DEBUG1(printk (KERN_DEBUG "DC390: DMA_Status: %02x\n", DC390_read8 (DMA_Status));) - //DEBUG1(DC390_write32 (DMA_ScsiBusCtrl, EN_INT_ON_PCI_ABORT);) + //DEBUG1(printk ("DC390: DMA_Status: %02x\n", DC390_read8 (DMA_Status));) } else /* xfer pad */ { + UCHAR bval = 0; if( pSRB->SGcount ) { pSRB->AdaptStatus = H_OVER_UNDER_RUN; pSRB->SRBStatus |= OVER_RUN; - DEBUG0(printk (KERN_WARNING " DC390: Overrun -");) + DEBUG0(printk (" DC390: Overrun -");) } - DEBUG0(printk (KERN_WARNING " Clear transfer pad \n");) - DC390_write8 (CtcReg_Low, 0); - DC390_write8 (CtcReg_Mid, 0); - DC390_write8 (CtcReg_High, 0); + DEBUG0(printk (" Clear transfer pad \n");) + DC390_write8 (CtcReg_Low, bval); + DC390_write8 (CtcReg_Mid, bval); + DC390_write8 (CtcReg_High, bval); pSRB->SRBState |= SRB_XFERPAD; DC390_write8 (ScsiCmd, DMA_COMMAND+XFER_PAD_BYTE); @@ -1137,7 +1017,7 @@ disc1: dc390_SRBdone( pACB, pDCB, pSRB); } } - pACB->MsgLen = 0; + return; } @@ -1152,7 +1032,7 @@ dc390_Reselect( PACB pACB ) DEBUG0(printk(KERN_INFO "RSEL,");) pDCB = pACB->pActiveDCB; if( pDCB ) - { /* Arbitration lost but Reselection won */ + { /* Arbitration lost but Reselection win */ DEBUG0(printk ("(ActiveDCB != 0)");) pSRB = pDCB->pActiveSRB; if( !( pACB->scan_devices ) ) @@ -1195,23 +1075,23 @@ dc390_Reselect( PACB pACB ) printk (KERN_ERR "DC390: Reselect without outstanding cmnd (ID %02x, LUN %02x)\n", wval & 0xff, (wval & 0xff00) >> 8); pDCB->pActiveSRB = pSRB; - dc390_EnableMsgOut_Abort ( pACB, pSRB ); + dc390_EnableMsgOut( pACB, pSRB ); } else { if( pDCB->DCBFlag & ABORT_DEV_ ) { pSRB->SRBState = SRB_ABORT_SENT; - printk (KERN_INFO "DC390: Reselect: Abort (ID %02x, LUN %02x)\n", + printk (KERN_NOTICE "DC390: Reselect: Abort (ID %02x, LUN %02x)\n", wval & 0xff, (wval & 0xff00) >> 8); - dc390_EnableMsgOut_Abort( pACB, pSRB ); + dc390_EnableMsgOut( pACB, pSRB ); } else pSRB->SRBState = SRB_DATA_XFER; } } - DEBUG1(printk (KERN_DEBUG "Resel SRB(%p): TagNum (%02x)\n", pSRB, pSRB->TagNumber);) + DEBUG1(printk ("Resel SRB(%p): TagNum (%02x)\n", pSRB, pSRB->TagNumber);) pSRB->ScsiPhase = SCSI_NOP0; DC390_write8 (Scsi_Dest_ID, pDCB->UnitSCSIID); DC390_write8 (Sync_Period, pDCB->SyncPeriod); @@ -1364,7 +1244,7 @@ dc390_SRBdone( PACB pACB, PDCB pDCB, PSRB pSRB ) else pcmd->result = (DRIVER_SENSE << 24) | (DRIVER_OK << 16) | SCSI_STAT_CHECKCOND; - REMOVABLEDEBUG(printk(KERN_INFO "Cmd=%02x,Result=%08x,XferL=%08x\n",pSRB->CmdBlock[0],\ + REMOVABLEDEBUG(printk("Cmd=%02x,Result=%08x,XferL=%08x\n",pSRB->CmdBlock[0],\ (UINT) pcmd->result, (UINT) pSRB->TotalXferredLen);) goto ckc_e; } @@ -1380,7 +1260,7 @@ dc390_SRBdone( PACB pACB, PDCB pDCB, PSRB pSRB ) { pcmd->result = (DRIVER_SENSE << 24) | (DRIVER_OK << 16) | SCSI_STAT_CHECKCOND; - REMOVABLEDEBUG(printk(KERN_INFO "Cmd=%02x, Result=%08x, XferL=%08x\n",pSRB->CmdBlock[0],\ + REMOVABLEDEBUG(printk("Cmd=%02x, Result=%08x, XferL=%08x\n",pSRB->CmdBlock[0],\ (UINT) pcmd->result, (UINT) pSRB->TotalXferredLen);) goto ckc_e; } @@ -1419,7 +1299,7 @@ dc390_SRBdone( PACB pACB, PDCB pDCB, PSRB pSRB ) swlval += ptr2->length; ptr2++; } - REMOVABLEDEBUG(printk(KERN_INFO "XferredLen=%08x,NotXferLen=%08x\n",\ + REMOVABLEDEBUG(printk("XferredLen=%08x,NotXferLen=%08x\n",\ (UINT) pSRB->TotalXferredLen, (UINT) swlval);) } dc390_RequestSense( pACB, pDCB, pSRB ); @@ -1707,6 +1587,22 @@ dc390_RequestSense( PACB pACB, PDCB pDCB, PSRB pSRB ) } +static void __inline__ +dc390_EnableMsgOut2( PACB pACB, PSRB pSRB ) +{ + pSRB->MsgCnt = 1; + DC390_write8 (ScsiCmd, SET_ATN_CMD); +} + + +static void __inline__ +dc390_EnableMsgOut( PACB pACB, PSRB pSRB ) +{ + pSRB->MsgOutBuf[0] = MSG_ABORT; + dc390_EnableMsgOut2( pACB, pSRB ); + pSRB->pSRBDCB->DCBFlag &= ~ABORT_DEV_; +} + static void __inline__ dc390_InvalidCmd( PACB pACB ) diff --git a/drivers/scsi/seagate.c b/drivers/scsi/seagate.c index 14b7e363fc70..9e94274644e1 100644 --- a/drivers/scsi/seagate.c +++ b/drivers/scsi/seagate.c @@ -164,7 +164,7 @@ typedef struct { } Signature; static const Signature signatures[] = { -#if defined(CONFIG_SCSI_SEAGATE) || defined(CONFIG_SCSI_SEAGATE_MODULE) +#ifdef CONFIG_SCSI_SEAGATE {"ST01 v1.7 (C) Copyright 1987 Seagate", 15, 37, SEAGATE}, {"SCSI BIOS 2.00 (C) Copyright 1987 Seagate", 15, 40, SEAGATE}, diff --git a/drivers/scsi/sym53c416.c b/drivers/scsi/sym53c416.c deleted file mode 100644 index a750550d80a1..000000000000 --- a/drivers/scsi/sym53c416.c +++ /dev/null @@ -1,805 +0,0 @@ -/* - * sym53c416.c - * Low-level SCSI driver for sym53c416 chip. - * Copyright (C) 1998 Lieven Willems (lw_linux@hotmail.com) - * - * LILO command line usage: sym53c416=[,] - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "scsi.h" -#include "hosts.h" -#include "sd.h" -#include "sym53c416.h" - -#define VERSION_STRING "Version 1.0.0" - -#define TC_LOW 0x00 /* Transfer counter low */ -#define TC_MID 0x01 /* Transfer counter mid */ -#define SCSI_FIFO 0x02 /* SCSI FIFO register */ -#define COMMAND_REG 0x03 /* Command Register */ -#define STATUS_REG 0x04 /* Status Register (READ) */ -#define DEST_BUS_ID 0x04 /* Destination Bus ID (WRITE) */ -#define INT_REG 0x05 /* Interrupt Register (READ) */ -#define TOM 0x05 /* Time out multiplier (WRITE) */ -#define STP 0x06 /* Synchronous Transfer period */ -#define SYNC_OFFSET 0x07 /* Synchronous Offset */ -#define CONF_REG_1 0x08 /* Configuration register 1 */ -#define CONF_REG_2 0x0B /* Configuration register 2 */ -#define CONF_REG_3 0x0C /* Configuration register 3 */ -#define CONF_REG_4 0x0D /* Configuration register 4 */ -#define TC_HIGH 0x0E /* Transfer counter high */ -#define PIO_FIFO_1 0x10 /* PIO FIFO register 1 */ -#define PIO_FIFO_2 0x11 /* PIO FIFO register 2 */ -#define PIO_FIFO_3 0x12 /* PIO FIFO register 3 */ -#define PIO_FIFO_4 0x13 /* PIO FIFO register 4 */ -#define PIO_FIFO_CNT 0x14 /* PIO FIFO count */ -#define PIO_INT_REG 0x15 /* PIO interrupt register */ -#define CONF_REG_5 0x16 /* Configuration register 5 */ -#define FEATURE_EN 0x1D /* Feature Enable register */ - -/* Configuration register 1 entries: */ -/* Bits 2-0: SCSI ID of host adapter */ -#define SCM 0x80 /* Slow Cable Mode */ -#define SRID 0x40 /* SCSI Reset Interrupt Disable */ -#define PTM 0x20 /* Parity Test Mode */ -#define EPC 0x10 /* Enable Parity Checking */ -#define CTME 0x08 /* Special Test Mode */ - -/* Configuration register 2 entries: */ -#define FE 0x40 /* Features Enable */ -#define SCSI2 0x08 /* SCSI 2 Enable */ -#define TBPA 0x04 /* Target Bad Parity Abort */ - -/* Configuration register 3 entries: */ -#define IDMRC 0x80 /* ID Message Reserved Check */ -#define QTE 0x40 /* Queue Tag Enable */ -#define CDB10 0x20 /* Command Descriptor Block 10 */ -#define FSCSI 0x10 /* FastSCSI */ -#define FCLK 0x08 /* FastClock */ - -/* Configuration register 4 entries: */ -#define RBS 0x08 /* Register bank select */ -#define EAN 0x04 /* Enable Active Negotiation */ - -/* Configuration register 5 entries: */ -#define LPSR 0x80 /* Lower Power SCSI Reset */ -#define IE 0x20 /* Interrupt Enable */ -#define LPM 0x02 /* Low Power Mode */ -#define WSE0 0x01 /* 0WS Enable */ - -/* Interrupt register entries: */ -#define SRST 0x80 /* SCSI Reset */ -#define ILCMD 0x40 /* Illegal Command */ -#define DIS 0x20 /* Disconnect */ -#define BS 0x10 /* Bus Service */ -#define FC 0x08 /* Function Complete */ -#define RESEL 0x04 /* Reselected */ -#define SI 0x03 /* Selection Interrupt */ - -/* Status Register Entries: */ -#define SCI 0x80 /* SCSI Core Int */ -#define GE 0x40 /* Gross Error */ -#define PE 0x20 /* Parity Error */ -#define TC 0x10 /* Terminal Count */ -#define VGC 0x08 /* Valid Group Code */ -#define PHBITS 0x07 /* Phase bits */ - -/* PIO Interrupt Register Entries: */ -#define SCI 0x80 /* SCSI Core Int */ -#define PFI 0x40 /* PIO FIFO Interrupt */ -#define FULL 0x20 /* PIO FIFO Full */ -#define EMPTY 0x10 /* PIO FIFO Empty */ -#define CE 0x08 /* Collision Error */ -#define OUE 0x04 /* Overflow / Underflow error */ -#define FIE 0x02 /* Full Interrupt Enable */ -#define EIE 0x01 /* Empty Interrupt Enable */ - -/* SYM53C416 SCSI phases (lower 3 bits of SYM53C416_STATUS_REG) */ -#define PHASE_DATA_OUT 0x00 -#define PHASE_DATA_IN 0x01 -#define PHASE_COMMAND 0x02 -#define PHASE_STATUS 0x03 -#define PHASE_RESERVED_1 0x04 -#define PHASE_RESERVED_2 0x05 -#define PHASE_MESSAGE_OUT 0x06 -#define PHASE_MESSAGE_IN 0x07 - -/* SYM53C416 core commands */ -#define NOOP 0x00 -#define FLUSH_FIFO 0x01 -#define RESET_CHIP 0x02 -#define RESET_SCSI_BUS 0x03 -#define DISABLE_SEL_RESEL 0x45 -#define RESEL_SEQ 0x40 -#define SEL_WITHOUT_ATN_SEQ 0x41 -#define SEL_WITH_ATN_SEQ 0x42 -#define SEL_WITH_ATN_AND_STOP_SEQ 0x43 -#define ENABLE_SEL_RESEL 0x44 -#define SEL_WITH_ATN3_SEQ 0x46 -#define RESEL3_SEQ 0x47 -#define SND_MSG 0x20 -#define SND_STAT 0x21 -#define SND_DATA 0x22 -#define DISCONNECT_SEQ 0x23 -#define TERMINATE_SEQ 0x24 -#define TARGET_COMM_COMPLETE_SEQ 0x25 -#define DISCONN 0x27 -#define RECV_MSG_SEQ 0x28 -#define RECV_CMD 0x29 -#define RECV_DATA 0x2A -#define RECV_CMD_SEQ 0x2B -#define TARGET_ABORT_PIO 0x04 -#define TRANSFER_INFORMATION 0x10 -#define INIT_COMM_COMPLETE_SEQ 0x11 -#define MSG_ACCEPTED 0x12 -#define TRANSFER_PAD 0x18 -#define SET_ATN 0x1A -#define RESET_ATN 0x1B -#define ILLEGAL 0xFF - -#define PIO_MODE 0x80 - -#define IO_RANGE 0x20 /* 0x00 - 0x1F */ -#define ID "sym53c416" -#define PIO_SIZE 128 /* Size of PIO fifo is 128 bytes */ - -#define READ_TIMEOUT 150 -#define WRITE_TIMEOUT 150 - -#ifdef MODULE - -#define sym53c416_base sym53c416 -#define sym53c416_base_1 sym53c416_1 -#define sym53c416_base_2 sym53c416_2 -#define sym53c416_base_3 sym53c416_3 - -static unsigned short sym53c416_base = 0; -static unsigned int sym53c416_irq = 0; -static unsigned short sym53c416_base_1 = 0; -static unsigned int sym53c416_irq_1 = 0; -static unsigned short sym53c416_base_2 = 0; -static unsigned int sym53c416_irq_2 = 0; -static unsigned short sym53c416_base_3 = 0; -static unsigned int sym53c416_irq_3 = 0; - -#endif - -/* #define DEBUG */ - -/* Macro for debugging purposes */ - -#ifdef DEBUG -#define DEB(x) x -#else -#define DEB(x) -#endif - -#define MAXHOSTS 4 - -enum phases - { - idle, - data_out, - data_in, - command_ph, - status_ph, - message_out, - message_in - }; - -typedef struct - { - int base; - int irq; - int scsi_id; - } host; - -host hosts[MAXHOSTS] = { - {0, 0, SYM53C416_SCSI_ID}, - {0, 0, SYM53C416_SCSI_ID}, - {0, 0, SYM53C416_SCSI_ID}, - {0, 0, SYM53C416_SCSI_ID} - }; - -static int host_index = 0; - -static char info[120]; - -static Scsi_Cmnd *current_command = NULL; - -struct proc_dir_entry proc_scsi_sym53c416 = {PROC_SCSI_SYM53C416, 7, ID, S_IFDIR | S_IRUGO | S_IXUGO, 2}; - -int fastpio = 1; - -int probeaddrs[] = {0x200, 0x220, 0x240, 0}; - -static void sym53c416_set_transfer_counter(int base, unsigned int len) - { - /* Program Transfer Counter */ - outb(len & 0x0000FF, base + TC_LOW); - outb((len & 0x00FF00) >> 8, base + TC_MID); - outb((len & 0xFF0000) >> 16, base + TC_HIGH); - } - -/* Returns the number of bytes read */ -static __inline__ unsigned int sym53c416_read(int base, unsigned char *buffer, unsigned int len) - { - unsigned int orig_len = len; - unsigned long flags = 0; - unsigned int bytes_left; - int i; - int timeout = READ_TIMEOUT; - - /* Do transfer */ - save_flags(flags); - cli(); - while(len && timeout) - { - bytes_left = inb(base + PIO_FIFO_CNT); /* Number of bytes in the PIO FIFO */ - if(fastpio && bytes_left > 3) - { - insl(base + PIO_FIFO_1, buffer, bytes_left >> 2); - buffer += bytes_left & 0xFC; - len -= bytes_left & 0xFC; - } - else if(bytes_left > 0) - { - len -= bytes_left; - for(; bytes_left > 0; bytes_left--) - *(buffer++) = inb(base + PIO_FIFO_1); - } - else - { - i = jiffies + timeout; - restore_flags(flags); - while(jiffies < i && (inb(base + PIO_INT_REG) & EMPTY) && timeout) - if(inb(base + PIO_INT_REG) & SCI) - timeout = 0; - save_flags(flags); - cli(); - if(inb(base + PIO_INT_REG) & EMPTY) - timeout = 0; - } - } - restore_flags(flags); - return orig_len - len; - } - -/* Returns the number of bytes written */ -static __inline__ unsigned int sym53c416_write(int base, unsigned char *buffer, unsigned int len) - { - unsigned int orig_len = len; - unsigned long flags = 0; - unsigned int bufferfree; - unsigned int i; - unsigned int timeout = WRITE_TIMEOUT; - - /* Do transfer */ - save_flags(flags); - cli(); - while(len && timeout) - { - bufferfree = PIO_SIZE - inb(base + PIO_FIFO_CNT); - if(bufferfree > len) - bufferfree = len; - if(fastpio && bufferfree > 3) - { - outsl(base + PIO_FIFO_1, buffer, bufferfree >> 2); - buffer += bufferfree & 0xFC; - len -= bufferfree & 0xFC; - } - else if(bufferfree > 0) - { - len -= bufferfree; - for(; bufferfree > 0; bufferfree--) - outb(*(buffer++), base + PIO_FIFO_1); - } - else - { - i = jiffies + timeout; - restore_flags(flags); - while(jiffies < i && (inb(base + PIO_INT_REG) & FULL) && timeout) - ; - save_flags(flags); - cli(); - if(inb(base + PIO_INT_REG) & FULL) - timeout = 0; - } - } - restore_flags(flags); - return orig_len - len; - } - -static void sym53c416_intr_handle(int irq, void *dev_id, struct pt_regs *regs) - { - int base = 0; - int i; - unsigned long flags = 0; - unsigned char status_reg, pio_int_reg, int_reg; - struct scatterlist *sglist; - unsigned int sgcount; - unsigned int tot_trans = 0; - - /* We search the base address of the host adapter which caused the interrupt */ - for(i = 0; i < host_index && !base; i++) - if(irq == hosts[i].irq) - base = hosts[i].base; - /* If no adapter found, we cannot handle the interrupt. Leave a message */ - /* and continue. This should never happen... */ - if(!base) - { - printk("sym53c416: No host adapter defined for interrupt %d\n", irq); - return; - } - /* Now we have the base address and we can start handling the interrupt */ - save_flags(flags); - cli(); - status_reg = inb(base + STATUS_REG); - pio_int_reg = inb(base + PIO_INT_REG); - int_reg = inb(base + INT_REG); - restore_flags(flags); - - /* First, we handle error conditions */ - if(int_reg & SCI) /* SCSI Reset */ - { - printk("sym53c416: Warning: Reset received\n"); - current_command->SCp.phase = idle; - current_command->result = DID_RESET << 16; - current_command->scsi_done(current_command); - return; - } - if(int_reg & ILCMD) /* Illegal Command */ - { - printk("sym53c416: Warning: Illegal Command: 0x%02x\n", inb(base + COMMAND_REG)); - current_command->SCp.phase = idle; - current_command->result = DID_ERROR << 16; - current_command->scsi_done(current_command); - return; - } - if(status_reg & GE) /* Gross Error */ - { - printk("sym53c416: Warning: Gross Error\n"); - current_command->SCp.phase = idle; - current_command->result = DID_ERROR << 16; - current_command->scsi_done(current_command); - return; - } - if(status_reg & PE) /* Parity Error */ - { - printk("sym53c416: Warning: Parity Error\n"); - current_command->SCp.phase = idle; - current_command->result = DID_PARITY << 16; - current_command->scsi_done(current_command); - return; - } - if(pio_int_reg & (CE | OUE)) - { - printk("sym53c416: Warning: PIO Interrupt Error\n"); - current_command->SCp.phase = idle; - current_command->result = DID_ERROR << 16; - current_command->scsi_done(current_command); - return; - } - if(int_reg & DIS) /* Disconnect */ - { - if(current_command->SCp.phase != message_in) - current_command->result = DID_NO_CONNECT << 16; - else - current_command->result = (current_command->SCp.Status & 0xFF) | ((current_command->SCp.Message & 0xFF) << 8) | (DID_OK << 16); - current_command->SCp.phase = idle; - current_command->scsi_done(current_command); - return; - } - /* Now we handle SCSI phases */ - switch(status_reg & PHBITS) /* Filter SCSI phase out of status reg */ - { - case PHASE_DATA_OUT: - { - if(int_reg & BS) - { - current_command->SCp.phase = data_out; - outb(FLUSH_FIFO, base + COMMAND_REG); - sym53c416_set_transfer_counter(base, current_command->request_bufflen); - outb(TRANSFER_INFORMATION | PIO_MODE, base + COMMAND_REG); - if(!current_command->use_sg) - tot_trans = sym53c416_write(base, current_command->request_buffer, current_command->request_bufflen); - else - { - sgcount = current_command->use_sg; - sglist = current_command->request_buffer; - while(sgcount--) - { - tot_trans += sym53c416_write(base, sglist->address, sglist->length); - sglist++; - } - } - if(tot_trans < current_command->underflow) - printk("sym53c416: Warning: underflow, wrote %d bytes, request for %d bytes\n", tot_trans, current_command->underflow); - } - break; - } - case PHASE_DATA_IN: - { - if(int_reg & BS) - { - current_command->SCp.phase = data_in; - outb(FLUSH_FIFO, base + COMMAND_REG); - sym53c416_set_transfer_counter(base, current_command->request_bufflen); - outb(TRANSFER_INFORMATION | PIO_MODE, base + COMMAND_REG); - if(!current_command->use_sg) - tot_trans = sym53c416_read(base, current_command->request_buffer, current_command->request_bufflen); - else - { - sgcount = current_command->use_sg; - sglist = current_command->request_buffer; - while(sgcount--) - { - tot_trans += sym53c416_read(base, sglist->address, sglist->length); - sglist++; - } - } - if(tot_trans < current_command->underflow) - printk("sym53c416: Warning: underflow, read %d bytes, request for %d bytes\n", tot_trans, current_command->underflow); - } - break; - } - case PHASE_COMMAND: - { - current_command->SCp.phase = command_ph; - printk("sym53c416: Warning: Unknown interrupt in command phase\n"); - break; - } - case PHASE_STATUS: - { - current_command->SCp.phase = status_ph; - outb(FLUSH_FIFO, base + COMMAND_REG); - outb(INIT_COMM_COMPLETE_SEQ, base + COMMAND_REG); - break; - } - case PHASE_RESERVED_1: - case PHASE_RESERVED_2: - { - printk("sym53c416: Warning: Reserved phase\n"); - break; - } - case PHASE_MESSAGE_OUT: - { - current_command->SCp.phase = message_out; - outb(SET_ATN, base + COMMAND_REG); - outb(MSG_ACCEPTED, base + COMMAND_REG); - break; - } - case PHASE_MESSAGE_IN: - { - current_command->SCp.phase = message_in; - current_command->SCp.Status = inb(base + SCSI_FIFO); - current_command->SCp.Message = inb(base + SCSI_FIFO); - if(current_command->SCp.Message == SAVE_POINTERS || current_command->SCp.Message == DISCONNECT) - outb(SET_ATN, base + COMMAND_REG); - outb(MSG_ACCEPTED, base + COMMAND_REG); - break; - } - } - } - -static void sym53c416_init(int base, int scsi_id) - { - outb(RESET_CHIP, base + COMMAND_REG); - outb(NOOP, base + COMMAND_REG); - outb(0x99, base + TOM); /* Time out of 250 ms */ - outb(0x05, base + STP); - outb(0x00, base + SYNC_OFFSET); - outb(EPC | scsi_id, base + CONF_REG_1); - outb(FE | SCSI2 | TBPA, base + CONF_REG_2); - outb(IDMRC | QTE | CDB10 | FSCSI | FCLK, base + CONF_REG_3); - outb(0x83 | EAN, base + CONF_REG_4); - outb(IE | WSE0, base + CONF_REG_5); - outb(0, base + FEATURE_EN); - } - -static int sym53c416_probeirq(int base, int scsi_id) - { - int irq, irqs, i; - - /* Clear interrupt register */ - inb(base + INT_REG); - /* Start probing for irq's */ - irqs = probe_irq_on(); - /* Reinit chip */ - sym53c416_init(base, scsi_id); - /* Cause interrupt */ - outb(NOOP, base + COMMAND_REG); - outb(ILLEGAL, base + COMMAND_REG); - outb(0x07, base + DEST_BUS_ID); - outb(0x00, base + DEST_BUS_ID); - /* Wait for interrupt to occur */ - i = jiffies + 20; - while(i > jiffies && !(inb(base + STATUS_REG) & SCI)) - barrier(); - if(i <= jiffies) /* timed out */ - return 0; - /* Get occurred irq */ - irq = probe_irq_off(irqs); - sym53c416_init(base, scsi_id); - return irq; - } - -/* Setup: sym53c416=base,irq */ -void sym53c416_setup(char *str, int *ints) - { - int i; - - if(host_index >= MAXHOSTS) - { - printk("sym53c416.c: Too many hosts defined\n"); - } - else - { - if(ints[0] < 1 || ints[0] > 2) - { - printk("sym53c416.c: Wrong number of parameters:\n"); - printk("sym53c416.c: usage: sym53c416=[,]\n"); - } - else - { - for(i = 0; i < host_index && i >= 0; i++) - if(hosts[i].base == ints[1]) - i = -2; - if(i >= 0) - { - hosts[host_index].base = ints[1]; - hosts[host_index].irq = (ints[0] == 2)? ints[2] : 0; - host_index++; - } - } - } - } - -static int sym53c416_test(int base) - { - outb(RESET_CHIP, base + COMMAND_REG); - outb(NOOP, base + COMMAND_REG); - if(inb(base + COMMAND_REG) != NOOP) - return 0; - if(!inb(base + TC_HIGH) || inb(base + TC_HIGH) == 0xFF) - return 0; - if((inb(base + PIO_INT_REG) & (FULL | EMPTY | CE | OUE | FIE | EIE)) != EMPTY) - return 0; - return 1; - } - -void sym53c416_probe(void) - { - int *base = probeaddrs; - int ints[2]; - - ints[0] = 1; - for(; *base; base++) - if(!check_region(*base, IO_RANGE) && sym53c416_test(*base)) - { - ints[1] = *base; - sym53c416_setup(NULL, ints); - } - } - -int sym53c416_detect(Scsi_Host_Template *tpnt) - { - unsigned long flags; - struct Scsi_Host * shpnt = NULL; - int i; - int count; - -#ifdef MODULE - int ints[3]; - - ints[0] = 2; - if(sym53c416_base) - { - ints[1] = sym53c416_base; - ints[2] = sym53c416_irq; - sym53c416_setup(NULL, ints); - } - if(sym53c416_base_1) - { - ints[1] = sym53c416_base_1; - ints[2] = sym53c416_irq_1; - sym53c416_setup(NULL, ints); - } - if(sym53c416_base_2) - { - ints[1] = sym53c416_base_2; - ints[2] = sym53c416_irq_2; - sym53c416_setup(NULL, ints); - } - if(sym53c416_base_3) - { - ints[1] = sym53c416_base_3; - ints[2] = sym53c416_irq_3; - sym53c416_setup(NULL, ints); - } -#endif - - printk("sym53c416.c: %s\n", VERSION_STRING); - - sym53c416_probe(); - - /* Now we register and set up each host adapter found... */ - for(count = 0, i = 0; i < host_index; i++) - if(!sym53c416_test(hosts[i].base)) - printk("No sym53c416 found at address 0x%03x\n", hosts[i].base); - else - { - if(hosts[i].irq == 0) - /* We don't have an irq yet, so we should probe for one */ - if((hosts[i].irq = sym53c416_probeirq(hosts[i].base, hosts[i].scsi_id)) == 0) - printk("irq autoprobing failed for sym53c416 at address 0x%03x\n", hosts[i].base); - if(hosts[i].irq && !check_region(hosts[i].base, IO_RANGE)) - { - shpnt = scsi_register(tpnt, 0); - save_flags(flags); - cli(); - /* Request for specified IRQ */ - if(request_irq(hosts[i].irq, sym53c416_intr_handle, 0, ID, NULL)) - { - restore_flags(flags); - printk("Unable to assign IRQ %d\n", hosts[i].irq); - scsi_unregister(shpnt); - } - else - { - /* Inform the kernel of our IO range */ - request_region(hosts[i].base, IO_RANGE, ID); - shpnt->unique_id = hosts[i].base; - shpnt->io_port = hosts[i].base; - shpnt->n_io_port = IO_RANGE; - shpnt->irq = hosts[i].irq; - shpnt->this_id = hosts[i].scsi_id; - sym53c416_init(hosts[i].base, hosts[i].scsi_id); - count++; - restore_flags(flags); - } - } - } - return count; - } - -const char *sym53c416_info(struct Scsi_Host *SChost) - { - int i; - int base = SChost->io_port; - int irq = SChost->irq; - int scsi_id = 0; - int rev = inb(base + TC_HIGH); - - for(i = 0; i < host_index; i++) - if(hosts[i].base == base) - scsi_id = hosts[i].scsi_id; - sprintf(info, "Symbios Logic 53c416 (rev. %d) at 0x%03x, irq %d, SCSI-ID %d, %s pio", rev, base, irq, scsi_id, (fastpio)? "fast" : "slow"); - return info; - } - -int sym53c416_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) - { - int base; - unsigned long flags = 0; - int i; - - /* Store base register as we can have more than one controller in the system */ - base = SCpnt->host->io_port; - current_command = SCpnt; /* set current command */ - current_command->scsi_done = done; /* set ptr to done function */ - current_command->SCp.phase = command_ph; /* currect phase is the command phase */ - current_command->SCp.Status = 0; - current_command->SCp.Message = 0; - - save_flags(flags); - cli(); - outb(SCpnt->target, base + DEST_BUS_ID); /* Set scsi id target */ - outb(FLUSH_FIFO, base + COMMAND_REG); /* Flush SCSI and PIO FIFO's */ - /* Write SCSI command into the SCSI fifo */ - for(i = 0; i < SCpnt->cmd_len; i++) - outb(SCpnt->cmnd[i], base + SCSI_FIFO); - /* Start selection sequence */ - outb(SEL_WITHOUT_ATN_SEQ, base + COMMAND_REG); - /* Now an interrupt will be generated which we will catch in out interrupt routine */ - restore_flags(flags); - return 0; - } - -static void internal_done(Scsi_Cmnd *SCpnt) - { - SCpnt->SCp.Status++; - } - -int sym53c416_command(Scsi_Cmnd *SCpnt) - { - sym53c416_queuecommand(SCpnt, internal_done); - SCpnt->SCp.Status = 0; - while(!SCpnt->SCp.Status) - barrier(); - return SCpnt->result; - } - -int sym53c416_abort(Scsi_Cmnd *SCpnt) - { - printk("sym53c416_abort\n"); - - /* We don't know how to abort for the moment */ - return SCSI_ABORT_SNOOZE; - } - -int sym53c416_reset(Scsi_Cmnd *SCpnt, unsigned int reset_flags) - { - int base; - int scsi_id = -1; - int i; - - printk("sym53c416_reset\n"); - base = SCpnt->host->io_port; - /* search scsi_id */ - for(i = 0; i < host_index && scsi_id != -1; i++) - if(hosts[i].base == base) - scsi_id = hosts[i].scsi_id; - outb(RESET_CHIP, base + COMMAND_REG); - outb(NOOP | PIO_MODE, base + COMMAND_REG); - outb(RESET_SCSI_BUS, base + COMMAND_REG); - sym53c416_init(base, scsi_id); - return SCSI_RESET_PENDING; - } - -int sym53c416_bios_param(Disk *disk, kdev_t dev, int *ip) - { - int size; - - size = disk->capacity; - ip[0] = 64; /* heads */ - ip[1] = 32; /* sectors */ - if((ip[2] = size >> 11) > 1024) /* cylinders, test for big disk */ - { - ip[0] = 255; /* heads */ - ip[1] = 63; /* sectors */ - ip[2] = size / (255 * 63); /* cylinders */ - } - return 0; - } - -/* Loadable module support */ -#ifdef MODULE - -#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,26) -MODULE_AUTHOR("Lieven Willems"); -MODULE_PARM(sym53c416, "1-2i"); -MODULE_PARM(sym53c416_1, "1-2i"); -MODULE_PARM(sym53c416_2, "1-2i"); -MODULE_PARM(sym53c416_3, "1-2i"); -#endif - -Scsi_Host_Template driver_template = SYM53C416; - -#include "scsi_module.c" -#endif diff --git a/drivers/scsi/sym53c416.h b/drivers/scsi/sym53c416.h deleted file mode 100644 index 49abc83cac7a..000000000000 --- a/drivers/scsi/sym53c416.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * sym53c416.h - * - * Copyright (C) 1998 Lieven Willems (lw_linux@hotmail.com) - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#ifndef _SYM53C416_H -#define _SYM53C416_H - -#if !defined(LINUX_VERSION_CODE) -#include -#endif - -#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s)) - -#include -#include - -#define SYM53C416_SCSI_ID 7 - -extern struct proc_dir_entry proc_scsi_sym53c416; - -extern int sym53c416_detect(Scsi_Host_Template *); -extern const char *sym53c416_info(struct Scsi_Host *); -extern int sym53c416_command(Scsi_Cmnd *); -extern int sym53c416_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); -extern int sym53c416_abort(Scsi_Cmnd *); -extern int sym53c416_reset(Scsi_Cmnd *, unsigned int); -extern int sym53c416_bios_param(Disk *, kdev_t, int *); -extern void sym53c416_setup(char *str, int *ints); - -#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,75) - -#define SYM53C416 { \ - proc_dir: &proc_scsi_sym53c416, \ - name: "Symbios Logic 53c416", \ - detect: sym53c416_detect, \ - info: sym53c416_info, \ - command: sym53c416_command, \ - queuecommand: sym53c416_queuecommand, \ - abort: sym53c416_abort, \ - reset: sym53c416_reset, \ - bios_param: sym53c416_bios_param, \ - can_queue: 1, \ - this_id: SYM53C416_SCSI_ID, \ - sg_tablesize: 32, \ - cmd_per_lun: 1, \ - unchecked_isa_dma: 1, \ - use_clustering: ENABLE_CLUSTERING \ - } - -#else - -#define SYM53C416 { \ - NULL, \ - NULL, \ - &proc_scsi_sym53c416, \ - NULL, \ - "Symbios Logic 53c416", \ - sym53c416_detect, \ - NULL, \ - sym53c416_info, \ - sym53c416_command, \ - sym53c416_queuecommand, \ - sym53c416_abort, \ - sym53c416_reset, \ - NULL, \ - sym53c416_bios_param, \ - 1, \ - SYM53C416_SCSI_ID, \ - 32, /* ???? */ \ - 1, \ - 0, \ - 1, \ - ENABLE_CLUSTERING \ - } - -#endif - -#endif diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c index af47e706c70e..ac29df6a5c69 100644 --- a/drivers/scsi/tmscsim.c +++ b/drivers/scsi/tmscsim.c @@ -7,9 +7,9 @@ ***********************************************************************/ /* (C) Copyright: put under GNU GPL in 10/96 * *************************************************************************/ -/* $Id: tmscsim.c,v 2.16 1998/12/25 17:54:44 garloff Exp $ */ +/* $Id: tmscsim.c,v 2.5 1998/11/05 10:16:43 garloff Exp $ */ /* Enhancements and bugfixes by * - * Kurt Garloff * + * Kurt Garloff * ***********************************************************************/ /* HISTORY: * * * @@ -92,11 +92,7 @@ * bios_param() now respects part. table. * * 2.0b 98/10/24 KG Docu fixes. Timeout Msg in DMA Blast. * * Disallow illegal idx in INQUIRY/REMOVE * - * 2.0c 98/11/19 KG Cleaned up detect/init for SMP boxes, * - * Write Erase DMA (1.20t) caused problems * - * 2.0d 98/12/25 KG Christmas release ;-) Message handling * - * competely reworked. Handle target ini- * - * tiated SDTR correctly. * + * 2.0b1 98/11/05 KG Cleaned up detection/initialization * ***********************************************************************/ /* Uncomment SA_INTERRUPT, if the driver refuses to share its IRQ with other devices */ @@ -372,8 +368,9 @@ void dc390_DoingSRB_Done( PACB pACB ); static void dc390_ScsiRstDetect( PACB pACB ); static void dc390_ResetSCSIBus( PACB pACB ); static void __inline__ dc390_RequestSense( PACB pACB, PDCB pDCB, PSRB pSRB ); +static void __inline__ dc390_EnableMsgOut2( PACB pACB, PSRB pSRB ); +static void __inline__ dc390_EnableMsgOut( PACB pACB, PSRB pSRB ); static void __inline__ dc390_InvalidCmd( PACB pACB ); -static void __inline__ dc390_EnableMsgOut_Abort (PACB, PSRB); static void dc390_remove_dev (PACB pACB, PDCB pDCB); void do_DC390_Interrupt( int, void *, struct pt_regs *); @@ -681,7 +678,7 @@ static PDCB __inline__ dc390_findDCB ( PACB pACB, Scsi_Cmnd *cmd) pDCB = pDCB->pNextDCB; if (pDCB == pACB->pLinkDCB) { - printk (KERN_WARNING "DC390: DCB not found (DCB=%08x, DCBmap[%2x]=%2x)\n", + printk (KERN_ERR "DC390: DCB not found (DCB=%08x, DCBmap[%2x]=%2x)\n", (int)pDCB, cmd->target, pACB->DCBmap[cmd->target]); return 0; } @@ -765,7 +762,7 @@ static void dc390_RewaitSRB( PDCB pDCB, PSRB pSRB ) UCHAR bval; pDCB->GoingSRBCnt--; pDCB->pDCBACB->SelLost++; - DEBUG0(printk(KERN_INFO "DC390: RewaitSRB (%p, %p) pid = %li\n", pDCB, pSRB, pSRB->pcmd->pid);) + DEBUG0(printk("DC390: RewaitSRB (%p, %p) pid = %li\n", pDCB, pSRB, pSRB->pcmd->pid);) psrb1 = pDCB->pGoingSRB; if( pSRB == psrb1 ) { @@ -992,7 +989,7 @@ int DC390_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *)) DEBUG0(/* if(pACB->scan_devices) */ \ - printk(KERN_INFO "DC390: Queue Cmd=%02x,ID=%d,LUN=%d (pid=%li)\n",\ + printk(KERN_DEBUG "DC390: Queue Cmd=%02x,ID=%d,LUN=%d (pid=%li)\n",\ cmd->cmnd[0],cmd->target,cmd->lun,cmd->pid);) DC390_LOCK_ACB; @@ -1258,17 +1255,15 @@ void dc390_dumpinfo (PACB pACB, PDCB pDCB, PSRB pSRB) printk (" %02x %02x %02x %02x %02x %02x\n", DC390_read8(INT_Status), DC390_read8(Current_Fifo), DC390_read8(CtrlReg1), DC390_read8(CtrlReg2), DC390_read8(CtrlReg3), DC390_read8(CtrlReg4)); - DC390_write32 (DMA_ScsiBusCtrl, WRT_ERASE_DMA_STAT | EN_INT_ON_PCI_ABORT); printk ("DC390: Register dump: DMA engine:\n"); printk ("DC390: Cmd STrCnt SBusA WrkBC WrkAC Stat SBusCtrl\n"); printk ("DC390: %02x %08x %08x %08x %08x %02x %08x\n", DC390_read8(DMA_Cmd), DC390_read32(DMA_XferCnt), DC390_read32(DMA_XferAddr), DC390_read32(DMA_Wk_ByteCntr), DC390_read32(DMA_Wk_AddrCntr), DC390_read8(DMA_Status), DC390_read32(DMA_ScsiBusCtrl)); - DC390_write32 (DMA_ScsiBusCtrl, EN_INT_ON_PCI_ABORT); PDEVSET1; PCI_READ_CONFIG_WORD(PDEV, PCI_STATUS, &pstat); printk ("DC390: Register dump: PCI Status: %04x\n", pstat); - printk ("DC390: In case of driver trouble read linux/drivers/scsi/README.tmscsim\n"); + printk ("DC390: Please report driver trouble to K.Garloff@ping.de\n"); }; @@ -1724,7 +1719,7 @@ void __init dc390_initACB (PSH psh, ULONG io_port, UCHAR Irq, UCHAR index) pACB->IOPortBase = (USHORT) io_port; pACB->IRQLevel = Irq; - DEBUG0(printk (KERN_INFO "DC390: Adapter index %i, ID %i, IO 0x%08x, IRQ 0x%02x\n", \ + DEBUG0(printk (KERN_DEBUG "DC390: Adapter index %i, ID %i, IO 0x%08x, IRQ 0x%02x\n", \ index, psh->this_id, (int)io_port, Irq);) psh->max_id = 8; @@ -1748,8 +1743,6 @@ void __init dc390_initACB (PSH psh, ULONG io_port, UCHAR Irq, UCHAR index) pACB->TagMaxNum = 2 << dc390_eepromBuf[index][EE_TAG_CMD_NUM]; pACB->ACBFlag = 0; pACB->scan_devices = 1; - pACB->MsgLen = 0; - pACB->Ignore_IRQ = 0; pACB->Gmode2 = dc390_eepromBuf[index][EE_MODE2]; dc390_linkSRB( pACB ); pACB->pTmpSRB = &pACB->TmpSRB; @@ -1847,7 +1840,7 @@ int __init dc390_initAdapter (PSH psh, ULONG io_port, UCHAR Irq, UCHAR index) (dc390_eepromBuf[index][EE_MODE2] & ACTIVE_NEGATION) ? NEGATE_REQACKDATA : 0); /* Negation */ DC390_write8 (DMA_Cmd, DMA_IDLE_CMD); DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD); - DC390_write32 (DMA_ScsiBusCtrl, EN_INT_ON_PCI_ABORT); + DC390_write32 (DMA_ScsiBusCtrl, WRT_ERASE_DMA_STAT | EN_INT_ON_PCI_ABORT); dstate = DC390_read8 (DMA_Status); DC390_write8 (DMA_Status, dstate); /* clear */ @@ -1917,8 +1910,8 @@ static int __init DC390_init (PSHT psht, ULONG io_port, UCHAR Irq, PDEVDECL, UCH } #endif - DEBUG0(printk(KERN_INFO "DC390: pSH = %8x,", (UINT) psh);) - DEBUG0(printk(" Index %02i,", index);) + DEBUG0(printk("DC390: pSH = %8x,", (UINT) psh);) + DEBUG0(printk("DC390: Index %02i,", index);) dc390_initACB( psh, io_port, Irq, index ); pACB = (PACB) psh->hostdata; @@ -1927,7 +1920,7 @@ static int __init DC390_init (PSHT psht, ULONG io_port, UCHAR Irq, PDEVDECL, UCH if( !dc390_initAdapter( psh, io_port, Irq, index ) ) { - DEBUG0(printk("\nDC390: pACB = %8x, pDCBmap = %8x, pSRB_array = %8x\n",\ + DEBUG0(printk("DC390: pACB = %8x, pDCBmap = %8x, pSRB_array = %8x\n",\ (UINT) pACB, (UINT) pACB->DCBmap, (UINT) pACB->SRB_array);) DEBUG0(printk("DC390: ACB size= %4x, DCB size= %4x, SRB size= %4x\n",\ sizeof(DC390_ACB), sizeof(DC390_DCB), sizeof(DC390_SRB) );) @@ -2010,7 +2003,7 @@ int __init DC390_detect (Scsi_Host_Template *psht) { DC390_LOCK_IO; /* Remove this when going to new eh */ PCI_GET_IO_AND_IRQ; - DEBUG0(printk(KERN_INFO "DC390(%i): IO_PORT=%04x,IRQ=%x\n", dc390_adapterCnt, (UINT) io_port, irq);) + DEBUG0(printk(KERN_DEBUG "DC390(%i): IO_PORT=%04x,IRQ=%x\n", dc390_adapterCnt, (UINT) io_port, irq);) if( !DC390_init(psht, io_port, irq, PDEV, dc390_adapterCnt)) { @@ -2256,7 +2249,7 @@ int dc390_set_info (char *buffer, int length, PACB pACB) /* NegoPeriod */ if (*pos != '-') { - SCANF (pos, p0, dum, 72, 800); + SCANF (pos, p0, dum, 76, 800); pDCB->NegoPeriod = dum >> 2; if (pDCB->NegoPeriod != olddevmode) needs_inquiry++; if (!pos) goto ok; @@ -2579,7 +2572,7 @@ int DC390_release(struct Scsi_Host *host) } if (irq_count == 1) { - DEBUG0(printk(KERN_INFO "DC390: Free IRQ %i\n",host->irq);) + DEBUG0(printk(KERN_DEBUG "DC390: Free IRQ %i\n",host->irq);) free_irq(host->irq,NULL); } } diff --git a/drivers/scsi/tmscsim.h b/drivers/scsi/tmscsim.h index acc6526fdfec..6cee55837786 100644 --- a/drivers/scsi/tmscsim.h +++ b/drivers/scsi/tmscsim.h @@ -3,7 +3,7 @@ ;* TEKRAM DC-390(T) PCI SCSI Bus Master Host Adapter * ;* Device Driver * ;***********************************************************************/ -/* $Id: tmscsim.h,v 2.4 1998/12/25 17:33:27 garloff Exp $ */ +/* $Id: tmscsim.h,v 2.1 1998/10/14 10:31:48 garloff Exp $ */ #ifndef _TMSCSIM_H #define _TMSCSIM_H @@ -95,13 +95,15 @@ UCHAR MsgOutBuf[6]; /* 0x48: */ SGL Segmentx; /* make a one entry of S/G list table */ +PUCHAR pMsgPtr; + UCHAR ScsiCmdLen; UCHAR ScsiPhase; UCHAR AdaptStatus; UCHAR TargetStatus; -/* 0x58: */ +/* 0x5c: */ UCHAR MsgCnt; UCHAR EndMessage; UCHAR RetryCnt; @@ -113,7 +115,7 @@ UCHAR SGIndex; UCHAR SRBStatus; //UCHAR IORBFlag; /*;81h-Reset, 2-retry */ -/* 0x60: */ +/* 0x64: */ }; @@ -216,16 +218,14 @@ spinlock_t lock; UCHAR sel_timeout; UCHAR glitch_cfg; -UCHAR MsgLen; -UCHAR Ignore_IRQ; /* Not used */ +UCHAR reserved[2]; /* alignment */ PDEVDECL1; /* Pointer to PCI cfg. space */ -/* 0x40/0x3c: */ +/* 0x44/0x40: */ ULONG Cmds; ULONG CmdInQ; ULONG CmdOutOfSRB; ULONG SelLost; - /* 0x50/0x4c: */ DC390_SRB TmpSRB; diff --git a/drivers/scsi/tripace.c b/drivers/scsi/tripace.c deleted file mode 100644 index 09d00feec2b9..000000000000 --- a/drivers/scsi/tripace.c +++ /dev/null @@ -1,1562 +0,0 @@ -/* tc2550.c -- Tripace TC-2550x based PCI SCSI Adapter SCSI driver - * Created:D.Ravi jun 8 1998 at chennai lab of Tripace - * Copyright 1998 Tripace Europe BV - * - * Driver version 1.00.000 (904) - - * This program is free software; you can redistribute 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. - - ************************************************************************** - - DESCRIPTION: - - - - - REFERENCES USED: - - 1.0 Design Kit for the Tripace TC-2550x based PCI SCSI Adapter - - 2.0 Tripace IOLAYER document. - - 3.0 LINUX driver sources in /usr/linux/drivers/scsi directory. - - - ALPHA TESTERS: - - 1.0 so far no external testers,only developer testing has been done. - - 2.0 Testing with IBMHDD,Quantum HDD,zip drive and sony CDROM has been - done. - - - NOTES ON USER DEFINABLE OPTIONS: - - 1.0 The following are the command line options that are possible for the - TRIPACE TC-2550 PCI SCSI controller without BIOS. - - tripace=fast clock,discon,sync,tag - - - The values for these four options can be either 0 or 1. - If fast clock is set to 1 ,then the chip uses a 60mhz clock.If ultra - scsi devices are used this should be set and the controller should have a - 60mhz crystal. - - if disconnect is 1 ,then disconnect/reconnect is allowed for all scsi - devices connected to the controller.if it is 0 ,it is off. - - sync = 1 means that synchronous negotiation will be done with scsi - devices.currently,though the flag is set ,the function is not implemented. - - Tag = 1 means that tagged queue commands can be sent to the scsi devices. - This is not implemnted as yet in the driver. - - The default values are 0,1,1,1 - - **************************************************************************/ - -#ifdef MODULE -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include "scsi.h" -#include "hosts.h" -#include "tripace.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "tripace_mcode.h" - -#define VERSION "$Revision: 1.00 $" - -/* #define DEBUG */ - - -#define MAXTARGET 8 -#define MAXSRBS 16 - -#define RISC_ENTRY1 0 - -#define DEV_PARAM_REG_BASE CFG_BASE+0x20 - -#define SCSI_DMA_POINTER CFG_BASE+0x40 -#define SCSI_DMA_COUNTER CFG_BASE+0x44 -#define HOST_DMA_POINTER CFG_BASE+0x48 -#define HOST_DMA_COUNTER CFG_BASE+0x4c -#define MBX_IN_BASE CFG_BASE+0x50 -#define MBX_OUT_BASE CFG_BASE+0x54 -#define DEV_HDR_BASE CFG_BASE+0x58 -#define TASK_Q_BASE CFG_BASE+0x5c -#define CURRENT_DEV_PTR CFG_BASE+0x60 -#define CURRENT_TASK_PTR CFG_BASE+0x64 -#define SG_LIST_PTR CFG_BASE+0x68 -#define ACC CFG_BASE+0x6c -#define SCRATCHB CFG_BASE+0x70 -#define CURRENT_INST CFG_BASE+0x74 -#define FLAG CFG_BASE+0x78 -#define SCRATCHC CFG_BASE+0x7a -#define MBX_IN_INDEX CFG_BASE+0x7b -#define PC CFG_BASE+0x7c -#define MBX_OUT_INDEX CFG_BASE+0x7f -#define PROGRAM_DATA_REG CFG_BASE+0x80 -#define CONTROL_REG CFG_BASE+0x84 -#define STATUS_INT_REG CFG_BASE+0x86 -#define SCSI_DATA CFG_BASE+0x88 -#define SCSI_CONTROL CFG_BASE+0x8A -#define SCSI_ID_REG CFG_BASE+0x8b - -#define INFO_BASE 0x780 -#define SIG_BASE 0x7D4 - -#define Q_FILE_SIZE 8192 -#define DEVHDR_SIZE 512 -#define MBOX_SIZE 48 -#define BIOS_SIGNATURE 0x55AAC731 - -#define PCI_1 1 -#define PCI_2 2 -#define MAX 28 - -#define PCI_BUS 1 -#define PCI_INDEX_PORT 0xCF8 -#define PCI_INDEX 0xF0 -#define PCI_CONFIG 0xC000 /* this needs to include slot number */ - -#define FAIL -1 -/* #define GOOD 0 */ -#define ERR 1 -#define DONE 2 -#define INT_HALT 0xfe000000 /* interrupt code */ - -#define SRB_DONE 0 -#define SRB_ACTIVE 2 -#define SRB_READY 1 -#define SRB_CLEAN 4 -#define SRB_ASSIGNED 8 -#define SRB_STOP 2 - -#define STOP_RISC 2 -#define FIRST_CMD 1 -#define SPECIAL_CMD 1 -#define MAX_OFFSET 30 -/* #define MAX_PERIOD 12 */ -#define MAX_PERIOD 12 -#define W_MAX_OFFSET 14 - -/* msg */ -#define CMD_ABORT 0x6 -#define DEVICE_RESET 0xC - - -#define CHECK_SYNC 0xA -#define CHECK_WIDE 0xD -#define SYNC_NORESPONSE 0x8 -#define SYNC_REJECTED 0x9 -#define SEL_TIME_OUT 0x11 -#define ERR_OVERRUN 0x12 -#define ERR_BUSFREE 0x13 -#define ERR_PHASE 0x14 -#define CHECK_COND 0x04 -#define ERR_PARITY 0x05 -#define ERR_MESSAGE 0x07 -#define WIDE_NORESPONSE 0x0b -#define WIDE_REJECTED 0x0c - - -#define DO_WIDE_NEGO 0x02 -#define DO_SYNC_NEGO 0x04 -#define FIRST_COMMAND 0x01 - -#define ENABLE_WIDE_BUS 0x100 -#define ENABLE_TAG_MSG 0x200 - -/*---------------------------------------------------------* -** parameter in register definitions * -** * -**---------------------------------------------------------*/ -/* - status register (read only) - */ -#define INTR_PENDING 0x01 -#define INTR_DIS 0x02 -#define SCAM_INTR_DIS 0x04 -#define POWER_SAVE_ON 0x08 -#define SCSI_RESET_OUT 0x10 -#define SCAM_INTR 0x20 -#define RISC_HALT 0x40 -#define SELECTION_TIMEOUT 0x80 -#define SCSI_PARITY_ERR 0x100 -#define SCSI_RESET_LAT 0x200 -#define STS_SCSI_RESET 0x400 -#define EEPROM_IN 0x800 -#define SCAM_ARB_WIN 0x1000 -#define EN_DMA 0x2000 -#define EN_ARB_SEL 0x4000 -/* - ** interrupt control register (write only) - */ -#define RESET_INTR_LATCH 0x01 -#define DIS_INTR 0x02 -#define DIS_SCAM_INTR 0x04 -#define POWER_SAVE 0x08 -#define RESET_SCSI_BUS 0x10 -/*ravi 10/3/98 changed for term power disable/enable in command line */ -/*#define EN_TERM_PWR 0x20 */ -#define TERM_PWR_EN 0x20 -/* - ** control register ( read/write ) - */ -#define RISC_CHIP_RESET 0x01 -#define RISC_SINGLE_SETP 0x02 -#define HALT_RISC 0x04 -#define EN_SCSI_SCAM 0x08 -#define DIS_SCSI_PARITY 0x10 -#define EN_TARGET_MODE 0x20 -#define FAST_CLOCK 0x40 -#define EN_MEMORY_WRITE 0x80 -#define DIS_PCI_BURST 0x100 -#define DIS_PCI_CACHE_LINE 0x200 -#define DIS_MUL_CACHE_LINE 0x400 -#define EEPROM_CLOCK 0x800 -#define EEPROM_DATA_OUT 0x1000 -#define EEPROM_CHIP_SEL 0x2000 -#define FAST_SELECTION 0x4000 -#define EN_SCAM_ARB 0x8000 - -#define TASK_DONE 0x80 - - -/*************************************************************************** -** filename: newtypes.h -** usage : type definition -****************************************************************************/ - - -/*************************************************************************** -** filename: newtypes.h -** usage : type definition -****************************************************************************/ - -#define MAX_Adapter 4 /* maximu adapters allow */ - -/* - ** command related structure (7 bytes) - */ -typedef struct _task_cmd -{ - u8 CmdInProcess; - u8 * REQ_Header; - void (*complete) (void); -} -TaskCmd, *PTaskCmd; - -/* - ** total 128 bytes - */ -typedef struct _HIM -{ - u8 status; /* device status, 0xFF not installed */ - u8 Target_ID; /* target ID */ - u8 type; /* target type mapped to device name */ - u16 attrib; /* lo 4bit: 1-Wide, 2-Sync, 4-Tag, */ - /* 8-removable, */ - /* hi 4bit: 10h do wide, 20h do sync, */ - /* 40h do tag, 0x80h - disc */ - /* bit 15: under BIOS, bit 8: > 1GB */ - u8 op_param; /* bit 7-5:period, bit4-0:offset */ - u8 drv_num; /* current ID --> 8x for BIOS used only */ - u8 sect_per_track; /* sector per track */ - u8 head_per_cyl; /* sector per track */ - u8 byte_per_sect; /* byte per sector (BIOS is 512) */ - u8 link_count; /* SRB link count: */ - u8 * ASPICMDLink; /* SRB link starting pointer */ - TaskCmd task[16]; /* array structure for each task */ - -} -DEVStruct; - -/* - ** total (4K+ 36) bytes for each adapter - */ -typedef struct _Adapter -{ - u16 IoPort; /* I/O Port address, 0 notsupport */ - u8 AdapterID; /* Adapter scsi ID, default = 7 */ - u8 first_disk_num; /* first disk number under BIOS (82->2) */ - u8 last_disk_num; /* last disk number under BIOS */ - u8 time_factor; /* used for device scam */ - - u8 IntrNum; /* -1 NotSupport, otherwise IRQ */ - u16 hw_attr; /* see eeprom def */ - u16 sw_attr; /* see eeprom def */ - DEVStruct dev[16]; /* target device structure */ - u16 mbx_out_ptr; /* mail box out pointer */ - u8 HAParam[16]; /* host adapter parameters */ - u8 bios_install; /* adapter has BIOS installed */ - u16 scam_type; /* scam use */ - u8 scam_assigned; /* scam use */ - u8 * Signature; /* BIOS signature & new manager address */ - u32 mbx_in_base; /* mbx in base logical address */ - u32 mbx_out_base; /* mbx out base logical address */ - u32 devhdr_base; /* devhdr base logical address */ - u32 taskq_base; /* taskq base logical address */ - u32 ptaskq_base; /* taskq base physical address */ - u32 pdev_base; /* taskq base physical address */ - u32 pmbi_base; /* taskq base physical address */ - u32 pmbo_base; /* taskq base physical address */ -} -Adapter, *PAdapter; - -/* - ** adapter information structure reserved for BIOS usage - */ - -typedef struct _dev_parm -{ - u8 header; /* header */ - u8 sect_per_track; /* sector per tarck */ -} -target_parm, *ptarget_parm; -/* - ** This structure is for BIOS used and read by driver - */ -typedef struct _Ada_data -{ - u8 drv_start; /* first drive */ - u8 drv_end; /* last drive */ - u16 timfact; /* timing factor */ - u32 old_int13; /* old int13 addr */ - u8 drive_id[8]; /* index= (8x-drv_start) */ - u8 drive_num[16]; /* device number */ - target_parm dev[16]; /* device parameters */ - u8 allow_discon[16]; /* disconnect record */ - u16 scam_type; /* scam use */ - u8 scam_assigned; /* scam use */ - u8 adapter_id; /* scam use */ - u32 signature; /* BIOS signature */ -} -HA_data, *PHA_data; - - -typedef struct _ScatGath -{ - u32 sg_address; /* must be physical address */ - u32 sg_length; /* sg length */ -} -ScatGath, *PScatGath; - -/* length must be 32 bytes */ -typedef struct _risc_srb -{ - u8 Tag_info; /* Tag information */ - u8 SRB_flag; /* SRB flag */ - u8 DEV_Status; /* SRB status */ - u8 ScsiStatus; /* scsi command status */ - u32 CDB; /* SCSI Command Block */ - u32 CDBLength; /* SCSI Command Length */ - u32 SenseDataPtr; /* auto sense pointer */ - u32 Sense_Cmd_Ptr; /* auto sense pointer */ - u32 SG_ListPtr; /* SG list */ - u8 SGNum; /* S/G number */ - u8 Identify; /* Identify message */ - u8 Sense_LUN; /* lun */ - u8 Sense_len; /* sense len */ - u32 Cmd_sg_addr; /* cmr sg ptr point to cmd */ -} -RISC_SRB, *PRISC_SRB; - - -typedef struct _SRB -{ /* for SCSI */ - RISC_SRB *risc_srb; /* structure of SRB in RISC */ - PAdapter AdapterPtr; /* a pointer to adapter structure */ - u8 LUN; /* lun number */ - u8 Tag_type; /* tag type */ - u8 Request_type; /* request type */ -} -SRB, *PSRB; - -typedef struct _sync_tbl -{ - int period; /* parameter setting */ - int f_factor; /* fast clock factor */ - int s_factor; /* slow clock factor */ -} -sync_tbl; - -/* - ** total 12 bytes of sg header - */ -typedef struct _dma_hrd -{ - u32 size; /* region size */ - u32 offset; /* offste */ - u16 segment; /* segment */ - u16 revsed; /* reserved */ - u16 num_avail; /* number available */ - u16 num_used; /* number used */ -} -DMA_HDR; - -/* - ** total 60 bytes (for each task in windows) - */ -typedef struct _dma_desc -{ - DMA_HDR dma_hdr; - ScatGath sg_list[6]; -} -dma_desc, *Pdma_desc; - -/* Flags */ -#define SRB_TOHOST 8 -#define SRB_TOTARGET 0x10 -#define SRB_NEEDSDT 0x20 -#define SRB_SENSE 0x40 /* only for OSD */ -#define SIZE_OF_SG 0x3C /* size of sg table (60 bytes) */ - -/* 2. Target Error == SCSI Status */ - -/* ============ function definiton ============ - ** 1. INPUT: PSRB - ** Start a scsi command. - * */ -static void StartScsiCmd(PRISC_SRB); - -#define CMD_INPROGRESS 0x01 -#define CMD_DISCONCTED 0x02 -#define CMD_DATAXFERED 0x04 - -#define TAR_TRUESG 0x01 -#define NEEDSDTN 0x10 - -#define MSG_ABORT 0x06 -#define MSG_RESET 0x0C -#define MSG_ALLOWDISC 0x40 -#define MSG_IDENTIFY 0x80 -#define MSG_EXTENDED 0x01 -#define MSG_NOMSG 0x08 -#define MSG_CMDCOMP 0x00 -#define MSG_DISC 0x04 -#define MSG_IGNWR 0x23 -#define MSG_RESTPTR 0x03 -#define MSG_SAVEPTR 0x02 -#define MSG_REJECTED 0x07 -#define MSG_INITRECVY 0x0f -#define MSG_LNKCMD 0x0a -#define MSG_LNKCMDTAG 0x0b -#define MSG_SIMPLEQUE 0x20 -#define MSG_MDFDATPTR 0x00 -#define MSG_SDTREQ 0x01 -#define MSG_WDTREQ 0x03 - -#define SECOND 18 //ticks per second -#define DEV_EMPTY 0xFF - -typedef struct _DEVHDR -{ - u32 Updatedmap; /* updated bitmap */ - u32 Startedmap; /* start bitmap */ - u32 Currentmap; /* current bitmap */ - u8 Task_Index; /* current task index */ - u8 Request_type; /* request type */ - u8 SpCmddone; /* special commad done */ - u8 Srb_loc; /* location */ - u8 TagCmdCnt; /* Pending task count */ - u8 ScsiID; /* scsi ID */ - u8 DeviceNum; /* device number */ - u8 WideMsg; /* wide bus message */ - u8 SyncPeriod; /* sync period */ - u8 SyncOffset; /* sync offset */ - u8 RtnWideMsg; /* return wide bus msg */ - u8 RtnSyncPeriod; /* Rtn sync period */ - u8 RtnSyncOffset; /* rtn sync offset */ - u8 ChkSenseTask; /* check sense task */ - u8 SenseCmd[6]; /* sense command */ -} -DevHdr, *PDevHdr; - -typedef struct _E2Prom -{ - u16 hw_parm; - u16 sw_parm; - u16 dev_parm[16]; -} -E2prom, *PE2prom; - -/* parameter setting for parameter */ -#define HW_ADAPTER_ID 0x0f -#define HW_PARITY_DISABLE 0x10 -#define HW_TERMPWR_ENABLE 0x20 -#define HW_FAST_CLOCK 0x40 -#define HW_DIAG_ENABLE 0x80 -#define HW_BURST_DISABLE 0x100 -#define HW_CACHE_LINE_DISABLE 0x200 -#define HW_MULTI_CACHE_DISABLE 0x400 -#define HW_SCAM_ENABLE 0x800 -#define HW_CACHE_LINE_SIZE_4 0x1000 -#define HW_CACHE_LINE_SIZE_8 0x2000 -#define HW_CACHE_LINE_SIZE_16 0x3000 -#define HW_FAST_SELECTION 0x4000 -#define HW_BIOS_DISABLE 0x8000 - - -/* software setting */ -#define SW_REMOVABLE_SUPPORT 0x1 -#define SW_OVER_1GB 0x2 -#define SW_8_DRIVE_SUPPORT 0x4 -#define SW_MAX_ID 0x8 -#define SW_DEVICE_CHANGED 0x10 - -/* parameter setting */ -#define PM_UNDER_BIOS 0x8000 -#define PM_BIOSSCAN_DISABLE 0x2000 -#define PM_NEED_STARTCMD 0x1000 -#define PM_DISCON_ENABLE 0x800 -#define PM_SYNC_ENABLE 0x400 -#define PM_TAG_ENABLE 0x200 -#define PM_WIDEBUS_ENABLE 0x100 -#define PM_TRANSFER_RATE 0xE0 -#define PM_TRANSFER_OFFSET 0x1F - -/* ScsiFunc */ -#define SUPPORT_MORETHAN16M 0x40 -#define SUPPORT_RESELECT 0x20 -#define SUPPORT_SYNC 0x10 -#define SUPPORT_LINKED 0x08 -#define SUPPORT_CMDQUEUE 0x02 -#define SUPPORT_SFTRE 0x01 -#define SUPPORT_WIDEHOST 0x04 -#define SUPPORT_PARCHK 0x80 - - -static unsigned int port_base = 0; -static unsigned int CFG_BASE = 0; -static unsigned int interrupt_level = 0; - -/* period table - - static sync_tbl period_tbl[8]= { - { 0, 12, 12,}, - { 1, 16, 18,}, - { 2, 20, 25,}, - { 3, 25, 31,}, - { 4, 29, 37,}, - { 5, 33, 43,}, - { 6, 50, 50,}, - { 7, 58, 75,}, - }; - */ - -/* pointer to scsi host struc for each HA */ -/* needs change for multiple HA support */ - -static struct Scsi_Host *tripace_host; - -/* Tc2550 mailbox data structures */ -static unsigned char tcmbdata[Q_FILE_SIZE + DEVHDR_SIZE + MBOX_SIZE + 64]; -/* static alloc of sg table for all tasks */ -/* dynamic memory is giving problems */ -static unsigned char table[8 * MAXSGENT * MAXSRBS * MAXTARGET + 4]; - - -/* global variables */ -/* logical addresses of mailbox in/out,dev header base,task que base */ - -static unsigned char *startsgptr; -static unsigned long pstartsgptr; - - -static u32 mbx_in_base, mbx_out_base, devhdr_base, taskq_base; -static u8 TargetID; - - -/* hostadapter structure-as of now we have a single adapter */ -Adapter HostAdapter[1]; -unsigned char ReqType, targetID, HANumber, Index, HostID; - -/* variable for term power in case of /T option */ -static unsigned short int EN_TERM_PWR = TERM_PWR_EN; -static unsigned short fast_clk = 0; -static unsigned short par_off = 0; -static unsigned short discon = 1; -static unsigned short syncflag = 1; -static unsigned short tagflag = 0; - - -static int makecode(unsigned, unsigned); -static void Init_struc(int); -static int download_RISC_code(void); -static void init_chip_reg(void); - -static PRISC_SRB search(PAdapter); -u32 insert_bit(u32, short int); -static void Get_Base(Adapter *); - -void tc2550_intr(int, void *, struct pt_regs *); - -static void internal_done(Scsi_Cmnd *); - -int tc2550_command(Scsi_Cmnd *); - -static int tc2550_pci_bios_detect(int *irq, int *iobase) -{ - int error; - unsigned char pci_bus, pci_dev_fn; /* PCI bus & device function */ - unsigned char pci_irq; /* PCI interrupt line */ - unsigned int pci_base; /* PCI I/O base address */ - unsigned short pci_vendor, pci_device; /* PCI vendor & device IDs */ - - - /* We will have to change this if more than 1 PCI bus is present and the - tripace scsi host is not on the first bus (i.e., a PCI to PCI bridge, - which is not supported by bios32 right now anyway). */ - - pci_bus = 0; - - for (pci_dev_fn = 0x0; pci_dev_fn < 0xff; pci_dev_fn++) - { - pcibios_read_config_word(pci_bus, - pci_dev_fn, - PCI_VENDOR_ID, - &pci_vendor); - - if (pci_vendor == 0x1190) - { - pcibios_read_config_word(pci_bus, - pci_dev_fn, - PCI_DEVICE_ID, - &pci_device); - - if (pci_device == 0xc731) - { - /* Break out once we have the correct device. If othertrip - PCI devices are added to this driver we will need to add - an or of the other PCI_DEVICE_ID here. */ - printk(KERN_INFO "Tripace TC-2550x based PCI SCSI Adapter detected\n"); - break; - } else - { - /* If we can't finl an tripace scsi card we give up. */ - return 0; - } - } - } - -/* vendor id not found */ - - if (pci_device != 0xc731) - { - printk(KERN_INFO "Tripace TC-2550x - No Host Adapter Detected \n"); - return (0); - } - /* We now have the appropriate device function for the tripace board so we - just read the PCI config info from the registers. */ - - if ((error = pcibios_read_config_dword(pci_bus, - pci_dev_fn, - PCI_BASE_ADDRESS_0, - &pci_base)) - || (error = pcibios_read_config_byte(pci_bus, - pci_dev_fn, - PCI_INTERRUPT_LINE, - &pci_irq))) - { - printk(KERN_ERR "Tripace TC-2550x not initializing" - " due to error reading configuration space\n"); - return 0; - } else - { - printk(KERN_INFO "TC-2550x PCI: IRQ = %u, I/O base = %X\n", - pci_irq, pci_base); - - /* Now we have the I/O base address and interrupt from the PCI - configuration registers. - */ - - *irq = pci_irq; - *iobase = (pci_base & 0xfff8); - CFG_BASE = *iobase; - - printk(KERN_INFO "TC-2550x Driver version 1.00.000 (904)\n"); - printk(KERN_INFO "TC-2550x: IRQ = %d, I/O base = 0x%X\n", *irq, *iobase); - return 1; - } - return 0; -} - -static void init_chip_reg(void) -{ - int i, val, base; - unsigned long tick; - - outw(HALT_RISC, CONTROL_REG); - base = CFG_BASE + 0x20; - for (i = 0; i < 16; i++) - outw(0, base + i * 2); - outw(EN_TERM_PWR, STATUS_INT_REG); - outw(RESET_SCSI_BUS, STATUS_INT_REG); - - udelay(50); /*wait for 50 micro secs */ - - outw(EN_TERM_PWR, STATUS_INT_REG); - val = (HALT_RISC | RISC_CHIP_RESET); - outw(val, CONTROL_REG); - outw(HALT_RISC, CONTROL_REG); - val = inw(STATUS_INT_REG); - tick = 0; - while ((val & 0x40) == 0 && tick < 0x3fff) - { - val = inw(STATUS_INT_REG); - tick += 1; - }; - if (tick == 0x3fff) - printk(KERN_DEBUG "val= %x \n\r", val); - outw(EN_TERM_PWR, STATUS_INT_REG); - outw(0, SCSI_CONTROL); - -/* delay for 50 micro secs */ - udelay(50); -} - -static int download_RISC_code(void) -{ - unsigned short i, j, fast = 0; - unsigned short hi, low, base; - long tmp; - unsigned long start_time; - - i = inw(CONTROL_REG); - if (i & 0x40) - fast = 1; - outw(HALT_RISC, CONTROL_REG); - -/* Ravi modified for sanity check dec 17 1998 */ - start_time = jiffies; - - do - { - if ((jiffies - start_time) > 5 * HZ) - { - printk(KERN_ERR "tc2550: Download failure.\n"); - return 1; - } - i = inw(STATUS_INT_REG); - } - while ((i & 0x40) == 0); - - outw(HALT_RISC + EN_MEMORY_WRITE, CONTROL_REG); - outw(EN_TERM_PWR + DIS_INTR, STATUS_INT_REG); - - /* download load RISC code - */ - outw(0, PC); - for (i = 0; i < ucode_size; i++) - outl(ucode_instruction[i], CURRENT_INST); - /* - // checksum checking (word) - */ - base = 0; - for (i = 0; i < ucode_size; i++) - { - outw(i * 4, PC); - tmp = inl(PROGRAM_DATA_REG); - hi = tmp >> 16; - low = (tmp & 0xffff); - base = base + (hi + low); - } - outw(HALT_RISC + RISC_CHIP_RESET, CONTROL_REG); - outw(HALT_RISC, CONTROL_REG); - if (fast_clk) - outw((HALT_RISC | FAST_CLOCK), CONTROL_REG); - if (par_off) - { - i = inw(CONTROL_REG); - outw((i | DIS_SCSI_PARITY), CONTROL_REG); - } - outw(EN_TERM_PWR, STATUS_INT_REG); - /*ravi - */ - if ((unsigned short) (ucode_checksum + base) != 0) - { - printk(KERN_ERR "tc2550: Checksum Error During Code Download\n"); - return (1); - }; - /* - load vector table - */ - j = 0; - base = CFG_BASE; - for (i = 0, j = 0; i < 15; i++, j = j + 2) - outw(ucode_vector[i], (base + j)); - outw(0, SCSI_CONTROL); - return (0); -} - -int tc2550_detect(Scsi_Host_Template * tpnt) -{ - int flag = 0; - int retcode; - struct Scsi_Host *shpnt; - unsigned long flags; - unsigned int mod4; - - - flag = tc2550_pci_bios_detect(&interrupt_level, &port_base); - if (!flag) - return (0); - - init_chip_reg(); /* chip Tc-2550 initialize */ - flag = download_RISC_code(); - if (flag == 0) - { - printk(KERN_INFO "tc2550: Successful F/W download on TC-2550x\n"); - } -/* now do a scsi register and get scsi host ptr */ - - shpnt = scsi_register(tpnt, 0); - - save_flags(flags); - cli(); - retcode = request_irq(interrupt_level, - tc2550_intr, SA_INTERRUPT, "tripace", NULL); - if (retcode) - { - printk(KERN_ERR "tc2550: Unable to allocate IRQ for Tripace TC-2550x based SCSI Host Adapter.\n"); - goto unregister; - } - /* For multiple HA we need to change all this */ - - - tripace_host = shpnt; - shpnt->io_port = CFG_BASE; - shpnt->n_io_port = 0xfc; /* Number of bytes of I/O space used */ - shpnt->dma_channel = 0; - shpnt->irq = interrupt_level; - - restore_flags(flags); - - - /* log i/o ports with the kernel */ - request_region(port_base, 0xfc, "tripace"); - -/* when we support multiple HA ,we need to modify */ - Init_struc(0); /* init mailboxes for one adapter */ -/* sg table init */ - - /* get physical address */ - startsgptr = (unsigned char *) table; - pstartsgptr = virt_to_phys((unsigned char *) table); - mod4 = pstartsgptr % 4; - if (mod4) - { - pstartsgptr += (4 - mod4); - startsgptr += (4 - mod4); - } - return (0); - - -unregister: - scsi_unregister(shpnt); - return (0); -} - -/**************************************************************************** -** Init chip registers and allocate required memory space -****************************************************************************/ - -static void Init_struc(int id) -{ - u32 pmbx_in_base, pmbx_out_base, pdevhdr_base, ptaskq_base; - unsigned long paddr; - char *laddr; - unsigned short modulo; - -/* setup ioport address and irq */ - - HostAdapter[id].IoPort = (u16) CFG_BASE; - HostAdapter[id].IntrNum = (u8) interrupt_level; - - laddr = tcmbdata; - paddr = virt_to_phys(tcmbdata); -/* adjust phys address to 32 byte boundary */ - modulo = paddr % 32; - if (modulo) - { - paddr = paddr + 32 - modulo; - laddr = laddr + 32 - modulo; - } - /* logical address */ - mbx_in_base = (u32) laddr; - pmbx_in_base = paddr; - HostAdapter[id].mbx_in_base = mbx_in_base; - - laddr += 32; - paddr += 32; - mbx_out_base = (u32) laddr; - pmbx_out_base = paddr; - HostAdapter[id].mbx_out_base = mbx_out_base; - memset((char *) mbx_in_base, 0, 48); - - laddr += 32; - paddr += 32; - devhdr_base = (u32) laddr; - pdevhdr_base = paddr; - HostAdapter[id].devhdr_base = devhdr_base; - memset((char *) devhdr_base, 0, 512); - - - laddr += 512; - paddr += 512; - - taskq_base = (u32) laddr; - ptaskq_base = paddr; - HostAdapter[id].taskq_base = taskq_base; - memset((char *) taskq_base, 0, Q_FILE_SIZE); - - HostAdapter[id].ptaskq_base = (u32) ptaskq_base; - HostAdapter[id].pdev_base = (u32) pdevhdr_base; - HostAdapter[id].pmbi_base = (u32) pmbx_in_base; - HostAdapter[id].pmbo_base = (u32) pmbx_out_base; - - outl(pmbx_in_base, MBX_IN_BASE); - outl(pmbx_out_base, MBX_OUT_BASE); - outl(pdevhdr_base, DEV_HDR_BASE); - outl(ptaskq_base, TASK_Q_BASE); - outb(0, MBX_IN_INDEX); - outb(0, MBX_OUT_INDEX); - /* clear mailbox out pointer */ - HostAdapter[id].mbx_out_ptr = 0; -} - - -/*************************************************************************** -** adjust bitmap position -** Input : old bitmap, new bit location -** Output: return with new bitmap layout -****************************************************************************/ - -extern __inline__ u32 insert_bit(u32 bits, short int loc) -{ - u32 lo = 0; - - lo = 1; - lo <<= loc; - - - return ((lo | bits)); -} - - -/*************************************************************************** -** Get the base address and structures of current host adapter -** Input : adapter structure pointer -** Output : none -****************************************************************************/ - -static void Get_Base(Adapter * padapter) -{ - - CFG_BASE = padapter->IoPort; - interrupt_level = (u16) padapter->IntrNum; - mbx_in_base = padapter->mbx_in_base; - mbx_out_base = padapter->mbx_out_base; - devhdr_base = padapter->devhdr_base; - taskq_base = padapter->taskq_base; - -} - - - -/*************************************************************************** -** name : search() -** Desc : search an available SRB from taskQ -** Input : adapter structure pointer -** Output : 1. a risc structure space pointer or 0 for non available -** 2. index of task location -****************************************************************************/ -static PRISC_SRB search(PAdapter pa) -{ - PRISC_SRB rsrb; - short int i; - unsigned long flags; - - Get_Base(pa); - rsrb = (PRISC_SRB) (taskq_base + TargetID * 16 * sizeof(RISC_SRB)); - /* check attrib in case drive doesn't support SYNC xfer */ - - if ((pa->dev[TargetID].attrib & DO_SYNC_NEGO) == 0) - ReqType = 0; - save_flags(flags); - cli(); - - Index = 0; - for (i = 0; i < 16; i++, rsrb++) - if (rsrb->SRB_flag == SRB_DONE) - break; - if (i == 16) - { - restore_flags(flags); - return (0); - } - Index = i; - restore_flags(flags); - memset((char *) rsrb, 0, 32); - rsrb->SRB_flag = SRB_ASSIGNED; /* mark for use */ - if ((pa->dev[TargetID].attrib & 0x44) == 0x44) - rsrb->Tag_info = 0x20; - return (rsrb); -} - -/*************************************************************************** -** Name : StartSCSICmd() -** func : 1. all commands passed through here are regular -** 2. fill in device structure bitmap && start RISC -** Input : risc srb structure, Index, ReqType -** Output : none -****************************************************************************/ -static void StartScsiCmd(PRISC_SRB rsrb) -{ - DevHdr *dev; - u16 status; - PAdapter pa; - unsigned short val; - u8 t, find_id, find_last, ch = 0; - char *mptr; -/* Request sense CDB */ - char RequestSense[6] = - {0x03, 0x00, 0x00, 0x00, 0x0e, 0}; - - pa = (PAdapter) & HostAdapter[HANumber]; - pa->dev[TargetID].task[Index].CmdInProcess = 1; /* command in process */ - dev = (DevHdr *) (devhdr_base + TargetID * sizeof(DevHdr)); - dev->Srb_loc = Index; - dev->Request_type = ReqType; /* set request type */ - dev->Updatedmap = insert_bit(dev->Updatedmap, Index); - for (val = 0; val < 6; val++) - dev->SenseCmd[val] = RequestSense[val]; - rsrb->Sense_Cmd_Ptr = virt_to_phys(&dev->SenseCmd[0]); - - if (ReqType >= 2) - { - if (ReqType & 0x2) - dev->WideMsg = 0x1; - else - { -/* printf("firing sync nego"); - //ravi 10/3/98 -ultra support in parse - - if(fast_clk) - dev->SyncPeriod = period_tbl[(ultra[TargetID])].f_factor; - else - dev->SyncPeriod = period_tbl[(ultra[TargetID])].s_factor; - */ - - if (pa->dev[TargetID].attrib & 0x1) - dev->SyncOffset = W_MAX_OFFSET; - else - dev->SyncOffset = MAX_OFFSET; - } - } - mptr = (char *) mbx_in_base; - find_id = 0xff; - find_last = 0xff; - for (t = 0; t < 15; t++) - { - ch = *mptr++; - if ((ch & 0xf) == TargetID) - { - find_id = t; - break; - } - } - - mptr = (char *) mbx_in_base; - for (t = 0; t < 15; t++) - { - ch = *mptr++; - if (ch & 0x80) - { - find_last = t; - break; - } - } - val = inw(STATUS_INT_REG); - mptr = (char *) mbx_in_base; - if (find_id != 0xff && find_last != 0xff) - { - if (find_id < find_last) - *(char *) (mptr + find_id) |= 0x10; - else - { - *(char *) (mptr + find_last) &= 0x7f; - *(char *) (mptr + find_id) |= 0x90; - } - } else if (find_last != 0xff && find_id == 0xff) - { - *(char *) (mptr + find_last) &= 0x7f; - find_last = find_last + 1; - *(char *) (mptr + find_last) = (0x90 | TargetID); - } else if (find_last == 0xff) - *(char *) mptr = (0x90 | TargetID); - - - ReqType = 0; - /* - // restart the RISC if it is halted before - */ - - rsrb->SRB_flag = SRB_READY; - - - if (val & RISC_HALT) - { - outw(ucode_start, PC); /* set pc counter */ - status = inw(CONTROL_REG); /* clear halt status */ - outw((status & ~HALT_RISC), CONTROL_REG); - } -#ifdef DEBUG - printk(KERN_DEBUG " start scsi issued \n"); -#endif - -} - -static void internal_done(Scsi_Cmnd * SCpnt) -{ - SCpnt->SCp.Status++; -} - -int tc2550_command(Scsi_Cmnd * SCpnt) -{ - tc2550_queue(SCpnt, internal_done); - - SCpnt->SCp.Status = 0; - while (!SCpnt->SCp.Status) - barrier(); - return SCpnt->result; -} - -int tc2550_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) -{ - - PAdapter pa; - PRISC_SRB rsrb; - int val; - struct scatterlist *sgpnt; - - - ScatGath *riscsgptr; - - - int i; - unsigned int nentries; - - pa = (PAdapter) & HostAdapter[HANumber]; - Get_Base(pa); - val = 0xaa; - TargetID = SCpnt->target; - HostID = 7; - /* the following code is for corel compatibility */ - if (SCpnt->lun != 0 || - (TargetID == HostID)) - { - SCpnt->result = DID_BAD_TARGET << 16; - done(SCpnt); - return (0); - }; - /* Error if more than 16 tasks /target if no space is available */ - - if ((rsrb = search(pa)) == 0) - { - SCpnt->result = DID_ERROR << 16; - done(SCpnt); - return (0); - }; - -/*Ravi -modified for hostid 16/12/98 */ - outb((u8) ((TargetID << 4) | HostID), SCSI_ID_REG); - - - rsrb->CDBLength = SCpnt->cmd_len; -/* get the physical address of CDB */ - rsrb->CDB = virt_to_phys((unsigned char *) SCpnt->cmnd); - - - if (discon) - - rsrb->Identify = 0xC0; - else - rsrb->Identify = 0x80; - -/* scatter gather processing */ - - nentries = SCpnt->use_sg; - if (nentries == 0) - nentries = 1; - rsrb->SGNum = nentries; - -#ifdef DEBUG - printk(KERN_DEBUG "sgentries = %d\n", nentries); -#endif - -/*allocate mem for scatter gather table at 32bit boundary */ - SCpnt->host_scribble = startsgptr + 8 * MAXSGENT * MAXSRBS * TargetID; - - /*(unsigned char *)scsi_malloc(4096); */ - - sgpnt = (struct scatterlist *) SCpnt->request_buffer; - - riscsgptr = (PScatGath) (SCpnt->host_scribble); - if (riscsgptr == NULL) - panic("tripace: unable to allocate DMA memory\n"); - - - /* fill physical address of scatter-gather list */ - rsrb->SG_ListPtr = virt_to_phys(SCpnt->host_scribble); - rsrb->Cmd_sg_addr = virt_to_phys(rsrb + 4); - - if (SCpnt->use_sg) - { - for (i = 0; i < SCpnt->use_sg; i++) - { - if (sgpnt[i].length == 0 || SCpnt->use_sg > 255) - { - unsigned char *ptr; - printk(KERN_ERR "tc2550: Bad segment list supplied to Tripace.c (%d, %d)\n", SCpnt->use_sg, i); - for (i = 0; i < SCpnt->use_sg; i++) - { - printk(KERN_ERR "%d: %x %x %d\n", i, (unsigned int) sgpnt[i].address, (unsigned int) sgpnt[i].alt_address, - sgpnt[i].length); - }; - printk(KERN_ERR "RISCGPTR %x: ", (unsigned int) riscsgptr); - ptr = (unsigned char *) &riscsgptr[i]; - for (i = 0; i < 18; i++) - printk("%02x ", ptr[i]); - panic("Tripace tc-2550x driver!"); - }; - - riscsgptr[i].sg_address = (u32) sgpnt[i].address; - riscsgptr[i].sg_length = sgpnt[i].length; - }; - } else - { - riscsgptr[0].sg_address = (u32) SCpnt->request_buffer; - riscsgptr[0].sg_length = SCpnt->request_bufflen; - }; - - -/* fill sense data pointer and len */ - - rsrb->Sense_len = sizeof(SCpnt->sense_buffer); - rsrb->SenseDataPtr = virt_to_phys(SCpnt->sense_buffer); - -/* store scsi command pointer for use in intr routine */ - pa->dev[TargetID].task[Index].REQ_Header = (u8 *) SCpnt; - SCpnt->scsi_done = done; - - /* pa->dev[TargetID].task[Index].complete = CompleteIORequest; */ - ReqType = 0; - StartScsiCmd(rsrb); - return 0; -} - -int tc2550_reset(Scsi_Cmnd * SCpnt) -{ - return 0; - -} - -#include "sd.h" - -int tc2550_biosparam(Scsi_Disk * disk, int dev, int *info_array) -{ - return 0; - -} - -int tc2550_abort(Scsi_Cmnd * SCpnt) -{ - - return 0; -} - - -const char *tc2550_info(struct Scsi_Host *ignore) -{ - - return 0; -} - -void tc2550_intr(int irq, void *dev_id, struct pt_regs *regs) -{ - void (*my_done) (Scsi_Cmnd *) = NULL; - - int val, id, map = 0, tmap, mbx_out_ptr; - u8 loc = 0; - PRISC_SRB rsrb; - DevHdr *dev; - char *ptr0; - PAdapter padapter; -/* - int i ; - unsigned long flags ; - */ - unsigned int memsize; - Scsi_Cmnd *SCtmp; - unsigned devstat = 0; - unsigned scsistat = 0; - long start_time; - -#ifdef DEBUG - printk("interrupt registered \n"); -#endif - -/* - save_flags(flags); - cli(); - */ - - /* multiple HA? not supported now! */ - HANumber = 0; - padapter = (PAdapter) & HostAdapter[HANumber]; - Get_Base(padapter); - -/* disable interrupts */ - val = inw(STATUS_INT_REG); - - udelay(10); - - val |= 0x20; /* clear interrupt pending */ - outw(val, STATUS_INT_REG); - - udelay(10); - - val |= 0x22; /* disable interrupt */ - - outw(val, STATUS_INT_REG); - /* - // if RISC is in halt state then find out why ? - */ - tmap = inw(STATUS_INT_REG); -/* The following code needs to be added when we intro sync /wide nego */ -/* - if(tmap & RISC_HALT) { - tmap= risc_halt_check(); - if(tmap) return(0xff); - }; - */ - - - mbx_out_ptr = padapter->mbx_out_ptr; - - val = *(u16 *) (mbx_out_base + mbx_out_ptr); - - while (val & 0x80) - { - loc = (char) (val & 0x7f); - id = val & 0xff00; - id >>= 8; - TargetID = id; - dev = (DevHdr *) (devhdr_base + TargetID * sizeof(DevHdr)); - /*(u16 *)(mbx_out_base+ mbx_out_ptr)= (val& 0xff7f); */ - rsrb = (PRISC_SRB) (taskq_base + (id * 16 + loc) * sizeof(RISC_SRB)); - Index = loc; - devstat = rsrb->DEV_Status; - scsistat = rsrb->ScsiStatus; - -/* (*padapter->dev[TargetID].task[loc].complete)(rsrb); */ - - *(u16 *) (mbx_out_base + mbx_out_ptr) = (val & 0xff7f); - - padapter->dev[TargetID].task[loc].CmdInProcess = 0; - mbx_out_ptr += 2; - if (mbx_out_ptr == 32) - mbx_out_ptr = 0; - padapter->mbx_out_ptr = mbx_out_ptr; - /* - * Clear init bimap if no more tasks are waiting - */ - map = 1; - dev->Updatedmap = (dev->Updatedmap ^ (map << loc)); - if ((dev->Updatedmap & 0x0000ffff) == 0) - { - ptr0 = (char *) mbx_in_base; - for (map = 0; map < 16; map++) - if ((*ptr0 & 0xf) == (char) id) - { - *ptr0 = (*ptr0 & 0xef); - break; - } else - ptr0++; - } - val = *(u16 *) (mbx_out_base + mbx_out_ptr); - - rsrb->SRB_flag = SRB_DONE; /* mark done */ - } - - /* stop RISC if mailbox is empty */ - - ptr0 = (char *) mbx_in_base; - for (map = 0; map < 16; map++) - if (*ptr0 & 0x10) - break; - if (map == 16) - { - tmap = inw(CONTROL_REG); - outw((tmap | HALT_RISC), CONTROL_REG); - -/*Ravi modified to introduce sanity check&time out dec 16 1998 */ - - start_time = jiffies; - - do - { - if ((start_time - jiffies) > 5 * HZ) - { - printk(KERN_ERR "tc2550: TC-2550x Controller Failure\n"); - return; - } - tmap = inw(STATUS_INT_REG); - } - while((tmap & RISC_HALT) == 0); - } - SCtmp = (Scsi_Cmnd *) padapter->dev[TargetID].task[loc].REQ_Header; - - if (!SCtmp || !SCtmp->scsi_done) - { - printk(KERN_ERR "tc2550: Tripace_Intr_Handle: Unexpected Interrupt\n"); - return; - } - memsize = 255 * sizeof(struct _ScatGath) + 4; - my_done = SCtmp->scsi_done; - /*if (SCtmp->host_scribble) - scsi_free(SCtmp->host_scribble,4096); */ - - - padapter->dev[TargetID].task[loc].REQ_Header = NULL; - SCtmp->result = makecode(devstat, scsistat); -/*enable chip interrupt signal */ - val = inw(STATUS_INT_REG); - udelay(25); /* delay for 25 micros */ - - val &= 0xfd; /* enable interrupt-bit1=0 in status-int reg */ - outw(val, STATUS_INT_REG); - - my_done(SCtmp); /* inform mid layer that scsi command is over */ -/* - restore_flags(flags); - */ - -} - -/* called from init/main.c */ -void tripace_setup(char *str, int *ints) -{ - switch (ints[0]) - { - - case 0: - - printk(KERN_INFO "tc2550: No Arguments In Command Line:Assuming Defaults\n"); - break; - - case 1: - fast_clk = ints[1]; - break; - - case 2: - fast_clk = ints[1]; - discon = ints[2]; - break; - - case 3: - fast_clk = ints[1]; - discon = ints[2]; - syncflag = ints[3]; - break; - - case 4: - fast_clk = ints[1]; - discon = ints[2]; - syncflag = ints[3]; - tagflag = ints[4]; - } - -#ifdef DEBUG - printk("fast_clk = %d,discon = %d,syncflag =%d,tagflag=%d\n", - fast_clk, discon, syncflag, tagflag); - printk("fast_clk = %d,discon = %d,syncflag =%d,tagflag=%d\n", - fast_clk, discon, syncflag, tagflag); - printk("fast_clk = %d,discon = %d,syncflag =%d,tagflag=%d\n", - fast_clk, discon, syncflag, tagflag); - printk("fast_clk = %d,discon = %d,syncflag =%d,tagflag=%d\n", - fast_clk, discon, syncflag, tagflag); -#endif - -} - -static int makecode(unsigned hosterr, unsigned scsierr) -{ - switch (hosterr) - { - case 0x0: - hosterr = 0; - break; - - case SEL_TIME_OUT: /* Selection time out-The initiator selection or target - reselection was not complete within the SCSI Time out period */ - hosterr = DID_TIME_OUT; - break; - - case ERR_PARITY: /* parity error */ - - hosterr = DID_PARITY; - break; - - case ERR_OVERRUN: /* Data overrun/underrun-The target attempted to transfer more data - than was allocated by the Data Length field or the sum of the - Scatter / Gather Data Length fields. */ - - case ERR_BUSFREE: /* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */ - - - case ERR_PHASE: /* Target bus phase sequence failure-An invalid bus phase or bus - phase sequence was requested by the target. */ - - hosterr = DID_ERROR; /* Couldn't find any better */ - break; - - default: - hosterr = DID_ERROR; - printk(KERN_ERR "tc2550: Makecode: Unknown Hoststatus %x\n", hosterr); - break; - } - return scsierr | (hosterr << 16); -} diff --git a/drivers/scsi/tripace.h b/drivers/scsi/tripace.h deleted file mode 100644 index 702af41064be..000000000000 --- a/drivers/scsi/tripace.h +++ /dev/null @@ -1,57 +0,0 @@ -/* tc2550.h -- Header for tripace TC-2550x PCI-SCSI HA - * Created: Tue June 9 by chennai team of Tripace Ravi - * Author: Ravi ravi01@md2.vsnl.net.in - * Copyright 1998 Tripace B.V - * - - * This program is free software; you can redistribute 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 MAXSGENT 16 - -#ifndef _TRIPACE_H -#define _TRIPACE_H - -int tc2550_detect( Scsi_Host_Template * ); -int tc2550_command( Scsi_Cmnd * ); -int tc2550_abort( Scsi_Cmnd * ); -const char *tc2550_info( struct Scsi_Host * ); -int tc2550_reset( Scsi_Cmnd * ); -int tc2550_queue( Scsi_Cmnd *, void (*done)(Scsi_Cmnd *) ); -int tc2550_biosparam(Disk *,int,int *) ; - -#define TC2550 { NULL, \ - NULL, \ - NULL, \ - "tripace", \ - PROC_SCSI_TRIPACE, \ - NULL, \ - tc2550_detect, \ - NULL, \ - tc2550_info, \ - tc2550_command, \ - tc2550_queue, \ - tc2550_abort, \ - tc2550_reset, \ - NULL, \ - tc2550_biosparam, \ - 1, \ - 7, \ - MAXSGENT, \ - 1, \ - 0, \ - 0, \ - DISABLE_CLUSTERING } -#endif diff --git a/drivers/scsi/tripace_mcode.h b/drivers/scsi/tripace_mcode.h deleted file mode 100644 index 17794a665b51..000000000000 --- a/drivers/scsi/tripace_mcode.h +++ /dev/null @@ -1,483 +0,0 @@ -u16 ucode_vector[] = { - 0x1e0, /* vector 0 */ - 0x0, /* vector 1 */ - 0x1d8, /* vector 2 */ - 0x500, /* vector 3 */ - 0x2f0, /* vector 4 */ - 0x2e4, /* vector 5 */ - 0x604, /* vector 6 */ - 0x258, /* vector 7 */ - 0x30c, /* vector 8 */ - 0x45c, /* vector 9 */ - 0x368, /* vector 10 */ - 0x4a4, /* vector 11 */ - 0x514, /* vector 12 */ - 0x520, /* vector 13 */ - 0x70c, /* vector 14 */ - 0x728 /* vector 15 */ - }; -unsigned short ucode_start = 0x0; /* starting point (9 bit only) */ - -unsigned short ucode_size = 0x1cb; /* total number of instructions */ -unsigned short ucode_checksum = 0x87d0; /* checksum */ -u32 ucode_instruction[] = { - 0x1c0e0078, /* line 1 --- addr 0 */ - 0x45800000, /* line 2 --- addr 4 */ - 0x08070004, /* line 3 --- addr 8 */ - 0x7d040000, /* line 4 --- addr c */ - 0x08040000, /* line 5 --- addr 10 */ - 0x9c000f00, /* line 6 --- addr 14 */ - 0x59500000, /* line 7 --- addr 18 */ - 0x100e0010, /* line 8 --- addr 1c */ - 0xcc000000, /* line 9 --- addr 20 */ - 0x1c0e0078, /* line 10 --- addr 24 */ - 0x6500000d, /* line 11 --- addr 28 */ - 0x0c070041, /* line 12 --- addr 2c */ - 0x08030016, /* line 13 --- addr 30 */ - 0x9c007700, /* line 14 --- addr 34 */ - 0x6100000d, /* line 15 --- addr 38 */ - 0x78000004, /* line 16 --- addr 3c */ - 0x7c000000, /* line 17 --- addr 40 */ - 0xdc000100, /* line 18 --- addr 44 */ - 0x60000008, /* line 19 --- addr 48 */ - 0x6500000f, /* line 20 --- addr 4c */ - 0x59700000, /* line 21 --- addr 50 */ - 0x3000002a, /* line 22 --- addr 54 */ - 0x9c000700, /* line 23 --- addr 58 */ - 0x3c00001a, /* line 24 --- addr 5c */ - 0xa000000e, /* line 25 --- addr 60 */ - 0x38000148, /* line 26 --- addr 64 */ - 0x18070021, /* line 27 --- addr 68 */ - 0x65000019, /* line 28 --- addr 6c */ - 0x9c000f00, /* line 29 --- addr 70 */ - 0x59700000, /* line 30 --- addr 74 */ - 0x1c0e0078, /* line 31 --- addr 78 */ - 0xc8000000, /* line 32 --- addr 7c */ - 0x30000145, /* line 33 --- addr 80 */ - 0x6500000c, /* line 34 --- addr 84 */ - 0x59700000, /* line 35 --- addr 88 */ - 0x38000030, /* line 36 --- addr 8c */ - 0x64000004, /* line 37 --- addr 90 */ - 0x94000000, /* line 38 --- addr 94 */ - 0xa0000000, /* line 39 --- addr 98 */ - 0x3c008043, /* line 40 --- addr 9c */ - 0x60000008, /* line 41 --- addr a0 */ - 0x78000004, /* line 42 --- addr a4 */ - 0x64000008, /* line 43 --- addr a8 */ - 0x3c008041, /* line 44 --- addr ac */ - 0x0800003d, /* line 45 --- addr b0 */ - 0xf8000000, /* line 46 --- addr b4 */ - 0x60000008, /* line 47 --- addr b8 */ - 0x6170000c, /* line 48 --- addr bc */ - 0x6500000d, /* line 49 --- addr c0 */ - 0x0c070041, /* line 50 --- addr c4 */ - 0x9c000700, /* line 51 --- addr c8 */ - 0x38000148, /* line 52 --- addr cc */ - 0x59070000, /* line 53 --- addr d0 */ - 0x1c0e0078, /* line 54 --- addr d4 */ - 0xc8000000, /* line 55 --- addr d8 */ - 0x1c0e0078, /* line 56 --- addr dc */ - 0x6d000001, /* line 57 --- addr e0 */ - 0x0800003f, /* line 58 --- addr e4 */ - 0x6c200004, /* line 59 --- addr e8 */ - 0x6c300008, /* line 60 --- addr ec */ - 0x30000067, /* line 61 --- addr f0 */ - 0xf8000000, /* line 62 --- addr f4 */ - 0x60000008, /* line 63 --- addr f8 */ - 0xdc700100, /* line 64 --- addr fc */ - 0x3000002a, /* line 65 --- addr 100 */ - 0x7c000000, /* line 66 --- addr 104 */ - 0x6100000c, /* line 67 --- addr 108 */ - 0x78000004, /* line 68 --- addr 10c */ - 0x30000000, /* line 69 --- addr 110 */ - 0xc0000000, /* line 70 --- addr 114 */ - 0xc0000000, /* line 71 --- addr 118 */ - 0xc0000000, /* line 72 --- addr 11c */ - 0xc0000000, /* line 73 --- addr 120 */ - 0xc0000000, /* line 74 --- addr 124 */ - 0xc0000000, /* line 75 --- addr 128 */ - 0xc0000000, /* line 76 --- addr 12c */ - 0x1c060183, /* line 77 --- addr 130 */ - 0x4d000000, /* line 78 --- addr 134 */ - 0x0c07004d, /* line 79 --- addr 138 */ - 0x59070000, /* line 80 --- addr 13c */ - 0x8c008000, /* line 81 --- addr 140 */ - 0x49800000, /* line 82 --- addr 144 */ - 0x6d000001, /* line 83 --- addr 148 */ - 0x59700000, /* line 84 --- addr 14c */ - 0x71000401, /* line 85 --- addr 150 */ - 0x59050000, /* line 86 --- addr 154 */ - 0x49800000, /* line 87 --- addr 158 */ - 0xb0000000, /* line 88 --- addr 15c */ - 0xb0050000, /* line 89 --- addr 160 */ - 0x1801005d, /* line 90 --- addr 164 */ - 0x65000010, /* line 91 --- addr 168 */ - 0xc0000000, /* line 92 --- addr 16c */ - 0x61000010, /* line 93 --- addr 170 */ - 0x59070000, /* line 94 --- addr 174 */ - 0x61000012, /* line 95 --- addr 178 */ - 0x0c010064, /* line 96 --- addr 17c */ - 0xfb000000, /* line 97 --- addr 180 */ - 0xfa000000, /* line 98 --- addr 184 */ - 0x6570000c, /* line 99 --- addr 188 */ - 0x30000030, /* line 100 --- addr 18c */ - 0xfb000000, /* line 101 --- addr 190 */ - 0xfe000000, /* line 102 --- addr 194 */ - 0x30000000, /* line 103 --- addr 198 */ - 0xb0000000, /* line 104 --- addr 19c */ - 0xfb000000, /* line 105 --- addr 1a0 */ - 0xf9000002, /* line 106 --- addr 1a4 */ - 0xd1001018, /* line 107 --- addr 1a8 */ - 0x65000012, /* line 108 --- addr 1ac */ - 0xdc000100, /* line 109 --- addr 1b0 */ - 0x9c000f00, /* line 110 --- addr 1b4 */ - 0x80000018, /* line 111 --- addr 1b8 */ - 0x61000012, /* line 112 --- addr 1bc */ - 0xd1001018, /* line 113 --- addr 1c0 */ - 0x18010140, /* line 114 --- addr 1c4 */ - 0xd1000110, /* line 115 --- addr 1c8 */ - 0x380f0140, /* line 116 --- addr 1cc */ - 0xb4000000, /* line 117 --- addr 1d0 */ - 0x30000140, /* line 118 --- addr 1d4 */ - 0x71001102, /* line 119 --- addr 1d8 */ - 0x3000004c, /* line 120 --- addr 1dc */ - 0xb0020000, /* line 121 --- addr 1e0 */ - 0x2c00707a, /* line 122 --- addr 1e4 */ - 0x59040080, /* line 123 --- addr 1e8 */ - 0xcc000000, /* line 124 --- addr 1ec */ - 0x2c00707f, /* line 125 --- addr 1f0 */ - 0x6500000c, /* line 126 --- addr 1f4 */ - 0x3000008b, /* line 127 --- addr 1f8 */ - 0x59040080, /* line 128 --- addr 1fc */ - 0x3c200089, /* line 129 --- addr 200 */ - 0x3c200089, /* line 130 --- addr 204 */ - 0x3c200089, /* line 131 --- addr 208 */ - 0x3c200089, /* line 132 --- addr 20c */ - 0x3c200089, /* line 133 --- addr 210 */ - 0x3c200089, /* line 134 --- addr 214 */ - 0x3c210089, /* line 135 --- addr 218 */ - 0x3c220089, /* line 136 --- addr 21c */ - 0x3000007c, /* line 137 --- addr 220 */ - 0x2c00708a, /* line 138 --- addr 224 */ - 0x59040080, /* line 139 --- addr 228 */ - 0x59700000, /* line 140 --- addr 22c */ - 0xc8000000, /* line 141 --- addr 230 */ - 0x6c100014, /* line 142 --- addr 234 */ - 0x2c002091, /* line 143 --- addr 238 */ - 0xb0080000, /* line 144 --- addr 23c */ - 0xb0080000, /* line 145 --- addr 240 */ - 0x54000000, /* line 146 --- addr 244 */ - 0x30000140, /* line 147 --- addr 248 */ - 0x54000000, /* line 148 --- addr 24c */ - 0x6c100014, /* line 149 --- addr 250 */ - 0x30000140, /* line 150 --- addr 254 */ - 0x65000015, /* line 151 --- addr 258 */ - 0xdc000100, /* line 152 --- addr 25c */ - 0x9c000f00, /* line 153 --- addr 260 */ - 0x80000018, /* line 154 --- addr 264 */ - 0x61000015, /* line 155 --- addr 268 */ - 0xd1001018, /* line 156 --- addr 26c */ - 0xf0000345, /* line 157 --- addr 270 */ - 0x6d000018, /* line 158 --- addr 274 */ - 0xc0000000, /* line 159 --- addr 278 */ - 0x3c0000a4, /* line 160 --- addr 27c */ - 0x69000018, /* line 161 --- addr 280 */ - 0x6810001c, /* line 162 --- addr 284 */ - 0x54000000, /* line 163 --- addr 288 */ - 0x30000096, /* line 164 --- addr 28c */ - 0x180500a4, /* line 165 --- addr 290 */ - 0x2c006129, /* line 166 --- addr 294 */ - 0x2c0070da, /* line 167 --- addr 298 */ - 0x180b00ac, /* line 168 --- addr 29c */ - 0x280000ac, /* line 169 --- addr 2a0 */ - 0x1c0900ac, /* line 170 --- addr 2a4 */ - 0xf1000645, /* line 171 --- addr 2a8 */ - 0x28000140, /* line 172 --- addr 2ac */ - 0x280020b2, /* line 173 --- addr 2b0 */ - 0x7c000000, /* line 174 --- addr 2b4 */ - 0x59040080, /* line 175 --- addr 2b8 */ - 0x2c0020ae, /* line 176 --- addr 2bc */ - 0x2c0020ae, /* line 177 --- addr 2c0 */ - 0x300000a4, /* line 178 --- addr 2c4 */ - 0x280000b8, /* line 179 --- addr 2c8 */ - 0x7c000000, /* line 180 --- addr 2cc */ - 0x59400080, /* line 181 --- addr 2d0 */ - 0x2c0000b4, /* line 182 --- addr 2d4 */ - 0x2c0000b4, /* line 183 --- addr 2d8 */ - 0x300000a4, /* line 184 --- addr 2dc */ - 0x30000140, /* line 185 --- addr 2e0 */ - 0x1c0200c1, /* line 186 --- addr 2e4 */ - 0x1c0c00bc, /* line 187 --- addr 2e8 */ - 0x30000181, /* line 188 --- addr 2ec */ - 0xb4030000, /* line 189 --- addr 2f0 */ - 0x71000502, /* line 190 --- addr 2f4 */ - 0x280050be, /* line 191 --- addr 2f8 */ - 0x74400680, /* line 192 --- addr 2fc */ - 0x3000004c, /* line 193 --- addr 300 */ - 0x71001302, /* line 194 --- addr 304 */ - 0x3000004c, /* line 195 --- addr 308 */ - 0x65000014, /* line 196 --- addr 30c */ - 0xdc000100, /* line 197 --- addr 310 */ - 0x9c000f00, /* line 198 --- addr 314 */ - 0x80000018, /* line 199 --- addr 318 */ - 0x61000014, /* line 200 --- addr 31c */ - 0xd1001018, /* line 201 --- addr 320 */ - 0xf0000545, /* line 202 --- addr 324 */ - 0x2c0040ca, /* line 203 --- addr 328 */ - 0x180700cf, /* line 204 --- addr 32c */ - 0x6c20000c, /* line 205 --- addr 330 */ - 0x6c30001b, /* line 206 --- addr 334 */ - 0x30000140, /* line 207 --- addr 338 */ - 0x6d000001, /* line 208 --- addr 33c */ - 0x9c00fe00, /* line 209 --- addr 340 */ - 0x69000001, /* line 210 --- addr 344 */ - 0x7c000000, /* line 211 --- addr 348 */ - 0xb8000000, /* line 212 --- addr 34c */ - 0x80000004, /* line 213 --- addr 350 */ - 0x60000004, /* line 214 --- addr 354 */ - 0x6c100014, /* line 215 --- addr 358 */ - 0x6810001c, /* line 216 --- addr 35c */ - 0x54000000, /* line 217 --- addr 360 */ - 0x28007140, /* line 218 --- addr 364 */ - 0x65000017, /* line 219 --- addr 368 */ - 0xdc000100, /* line 220 --- addr 36c */ - 0x9c000f00, /* line 221 --- addr 370 */ - 0x80000018, /* line 222 --- addr 374 */ - 0x61000017, /* line 223 --- addr 378 */ - 0xd1001018, /* line 224 --- addr 37c */ - 0x59040000, /* line 225 --- addr 380 */ - 0x3c000114, /* line 226 --- addr 384 */ - 0x3c040104, /* line 227 --- addr 388 */ - 0x3c0200ed, /* line 228 --- addr 38c */ - 0x3c0700e8, /* line 229 --- addr 390 */ - 0x3c0100f6, /* line 230 --- addr 394 */ - 0x3c2300ef, /* line 231 --- addr 398 */ - 0x3c0800ed, /* line 232 --- addr 39c */ - 0xb4030000, /* line 233 --- addr 3a0 */ - 0xb0050000, /* line 234 --- addr 3a4 */ - 0x2c0070ea, /* line 235 --- addr 3a8 */ - 0x28005181, /* line 236 --- addr 3ac */ - 0x30000140, /* line 237 --- addr 3b0 */ - 0xb0050000, /* line 238 --- addr 3b4 */ - 0x30000140, /* line 239 --- addr 3b8 */ - 0xb0050000, /* line 240 --- addr 3bc */ - 0x28007181, /* line 241 --- addr 3c0 */ - 0x59040080, /* line 242 --- addr 3c4 */ - 0xb4060000, /* line 243 --- addr 3c8 */ - 0x28006140, /* line 244 --- addr 3cc */ - 0xb0060000, /* line 245 --- addr 3d0 */ - 0x30000140, /* line 246 --- addr 3d4 */ - 0xb0050000, /* line 247 --- addr 3d8 */ - 0x2c0070f8, /* line 248 --- addr 3dc */ - 0x59040080, /* line 249 --- addr 3e0 */ - 0x3c0200ff, /* line 250 --- addr 3e4 */ - 0x3c0300fd, /* line 251 --- addr 3e8 */ - 0x2c0070fc, /* line 252 --- addr 3ec */ - 0x59040080, /* line 253 --- addr 3f0 */ - 0x2c0070fe, /* line 254 --- addr 3f4 */ - 0x59040080, /* line 255 --- addr 3f8 */ - 0x2c007100, /* line 256 --- addr 3fc */ - 0x59040080, /* line 257 --- addr 400 */ - 0x2c007102, /* line 258 --- addr 404 */ - 0x59040040, /* line 259 --- addr 408 */ - 0x300000e8, /* line 260 --- addr 40c */ - 0x180a010a, /* line 261 --- addr 410 */ - 0x18060108, /* line 262 --- addr 414 */ - 0xb0060000, /* line 263 --- addr 418 */ - 0x3000010a, /* line 264 --- addr 41c */ - 0x1c0b010a, /* line 265 --- addr 420 */ - 0xb0080000, /* line 266 --- addr 424 */ - 0x1c01010c, /* line 267 --- addr 428 */ - 0xb4000000, /* line 268 --- addr 42c */ - 0xb0050000, /* line 269 --- addr 430 */ - 0x6c10001c, /* line 270 --- addr 434 */ - 0x68100014, /* line 271 --- addr 438 */ - 0x50000000, /* line 272 --- addr 43c */ - 0x6570000c, /* line 273 --- addr 440 */ - 0xfb000000, /* line 274 --- addr 444 */ - 0x1c010030, /* line 275 --- addr 448 */ - 0x30000000, /* line 276 --- addr 44c */ - 0x1807004c, /* line 277 --- addr 450 */ - 0xb0050000, /* line 278 --- addr 454 */ - 0x30000145, /* line 279 --- addr 458 */ - 0x65000013, /* line 280 --- addr 45c */ - 0xdc000100, /* line 281 --- addr 460 */ - 0x9c000f00, /* line 282 --- addr 464 */ - 0x80000018, /* line 283 --- addr 468 */ - 0x61000013, /* line 284 --- addr 46c */ - 0xd1001018, /* line 285 --- addr 470 */ - 0x6d000099, /* line 286 --- addr 474 */ - 0x18070120, /* line 287 --- addr 478 */ - 0x9c00bf00, /* line 288 --- addr 47c */ - 0x1c010123, /* line 289 --- addr 480 */ - 0x59400080, /* line 290 --- addr 484 */ - 0x30000140, /* line 291 --- addr 488 */ - 0x594000c0, /* line 292 --- addr 48c */ - 0x2c005125, /* line 293 --- addr 490 */ - 0x6d4000c0, /* line 294 --- addr 494 */ - 0x2c005127, /* line 295 --- addr 498 */ - 0x59470080, /* line 296 --- addr 49c */ - 0x30000140, /* line 297 --- addr 4a0 */ - 0x65000016, /* line 298 --- addr 4a4 */ - 0xdc000100, /* line 299 --- addr 4a8 */ - 0x9c000f00, /* line 300 --- addr 4ac */ - 0x80000018, /* line 301 --- addr 4b0 */ - 0x61000016, /* line 302 --- addr 4b4 */ - 0xd1001018, /* line 303 --- addr 4b8 */ - 0x59040080, /* line 304 --- addr 4bc */ - 0x1c07013e, /* line 305 --- addr 4c0 */ - 0x69000003, /* line 306 --- addr 4c4 */ - 0x3802013e, /* line 307 --- addr 4c8 */ - 0xb4070000, /* line 308 --- addr 4cc */ - 0x71000402, /* line 309 --- addr 4d0 */ - 0x61700019, /* line 310 --- addr 4d4 */ - 0x6d00001a, /* line 311 --- addr 4d8 */ - 0x6100001b, /* line 312 --- addr 4dc */ - 0x6d00001b, /* line 313 --- addr 4e0 */ - 0x6100001e, /* line 314 --- addr 4e4 */ - 0x38000140, /* line 315 --- addr 4e8 */ - 0x6500000d, /* line 316 --- addr 4ec */ - 0x8c008000, /* line 317 --- addr 4f0 */ - 0x6100000d, /* line 318 --- addr 4f4 */ - 0xb0070000, /* line 319 --- addr 4f8 */ - 0x2c00613f, /* line 320 --- addr 4fc */ - 0x20204778, /* line 321 --- addr 500 */ - 0x18050141, /* line 322 --- addr 504 */ - 0x205769ab, /* line 323 --- addr 508 */ - 0x107e00c0, /* line 324 --- addr 50c */ - 0x30000140, /* line 325 --- addr 510 */ - 0x6c200010, /* line 326 --- addr 514 */ - 0x74300600, /* line 327 --- addr 518 */ - 0x30000067, /* line 328 --- addr 51c */ - 0x6500000f, /* line 329 --- addr 520 */ - 0x59700000, /* line 330 --- addr 524 */ - 0xc8000000, /* line 331 --- addr 528 */ - 0x1c0e0078, /* line 332 --- addr 52c */ - 0x6500000d, /* line 333 --- addr 530 */ - 0x0c0001b6, /* line 334 --- addr 534 */ - 0x6c200004, /* line 335 --- addr 538 */ - 0x6c300008, /* line 336 --- addr 53c */ - 0x0c010153, /* line 337 --- addr 540 */ - 0x0c020185, /* line 338 --- addr 544 */ - 0x30000000, /* line 339 --- addr 548 */ - 0xb4060000, /* line 340 --- addr 54c */ - 0xf9000002, /* line 341 --- addr 550 */ - 0x28005181, /* line 342 --- addr 554 */ - 0x65000013, /* line 343 --- addr 558 */ - 0x2c005158, /* line 344 --- addr 55c */ - 0x6d4000d9, /* line 345 --- addr 560 */ - 0x2c00515a, /* line 346 --- addr 564 */ - 0x744001c0, /* line 347 --- addr 568 */ - 0x2c00515c, /* line 348 --- addr 56c */ - 0x744002c0, /* line 349 --- addr 570 */ - 0x2c00515e, /* line 350 --- addr 574 */ - 0x744003c0, /* line 351 --- addr 578 */ - 0x2c005160, /* line 352 --- addr 57c */ - 0x59400080, /* line 353 --- addr 580 */ - 0x2800717f, /* line 354 --- addr 584 */ - 0x59040080, /* line 355 --- addr 588 */ - 0x3c07017d, /* line 356 --- addr 58c */ - 0x380100e1, /* line 357 --- addr 590 */ - 0x28007181, /* line 358 --- addr 594 */ - 0x59040080, /* line 359 --- addr 598 */ - 0x38020179, /* line 360 --- addr 59c */ - 0x28007181, /* line 361 --- addr 5a0 */ - 0x59040080, /* line 362 --- addr 5a4 */ - 0x38030179, /* line 363 --- addr 5a8 */ - 0x28007181, /* line 364 --- addr 5ac */ - 0x59040000, /* line 365 --- addr 5b0 */ - 0x61000016, /* line 366 --- addr 5b4 */ - 0x71000d02, /* line 367 --- addr 5b8 */ - 0x6500000d, /* line 368 --- addr 5bc */ - 0x08020175, /* line 369 --- addr 5c0 */ - 0xb4030000, /* line 370 --- addr 5c4 */ - 0xb0050000, /* line 371 --- addr 5c8 */ - 0xfe000000, /* line 372 --- addr 5cc */ - 0x30000189, /* line 373 --- addr 5d0 */ - 0xb0050000, /* line 374 --- addr 5d4 */ - 0xb0060000, /* line 375 --- addr 5d8 */ - 0xfe000000, /* line 376 --- addr 5dc */ - 0x30000140, /* line 377 --- addr 5e0 */ - 0x71000702, /* line 378 --- addr 5e4 */ - 0x28007176, /* line 379 --- addr 5e8 */ - 0x59040080, /* line 380 --- addr 5ec */ - 0x3000017a, /* line 381 --- addr 5f0 */ - 0x71000c02, /* line 382 --- addr 5f4 */ - 0x30000176, /* line 383 --- addr 5f8 */ - 0x71000b02, /* line 384 --- addr 5fc */ - 0x30000176, /* line 385 --- addr 600 */ - 0x71001402, /* line 386 --- addr 604 */ - 0x30000140, /* line 387 --- addr 608 */ - 0x6c200004, /* line 388 --- addr 60c */ - 0x6c300008, /* line 389 --- addr 610 */ - 0x74400000, /* line 390 --- addr 614 */ - 0xf9000002, /* line 391 --- addr 618 */ - 0x28005181, /* line 392 --- addr 61c */ - 0x6d4000d9, /* line 393 --- addr 620 */ - 0x2c00518d, /* line 394 --- addr 624 */ - 0x2c00518d, /* line 395 --- addr 628 */ - 0x300001b2, /* line 396 --- addr 62c */ - 0x28005140, /* line 397 --- addr 630 */ - 0xb0060000, /* line 398 --- addr 634 */ - 0x744001c0, /* line 399 --- addr 638 */ - 0x2c005190, /* line 400 --- addr 63c */ - 0x744003c0, /* line 401 --- addr 640 */ - 0x2c005192, /* line 402 --- addr 644 */ - 0x744001c0, /* line 403 --- addr 648 */ - 0x65000014, /* line 404 --- addr 64c */ - 0x2c005195, /* line 405 --- addr 650 */ - 0x594000c0, /* line 406 --- addr 654 */ - 0x65000015, /* line 407 --- addr 658 */ - 0x2c005198, /* line 408 --- addr 65c */ - 0x59400080, /* line 409 --- addr 660 */ - 0x280071b4, /* line 410 --- addr 664 */ - 0x59040080, /* line 411 --- addr 668 */ - 0x3c0701b2, /* line 412 --- addr 66c */ - 0x380100e1, /* line 413 --- addr 670 */ - 0x28007181, /* line 414 --- addr 674 */ - 0x59040080, /* line 415 --- addr 678 */ - 0x38030179, /* line 416 --- addr 67c */ - 0x28007181, /* line 417 --- addr 680 */ - 0x59040080, /* line 418 --- addr 684 */ - 0x38010179, /* line 419 --- addr 688 */ - 0x28007181, /* line 420 --- addr 68c */ - 0x59040080, /* line 421 --- addr 690 */ - 0x61000017, /* line 422 --- addr 694 */ - 0x28007181, /* line 423 --- addr 698 */ - 0x59040080, /* line 424 --- addr 69c */ - 0x61000018, /* line 425 --- addr 6a0 */ - 0x71000a02, /* line 426 --- addr 6a4 */ - 0x30000176, /* line 427 --- addr 6a8 */ - 0xc0000000, /* line 428 --- addr 6ac */ - 0xc0000000, /* line 429 --- addr 6b0 */ - 0xc0000000, /* line 430 --- addr 6b4 */ - 0xc0000000, /* line 431 --- addr 6b8 */ - 0xc0000000, /* line 432 --- addr 6bc */ - 0xc0000000, /* line 433 --- addr 6c0 */ - 0xc0000000, /* line 434 --- addr 6c4 */ - 0x71000902, /* line 435 --- addr 6c8 */ - 0x30000176, /* line 436 --- addr 6cc */ - 0x71000802, /* line 437 --- addr 6d0 */ - 0x30000176, /* line 438 --- addr 6d4 */ - 0xa000000e, /* line 439 --- addr 6d8 */ - 0x08000000, /* line 440 --- addr 6dc */ - 0x74400000, /* line 441 --- addr 6e0 */ - 0xf90000d2, /* line 442 --- addr 6e4 */ - 0x28005181, /* line 443 --- addr 6e8 */ - 0x6d400084, /* line 444 --- addr 6ec */ - 0x7900000c, /* line 445 --- addr 6f0 */ - 0x7d000000, /* line 446 --- addr 6f4 */ - 0xdc000100, /* line 447 --- addr 6f8 */ - 0x6100000e, /* line 448 --- addr 6fc */ - 0x1801004c, /* line 449 --- addr 700 */ - 0xd1000110, /* line 450 --- addr 704 */ - 0x3000004c, /* line 451 --- addr 708 */ - 0xf90000ef, /* line 452 --- addr 70c */ - 0xfe000000, /* line 453 --- addr 710 */ - 0x280051c5, /* line 454 --- addr 714 */ - 0x180501c5, /* line 455 --- addr 718 */ - 0x74400680, /* line 456 --- addr 71c */ - 0xfb000000, /* line 457 --- addr 720 */ - 0xfe000000, /* line 458 --- addr 724 */ - 0xfe000000 /* line 459 --- addr 728 */ - }; diff --git a/drivers/sound/Config.in b/drivers/sound/Config.in index b1bc3607904b..b160c29e591e 100644 --- a/drivers/sound/Config.in +++ b/drivers/sound/Config.in @@ -1,15 +1,251 @@ -# -# Sound driver configuration -# -#-------- -# There is another config script which is compatible with rest of -# the kernel. It can be activated by running 'make mkscript' in this -# directory. Please note that this is an _experimental_ feature which -# doesn't work with all cards (PSS, SM Wave, AudioTrix Pro, Maui). -#-------- -# -$MAKE -C drivers/sound config || exit 1 +bool 'ProAudioSpectrum 16 support' CONFIG_PAS +bool 'Sound Blaster (SB, SBPro, SB16, clones) support' CONFIG_SB +bool 'Generic OPL2/OPL3 FM synthesizer support' CONFIG_ADLIB +bool 'Gravis Ultrasound support' CONFIG_GUS +bool 'MPU-401 support (NOT for SB16)' CONFIG_MPU401 +bool '6850 UART Midi support' CONFIG_UART6850 +bool 'PSS (ECHO-ADI2111) support' CONFIG_PSS +bool '16 bit sampling option of GUS (_NOT_ GUS MAX)' CONFIG_GUS16 +bool 'GUS MAX support' CONFIG_GUSMAX +bool 'Microsoft Sound System support' CONFIG_MSS +bool 'Ensoniq SoundScape support' CONFIG_SSCAPE +bool 'MediaTrix AudioTrix Pro support' CONFIG_TRIX +bool 'Support for MAD16 and/or Mozart based cards' CONFIG_MAD16 +bool 'Support for Crystal CS4232 based (PnP) cards' CONFIG_CS4232 +bool 'Support for Turtle Beach Wave Front (Maui, Tropez) synthesizers' CONFIG_MAUI +bool '/dev/dsp and /dev/audio support' CONFIG_AUDIO +bool 'MIDI interface support' CONFIG_MIDI +bool 'FM synthesizer (YM3812/OPL-3) support' CONFIG_YM3812 + +if [ "$CONFIG_SB" = "y" ]; then +hex 'I/O base for SB Check from manual of the card' SBC_BASE 220 +fi + +if [ "$CONFIG_SB" = "y" ]; then +int 'Sound Blaster IRQ Check from manual of the card' SBC_IRQ 7 +fi + +if [ "$CONFIG_SB" = "y" ]; then +int 'Sound Blaster DMA 0, 1 or 3' SBC_DMA 1 +fi + +if [ "$CONFIG_SB" = "y" ]; then +int 'Sound Blaster 16 bit DMA (_REQUIRED_for SB16, Jazz16, SMW) 5, 6 or 7 (use 1 for 8 bit cards)' SB_DMA2 5 +fi + +if [ "$CONFIG_SB" = "y" ]; then +hex 'MPU401 I/O base of SB16, Jazz16 and ES1688 Check from manual of the card' SB_MPU_BASE 0 +fi + +if [ "$CONFIG_SB" = "y" ]; then +int 'SB MPU401 IRQ (Jazz16, SM Wave and ES1688) Use -1 with SB16' SB_MPU_IRQ -1 +fi + +if [ "$CONFIG_PAS" = "y" ]; then +int 'PAS16 IRQ 3, 4, 5, 7, 9, 10, 11, 12, 14 or 15' PAS_IRQ 10 +fi + +if [ "$CONFIG_PAS" = "y" ]; then +int 'PAS16 DMA 0, 1, 3, 5, 6 or 7' PAS_DMA 3 +fi + +if [ "$CONFIG_GUS" = "y" ]; then +hex 'I/O base for GUS 210, 220, 230, 240, 250 or 260' GUS_BASE 220 +fi + +if [ "$CONFIG_GUS" = "y" ]; then +int 'GUS IRQ 3, 5, 7, 9, 11, 12 or 15' GUS_IRQ 15 +fi + +if [ "$CONFIG_GUS" = "y" ]; then +int 'GUS DMA 1, 3, 5, 6 or 7' GUS_DMA 6 +fi + +if [ "$CONFIG_GUS" = "y" ]; then +int 'Second DMA channel for GUS 1, 3, 5, 6 or 7' GUS_DMA2 -1 +fi + +if [ "$CONFIG_GUS16" = "y" ]; then +hex 'I/O base for the 16 bit daughtercard of GUS 530, 604, E80 or F40' GUS16_BASE 530 +fi + +if [ "$CONFIG_GUS16" = "y" ]; then +int 'GUS 16 bit daughtercard IRQ 3, 4, 5, 7, or 9' GUS16_IRQ 7 +fi + +if [ "$CONFIG_GUS16" = "y" ]; then +int 'GUS DMA 0, 1 or 3' GUS16_DMA 3 +fi + +if [ "$CONFIG_MPU401" = "y" ]; then +hex 'I/O base for MPU401 Check from manual of the card' MPU_BASE 330 +fi + +if [ "$CONFIG_MPU401" = "y" ]; then +int 'MPU401 IRQ Check from manual of the card' MPU_IRQ 9 +fi + +if [ "$CONFIG_MAUI" = "y" ]; then +hex 'I/O base for Maui 210, 230, 260, 290, 300, 320, 338 or 330' MAUI_BASE 330 +fi + +if [ "$CONFIG_MAUI" = "y" ]; then +int 'Maui IRQ 5, 9, 12 or 15' MAUI_IRQ 9 +fi + +if [ "$CONFIG_UART6850" = "y" ]; then +hex 'I/O base for UART 6850 MIDI port (Unknown)' U6850_BASE 0 +fi + +if [ "$CONFIG_UART6850" = "y" ]; then +int 'UART6850 IRQ (Unknown)' U6850_IRQ -1 +fi + +if [ "$CONFIG_PSS" = "y" ]; then +hex 'PSS I/O base 220 or 240' PSS_BASE 220 +fi + +if [ "$CONFIG_PSS" = "y" ]; then +hex 'PSS audio I/O base 530, 604, E80 or F40' PSS_MSS_BASE 530 +fi + +if [ "$CONFIG_PSS" = "y" ]; then +int 'PSS audio IRQ 7, 9, 10 or 11' PSS_MSS_IRQ 11 +fi + +if [ "$CONFIG_PSS" = "y" ]; then +int 'PSS audio DMA 0, 1 or 3' PSS_MSS_DMA 3 +fi + +if [ "$CONFIG_PSS" = "y" ]; then +hex 'PSS MIDI I/O base ' PSS_MPU_BASE 330 +fi + +if [ "$CONFIG_PSS" = "y" ]; then +int 'PSS MIDI IRQ 3, 4, 5, 7 or 9' PSS_MPU_IRQ 9 +fi + +if [ "$CONFIG_MSS" = "y" ]; then +hex 'MSS/WSS I/O base 530, 604, E80 or F40' MSS_BASE 530 +fi +if [ "$CONFIG_MSS" = "y" ]; then +int 'MSS/WSS IRQ 7, 9, 10 or 11' MSS_IRQ 11 +fi + +if [ "$CONFIG_MSS" = "y" ]; then +int 'MSS/WSS DMA 0, 1 or 3' MSS_DMA 3 +fi + +if [ "$CONFIG_SSCAPE" = "y" ]; then +hex 'SoundScape MIDI I/O base 320, 330, 340 or 350' SSCAPE_BASE 330 +fi + +if [ "$CONFIG_SSCAPE" = "y" ]; then +int 'SoundScape MIDI IRQ ' SSCAPE_IRQ 9 +fi + +if [ "$CONFIG_SSCAPE" = "y" ]; then +int 'SoundScape initialization DMA 0, 1 or 3' SSCAPE_DMA 3 +fi + +if [ "$CONFIG_SSCAPE" = "y" ]; then +hex 'SoundScape audio I/O base 534, 608, E84 or F44' SSCAPE_MSS_BASE 534 +fi + +if [ "$CONFIG_SSCAPE" = "y" ]; then +int 'SoundScape audio IRQ 7, 9, 10 or 11' SSCAPE_MSS_IRQ 11 +fi + +if [ "$CONFIG_TRIX" = "y" ]; then +hex 'AudioTrix audio I/O base 530, 604, E80 or F40' TRIX_BASE 530 +fi + +if [ "$CONFIG_TRIX" = "y" ]; then +int 'AudioTrix audio IRQ 7, 9, 10 or 11' TRIX_IRQ 11 +fi + +if [ "$CONFIG_TRIX" = "y" ]; then +int 'AudioTrix audio DMA 0, 1 or 3' TRIX_DMA 0 +fi + +if [ "$CONFIG_TRIX" = "y" ]; then +int 'AudioTrix second (duplex) DMA 0, 1 or 3' TRIX_DMA2 3 +fi + +if [ "$CONFIG_TRIX" = "y" ]; then +hex 'AudioTrix MIDI I/O base 330, 370, 3B0 or 3F0' TRIX_MPU_BASE 330 +fi + +if [ "$CONFIG_TRIX" = "y" ]; then +int 'AudioTrix MIDI IRQ 3, 4, 5, 7 or 9' TRIX_MPU_IRQ 9 +fi + +if [ "$CONFIG_TRIX" = "y" ]; then +hex 'AudioTrix SB I/O base 220, 210, 230, 240, 250, 260 or 270' TRIX_SB_BASE 220 +fi + +if [ "$CONFIG_TRIX" = "y" ]; then +int 'AudioTrix SB IRQ 3, 4, 5 or 7' TRIX_SB_IRQ 7 +fi + +if [ "$CONFIG_TRIX" = "y" ]; then +int 'AudioTrix SB DMA 1 or 3' TRIX_SB_DMA 1 +fi + +if [ "$CONFIG_CS4232" = "y" ]; then +hex 'CS4232 audio I/O base 530, 604, E80 or F40' CS4232_BASE 530 +fi + +if [ "$CONFIG_CS4232" = "y" ]; then +int 'CS4232 audio IRQ 5, 7, 9, 11, 12 or 15' CS4232_IRQ 11 +fi + +if [ "$CONFIG_CS4232" = "y" ]; then +int 'CS4232 audio DMA 0, 1 or 3' CS4232_DMA 0 +fi + +if [ "$CONFIG_CS4232" = "y" ]; then +int 'CS4232 second (duplex) DMA 0, 1 or 3' CS4232_DMA2 3 +fi + +if [ "$CONFIG_CS4232" = "y" ]; then +hex 'CS4232 MIDI I/O base 330, 370, 3B0 or 3F0' CS4232_MPU_BASE 330 +fi + +if [ "$CONFIG_CS4232" = "y" ]; then +int 'CS4232 MIDI IRQ 5, 7, 9, 11, 12 or 15' CS4232_MPU_IRQ 9 +fi + +if [ "$CONFIG_MAD16" = "y" ]; then +hex 'MAD16 audio I/O base 530, 604, E80 or F40' MAD16_BASE 530 +fi + +if [ "$CONFIG_MAD16" = "y" ]; then +int 'MAD16 audio IRQ 7, 9, 10 or 11' MAD16_IRQ 11 +fi + +if [ "$CONFIG_MAD16" = "y" ]; then +int 'MAD16 audio DMA 0, 1 or 3' MAD16_DMA 3 +fi + +if [ "$CONFIG_MAD16" = "y" ]; then +int 'MAD16 second (duplex) DMA 0, 1 or 3' MAD16_DMA2 0 +fi + +if [ "$CONFIG_MAD16" = "y" ]; then +hex 'MAD16 MIDI I/O base 300, 310, 320 or 330 (0 disables)' MAD16_MPU_BASE 330 +fi + +if [ "$CONFIG_MAD16" = "y" ]; then +int 'MAD16 MIDI IRQ 5, 7, 9 or 10' MAD16_MPU_IRQ 9 +fi + +if [ "$CONFIG_AUDIO" = "y" ]; then +int 'Audio DMA buffer size 4096, 16384, 32768 or 65536' DSP_BUFFSIZE 65536 +fi +# +$MAKE -C drivers/sound kernelconfig || exit 1 bool 'Additional low level drivers' CONFIG_LOWLEVEL_SOUND if [ "$CONFIG_LOWLEVEL_SOUND" = "y" ]; then diff --git a/drivers/sound/audio.c b/drivers/sound/audio.c index 32e9909a15d4..62027a4ca659 100644 --- a/drivers/sound/audio.c +++ b/drivers/sound/audio.c @@ -201,9 +201,6 @@ audio_write (int dev, struct fileinfo *file, const char *buf, int count) p = 0; c = count; - if (count < 0) - return -EINVAL; - if ((audio_mode[dev] & AM_READ) && !(audio_devs[dev]->flags & DMA_DUPLEX)) { /* Direction change */ } diff --git a/fs/Config.in b/fs/Config.in index 19fa2ef9188b..0dd9e61e0ead 100644 --- a/fs/Config.in +++ b/fs/Config.in @@ -19,8 +19,6 @@ if [ "$CONFIG_NLS" = "y" -o "$CONFIG_NLS" = "m" ]; then dep_tristate 'MSDOS fs support' CONFIG_MSDOS_FS $CONFIG_FAT_FS dep_tristate 'umsdos: Unix like fs on top of std MSDOS FAT fs' CONFIG_UMSDOS_FS $CONFIG_MSDOS_FS dep_tristate 'VFAT (Windows-95) fs support' CONFIG_VFAT_FS $CONFIG_FAT_FS - mainmenu_option next_comment - comment 'Select available code pages' dep_tristate 'Codepage 437 (United States, Canada)' CONFIG_NLS_CODEPAGE_437 $CONFIG_NLS dep_tristate 'Codepage 737 (Greek)' CONFIG_NLS_CODEPAGE_737 $CONFIG_NLS dep_tristate 'Codepage 775 (Baltic Rim)' CONFIG_NLS_CODEPAGE_775 $CONFIG_NLS @@ -46,9 +44,7 @@ if [ "$CONFIG_NLS" = "y" -o "$CONFIG_NLS" = "m" ]; then dep_tristate 'NLS ISO 8859-7 (Modern Greek)' CONFIG_NLS_ISO8859_7 $CONFIG_NLS dep_tristate 'NLS ISO 8859-8 (Hebrew)' CONFIG_NLS_ISO8859_8 $CONFIG_NLS dep_tristate 'NLS ISO 8859-9 (Latin 5; Turkey)' CONFIG_NLS_ISO8859_9 $CONFIG_NLS - dep_tristate 'NLS ISO 8859-15 (Latin 9; Western European Languages with Euro)' CONFIG_NLS_ISO8859_15 $CONFIG_NLS dep_tristate 'NLS KOI8-R (Russian)' CONFIG_NLS_KOI8_R $CONFIG_NLS - endmenu fi bool '/proc filesystem support' CONFIG_PROC_FS @@ -68,9 +64,6 @@ if [ "$CONFIG_INET" = "y" ]; then fi if [ "$CONFIG_IPX" != "n" ]; then tristate 'NCP filesystem support (to mount NetWare volumes)' CONFIG_NCP_FS - if [ "$CONFIG_NCP_FS" != "n" ]; then - source fs/ncpfs/Config.in - fi fi tristate 'OS/2 HPFS filesystem support (read only)' CONFIG_HPFS_FS tristate 'System V and Coherent filesystem support' CONFIG_SYSV_FS diff --git a/fs/Makefile b/fs/Makefile index df8d0347c504..13897ec1eef6 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -481,14 +481,6 @@ else endif endif -ifeq ($(CONFIG_NLS_ISO8859_15),y) -NLS += nls_iso8859_15.o -else - ifeq ($(CONFIG_NLS_ISO8859_15),m) - M_OBJS += nls_iso8859_15.o - endif -endif - ifeq ($(CONFIG_NLS_KOI8_R),y) NLS += nls_koi8_r.o else diff --git a/fs/autofs/root.c b/fs/autofs/root.c index 71abff2575b8..69e62f823362 100644 --- a/fs/autofs/root.c +++ b/fs/autofs/root.c @@ -108,10 +108,6 @@ static int autofs_root_lookup(struct inode *dir, const char *name, int len, *result = NULL; if (!dir) return -ENOENT; - - if (len > NAME_MAX) - return -ENOENT; - if (!S_ISDIR(dir->i_mode)) { iput(dir); return -ENOTDIR; @@ -198,9 +194,6 @@ static int autofs_root_symlink(struct inode *dir, const char *name, int len, con iput(dir); return -EPERM; } - if ( len > NAME_MAX) - return -ENAMETOOLONG; - if ( autofs_hash_lookup(dh,hash,name,len) ) { iput(dir); return -EEXIST; @@ -259,9 +252,6 @@ static int autofs_root_unlink(struct inode *dir, const char *name, int len) if ( !autofs_oz_mode(sbi) ) return -EPERM; - - if(len > NAME_MAX) - return -ENAMETOOLONG; ent = autofs_hash_lookup(dh,hash,name,len); if ( !ent ) diff --git a/fs/ext2/fsync.c b/fs/ext2/fsync.c index 45962dc8f553..7248144eadd9 100644 --- a/fs/ext2/fsync.c +++ b/fs/ext2/fsync.c @@ -10,8 +10,6 @@ * linux/fs/minix/truncate.c Copyright (C) 1991, 1992 Linus Torvalds * * ext2fs fsync primitive - * - * Fast 'fsync' on large files (Scott Laird ) */ #include @@ -175,13 +173,6 @@ int ext2_sync_file (struct inode * inode, struct file * file) */ goto skip; - /* fsync on large files is *slow*, so fall back to sync() if - * the file's over 10M */ - if (inode->i_size>10000000) { - file_fsync(inode,file); - goto skip; - } - for (wait=0; wait<=1; wait++) { err |= sync_direct (inode, wait); diff --git a/fs/ioctl.c b/fs/ioctl.c index e71978a8adc8..e746056e404b 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -60,57 +59,50 @@ asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) { struct file * filp; int on; - int retval = 0; - filp = fget(fd); - - if(filp==NULL) + if (fd >= NR_OPEN || !(filp = current->files->fd[fd])) return -EBADF; - switch (cmd) { case FIOCLEX: FD_SET(fd, ¤t->files->close_on_exec); - break; + return 0; case FIONCLEX: FD_CLR(fd, ¤t->files->close_on_exec); - break; + return 0; case FIONBIO: - retval = verify_area(VERIFY_READ, (unsigned int *)arg, + on = verify_area(VERIFY_READ, (unsigned int *)arg, sizeof(unsigned int)); - if(!retval) - { - on = get_user((unsigned int *) arg); - if (on) - filp->f_flags |= O_NONBLOCK; - else - filp->f_flags &= ~O_NONBLOCK; - } - break; + if(on) + return on; + on = get_user((unsigned int *) arg); + if (on) + filp->f_flags |= O_NONBLOCK; + else + filp->f_flags &= ~O_NONBLOCK; + return 0; case FIOASYNC: /* O_SYNC is not yet implemented, but it's here for completeness. */ - retval = verify_area(VERIFY_READ, (unsigned int *)arg, + on = verify_area(VERIFY_READ, (unsigned int *)arg, sizeof(unsigned int)); - if(!retval) - { - on = get_user ((unsigned int *) arg); - if (on) - filp->f_flags |= O_SYNC; - else - filp->f_flags &= ~O_SYNC; - } - break; + if(on) + return on; + on = get_user ((unsigned int *) arg); + if (on) + filp->f_flags |= O_SYNC; + else + filp->f_flags &= ~O_SYNC; + return 0; default: if (filp->f_inode && S_ISREG(filp->f_inode->i_mode)) - retval = file_ioctl(filp, cmd, arg); - else if (filp->f_op && filp->f_op->ioctl) - retval = filp->f_op->ioctl(filp->f_inode, filp, cmd, arg); - else - retval = -ENOTTY; + return file_ioctl(filp, cmd, arg); + + if (filp->f_op && filp->f_op->ioctl) + return filp->f_op->ioctl(filp->f_inode, filp, cmd, arg); + + return -ENOTTY; } - fput(filp, filp->f_inode); - return retval; } diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 24b0e08ee825..acf5db4c3e7f 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c @@ -32,13 +32,6 @@ */ #define IGNORE_WRONG_MULTI_VOLUME_SPECS -/* - * A home-burnt Joliet level 3 cd-rom with a 100 MB zip file had more than - * 100 file sections, so the limit should be larger than that. What does the - * ISO9660 standard say? (Ulrik Dickow ) - */ -#define MAX_FILE_SECTIONS 1000 - #ifdef LEAK_CHECK static int check_malloc = 0; static int check_bread = 0; @@ -554,17 +547,12 @@ struct super_block *isofs_read_super(struct super_block *s,void *data, return NULL; } -#ifdef DO_FUNKY_BROKEN_MEDIA_CHANGE_CHECK if(!check_disk_change(s->s_dev)) { return s; } if (s->u.isofs_sb.s_nls_iocharset) unload_nls(s->u.isofs_sb.s_nls_iocharset); if (opt.iocharset) kfree(opt.iocharset); -#else - check_disk_change(s->s_dev); - return s; -#endif out: /* Kick out for various error conditions */ brelse(bh); @@ -658,9 +646,8 @@ int isofs_bmap(struct inode * inode,int block) nextino = ino->u.isofs_i.i_next_section_ino; iput(ino); - if(++i > MAX_FILE_SECTIONS) { - printk("isofs_bmap: More than %d file sections ?!?, aborting...\n", - MAX_FILE_SECTIONS); + if(++i > 100) { + printk("isofs_bmap: More than 100 file sections ?!?, aborting...\n"); printk("isofs_bmap: ino=%lu block=%d firstext=%u size=%u nextino=%lu\n", inode->i_ino, block, firstext, (unsigned)size, nextino); return 0; @@ -701,10 +688,9 @@ static int isofs_read_level3_size(struct inode * inode) ino = inode->i_ino; i = 0; do { - if(i > MAX_FILE_SECTIONS) { - printk("isofs_read_level3_size: More than %d file sections ?!?, aborting...\n" - "isofs_read_level3_size: inode=%lu ino=%lu\n", MAX_FILE_SECTIONS, - inode->i_ino, ino); + if(i > 100) { + printk("isofs_read_level3_size: More than 100 file sections ?!?, aborting...\n" + "isofs_read_level3_size: inode=%lu ino=%lu\n", inode->i_ino, ino); return 0; } diff --git a/fs/locks.c b/fs/locks.c index 92b443a35cc5..f16b8a4d2da1 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -107,7 +107,6 @@ #include #include #include -#include #include #include @@ -256,25 +255,17 @@ asmlinkage int sys_flock(unsigned int fd, unsigned int cmd) { struct file_lock file_lock; struct file *filp; - int err = -EINVAL; - - filp = fget(fd); - if(filp==NULL) - return -EBADF; - - if (!flock_make_lock(filp, &file_lock, cmd)) - goto out; + if ((fd >= NR_OPEN) || !(filp = current->files->fd[fd])) + return (-EBADF); + if (!flock_make_lock(filp, &file_lock, cmd)) + return (-EINVAL); + if ((file_lock.fl_type != F_UNLCK) && !(filp->f_mode & 3)) - { - err = -EBADF; - goto out; - } - err=flock_lock_file(filp, &file_lock, (cmd & (LOCK_UN | LOCK_NB)) ? 0 : 1); -out: - fput(filp, filp->f_inode); - return err; + return (-EBADF); + + return (flock_lock_file(filp, &file_lock, (cmd & (LOCK_UN | LOCK_NB)) ? 0 : 1)); } /* Report the first existing lock that would conflict with l. @@ -287,27 +278,19 @@ int fcntl_getlk(unsigned int fd, struct flock *l) struct file *filp; struct file_lock *fl,file_lock; + if ((fd >= NR_OPEN) || !(filp = current->files->fd[fd])) + return (-EBADF); error = verify_area(VERIFY_WRITE, l, sizeof(*l)); if (error) return (error); - filp = fget(fd); - if(filp==NULL) - return -EBADF; - memcpy_fromfs(&flock, l, sizeof(flock)); if ((flock.l_type != F_RDLCK) && (flock.l_type != F_WRLCK)) - { - error = -EINVAL; - goto out; - } + return (-EINVAL); if (!filp->f_inode || !posix_make_lock(filp, &file_lock, &flock)) - { - error = -EINVAL; - goto out; - } - + return (-EINVAL); + flock.l_type = F_UNLCK; for (fl = filp->f_inode->i_flock; fl != NULL; fl = fl->fl_next) { if (!(fl->fl_flags & FL_POSIX)) @@ -324,9 +307,7 @@ int fcntl_getlk(unsigned int fd, struct flock *l) } memcpy_tofs(l, &flock, sizeof(flock)); -out: - fput(filp, filp->f_inode); - return error; + return (0); } /* Apply the lock described by l to an open file descriptor. @@ -345,20 +326,19 @@ int fcntl_setlk(unsigned int fd, unsigned int cmd, struct flock *l) /* Get arguments and validate them ... */ + if ((fd >= NR_OPEN) || !(filp = current->files->fd[fd])) + return (-EBADF); + error = verify_area(VERIFY_READ, l, sizeof(*l)); if (error) return (error); - - filp = fget(fd); - if(filp==NULL) - return -EBADF; - - inode = filp->f_inode; - + + if (!(inode = filp->f_inode)) + return (-EINVAL); + /* * This might block, so we do it before checking the inode. */ - memcpy_fromfs(&flock, l, sizeof(flock)); /* Don't allow mandatory locks on files that may be memory mapped @@ -370,34 +350,22 @@ int fcntl_setlk(unsigned int fd, unsigned int cmd, struct flock *l) struct vm_area_struct *vma = inode->i_mmap; do { if (vma->vm_flags & VM_MAYSHARE) - { - error = -EAGAIN; - goto out; - } + return (-EAGAIN); vma = vma->vm_next_share; } while (vma != inode->i_mmap); } if (!posix_make_lock(filp, &file_lock, &flock)) - { - error = -EINVAL; - goto out; - } + return (-EINVAL); switch (flock.l_type) { case F_RDLCK: if (!(filp->f_mode & 1)) - { - error = -EBADF; - goto out; - } + return (-EBADF); break; case F_WRLCK: if (!(filp->f_mode & 2)) - { - error = -EBADF; - goto out; - } + return (-EBADF); break; case F_UNLCK: break; @@ -416,19 +384,13 @@ int fcntl_setlk(unsigned int fd, unsigned int cmd, struct flock *l) } #endif if (!(filp->f_mode & 3)) - { - error = -EBADF; - goto out; - } + return (-EBADF); break; default: return (-EINVAL); } - error = posix_lock_file(filp, &file_lock, cmd == F_SETLKW); -out: - fput(filp, filp->f_inode); - return error; + return (posix_lock_file(filp, &file_lock, cmd == F_SETLKW)); } /* This function is called when the file is closed. diff --git a/fs/ncpfs/Config.in b/fs/ncpfs/Config.in deleted file mode 100644 index 6b21d399e4a0..000000000000 --- a/fs/ncpfs/Config.in +++ /dev/null @@ -1,9 +0,0 @@ -# -# NCP Filesystem configuration -# -bool ' Packet singatures' CONFIG_NCPFS_PACKET_SIGNING -bool ' Proprietary file locking' CONFIG_NCPFS_IOCTL_LOCKING -bool ' Clear remove/delete inhibit when needed' CONFIG_NCPFS_STRONG -bool ' Use NFS namespace if available' CONFIG_NCPFS_NFS_NS -bool ' Use LONG (OS/2) namespace if available' CONFIG_NCPFS_OS2_NS -bool ' Allow mounting of volume subdirectories' CONFIG_NCPFS_MOUNT_SUBDIR diff --git a/fs/ncpfs/Makefile b/fs/ncpfs/Makefile index f009ad53b137..be43c491b180 100644 --- a/fs/ncpfs/Makefile +++ b/fs/ncpfs/Makefile @@ -8,8 +8,7 @@ # Note 2! The CFLAGS definitions are now in the main makefile... O_TARGET := ncpfs.o -O_OBJS := dir.o file.o inode.o ioctl.o mmap.o ncplib_kernel.o sock.o \ - ncpsign_kernel.o +O_OBJS := dir.o file.o inode.o ioctl.o mmap.o ncplib_kernel.o sock.o M_OBJS := $(O_TARGET) # If you want debugging output, please uncomment the following line diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index 4496bdc6fc4f..9d9c7d58c70c 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c @@ -5,8 +5,6 @@ * */ -#include - #include #include #include @@ -105,14 +103,7 @@ ncp_namespace(struct inode *i) static inline int ncp_preserve_case(struct inode *i) { - return -#ifdef CONFIG_NCPFS_OS2_NS - (ncp_namespace(i) == NW_NS_OS2) || -#endif /* CONFIG_NCPFS_OS2_NS */ -#ifdef CONFIG_NCPFS_NFS_NS - (ncp_namespace(i) == NW_NS_NFS) || -#endif /* CONFIG_NCPFS_NFS_NS */ - 0; + return (ncp_namespace(i) == NW_NS_OS2); } static struct file_operations ncp_dir_operations = { @@ -166,7 +157,7 @@ inline ino_t ncp_info_ino(struct ncp_server *server, struct ncp_inode_info *info) { return ncp_single_volume(server) - ? (info->finfo.i.dirEntNum == server->root.finfo.i.dirEntNum)?0:info->finfo.i.dirEntNum: (ino_t)info; + ? info->finfo.i.dirEntNum : (ino_t)info; } static inline int @@ -946,7 +937,6 @@ ncp_create(struct inode *dir, const char *name, int len, int mode, { struct nw_file_info finfo; __u8 _name[len+1]; - int error; *result = NULL; @@ -971,18 +961,15 @@ ncp_create(struct inode *dir, const char *name, int len, int mode, } lock_super(dir->i_sb); - if ((error = ncp_open_create_file_or_subdir(NCP_SERVER(dir), + if (ncp_open_create_file_or_subdir(NCP_SERVER(dir), NCP_ISTRUCT(dir), _name, OC_MODE_CREATE|OC_MODE_OPEN| OC_MODE_REPLACE, 0, AR_READ|AR_WRITE, - &finfo)) != 0) + &finfo) != 0) { unlock_super(dir->i_sb); iput(dir); - if (error == 0x87) { - return -ENAMETOOLONG; - } return -EACCES; } @@ -1108,65 +1095,6 @@ ncp_rmdir(struct inode *dir, const char *name, int len) return error; } - -#ifdef CONFIG_NCPFS_STRONG -/* try to delete a readonly file (NW R bit set) */ - -static int -ncp_force_unlink(struct inode *dir,char *name,int len) -{ - int res=0x9c,res2; - struct inode *_inode; - struct iattr ia; - - /* remove the Read-Only flag on the NW server */ - - dir->i_count++; - res2=ncp_lookup(dir,name,len,&_inode); - if (res2) - { - goto leave_me; /* abort operation */ - } - memset(&ia,0,sizeof(struct iattr)); - ia.ia_mode = _inode->i_mode; - ia.ia_mode |= NCP_SERVER(dir)->m.file_mode & 0222; /* set write bits */ - ia.ia_valid = ATTR_MODE; - - res2=ncp_notify_change(_inode,&ia); - if (res2) - { - iput(_inode); - goto leave_me; - } - - /* now try again the delete operation */ - - res2 = ncp_del_file_or_subdir(NCP_SERVER(dir),NCP_ISTRUCT(dir),name); - - res=res2; /* save status to use as return value */ - - res=res2; - if (res2) /* delete failed, set R bit again */ - { - memset(&ia,0,sizeof(struct iattr)); - ia.ia_mode = _inode->i_mode; - ia.ia_mode &= ~(NCP_SERVER(dir)->m.file_mode & 0222); /* clear write bits */ - ia.ia_valid = ATTR_MODE; - - res2=ncp_notify_change(_inode,&ia); - if (res2) - { - iput(_inode); - goto leave_me; - } - } - iput(_inode); - - leave_me: - return(res); -} -#endif /* CONFIG_NCPFS_STRONG */ - static int ncp_unlink(struct inode *dir, const char *name, int len) { @@ -1198,21 +1126,14 @@ ncp_unlink(struct inode *dir, const char *name, int len) str_upper(_name); } - error = ncp_del_file_or_subdir(NCP_SERVER(dir), - NCP_ISTRUCT(dir), - _name); -#ifdef CONFIG_NCPFS_STRONG - if (error == 0x9c && NCP_SERVER(dir)->m.flags & NCP_MOUNT_STRONG) /* readonly */ + if ((error = ncp_del_file_or_subdir(NCP_SERVER(dir), + NCP_ISTRUCT(dir), + _name)) == 0) { - error = ncp_force_unlink(dir,_name,len); /* special treatment */ + ncp_invalid_dir_cache(dir); } -#endif /* CONFIG_NCPFS_STRONG */ - - if (error == 0) { - ncp_invalid_dir_cache(dir); - } else if (error == 0xFF) { - error = -ENOENT; - } else { + else + { error = -EACCES; } } @@ -1220,83 +1141,6 @@ ncp_unlink(struct inode *dir, const char *name, int len) return error; } -#ifdef CONFIG_NCPFS_STRONG -static int -ncp_force_rename(struct inode *old_dir, const char *old_name, char *_old_name, int old_len, - struct inode *new_dir, const char *new_name, char *_new_name, int new_len) -{ - int res=0x90,res2; - char _rename_old[old_len+1]; - char _rename_new[new_len+1]; - struct inode *_inode,*x_dir; - struct iattr ia; - - strncpy(_rename_old,old_name,old_len); - _rename_old[old_len] = 0; - strncpy(_rename_new,new_name,new_len); - _rename_new[new_len] = 0; - - /* remove the Read-Only flag on the NW server */ - - old_dir->i_count++; - res2=ncp_lookup(old_dir,_rename_old,old_len,&_inode); - if (res2) - { - goto leave_me; - } - memset(&ia,0,sizeof(struct iattr)); - ia.ia_mode = _inode->i_mode; - ia.ia_mode |= NCP_SERVER(old_dir)->m.file_mode & 0222; /* set write bits */ - ia.ia_valid = ATTR_MODE; - - res2=ncp_notify_change(_inode,&ia); - if (res2) - { - iput(_inode); - goto leave_me; - } - - /* now try again the rename operation */ - res2 = ncp_ren_or_mov_file_or_subdir(NCP_SERVER(old_dir), - NCP_ISTRUCT(old_dir), _old_name, - NCP_ISTRUCT(new_dir), _new_name); - - res=res2; - if (!res2) /* rename succeeded, get a new inode for the new file */ - { - x_dir=new_dir; - new_dir->i_count++; - iput(_inode); - res2=ncp_lookup(new_dir,_rename_new,new_len,&_inode); - if (res2) - { - goto leave_me; - } - } - else - { - x_dir=old_dir; - } - - memset(&ia,0,sizeof(struct iattr)); - ia.ia_mode = _inode->i_mode; - ia.ia_mode &= ~(NCP_SERVER(x_dir)->m.file_mode & 0222); /* clear write bits */ - ia.ia_valid = ATTR_MODE; - - res2=ncp_notify_change(_inode,&ia); - iput(_inode); - if (res2) - { - printk(KERN_INFO "ncpfs: ncp_notify_change (2) failed: %08x\n",res2); - goto leave_me; - } - - leave_me: - return(res); -} -#endif /* CONFIG_NCPFS_STRONG */ - - static int ncp_rename(struct inode *old_dir, const char *old_name, int old_len, struct inode *new_dir, const char *new_name, int new_len, @@ -1353,26 +1197,14 @@ ncp_rename(struct inode *old_dir, const char *old_name, int old_len, NCP_ISTRUCT(old_dir), _old_name, NCP_ISTRUCT(new_dir), _new_name); -#ifdef CONFIG_NCPFS_STRONG - if (res == 0x90 && NCP_SERVER(old_dir)->m.flags & NCP_MOUNT_STRONG) /* file is readonly */ + if (res == 0) { - res=ncp_force_rename(old_dir,old_name,_old_name,old_len,new_dir,new_name,_new_name,new_len); - } -#endif /* CONFIG_NCPFS_STRONG */ - - if (res == 0) - { - ncp_invalid_dir_cache(old_dir); - ncp_invalid_dir_cache(new_dir); - } + ncp_invalid_dir_cache(old_dir); + ncp_invalid_dir_cache(new_dir); + } else { - if (res == 0x9E) - res = -ENAMETOOLONG; - else if (res == 0xFF) - res = -ENOENT; - else - res = -EACCES; + res = -EACCES; } finished: diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c index d96a00f273eb..72ec823a5317 100644 --- a/fs/ncpfs/inode.c +++ b/fs/ncpfs/inode.c @@ -32,6 +32,7 @@ static void ncp_put_inode(struct inode *); static void ncp_read_inode(struct inode *); static void ncp_put_super(struct super_block *); static void ncp_statfs(struct super_block *sb, struct statfs *buf, int bufsiz); +static int ncp_notify_change(struct inode *inode, struct iattr *attr); static struct super_operations ncp_sops = { ncp_read_inode, /* read inode */ @@ -82,9 +83,6 @@ ncp_read_inode(struct inode *inode) else { inode->i_mode = NCP_SERVER(inode)->m.file_mode; -#if 1 - if (NCP_ISTRUCT(inode)->attributes & /* 0x60001 incl. DiRi */ 1) inode->i_mode &= ~0222; -#endif inode->i_size = NCP_ISTRUCT(inode)->dataStreamSize; } @@ -146,11 +144,10 @@ ncp_put_inode(struct inode *inode) */ lock_super(sb); - if (inode->i_count > 1) - { - printk("ncp_put_inode: inode in use device %s, inode %ld, count=%ld\n", - kdevname(inode->i_dev), inode->i_ino, inode->i_count); - goto unlock; + if (inode->i_count > 1) { +printk("ncp_put_inode: inode in use device %s, inode %ld, count=%ld\n", +kdevname(inode->i_dev), inode->i_ino, inode->i_count); + goto unlock; } DDPRINTK("ncp_put_inode: put %s\n", @@ -201,9 +198,6 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent) struct file *msg_filp; kdev_t dev = sb->s_dev; int error; -#ifdef CONFIG_NCPFS_PACKET_SIGNING - int options; -#endif if (data == NULL) { @@ -280,10 +274,7 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent) server->packet = NULL; server->buffer_size = 0; server->conn_status = 0; -#ifdef CONFIG_NCPFS_PACKET_SIGNING - server->sign_wanted = 0; - server->sign_active = 0; -#endif + server->m = *data; server->m.file_mode = (server->m.file_mode & (S_IRWXU|S_IRWXG|S_IRWXO)) | S_IFREG; @@ -351,29 +342,6 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent) goto disconnect; } -#ifdef CONFIG_NCPFS_PACKET_SIGNING - if (ncp_negotiate_size_and_options(server, NCP_DEFAULT_BUFSIZE, - NCP_DEFAULT_OPTIONS, &(server->buffer_size), &options) == 0) - { - if (options != NCP_DEFAULT_OPTIONS) - { - if (ncp_negotiate_size_and_options(server, - NCP_DEFAULT_BUFSIZE, - options & 2, - &(server->buffer_size), &options) != 0) - - { - sb->s_dev = 0; - printk("ncp_read_super: " - "could not set options\n"); - goto disconnect; - } - } - if (options & 2) - server->sign_wanted = 1; - } - else -#endif /* CONFIG_NCPFS_PACKET_SIGNING */ if (ncp_negotiate_buffersize(server, NCP_DEFAULT_BUFSIZE, &(server->buffer_size)) != 0) { @@ -481,7 +449,7 @@ ncp_statfs(struct super_block *sb, struct statfs *buf, int bufsiz) memcpy_tofs(buf, &tmp, bufsiz); } -int +static int ncp_notify_change(struct inode *inode, struct iattr *attr) { int result = 0; @@ -512,33 +480,6 @@ ncp_notify_change(struct inode *inode, struct iattr *attr) info_mask = 0; memset(&info, 0, sizeof(info)); -#if 1 - if ((attr->ia_valid & ATTR_MODE) != 0) - { - if (NCP_ISTRUCT(inode)->attributes & aDIR) - { - return -EPERM; - } - else - { - umode_t newmode; - - info_mask |= DM_ATTRIBUTES; - newmode=attr->ia_mode; - newmode &= NCP_SERVER(inode)->m.file_mode; - - if (newmode & 0222) /* any write bit set */ - { - info.attributes &= ~0x60001; - } - else - { - info.attributes |= 0x60001; - } - } - } -#endif - if ((attr->ia_valid & ATTR_CTIME) != 0) { info_mask |= (DM_CREATE_TIME|DM_CREATE_DATE); diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c index d8dac13fecd4..4350fdd6561a 100644 --- a/fs/ncpfs/ioctl.c +++ b/fs/ncpfs/ioctl.c @@ -5,8 +5,6 @@ * */ -#include - #include #include #include @@ -15,7 +13,6 @@ #include #include #include -#include "ncplib_kernel.h" int ncp_ioctl (struct inode * inode, struct file * filp, @@ -155,242 +152,6 @@ ncp_ioctl (struct inode * inode, struct file * filp, put_fs_word(server->m.mounted_uid, (uid_t*) arg); return 0; -#if 0 - case NCP_IOC_GETMOUNTUID_INT: - if ( (permission(inode, MAY_READ) != 0) - && (current->uid != server->m.mounted_uid)) - { - return -EACCES; - } - - if ((result = verify_area(VERIFY_WRITE, (unsigned int*)arg, - sizeof(unsigned int))) != 0) - { - return result; - } - { - unsigned int tmp=server->m.mounted_uid; - put_fs_long(tmp, (unsigned int*) arg); - } - return 0; -#endif - -#ifdef CONFIG_NCPFS_MOUNT_SUBDIR - case NCP_IOC_GETROOT: - { - struct ncp_setroot_ioctl sr; - - if ( (permission(inode, MAY_READ) != 0) - && (current->uid != server->m.mounted_uid)) - { - return -EACCES; - } - if (server->m.mounted_vol[0]) { - sr.volNumber = server->root.finfo.i.volNumber; - sr.dirEntNum = server->root.finfo.i.dirEntNum; - sr.namespace = server->name_space[sr.volNumber]; - } else { - sr.volNumber = -1; - sr.namespace = 0; - sr.dirEntNum = 0; - } - if ((result = verify_area(VERIFY_WRITE, - (struct ncp_setroot_ioctl*)arg, - sizeof(sr))) != 0) - { - return result; - } - memcpy_tofs((struct ncp_setroot_ioctl*)arg, - &sr, sizeof(sr)); - return 0; - } - case NCP_IOC_SETROOT: - { - struct ncp_setroot_ioctl sr; - - if ( (permission(inode, MAY_WRITE) != 0) - && (current->uid != server->m.mounted_uid)) - { - return -EACCES; - } - if ((result = verify_area(VERIFY_READ, - (struct ncp_setroot_ioctl*)arg, - sizeof(sr))) != 0) - { - return result; - } - memcpy_fromfs(&sr, (struct ncp_setroot_ioctl*)arg, sizeof(sr)); - if (sr.volNumber < 0) { - server->m.mounted_vol[0] = 0; - server->root.finfo.i.volNumber = 0; - server->root.finfo.i.dirEntNum = 0; - } else if (sr.volNumber >= NCP_NUMBER_OF_VOLUMES) { - return -EINVAL; - } else { - if (ncp_mount_subdir(server, sr.volNumber, sr.namespace, sr.dirEntNum)) { - return -ENOENT; - } - } - return 0; - } -#endif /* CONFIG_NCPFS_MOUNT_SUBDIR */ - -#ifdef CONFIG_NCPFS_PACKET_SIGNING - case NCP_IOC_SIGN_INIT: - if ((permission(inode, MAY_WRITE) != 0) - && (current->uid != server->m.mounted_uid)) - { - return -EACCES; - } - if ((result = verify_area(VERIFY_READ, (struct ncp_sign_init*)arg, - sizeof(struct ncp_sign_init))) != 0) - { - return result; - } - if (server->sign_active) - { - return -EINVAL; - } - if (server->sign_wanted) - { - struct ncp_sign_init sign; - - memcpy_fromfs(&sign, (struct ncp_sign_init *) arg, - sizeof(sign)); - memcpy(server->sign_root,sign.sign_root,8); - memcpy(server->sign_last,sign.sign_last,16); - server->sign_active = 1; - } - /* ignore when signatures not wanted */ - return 0; - - case NCP_IOC_SIGN_WANTED: - if ( (permission(inode, MAY_READ) != 0) - && (current->uid != server->m.mounted_uid)) - { - return -EACCES; - } - if ((result = verify_area(VERIFY_WRITE, (int*) arg, - sizeof(int))) != 0) - { - return result; - } - /* Should not it be put_fs_long? Vandrove@vc.cvut.cz */ - put_fs_word(server->sign_wanted, (int*) arg); - return 0; - - case NCP_IOC_SET_SIGN_WANTED: - { - int newstate; - - if ( (permission(inode, MAY_WRITE) != 0) - && (current->uid != server->m.mounted_uid)) - { - return -EACCES; - } - if ((result = verify_area(VERIFY_READ, (int*) arg, - sizeof(int))) != 0) - { - return result; - } - /* get only low 8 bits... */ - newstate = get_fs_byte((unsigned char*)arg); - if (server->sign_active) { - /* cannot turn signatures OFF when active */ - if (!newstate) return -EINVAL; - } else { - server->sign_wanted = newstate != 0; - } - return 0; - } - -#endif /* CONFIG_NCPFS_PACKET_SIGNING */ - -#ifdef CONFIG_NCPFS_IOCTL_LOCKING - case NCP_IOC_LOCKUNLOCK: - if ( (permission(inode, MAY_WRITE) != 0) - && (current->uid != server->m.mounted_uid)) - { - return -EACCES; - } - { - struct ncp_lock_ioctl rqdata; - struct nw_file_info *finfo; - int result; - - if ((result = verify_area(VERIFY_READ, - (struct ncp_lock_ioctl*)arg, - sizeof(rqdata))) != 0) - { - return result; - } - memcpy_fromfs(&rqdata, (struct ncp_lock_ioctl*)arg, - sizeof(rqdata)); - if (rqdata.origin != 0) - return -EINVAL; - /* check for cmd */ - switch (rqdata.cmd) { - case NCP_LOCK_EX: - case NCP_LOCK_SH: - if (rqdata.timeout == 0) - rqdata.timeout = NCP_LOCK_DEFAULT_TIMEOUT; - else if (rqdata.timeout > NCP_LOCK_MAX_TIMEOUT) - rqdata.timeout = NCP_LOCK_MAX_TIMEOUT; - break; - case NCP_LOCK_LOG: - rqdata.timeout = NCP_LOCK_DEFAULT_TIMEOUT; /* has no effect */ - case NCP_LOCK_CLEAR: - break; - default: - return -EINVAL; - } - if ((result = ncp_make_open(inode, O_RDWR)) != 0) - { - return result; - } - if (!ncp_conn_valid(server)) - { - return -EIO; - } - if (!S_ISREG(inode->i_mode)) - { - return -EISDIR; - } - finfo=NCP_FINFO(inode); - if (!finfo->opened) - { - return -EBADFD; - } - if (rqdata.cmd == NCP_LOCK_CLEAR) - { - result = ncp_ClearPhysicalRecord(NCP_SERVER(inode), - finfo->file_handle, - rqdata.offset, - rqdata.length); - if (result > 0) result = 0; /* no such lock */ - } - else - { - int lockcmd; - - switch (rqdata.cmd) - { - case NCP_LOCK_EX: lockcmd=1; break; - case NCP_LOCK_SH: lockcmd=3; break; - default: lockcmd=0; break; - } - result = ncp_LogPhysicalRecord(NCP_SERVER(inode), - finfo->file_handle, - lockcmd, - rqdata.offset, - rqdata.length, - rqdata.timeout); - if (result > 0) result = -EAGAIN; - } - return result; - } -#endif /* CONFIG_NCPFS_IOCTL_LOCKING */ - default: return -EINVAL; } diff --git a/fs/ncpfs/ncplib_kernel.c b/fs/ncpfs/ncplib_kernel.c index 134aa2981f7b..625193f14ae9 100644 --- a/fs/ncpfs/ncplib_kernel.c +++ b/fs/ncpfs/ncplib_kernel.c @@ -5,8 +5,6 @@ * */ -#include - #include "ncplib_kernel.h" typedef __u8 byte; @@ -131,33 +129,6 @@ ncp_reply_dword(struct ncp_server *server, int offset) return *(dword *)(ncp_reply_data(server, offset)); } - -/* options: - * bit 0 ipx checksum - * bit 1 packet signing - */ -int -ncp_negotiate_size_and_options(struct ncp_server *server, - int size, int options, int *ret_size, int *ret_options) { - int result; - - ncp_init_request(server); - ncp_add_word(server, htons(size)); - ncp_add_byte(server, options); - - if ((result = ncp_request(server, 0x61)) != 0) - { - ncp_unlock_server(server); - return result; - } - - *ret_size = min(ntohs(ncp_reply_word(server, 0)), size); - *ret_options = ncp_reply_byte(server, 4); - - ncp_unlock_server(server); - return 0; -} - int ncp_negotiate_buffersize(struct ncp_server *server, int size, int *target) @@ -290,7 +261,7 @@ ncp_obtain_info(struct ncp_server *server, ncp_add_byte(server, 6); /* subfunction */ ncp_add_byte(server, server->name_space[vol_num]); ncp_add_byte(server, server->name_space[vol_num]); - ncp_add_word(server, 0x8006); /* get all */ + ncp_add_word(server, 0xff); /* get all */ ncp_add_dword(server, RIM_ALL); ncp_add_handle_path(server, vol_num, dir_base, 1, path); @@ -306,9 +277,8 @@ ncp_obtain_info(struct ncp_server *server, } static inline int -ncp_get_known_namespace(struct ncp_server *server, __u8 volume) +ncp_has_os2_namespace(struct ncp_server *server, __u8 volume) { -#if defined(CONFIG_NCPFS_OS2_NS) || defined(CONFIG_NCPFS_NFS_NS) int result; __u8 *namespace; __u16 no_namespaces; @@ -321,10 +291,9 @@ ncp_get_known_namespace(struct ncp_server *server, __u8 volume) if ((result = ncp_request(server, 87)) != 0) { ncp_unlock_server(server); - return NW_NS_DOS; + return 0; } - result=NW_NS_DOS; no_namespaces = ncp_reply_word(server, 0); namespace = ncp_reply_data(server, 2); @@ -332,104 +301,16 @@ ncp_get_known_namespace(struct ncp_server *server, __u8 volume) { DPRINTK("get_namespaces: found %d on %d\n", *namespace,volume); -#ifdef CONFIG_NCPFS_NFS_NS - if ((*namespace == NW_NS_NFS) && !(server->m.flags&NCP_MOUNT_NO_NFS)) - { - result = NW_NS_NFS; - break; - } -#endif /* CONFIG_NCPFS_NFS_NS */ -#ifdef CONFIG_NCPFS_OS2_NS - if ((*namespace == NW_NS_OS2) && !(server->m.flags&NCP_MOUNT_NO_OS2)) + if (*namespace == 4) { - result = NW_NS_OS2; + DPRINTK("get_namespaces: found OS2\n"); + ncp_unlock_server(server); + return 1; } -#endif /* CONFIG_NCPFS_OS2_NS */ namespace += 1; no_namespaces -= 1; } ncp_unlock_server(server); - return result; -#else /* neither OS2 nor NFS - only DOS */ - return NW_NS_DOS; -#endif /* defined(CONFIG_NCPFS_OS2_NS) || defined(CONFIG_NCPFS_NFS_NS) */ -} - -static int -ncp_ObtainSpecificDirBase(struct ncp_server *server, - __u8 nsSrc, __u8 nsDst, __u8 vol_num, __u32 dir_base, - char *path, /* At most 1 component */ - __u32 *dirEntNum) -{ - int result; - - ncp_init_request(server); - ncp_add_byte(server, 6); /* subfunction */ - ncp_add_byte(server, nsSrc); - ncp_add_byte(server, nsDst); - ncp_add_word(server, 0x8006); /* get all */ - ncp_add_dword(server, RIM_ALL); - ncp_add_handle_path(server, vol_num, dir_base, 1, path); - - if ((result = ncp_request(server, 87)) != 0) - { - ncp_unlock_server(server); - return result; - } - - if (dirEntNum) - *dirEntNum = ncp_reply_dword(server, 0x30); - ncp_unlock_server(server); - return 0; -} - -int -ncp_mount_subdir(struct ncp_server *server, - __u8 volNumber, - __u8 srcNS, __u32 dirEntNum) -{ - int dstNS; - int result; - __u32 newDirEnt; - - dstNS = ncp_get_known_namespace(server, volNumber); - if ((result = ncp_ObtainSpecificDirBase(server, srcNS, dstNS, volNumber, - dirEntNum, NULL, &newDirEnt)) != 0) - { - return result; - } - server->name_space[volNumber] = dstNS; - server->root.finfo.i.volNumber = volNumber; - server->root.finfo.i.dirEntNum = newDirEnt; - server->m.mounted_vol[1] = 0; - server->m.mounted_vol[0] = 'X'; - return 0; -} - -static int -ncp_obtain_DOS_dir_base(struct ncp_server *server, - struct nw_info_struct* file, - char *path, /* At most 1 component */ - __u32 *DOS_dir_base) -{ - int result; - - ncp_init_request(server); - ncp_add_byte(server, 6); /* subfunction */ - ncp_add_byte(server, server->name_space[file->volNumber]); - ncp_add_byte(server, server->name_space[file->volNumber]); - ncp_add_word(server, 0x8006); /* get all */ - ncp_add_dword(server, RIM_DIRECTORY); - ncp_add_handle_path(server, file->volNumber, file->dirEntNum, 1, path); - - if ((result = ncp_request(server, 87)) != 0) - { - ncp_unlock_server(server); - return result; - } - - if (DOS_dir_base) *DOS_dir_base=ncp_reply_dword(server, 0x34); - ncp_unlock_server(server); return 0; } @@ -467,8 +348,7 @@ ncp_lookup_volume(struct ncp_server *server, target->volNumber = volnum = ncp_reply_byte(server, 8); ncp_unlock_server(server); - server->name_space[volnum] = - ncp_get_known_namespace(server, volnum); + server->name_space[volnum] = ncp_has_os2_namespace(server,volnum)?4:0; DPRINTK("lookup_vol: namespace[%d] = %d\n", volnum, server->name_space[volnum]); @@ -503,44 +383,25 @@ ncp_modify_file_or_subdir_dos_info(struct ncp_server *server, return result; } -static int -ncp_DeleteNSEntry(struct ncp_server *server, - __u8 have_dir_base, __u8 volume, __u32 dir_base, - char* name, __u8 ns, int attr) +int +ncp_del_file_or_subdir(struct ncp_server *server, + struct nw_info_struct *dir, char *name) { int result; ncp_init_request(server); ncp_add_byte(server, 8); /* subfunction */ - ncp_add_byte(server, ns); /* namespace */ + ncp_add_byte(server, server->name_space[dir->volNumber]); ncp_add_byte(server, 0); /* reserved */ - ncp_add_word(server, attr); /* search attribs */ - ncp_add_handle_path(server, volume, dir_base, have_dir_base, name); + ncp_add_word(server, 0x8006); /* search attribs: all */ + ncp_add_handle_path(server, dir->volNumber, + dir->dirEntNum, 1, name); result = ncp_request(server, 87); ncp_unlock_server(server); return result; } -int -ncp_del_file_or_subdir(struct ncp_server *server, - struct nw_info_struct *dir, char *name) -{ -#ifdef CONFIG_NCPFS_NFS_NS - if (server->name_space[dir->volNumber]==NW_NS_NFS) - { - __u32 DOS_dir_base; - int result; - - result=ncp_obtain_DOS_dir_base(server, dir, name, &DOS_dir_base); - if (result) return result; - return ncp_DeleteNSEntry(server, 1, dir->volNumber, DOS_dir_base, NULL, NW_NS_DOS, 0x8006); - } - else -#endif /* CONFIG_NCPFS_NFS_NS */ - return ncp_DeleteNSEntry(server, 1, dir->volNumber, dir->dirEntNum, name, server->name_space[dir->volNumber], 0x8006); -} - static inline void ConvertToNWfromDWORD ( __u32 sfd , __u8 ret[6] ) { @@ -567,7 +428,7 @@ ncp_open_create_file_or_subdir(struct ncp_server *server, if ((create_attributes & aDIR) != 0) { search_attribs |= 0x8000; - } +} ncp_init_request(server); ncp_add_byte(server, 1); /* subfunction */ @@ -603,7 +464,7 @@ ncp_open_create_file_or_subdir(struct ncp_server *server, if (dir != NULL) { /* in target there's a new finfo to fill */ - ncp_extract_file_info(ncp_reply_data(server, 6), &(target->i)); + ncp_extract_file_info(ncp_reply_data(server, 5), &(target->i)); } ConvertToNWfromDWORD(target->server_file_handle, target->file_handle); @@ -650,21 +511,12 @@ ncp_search_for_file_or_subdir(struct ncp_server *server, ncp_add_byte(server, 3); /* subfunction */ ncp_add_byte(server, server->name_space[seq->volNumber]); ncp_add_byte(server, 0); /* data stream (???) */ - ncp_add_word(server, 0x8006); /* Search attribs */ + ncp_add_word(server, 0xffff); /* Search attribs */ ncp_add_dword(server, RIM_ALL); /* return info mask */ ncp_add_mem(server, seq, 9); -#ifdef CONFIG_NCPFS_NFS_NS - if (server->name_space[seq->volNumber]==NW_NS_NFS) - { - ncp_add_byte(server, 0); - } - else -#endif /* CONFIG_NCPFS_NFS_NS */ - { - ncp_add_byte(server, 2); /* 2 byte pattern */ - ncp_add_byte(server, 0xff); /* following is a wildcard */ - ncp_add_byte(server, '*'); - } + ncp_add_byte(server, 2); /* 2 byte pattern */ + ncp_add_byte(server, 0xff); /* following is a wildcard */ + ncp_add_byte(server, '*'); if ((result = ncp_request(server, 87)) != 0) { @@ -680,9 +532,9 @@ ncp_search_for_file_or_subdir(struct ncp_server *server, } int -ncp_RenameNSEntry(struct ncp_server *server, - struct nw_info_struct *old_dir, char *old_name, int old_type, - struct nw_info_struct *new_dir, char *new_name) +ncp_ren_or_mov_file_or_subdir(struct ncp_server *server, + struct nw_info_struct *old_dir, char *old_name, + struct nw_info_struct *new_dir, char *new_name) { int result; @@ -694,7 +546,7 @@ ncp_RenameNSEntry(struct ncp_server *server, ncp_add_byte(server, 4); /* subfunction */ ncp_add_byte(server, server->name_space[old_dir->volNumber]); ncp_add_byte(server, 1); /* rename flag */ - ncp_add_word(server, old_type); /* search attributes */ + ncp_add_word(server, 0x8006); /* search attributes */ /* source Handle Path */ ncp_add_byte(server, old_dir->volNumber); @@ -718,31 +570,6 @@ ncp_RenameNSEntry(struct ncp_server *server, return result; } -int -ncp_ren_or_mov_file_or_subdir(struct ncp_server *server, - struct nw_info_struct *old_dir, char *old_name, - struct nw_info_struct *new_dir, char *new_name) -{ - int result; - int old_type = 0x0006; - -/* If somebody can do it atomic, call me... vandrove@vc.cvut.cz */ - result = ncp_RenameNSEntry(server, old_dir, old_name, old_type, - new_dir, new_name); - if (result == 0xFF) /* File Not Found, try directory */ - { - old_type = 0x0016; - result = ncp_RenameNSEntry(server, old_dir, old_name, old_type, - new_dir, new_name); - } - if (result != 0x92) return result; /* All except NO_FILES_RENAMED */ - result = ncp_del_file_or_subdir(server, new_dir, new_name); - if (result != 0) return -EACCES; - result = ncp_RenameNSEntry(server, old_dir, old_name, old_type, - new_dir, new_name); - return result; -} - /* We have to transfer to/from user space */ int @@ -798,48 +625,3 @@ ncp_write(struct ncp_server *server, const char *file_id, return 0; } -#ifdef CONFIG_NCPFS_IOCTL_LOCKING -int -ncp_LogPhysicalRecord(struct ncp_server *server, const char *file_id, - __u8 locktype, __u32 offset, __u32 length, __u16 timeout) -{ - int result; - - ncp_init_request(server); - ncp_add_byte(server, locktype); - ncp_add_mem(server, file_id, 6); - ncp_add_dword(server, htonl(offset)); - ncp_add_dword(server, htonl(length)); - ncp_add_word(server, htons(timeout)); - - if ((result = ncp_request(server, 0x1A)) != 0) - { - ncp_unlock_server(server); - return result; - } - ncp_unlock_server(server); - return 0; -} - -int -ncp_ClearPhysicalRecord(struct ncp_server *server, const char *file_id, - __u32 offset, __u32 length) -{ - int result; - - ncp_init_request(server); - ncp_add_byte(server, 0); /* who knows... lanalyzer says that */ - ncp_add_mem(server, file_id, 6); - ncp_add_dword(server, htonl(offset)); - ncp_add_dword(server, htonl(length)); - - if ((result = ncp_request(server, 0x1E)) != 0) - { - ncp_unlock_server(server); - return result; - } - ncp_unlock_server(server); - return 0; -} -#endif /* CONFIG_NCPFS_IOCTL_LOCKING */ - diff --git a/fs/ncpfs/ncplib_kernel.h b/fs/ncpfs/ncplib_kernel.h index 1f4e1ee69d3f..d564bf31528b 100644 --- a/fs/ncpfs/ncplib_kernel.h +++ b/fs/ncpfs/ncplib_kernel.h @@ -8,8 +8,6 @@ #ifndef _NCPLIB_H #define _NCPLIB_H -#include - #include #include #include @@ -24,9 +22,6 @@ #include -int -ncp_negotiate_size_and_options(struct ncp_server *server, int size, - int options, int *ret_size, int *ret_options); int ncp_negotiate_buffersize(struct ncp_server *server, int size, int *target); @@ -170,22 +165,5 @@ ncp_ren_or_mov_file_or_subdir(struct ncp_server *server, struct nw_info_struct *old_dir, char *old_name, struct nw_info_struct *new_dir, char *new_name); -#ifdef CONFIG_NCPFS_IOCTL_LOCKING -int -ncp_LogPhysicalRecord(struct ncp_server *server, - const char *file_id, __u8 locktype, - __u32 offset, __u32 length, __u16 timeout); - -int -ncp_ClearPhysicalRecord(struct ncp_server *server, - const char *file_id, - __u32 offset, __u32 length); -#endif /* CONFIG_NCPFS_IOCTL_LOCKING */ - -#ifdef CONFIG_NCPFS_MOUNT_SUBDIR -int -ncp_mount_subdir(struct ncp_server* server, __u8 volNumber, - __u8 srcNS, __u32 srcDirEntNum); -#endif /* CONFIG_NCPFS_MOUNT_SUBDIR */ #endif /* _NCPLIB_H */ diff --git a/fs/ncpfs/ncpsign_kernel.c b/fs/ncpfs/ncpsign_kernel.c deleted file mode 100644 index 7b9015ec8d5a..000000000000 --- a/fs/ncpfs/ncpsign_kernel.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * ncpsign_kernel.c - * - * Arne de Bruijn (arne@knoware.nl), 1997 - * - */ - -#include - -#ifdef CONFIG_NCPFS_PACKET_SIGNING - -#if 0 -#ifdef MODULE -#include -#include -#endif -#endif - -#include -#include -#if 0 -#include -#include -#endif -#include "ncpsign_kernel.h" - -#define rol32(i,c) (((((i)&0xffffffff)<>(32-c))) -/* i386: 32-bit, little endian, handles mis-alignment */ -#ifdef __i386__ -#define GET_LE32(p) (*(int *)(p)) -#define PUT_LE32(p,v) { *(int *)(p)=v; } -#else -/* from include/ncplib.h */ -#define BVAL(buf,pos) (((__u8 *)(buf))[pos]) -#define PVAL(buf,pos) ((unsigned)BVAL(buf,pos)) -#define BSET(buf,pos,val) (BVAL(buf,pos) = (val)) - -static inline word -WVAL_LH(__u8 * buf, int pos) -{ - return PVAL(buf, pos) | PVAL(buf, pos + 1) << 8; -} -static inline dword -DVAL_LH(__u8 * buf, int pos) -{ - return WVAL_LH(buf, pos) | WVAL_LH(buf, pos + 2) << 16; -} -static inline void -WSET_LH(__u8 * buf, int pos, word val) -{ - BSET(buf, pos, val & 0xff); - BSET(buf, pos + 1, val >> 8); -} -static inline void -DSET_LH(__u8 * buf, int pos, dword val) -{ - WSET_LH(buf, pos, val & 0xffff); - WSET_LH(buf, pos + 2, val >> 16); -} - -#define GET_LE32(p) DVAL_LH(p,0) -#define PUT_LE32(p,v) DSET_LH(p,0,v) -#endif - -#define min(a,b) ((a)<(b)?(a):(b)) - -static void nwsign(char *r_data1, char *r_data2, char *outdata) { - int i; - unsigned int w0,w1,w2,w3; - static int rbit[4]={0, 2, 1, 3}; -#ifdef __i386__ - unsigned int *data2=(int *)r_data2; -#else - unsigned int data2[16]; - for (i=0;i<16;i++) - data2[i]=GET_LE32(r_data2+(i<<2)); -#endif - w0=GET_LE32(r_data1); - w1=GET_LE32(r_data1+4); - w2=GET_LE32(r_data1+8); - w3=GET_LE32(r_data1+12); - for (i=0;i<16;i+=4) { - w0=rol32(w0 + ((w1 & w2) | ((~w1) & w3)) + data2[i+0],3); - w3=rol32(w3 + ((w0 & w1) | ((~w0) & w2)) + data2[i+1],7); - w2=rol32(w2 + ((w3 & w0) | ((~w3) & w1)) + data2[i+2],11); - w1=rol32(w1 + ((w2 & w3) | ((~w2) & w0)) + data2[i+3],19); - } - for (i=0;i<4;i++) { - w0=rol32(w0 + (((w2 | w3) & w1) | (w2 & w3)) + 0x5a827999 + data2[i+0],3); - w3=rol32(w3 + (((w1 | w2) & w0) | (w1 & w2)) + 0x5a827999 + data2[i+4],5); - w2=rol32(w2 + (((w0 | w1) & w3) | (w0 & w1)) + 0x5a827999 + data2[i+8],9); - w1=rol32(w1 + (((w3 | w0) & w2) | (w3 & w0)) + 0x5a827999 + data2[i+12],13); - } - for (i=0;i<4;i++) { - w0=rol32(w0 + ((w1 ^ w2) ^ w3) + 0x6ed9eba1 + data2[rbit[i]+0],3); - w3=rol32(w3 + ((w0 ^ w1) ^ w2) + 0x6ed9eba1 + data2[rbit[i]+8],9); - w2=rol32(w2 + ((w3 ^ w0) ^ w1) + 0x6ed9eba1 + data2[rbit[i]+4],11); - w1=rol32(w1 + ((w2 ^ w3) ^ w0) + 0x6ed9eba1 + data2[rbit[i]+12],15); - } - PUT_LE32(outdata,(w0+GET_LE32(r_data1)) & 0xffffffff); - PUT_LE32(outdata+4,(w1+GET_LE32(r_data1+4)) & 0xffffffff); - PUT_LE32(outdata+8,(w2+GET_LE32(r_data1+8)) & 0xffffffff); - PUT_LE32(outdata+12,(w3+GET_LE32(r_data1+12)) & 0xffffffff); -} - -/* Make a signature for the current packet and add it at the end of the */ -/* packet. */ -void sign_packet(struct ncp_server *server, int *size) { - char data[64]; - - memset(data,0,64); - memcpy(data,server->sign_root,8); - PUT_LE32(data+8,(*size)); - memcpy(data+12,server->packet+sizeof(struct ncp_request_header)-1, - min((*size)-sizeof(struct ncp_request_header)+1,52)); - - nwsign(server->sign_last,data,server->sign_last); - - memcpy(server->packet+(*size),server->sign_last,8); - (*size)+=8; -} - -#endif /* CONFIG_NCPFS_PACKET_SIGNING */ - diff --git a/fs/ncpfs/ncpsign_kernel.h b/fs/ncpfs/ncpsign_kernel.h deleted file mode 100644 index 85974f346365..000000000000 --- a/fs/ncpfs/ncpsign_kernel.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * ncpsign_kernel.h - * - * Arne de Bruijn (arne@knoware.nl), 1997 - * - */ - -#ifndef _NCPSIGN_KERNEL_H -#define _NCPSIGN_KERNEL_H - -#include -#include - -void sign_packet(struct ncp_server *server, int *size); - -#endif diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c index c13b856e7fd9..e80b595c3dc4 100644 --- a/fs/ncpfs/sock.c +++ b/fs/ncpfs/sock.c @@ -7,8 +7,6 @@ * */ -#include - #include #include #include @@ -27,7 +25,6 @@ #include #include -#include "ncpsign_kernel.h" #define _S(nr) (1<<((nr)-1)) static int _recvfrom(struct socket *sock, unsigned char *ubuf, @@ -565,12 +562,7 @@ ncp_do_request(struct ncp_server *server, int size) printk("ncpfs: Server not locked!\n"); return -EIO; } -#ifdef CONFIG_NCPFS_PACKET_SIGNING - if (server->sign_active) - { - sign_packet(server, &size); - } -#endif /* CONFIG_NCPFS_PACKET_SIGNING */ + if (!ncp_conn_valid(server)) { return -EIO; diff --git a/fs/nls.c b/fs/nls.c index d8c85836c13a..74af3d021fa6 100644 --- a/fs/nls.c +++ b/fs/nls.c @@ -455,9 +455,6 @@ int init_nls(void) #ifdef CONFIG_NLS_ISO8859_9 init_nls_iso8859_9(); #endif -#ifdef CONFIG_NLS_ISO8859_15 - init_nls_iso8859_15(); -#endif #ifdef CONFIG_NLS_CODEPAGE_437 init_nls_cp437(); #endif diff --git a/fs/nls_iso8859_15.c b/fs/nls_iso8859_15.c deleted file mode 100644 index 33478bf9b1de..000000000000 --- a/fs/nls_iso8859_15.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * linux/fs/nls_iso8859-15.c - * - * Charset iso8859-15 translation tables. - * The Unicode to charset table has only exact mappings. - */ - -#include -#include -#include -#include - -static struct nls_unicode charset2uni[256] = { - /* 0x00*/ - {0x00, 0x00}, {0x01, 0x00}, {0x02, 0x00}, {0x03, 0x00}, - {0x04, 0x00}, {0x05, 0x00}, {0x06, 0x00}, {0x07, 0x00}, - {0x08, 0x00}, {0x09, 0x00}, {0x0a, 0x00}, {0x0b, 0x00}, - {0x0c, 0x00}, {0x0d, 0x00}, {0x0e, 0x00}, {0x0f, 0x00}, - /* 0x10*/ - {0x10, 0x00}, {0x11, 0x00}, {0x12, 0x00}, {0x13, 0x00}, - {0x14, 0x00}, {0x15, 0x00}, {0x16, 0x00}, {0x17, 0x00}, - {0x18, 0x00}, {0x19, 0x00}, {0x1a, 0x00}, {0x1b, 0x00}, - {0x1c, 0x00}, {0x1d, 0x00}, {0x1e, 0x00}, {0x1f, 0x00}, - /* 0x20*/ - {0x20, 0x00}, {0x21, 0x00}, {0x22, 0x00}, {0x23, 0x00}, - {0x24, 0x00}, {0x25, 0x00}, {0x26, 0x00}, {0x27, 0x00}, - {0x28, 0x00}, {0x29, 0x00}, {0x2a, 0x00}, {0x2b, 0x00}, - {0x2c, 0x00}, {0x2d, 0x00}, {0x2e, 0x00}, {0x2f, 0x00}, - /* 0x30*/ - {0x30, 0x00}, {0x31, 0x00}, {0x32, 0x00}, {0x33, 0x00}, - {0x34, 0x00}, {0x35, 0x00}, {0x36, 0x00}, {0x37, 0x00}, - {0x38, 0x00}, {0x39, 0x00}, {0x3a, 0x00}, {0x3b, 0x00}, - {0x3c, 0x00}, {0x3d, 0x00}, {0x3e, 0x00}, {0x3f, 0x00}, - /* 0x40*/ - {0x40, 0x00}, {0x41, 0x00}, {0x42, 0x00}, {0x43, 0x00}, - {0x44, 0x00}, {0x45, 0x00}, {0x46, 0x00}, {0x47, 0x00}, - {0x48, 0x00}, {0x49, 0x00}, {0x4a, 0x00}, {0x4b, 0x00}, - {0x4c, 0x00}, {0x4d, 0x00}, {0x4e, 0x00}, {0x4f, 0x00}, - /* 0x50*/ - {0x50, 0x00}, {0x51, 0x00}, {0x52, 0x00}, {0x53, 0x00}, - {0x54, 0x00}, {0x55, 0x00}, {0x56, 0x00}, {0x57, 0x00}, - {0x58, 0x00}, {0x59, 0x00}, {0x5a, 0x00}, {0x5b, 0x00}, - {0x5c, 0x00}, {0x5d, 0x00}, {0x5e, 0x00}, {0x5f, 0x00}, - /* 0x60*/ - {0x60, 0x00}, {0x61, 0x00}, {0x62, 0x00}, {0x63, 0x00}, - {0x64, 0x00}, {0x65, 0x00}, {0x66, 0x00}, {0x67, 0x00}, - {0x68, 0x00}, {0x69, 0x00}, {0x6a, 0x00}, {0x6b, 0x00}, - {0x6c, 0x00}, {0x6d, 0x00}, {0x6e, 0x00}, {0x6f, 0x00}, - /* 0x70*/ - {0x70, 0x00}, {0x71, 0x00}, {0x72, 0x00}, {0x73, 0x00}, - {0x74, 0x00}, {0x75, 0x00}, {0x76, 0x00}, {0x77, 0x00}, - {0x78, 0x00}, {0x79, 0x00}, {0x7a, 0x00}, {0x7b, 0x00}, - {0x7c, 0x00}, {0x7d, 0x00}, {0x7e, 0x00}, {0x7f, 0x00}, - /* 0x80*/ - {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, - {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, - {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, - {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, - /* 0x90*/ - {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, - {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, - {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, - {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, - /* 0xa0*/ - {0xa0, 0x00}, {0xa1, 0x00}, {0xa2, 0x00}, {0xa3, 0x00}, - {0xac, 0x20}, {0xa5, 0x00}, {0x60, 0x01}, {0xa7, 0x00}, - {0x61, 0x01}, {0xa9, 0x00}, {0xaa, 0x00}, {0xab, 0x00}, - {0xac, 0x00}, {0xad, 0x00}, {0xae, 0x00}, {0xaf, 0x00}, - /* 0xb0*/ - {0xb0, 0x00}, {0xb1, 0x00}, {0xb2, 0x00}, {0xb3, 0x00}, - {0x7d, 0x01}, {0xb5, 0x00}, {0xb6, 0x00}, {0xb7, 0x00}, - {0x7e, 0x01}, {0xb9, 0x00}, {0xba, 0x00}, {0xbb, 0x00}, - {0x52, 0x01}, {0x53, 0x01}, {0x78, 0x01}, {0xbf, 0x00}, - /* 0xc0*/ - {0xc0, 0x00}, {0xc1, 0x00}, {0xc2, 0x00}, {0xc3, 0x00}, - {0xc4, 0x00}, {0xc5, 0x00}, {0xc6, 0x00}, {0xc7, 0x00}, - {0xc8, 0x00}, {0xc9, 0x00}, {0xca, 0x00}, {0xcb, 0x00}, - {0xcc, 0x00}, {0xcd, 0x00}, {0xce, 0x00}, {0xcf, 0x00}, - /* 0xd0*/ - {0xd0, 0x00}, {0xd1, 0x00}, {0xd2, 0x00}, {0xd3, 0x00}, - {0xd4, 0x00}, {0xd5, 0x00}, {0xd6, 0x00}, {0xd7, 0x00}, - {0xd8, 0x00}, {0xd9, 0x00}, {0xda, 0x00}, {0xdb, 0x00}, - {0xdc, 0x00}, {0xdd, 0x00}, {0xde, 0x00}, {0xdf, 0x00}, - /* 0xe0*/ - {0xe0, 0x00}, {0xe1, 0x00}, {0xe2, 0x00}, {0xe3, 0x00}, - {0xe4, 0x00}, {0xe5, 0x00}, {0xe6, 0x00}, {0xe7, 0x00}, - {0xe8, 0x00}, {0xe9, 0x00}, {0xea, 0x00}, {0xeb, 0x00}, - {0xec, 0x00}, {0xed, 0x00}, {0xee, 0x00}, {0xef, 0x00}, - /* 0xf0*/ - {0xf0, 0x00}, {0xf1, 0x00}, {0xf2, 0x00}, {0xf3, 0x00}, - {0xf4, 0x00}, {0xf5, 0x00}, {0xf6, 0x00}, {0xf7, 0x00}, - {0xf8, 0x00}, {0xf9, 0x00}, {0xfa, 0x00}, {0xfb, 0x00}, - {0xfc, 0x00}, {0xfd, 0x00}, {0xfe, 0x00}, {0xff, 0x00}, -}; - -static unsigned char page00[256] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */ - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */ - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */ - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */ - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20-0x27 */ - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28-0x2f */ - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30-0x37 */ - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38-0x3f */ - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40-0x47 */ - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 0x48-0x4f */ - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50-0x57 */ - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 0x58-0x5f */ - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60-0x67 */ - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 0x68-0x6f */ - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70-0x77 */ - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, /* 0x78-0x7f */ - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ - 0xa0, 0xa1, 0xa2, 0xa3, 0x00, 0xa5, 0x00, 0xa7, /* 0xa0-0xa7 */ - 0x00, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */ - 0xb0, 0xb1, 0xb2, 0xb3, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ - 0x00, 0xb9, 0xba, 0xbb, 0x00, 0x00, 0x00, 0xbf, /* 0xb8-0xbf */ - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0-0xc7 */ - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */ - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xd0-0xd7 */ - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0xd8-0xdf */ - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0-0xe7 */ - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */ - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xf0-0xf7 */ - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0xf8-0xff */ -}; - -static unsigned char page01[256] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ - 0x00, 0x00, 0xbc, 0xbd, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ - 0xa6, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ - 0xbe, 0x00, 0x00, 0x00, 0x00, 0xb4, 0xb8, 0x00, /* 0x78-0x7f */ - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */ -}; - -static unsigned char page20[256] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ - 0x00, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */ -}; - -static unsigned char *page_uni2charset[256] = { - page00, page01, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - - page20, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -}; - -static void inc_use_count(void) -{ - MOD_INC_USE_COUNT; -} - -static void dec_use_count(void) -{ - MOD_DEC_USE_COUNT; -} - -static struct nls_table table = { - "iso8859-15", - page_uni2charset, - charset2uni, - inc_use_count, - dec_use_count, - NULL -}; - -int init_nls_iso8859_15(void) -{ - return register_nls(&table); -} - -#ifdef MODULE -int init_module(void) -{ - return init_nls_iso8859_15(); -} - - -void cleanup_module(void) -{ - unregister_nls(&table); - return; -} -#endif - -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-indent-level: 8 - * c-brace-imaginary-offset: 0 - * c-brace-offset: -8 - * c-argdecl-indent: 8 - * c-label-offset: -8 - * c-continued-statement-offset: 8 - * c-continued-brace-offset: 0 - * End: - */ diff --git a/fs/open.c b/fs/open.c index ae633d7033d3..1d1c94fac68d 100644 --- a/fs/open.c +++ b/fs/open.c @@ -68,10 +68,6 @@ int do_truncate(struct inode *inode, unsigned long length) int error; struct iattr newattrs; - /* Not pretty: "inode->i_size" shouldn't really be "off_t". But it is. */ - if ((off_t) length < 0) - return -EINVAL; - down(&inode->i_sem); newattrs.ia_size = length; newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; diff --git a/fs/proc/array.c b/fs/proc/array.c index d2e2323867e1..e76ecdcfb333 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -60,7 +60,6 @@ int get_malloc(char * buffer); #endif -extern unsigned long get_wchan(struct task_struct *); static int read_core(struct inode * inode, struct file * file,char * buf, int count) { @@ -412,6 +411,55 @@ static int get_arg(int pid, char * buffer) return get_array(p, (*p)->mm->arg_start, (*p)->mm->arg_end, buffer); } +unsigned long get_wchan(struct task_struct *p) +{ + if (!p || p == current || p->state == TASK_RUNNING) + return 0; +#if defined(__i386__) + { + unsigned long ebp, eip; + unsigned long stack_page; + int count = 0; + + stack_page = p->kernel_stack_page; + if (!stack_page) + return 0; + ebp = p->tss.ebp; + do { + if (ebp < stack_page || ebp >= 4092+stack_page) + return 0; + eip = *(unsigned long *) (ebp+4); + if (eip < (unsigned long) interruptible_sleep_on + || eip >= (unsigned long) add_timer) + return eip; + ebp = *(unsigned long *) ebp; + } while (count++ < 16); + } +#elif defined(__alpha__) + /* + * This one depends on the frame size of schedule(). Do a + * "disass schedule" in gdb to find the frame size. Also, the + * code assumes that sleep_on() follows immediately after + * interruptible_sleep_on() and that add_timer() follows + * immediately after interruptible_sleep(). Ugly, isn't it? + * Maybe adding a wchan field to task_struct would be better, + * after all... + */ + { + unsigned long schedule_frame; + unsigned long pc; + + pc = thread_saved_pc(&p->tss); + if (pc >= (unsigned long) interruptible_sleep_on && pc < (unsigned long) add_timer) { + schedule_frame = ((unsigned long *)p->tss.ksp)[6]; + return ((unsigned long *)schedule_frame)[12]; + } + return pc; + } +#endif + return 0; +} + #if defined(__i386__) # define KSTK_EIP(tsk) (((unsigned long *)tsk->kernel_stack_page)[1019]) # define KSTK_ESP(tsk) (((unsigned long *)tsk->kernel_stack_page)[1022]) diff --git a/fs/select.c b/fs/select.c index c53086de1d46..ccdbc6564491 100644 --- a/fs/select.c +++ b/fs/select.c @@ -347,8 +347,10 @@ asmlinkage int sys_select(int n, fd_set *inp, fd_set *outp, fd_set *exp, struct (fd_set *) &res_out, (fd_set *) &res_ex, (fd_set *) &locked); - timeout = current->timeout?current->timeout - jiffies - 1:0; + timeout = current->timeout - jiffies - 1; current->timeout = 0; + if ((long) timeout < 0) + timeout = 0; if (tvp && !(current->personality & STICKY_TIMEOUTS)) { put_user(timeout/HZ, &tvp->tv_sec); timeout %= HZ; diff --git a/include/asm-alpha/ioctls.h b/include/asm-alpha/ioctls.h index 0337b92b3db7..bb4f71de877e 100644 --- a/include/asm-alpha/ioctls.h +++ b/include/asm-alpha/ioctls.h @@ -83,8 +83,6 @@ #define TIOCGETD 0x5424 #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ #define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ -#define TIOCSBRK 0x5427 /* BSD compatibility */ -#define TIOCCBRK 0x5428 /* BSD compatibility */ #define TIOCSERCONFIG 0x5453 #define TIOCSERGWILD 0x5454 diff --git a/include/asm-i386/bugs.h b/include/asm-i386/bugs.h index a49c34ebee6b..6e26f6b28f23 100644 --- a/include/asm-i386/bugs.h +++ b/include/asm-i386/bugs.h @@ -132,24 +132,6 @@ static void check_tlb(void) extern int pentium_f00f_bug; extern void trap_init_f00f_bug(void); -/* - * Access to machine-specific registers (available on 586 and better only) - * Note: the rd* operations modify the parameters directly (without using - * pointer indirection), this allows gcc to optimize better - * Code from Richard Gooch's 2.2 MTRR drivers. - */ - -#define rdmsr(msr,val1,val2) \ - __asm__ __volatile__("rdmsr" \ - : "=a" (val1), "=d" (val2) \ - : "c" (msr)) - -#define wrmsr(msr,val1,val2) \ - __asm__ __volatile__("wrmsr" \ - : /* no outputs */ \ - : "c" (msr), "a" (val1), "d" (val2)) - - static void check_pentium_f00f(void) { /* @@ -163,26 +145,6 @@ static void check_pentium_f00f(void) } } -static void check_privacy(void) -{ - /* - * Pentium III or higher - processors with mtrrs/cpuid - */ - if(memcmp(x86_vendor_id, "GenuineIntel", 12)) - return; - if(x86_capability & (1<<18)) - { - /* - * Thanks to Phil Karn for this bit. - */ - unsigned long lo,hi; - rdmsr(0x119,lo,hi); - lo |= 0x200000; - wrmsr(0x119,lo,hi); - printk(KERN_INFO "Pentium-III serial number disabled.\n"); - } -} - /* * B step AMD K6 before B 9730xxxx have hardware bugs that can cause * misexecution of code under Linux. Owners of such processors should @@ -373,6 +335,5 @@ static void check_bugs(void) check_fpu(); check_hlt(); check_pentium_f00f(); - check_privacy(); system_utsname.machine[1] = '0' + x86; } diff --git a/include/asm-i386/ioctls.h b/include/asm-i386/ioctls.h index b0761abfc4ea..60e0806e54e5 100644 --- a/include/asm-i386/ioctls.h +++ b/include/asm-i386/ioctls.h @@ -44,8 +44,6 @@ #define TIOCGETD 0x5424 #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ #define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ -#define TIOCSBRK 0x5427 /* BSD compatibility */ -#define TIOCCBRK 0x5428 /* BSD compatibility */ #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ #define FIOCLEX 0x5451 #define FIOASYNC 0x5452 diff --git a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h index 1ee83471941f..aa29478fe1cb 100644 --- a/include/asm-i386/pgtable.h +++ b/include/asm-i386/pgtable.h @@ -54,7 +54,7 @@ do { unsigned long tmpreg; __asm__ __volatile__("movl %%cr3,%0\n\tmovl %0,%%cr3" * address. */ #define __invlpg_mem(addr) \ - (*((char *)(addr)-__PAGE_OFFSET)) + (((char *)(addr)-__PAGE_OFFSET)) #define __invlpg(addr) \ __asm__ __volatile__("invlpg %0": :"m" (__invlpg_mem(addr))) diff --git a/include/linux/apm_bios.h b/include/linux/apm_bios.h index ee5f5d00a429..d3804b3bed28 100644 --- a/include/linux/apm_bios.h +++ b/include/linux/apm_bios.h @@ -3,7 +3,7 @@ /* * Include file for the interface to an APM BIOS - * Copyright 1994-1999 Stephen Rothwell (Stephen.Rothwell@canb.auug.org.au) + * Copyright 1994, 1995 Stephen Rothwell (Stephen.Rothwell@pd.necisa.oz.au) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -14,6 +14,8 @@ * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. + * + * $Id: apm_bios.h,v 0.9 1995/03/09 13:50:05 sfr Exp $ */ typedef unsigned short apm_event_t; @@ -77,7 +79,6 @@ struct apm_bios_struct { extern struct apm_bios_info apm_bios_info; extern void apm_bios_init(void); -extern void apm_setup(char *, int *); extern int apm_register_callback(int (*callback)(apm_event_t)); extern void apm_unregister_callback(int (*callback)(apm_event_t)); diff --git a/include/linux/blk.h b/include/linux/blk.h index 62c0b4398272..92634d7a1b65 100644 --- a/include/linux/blk.h +++ b/include/linux/blk.h @@ -310,16 +310,6 @@ static void floppy_off(unsigned int nr); #define DEVICE_ON(device) #define DEVICE_OFF(device) -#elif (MAJOR_NR == COMPAQ_SMART2_MAJOR) - -#define DEVICE_NAME "ida" -#define DEVICE_INTR do_ida -#define TIMEOUT_VALUE (25*HZ) -#define DEVICE_REQUEST do_ida_request0 -#define DEVICE_NR(device) (MINOR(device) >> 4) -#define DEVICE_ON(device) -#define DEVICE_OFF(device) - #endif /* MAJOR_NR == whatever */ #if (MAJOR_NR != SCSI_TAPE_MAJOR) @@ -380,7 +370,7 @@ static void (DEVICE_REQUEST)(void); /* end_request() - SCSI devices have their own version */ /* - IDE drivers have their own copy too */ -#if ! SCSI_BLK_MAJOR(MAJOR_NR) && (MAJOR_NR != COMPAQ_SMART2_MAJOR) +#if ! SCSI_BLK_MAJOR(MAJOR_NR) #if defined(IDE_DRIVER) && !defined(_IDE_C) /* shared copy for IDE modules */ void ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup); diff --git a/include/linux/cyclades.h b/include/linux/cyclades.h index 759e3f3fc2d3..5620b5c40a22 100644 --- a/include/linux/cyclades.h +++ b/include/linux/cyclades.h @@ -316,7 +316,6 @@ struct FIRM_ID { #define C_IN_OVR_ERROR 0x00008000 /* overrun error */ #define C_IN_RXOFL 0x00010000 /* RX buffer overflow */ #define C_IN_IOCTLW 0x00020000 /* I/O control w/ wait */ -#define C_IN_MRTS 0x00040000 /* modem RTS drop */ /* flow control */ @@ -333,14 +332,12 @@ struct FIRM_ID { /* rs_control/rs_status RS-232 signals */ -#define C_RS_PARAM 0x80000000 /* Indicates presence of parameter in - IOCTLM command */ -#define C_RS_RTS 0x00000001 /* RTS */ -#define C_RS_DTR 0x00000004 /* DTR */ #define C_RS_DCD 0x00000100 /* CD */ #define C_RS_DSR 0x00000200 /* DSR */ #define C_RS_RI 0x00000400 /* RI */ #define C_RS_CTS 0x00000800 /* CTS */ +#define C_RS_RTS 0x00000001 /* RTS */ +#define C_RS_DTR 0x00000004 /* DTR */ /* commands Host <-> Board */ @@ -356,18 +353,13 @@ struct FIRM_ID { #define C_CM_SET_BREAK 0x43 /* Tx break on */ #define C_CM_CLR_BREAK 0x44 /* Tx break off */ #define C_CM_CMD_DONE 0x45 /* Previous command done */ -#define C_CM_INTBACK2 0x46 /* Alternate Interrupt back */ #define C_CM_TINACT 0x51 /* set inactivity detection */ #define C_CM_IRQ_ENBL 0x52 /* enable generation of interrupts */ #define C_CM_IRQ_DSBL 0x53 /* disable generation of interrupts */ -#define C_CM_ACK_ENBL 0x54 /* enable acknowledged interrupt mode */ -#define C_CM_ACK_DSBL 0x55 /* disable acknowledged intr mode */ +#define C_CM_ACK_ENBL 0x54 /* enable acknolowdged interrupt mode */ +#define C_CM_ACK_DSBL 0x55 /* disable acknolowdged intr mode */ #define C_CM_FLUSH_RX 0x56 /* flushes Rx buffer */ #define C_CM_FLUSH_TX 0x57 /* flushes Tx buffer */ -#define C_CM_Q_ENABLE 0x58 /* enables queue access from the - driver */ -#define C_CM_Q_DISABLE 0x59 /* disables queue access from the - driver */ #define C_CM_TXBEMPTY 0x60 /* Tx buffer is empty */ #define C_CM_TXLOWWM 0x61 /* Tx buffer low water mark */ @@ -377,7 +369,6 @@ struct FIRM_ID { #define C_CM_MDSR 0x71 /* modem DSR change */ #define C_CM_MRI 0x72 /* modem RI change */ #define C_CM_MCTS 0x73 /* modem CTS change */ -#define C_CM_MRTS 0x74 /* modem RTS drop */ #define C_CM_RXBRK 0x84 /* Break received */ #define C_CM_PR_ERROR 0x85 /* Parity error */ #define C_CM_FR_ERROR 0x86 /* Frame error */ @@ -458,22 +449,9 @@ struct BOARD_CTRL { /* FW to Host commands */ uclong fwcmd_channel; /* channel number */ uclong fwcmd_param; /* pointer to parameters */ - uclong zf_int_queue_addr; /* offset for INT_QUEUE structure */ /* filler so the structures are aligned */ - uclong filler[6]; -}; - -/* Host Interrupt Queue */ - -#define QUEUE_SIZE (10*MAX_CHAN) - -struct INT_QUEUE { - unsigned char intr_code[QUEUE_SIZE]; - unsigned long channel[QUEUE_SIZE]; - unsigned long param[QUEUE_SIZE]; - unsigned long put; - unsigned long get; + uclong filler[7]; }; /* @@ -603,13 +581,10 @@ struct cyclades_port { #define CyISA_Ywin 0x2000 #define CyPCI_Ywin 0x4000 -#define CyPCI_Yctl 0x80 #define CyPCI_Zctl CTRL_WINDOW_SIZE #define CyPCI_Zwin 0x80000 #define CyPCI_Ze_win (2 * CyPCI_Zwin) -#define PCI_DEVICE_ID_MASK 0x06 - /**** CD1400 registers ****/ #define CD1400_REV_G 0x46 diff --git a/include/linux/fd.h b/include/linux/fd.h index 22aef6eecb68..a05cf3900c66 100644 --- a/include/linux/fd.h +++ b/include/linux/fd.h @@ -215,7 +215,7 @@ struct floppy_drive_struct { /* Prevent "aliased" accesses. */ int fd_ref; int fd_device; - unsigned long last_checked; /* when was the drive last checked for a disk + int last_checked; /* when was the drive last checked for a disk * change? */ char *dmabuf; diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h index e223480dfe8e..2645deea4edb 100644 --- a/include/linux/hdreg.h +++ b/include/linux/hdreg.h @@ -92,12 +92,11 @@ struct hd_geometry { #define HDIO_GETGEO 0x0301 /* get device geometry */ #define HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */ #define HDIO_GET_MULTCOUNT 0x0304 /* get current IDE blockmode setting */ -#define HDIO_OBSOLETE_IDENTITY 0x0307 /* OBSOLETE, DO NOT USE: returns 142 bytes */ +#define HDIO_GET_IDENTITY 0x0307 /* get IDE identification info */ #define HDIO_GET_KEEPSETTINGS 0x0308 /* get keep-settings-on-reset flag */ #define HDIO_GET_32BIT 0x0309 /* get current io_32bit setting */ #define HDIO_GET_NOWERR 0x030a /* get ignore-write-error flag */ #define HDIO_GET_DMA 0x030b /* get use-dma flag */ -#define HDIO_GET_IDENTITY 0x030d /* get IDE identification info */ #define HDIO_DRIVE_CMD 0x031f /* execute a special drive command */ /* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */ @@ -167,54 +166,14 @@ struct hd_driveid { unsigned short word79; unsigned short word80; unsigned short word81; - unsigned short command_sets; /* bits 0:Smart 1:Security 2:Removable 3:PM */ - unsigned short word83; /* bits 14:Smart Enabled 13:0 zero */ + unsigned short word82; + unsigned short word83; unsigned short word84; unsigned short word85; unsigned short word86; unsigned short word87; unsigned short dma_ultra; - unsigned short word89; /* reserved (word 89) */ - unsigned short word90; /* reserved (word 90) */ - unsigned short word91; /* reserved (word 91) */ - unsigned short word92; /* reserved (word 92) */ - unsigned short word93; /* reserved (word 93) */ - unsigned short word94; /* reserved (word 94) */ - unsigned short word95; /* reserved (word 95) */ - unsigned short word96; /* reserved (word 96) */ - unsigned short word97; /* reserved (word 97) */ - unsigned short word98; /* reserved (word 98) */ - unsigned short word99; /* reserved (word 99) */ - unsigned short word100; /* reserved (word 100) */ - unsigned short word101; /* reserved (word 101) */ - unsigned short word102; /* reserved (word 102) */ - unsigned short word103; /* reserved (word 103) */ - unsigned short word104; /* reserved (word 104) */ - unsigned short word105; /* reserved (word 105) */ - unsigned short word106; /* reserved (word 106) */ - unsigned short word107; /* reserved (word 107) */ - unsigned short word108; /* reserved (word 108) */ - unsigned short word109; /* reserved (word 109) */ - unsigned short word110; /* reserved (word 110) */ - unsigned short word111; /* reserved (word 111) */ - unsigned short word112; /* reserved (word 112) */ - unsigned short word113; /* reserved (word 113) */ - unsigned short word114; /* reserved (word 114) */ - unsigned short word115; /* reserved (word 115) */ - unsigned short word116; /* reserved (word 116) */ - unsigned short word117; /* reserved (word 117) */ - unsigned short word118; /* reserved (word 118) */ - unsigned short word119; /* reserved (word 119) */ - unsigned short word120; /* reserved (word 120) */ - unsigned short word121; /* reserved (word 121) */ - unsigned short word122; /* reserved (word 122) */ - unsigned short word123; /* reserved (word 123) */ - unsigned short word124; /* reserved (word 124) */ - unsigned short word125; /* reserved (word 125) */ - unsigned short word126; /* reserved (word 126) */ - unsigned short word127; /* reserved (word 127) */ - unsigned short security; /* bits 0:suuport 1:enabled 2:locked 3:frozen */ - unsigned short reserved[127]; + unsigned short reserved[167]; }; #ifdef __KERNEL__ diff --git a/include/linux/in.h b/include/linux/in.h index 8a42144e9d88..b2a44f590f21 100644 --- a/include/linux/in.h +++ b/include/linux/in.h @@ -31,9 +31,6 @@ enum { IPPROTO_PUP = 12, /* PUP protocol */ IPPROTO_UDP = 17, /* User Datagram Protocol */ IPPROTO_IDP = 22, /* XNS IDP protocol */ - IPPROTO_GRE = 47, /* GRE Encapsulation used by PPTP et al */ - IPPROTO_ESP = 50, /* ESP protocol for IPSec */ - IPPROTO_AH = 51, /* AH protocol for IPSec */ IPPROTO_RAW = 255, /* Raw IP packets */ IPPROTO_MAX diff --git a/include/linux/major.h b/include/linux/major.h index 48b84a98dc22..c5d28fc1a023 100644 --- a/include/linux/major.h +++ b/include/linux/major.h @@ -71,15 +71,6 @@ #define APBLOCK_MAJOR 60 /* AP1000 Block device */ #define DDV_MAJOR 61 /* AP1000 DDV block device */ -#define COMPAQ_SMART2_MAJOR 72 -#define COMPAQ_SMART2_MAJOR1 73 -#define COMPAQ_SMART2_MAJOR2 74 -#define COMPAQ_SMART2_MAJOR3 75 -#define COMPAQ_SMART2_MAJOR4 76 -#define COMPAQ_SMART2_MAJOR5 77 -#define COMPAQ_SMART2_MAJOR6 78 -#define COMPAQ_SMART2_MAJOR7 79 - #define SPECIALIX_NORMAL_MAJOR 75 #define SPECIALIX_CALLOUT_MAJOR 76 diff --git a/include/linux/ncp_fs.h b/include/linux/ncp_fs.h index 9bf794dd65c3..1d6744420099 100644 --- a/include/linux/ncp_fs.h +++ b/include/linux/ncp_fs.h @@ -29,7 +29,7 @@ struct ncp_ioctl_request { struct ncp_fs_info { int version; struct sockaddr_ipx addr; - __kernel_uid_t mounted_uid; + uid_t mounted_uid; int connection; /* Connection number the server assigned us */ int buffer_size; /* The negotiated buffer size, to be used for read/write requests! */ @@ -38,50 +38,13 @@ struct ncp_fs_info { __u32 directory_id; }; -struct ncp_sign_init -{ - char sign_root[8]; - char sign_last[16]; -}; - -struct ncp_lock_ioctl -{ -#define NCP_LOCK_LOG 0 -#define NCP_LOCK_SH 1 -#define NCP_LOCK_EX 2 -#define NCP_LOCK_CLEAR 256 - int cmd; - int origin; - unsigned int offset; - unsigned int length; -#define NCP_LOCK_DEFAULT_TIMEOUT 18 -#define NCP_LOCK_MAX_TIMEOUT 180 - int timeout; -}; - -struct ncp_setroot_ioctl -{ - int volNumber; - int namespace; - __u32 dirEntNum; -}; - #define NCP_IOC_NCPREQUEST _IOR('n', 1, struct ncp_ioctl_request) -#define NCP_IOC_GETMOUNTUID _IOW('n', 2, __kernel_uid_t) -#define NCP_IOC_GETMOUNTUID_INT _IOW('n', 2, unsigned int) +#define NCP_IOC_GETMOUNTUID _IOW('n', 2, uid_t) #define NCP_IOC_CONN_LOGGED_IN _IO('n', 3) #define NCP_GET_FS_INFO_VERSION (1) #define NCP_IOC_GET_FS_INFO _IOWR('n', 4, struct ncp_fs_info) -#define NCP_IOC_SIGN_INIT _IOR('n', 5, struct ncp_sign_init) -#define NCP_IOC_SIGN_WANTED _IOR('n', 6, int) -#define NCP_IOC_SET_SIGN_WANTED _IOW('n', 6, int) - -#define NCP_IOC_LOCKUNLOCK _IOR('n', 7, struct ncp_lock_ioctl) - -#define NCP_IOC_GETROOT _IOW('n', 8, struct ncp_setroot_ioctl) -#define NCP_IOC_SETROOT _IOR('n', 8, struct ncp_setroot_ioctl) /* * The packet size to allocate. One page should be enough. */ @@ -179,7 +142,6 @@ int ncp_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, unsigned long arg); /* linux/fs/ncpfs/inode.c */ -int ncp_notify_change(struct inode *inode, struct iattr *attr); struct super_block *ncp_read_super(struct super_block *sb, void *raw_data, int silent); extern int init_ncp_fs(void); diff --git a/include/linux/ncp_fs_sb.h b/include/linux/ncp_fs_sb.h index e98c5b446fa8..6d1d7c5105e6 100644 --- a/include/linux/ncp_fs_sb.h +++ b/include/linux/ncp_fs_sb.h @@ -14,7 +14,6 @@ #ifdef __KERNEL__ #define NCP_DEFAULT_BUFSIZE 1024 -#define NCP_DEFAULT_OPTIONS 0 /* 2 for packet signatures */ struct ncp_server { @@ -58,12 +57,6 @@ struct ncp_server { struct ncp_inode_info root; char root_path; /* '\0' */ - -/* info for packet signing */ - int sign_wanted; /* 1=Server needs signed packets */ - int sign_active; /* 0=don't do signing, 1=do */ - char sign_root[8]; /* generated from password and encr. key */ - char sign_last[16]; }; static inline int diff --git a/include/linux/ncp_mount.h b/include/linux/ncp_mount.h index 1a411011447b..3de288659667 100644 --- a/include/linux/ncp_mount.h +++ b/include/linux/ncp_mount.h @@ -21,16 +21,13 @@ /* Values for flags */ #define NCP_MOUNT_SOFT 0x0001 #define NCP_MOUNT_INTR 0x0002 -#define NCP_MOUNT_STRONG 0x0004 /* enable delete/rename of r/o files */ -#define NCP_MOUNT_NO_OS2 0x0008 -#define NCP_MOUNT_NO_NFS 0x0010 struct ncp_mount_data { int version; unsigned int ncp_fd; /* The socket to the ncp port */ unsigned int wdog_fd; /* Watchdog packets come here */ unsigned int message_fd; /* Message notifications come here */ - __kernel_uid_t mounted_uid; /* Who may umount() this filesystem? */ + uid_t mounted_uid; /* Who may umount() this filesystem? */ struct sockaddr_ipx serv_addr; unsigned char server_name[NCP_BINDERY_NAME_LEN]; @@ -43,10 +40,10 @@ struct ncp_mount_data { unsigned int retry_count; /* And how often should I retry? */ unsigned int flags; - __kernel_uid_t uid; - __kernel_gid_t gid; - __kernel_mode_t file_mode; - __kernel_mode_t dir_mode; + uid_t uid; + gid_t gid; + mode_t file_mode; + mode_t dir_mode; }; #endif diff --git a/include/linux/nls.h b/include/linux/nls.h index cfa72dc0f3ba..37bb7f2fb439 100644 --- a/include/linux/nls.h +++ b/include/linux/nls.h @@ -42,7 +42,6 @@ extern int init_nls_iso8859_6(void); extern int init_nls_iso8859_7(void); extern int init_nls_iso8859_8(void); extern int init_nls_iso8859_9(void); -extern int init_nls_iso8859_15(void); extern int init_nls_cp437(void); extern int init_nls_cp737(void); extern int init_nls_cp775(void); @@ -59,6 +58,5 @@ extern int init_nls_cp865(void); extern int init_nls_cp866(void); extern int init_nls_cp869(void); extern int init_nls_cp874(void); -extern int init_nls_koi8_r(void); #endif /* _LINUX_NLS_H */ diff --git a/include/linux/pci.h b/include/linux/pci.h index f457018505d8..d4a9bdea20d5 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -119,8 +119,8 @@ /* bit 1 is reserved if address_space = 1 */ #define PCI_CARDBUS_CIS 0x28 -#define PCI_SUBSYSTEM_VENDOR_ID 0x2c -#define PCI_SUBSYSTEM_ID 0x2e +#define PCI_SUBSYSTEM_ID 0x2c +#define PCI_SUBSYSTEM_VENDOR_ID 0x2e #define PCI_ROM_ADDRESS 0x30 /* 32 bits */ #define PCI_ROM_ADDRESS_ENABLE 0x01 /* Write 1 to enable ROM, bits 31..11 are address, @@ -304,8 +304,6 @@ #define PCI_DEVICE_ID_DEC_21052 0x0021 #define PCI_DEVICE_ID_DEC_21150 0x0022 #define PCI_DEVICE_ID_DEC_21152 0x0024 -#define PCI_DEVICE_ID_DEC_21154 0x0026 -#define PCI_DEVICE_ID_DEC_21285 0x1065 #define PCI_VENDOR_ID_CIRRUS 0x1013 #define PCI_DEVICE_ID_CIRRUS_7548 0x0038 @@ -356,11 +354,7 @@ #define PCI_DEVICE_ID_MATROX_MYS 0x051A #define PCI_DEVICE_ID_MATROX_MIL_2 0x051b #define PCI_DEVICE_ID_MATROX_MIL_2_AGP 0x051f -#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520 -#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521 #define PCI_DEVICE_ID_MATROX_MGA_IMP 0x0d10 -#define PCI_DEVICE_ID_MATROX_G100_MM 0x1000 -#define PCI_DEVICE_ID_MATROX_G100_AGP 0x1001 #define PCI_VENDOR_ID_CT 0x102c #define PCI_DEVICE_ID_CT_65545 0x00d8 @@ -480,7 +474,6 @@ #define PCI_DEVICE_ID_MYLEX_DAC960P_V2 0x0001 #define PCI_DEVICE_ID_MYLEX_DAC960P_V3 0x0002 #define PCI_DEVICE_ID_MYLEX_DAC960P_V4 0x0010 -#define PCI_DEVICE_ID_MYLEX_DAC960P_V5 0x0020 #define PCI_VENDOR_ID_APPLE 0x106b #define PCI_DEVICE_ID_APPLE_BANDIT 0x0001 @@ -658,9 +651,6 @@ #define PCI_DEVICE_ID_INIT_320P 0x9100 #define PCI_DEVICE_ID_INIT_360P 0x9500 -#define PCI_VENDOR_ID_TTI 0x1103 -#define PCI_DEVICE_ID_TTI_HPT343 0x0003 - #define PCI_VENDOR_ID_VIA 0x1106 #define PCI_DEVICE_ID_VIA_82C505 0x0505 #define PCI_DEVICE_ID_VIA_82C561 0x0561 @@ -670,7 +660,6 @@ #define PCI_DEVICE_ID_VIA_82C586_0 0x0586 #define PCI_DEVICE_ID_VIA_82C595 0x0595 #define PCI_DEVICE_ID_VIA_82C597_0 0x0597 -#define PCI_DEVICE_ID_VIA_82C598_0 0x0598 #define PCI_DEVICE_ID_VIA_82C926 0x0926 #define PCI_DEVICE_ID_VIA_82C416 0x1571 #define PCI_DEVICE_ID_VIA_82C595_97 0x1595 @@ -678,7 +667,6 @@ #define PCI_DEVICE_ID_VIA_82C586_3 0x3040 #define PCI_DEVICE_ID_VIA_86C100A 0x6100 #define PCI_DEVICE_ID_VIA_82C597_1 0x8597 -#define PCI_DEVICE_ID_VIA_82C598_1 0x8598 #define PCI_VENDOR_ID_SMC2 0x1113 #define PCI_DEVICE_ID_SMC2_1211TX 0x1211 @@ -819,10 +807,6 @@ #define PCI_VENDOR_ID_CYCLADES 0x120e #define PCI_DEVICE_ID_CYCLOM_Y_Lo 0x0100 #define PCI_DEVICE_ID_CYCLOM_Y_Hi 0x0101 -#define PCI_DEVICE_ID_CYCLOM_4Y_Lo 0x0102 -#define PCI_DEVICE_ID_CYCLOM_4Y_Hi 0x0103 -#define PCI_DEVICE_ID_CYCLOM_8Y_Lo 0x0104 -#define PCI_DEVICE_ID_CYCLOM_8Y_Hi 0x0105 #define PCI_DEVICE_ID_CYCLOM_Z_Lo 0x0200 #define PCI_DEVICE_ID_CYCLOM_Z_Hi 0x0201 @@ -966,12 +950,9 @@ #define PCI_VENDOR_ID_ADAPTEC 0x9004 #define PCI_DEVICE_ID_ADAPTEC_7810 0x1078 -#define PCI_DEVICE_ID_ADAPTEC_7821 0x2178 #define PCI_DEVICE_ID_ADAPTEC_7850 0x5078 #define PCI_DEVICE_ID_ADAPTEC_7855 0x5578 #define PCI_DEVICE_ID_ADAPTEC_5800 0x5800 -#define PCI_DEVICE_ID_ADAPTEC_3860 0x6038 -#define PCI_DEVICE_ID_ADAPTEC_1480A 0x6075 #define PCI_DEVICE_ID_ADAPTEC_7860 0x6078 #define PCI_DEVICE_ID_ADAPTEC_7861 0x6178 #define PCI_DEVICE_ID_ADAPTEC_7870 0x7078 @@ -985,28 +966,13 @@ #define PCI_DEVICE_ID_ADAPTEC_7882 0x8278 #define PCI_DEVICE_ID_ADAPTEC_7883 0x8378 #define PCI_DEVICE_ID_ADAPTEC_7884 0x8478 -#define PCI_DEVICE_ID_ADAPTEC_7885 0x8578 -#define PCI_DEVICE_ID_ADAPTEC_7886 0x8678 -#define PCI_DEVICE_ID_ADAPTEC_7887 0x8778 -#define PCI_DEVICE_ID_ADAPTEC_7888 0x8878 #define PCI_DEVICE_ID_ADAPTEC_1030 0x8b78 #define PCI_VENDOR_ID_ADAPTEC2 0x9005 #define PCI_DEVICE_ID_ADAPTEC2_2940U2 0x0010 -#define PCI_DEVICE_ID_ADAPTEC2_2930U2 0x0011 -#define PCI_DEVICE_ID_ADAPTEC2_7890B 0x0013 #define PCI_DEVICE_ID_ADAPTEC2_7890 0x001f #define PCI_DEVICE_ID_ADAPTEC2_3940U2 0x0050 -#define PCI_DEVICE_ID_ADAPTEC2_3950U2D 0x0051 #define PCI_DEVICE_ID_ADAPTEC2_7896 0x005f -#define PCI_DEVICE_ID_ADAPTEC2_7892A 0x0080 -#define PCI_DEVICE_ID_ADAPTEC2_7892B 0x0081 -#define PCI_DEVICE_ID_ADAPTEC2_7892D 0x0083 -#define PCI_DEVICE_ID_ADAPTEC2_7892P 0x008f -#define PCI_DEVICE_ID_ADAPTEC2_7899A 0x00c0 -#define PCI_DEVICE_ID_ADAPTEC2_7899B 0x00c1 -#define PCI_DEVICE_ID_ADAPTEC2_7899D 0x00c3 -#define PCI_DEVICE_ID_ADAPTEC2_7899P 0x00cf #define PCI_VENDOR_ID_ATRONICS 0x907f #define PCI_DEVICE_ID_ATRONICS_2015 0x2015 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index b8711043d904..7b1260a198a9 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -141,9 +141,7 @@ enum scsi_directory_inos { PROC_SCSI_AM53C974, PROC_SCSI_SSC, PROC_SCSI_NCR53C406A, - PROC_SCSI_SYM53C416, PROC_SCSI_MEGARAID, - PROC_SCSI_INIA100, PROC_SCSI_PPA, PROC_SCSI_ATP870U, PROC_SCSI_ESP, @@ -153,9 +151,6 @@ enum scsi_directory_inos { PROC_SCSI_ATARI, PROC_SCSI_GDTH, PROC_SCSI_INI9100U, - PROC_SCSI_PCI2000, - PROC_SCSI_PCI2220I, - PROC_SCSI_PSI240I, PROC_SCSI_IDESCSI, PROC_SCSI_SCSI_DEBUG, PROC_SCSI_NOT_PRESENT, diff --git a/include/linux/tasks.h b/include/linux/tasks.h index d4e743011825..4540e34f0f44 100644 --- a/include/linux/tasks.h +++ b/include/linux/tasks.h @@ -11,7 +11,7 @@ #define NR_CPUS 1 #endif -#define NR_TASKS 512 /* Max 4092, or 4090 w/APM configured on x86 */ +#define NR_TASKS 512 #define MAX_TASKS_PER_USER (NR_TASKS/2) #define MIN_TASKS_LEFT_FOR_ROOT 4 diff --git a/include/linux/via_ide_dma.h b/include/linux/via_ide_dma.h deleted file mode 100644 index b82fe5a41921..000000000000 --- a/include/linux/via_ide_dma.h +++ /dev/null @@ -1,162 +0,0 @@ -/* Via Apollo timings display header file for triton.c. - Copyright (c) 1998 Michel Aubry -*/ - -typedef char *PCHAR; - -static int via_get_info(char *, char **, off_t, int, int); -static PCHAR print_apollo_drive_config(char *buf,byte bus, byte fn); -static PCHAR print_apollo_ide_config(char *buf, byte bus, byte fn); -static PCHAR print_apollo_chipset_control1(char *buf,byte bus, byte fn); -static PCHAR print_apollo_chipset_control2(char *p,byte bus, byte fn); -static PCHAR print_apollo_chipset_control3(char *p, byte bus, byte fn, unsigned short n); - -static struct proc_dir_entry via_proc_entry = { - 0, 3, "via", S_IFREG | S_IRUGO, 1, 0, 0, 0, 0, via_get_info -}; - -/* we save bus, function of chipset here for further debug use */ -static byte bmide_bus, bmide_fn; - -static char *FIFO_str[] = {" 1 ", "3/4", "1/2", "1/4"}; -static char *control3_str[] = {"No limitation", "64","128","192"}; - -static int via_get_info(char *buffer, char **addr, off_t offset, int count, int dummy) -{ - /* print what /proc/via displays, if required from DISPLAY_APOLLO_TIMINGS */ - char *p = buffer; - /* Parameter of chipset : */ - /* Miscellaneous control 1 */ - p = print_apollo_chipset_control1(buffer,bmide_bus, bmide_fn); - /* Miscellaneous control 2 */ - p = print_apollo_chipset_control2(p,bmide_bus, bmide_fn); - /* Parameters of drives: */ - /* Header */ - p += sprintf(p,"------------------Primary IDE------------Secondary IDE-----\n"); - p = print_apollo_chipset_control3(p, bmide_bus, bmide_fn, 0); - p = print_apollo_ide_config(p,bmide_bus, bmide_fn); - p += sprintf(p,"--------------drive0------drive1-------drive0------drive1----\n"); - p = print_apollo_chipset_control3(p, bmide_bus, bmide_fn, 1); - p = print_apollo_drive_config(p,bmide_bus, bmide_fn); - - return p-buffer; /* hoping it is less than 4K... */ -} - -static PCHAR print_apollo_drive_config(char *buf,byte bus, byte fn) -{ - int rc; - unsigned int time; - byte tm; - char *p = buf; - - /* printk("--------------drive0------drive1-------drive0------drive1----");*/ - - /* Drive Timing Control */ - - rc = pcibios_read_config_dword(bus, fn, 0x48, &time); - p += sprintf(p,"Act Pls Width: %02d %02d %02d %02d\n",((time & 0xf0000000)>>28)+1,((time & 0xf00000)>>20)+1,((time & 0xf000)>>12)+1, ((time & 0xf0)>>4)+1); - p += sprintf(p,"Recovery Time: %02d %02d %02d %02d\n",((time & 0x0f000000)>>24)+1, ((time & 0x0f0000)>>16)+1, ((time & 0x0f00)>>8)+1, (time & 0x0f)+1); - - /* Address Setup Time */ - - rc = pcibios_read_config_byte(bus, fn, 0x4C, &tm); - p += sprintf(p, "Add. Setup T.: %01dT %01dT %01dT %01dT\n",((tm & 0xc0)>>6) + 1,((tm & 0x30)>>4) + 1,((tm & 0x0c)>>2) + 1,(tm & 0x03) + 1); - - /* UltraDMA33 Extended Timing Control */ - - rc = pcibios_read_config_dword(bus, fn, 0x50, &time); - p += sprintf(p, "------------------UDMA-Timing-Control------------------------\n"); - p += sprintf(p, "Enable Meth.: %01d %01d %01d %01d\n",(time & 0x80000000)?1:0,(time & 0x800000)?1:0, (time & 0x8000)?1:0, (time & 0x80)?1:0); - p += sprintf(p, "Enable: %s %s %s %s\n",(time & 0x40000000)?"yes":"no ", (time & 0x400000)?"yes":"no ",(time & 0x4000)?"yes":"no ",(time & 0x40)?"yes":"no "); - p += sprintf(p, "Transfer Mode: %s %s %s %s\n",(time & 0x20000000)?"PIO":"DMA",(time & 0x200000)?"PIO":"DMA",(time & 0x2000)?"PIO":"DMA",(time & 0x20)?"PIO":"DMA"); - p += sprintf(p, "Cycle Time: %01dT %01dT %01dT %01dT\n",((time & 0x03000000)>>24)+2,((time & 0x030000)>>16)+2,((time & 0x0300)>>8)+2,(time & 0x03)+2); - - return (PCHAR)p; -} - -static PCHAR print_apollo_ide_config(char *buf, byte bus, byte fn) -{ - byte time, tmp; - unsigned short size0,size1; - int rc; - char *p = buf; - - rc = pcibios_read_config_byte(bus, fn, 0x41, &time); - p += sprintf(p,"Prefetch Buffer : %s %s\n", (time & 128)?"on ":"off", (time & 32)?"on ":"off"); - p += sprintf(p,"Post Write Buffer: %s %s\n", (time & 64)? "on ": "off",(time & 16)?"on ":"off"); - - /* FIFO configuration */ - rc = pcibios_read_config_byte(bus, fn, 0x43, &time); - tmp = ((time & 0x20)>>2) + ((time & 0x40)>>3); - p += sprintf(p,"FIFO Conf/Chan. : %02d %02d\n", 16 - tmp, tmp); - tmp = (time & 0x0F)>>2; - p += sprintf(p,"Threshold Prim. : %s %s\n", FIFO_str[tmp],FIFO_str[time & 0x03]); - - /* chipset Control3 */ - rc = pcibios_read_config_byte(bus, fn, 0x46, &time); - p += sprintf(p,"Read DMA FIFO flush: %s %s\n",(time & 0x80)?"on ":"off", (time & 0x40)?"on ":"off"); - p += sprintf(p,"End Sect. FIFO flush: %s %s\n",(time & 0x20)?"on ":"off", (time & 0x10)?"on ":"off"); - p += sprintf(p,"Max DRDY Pulse Width: %s %s\n", control3_str[(time & 0x03)], (time & 0x03)? "PCI clocks":""); - - /* Primary and Secondary sector sizes */ - rc = pcibios_read_config_word(bus, fn, 0x60, &size0); - rc = pcibios_read_config_word(bus, fn, 0x68, &size1); - p += sprintf(p,"Bytes Per Sector: %03d %03d\n",size0 & 0xfff,size1 & 0xfff); - return (PCHAR)p; -} - -static PCHAR print_apollo_chipset_control1(char *buf,byte bus, byte fn) -{ - byte t; - int rc; - char *p = buf; - unsigned short c; - byte l,l_max; - - rc = pcibios_read_config_word(bus, fn, 0x04, &c); - rc = pcibios_read_config_byte(bus, fn, 0x44, &t); - rc = pcibios_read_config_byte(bus, fn, 0x0d, &l); - rc = pcibios_read_config_byte(bus, fn, 0x3f, &l_max); - p += sprintf(p,"Command register = 0x%x\n",c); - p += sprintf(p,"Master Read Cycle IRDY %d Wait State\n", (t & 64)>>6); - p += sprintf(p,"Master Write Cycle IRDY %d Wait State\n", (t & 32)>>5 ); - p += sprintf(p,"FIFO Output Data 1/2 Clock Advance: %s\n", (t & 16)? "on ":"off"); - p += sprintf(p,"Bus Master IDE Status Register Read Retry: %s\n", (t & 8)? "on " : "off"); - p += sprintf(p,"Latency timer = %d (max. = %d)\n",l,l_max); - return (PCHAR)p; -} - -static PCHAR print_apollo_chipset_control2(char *buf,byte bus, byte fn) -{ - byte t; - int rc; - char *p = buf; - rc = pcibios_read_config_byte(bus, fn, 0x45, &t); - p += sprintf(p,"Interrupt Steering Swap: %s\n", (t & 64)? "on ":"off"); - return (PCHAR)p; -} - -static PCHAR print_apollo_chipset_control3(char *buf, byte bus, byte fn, unsigned short n) -{ - /* at that point we can be sure that register 0x20 of the chipset contains the right address... */ - unsigned int bibma; - int rc; - byte c0,c1; - char *p = buf; - - rc = pcibios_read_config_dword(bus, fn, 0x20, &bibma); - bibma = (bibma & 0xfff0) ; - - /* at that point bibma+0x2 et bibma+0xa are byte registers to investigate:*/ - c0 = inb((unsigned short)bibma + 0x02); - c1 = inb((unsigned short)bibma + 0x0a); - - if(n==0) - /*p = sprintf(p,"--------------------Primary IDE------------Secondary IDE-----");*/ - p += sprintf(p,"both channels togth: %s %s\n",(c0&0x80)?"no":"yes",(c1&0x80)?"no":"yes"); - else - /*p = sprintf(p,"--------------drive0------drive1-------drive0------drive1----");*/ - p += sprintf(p,"DMA enabled: %s %s %s %s\n",(c0&0x20)?"yes":"no ",(c0&0x40)?"yes":"no ",(c1&0x20)?"yes":"no ",(c1&0x40)?"yes":"no "); - - return (PCHAR)p; -} diff --git a/include/linux/wireless.h b/include/linux/wireless.h index 68c27c7270f5..a36835558880 100644 --- a/include/linux/wireless.h +++ b/include/linux/wireless.h @@ -1,7 +1,7 @@ /* * This file define a set of standard wireless extensions * - * Version : 6 18.2.99 + * Version : 4 12.2.97 * * Authors : Jean Tourrilhes - HPLB - */ @@ -63,7 +63,7 @@ * (there is some stuff that will be added in the future...) * I just plan to increment with each new version. */ -#define WIRELESS_EXT 6 +#define WIRELESS_EXT 5 /* * Changes : @@ -82,10 +82,6 @@ * -------- * - Missing encoding definitions in range * - Access points stuff - * - * V5 to V6 - * -------- - * - 802.11 support */ /* -------------------------- IOCTL LIST -------------------------- */ @@ -117,19 +113,11 @@ #define SIOCGIWAP 0x8B15 /* get access point hardware addresses */ #define SIOCGIWAPLIST 0x8B17 /* get list of access point in range */ -/* 802.11 specific support */ -#define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */ -#define SIOCGIWESSID 0x8B1B /* get ESSID */ -/* As the ESSID is a string up to 32 bytes long, it doesn't fit within the - * 'iwreq' structure, so we need to use the 'data' member to point to a - * string in user space, like it is done for RANGE... - */ - /* ------------------------- IOCTL STUFF ------------------------- */ /* The first and the last (range) */ #define SIOCIWFIRST 0x8B00 -#define SIOCIWLAST 0x8B1B +#define SIOCIWLAST 0x8B17 /* Even : get (world access), odd : set (root access) */ #define IW_IS_SET(cmd) (!((cmd) & 0x1)) diff --git a/include/net/ip_masq.h b/include/net/ip_masq.h index a06e75f19be9..ccfb646c38b2 100644 --- a/include/net/ip_masq.h +++ b/include/net/ip_masq.h @@ -84,13 +84,6 @@ struct ip_masq { void *app_data; /* Application private data */ unsigned flags; /* status flags */ struct ip_masq *control; /* Corresponding control connection */ -#ifdef CONFIG_IP_MASQUERADE_IPSEC - struct ip_masq *d_link; /* hashed link ptr */ - __u32 ospi, ispi; /* outbound and inbound SPI keys for IPSEC */ - /* also the icookie for ISAKMP masquerade */ - short ocnt; /* counter of inits sent - limit blocking */ - short blocking; /* if we're blocking another host */ -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ }; /* diff --git a/include/scsi/scsicam.h b/include/scsi/scsicam.h index a9f00e229fdd..954e1407ee54 100644 --- a/include/scsi/scsicam.h +++ b/include/scsi/scsicam.h @@ -14,6 +14,4 @@ #define SCSICAM_H #include extern int scsicam_bios_param (Disk *disk, kdev_t dev, int *ip); -extern int scsi_partsize(struct buffer_head *bh, unsigned long capacity, - unsigned int *cyls, unsigned int *hds, unsigned int *secs); #endif /* def SCSICAM_H */ diff --git a/init/main.c b/init/main.c index 43707f153a82..322d75cb3d8f 100644 --- a/init/main.c +++ b/init/main.c @@ -39,9 +39,6 @@ #ifdef CONFIG_MTRR #include #endif -#ifdef CONFIG_APM -#include -#endif #include @@ -106,7 +103,6 @@ extern void u14_34f_setup(char *str, int *ints); extern void fdomain_setup(char *str, int *ints); extern void in2000_setup(char *str, int *ints); extern void NCR53c406a_setup(char *str, int *ints); -extern void sym53c416_setup(char *str, int *ints); extern void wd7000_setup(char *str, int *ints); extern void dc390_setup(char* str, int *ints); extern void ppa_setup(char *str, int *ints); @@ -209,11 +205,6 @@ extern void pg_setup(char *str, int *ints); #ifdef CONFIG_PARIDE_PCD extern void pcd_setup(char *str, int *ints); #endif -#ifdef CONFIG_BLK_CPQ_DA -#ifdef CONFIG_BLK_CPQ_DA_EISA -extern void cpqarray_setup(char *str, int *ints); -#endif -#endif #if defined(CONFIG_SYSVIPC) || defined(CONFIG_KERNELD) extern void ipc_init(void); @@ -382,9 +373,6 @@ struct kernel_param bootsetups[] = { #ifdef CONFIG_SCSI_NCR53C406A { "ncr53c406a=", NCR53c406a_setup}, #endif -#ifdef CONFIG_SCSI_SYM53C416 - { "sym53c416=", sym53c416_setup}, -#endif #ifdef CONFIG_SCSI_FUTURE_DOMAIN { "fdomain=", fdomain_setup}, #endif @@ -484,10 +472,8 @@ struct kernel_param bootsetups[] = { #ifdef CONFIG_BAYCOM { "baycom=", baycom_setup }, #endif -#ifdef CONFIG_BLK_CPQ_DA -#ifdef CONFIG_BLK_CPQ_DA_EISA - { "smart2=", cpqarray_setup }, -#endif +#ifdef CONFIG_APM + { "apm=", apm_setup }, #endif { 0, 0 } }; @@ -508,9 +494,6 @@ static struct kernel_param raw_params[] = { #endif #ifdef CONFIG_PARIDE_PG { "pg.", pg_setup }, -#endif -#ifdef CONFIG_APM - { "apm=", apm_setup }, #endif { 0, 0 } } ; diff --git a/kernel/ksyms.c b/kernel/ksyms.c index ef75d1dc2325..4fa02bad6b9f 100644 --- a/kernel/ksyms.c +++ b/kernel/ksyms.c @@ -201,8 +201,6 @@ struct symbol_table symbol_table = { X(hardsect_size), X(blk_size), X(blk_dev), - X(max_sectors), - X(max_segments), X(is_read_only), X(set_device_ro), X(bmap), diff --git a/kernel/sched.c b/kernel/sched.c index d3e3daea00ac..0904f59f3922 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -87,6 +87,7 @@ unsigned long prof_shift = 0; #define _S(nr) (1<<((nr)-1)) extern void mem_use(void); +extern unsigned long get_wchan(struct task_struct *); static unsigned long init_kernel_stack[1024] = { STACK_MAGIC, }; unsigned long init_user_stack[1024] = { STACK_MAGIC, }; @@ -1666,56 +1667,6 @@ asmlinkage int sys_nanosleep(struct timespec *rqtp, struct timespec *rmtp) return 0; } -/* Used in fs/proc/array.c */ -unsigned long get_wchan(struct task_struct *p) -{ - if (!p || p == current || p->state == TASK_RUNNING) - return 0; -#if defined(__i386__) - { - unsigned long ebp, eip; - unsigned long stack_page; - int count = 0; - - stack_page = p->kernel_stack_page; - if (!stack_page) - return 0; - ebp = p->tss.ebp; - do { - if (ebp < stack_page || ebp >= 4092+stack_page) - return 0; - eip = *(unsigned long *) (ebp+4); - if (eip < (unsigned long) interruptible_sleep_on - || eip >= (unsigned long) add_timer) - return eip; - ebp = *(unsigned long *) ebp; - } while (count++ < 16); - } -#elif defined(__alpha__) - /* - * This one depends on the frame size of schedule(). Do a - * "disass schedule" in gdb to find the frame size. Also, the - * code assumes that sleep_on() follows immediately after - * interruptible_sleep_on() and that add_timer() follows - * immediately after interruptible_sleep(). Ugly, isn't it? - * Maybe adding a wchan field to task_struct would be better, - * after all... - */ - { - unsigned long schedule_frame; - unsigned long pc; - - pc = thread_saved_pc(&p->tss); - if (pc >= (unsigned long) interruptible_sleep_on && pc < (unsigned long) add_timer) { - schedule_frame = ((unsigned long *)p->tss.ksp)[6]; - return ((unsigned long *)schedule_frame)[12]; - } - return pc; - } -#endif - return 0; -} - static void show_task(int nr,struct task_struct * p) { unsigned long free; diff --git a/kernel/sys.c b/kernel/sys.c index 749f32c7f8bf..0de552de1e66 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -226,9 +226,6 @@ asmlinkage int sys_reboot(int magic, int magic_too, int flag) void ctrl_alt_del(void) { if (C_A_D) { -#ifdef CONFIG_BLK_DEV_DAC960 - DAC960_Finalize(); -#endif #ifdef CONFIG_SCSI_GDTH gdth_halt(); #endif diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 015459d951eb..3faeac96ea59 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c @@ -408,7 +408,6 @@ static int atif_probe_device(struct atalk_iface *atif) * Scan the networks. */ - atif->status |= ATIF_PROBE; for(netct=0;netct<=netrange;netct++) { /* @@ -436,10 +435,8 @@ static int atif_probe_device(struct atalk_iface *atif) if(atif->status&ATIF_PROBE_FAIL) break; } - if(!(atif->status&ATIF_PROBE_FAIL)) { - atif->status &= ~ATIF_PROBE; + if(!(atif->status&ATIF_PROBE_FAIL)) return 0; - } } atif->status&=~ATIF_PROBE_FAIL; } @@ -447,7 +444,6 @@ static int atif_probe_device(struct atalk_iface *atif) if(probe_net>ntohs(atif->nets.nr_lastnet)) probe_net=ntohs(atif->nets.nr_firstnet); } - atif->status &= ~ATIF_PROBE; return -EADDRINUSE; /* Network is full... */ } @@ -513,7 +509,7 @@ static struct atalk_iface *atalk_find_interface(int net, int node) struct atalk_iface *iface; for(iface=atalk_iface_list;iface!=NULL;iface=iface->next) { - if((node==ATADDR_BCAST || node==ATADDR_ANYNODE || iface->address.s_node==node) + if((node==ATADDR_BCAST || iface->address.s_node==node) && iface->address.s_net==net && !(iface->status&ATIF_PROBE)) return iface; } @@ -1548,10 +1544,7 @@ static int atalk_rcv(struct sk_buff *skb, struct device *dev, struct packet_type /* Which socket - atalk_search_socket() looks for a *full match* of the tuple */ tosat.sat_addr.s_net = ddp->deh_dnet; - if (ddp->deh_dnode == ATADDR_ANYNODE) - tosat.sat_addr.s_node = atif->address.s_node; - else - tosat.sat_addr.s_node = ddp->deh_dnode; + tosat.sat_addr.s_node = ddp->deh_dnode; tosat.sat_port = ddp->deh_dport; sock=atalk_search_socket( &tosat, atif ); diff --git a/net/bridge/br.c b/net/bridge/br.c index 96c2603186ab..da4ac132ab76 100644 --- a/net/bridge/br.c +++ b/net/bridge/br.c @@ -91,8 +91,6 @@ static struct notifier_block br_dev_notifier={ void transmit_config(int port_no) /* (4.6.1) */ { - if(!(br_stats.flags & BR_UP)) - return; /* this should not happen but happens */ if (hold_timer[port_no].active) { /* (4.6.1.3.1) */ port_info[port_no].config_pending = TRUE; /* (4.6.1.3.1) */ } else { /* (4.6.1.3.2) */ @@ -873,12 +871,11 @@ int hold_timer_expired(int port_no) int send_config_bpdu(int port_no, Config_bpdu *config_bpdu) { - struct sk_buff *skb; - struct device *dev = port_info[port_no].dev; - int size; +struct sk_buff *skb; +struct device *dev = port_info[port_no].dev; +int size; +unsigned long flags; - if(!(br_stats.flags & BR_UP)) - return(-1); /* this should not happen but happens */ if (port_info[port_no].state == Disabled) { printk(KERN_DEBUG "send_config_bpdu: port %i not valid\n",port_no); return(-1); @@ -930,12 +927,11 @@ int send_config_bpdu(int port_no, Config_bpdu *config_bpdu) int send_tcn_bpdu(int port_no, Tcn_bpdu *bpdu) { - struct sk_buff *skb; - struct device *dev = port_info[port_no].dev; - int size; +struct sk_buff *skb; +struct device *dev = port_info[port_no].dev; +int size; +unsigned long flags; - if(!(br_stats.flags & BR_UP)) - return(-1); /* this should not happen but happens */ if (port_info[port_no].state == Disabled) { printk(KERN_DEBUG "send_tcn_bpdu: port %i not valid\n",port_no); return(-1); @@ -1051,6 +1047,7 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v int br_receive_frame(struct sk_buff *skb) /* 3.5 */ { int port; + int i; if (br_stats.flags & BR_DEBUG) printk("br_receive_frame: "); diff --git a/net/ipv4/Config.in b/net/ipv4/Config.in index b795005aaf83..8fe657e94646 100644 --- a/net/ipv4/Config.in +++ b/net/ipv4/Config.in @@ -16,22 +16,9 @@ if [ "$CONFIG_FIREWALL" = "y" ]; then comment 'Protocol-specific masquerading support will be built as modules.' if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then bool 'IP: ipautofw masquerading (EXPERIMENTAL)' CONFIG_IP_MASQUERADE_IPAUTOFW - bool 'IP: MS PPTP masq support (EXPERIMENTAL)' CONFIG_IP_MASQUERADE_PPTP + bool 'IP: MS PPTP client masq support (EXPERIMENTAL)' CONFIG_IP_MASQUERADE_PPTP if [ "$CONFIG_IP_MASQUERADE_PPTP" = "y" ]; then - bool 'IP: MS PPTP Call ID masq support (EXPERIMENTAL)' CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT bool 'IP: MS PPTP masq debugging' DEBUG_IP_MASQUERADE_PPTP - if [ "$DEBUG_IP_MASQUERADE_PPTP" = "y" ]; then - bool 'IP: MS PPTP masq verbose debugging' DEBUG_IP_MASQUERADE_PPTP_VERBOSE - fi - fi - bool 'IP: IPSEC ESP & ISAKMP masq support (EXPERIMENTAL)' CONFIG_IP_MASQUERADE_IPSEC - if [ "$CONFIG_IP_MASQUERADE_IPSEC" = "y" ]; then - int 'IP: IPSEC masq table lifetime (minutes)' CONFIG_IP_MASQUERADE_IPSEC_EXPIRE 30 - bool 'IP: Disable inbound ESP destination guessing' CONFIG_IP_MASQUERADE_IPSEC_NOGUESS - bool 'IP: IPSEC masq debugging' DEBUG_IP_MASQUERADE_IPSEC - if [ "$DEBUG_IP_MASQUERADE_IPSEC" = "y" ]; then - bool 'IP: IPSEC masq verbose debugging' DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - fi fi fi bool 'IP: ICMP masquerading' CONFIG_IP_MASQUERADE_ICMP diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 47da5bfad8d5..70dbc0ec734c 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -1784,15 +1784,13 @@ int arp_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt) * is not from an IP number. We can't currently handle this, so toss * it. */ -#if defined(CONFIG_NET_ETHERNET) || defined(CONFIG_FDDI) - if (dev->type == ARPHRD_ETHER || dev->type == ARPHRD_FDDI) +#ifdef CONFIG_FDDI + if (dev->type == ARPHRD_FDDI) { /* * According to RFC 1390, FDDI devices should accept ARP hardware types * of 1 (Ethernet). However, to be more robust, we'll accept hardware * types of either 1 (Ethernet) or 6 (IEEE 802.2). - * - * ETHERNET devices will accept both hardware types, too. (RFC 1042) */ if (arp->ar_hln != dev->addr_len || ((ntohs(arp->ar_hrd) != ARPHRD_ETHER) && (ntohs(arp->ar_hrd) != ARPHRD_IEEE802)) || diff --git a/net/ipv4/ip_masq.c b/net/ipv4/ip_masq.c index bf71ed067909..35cb7ab215c1 100644 --- a/net/ipv4/ip_masq.c +++ b/net/ipv4/ip_masq.c @@ -20,7 +20,6 @@ * Delian Delchev : Added support for ICMP requests and replys * Nigel Metheringham : ICMP in ICMP handling, tidy ups, bug fixes, made ICMP optional * Juan Jose Ciarlante : re-assign maddr if no packet received from outside - * John D. Hardin : Added PPTP and IPSEC protocols * */ @@ -46,66 +45,29 @@ #define IP_MASQ_TAB_SIZE 256 /* must be power of 2 */ -#ifdef CONFIG_IP_MASQUERADE_PPTP -/* - * This is clumsier than it otherwise might be (i.e. the - * PPTP control channel sniffer should be a module, and there - * should be a separate table for GRE masq entries so that - * we're not making all of the hacks to the TCP table code) - # but I wanted to keep the code changes localized to one file - # if possible. - * This should all be modular, and the table routines need to - * be somewhat more generic. - * - * Maybe for 2.0.38 - we'll see. - * - * John Hardin gets all blame... - * See also http://www.wolfenet.com/~jhardin/ip_masq_vpn.html - */ - -static const char *strGREProt = "GRE"; -#ifdef CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT /* - * MULTICLIENT watches the control channel and preloads the - * call ID into the masq table entry, so we want the - * masq table entry to persist until a Call Disconnect - * occurs, otherwise the call IDs will be lost and the link broken. - */ -#define MASQUERADE_EXPIRE_PPTP 15*60*HZ - + * to turn it on, of course +*/ +#define CONFIG_IP_MASQUERADE_PPTP 1 /* - * To support multiple clients communicating with the same server, - * we have to sniff the control channel and trap the client's - * call ID, then substitute a unique-to-the-firewall call ID. - * Then on inbound GRE packets we use the bogus call ID to figure - * out which client to route the traffic to, then replace the - * bogus call ID with the client's real call ID, which we've saved. - * For simplicity we'll use masq port as the bogus call ID. - * The actual call ID will be stored in the masq table as - * the source port, and the destination port will always be zero. - * - * NB: PPTP servers can tell whether the client is masqueraded by - * looking for call IDs above 61000. - */ -#define PPTP_CONTROL_PORT 1723 +*/ -#else /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ -/* non-MULTICLIENT ignores call IDs, so masq table - * entries may expire quickly without causing problems. - */ -#define MASQUERADE_EXPIRE_PPTP 5*60*HZ +#ifdef CONFIG_IP_MASQUERADE_PPTP -#endif /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ +/* + * try these if you're having problems... +#define DEBUG_IP_MASQUERADE_PPTP 1 +#define DEBUG_IP_MASQUERADE_VERBOSE 1 +*/ /* * Define this here rather than in /usr/src/linux/include/wherever/whatever.h * in order to localize my mistakes to one file... - * - * This struct may be architecture-specific because of the bitmaps. */ -struct pptp_gre_header { + +struct grehdr { __u8 recur:3, is_strict:1, @@ -117,78 +79,14 @@ struct pptp_gre_header { version:3, flags:5; __u16 - protocol, - payload_len, - call_id; /* peer's call_id for this session */ - + protocol; }; -#endif /* CONFIG_IP_MASQUERADE_PPTP */ - - -#ifdef CONFIG_IP_MASQUERADE_IPSEC -/* - * The above comments about PPTP apply here, too. This should all be a module. - * - * The "port numbers" for masq table purposes will be part of the - * SPI, just to gain a little benefit from the hashing. - */ - -static const char *strESPProt = "ESP"; -static const char *strAHProt = "AH"; - -/* - * ISAKMP uses 500/udp, and the traffic must come from - * 500/udp (i.e. 500/udp <-> 500/udp), so we need to - * check for ISAKMP UDP traffic and avoid changing the - * source port number. In order to associate the data streams - * we may need to sniff the ISAKMP cookies as well. - */ -#define UDP_PORT_ISAKMP 500 /* ISAKMP default UDP port */ - -#if CONFIG_IP_MASQUERADE_IPSEC_EXPIRE > 15 -#define MASQUERADE_EXPIRE_IPSEC CONFIG_IP_MASQUERADE_IPSEC_EXPIRE*60*HZ -#else -#define MASQUERADE_EXPIRE_IPSEC 15*60*HZ -#endif - -/* - * We can't know the inbound SPI until it comes in (the ISAKMP exchange - * is encryptd so we can't sniff it out of that), so we associate inbound - * and outbound traffic by inspection. If somebody sends a new packet to a - * remote server, then block all other new traffic to that server until we - * get a response from that server with a SPI we haven't seen yet. It is - * assumed that this is the correct response - we have no way to verify it, - * as everything else is encrypted. - * - * If there is a collision, the block will last for up to two minutes (or - * whatever MASQUERADE_EXPIRE_IPSEC_INIT is set to), and if the client - * retries during that time the timer will be reset. This could easily lead - * to a Denial of Service, so we limit the number of retries that will - * reset the timer. This means the maximum time the server could be blocked - * is ((IPSEC_INIT_RETRIES + 1) * MASQUERADE_EXPIRE_IPSEC_INIT). - * - * Note: blocking will not affect already-established traffic (i.e. where - * the inbound SPI has been associated with an outbound SPI). - */ -#define MASQUERADE_EXPIRE_IPSEC_INIT 2*60*HZ -#define IPSEC_INIT_RETRIES 5 - -/* - * ...connections that don't get an answer are squelched - * (recognized but ignored) for a short time to prevent DoS. - * SPI values 1-255 are reserved by the IANA and are currently (2/99) - * not assigned. If that should change, this number must also be changed - * to an unused NONZERO value: - */ -#define IPSEC_INIT_SQUELCHED 1 -struct ip_masq * ip_masq_out_get_ipsec(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port, __u32 o_spi); -struct ip_masq * ip_masq_in_get_ipsec(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port, __u32 i_spi); -struct ip_masq * ip_masq_out_get_isakmp(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port, __u32 cookie); -struct ip_masq * ip_masq_in_get_isakmp(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port, __u32 cookie); +#define IPPROTO_GRE 47 /* GRE Encapsulation used by Microsoft PPTP */ +static const char *strGREProt = "GRE"; -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ +#endif /* CONFIG_IP_MASQUERADE_PPTP */ /* * Implement IP packet masquerading @@ -199,7 +97,7 @@ static const char *strProt[] = {"UDP","TCP","ICMP"}; /* * masq_proto_num returns 0 for UDP, 1 for TCP, 2 for ICMP * - * No, I am NOT going to add GRE/ESP/AH support to everything that relies on this... + * No, I am NOT going to add GRE support to everything that relies on this... * */ @@ -208,13 +106,10 @@ static int masq_proto_num(unsigned proto) switch (proto) { case IPPROTO_UDP: return (0); break; + case IPPROTO_TCP: return (1); break; #ifdef CONFIG_IP_MASQUERADE_PPTP - case IPPROTO_GRE: + case IPPROTO_GRE: return (1); break; /* steal a few TCP ports */ #endif /* CONFIG_IP_MASQUERADE_PPTP */ -#ifdef CONFIG_IP_MASQUERADE_IPSEC - case IPPROTO_ESP: -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ - case IPPROTO_TCP: return (1); break; case IPPROTO_ICMP: return (2); break; default: return (-1); break; } @@ -250,24 +145,19 @@ static __inline__ const __u8 icmp_type_request(__u8 type) static __inline__ const char *masq_proto_name(unsigned proto) { - +#ifdef CONFIG_IP_MASQUERADE_PPTP /* + * Yes, I know this sucks for efficiency and is ugly. * I don't want to track down everything that - * relies on masq_proto_num() and make it GRE/ESP/AH-tolerant. + * relies on masq_proto_num() and make it GRE-tolerant. + * The number of sites running this patch will probably be small, + * and hopefully the 2.1/2.2 kernel will support masquerading of + * arbitrary IP protocols (or at least GRE). */ -#ifdef CONFIG_IP_MASQUERADE_PPTP if (proto == IPPROTO_GRE) { return strGREProt; } #endif /* CONFIG_IP_MASQUERADE_PPTP */ -#ifdef CONFIG_IP_MASQUERADE_IPSEC - if (proto == IPPROTO_ESP) { - return strESPProt; - } else if (proto == IPPROTO_AH) { - return strAHProt; - } -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ - return strProt[masq_proto_num(proto)]; } @@ -312,14 +202,6 @@ static struct symbol_table ip_masq_syms = { struct ip_masq *ip_masq_m_tab[IP_MASQ_TAB_SIZE]; struct ip_masq *ip_masq_s_tab[IP_MASQ_TAB_SIZE]; -#ifdef CONFIG_IP_MASQUERADE_IPSEC - /* - * Add a third hash table for input lookup by remote side - */ -struct ip_masq *ip_masq_d_tab[IP_MASQ_TAB_SIZE]; - -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ - /* * timeouts */ @@ -461,29 +343,30 @@ ip_masq_hash(struct ip_masq *ms) ms->m_link = ip_masq_m_tab[hash]; ip_masq_m_tab[hash] = ms; +#ifdef DEBUG_IP_MASQUERADE_PPTP + printk("MASQ: hashed %d %08X:%04hX->%08X:%04hX into in\n", + ms->protocol, + ms->saddr, + ms->sport, + ms->maddr, + ms->mport); +#endif /* DEBUG_IP_MASQUERADE_PPTP */ + /* * Hash by proto,s{addr,port} */ -#ifdef CONFIG_IP_MASQUERADE_PPTP - if (ms->protocol == IPPROTO_GRE) { - /* Ignore the source port (Call ID) when hashing, as - * outbound packets will not be able to supply it... - */ - hash = ip_masq_hash_key(ms->protocol, ms->saddr, 0); - } else -#endif /* CONFIG_IP_MASQUERADE_PPTP */ hash = ip_masq_hash_key(ms->protocol, ms->saddr, ms->sport); ms->s_link = ip_masq_s_tab[hash]; ip_masq_s_tab[hash] = ms; -#ifdef CONFIG_IP_MASQUERADE_IPSEC - /* - * Hash by proto,d{addr,port} - */ - hash = ip_masq_hash_key(ms->protocol, ms->daddr, ms->dport); - ms->d_link = ip_masq_d_tab[hash]; - ip_masq_d_tab[hash] = ms; -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ +#ifdef DEBUG_IP_MASQUERADE_PPTP + printk("MASQ: hashed %d %08X:%04hX->%08X:%04hX into out\n", + ms->protocol, + ms->saddr, + ms->sport, + ms->daddr, + ms->dport); +#endif /* DEBUG_IP_MASQUERADE_PPTP */ ms->flags |= IP_MASQ_F_HASHED; return 1; @@ -515,11 +398,6 @@ static __inline__ int ip_masq_unhash(struct ip_masq *ms) /* * UNhash by s{addr,port} */ -#ifdef CONFIG_IP_MASQUERADE_PPTP - if (ms->protocol == IPPROTO_GRE) { - hash = ip_masq_hash_key(ms->protocol, ms->saddr, 0); - } else -#endif /* CONFIG_IP_MASQUERADE_PPTP */ hash = ip_masq_hash_key(ms->protocol, ms->saddr, ms->sport); for (ms_p = &ip_masq_s_tab[hash]; *ms_p ; ms_p = &(*ms_p)->s_link) if (ms == (*ms_p)) { @@ -527,18 +405,6 @@ static __inline__ int ip_masq_unhash(struct ip_masq *ms) break; } -#ifdef CONFIG_IP_MASQUERADE_IPSEC - /* - * UNhash by d{addr,port} - */ - hash = ip_masq_hash_key(ms->protocol, ms->daddr, ms->dport); - for (ms_p = &ip_masq_d_tab[hash]; *ms_p ; ms_p = &(*ms_p)->d_link) - if (ms == (*ms_p)) { - *ms_p = ms->d_link; - break; - } -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ - ms->flags &= ~IP_MASQ_F_HASHED; return 1; } @@ -561,9 +427,6 @@ ip_masq_in_get(struct iphdr *iph) int protocol; __u32 s_addr, d_addr; __u16 s_port, d_port; -#ifdef CONFIG_IP_MASQUERADE_IPSEC - __u32 cookie; -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ portptr = (__u16 *)&(((char *)iph)[iph->ihl*4]); protocol = iph->protocol; @@ -572,12 +435,14 @@ ip_masq_in_get(struct iphdr *iph) d_addr = iph->daddr; d_port = portptr[1]; -#ifdef CONFIG_IP_MASQUERADE_IPSEC - if (protocol == IPPROTO_UDP && ntohs(s_port) == UDP_PORT_ISAKMP && ntohs(d_port) == UDP_PORT_ISAKMP) { - cookie = *((__u32 *)&portptr[4]); - return ip_masq_in_get_isakmp(protocol, s_addr, s_port, d_addr, d_port, cookie); - } else -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ +#ifdef CONFIG_IP_MASQUERADE_PPTP +/* + * Allow for GRE portlessness... + */ + if (protocol == IPPROTO_GRE) { + s_port = d_port = 0; + } +#endif /* CONFIG_IP_MASQUERADE_PPTP */ return ip_masq_in_get_2(protocol, s_addr, s_port, d_addr, d_port); } @@ -625,156 +490,34 @@ ip_masq_in_get_2(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d } #ifdef CONFIG_IP_MASQUERADE_PPTP - if (protocol == IPPROTO_GRE) { - for(ms = ip_masq_m_tab[hash]; ms ; ms = ms->m_link) { - if (protocol==ms->protocol && -#ifdef CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT - ms->mport == d_port && /* ignore source port */ -#else /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ - ms->mport == 0 && ms->sport == 0 && -#endif /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ - s_addr==ms->daddr && d_addr==ms->maddr) { -#ifdef DEBUG_IP_MASQUERADE_PPTP_VERBOSE - printk(KERN_DEBUG "MASQ: look/in %d %08X:%04hX->%08X:%04hX OK\n", - protocol, - s_addr, - s_port, - d_addr, - d_port); -#endif /* DEBUG_IP_MASQUERADE_PPTP_VERBOSE */ - return ms; - } - } - } -#endif /* CONFIG_IP_MASQUERADE_PPTP */ - - -#ifdef DEBUG_IP_MASQUERADE_VERBOSE - printk("MASQ: look/in %d %08X:%04hX->%08X:%04hX fail\n", - protocol, - s_addr, - s_port, - d_addr, - d_port); -#endif - return NULL; -} - -#ifdef CONFIG_IP_MASQUERADE_IPSEC -struct ip_masq * -ip_masq_in_get_ipsec(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port, __u32 i_spi) -{ - unsigned hash; - struct ip_masq *ms; - - if (protocol != IPPROTO_ESP) { - return ip_masq_in_get_2(protocol,s_addr,s_port,d_addr,d_port); - } - - /* find an entry for a packet coming in from outside, - * or find whether there's a setup pending - */ - - if (i_spi != 0) { - /* there's a SPI - look for a completed entry */ - hash = ip_masq_hash_key(protocol, s_addr, s_port); - for(ms = ip_masq_d_tab[hash]; ms ; ms = ms->d_link) { - if (protocol==ms->protocol && - s_addr==ms->daddr && - d_addr==ms->maddr && - ms->ispi != 0 && i_spi==ms->ispi) { -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "MASQ: IPSEC look/in %08X->%08X:%08X OK\n", - s_addr, - d_addr, - i_spi); -#endif - return ms; - } - } - } - - /* no joy. look for a pending connection - maybe somebody else's - * if we're checking for a pending setup, the d_addr will be zero - * to avoid having to know the masq IP. - */ - hash = ip_masq_hash_key(protocol, s_addr, 0); - for(ms = ip_masq_d_tab[hash]; ms ; ms = ms->d_link) { - if (protocol==ms->protocol && - s_addr==ms->daddr && - (d_addr==0 || d_addr==ms->maddr) && - ms->ispi==0) { -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "MASQ: IPSEC look/in %08X->%08X:0 OK\n", - s_addr, - d_addr - ); -#endif - return ms; - } - } - -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "MASQ: IPSEC look/in %08X->%08X:%08X fail\n", - s_addr, - d_addr, - i_spi); -#endif - return NULL; -} - -struct ip_masq * -ip_masq_in_get_isakmp(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port, __u32 cookie) -{ - unsigned hash; - struct ip_masq *ms; - -#ifdef DEBUG_IP_MASQUERADE_IPSEC - printk(KERN_DEBUG "ip_masq_in_get_isakmp(): "); - printk("%s -> ", in_ntoa(s_addr)); - printk("%s cookie %lX\n", in_ntoa(d_addr), ntohl(cookie)); -#endif /* DEBUG_IP_MASQUERADE_IPSEC */ - - if (cookie == 0) { - printk(KERN_INFO "ip_masq_in_get_isakmp(): "); - printk("zero cookie from %s\n", in_ntoa(s_addr)); - } - - hash = ip_masq_hash_key(protocol, d_addr, d_port); for(ms = ip_masq_m_tab[hash]; ms ; ms = ms->m_link) { - if (protocol==ms->protocol && - cookie==ms->ospi && - ((s_addr==ms->daddr || ms->flags & IP_MASQ_F_NO_DADDR) - ) && - (s_port==ms->dport || ms->flags & IP_MASQ_F_NO_DPORT) && - (d_addr==ms->maddr && d_port==ms->mport)) { -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "MASQ: look/in %d %08X:%04hX->%08X:%04hX %08X OK\n", + if (protocol==ms->protocol && ms->sport == 0 && + s_addr==ms->daddr && d_addr==ms->maddr) { +#ifdef DEBUG_IP_MASQUERADE_PPTP + printk("MASQ: look/in %d %08X:%04hX->%08X:%04hX OK\n", protocol, s_addr, s_port, d_addr, - d_port, - cookie); -#endif + d_port); +#endif /* DEBUG_IP_MASQUERADE_PPTP */ return ms; } } +#endif /* CONFIG_IP_MASQUERADE_PPTP */ -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "MASQ: look/in %d %08X:%04hX->%08X:%04hX %08X fail\n", + +#ifdef DEBUG_IP_MASQUERADE_VERBOSE + printk("MASQ: look/in %d %08X:%04hX->%08X:%04hX fail\n", protocol, s_addr, s_port, d_addr, - d_port, - cookie); + d_port); #endif return NULL; } -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ - /* * Returns ip_masq associated with addresses found in iph. * called for pkts coming from inside-to-OUTside the firewall. @@ -787,10 +530,6 @@ ip_masq_out_get(struct iphdr *iph) int protocol; __u32 s_addr, d_addr; __u16 s_port, d_port; -#ifdef CONFIG_IP_MASQUERADE_IPSEC - __u32 cookie; -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ - portptr = (__u16 *)&(((char *)iph)[iph->ihl*4]); protocol = iph->protocol; @@ -799,12 +538,14 @@ ip_masq_out_get(struct iphdr *iph) d_addr = iph->daddr; d_port = portptr[1]; -#ifdef CONFIG_IP_MASQUERADE_IPSEC - if (protocol == IPPROTO_UDP && ntohs(s_port) == UDP_PORT_ISAKMP && ntohs(d_port) == UDP_PORT_ISAKMP) { - cookie = *((__u32 *)&portptr[4]); - return ip_masq_out_get_isakmp(protocol, s_addr, s_port, d_addr, d_port, cookie); - } else -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ +#ifdef CONFIG_IP_MASQUERADE_PPTP +/* + * Allow for GRE portlessness... + */ + if (protocol == IPPROTO_GRE) { + s_port = d_port = 0; + } +#endif /* CONFIG_IP_MASQUERADE_PPTP */ return ip_masq_out_get_2(protocol, s_addr, s_port, d_addr, d_port); } @@ -830,35 +571,6 @@ ip_masq_out_get_2(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 struct ip_masq *ms; -#ifdef CONFIG_IP_MASQUERADE_PPTP -#ifdef CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT - if (protocol == IPPROTO_GRE) { - /* - * Call ID is saved in source port number, - * but we have no way of knowing it on the outbound packet... - * we only know the *other side's* Call ID - */ - - hash = ip_masq_hash_key(protocol, s_addr, 0); - for(ms = ip_masq_s_tab[hash]; ms ; ms = ms->s_link) { - if (protocol == ms->protocol && - s_addr == ms->saddr && (s_port == 0 || s_port == ms->sport) && - d_addr == ms->daddr && d_port == ms->dport ) { -#ifdef DEBUG_IP_MASQUERADE_VERBOSE - printk(KERN_DEBUG "MASQ: lk/out2 %d %08X:%04hX->%08X:%04hX OK\n", - protocol, - s_addr, - s_port, - d_addr, - d_port); -#endif /* DEBUG_IP_MASQUERADE_VERBOSE */ - return ms; - } - } - } -#endif /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ -#endif /* CONFIG_IP_MASQUERADE_PPTP */ - hash = ip_masq_hash_key(protocol, s_addr, s_port); for(ms = ip_masq_s_tab[hash]; ms ; ms = ms->s_link) { if (protocol == ms->protocol && @@ -903,92 +615,6 @@ ip_masq_out_get_2(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 return NULL; } -#ifdef CONFIG_IP_MASQUERADE_IPSEC -struct ip_masq * -ip_masq_out_get_ipsec(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port, __u32 o_spi) -{ - unsigned hash; - struct ip_masq *ms; - - if (protocol != IPPROTO_ESP) { - return ip_masq_out_get_2(protocol,s_addr,s_port,d_addr,d_port); - } - - hash = ip_masq_hash_key(protocol, s_addr, s_port); - for(ms = ip_masq_s_tab[hash]; ms ; ms = ms->s_link) { - if (protocol==ms->protocol && - s_addr==ms->saddr && - d_addr==ms->daddr && - o_spi==ms->ospi) { -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "MASQ: IPSEC look/out %08X:%08X->%08X OK\n", - s_addr, - o_spi, - d_addr); -#endif - return ms; - } - } - -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "MASQ: IPSEC look/out %08X:%08X->%08X fail\n", - s_addr, - o_spi, - d_addr); -#endif - return NULL; -} - -struct ip_masq * -ip_masq_out_get_isakmp(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port, __u32 cookie) -{ - unsigned hash; - struct ip_masq *ms; - -#ifdef DEBUG_IP_MASQUERADE_IPSEC - printk(KERN_DEBUG "ip_masq_out_get_isakmp(): "); - printk("%s -> ", in_ntoa(s_addr)); - printk("%s cookie %lX\n", in_ntoa(d_addr), ntohl(cookie)); -#endif /* DEBUG_IP_MASQUERADE_IPSEC */ - - if (cookie == 0) { - printk(KERN_INFO "ip_masq_out_get_isakmp(): "); - printk("zero cookie from %s\n", in_ntoa(s_addr)); - } - - hash = ip_masq_hash_key(protocol, s_addr, s_port); - for(ms = ip_masq_s_tab[hash]; ms ; ms = ms->s_link) { - if (protocol == ms->protocol && - cookie == ms->ospi && - s_addr == ms->saddr && s_port == ms->sport && - d_addr == ms->daddr && d_port == ms->dport ) { -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "MASQ: lk/out1 %d %08X:%04hX->%08X:%04hX %08X OK\n", - protocol, - s_addr, - s_port, - d_addr, - d_port, - cookie); -#endif - return ms; - } - } - -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "MASQ: lk/out1 %d %08X:%04hX->%08X:%04hX %08X fail\n", - protocol, - s_addr, - s_port, - d_addr, - d_port, - cookie); -#endif - return NULL; -} - -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ - /* * Returns ip_masq for given proto,m_addr,m_port. * called by allocation routine to find an unused m_port. @@ -1137,34 +763,6 @@ struct ip_masq * ip_masq_new_enh(struct device *dev, int proto, __u32 saddr, __u for (ports_tried = 0; (*free_ports_p && (ports_tried <= (PORT_MASQ_END - PORT_MASQ_BEGIN))); ports_tried++){ - -#ifdef CONFIG_IP_MASQUERADE_PPTP -#ifndef CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT - /* Ignoring PPTP call IDs. - * Don't needlessly increase the TCP port pointer. - */ - if (proto == IPPROTO_GRE) { - ms->mport = 0; - mst = NULL; - } else { -#endif /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ -#endif /* CONFIG_IP_MASQUERADE_PPTP */ - -#ifdef CONFIG_IP_MASQUERADE_IPSEC - /* ESP masq keys off the SPI, not the port number. - * Don't needlessly increase the TCP port pointer. - */ - if (proto == IPPROTO_ESP) { - ms->mport = 0; - mst = NULL; - } else { - if (proto == IPPROTO_UDP && ntohs(sport) == UDP_PORT_ISAKMP && ntohs(dport) == UDP_PORT_ISAKMP) { - /* the port number cannot be changed */ - ms->mport = htons(UDP_PORT_ISAKMP); - mst = NULL; - } else { -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ - save_flags(flags); cli(); @@ -1180,23 +778,17 @@ struct ip_masq * ip_masq_new_enh(struct device *dev, int proto, __u32 saddr, __u restore_flags(flags); +#ifdef CONFIG_IP_MASQUERADE_PPTP + if (proto == IPPROTO_GRE) { + ms->mport = 0; + } +#endif /* CONFIG_IP_MASQUERADE_PPTP */ + /* * lookup to find out if this port is used. */ mst = ip_masq_getbym(proto, ms->maddr, ms->mport); - -#ifdef CONFIG_IP_MASQUERADE_PPTP -#ifndef CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT - } -#endif /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ -#endif /* CONFIG_IP_MASQUERADE_PPTP */ - -#ifdef CONFIG_IP_MASQUERADE_IPSEC - } - } -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ - if (mst == NULL || matchport) { save_flags(flags); cli(); @@ -1237,11 +829,11 @@ struct ip_masq * ip_masq_new(struct device *dev, int proto, __u32 saddr, __u16 s void ip_masq_set_expire(struct ip_masq *ms, unsigned long tout) { - /* There Can Be Only One (timer on a masq table entry, that is) */ - del_timer(&ms->timer); if (tout) { ms->timer.expires = jiffies+tout; add_timer(&ms->timer); + } else { + del_timer(&ms->timer); } } @@ -1258,41 +850,40 @@ static void recalc_check(struct udphdr *uh, __u32 saddr, #ifdef CONFIG_IP_MASQUERADE_PPTP /* - * Masquerade of GRE connections - * to support a PPTP VPN client or server. + * Quick-and-dirty handling of GRE connections + * to support masquerading a Microsoft PPTP client. + * John Hardin gets all blame... */ /* * Handle outbound GRE packets. * - * This is largely a copy of ip_fw_masquerade() + * This is largely a copy of ip_fw_masquerade(), unless I decide + * to fold it in *there* rather than duplicating code *here*... + * + * GRE doesn't have ports, so we use dummy ports 0/0 and only support + * one GRE session per remote server. */ int ip_fw_masq_gre(struct sk_buff **skb_p, struct device *dev) { struct sk_buff *skb = *skb_p; - struct iphdr *iph = skb->h.iph; - struct pptp_gre_header *greh; + struct iphdr *iph = skb->h.iph; + struct grehdr *greh; #ifdef DEBUG_IP_MASQUERADE_PPTP -#ifdef DEBUG_IP_MASQUERADE_PPTP_VERBOSE - __u8 *greraw; -#endif /* DEBUG_IP_MASQUERADE_PPTP_VERBOSE */ + __u8 *greraw; #endif /* DEBUG_IP_MASQUERADE_PPTP */ struct ip_masq *ms; - unsigned long flags; + unsigned long flags; - greh = (struct pptp_gre_header *)&(((char *)iph)[iph->ihl*4]); + greh = (struct grehdr *)&(((char *)iph)[iph->ihl*4]); #ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_fw_masq_gre(): "); - printk("Outbound GRE packet from %s", in_ntoa(iph->saddr)); - printk(" to %s\n", in_ntoa(iph->daddr)); + printk("Outbound GRE packet from %lX to %lX\n", ntohl(iph->saddr), ntohl(iph->daddr)); -#ifdef DEBUG_IP_MASQUERADE_PPTP_VERBOSE greraw = (__u8 *) greh; - printk(KERN_DEBUG "ip_fw_masq_gre(): "); printk("GRE raw: %X %X %X %X %X %X %X %X %X %X %X %X.\n", greraw[0], greraw[1], @@ -1306,7 +897,6 @@ int ip_fw_masq_gre(struct sk_buff **skb_p, struct device *dev) greraw[9], greraw[10], greraw[11]); - printk(KERN_DEBUG "ip_fw_masq_gre(): "); printk("GRE C: %d R: %d K: %d S: %d s: %d recur: %X.\n", greh->has_cksum, greh->has_routing, @@ -1314,41 +904,41 @@ int ip_fw_masq_gre(struct sk_buff **skb_p, struct device *dev) greh->has_seq, greh->is_strict, greh->recur); - printk(KERN_DEBUG "ip_fw_masq_gre(): "); printk("GRE flags: %X ver: %X.\n", greh->flags, greh->version); - printk(KERN_DEBUG "ip_fw_masq_gre(): "); printk("GRE proto: %X.\n", ntohs(greh->protocol)); -#endif /* DEBUG_IP_MASQUERADE_PPTP_VERBOSE */ #endif /* DEBUG_IP_MASQUERADE_PPTP */ - if (ntohs(greh->protocol) != 0x880B) { + if (ntohs(greh->protocol) != 0x880b) { #ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_INFO "ip_fw_masq_gre(): "); printk("GRE protocol %X not 0x880B (non-PPTP encap?) - discarding.\n", ntohs(greh->protocol)); #endif /* DEBUG_IP_MASQUERADE_PPTP */ return -1; } /* - * Look for masq table entry + * Now hunt the list to see if we have an old entry */ - ms = ip_masq_out_get_2(IPPROTO_GRE, - iph->saddr, 0, - iph->daddr, 0); - + ms = ip_masq_out_get(iph); if (ms!=NULL) { - /* delete the expiration timer */ ip_masq_set_expire(ms,0); /* + * Until we tie into the PPTP control channel, + * there's no way to detect the data channel going + * down. Therefore, we may have an invalid GRE masq + * from a previous session if, for example, the PPP + * link goes down and is brought right back up and the + * PPTP link tries to be established before the masq + * entry expires (see the timer below). * Make sure that the masq IP address is correct - * for dynamic IP... + * for the current session... */ - if ( (ms->maddr != dev->pa_addr) && (sysctl_ip_dynaddr & 3) ) { - printk(KERN_INFO "ip_fw_masq_gre(): "); - printk("change maddr from %s", in_ntoa(ms->maddr)); - printk(" to %s\n", in_ntoa(dev->pa_addr)); + if (ms->maddr != dev->pa_addr) { +#ifdef DEBUG_IP_MASQUERADE_PPTP + printk("GRE masq IP changed from %lX to %lX\n", + ntohl(ms->maddr),ntohl(dev->pa_addr)); +#endif /* DEBUG_IP_MASQUERADE_PPTP */ save_flags(flags); cli(); ip_masq_unhash(ms); @@ -1356,49 +946,42 @@ int ip_fw_masq_gre(struct sk_buff **skb_p, struct device *dev) ip_masq_hash(ms); restore_flags(flags); } - } else { - /* - * Nope, not found, create a new entry for it, maybe - */ + } + + /* + * Nope, not found, create a new entry for it + */ -#ifdef CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT - /* masq table entry has to come from control channel sniffing. - * If we can't find one, it may have expired. - * How can this happen with the control channel active? - */ - printk(KERN_INFO "ip_fw_masq_gre(): "); - printk("Outbound GRE to %s has no masq table entry.\n", - in_ntoa(iph->daddr)); - return -1; -#else /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ - /* call IDs ignored, can create masq table entries on the fly. */ - ms = ip_masq_new(dev, iph->protocol, + if (ms==NULL) + { + ms = ip_masq_new_enh(dev, iph->protocol, iph->saddr, 0, iph->daddr, 0, + 0, 0); - - if (ms == NULL) { - printk(KERN_NOTICE "ip_fw_masq_gre(): Couldn't create masq table entry.\n"); + if (ms == NULL) return -1; - } -#endif /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ } + /* + * Change the fragments origin + */ + /* - * Set iph source addr from ip_masq obj. + * Set iph addr from ip_masq obj. */ iph->saddr = ms->maddr; + /* * set timeout and check IP header */ - ip_masq_set_expire(ms, MASQUERADE_EXPIRE_PPTP); + ip_masq_set_expire(ms, 6000); /* 60 second timeout */ ip_send_check(iph); #ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "MASQ: GRE O-routed from %s over %s\n", - in_ntoa(ms->maddr), dev->name); + printk("GRE O-routed from %lX over %s\n",ntohl(ms->maddr),dev->name); #endif /* DEBUG_IP_MASQUERADE_PPTP */ return 0; @@ -1407,32 +990,34 @@ int ip_fw_masq_gre(struct sk_buff **skb_p, struct device *dev) /* * Handle inbound GRE packets. * + * NT PPTP uses a plain TCP connection to port 1723 to set up the + * GRE encapsulated channel. To figure out where to send the + * inbound GRE packet, we'll look for the masq record for that. + * This means that if you're not masquerading the outbound control + * session, the inbound data session will fail. + * + * To keep this simple, we'll only support one inbound GRE connection + * per PPTP server. */ int ip_fw_demasq_gre(struct sk_buff **skb_p, struct device *dev) { struct sk_buff *skb = *skb_p; struct iphdr *iph = skb->h.iph; - struct pptp_gre_header *greh; + struct grehdr *greh; #ifdef DEBUG_IP_MASQUERADE_PPTP -#ifdef DEBUG_IP_MASQUERADE_PPTP_VERBOSE __u8 *greraw; -#endif /* DEBUG_IP_MASQUERADE_PPTP_VERBOSE */ #endif /* DEBUG_IP_MASQUERADE_PPTP */ struct ip_masq *ms; - greh = (struct pptp_gre_header *)&(((char *)iph)[iph->ihl*4]); + greh = (struct grehdr *)&(((char *)iph)[iph->ihl*4]); #ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_fw_demasq_gre(): "); - printk("Inbound GRE packet from %s", in_ntoa(iph->saddr)); - printk(" to %s\n", in_ntoa(iph->daddr)); + printk("Inbound GRE packet from %lX to %lX\n", ntohl(iph->saddr), ntohl(iph->daddr)); -#ifdef DEBUG_IP_MASQUERADE_PPTP_VERBOSE greraw = (__u8 *) greh; - printk(KERN_DEBUG "ip_fw_demasq_gre(): "); printk("GRE raw: %X %X %X %X %X %X %X %X %X %X %X %X.\n", greraw[0], greraw[1], @@ -1446,7 +1031,6 @@ int ip_fw_demasq_gre(struct sk_buff **skb_p, struct device *dev) greraw[9], greraw[10], greraw[11]); - printk(KERN_DEBUG "ip_fw_demasq_gre(): "); printk("GRE C: %d R: %d K: %d S: %d s: %d recur: %X.\n", greh->has_cksum, greh->has_routing, @@ -1454,919 +1038,51 @@ int ip_fw_demasq_gre(struct sk_buff **skb_p, struct device *dev) greh->has_seq, greh->is_strict, greh->recur); - printk(KERN_DEBUG "ip_fw_demasq_gre(): "); printk("GRE flags: %X ver: %X.\n", greh->flags, greh->version); - printk(KERN_DEBUG "ip_fw_demasq_gre(): "); printk("GRE proto: %X.\n", ntohs(greh->protocol)); -#endif /* DEBUG_IP_MASQUERADE_PPTP_VERBOSE */ - -#ifdef CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT - printk(KERN_DEBUG "ip_fw_demasq_gre(): "); - printk("PPTP call ID: %X.\n", ntohs(greh->call_id)); -#endif /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ - #endif /* DEBUG_IP_MASQUERADE_PPTP */ - if (ntohs(greh->protocol) != 0x880B) { + if (ntohs(greh->protocol) != 0x880b) { #ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_INFO "ip_fw_demasq_gre(): "); printk("GRE protocol %X not 0x880B (non-PPTP encap?) - discarding.\n", ntohs(greh->protocol)); #endif /* DEBUG_IP_MASQUERADE_PPTP */ return -1; } /* - * Look for a masq table entry and reroute if found + * reroute to original host if found... */ -#ifdef CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT - ms = ip_masq_getbym(IPPROTO_GRE, - iph->daddr, greh->call_id); -#else /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ - ms = ip_masq_in_get_2(IPPROTO_GRE, - iph->saddr, 0, - iph->daddr, 0); -#endif /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ + ms = ip_masq_in_get(iph); if (ms != NULL) { - /* delete the expiration timer */ + /* Stop the timer ticking.... */ ip_masq_set_expire(ms,0); iph->daddr = ms->saddr; -#ifdef CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT - /* - * change peer call ID to original value - * (saved in masq table source port) - */ - - greh->call_id = ms->sport; - -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_fw_demasq_gre(): "); - printk("inbound PPTP from %s call ID now %X\n", - in_ntoa(iph->saddr), ntohs(greh->call_id)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ -#endif /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ /* - * resum checksums and set timeout + * Yug! adjust IP checksums, also update + * timeouts. */ - ip_masq_set_expire(ms, MASQUERADE_EXPIRE_PPTP); + ip_masq_set_expire(ms, 6000); /* 60 second timeout */ ip_send_check(iph); #ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "MASQ: GRE I-routed to %s\n", in_ntoa(iph->daddr)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ + printk("GRE I-routed to %lX\n",ntohl(iph->daddr)); +#endif return 1; } /* sorry, all this trouble for a no-hit :) */ - printk(KERN_INFO "ip_fw_demasq_gre(): "); - printk("Inbound from %s has no masq table entry.\n", in_ntoa(iph->saddr)); return 0; } -#ifdef CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT -/* - * Define all of the PPTP control channel message structures. - * Sniff the control channel looking for start- and end-call - * messages, and masquerade the Call ID as if it was a TCP - * port. - */ - -#define PPTP_CONTROL_PACKET 1 -#define PPTP_MGMT_PACKET 2 -#define PPTP_MAGIC_COOKIE 0x1A2B3C4D - -struct PptpPacketHeader { - __u16 packetLength; - __u16 packetType; - __u32 magicCookie; -}; - -/* PptpControlMessageType values */ -#define PPTP_START_SESSION_REQUEST 1 -#define PPTP_START_SESSION_REPLY 2 -#define PPTP_STOP_SESSION_REQUEST 3 -#define PPTP_STOP_SESSION_REPLY 4 -#define PPTP_ECHO_REQUEST 5 -#define PPTP_ECHO_REPLY 6 -#define PPTP_OUT_CALL_REQUEST 7 -#define PPTP_OUT_CALL_REPLY 8 -#define PPTP_IN_CALL_REQUEST 9 -#define PPTP_IN_CALL_REPLY 10 -#define PPTP_CALL_CLEAR_REQUEST 11 -#define PPTP_CALL_DISCONNECT_NOTIFY 12 -#define PPTP_CALL_ERROR_NOTIFY 13 -#define PPTP_WAN_ERROR_NOTIFY 14 -#define PPTP_SET_LINK_INFO 15 - -struct PptpControlHeader { - __u16 messageType; - __u16 reserved; -}; - -struct PptpOutCallRequest { - __u16 callID; - __u16 callSerialNumber; - __u32 minBPS; - __u32 maxBPS; - __u32 bearerType; - __u32 framingType; - __u16 packetWindow; - __u16 packetProcDelay; - __u16 reserved1; - __u16 phoneNumberLength; - __u16 reserved2; - __u8 phoneNumber[64]; - __u8 subAddress[64]; -}; - -struct PptpOutCallReply { - __u16 callID; - __u16 peersCallID; - __u8 resultCode; - __u8 generalErrorCode; - __u16 causeCode; - __u32 connectSpeed; - __u16 packetWindow; - __u16 packetProcDelay; - __u32 physChannelID; -}; - -struct PptpInCallRequest { - __u16 callID; - __u16 callSerialNumber; - __u32 callBearerType; - __u32 physChannelID; - __u16 dialedNumberLength; - __u16 dialingNumberLength; - __u8 dialedNumber[64]; - __u8 dialingNumber[64]; - __u8 subAddress[64]; -}; - -struct PptpInCallReply { - __u16 callID; - __u16 peersCallID; - __u8 resultCode; - __u8 generalErrorCode; - __u16 packetWindow; - __u16 packetProcDelay; - __u16 reserved; -}; - -struct PptpCallDisconnectNotify { - __u16 callID; - __u8 resultCode; - __u8 generalErrorCode; - __u16 causeCode; - __u16 reserved; - __u8 callStatistics[128]; -}; - -struct PptpWanErrorNotify { - __u16 peersCallID; - __u16 reserved; - __u32 crcErrors; - __u32 framingErrors; - __u32 hardwareOverRuns; - __u32 bufferOverRuns; - __u32 timeoutErrors; - __u32 alignmentErrors; -}; - -struct PptpSetLinkInfo { - __u16 peersCallID; - __u16 reserved; - __u32 sendAccm; - __u32 recvAccm; -}; - - -/* Packet sent to or from PPTP control port. Process it. */ -/* Yes, all of this should be in a kernel module. Real Soon Now... */ -void ip_masq_pptp(struct sk_buff *skb, struct ip_masq *ms, struct device *dev) -{ - struct iphdr *iph = skb->h.iph; - struct PptpPacketHeader *pptph = NULL; - struct PptpControlHeader *ctlh = NULL; - union { - char *req; - struct PptpOutCallRequest *ocreq; - struct PptpOutCallReply *ocack; - struct PptpInCallRequest *icreq; - struct PptpInCallReply *icack; - struct PptpCallDisconnectNotify *disc; - struct PptpWanErrorNotify *wanerr; - struct PptpSetLinkInfo *setlink; - } pptpReq; - struct ip_masq *ms_gre = NULL; - - /* - * The GRE data channel will be treated as the "control channel" - * for the purposes of masq because there are keepalives happening - * on the control channel, whereas the data channel may be subject - * to relatively long periods of inactivity. - */ - - pptph = (struct PptpPacketHeader *)&(((char *)iph)[sizeof(struct iphdr) + sizeof(struct tcphdr)]); -#ifdef DEBUG_IP_MASQUERADE_PPTP_VERBOSE - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("LEN=%d TY=%d MC=%lX", ntohs(pptph->packetLength), - ntohs(pptph->packetType), ntohl(pptph->magicCookie)); - printk(" from %s", in_ntoa(iph->saddr)); - printk(" to %s\n", in_ntoa(iph->daddr)); -#endif /* DEBUG_IP_MASQUERADE_PPTP_VERBOSE */ - - if (ntohs(pptph->packetType) == PPTP_CONTROL_PACKET && - ntohl(pptph->magicCookie) == PPTP_MAGIC_COOKIE) { -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("PPTP control packet from %s", in_ntoa(iph->saddr)); - printk(" to %s\n", in_ntoa(iph->daddr)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - ctlh = (struct PptpControlHeader *)&(((char*)pptph)[sizeof(struct PptpPacketHeader)]); - pptpReq.req = &(((char*)ctlh)[sizeof(struct PptpControlHeader)]); -#ifdef DEBUG_IP_MASQUERADE_PPTP_VERBOSE - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("MTY=%X R0=%X\n", - ntohs(ctlh->messageType), ctlh->reserved); -#endif /* DEBUG_IP_MASQUERADE_PPTP_VERBOSE */ - - switch (ntohs(ctlh->messageType)) - { - case PPTP_OUT_CALL_REQUEST: - if (iph->daddr == ms->daddr) /* outbound only */ - { -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("Call request, call ID %X\n", - ntohs(pptpReq.ocreq->callID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - ms_gre = ip_masq_new(dev, IPPROTO_GRE, - ms->saddr, pptpReq.ocreq->callID, - ms->daddr, 0, - 0); - if (ms_gre != NULL) - { - ms->control = ms_gre; - ms_gre->flags |= IP_MASQ_F_CONTROL; - ip_masq_set_expire(ms_gre, 0); - ip_masq_set_expire(ms_gre, 2*60*HZ); - pptpReq.ocreq->callID = ms_gre->mport; - printk(KERN_INFO "ip_masq_pptp(): "); - printk("Req outcall PPTP sess %s", in_ntoa(ms->saddr)); - printk(" -> %s", in_ntoa(ms->daddr)); - printk(" Call ID %X -> %X.\n", ntohs(ms_gre->sport), ntohs(ms_gre->mport)); -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("masqed call ID %X\n", - ntohs(pptpReq.ocreq->callID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - } else { - printk(KERN_NOTICE "ip_masq_pptp(): "); - printk("Couldn't create GRE masq table entry (%s)\n", "OUT_CALL_REQ"); - } - } - break; - case PPTP_OUT_CALL_REPLY: - if (iph->saddr == ms->daddr) /* inbound (masqueraded client) */ - { -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("Call reply, peer call ID %X\n", - ntohs(pptpReq.ocack->peersCallID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - ms_gre = ip_masq_getbym(IPPROTO_GRE, - ms->maddr, pptpReq.ocack->peersCallID); - if (ms_gre != NULL) - { - ip_masq_set_expire(ms_gre, 0); - ip_masq_set_expire(ms_gre, 2*60*HZ); - pptpReq.ocack->peersCallID = ms_gre->sport; - printk(KERN_INFO "ip_masq_pptp(): "); - printk("Estab outcall PPTP sess %s", in_ntoa(ms->saddr)); - printk(" -> %s", in_ntoa(ms->daddr)); - printk(" Call ID %X -> %X.\n", ntohs(ms_gre->sport), ntohs(ms_gre->mport)); -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("unmasqed call ID %X\n", - ntohs(pptpReq.ocack->callID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - } else { - printk(KERN_INFO "ip_masq_pptp(): "); - printk("Lost GRE masq table entry (%s)\n", "OUT_CALL_REPLY"); - } - } - break; - case PPTP_IN_CALL_REQUEST: - if (iph->daddr == ms->daddr) /* outbound only */ - { -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("Call request, call ID %X\n", - ntohs(pptpReq.icreq->callID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - ms_gre = ip_masq_new(dev, IPPROTO_GRE, - ms->saddr, pptpReq.icreq->callID, - ms->daddr, 0, - 0); - if (ms_gre != NULL) - { - ms->control = ms_gre; - ms_gre->flags |= IP_MASQ_F_CONTROL; - ip_masq_set_expire(ms_gre, 0); - ip_masq_set_expire(ms_gre, 2*60*HZ); - pptpReq.icreq->callID = ms_gre->mport; - printk(KERN_INFO "ip_masq_pptp(): "); - printk("Req incall PPTP sess %s", in_ntoa(ms->saddr)); - printk(" -> %s", in_ntoa(ms->daddr)); - printk(" Call ID %X -> %X.\n", ntohs(ms_gre->sport), ntohs(ms_gre->mport)); -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("masqed call ID %X\n", - ntohs(pptpReq.icreq->callID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - } else { - printk(KERN_NOTICE "ip_masq_pptp(): "); - printk("Couldn't create GRE masq table entry (%s)\n", "IN_CALL_REQ"); - } - } - break; - case PPTP_IN_CALL_REPLY: - if (iph->saddr == ms->daddr) /* inbound (masqueraded client) */ - { -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("Call reply, peer call ID %X\n", - ntohs(pptpReq.icack->peersCallID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - ms_gre = ip_masq_getbym(IPPROTO_GRE, - ms->maddr, pptpReq.icack->peersCallID); - if (ms_gre != NULL) - { - ip_masq_set_expire(ms_gre, 0); - ip_masq_set_expire(ms_gre, 2*60*HZ); - pptpReq.icack->peersCallID = ms_gre->sport; - printk(KERN_INFO "ip_masq_pptp(): "); - printk("Estab incall PPTP sess %s", in_ntoa(ms->saddr)); - printk(" -> %s", in_ntoa(ms->daddr)); - printk(" Call ID %X -> %X.\n", ntohs(ms_gre->sport), ntohs(ms_gre->mport)); -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("unmasqed call ID %X\n", - ntohs(pptpReq.icack->callID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - } else { - printk(KERN_INFO "ip_masq_pptp(): "); - printk("Lost GRE masq table entry (%s)\n", "IN_CALL_REPLY"); - } - } - break; - case PPTP_CALL_DISCONNECT_NOTIFY: - if (iph->daddr == ms->daddr) /* outbound only */ - { -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("Disconnect notify, call ID %X\n", - ntohs(pptpReq.disc->callID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - ms_gre = ip_masq_out_get_2(IPPROTO_GRE, - iph->saddr, pptpReq.disc->callID, - iph->daddr, 0); - if (ms_gre != NULL) - { - /* - * expire the data channel - * table entry quickly now. - */ - ip_masq_set_expire(ms_gre, 0); - ip_masq_set_expire(ms_gre, 30*HZ); - ms->control = NULL; - ms_gre->flags &= ~IP_MASQ_F_CONTROL; - pptpReq.disc->callID = ms_gre->mport; - printk(KERN_INFO "ip_masq_pptp(): "); - printk("Disconnect PPTP sess %s", in_ntoa(ms->saddr)); - printk(" -> %s", in_ntoa(ms->daddr)); - printk(" Call ID %X -> %X.\n", ntohs(ms_gre->sport), ntohs(ms_gre->mport)); -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("masqed call ID %X\n", - ntohs(pptpReq.disc->callID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - } - } - break; - case PPTP_WAN_ERROR_NOTIFY: - if (iph->saddr == ms->daddr) /* inbound only */ - { -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("Error notify, peer call ID %X\n", - ntohs(pptpReq.wanerr->peersCallID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - ms_gre = ip_masq_getbym(IPPROTO_GRE, - ms->maddr, pptpReq.wanerr->peersCallID); - if (ms_gre != NULL) - { - pptpReq.wanerr->peersCallID = ms_gre->sport; -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("unmasqed call ID %X\n", - ntohs(pptpReq.wanerr->peersCallID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - } else { - printk(KERN_INFO "ip_masq_pptp(): "); - printk("Lost GRE masq table entry (%s)\n", "WAN_ERROR_NOTIFY"); - } - } - break; - case PPTP_SET_LINK_INFO: - if (iph->saddr == ms->daddr) /* inbound only */ - { -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("Set link info, peer call ID %X\n", - ntohs(pptpReq.setlink->peersCallID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - ms_gre = ip_masq_getbym(IPPROTO_GRE, - ms->maddr, pptpReq.setlink->peersCallID); - if (ms_gre != NULL) - { - pptpReq.setlink->peersCallID = ms_gre->sport; -#ifdef DEBUG_IP_MASQUERADE_PPTP - printk(KERN_DEBUG "ip_masq_pptp(): "); - printk("unmasqed call ID %X\n", - ntohs(pptpReq.setlink->peersCallID)); -#endif /* DEBUG_IP_MASQUERADE_PPTP */ - } else { - printk(KERN_INFO "ip_masq_pptp(): "); - printk("Lost GRE masq table entry (%s)\n", "SET_LINK_INFO"); - } - } - break; - } - } -} -#endif /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ - -static struct symbol_table pptp_masq_syms = { -#include - X(ip_fw_masq_gre), - X(ip_fw_demasq_gre), -#ifdef CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT - X(ip_masq_pptp), -#endif /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ -#include -}; - #endif /* CONFIG_IP_MASQUERADE_PPTP */ -#ifdef CONFIG_IP_MASQUERADE_IPSEC -/* - * Quick-and-dirty handling of ESP connections - * John Hardin gets all blame... - */ - -/* - * Handle outbound ESP packets. - * - * This is largely a copy of ip_fw_masquerade() - * - * To associate inbound traffic with outbound traffic, we only - * allow one session per remote host to be negotiated at a time. - * If a packet comes in and there's no masq table entry for it, - * then check for other masq table entries for the same server - * with the inbound SPI set to zero (i.e. no response yet). If - * found, discard the packet. - * This will DoS the server for the duration of the connection - * attempt, so keep the masq entry's lifetime short until a - * response comes in. - * If multiple masqueraded hosts are in contention for the same - * remote host, enforce round-robin access. This may lead to - * misassociation of response traffic if the response is delayed - * a great deal, but the masqueraded hosts will clean that up - * if it happens. - */ - -int ip_fw_masq_esp(struct sk_buff **skb_p, struct device *dev) -{ - struct sk_buff *skb = *skb_p; - struct iphdr *iph = skb->h.iph; - struct ip_masq *ms; - unsigned long flags; - __u32 o_spi; - __u16 fake_sport; - unsigned long timeout = MASQUERADE_EXPIRE_IPSEC; - - o_spi = *((__u32 *)&(((char *)iph)[iph->ihl*4])); - fake_sport = (__u16) ntohl(o_spi) & 0xffff; - -#ifdef DEBUG_IP_MASQUERADE_IPSEC - printk(KERN_DEBUG "ip_fw_masq_esp(): "); - printk("pkt %s", in_ntoa(iph->saddr)); - printk(" -> %s SPI %lX (fakeport %X)\n", in_ntoa(iph->daddr), ntohl(o_spi), fake_sport); -#endif /* DEBUG_IP_MASQUERADE_IPSEC */ - - if (o_spi == 0) { - /* illegal SPI - discard */ - printk(KERN_INFO "ip_fw_masq_esp(): "); - printk("zero SPI from %s discarded\n", in_ntoa(iph->saddr)); - return -1; - } - - /* - * Look for masq table entry - */ - - ms = ip_masq_out_get_ipsec(IPPROTO_ESP, - iph->saddr, fake_sport, - iph->daddr, 0, - o_spi); - - if (ms!=NULL) { - if (ms->ispi == IPSEC_INIT_SQUELCHED) { - /* squelched: toss the packet without changing the timer */ -#ifdef DEBUG_IP_MASQUERADE_IPSEC - printk(KERN_INFO "ip_fw_masq_esp(): "); - printk("init %s ", in_ntoa(iph->saddr)); - printk("-> %s SPI %lX ", in_ntoa(iph->daddr), ntohl(o_spi)); - printk("squelched\n"); -#endif /* DEBUG_IP_MASQUERADE_IPSEC */ - return -1; - } - - /* delete the expiration timer */ - ip_masq_set_expire(ms,0); - - /* - * Make sure that the masq IP address is correct - * for dynamic IP... - */ - if ( (ms->maddr != dev->pa_addr) && (sysctl_ip_dynaddr & 3) ) { - printk(KERN_INFO "ip_fw_masq_esp(): "); - printk("change maddr from %s", in_ntoa(ms->maddr)); - printk(" to %s\n", in_ntoa(dev->pa_addr)); - save_flags(flags); - cli(); - ip_masq_unhash(ms); - ms->maddr = dev->pa_addr; - ip_masq_hash(ms); - restore_flags(flags); - } - - if (ms->ispi == 0) { - /* no response yet, keep timeout short */ - timeout = MASQUERADE_EXPIRE_IPSEC_INIT; - if (ms->blocking) { - /* prevent DoS: limit init packet timer resets */ - ms->ocnt++; - #ifdef DEBUG_IP_MASQUERADE_IPSEC - printk(KERN_INFO "ip_fw_masq_esp(): "); - printk("init %s ", in_ntoa(iph->saddr)); - printk("-> %s SPI %lX ", in_ntoa(iph->daddr), ntohl(o_spi)); - printk("retry %d\n", ms->ocnt); - #endif /* DEBUG_IP_MASQUERADE_IPSEC */ - if (ms->ocnt > IPSEC_INIT_RETRIES) { - /* more than IPSEC_INIT_RETRIES tries, give up */ - printk(KERN_INFO "ip_fw_masq_esp(): "); - printk("init %s ", in_ntoa(iph->saddr)); - printk("-> %s SPI %lX ", in_ntoa(iph->daddr), ntohl(o_spi)); - printk("no response after %d tries, unblocking & squelching\n", ms->ocnt); - /* squelch that source+SPI for a bit */ - timeout = 30*HZ; - save_flags(flags); - cli(); - ip_masq_unhash(ms); - ms->ispi = IPSEC_INIT_SQUELCHED; - ms->dport = IPSEC_INIT_SQUELCHED; - ip_masq_hash(ms); - restore_flags(flags); - ip_masq_set_expire(ms, timeout); - /* toss the packet */ - return -1; - } - } - } - } else { - /* - * Nope, not found, create a new entry for it, maybe - */ - - /* see if there are any pending inits with the same destination... */ - ms = ip_masq_in_get_ipsec(IPPROTO_ESP, - iph->daddr, 0, - 0, 0, - 0); - - if (ms != NULL) { - /* found one with ispi == 0 */ - if (ms->saddr != iph->saddr) { - /* it's not ours, don't step on their toes */ - printk(KERN_INFO "ip_fw_masq_esp(): "); - printk("init %s ", in_ntoa(iph->saddr)); - printk("-> %s ", in_ntoa(iph->daddr)); - printk("temporarily blocked by pending "); - printk("%s init\n", in_ntoa(ms->saddr)); - /* let it know it has competition */ - ms->blocking = 1; - /* toss the packet */ - return -1; - } - if (ms->ospi != o_spi) { - /* SPIs differ, still waiting for a previous attempt to expire */ - printk(KERN_INFO "ip_fw_masq_esp(): "); - printk("init %s ", in_ntoa(iph->saddr)); - printk("-> %s SPI %lX ", in_ntoa(iph->daddr), ntohl(o_spi)); - printk("temporarily blocked by pending "); - printk("init w/ SPI %lX\n", ntohl(ms->ospi)); - /* let it know it has competition */ - ms->blocking = 1; - /* toss the packet */ - return -1; - } - } else /* nothing pending, make new entry, pending response */ - ms = ip_masq_new(dev, iph->protocol, - iph->saddr, fake_sport, - iph->daddr, 0, - 0); - - if (ms == NULL) { - printk(KERN_NOTICE "ip_fw_masq_esp(): Couldn't create masq table entry.\n"); - return -1; - } - - ms->blocking = ms->ocnt = 0; - ms->ospi = o_spi; - timeout = MASQUERADE_EXPIRE_IPSEC_INIT; /* fairly brief timeout while waiting for a response */ - } - - /* - * Set iph source addr from ip_masq obj. - */ - iph->saddr = ms->maddr; - - /* - * set timeout and check IP header - */ - - ip_masq_set_expire(ms, timeout); - ip_send_check(iph); - -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "MASQ: ESP O-routed from %s over %s\n", - in_ntoa(ms->maddr), dev->name); -#endif /* DEBUG_IP_MASQUERADE_IPSEC_VERBOSE */ - - return 0; -} - -/* - * Handle inbound ESP packets. - * - */ - -int ip_fw_demasq_esp(struct sk_buff **skb_p, struct device *dev) -{ - struct sk_buff *skb = *skb_p; - struct iphdr *iph = skb->h.iph; - struct ip_masq *ms; - unsigned long flags; - __u32 i_spi; - __u16 fake_sport; -#ifndef CONFIG_IP_MASQUERADE_IPSEC_NOGUESS - #define ESP_GUESS_SZ 5 /* minimum 3, please */ - #define ESP_CAND_MIN_TM 5*60*HZ /* max 10*60*HZ? */ - unsigned hash; - int i, ii, - ncand = 0, nguess = 0; - __u16 isakmp; - __u32 cand_ip, - guess_ip[ESP_GUESS_SZ]; - unsigned long cand_tm, - guess_tm[ESP_GUESS_SZ]; - struct sk_buff *skb_cl; - struct iphdr *iph_cl; -#endif /* CONFIG_IP_MASQUERADE_IPSEC_NOGUESS */ - - i_spi = *((__u32 *)&(((char *)iph)[iph->ihl*4])); - fake_sport = (__u16) ntohl(i_spi) & 0xffff; - -#ifdef DEBUG_IP_MASQUERADE_IPSEC - printk(KERN_DEBUG "ip_fw_demasq_esp(): "); - printk("pkt %s", in_ntoa(iph->saddr)); - printk(" -> %s SPI %lX (fakeport %X)\n", in_ntoa(iph->daddr), ntohl(i_spi), fake_sport); -#endif /* DEBUG_IP_MASQUERADE_IPSEC */ - - if (i_spi == 0) { - /* illegal SPI - discard */ - printk(KERN_INFO "ip_fw_demasq_esp(): "); - printk("zero SPI from %s discarded\n", in_ntoa(iph->saddr)); - return -1; - } - - if (i_spi == IPSEC_INIT_SQUELCHED) { - /* Ack! This shouldn't happen! */ - /* IPSEC_INIT_SQUELCHED is chosen to be a reserved value as of 4/99 */ - printk(KERN_NOTICE "ip_fw_demasq_esp(): "); - printk("SPI from %s is IPSEC_INIT_SQUELCHED - modify ip_masq.c!\n", in_ntoa(iph->saddr)); - return -1; - } - - /* - * Look for a masq table entry and reroute if found - */ - - ms = ip_masq_in_get_ipsec(IPPROTO_ESP, - iph->saddr, fake_sport, - iph->daddr, 0, - i_spi); - - if (ms != NULL) - { - /* delete the expiration timer */ - ip_masq_set_expire(ms,0); - - iph->daddr = ms->saddr; - - if (ms->ispi == 0) { -#ifdef DEBUG_IP_MASQUERADE_IPSEC - printk(KERN_INFO "ip_fw_demasq_esp(): "); - printk("resp from %s SPI %lX", in_ntoa(iph->saddr), ntohl(i_spi)); - printk(" routed to %s (SPI %lX)\n", in_ntoa(ms->saddr), ntohl(ms->ospi)); -#endif /* DEBUG_IP_MASQUERADE_IPSEC */ - save_flags(flags); - cli(); - ip_masq_unhash(ms); - ms->ispi = i_spi; - ms->dport = fake_sport; - ip_masq_hash(ms); - restore_flags(flags); - } - - /* - * resum checksums and set timeout - */ - ip_masq_set_expire(ms, MASQUERADE_EXPIRE_IPSEC); - ip_send_check(iph); - -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "MASQ: ESP I-routed to %s\n", in_ntoa(iph->daddr)); -#endif /* DEBUG_IP_MASQUERADE_IPSEC_VERBOSE */ - return 1; - } - -#ifndef CONFIG_IP_MASQUERADE_IPSEC_NOGUESS - /* Guess who this packet is likely intended for: - * Scan the UDP masq table for local hosts that have communicated via - * ISAKMP with the host who sent this packet. - * Using an insertion sort with duplicate IP suppression, build a list - * of the ESP_GUESS_SZ most recent ISAKMP sessions (determined by - * sorting in decreasing order of timeout timer). - * Clone the original packet and send it to those hosts, but DON'T make - * a masq table entry, as we're only guessing. It is assumed that the correct - * host will respond to the traffic and that will create a masq table entry. - * To limit the list a bit, don't consider any ISAKMP masq entries with - * less than ESP_CAND_MIN_TM time to live. This should be some value less - * than the IPSEC table timeout or *all* entries will be ignored... - */ - -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "ip_fw_demasq_esp(): "); - printk("guessing from %s SPI %lX\n", in_ntoa(iph->saddr), ntohl(i_spi)); -#endif /* DEBUG_IP_MASQUERADE_IPSEC_VERBOSE */ - - /* zero out the guess table */ - for (i = 0;i < ESP_GUESS_SZ; i++) { - guess_ip[i] = 0; - guess_tm[i] = 0; - } - - /* scan ISAKMP sessions with the source host */ - isakmp = htons(UDP_PORT_ISAKMP); - hash = ip_masq_hash_key(IPPROTO_UDP, iph->saddr, isakmp); - for(ms = ip_masq_d_tab[hash]; ms ; ms = ms->d_link) { - if (ms->protocol == IPPROTO_UDP && - ms->daddr == iph->saddr && - ms->sport == isakmp && - ms->dport == isakmp && - ms->mport == isakmp && - ms->ospi != 0) { - /* a candidate... */ - ncand++; - cand_ip = ms->saddr; - cand_tm = ms->timer.expires - jiffies; -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "ip_fw_demasq_esp(): "); - printk("cand %d: IP %s TM %ld\n", ncand, in_ntoa(cand_ip), cand_tm); -#endif /* DEBUG_IP_MASQUERADE_IPSEC_VERBOSE */ - if (cand_tm > ESP_CAND_MIN_TM) { - /* traffic is recent enough, add to list (maybe) */ - for (i = 0; i < ESP_GUESS_SZ; i++) { - if (cand_tm > guess_tm[i]) { - /* newer */ - if (guess_ip[i] != 0 && cand_ip != guess_ip[i]) { - /* newer and IP different - insert */ - if (i < (ESP_GUESS_SZ - 1)) { - /* move entries down the list, - * find first entry after this slot - * where the IP is 0 (unused) or - * IP == candidate (older traffic, same host) - * rather than simply going to the end of the list, - * for efficiency (don't shift zeros) and - * duplicate IP suppression (don't keep older entries - * having the same IP) - */ - for (ii = i + 1; ii < (ESP_GUESS_SZ - 1); ii++) { - if (guess_ip[ii] == 0 || guess_ip[ii] == cand_ip) - break; - } - for (ii-- ; ii >= i; ii--) { - guess_ip[ii+1] = guess_ip[ii]; - guess_tm[ii+1] = guess_tm[ii]; - } - } - } - guess_ip[i] = cand_ip; - guess_tm[i] = cand_tm; - break; - } - if (cand_ip == guess_ip[i]) { - /* fresher entry already there */ - break; - } - } - } - } - } - - if (guess_ip[0]) { - /* had guesses - send */ - if (guess_ip[1]) { - /* multiple guesses, send a copy to all */ - for (i = 0; guess_ip[i] != 0; i++) { - nguess++; -#ifdef DEBUG_IP_MASQUERADE_IPSEC_VERBOSE - printk(KERN_DEBUG "ip_fw_demasq_esp(): "); - printk("guess %d: IP %s TM %ld\n", nguess, in_ntoa(guess_ip[i]), guess_tm[i]); -#endif /* DEBUG_IP_MASQUERADE_IPSEC_VERBOSE */ - /* duplicate and send the skb */ - if ((skb_cl = skb_copy(skb, GFP_ATOMIC)) == NULL) { - printk(KERN_INFO "ip_fw_demasq_esp(): "); - printk("guessing: cannot copy skb\n"); - } else { - iph_cl = skb_cl->h.iph; - iph_cl->daddr = guess_ip[i]; - ip_send_check(iph_cl); - ip_forward(skb_cl, dev, IPFWD_MASQUERADED, iph_cl->daddr); - kfree_skb(skb_cl, FREE_WRITE); - } - } -#ifdef DEBUG_IP_MASQUERADE_IPSEC - printk(KERN_INFO "ip_fw_demasq_esp(): "); - printk("guessing from %s SPI %lX sent to", in_ntoa(iph->saddr), ntohl(i_spi)); - printk(" %d hosts (%d cand)\n", nguess, ncand); -#endif /* DEBUG_IP_MASQUERADE_IPSEC */ - return -1; /* discard original packet */ - } else { - /* only one guess, send original packet to that host */ - iph->daddr = guess_ip[0]; - ip_send_check(iph); - -#ifdef DEBUG_IP_MASQUERADE_IPSEC - printk(KERN_INFO "ip_fw_demasq_esp(): "); - printk("guessing from %s SPI %lX sent to", in_ntoa(iph->saddr), ntohl(i_spi)); - printk(" %s (%d cand)\n", in_ntoa(guess_ip[0]), ncand); -#endif /* DEBUG_IP_MASQUERADE_IPSEC */ - return 1; - } - } -#endif /* CONFIG_IP_MASQUERADE_IPSEC_NOGUESS */ - - /* sorry, all this trouble for a no-hit :) */ - printk(KERN_INFO "ip_fw_demasq_esp(): "); - printk("Inbound from %s SPI %lX has no masq table entry.\n", in_ntoa(iph->saddr), ntohl(i_spi)); - return 0; -} - -static struct symbol_table ipsec_masq_syms = { -#include - X(ip_masq_out_get_ipsec), - X(ip_masq_in_get_ipsec), - X(ip_masq_out_get_isakmp), - X(ip_masq_in_get_isakmp), - X(ip_fw_masq_esp), - X(ip_fw_demasq_esp), -#include -}; - -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ - - int ip_fw_masquerade(struct sk_buff **skb_ptr, struct device *dev) { struct sk_buff *skb=*skb_ptr; @@ -2388,10 +1104,6 @@ int ip_fw_masquerade(struct sk_buff **skb_ptr, struct device *dev) if (iph->protocol==IPPROTO_GRE) return (ip_fw_masq_gre(skb_ptr,dev)); #endif /* CONFIG_IP_MASQUERADE_PPTP */ -#ifdef CONFIG_IP_MASQUERADE_IPSEC - if (iph->protocol==IPPROTO_ESP) - return (ip_fw_masq_esp(skb_ptr,dev)); -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ if (iph->protocol!=IPPROTO_UDP && iph->protocol!=IPPROTO_TCP) return -1; @@ -2408,7 +1120,6 @@ int ip_fw_masquerade(struct sk_buff **skb_ptr, struct device *dev) #endif ms = ip_masq_out_get(iph); - if (ms!=NULL) { ip_masq_set_expire(ms,0); @@ -2486,29 +1197,8 @@ int ip_fw_masquerade(struct sk_buff **skb_ptr, struct device *dev) 0); if (ms == NULL) return -1; - -#ifdef CONFIG_IP_MASQUERADE_IPSEC - if (iph->protocol == IPPROTO_UDP && ntohs(portptr[0]) == UDP_PORT_ISAKMP && ntohs(portptr[1]) == UDP_PORT_ISAKMP) { - /* save the initiator cookie */ - ms->ospi = *((__u32 *)&portptr[4]); - } -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ } -#ifdef CONFIG_IP_MASQUERADE_PPTP -#ifdef CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT - if (iph->protocol == IPPROTO_TCP && ntohs(portptr[1]) == PPTP_CONTROL_PORT) - { - /* - * Packet sent to PPTP control port. Process it. - * May change call ID word in request, but - * packet length will not change. - */ - ip_masq_pptp(skb, ms, dev); - } -#endif /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ -#endif /* CONFIG_IP_MASQUERADE_PPTP */ - /* * Change the fragments origin */ @@ -2541,13 +1231,6 @@ int ip_fw_masquerade(struct sk_buff **skb_ptr, struct device *dev) if (masq_proto_num(iph->protocol)==0) { -#ifdef CONFIG_IP_MASQUERADE_IPSEC - if (iph->protocol == IPPROTO_UDP && ntohs(portptr[0]) == UDP_PORT_ISAKMP && ntohs(portptr[1]) == UDP_PORT_ISAKMP) { - /* ISAKMP timeout should be same as ESP timeout to allow for rekeying */ - timeout = MASQUERADE_EXPIRE_IPSEC; - } else -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ - timeout = ip_masq_expire->udp_timeout; recalc_check((struct udphdr *)portptr,iph->saddr,iph->daddr,size); } @@ -3039,12 +1722,11 @@ int ip_fw_demasquerade(struct sk_buff **skb_p, struct device *dev) __u16 *portptr; struct ip_masq *ms; unsigned short len; - unsigned long timeout = MASQUERADE_EXPIRE_TCP; + unsigned long timeout; #ifdef CONFIG_IP_MASQUERADE_IPAUTOFW struct ip_autofw *af; #endif /* CONFIG_IP_MASQUERADE_IPAUTOFW */ - switch (iph->protocol) { case IPPROTO_ICMP: return(ip_fw_demasq_icmp(skb_p, dev)); @@ -3052,19 +1734,12 @@ int ip_fw_demasquerade(struct sk_buff **skb_p, struct device *dev) case IPPROTO_GRE: return(ip_fw_demasq_gre(skb_p, dev)); #endif /* CONFIG_IP_MASQUERADE_PPTP */ -#ifdef CONFIG_IP_MASQUERADE_IPSEC - case IPPROTO_ESP: - return(ip_fw_demasq_esp(skb_p, dev)); -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ case IPPROTO_TCP: case IPPROTO_UDP: /* Make sure packet is in the masq range */ portptr = (__u16 *)&(((char *)iph)[iph->ihl*4]); if ((ntohs(portptr[1]) < PORT_MASQ_BEGIN || ntohs(portptr[1]) > PORT_MASQ_END) -#ifdef CONFIG_IP_MASQUERADE_IPSEC - && ((iph->protocol != IPPROTO_UDP) || (ntohs(portptr[0]) != UDP_PORT_ISAKMP) || (ntohs(portptr[1]) != UDP_PORT_ISAKMP)) -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ #ifdef CONFIG_IP_MASQUERADE_IPAUTOFW && !ip_autofw_check_range(iph->saddr, portptr[1], iph->protocol, 0) @@ -3193,20 +1868,6 @@ int ip_fw_demasquerade(struct sk_buff **skb_p, struct device *dev) len = ntohs(iph->tot_len) - (iph->ihl * 4); } -#ifdef CONFIG_IP_MASQUERADE_PPTP -#ifdef CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT - if (iph->protocol == IPPROTO_TCP && ntohs(portptr[0]) == PPTP_CONTROL_PORT) - { - /* - * Packet received from PPTP control port. Process it. - * May change call ID word in request, but - * packet length will not change. - */ - ip_masq_pptp(skb, ms, dev); - } -#endif /* CONFIG_IP_MASQUERADE_PPTP_MULTICLIENT */ -#endif /* CONFIG_IP_MASQUERADE_PPTP */ - /* * Yug! adjust UDP/TCP and IP checksums, also update * timeouts. @@ -3215,14 +1876,6 @@ int ip_fw_demasquerade(struct sk_buff **skb_p, struct device *dev) if (masq_proto_num(iph->protocol)==0) { recalc_check((struct udphdr *)portptr,iph->saddr,iph->daddr,len); - -#ifdef CONFIG_IP_MASQUERADE_IPSEC - if (iph->protocol == IPPROTO_UDP && ntohs(portptr[0]) == UDP_PORT_ISAKMP && ntohs(portptr[1]) == UDP_PORT_ISAKMP) { - /* ISAKMP timeout should be same as ESP timeout to allow for rekeying */ - timeout = MASQUERADE_EXPIRE_IPSEC; - } else -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ - timeout = ip_masq_expire->udp_timeout; } else @@ -3388,12 +2041,6 @@ done: int ip_masq_init(void) { register_symtab (&ip_masq_syms); -#ifdef CONFIG_IP_MASQUERADE_PPTP - register_symtab (&pptp_masq_syms); -#endif /* CONFIG_IP_MASQUERADE_PPTP */ -#ifdef CONFIG_IP_MASQUERADE_IPSEC - register_symtab (&ipsec_masq_syms); -#endif /* CONFIG_IP_MASQUERADE_IPSEC */ #ifdef CONFIG_PROC_FS proc_net_register(&(struct proc_dir_entry) { PROC_NET_IPMSQHST, 13, "ip_masquerade", diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 323fc424071c..6784ca56b963 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -455,6 +455,9 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int opt int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen) { int val,err; +#ifdef CONFIG_IP_MULTICAST + int len; +#endif if(level!=SOL_IP) return -EOPNOTSUPP; @@ -538,33 +541,16 @@ int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *op val=sk->ip_mc_loop; break; case IP_MULTICAST_IF: - { - struct device *dev; - struct in_addr ia; - err=verify_area(VERIFY_WRITE, optlen, sizeof(int)); if(err) return err; - err=verify_area(VERIFY_WRITE, optval, sizeof(ia)); + len=strlen(sk->ip_mc_name); + err=verify_area(VERIFY_WRITE, optval, len); if(err) return err; - - if(*sk->ip_mc_name) - { - dev=dev_get(sk->ip_mc_name); - /* Someone ran off with the interface, its probably - been downed. */ - if(dev==NULL) - return -ENODEV; - ia.s_addr = dev->pa_addr; - } - else - ia.s_addr = 0L; - - put_user(sizeof(ia),(int *) optlen); - memcpy_tofs((void *)optval, &ia, sizeof(ia)); + put_user(len,(int *) optlen); + memcpy_tofs((void *)optval,sk->ip_mc_name, len); return 0; - } #endif default: return(-ENOPROTOOPT); diff --git a/net/ipv4/rarp.c b/net/ipv4/rarp.c index 0a9c4cbe445a..b4d3d9d38fd7 100644 --- a/net/ipv4/rarp.c +++ b/net/ipv4/rarp.c @@ -189,8 +189,6 @@ static void rarp_init_pkt (void) rarp_pkt_inited=1; } -#ifdef MODULE - static void rarp_end_pkt(void) { if(!rarp_pkt_inited) @@ -200,8 +198,6 @@ static void rarp_end_pkt(void) rarp_pkt_inited=0; } -#endif - /* * Receive an arp request by the device layer. Maybe it should be diff --git a/net/netlink.c b/net/netlink.c index 6b88581059f9..b00f85de7d96 100644 --- a/net/netlink.c +++ b/net/netlink.c @@ -198,7 +198,6 @@ int netlink_attach(int unit, int (*function)(struct sk_buff *skb)) if(active_map&(1< #include #include -#include #include #include @@ -111,8 +110,6 @@ static struct symbol_table net_syms = { X(ip_id_count), X(ip_send_check), X(ip_forward), - X(ip_queue_xmit), - X(ip_fragment), X(sysctl_ip_forward), #if defined(CONFIG_ULTRA) || defined(CONFIG_WD80x3) || \ @@ -134,11 +131,6 @@ static struct symbol_table net_syms = { X(tr_type_trans), #endif -#ifdef CONFIG_FDDI - X(fddi_setup), - X(fddi_type_trans), -#endif - #ifdef CONFIG_NET_ALIAS #include #endif diff --git a/scripts/Menuconfig b/scripts/Menuconfig index 789b9130d7ae..48e93c8e8c03 100644 --- a/scripts/Menuconfig +++ b/scripts/Menuconfig @@ -76,14 +76,6 @@ function define_bool () { eval $1=$2 } -# -# Define an int to a specific value. -# - -function define_int () { - eval $1=$2 -} - # # Create a boolean (Yes/No) function for our current menu # which calls our local bool function. @@ -963,13 +955,6 @@ save_configuration () { esac } - function define_int () { - eval $1="$2" - echo "$1=$2" >>$CONFIG - echo "#define $1 $2" >>$CONFIG_H - } - - function choice () { # # Find the first choice that's already set to 'y' diff --git a/scripts/tkgen.c b/scripts/tkgen.c index 63ca8709e933..fc9338db39de 100644 --- a/scripts/tkgen.c +++ b/scripts/tkgen.c @@ -280,7 +280,6 @@ void generate_if(struct kconfig * item, */ switch(item->tok) { - case tok_define_int: case tok_define: printf("} then { set %s %s } \n", item->optionname, item->value); break; @@ -465,9 +464,6 @@ void generate_if_for_outfile(struct kconfig * item, */ switch(item->tok) { - case tok_define_int: - printf("} then {write_int $cfg $autocfg %s %s $notmod }\n", item->optionname, item->value); - break; case tok_define: printf("} then {write_tristate $cfg $autocfg %s %s $notmod }\n", item->optionname, item->value); break; @@ -576,8 +572,7 @@ static void end_proc(int menu_num) * Skip items not for this menu, or ones having no conditions. */ if (cfg->menu_number != menu_num ) continue; - if (cfg->tok != tok_define && cfg->tok != tok_define_int) - continue; + if (cfg->tok != tok_define) continue; /* * Clear all of the booleans that are defined in this menu. */ @@ -722,7 +717,6 @@ void dump_tk_script(struct kconfig *scfg) cfg->menu_line = menu_line++; break; case tok_define: - case tok_define_int: cfg->menu_number = -1; case tok_choice: default: @@ -929,7 +923,7 @@ void dump_tk_script(struct kconfig *scfg) /* * Skip items not for this menu, or ones having no conditions. */ - if( cfg->tok != tok_define && cfg->tok != tok_define_int) continue; + if( cfg->tok != tok_define) continue; if (cfg->cond != NULL ) generate_if(cfg, cfg->cond, menu_num, cfg->menu_line); else @@ -994,7 +988,6 @@ void dump_tk_script(struct kconfig *scfg) case tok_tristate: case tok_dep_tristate: case tok_define: - case tok_define_int: case tok_choose: if(!(cfg->flags & GLOBAL_WRITTEN)) { @@ -1026,7 +1019,7 @@ void dump_tk_script(struct kconfig *scfg) printf("\twrite_comment $cfg $autocfg \"%s\"\n", cfg->label); } #if 0 - else if(cfg->tok == tok_define || cfg->tok == tok_define_int) + else if(cfg->tok == tok_define) { printf("\twrite_define %s %s\n", cfg->optionname, cfg->value); @@ -1050,12 +1043,6 @@ void dump_tk_script(struct kconfig *scfg) cfg->optionname, cfg->optionname); } - else if (cfg->tok == tok_define_int ) - { - printf("\twrite_int $cfg $autocfg %s $%s $notmod\n", - cfg->optionname, - cfg->optionname); - } else if (cfg->tok == tok_hex ) { printf("\twrite_hex $cfg $autocfg %s $%s $notmod\n", @@ -1122,14 +1109,13 @@ void dump_tk_script(struct kconfig *scfg) clear_globalflags(config); for(cfg = scfg; cfg != NULL; cfg = cfg->next) { - if( cfg->tok != tok_define && cfg->tok != tok_define_int ) - continue; + if( cfg->tok != tok_define ) continue; printf("\tglobal %s; set %s 0\n", cfg->optionname, cfg->optionname); cfg->flags |= GLOBAL_WRITTEN; } for(cfg = scfg; cfg != NULL; cfg = cfg->next) { - if( cfg->tok != tok_define && cfg->tok != tok_define_int ) continue; + if( cfg->tok != tok_define ) continue; if (cfg->cond != NULL ) generate_if(cfg, cfg->cond, -1, 0); else diff --git a/scripts/tkparse.c b/scripts/tkparse.c index 73b62f589716..2a000217c98e 100644 --- a/scripts/tkparse.c +++ b/scripts/tkparse.c @@ -345,11 +345,6 @@ void parse(char * pnt) { tok = tok_define; pnt += 11; } - else if (strncmp(pnt, "define_int", 10) == 0) - { - tok = tok_define_int; - pnt += 10; - } else if (strncmp(pnt, "bool", 4) == 0) { tok = tok_bool; @@ -452,10 +447,6 @@ void parse(char * pnt) { if(*pnt == 'n' || *pnt == 'N' ) kcfg->value = "0"; if(*pnt == 'm' || *pnt == 'M' ) kcfg->value = "2"; break; - case tok_define_int: - pnt = get_string(pnt, &kcfg->optionname); - pnt = get_string(pnt, &kcfg->value); - break; case tok_menuname: pnt = get_qstring(pnt, &kcfg->label); break; diff --git a/scripts/tkparse.h b/scripts/tkparse.h index 61209e02abf8..911abdfbee43 100644 --- a/scripts/tkparse.h +++ b/scripts/tkparse.h @@ -14,7 +14,6 @@ enum token { tok_hex, tok_make, tok_define, - tok_define_int, tok_choose, tok_choice, tok_endmenu, -- 2.39.5