⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eata.c

📁 GNU Mach 微内核源代码, 基于美国卡内基美隆大学的 Mach 研究项目
💻 C
📖 第 1 页 / 共 5 页
字号:
/* *      eata.c - Low-level driver for EATA/DMA SCSI host adapters. * *      26 Jul 1998 Rev. 4.33 for linux 2.0.35 and 2.1.111 *        + Added command line option (rs:[y|n]) to reverse the scan order *          of PCI boards. The default is rs:y, which reverses the BIOS order *          while registering PCI boards. The default value rs:y generates *          the same order of all previous revisions of this driver. *          Pls. note that "BIOS order" might have been reversed itself *          after the 2.1.9x PCI modifications in the linux kernel. *          The rs value is ignored when the explicit list of addresses *          is used by the "eata=port0,port1,..." command line option. *        + Added command line option (et:[y|n]) to force use of extended *          translation (255 heads, 63 sectors) as disk geometry. *          The default is et:n, which uses the disk geometry returned *          by scsicam_bios_param. The default value et:n is compatible with *          all previous revisions of this driver. * *      28 May 1998 Rev. 4.32 for linux 2.0.33 and 2.1.104 *          Increased busy timeout from 10 msec. to 200 msec. while *          processing interrupts. * *      16 May 1998 Rev. 4.31 for linux 2.0.33 and 2.1.102 *          Improved abort handling during the eh recovery process. * *      13 May 1998 Rev. 4.30 for linux 2.0.33 and 2.1.101 *          The driver is now fully SMP safe, including the *          abort and reset routines. *          Added command line options (eh:[y|n]) to choose between *          new_eh_code and the old scsi code. *          If linux version >= 2.1.101 the default is eh:y, while the eh *          option is ignored for previous releases and the old scsi code *          is used. * *      18 Apr 1998 Rev. 4.20 for linux 2.0.33 and 2.1.97 *          Reworked interrupt handler. * *      11 Apr 1998 rev. 4.05 for linux 2.0.33 and 2.1.95 *          Major reliability improvement: when a batch with overlapping *          requests is detected, requests are queued one at a time *          eliminating any possible board or drive reordering. * *      10 Apr 1998 rev. 4.04 for linux 2.0.33 and 2.1.95 *          Improved SMP support (if linux version >= 2.1.95). * *       9 Apr 1998 rev. 4.03 for linux 2.0.33 and 2.1.94 *          Added support for new PCI code and IO-APIC remapping of irqs. *          Performance improvement: when sequential i/o is detected, *          always use direct sort instead of reverse sort. * *       4 Apr 1998 rev. 4.02 for linux 2.0.33 and 2.1.92 *          io_port is now unsigned long. * *      17 Mar 1998 rev. 4.01 for linux 2.0.33 and 2.1.88 *          Use new scsi error handling code (if linux version >= 2.1.88). *          Use new interrupt code. * *      12 Sep 1997 rev. 3.11 for linux 2.0.30 and 2.1.55 *          Use of udelay inside the wait loops to avoid timeout *          problems with fast cpus. *          Removed check about useless calls to the interrupt service *          routine (reported on SMP systems only). *          At initialization time "sorted/unsorted" is displayed instead *          of "linked/unlinked" to reinforce the fact that "linking" is *          nothing but "elevator sorting" in the actual implementation. * *      17 May 1997 rev. 3.10 for linux 2.0.30 and 2.1.38 *          Use of serial_number_at_timeout in abort and reset processing. *          Use of the __initfunc and __initdata macro in setup code. *          Minor cleanups in the list_statistics code. *          Increased controller busy timeout in order to better support *          slow SCSI devices. * *      24 Feb 1997 rev. 3.00 for linux 2.0.29 and 2.1.26 *          When loading as a module, parameter passing is now supported *          both in 2.0 and in 2.1 style. *          Fixed data transfer direction for some SCSI opcodes. *          Immediate acknowledge to request sense commands. *          Linked commands to each disk device are now reordered by elevator *          sorting. Rare cases in which reordering of write requests could *          cause wrong results are managed. *          Fixed spurious timeouts caused by long simple queue tag sequences. *          New command line option (tm:[0-3]) to choose the type of tags: *          0 -> mixed (default); 1 -> simple; 2 -> head; 3 -> ordered. * *      18 Jan 1997 rev. 2.60 for linux 2.1.21 and 2.0.28 *          Added command line options to enable/disable linked commands *          (lc:[y|n]), tagged commands (tc:[y|n]) and to set the max queue *          depth (mq:xx). Default is "eata=lc:n,tc:n,mq:16". *          Improved command linking. *          Documented how to setup RAID-0 with DPT SmartRAID boards. * *       8 Jan 1997 rev. 2.50 for linux 2.1.20 and 2.0.27 *          Added linked command support. *          Improved detection of PCI boards using ISA base addresses. * *       3 Dec 1996 rev. 2.40 for linux 2.1.14 and 2.0.27 *          Added support for tagged commands and queue depth adjustment. * *      22 Nov 1996 rev. 2.30 for linux 2.1.12 and 2.0.26 *          When CONFIG_PCI is defined, BIOS32 is used to include in the *          list of i/o ports to be probed all the PCI SCSI controllers. *          The list of i/o ports to be probed can be overwritten by the *          "eata=port0,port1,...." boot command line option. *          Scatter/gather lists are now allocated by a number of kmalloc *          calls, in order to avoid the previous size limit of 64Kb. * *      16 Nov 1996 rev. 2.20 for linux 2.1.10 and 2.0.25 *          Added support for EATA 2.0C, PCI, multichannel and wide SCSI. * *      27 Sep 1996 rev. 2.12 for linux 2.1.0 *          Portability cleanups (virtual/bus addressing, little/big endian *          support). * *      09 Jul 1996 rev. 2.11 for linux 2.0.4 *          Number of internal retries is now limited. * *      16 Apr 1996 rev. 2.10 for linux 1.3.90 *          New argument "reset_flags" to the reset routine. * *       6 Jul 1995 rev. 2.01 for linux 1.3.7 *          Update required by the new /proc/scsi support. * *      11 Mar 1995 rev. 2.00 for linux 1.2.0 *          Fixed a bug which prevented media change detection for removable *          disk drives. * *      23 Feb 1995 rev. 1.18 for linux 1.1.94 *          Added a check for scsi_register returning NULL. * *      11 Feb 1995 rev. 1.17 for linux 1.1.91 *          Now DEBUG_RESET is disabled by default. *          Register a board even if it does not assert DMA protocol support *          (DPT SK2011B does not report correctly the dmasup bit). * *       9 Feb 1995 rev. 1.16 for linux 1.1.90 *          Use host->wish_block instead of host->block. *          New list of Data Out SCSI commands. * *       8 Feb 1995 rev. 1.15 for linux 1.1.89 *          Cleared target_time_out counter while performing a reset. *          All external symbols renamed to avoid possible name conflicts. * *      28 Jan 1995 rev. 1.14 for linux 1.1.86 *          Added module support. *          Log and do a retry when a disk drive returns a target status *          different from zero on a recovered error. * *      24 Jan 1995 rev. 1.13 for linux 1.1.85 *          Use optimized board configuration, with a measured performance *          increase in the range 10%-20% on i/o throughput. * *      16 Jan 1995 rev. 1.12 for linux 1.1.81 *          Fix mscp structure comments (no functional change). *          Display a message if check_region detects a port address *          already in use. * *      17 Dec 1994 rev. 1.11 for linux 1.1.74 *          Use the scsicam_bios_param routine. This allows an easy *          migration path from disk partition tables created using *          different SCSI drivers and non optimal disk geometry. * *      15 Dec 1994 rev. 1.10 for linux 1.1.74 *          Added support for ISA EATA boards (DPT PM2011, DPT PM2021). *          The host->block flag is set for all the detected ISA boards. *          The detect routine no longer enforces LEVEL triggering *          for EISA boards, it just prints a warning message. * *      30 Nov 1994 rev. 1.09 for linux 1.1.68 *          Redo i/o on target status CHECK_CONDITION for TYPE_DISK only. *          Added optional support for using a single board at a time. * *      18 Nov 1994 rev. 1.08 for linux 1.1.64 *          Forces sg_tablesize = 64 and can_queue = 64 if these *          values are not correctly detected (DPT PM2012). * *      14 Nov 1994 rev. 1.07 for linux 1.1.63  Final BETA release. *      04 Aug 1994 rev. 1.00 for linux 1.1.39  First BETA release. * * *          This driver is based on the CAM (Common Access Method Committee) *          EATA (Enhanced AT Bus Attachment) rev. 2.0A, using DMA protocol. * *  Copyright (C) 1994-1998 Dario Ballabio (dario@milano.europe.dg.com) * *  Redistribution and use in source and binary forms, with or without *  modification, are permitted provided that redistributions of source *  code retain the above copyright notice and this comment without *  modification. * *//* * *  Here is a brief description of the DPT SCSI host adapters. *  All these boards provide an EATA/DMA compatible programming interface *  and are fully supported by this driver in any configuration, including *  multiple SCSI channels: * *  PM2011B/9X -  Entry Level ISA *  PM2021A/9X -  High Performance ISA *  PM2012A       Old EISA *  PM2012B       Old EISA *  PM2022A/9X -  Entry Level EISA *  PM2122A/9X -  High Performance EISA *  PM2322A/9X -  Extra High Performance EISA *  PM3021     -  SmartRAID Adapter for ISA *  PM3222     -  SmartRAID Adapter for EISA (PM3222W is 16-bit wide SCSI) *  PM3224     -  SmartRAID Adapter for PCI  (PM3224W is 16-bit wide SCSI) * *  The above list is just an indication: as a matter of fact all DPT *  boards using the EATA/DMA protocol are supported by this driver, *  since they use exactely the same programming interface. * *  The DPT PM2001 provides only the EATA/PIO interface and hence is not *  supported by this driver. * *  This code has been tested with up to 3 Distributed Processing Technology *  PM2122A/9X (DPT SCSI BIOS v002.D1, firmware v05E.0) EISA controllers, *  in any combination of private and shared IRQ. *  PCI support has been tested using up to 2 DPT PM3224W (DPT SCSI BIOS *  v003.D0, firmware v07G.0). * *  DPT SmartRAID boards support "Hardware Array" - a group of disk drives *  which are all members of the same RAID-0, RAID-1 or RAID-5 array implemented *  in host adapter hardware. Hardware Arrays are fully compatible with this *  driver, since they look to it as a single disk drive. * *  WARNING: to create a RAID-0 "Hardware Array" you must select "Other Unix" *  as the current OS in the DPTMGR "Initial System Installation" menu. *  Otherwise RAID-0 is generated as an "Array Group" (i.e. software RAID-0), *  which is not supported by the actual SCSI subsystem. *  To get the "Array Group" functionality, the Linux MD driver must be used *  instead of the DPT "Array Group" feature. * *  Multiple ISA, EISA and PCI boards can be configured in the same system. *  It is suggested to put all the EISA boards on the same IRQ level, all *  the PCI  boards on another IRQ level, while ISA boards cannot share *  interrupts. * *  If you configure multiple boards on the same IRQ, the interrupt must *  be _level_ triggered (not _edge_ triggered). * *  This driver detects EATA boards by probes at fixed port addresses, *  so no BIOS32 or PCI BIOS support is required. *  The suggested way to detect a generic EATA PCI board is to force on it *  any unused EISA address, even if there are other controllers on the EISA *  bus, or even if you system has no EISA bus at all. *  Do not force any ISA address on EATA PCI boards. * *  If PCI bios support is configured into the kernel, BIOS32 is used to *  include in the list of i/o ports to be probed all the PCI SCSI controllers. * *  Due to a DPT BIOS "feature", it might not be possible to force an EISA *  address on more then a single DPT PCI board, so in this case you have to *  let the PCI BIOS assign the addresses. * *  The sequence of detection probes is: * *  - ISA 0x1F0; *  - PCI SCSI controllers (only if BIOS32 is available); *  - EISA/PCI 0x1C88 through 0xFC88 (corresponding to EISA slots 1 to 15); *  - ISA  0x170, 0x230, 0x330. * *  The above list of detection probes can be totally replaced by the *  boot command line option: "eata=port0,port1,port2,...", where the *  port0, port1... arguments are ISA/EISA/PCI addresses to be probed. *  For example using "eata=0x7410,0x7450,0x230", the driver probes *  only the two PCI addresses 0x7410 and 0x7450 and the ISA address 0x230, *  in this order; "eata=0" totally disables this driver. * *  After the optional list of detection probes, other possible command line *  options are: * *  eh:y  use new scsi code (linux 2.2 only); *  eh:n  use old scsi code; *  et:y  force use of extended translation (255 heads, 63 sectors); *  et:n  use disk geometry detected by scsicam_bios_param; *  rs:y  reverse scan order while detecting PCI boards; *  rs:n  use BIOS order while detecting PCI boards; *  lc:y  enables linked commands; *  lc:n  disables linked commands; *  tc:y  enables tagged commands; *  tc:n  disables tagged commands; *  tm:0  use head/simple/ordered queue tag sequences; *  tm:1  use only simple queue tags; *  tm:2  use only head of queue tags; *  tm:3  use only ordered queue tags; *  mq:xx set the max queue depth to the value xx (2 <= xx <= 32). * *  The default value is: "eata=lc:n,tc:n,mq:16,tm:0,et:n,rs:n". *  An example using the list of detection probes could be: *  "eata=0x7410,0x230,lc:y,tc:n,mq:4,eh:n,et:n". * *  When loading as a module, parameters can be specified as well. *  The above example would be (use 1 in place of y and 0 in place of n): * *  modprobe eata io_port=0x7410,0x230 linked_comm=1 tagged_comm=0 \ *                max_queue_depth=4 tag_mode=0 use_new_eh_code=0 \ *                ext_tran=0 rev_scan=1 * *  ---------------------------------------------------------------------------- *  In this implementation, linked commands are designed to work with any DISK *  or CD-ROM, since this linking has only the intent of clustering (time-wise) *  and reordering by elevator sorting commands directed to each device, *  without any relation with the actual SCSI protocol between the controller *  and the device. *  If Q is the queue depth reported at boot time for each device (also named *  cmds/lun) and Q > 2, whenever there is already an active command to the *  device all other commands to the same device  (up to Q-1) are kept waiting *  in the elevator sorting queue. When the active command completes, the *  commands in this queue are sorted by sector address. The sort is chosen *  between increasing or decreasing by minimizing the seek distance between *  the sector of the commands just completed and the sector of the first *  command in the list to be sorted. *  Trivial math assures that the unsorted average seek distance when doing *  random seeks over S sectors is S/3. *  When (Q-1) requests are uniformly distributed over S sectors, the average *  distance between two adjacent requests is S/((Q-1) + 1), so the sorted *  average seek distance for (Q-1) random requests over S sectors is S/Q. *  The elevator sorting hence divides the seek distance by a factor Q/3. *  The above pure geometric remarks are valid in all cases and the *  driver effectively reduces the seek distance by the predicted factor *  when there are Q concurrent read i/o operations on the device, but this *  does not necessarily results in a noticeable performance improvement: *  your mileage may vary.... * *  Note: command reordering inside a batch of queued commands could cause *        wrong results only if there is at least one write request and the *        intersection (sector-wise) of all requests is not empty. *        When the driver detects a batch including overlapping requests *        (a really rare event) strict serial (pid) order is enforced. *  ---------------------------------------------------------------------------- *  The extended translation option (et:y) is useful when using large physical *  disks/arrays. It could also be useful when switching between Adaptec boards *  and DPT boards without reformatting the disk. *  When a boot disk is partitioned with extended translation, in order to *  be able to boot it with a DPT board is could be necessary to add to *  lilo.conf additional commands as in the following example: * *  fix-table *  disk=/dev/sda bios=0x80 sectors=63 heads=128 cylindres=546 * *  where the above geometry should be replaced with the one reported at *  power up by the DPT controller. *  ---------------------------------------------------------------------------- * *  The boards are named EATA0, EATA1,... according to the detection order. * *  In order to support multiple ISA boards in a reliable way, *  the driver sets host->wish_block = TRUE for all ISA boards. */#include <linux/version.h>#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))#define MAX_INT_PARAM 10#if defined(MODULE)#include <linux/module.h>#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,26)MODULE_PARM(io_port, "1-" __MODULE_STRING(MAX_INT_PARAM) "i");MODULE_PARM(linked_comm, "i");MODULE_PARM(tagged_comm, "i");MODULE_PARM(link_statistics, "i");MODULE_PARM(max_queue_depth, "i");MODULE_PARM(tag_mode, "i");MODULE_PARM(use_new_eh_code, "i");MODULE_PARM(ext_tran, "i");MODULE_PARM(rev_scan, "i");MODULE_AUTHOR("Dario Ballabio");#endif#endif#include <linux/string.h>#include <linux/sched.h>#include <linux/kernel.h>#include <linux/ioport.h>#include <linux/delay.h>#include <asm/io.h>#include <asm/system.h>#include <asm/byteorder.h>#include <linux/proc_fs.h>#include <linux/blk.h>#include "scsi.h"#include "hosts.h"#include "sd.h"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -