📄 advansys.c
字号:
the interrupt handler. In the timeout function if the interrupt has not occurred then print a message and run in polled mode. 3. Allow bus type scanning order to be changed. 4. Need to add support for target mode commands, cf. CAM XPT. J. Credits (Chronological Order) Bob Frey <bfrey@turbolinux.com.cn> wrote the AdvanSys SCSI driver and maintained it up to 3.3F. He continues to answer questions and help maintain the driver. Nathan Hartwell <mage@cdc3.cdc.net> provided the directions and basis for the Linux v1.3.X changes which were included in the 1.2 release. Thomas E Zerucha <zerucha@shell.portal.com> pointed out a bug in advansys_biosparam() which was fixed in the 1.3 release. Erik Ratcliffe <erik@caldera.com> has done testing of the AdvanSys driver in the Caldera releases. Rik van Riel <H.H.vanRiel@fys.ruu.nl> provided a patch to AscWaitTixISRDone() which he found necessary to make the driver work with a SCSI-1 disk. Mark Moran <mmoran@mmoran.com> has helped test Ultra-Wide support in the 3.1A driver. Doug Gilbert <dgilbert@interlog.com> has made changes and suggestions to improve the driver and done a lot of testing. Ken Mort <ken@mort.net> reported a DEBUG compile bug fixed in 3.2K. Tom Rini <trini@kernel.crashing.org> provided the CONFIG_ISA patch and helped with PowerPC wide and narrow board support. Philip Blundell <philip.blundell@pobox.com> provided an advansys_interrupts_enabled patch. Dave Jones <dave@denial.force9.co.uk> reported the compiler warnings generated when CONFIG_PROC_FS was not defined in the 3.2M driver. Jerry Quinn <jlquinn@us.ibm.com> fixed PowerPC support (endian problems) for wide cards. Bryan Henderson <bryanh@giraffe-data.com> helped debug narrow card error handling. Manuel Veloso <veloso@pobox.com> worked hard on PowerPC narrow board support and fixed a bug in AscGetEEPConfig(). Arnaldo Carvalho de Melo <acme@conectiva.com.br> made save_flags/restore_flags changes. Andy Kellner <AKellner@connectcom.net> continues the Advansys SCSI driver development for ConnectCom (Version > 3.3F). K. ConnectCom (AdvanSys) Contact Information Mail: ConnectCom Solutions, Inc. 1150 Ringwood Court San Jose, CA 95131 Operator/Sales: 1-408-383-9400 FAX: 1-408-383-9612 Tech Support: 1-408-467-2930 Tech Support E-Mail: linux@connectcom.net FTP Site: ftp.connectcom.net (login: anonymous) Web Site: http://www.connectcom.net*//* * --- Linux Version */#ifndef LINUX_VERSION_CODE#include <linux/version.h>#endif /* LINUX_VERSION_CODE *//* Convert Linux Version, Patch-level, Sub-level to LINUX_VERSION_CODE. */#define ASC_LINUX_VERSION(V, P, S) (((V) * 65536) + ((P) * 256) + (S))#define ASC_LINUX_KERNEL22 (LINUX_VERSION_CODE < ASC_LINUX_VERSION(2,4,0))#define ASC_LINUX_KERNEL24 (LINUX_VERSION_CODE >= ASC_LINUX_VERSION(2,4,0))/* Driver supported only in version 2.2 and version >= 2.4. */#if LINUX_VERSION_CODE < ASC_LINUX_VERSION(2,2,0) || \ (LINUX_VERSION_CODE > ASC_LINUX_VERSION(2,3,0) && \ LINUX_VERSION_CODE < ASC_LINUX_VERSION(2,4,0))#error "AdvanSys driver supported only in 2.2 and 2.4 or greater kernels."#endif/* * --- Linux Include Files */#include <linux/config.h>#include <linux/module.h>#if defined(CONFIG_X86) && !defined(CONFIG_ISA)#define CONFIG_ISA#endif /* CONFIG_X86 && !CONFIG_ISA */#include <linux/string.h>#include <linux/sched.h>#include <linux/kernel.h>#include <linux/types.h>#include <linux/ioport.h>#include <linux/delay.h>#include <linux/slab.h>#include <linux/mm.h>#include <linux/proc_fs.h>#include <linux/init.h>#include <asm/io.h>#include <asm/system.h>#include <asm/dma.h>#include <linux/blk.h>#include <linux/stat.h>#if ASC_LINUX_KERNEL24#include <linux/spinlock.h>#elif ASC_LINUX_KERNEL22#include <asm/spinlock.h>#endif#include "scsi.h"#include "hosts.h"#include "sd.h"#include "advansys.h"#ifdef CONFIG_PCI#include <linux/pci.h>#endif /* CONFIG_PCI *//* * --- Driver Options *//* Enable driver assertions. */#define ADVANSYS_ASSERT/* Enable driver /proc statistics. */#define ADVANSYS_STATS/* Enable driver tracing. *//* #define ADVANSYS_DEBUG *//* * --- Debugging Header */#ifdef ADVANSYS_DEBUG#define STATIC#else /* ADVANSYS_DEBUG */#define STATIC static#endif /* ADVANSYS_DEBUG *//* * --- Asc Library Constants and Macros */#define ASC_LIB_VERSION_MAJOR 1#define ASC_LIB_VERSION_MINOR 24#define ASC_LIB_SERIAL_NUMBER 123/* * Portable Data Types * * Any instance where a 32-bit long or pointer type is assumed * for precision or HW defined structures, the following define * types must be used. In Linux the char, short, and int types * are all consistent at 8, 16, and 32 bits respectively. Pointers * and long types are 64 bits on Alpha and UltraSPARC. */#define ASC_PADDR __u32 /* Physical/Bus address data type. */#define ASC_VADDR __u32 /* Virtual address data type. */#define ASC_DCNT __u32 /* Unsigned Data count type. */#define ASC_SDCNT __s32 /* Signed Data count type. *//* * These macros are used to convert a virtual address to a * 32-bit value. This currently can be used on Linux Alpha * which uses 64-bit virtual address but a 32-bit bus address. * This is likely to break in the future, but doing this now * will give us time to change the HW and FW to handle 64-bit * addresses. */#define ASC_VADDR_TO_U32 virt_to_bus#define ASC_U32_TO_VADDR bus_to_virttypedef unsigned char uchar;#ifndef NULL#define NULL (0)#endif#ifndef TRUE#define TRUE (1)#endif#ifndef FALSE#define FALSE (0)#endif#define EOF (-1)#define ERR (-1)#define UW_ERR (uint)(0xFFFF)#define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)#define AscPCIConfigVendorIDRegister 0x0000#define AscPCIConfigDeviceIDRegister 0x0002#define AscPCIConfigCommandRegister 0x0004#define AscPCIConfigStatusRegister 0x0006#define AscPCIConfigRevisionIDRegister 0x0008#define AscPCIConfigCacheSize 0x000C#define AscPCIConfigLatencyTimer 0x000D#define AscPCIIOBaseRegister 0x0010#define AscPCICmdRegBits_IOMemBusMaster 0x0007#define ASC_PCI_ID2BUS(id) ((id) & 0xFF)#define ASC_PCI_ID2DEV(id) (((id) >> 11) & 0x1F)#define ASC_PCI_ID2FUNC(id) (((id) >> 8) & 0x7)#define ASC_PCI_MKID(bus, dev, func) ((((dev) & 0x1F) << 11) | (((func) & 0x7) << 8) | ((bus) & 0xFF))#define ASC_PCI_VENDORID 0x10CD#define ASC_PCI_DEVICEID_1200A 0x1100#define ASC_PCI_DEVICEID_1200B 0x1200#define ASC_PCI_DEVICEID_ULTRA 0x1300#define ASC_PCI_REVISION_3150 0x02#define ASC_PCI_REVISION_3050 0x03#define ASC_DVCLIB_CALL_DONE (1)#define ASC_DVCLIB_CALL_FAILED (0)#define ASC_DVCLIB_CALL_ERROR (-1)/* * Enable CC_VERY_LONG_SG_LIST to support up to 64K element SG lists. * The SRB structure will have to be changed and the ASC_SRB2SCSIQ() * macro re-defined to be able to obtain a ASC_SCSI_Q pointer from the * SRB structure. */#define CC_VERY_LONG_SG_LIST 0#define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)#define PortAddr unsigned short /* port address size */#define inp(port) inb(port)#define outp(port, byte) outb((byte), (port))#define inpw(port) inw(port)#define outpw(port, word) outw((word), (port))#define ASC_MAX_SG_QUEUE 7#define ASC_MAX_SG_LIST 255#define ASC_CS_TYPE unsigned short#define ASC_IS_ISA (0x0001)#define ASC_IS_ISAPNP (0x0081)#define ASC_IS_EISA (0x0002)#define ASC_IS_PCI (0x0004)#define ASC_IS_PCI_ULTRA (0x0104)#define ASC_IS_PCMCIA (0x0008)#define ASC_IS_MCA (0x0020)#define ASC_IS_VL (0x0040)#define ASC_ISA_PNP_PORT_ADDR (0x279)#define ASC_ISA_PNP_PORT_WRITE (ASC_ISA_PNP_PORT_ADDR+0x800)#define ASC_IS_WIDESCSI_16 (0x0100)#define ASC_IS_WIDESCSI_32 (0x0200)#define ASC_IS_BIG_ENDIAN (0x8000)#define ASC_CHIP_MIN_VER_VL (0x01)#define ASC_CHIP_MAX_VER_VL (0x07)#define ASC_CHIP_MIN_VER_PCI (0x09)#define ASC_CHIP_MAX_VER_PCI (0x0F)#define ASC_CHIP_VER_PCI_BIT (0x08)#define ASC_CHIP_MIN_VER_ISA (0x11)#define ASC_CHIP_MIN_VER_ISA_PNP (0x21)#define ASC_CHIP_MAX_VER_ISA (0x27)#define ASC_CHIP_VER_ISA_BIT (0x30)#define ASC_CHIP_VER_ISAPNP_BIT (0x20)#define ASC_CHIP_VER_ASYN_BUG (0x21)#define ASC_CHIP_VER_PCI 0x08#define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)#define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)#define ASC_CHIP_MIN_VER_EISA (0x41)#define ASC_CHIP_MAX_VER_EISA (0x47)#define ASC_CHIP_VER_EISA_BIT (0x40)#define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)#define ASC_MAX_LIB_SUPPORTED_ISA_CHIP_VER 0x21#define ASC_MAX_LIB_SUPPORTED_PCI_CHIP_VER 0x0A#define ASC_MAX_VL_DMA_ADDR (0x07FFFFFFL)#define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)#define ASC_MAX_PCI_DMA_ADDR (0xFFFFFFFFL)#define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)#define ASC_MAX_ISA_DMA_ADDR (0x00FFFFFFL)#define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)#define ASC_MAX_EISA_DMA_ADDR (0x07FFFFFFL)#define ASC_MAX_EISA_DMA_COUNT (0x07FFFFFFL)#define ASC_SCSI_ID_BITS 3#define ASC_SCSI_TIX_TYPE uchar#define ASC_ALL_DEVICE_BIT_SET 0xFF#define ASC_SCSI_BIT_ID_TYPE uchar#define ASC_MAX_TID 7#define ASC_MAX_LUN 7#define ASC_SCSI_WIDTH_BIT_SET 0xFF#define ASC_MAX_SENSE_LEN 32#define ASC_MIN_SENSE_LEN 14#define ASC_MAX_CDB_LEN 12#define ASC_SCSI_RESET_HOLD_TIME_US 60#define SCSICMD_TestUnitReady 0x00#define SCSICMD_Rewind 0x01#define SCSICMD_Rezero 0x01#define SCSICMD_RequestSense 0x03#define SCSICMD_Format 0x04#define SCSICMD_FormatUnit 0x04#define SCSICMD_Read6 0x08#define SCSICMD_Write6 0x0A#define SCSICMD_Seek6 0x0B#define SCSICMD_Inquiry 0x12#define SCSICMD_Verify6 0x13#define SCSICMD_ModeSelect6 0x15#define SCSICMD_ModeSense6 0x1A#define SCSICMD_StartStopUnit 0x1B#define SCSICMD_LoadUnloadTape 0x1B#define SCSICMD_ReadCapacity 0x25#define SCSICMD_Read10 0x28#define SCSICMD_Write10 0x2A#define SCSICMD_Seek10 0x2B#define SCSICMD_Erase10 0x2C#define SCSICMD_WriteAndVerify10 0x2E#define SCSICMD_Verify10 0x2F#define SCSICMD_WriteBuffer 0x3B#define SCSICMD_ReadBuffer 0x3C#define SCSICMD_ReadLong 0x3E#define SCSICMD_WriteLong 0x3F#define SCSICMD_ReadTOC 0x43#define SCSICMD_ReadHeader 0x44#define SCSICMD_ModeSelect10 0x55#define SCSICMD_ModeSense10 0x5A/* Inquiry Data Peripheral Device Types */#define SCSI_TYPE_DASD 0x00
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -