📄 aic7xxx.c
字号:
* EISA/VL-bus stuff */#define MINSLOT 1#define MAXSLOT 15#define SLOTBASE(x) ((x) << 12)#define BASE_TO_SLOT(x) ((x) >> 12)/* * Standard EISA Host ID regs (Offset from slot base) */#define AHC_HID0 0x80 /* 0,1: msb of ID2, 2-7: ID1 */#define AHC_HID1 0x81 /* 0-4: ID3, 5-7: LSB ID2 */#define AHC_HID2 0x82 /* product */#define AHC_HID3 0x83 /* firmware revision *//* * AIC-7770 I/O range to reserve for a card */#define MINREG 0xC00#define MAXREG 0xCBF#define INTDEF 0x5C /* Interrupt Definition Register *//* * AIC-78X0 PCI registers */#define CLASS_PROGIF_REVID 0x08#define DEVREVID 0x000000FFul#define PROGINFC 0x0000FF00ul#define SUBCLASS 0x00FF0000ul#define BASECLASS 0xFF000000ul#define CSIZE_LATTIME 0x0C#define CACHESIZE 0x0000003Ful /* only 5 bits */#define LATTIME 0x0000FF00ul#define DEVCONFIG 0x40#define SCBSIZE32 0x00010000ul /* aic789X only */#define MPORTMODE 0x00000400ul /* aic7870 only */#define RAMPSM 0x00000200ul /* aic7870 only */#define RAMPSM_ULTRA2 0x00000004#define VOLSENSE 0x00000100ul#define SCBRAMSEL 0x00000080ul#define SCBRAMSEL_ULTRA2 0x00000008#define MRDCEN 0x00000040ul#define EXTSCBTIME 0x00000020ul /* aic7870 only */#define EXTSCBPEN 0x00000010ul /* aic7870 only */#define BERREN 0x00000008ul#define DACEN 0x00000004ul#define STPWLEVEL 0x00000002ul#define DIFACTNEGEN 0x00000001ul /* aic7870 only */#define SCAMCTL 0x1a /* Ultra2 only */#define CCSCBBADDR 0xf0 /* aic7895/6/7 *//* * Define the different types of SEEPROMs on aic7xxx adapters * and make it also represent the address size used in accessing * its registers. The 93C46 chips have 1024 bits organized into * 64 16-bit words, while the 93C56 chips have 2048 bits organized * into 128 16-bit words. The C46 chips use 6 bits to address * each word, while the C56 and C66 (4096 bits) use 8 bits to * address each word. */typedef enum {C46 = 6, C56_66 = 8} seeprom_chip_type;/* * * Define the format of the SEEPROM registers (16 bits). * */struct seeprom_config {/* * SCSI ID Configuration Flags */#define CFXFER 0x0007 /* synchronous transfer rate */#define CFSYNCH 0x0008 /* enable synchronous transfer */#define CFDISC 0x0010 /* enable disconnection */#define CFWIDEB 0x0020 /* wide bus device (wide card) */#define CFSYNCHISULTRA 0x0040 /* CFSYNC is an ultra offset */#define CFNEWULTRAFORMAT 0x0080 /* Use the Ultra2 SEEPROM format */#define CFSTART 0x0100 /* send start unit SCSI command */#define CFINCBIOS 0x0200 /* include in BIOS scan */#define CFRNFOUND 0x0400 /* report even if not found */#define CFMULTILUN 0x0800 /* probe mult luns in BIOS scan */#define CFWBCACHEYES 0x4000 /* Enable W-Behind Cache on drive */#define CFWBCACHENC 0xc000 /* Don't change W-Behind Cache *//* UNUSED 0x3000 */ unsigned short device_flags[16]; /* words 0-15 *//* * BIOS Control Bits */#define CFSUPREM 0x0001 /* support all removable drives */#define CFSUPREMB 0x0002 /* support removable drives for boot only */#define CFBIOSEN 0x0004 /* BIOS enabled *//* UNUSED 0x0008 */#define CFSM2DRV 0x0010 /* support more than two drives */#define CF284XEXTEND 0x0020 /* extended translation (284x cards) *//* UNUSED 0x0040 */#define CFEXTEND 0x0080 /* extended translation enabled *//* UNUSED 0xFF00 */ unsigned short bios_control; /* word 16 *//* * Host Adapter Control Bits */#define CFAUTOTERM 0x0001 /* Perform Auto termination */#define CFULTRAEN 0x0002 /* Ultra SCSI speed enable (Ultra cards) */#define CF284XSELTO 0x0003 /* Selection timeout (284x cards) */#define CF284XFIFO 0x000C /* FIFO Threshold (284x cards) */#define CFSTERM 0x0004 /* SCSI low byte termination */#define CFWSTERM 0x0008 /* SCSI high byte termination (wide card) */#define CFSPARITY 0x0010 /* SCSI parity */#define CF284XSTERM 0x0020 /* SCSI low byte termination (284x cards) */#define CFRESETB 0x0040 /* reset SCSI bus at boot */#define CFBPRIMARY 0x0100 /* Channel B primary on 7895 chipsets */#define CFSEAUTOTERM 0x0400 /* aic7890 Perform SE Auto Term */#define CFLVDSTERM 0x0800 /* aic7890 LVD Termination *//* UNUSED 0xF280 */ unsigned short adapter_control; /* word 17 *//* * Bus Release, Host Adapter ID */#define CFSCSIID 0x000F /* host adapter SCSI ID *//* UNUSED 0x00F0 */#define CFBRTIME 0xFF00 /* bus release time */ unsigned short brtime_id; /* word 18 *//* * Maximum targets */#define CFMAXTARG 0x00FF /* maximum targets *//* UNUSED 0xFF00 */ unsigned short max_targets; /* word 19 */ unsigned short res_1[11]; /* words 20-30 */ unsigned short checksum; /* word 31 */};#define SELBUS_MASK 0x0a#define SELNARROW 0x00#define SELBUSB 0x08#define SINGLE_BUS 0x00#define SCB_TARGET(scb) \ (((scb)->hscb->target_channel_lun & TID) >> 4)#define SCB_LUN(scb) \ ((scb)->hscb->target_channel_lun & LID)#define SCB_IS_SCSIBUS_B(scb) \ (((scb)->hscb->target_channel_lun & SELBUSB) != 0)/* * If an error occurs during a data transfer phase, run the command * to completion - it's easier that way - making a note of the error * condition in this location. This then will modify a DID_OK status * into an appropriate error for the higher-level SCSI code. */#define aic7xxx_error(cmd) ((cmd)->SCp.Status)/* * Keep track of the targets returned status. */#define aic7xxx_status(cmd) ((cmd)->SCp.sent_command)/* * The position of the SCSI commands scb within the scb array. */#define aic7xxx_position(cmd) ((cmd)->SCp.have_data_in)/* * So we can keep track of our host structs */static struct aic7xxx_host *first_aic7xxx = NULL;/* * As of Linux 2.1, the mid-level SCSI code uses virtual addresses * in the scatter-gather lists. We need to convert the virtual * addresses to physical addresses. */struct hw_scatterlist { unsigned int address; unsigned int length;};/* * Maximum number of SG segments these cards can support. */#define AIC7XXX_MAX_SG 128/* * The maximum number of SCBs we could have for ANY type * of card. DON'T FORGET TO CHANGE THE SCB MASK IN THE * SEQUENCER CODE IF THIS IS MODIFIED! */#define AIC7XXX_MAXSCB 255struct aic7xxx_hwscb {/* ------------ Begin hardware supported fields ---------------- *//* 0*/ unsigned char control;/* 1*/ unsigned char target_channel_lun; /* 4/1/3 bits *//* 2*/ unsigned char target_status;/* 3*/ unsigned char SG_segment_count;/* 4*/ unsigned int SG_list_pointer;/* 8*/ unsigned char residual_SG_segment_count;/* 9*/ unsigned char residual_data_count[3];/*12*/ unsigned int data_pointer;/*16*/ unsigned int data_count;/*20*/ unsigned int SCSI_cmd_pointer;/*24*/ unsigned char SCSI_cmd_length;/*25*/ unsigned char tag; /* Index into our kernel SCB array. * Also used as the tag for tagged I/O */#define SCB_PIO_TRANSFER_SIZE 26 /* amount we need to upload/download * via PIO to initialize a transaction. *//*26*/ unsigned char next; /* Used to thread SCBs awaiting selection * or disconnected down in the sequencer. *//*27*/ unsigned char prev;/*28*/ unsigned int pad; /* * Unused by the kernel, but we require * the padding so that the array of * hardware SCBs is alligned on 32 byte * boundaries so the sequencer can index */};typedef enum { SCB_FREE = 0x0000, SCB_WAITINGQ = 0x0002, SCB_ACTIVE = 0x0004, SCB_SENSE = 0x0008, SCB_ABORT = 0x0010, SCB_DEVICE_RESET = 0x0020, SCB_RESET = 0x0040, SCB_RECOVERY_SCB = 0x0080, SCB_WAS_BUSY = 0x0100, SCB_MSGOUT_SENT = 0x0200, SCB_MSGOUT_SDTR = 0x0400, SCB_MSGOUT_WDTR = 0x0800, SCB_MSGOUT_BITS = SCB_MSGOUT_SENT | SCB_MSGOUT_SDTR | SCB_MSGOUT_WDTR, SCB_QUEUED_ABORT = 0x1000, SCB_QUEUED_FOR_DONE = 0x2000} scb_flag_type;typedef enum { AHC_FNONE = 0x00000000, AHC_PAGESCBS = 0x00000001, AHC_CHANNEL_B_PRIMARY = 0x00000002, AHC_USEDEFAULTS = 0x00000004, AHC_INDIRECT_PAGING = 0x00000008, AHC_CHNLB = 0x00000020, AHC_CHNLC = 0x00000040, AHC_EXTEND_TRANS_A = 0x00000100, AHC_EXTEND_TRANS_B = 0x00000200, AHC_TERM_ENB_A = 0x00000400, AHC_TERM_ENB_SE_LOW = 0x00000400, AHC_TERM_ENB_B = 0x00000800, AHC_TERM_ENB_SE_HIGH = 0x00000800, AHC_HANDLING_REQINITS = 0x00001000, AHC_TARGETMODE = 0x00002000, AHC_NEWEEPROM_FMT = 0x00004000, /* * Here ends the FreeBSD defined flags and here begins the linux defined * flags. NOTE: I did not preserve the old flag name during this change * specifically to force me to evaluate what flags were being used properly * 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, AHC_BIOS_ENABLED = 0x00800000, AHC_SEEPROM_FOUND = 0x01000000, AHC_TERM_ENB_LVD = 0x02000000, AHC_ABORT_PENDING = 0x04000000, AHC_RESET_PENDING = 0x08000000,#define AHC_IN_ISR_BIT 28 AHC_IN_ISR = 0x10000000, AHC_IN_ABORT = 0x20000000, AHC_IN_RESET = 0x40000000, AHC_EXTERNAL_SRAM = 0x80000000} ahc_flag_type;typedef enum { AHC_NONE = 0x0000, AHC_CHIPID_MASK = 0x00ff, AHC_AIC7770 = 0x0001, AHC_AIC7850 = 0x0002, AHC_AIC7860 = 0x0003, AHC_AIC7870 = 0x0004, AHC_AIC7880 = 0x0005, AHC_AIC7890 = 0x0006, AHC_AIC7895 = 0x0007, AHC_AIC7896 = 0x0008, AHC_AIC7892 = 0x0009, AHC_AIC7899 = 0x000a, AHC_VL = 0x0100, AHC_EISA = 0x0200, AHC_PCI = 0x0400,} ahc_chip;typedef enum { AHC_FENONE = 0x0000, AHC_ULTRA = 0x0001, AHC_ULTRA2 = 0x0002, AHC_WIDE = 0x0004, AHC_TWIN = 0x0008, AHC_MORE_SRAM = 0x0010, AHC_CMD_CHAN = 0x0020, AHC_QUEUE_REGS = 0x0040, AHC_SG_PRELOAD = 0x0080, AHC_SPIOCAP = 0x0100, AHC_ULTRA160 = 0x0200,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -