📄 advansys.c
字号:
1. Need to add memory mapping workaround. Test the memory mapping. If it doesn't work revert to I/O port access. Can a test be done safely? 2. Handle an interrupt not working. Keep an interrupt counter in 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. 5 Need to add support for new Linux SCSI error handling method. 6. Need to fix sti/cli code in Asc Library. 7. Need to fix abort code in Adv Library. 8. Reduce io_request_lock hold time. K. Credits 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 testing. Ken Mort <ken@mort.net> reported a DEBUG compile bug fixed in 3.2K. L. AdvanSys Contact Information Mail: Advanced System Products, 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: support@advansys.com FTP Site: ftp.advansys.com (login: anonymous) Web Site: http://www.advansys.com*//* * --- Linux Version *//* Convert Linux Version, Patch-level, Sub-level to LINUX_VERSION_CODE. */#define ASC_LINUX_VERSION(V, P, S) (((V) * 65536) + ((P) * 256) + (S))#ifndef LINUX_VERSION_CODE#include <linux/version.h>#endif /* LINUX_VERSION_CODE *//* * --- Linux Include Files */#include <linux/config.h>#if LINUX_VERSION_CODE >= ASC_LINUX_VERSION(1,3,0)#ifdef MODULE#include <linux/module.h>#endif /* MODULE */#endif /* version >= v1.3.0 */#include <linux/string.h>#include <linux/sched.h>#include <linux/kernel.h>#if LINUX_VERSION_CODE < ASC_LINUX_VERSION(2,1,0)#include <linux/head.h>#endif /* verions < v2.1.0 */#include <linux/types.h>#include <linux/ioport.h>#include <linux/delay.h>#include <linux/malloc.h>#include <linux/mm.h>#if LINUX_VERSION_CODE >= ASC_LINUX_VERSION(1,3,0)#include <linux/proc_fs.h>#endif /* version >= v1.3.0 */#if LINUX_VERSION_CODE >= ASC_LINUX_VERSION(2,1,23)#include <linux/init.h>#endif /* version >= v2.1.23 */#include <asm/io.h>#include <asm/system.h>#include <asm/dma.h>#if LINUX_VERSION_CODE < ASC_LINUX_VERSION(1,3,0)#include "../block/blk.h"#else /* version >= v1.3.0 */#include <linux/blk.h>#include <linux/stat.h>#endif /* version >= v1.3.0 */#if LINUX_VERSION_CODE >= ASC_LINUX_VERSION(2,3,18)#include <linux/spinlock.h>#elif LINUX_VERSION_CODE >= ASC_LINUX_VERSION(2,1,95)#include <asm/spinlock.h>#endif /* version >= 2.1.95 */#include "scsi.h"#include "hosts.h"#include "sd.h"#include "advansys.h"#if LINUX_VERSION_CODE >= ASC_LINUX_VERSION(2,1,93)#ifdef CONFIG_PCI#include <linux/pci.h>#endif /* CONFIG_PCI */#else /* version < v2.1.93 *//* * For earlier than v2.1.93 the driver has its own PCI configuration. * If PCI is not needed in a kernel before v2.1.93 this define can be * turned-off to make the driver object smaller. */#define ASC_CONFIG_PCI#endif /* version < v2.1.93 */#if LINUX_VERSION_CODE < ASC_LINUX_VERSION(2,1,0)#define cpu_to_le16(word) (word)#define le16_to_cpu(word) (word)#define cpu_to_le32(dword) (dword)#define le32_to_cpu(dword) (dword)#endif /* version < v2.1.0 *//* * --- Driver Options *//* Enable driver assertions. */#define ADVANSYS_ASSERT/* Enable driver tracing. *//* #define ADVANSYS_DEBUG *//* * Because of no /proc to display them, statistics are disabled * for versions prior to v1.3.0. */#if LINUX_VERSION_CODE < ASC_LINUX_VERSION(1,3,0)#undef ADVANSYS_STATS /* Disable statistics */#else /* version >= v1.3.0 */#define ADVANSYS_STATS /* Enable statistics. */#endif /* version >= v1.3.0 *//* * --- 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 121/* * 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 inpw(port) inw(port)#define inpl(port) inl(port)#define outp(port, byte) outb((byte), (port))#define outpw(port, word) outw((word), (port))#define outpl(port, dword) outl((dword), (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)#ifndef inpw_noswap#define inpw_noswap(port) inpw(port)#endif#ifndef outpw_noswap#define outpw_noswap(port, data) outpw(port, data)#endif#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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -