📄 aic7xxx_old.c
字号:
{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! */static const char *board_names[] = { "AIC-7xxx Unknown", /* AIC_NONE */ "Adaptec AIC-7810 Hardware RAID Controller", /* AIC_7810 */ "Adaptec AIC-7770 SCSI host adapter", /* AIC_7770 */ "Adaptec AHA-274X SCSI host adapter", /* AIC_7771 */ "Adaptec AHA-284X SCSI host adapter", /* AIC_284x */ "Adaptec AIC-7850 SCSI host adapter", /* AIC_7850 */ "Adaptec AIC-7855 SCSI host adapter", /* AIC_7855 */ "Adaptec AIC-7860 Ultra SCSI host adapter", /* AIC_7860 */ "Adaptec AHA-2940A Ultra SCSI host adapter", /* AIC_7861 */ "Adaptec AIC-7870 SCSI host adapter", /* AIC_7870 */ "Adaptec AHA-294X SCSI host adapter", /* AIC_7871 */ "Adaptec AHA-394X SCSI host adapter", /* AIC_7872 */ "Adaptec AHA-398X SCSI host adapter", /* AIC_7873 */ "Adaptec AHA-2944 SCSI host adapter", /* AIC_7874 */ "Adaptec AIC-7880 Ultra SCSI host adapter", /* AIC_7880 */ "Adaptec AHA-294X Ultra SCSI host adapter", /* AIC_7881 */ "Adaptec AHA-394X Ultra SCSI host adapter", /* AIC_7882 */ "Adaptec AHA-398X Ultra SCSI host adapter", /* AIC_7883 */ "Adaptec AHA-2944 Ultra SCSI host adapter", /* AIC_7884 */ "Adaptec AHA-2940UW Pro Ultra SCSI host adapter", /* AIC_7887 */ "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 */};/* * There should be a specific return value for this in scsi.h, but * it seems that most drivers ignore it. */#define DID_UNDERFLOW DID_ERROR/* * What we want to do is have the higher level scsi driver requeue * the command to us. There is no specific driver status for this * condition, but the higher level scsi driver will requeue the * command on a DID_BUS_BUSY error. * * Upon further inspection and testing, it seems that DID_BUS_BUSY * will *always* retry the command. We can get into an infinite loop * if this happens when we really want some sort of counter that * will automatically abort/reset the command after so many retries. * Using DID_ERROR will do just that. (Made by a suggestion by * Doug Ledford 8/1/96) */#define DID_RETRY_COMMAND DID_ERROR#define HSCSIID 0x07#define SCSI_RESET 0x040/* * 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 0xCFF#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)/* * The stored DMA mapping for single-buffer data transfers. */#define aic7xxx_mapping(cmd) ((cmd)->SCp.phase)/* * Get out private data area from a scsi cmd pointer */#define AIC_DEV(cmd) ((struct aic_dev_data *)(cmd)->device->hostdata)/* * 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 aligned on 32 byte * boundaries so the sequencer can index */};typedef enum { SCB_FREE = 0x0000, SCB_DTR_SCB = 0x0001, SCB_WAITINGQ = 0x0002, SCB_ACTIVE = 0x0004, SCB_SENSE = 0x0008, SCB_ABORT = 0x0010, SCB_DEVICE_RESET = 0x0020, SCB_RESET = 0x0040, SCB_RECOVERY_SCB = 0x0080, SCB_MSGOUT_PPR = 0x0100, SCB_MSGOUT_SENT = 0x0200, SCB_MSGOUT_SDTR = 0x0400, SCB_MSGOUT_WDTR = 0x0800, SCB_MSGOUT_BITS = SCB_MSGOUT_PPR | SCB_MSGOUT_SENT | SCB_MSGOUT_SDTR | SCB_MSGOUT_WDTR, SCB_QUEUED_ABORT = 0x1000, SCB_QUEUED_FOR_DONE = 0x2000, SCB_WAS_BUSY = 0x4000, SCB_QUEUE_FULL = 0x8000} 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,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -