📄 sym53c8xx.c
字号:
#expression, \ __FILE__, __LINE__); \ } \}/*==========================================================**** Big/Little endian support.****==========================================================*//*** If the NCR uses big endian addressing mode over the ** PCI, actual io register addresses for byte and word ** accesses must be changed according to lane routing.** Btw, ncr_offb() and ncr_offw() macros only apply to ** constants and so donnot generate bloated code.*/#if defined(SCSI_NCR_BIG_ENDIAN)#define ncr_offb(o) (((o)&~3)+((~((o)&3))&3))#define ncr_offw(o) (((o)&~3)+((~((o)&3))&2))#else#define ncr_offb(o) (o)#define ncr_offw(o) (o)#endif/*** If the CPU and the NCR use same endian-ness adressing,** no byte reordering is needed for script patching.** Macro cpu_to_scr() is to be used for script patching.** Macro scr_to_cpu() is to be used for getting a DWORD ** from the script.*/#if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)#define cpu_to_scr(dw) cpu_to_le32(dw)#define scr_to_cpu(dw) le32_to_cpu(dw)#elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)#define cpu_to_scr(dw) cpu_to_be32(dw)#define scr_to_cpu(dw) be32_to_cpu(dw)#else#define cpu_to_scr(dw) (dw)#define scr_to_cpu(dw) (dw)#endif/*==========================================================**** Access to the controller chip.**** If NCR_IOMAPPED is defined, the driver will use ** normal IOs instead of the MEMORY MAPPED IO method ** recommended by PCI specifications.** If all PCI bridges, host brigdes and architectures ** would have been correctly designed for PCI, this ** option would be useless.****==========================================================*//*** If the CPU and the NCR use same endian-ness adressing,** no byte reordering is needed for accessing chip io ** registers. Functions suffixed by '_raw' are assumed ** to access the chip over the PCI without doing byte ** reordering. Functions suffixed by '_l2b' are ** assumed to perform little-endian to big-endian byte ** reordering, those suffixed by '_b2l' blah, blah,** blah, ...*/#if defined(NCR_IOMAPPED)/*** IO mapped only input / ouput*/#define INB_OFF(o) inb (np->base_io + ncr_offb(o))#define OUTB_OFF(o, val) outb ((val), np->base_io + ncr_offb(o))#if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)#define INW_OFF(o) inw_l2b (np->base_io + ncr_offw(o))#define INL_OFF(o) inl_l2b (np->base_io + (o))#define OUTW_OFF(o, val) outw_b2l ((val), np->base_io + ncr_offw(o))#define OUTL_OFF(o, val) outl_b2l ((val), np->base_io + (o))#elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)#define INW_OFF(o) inw_b2l (np->base_io + ncr_offw(o))#define INL_OFF(o) inl_b2l (np->base_io + (o))#define OUTW_OFF(o, val) outw_l2b ((val), np->base_io + ncr_offw(o))#define OUTL_OFF(o, val) outl_l2b ((val), np->base_io + (o))#else#define INW_OFF(o) inw_raw (np->base_io + ncr_offw(o))#define INL_OFF(o) inl_raw (np->base_io + (o))#define OUTW_OFF(o, val) outw_raw ((val), np->base_io + ncr_offw(o))#define OUTL_OFF(o, val) outl_raw ((val), np->base_io + (o))#endif /* ENDIANs */#else /* defined NCR_IOMAPPED *//*** MEMORY mapped IO input / output*/#define INB_OFF(o) readb((char *)np->reg + ncr_offb(o))#define OUTB_OFF(o, val) writeb((val), (char *)np->reg + ncr_offb(o))#if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)#define INW_OFF(o) readw_l2b((char *)np->reg + ncr_offw(o))#define INL_OFF(o) readl_l2b((char *)np->reg + (o))#define OUTW_OFF(o, val) writew_b2l((val), (char *)np->reg + ncr_offw(o))#define OUTL_OFF(o, val) writel_b2l((val), (char *)np->reg + (o))#elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)#define INW_OFF(o) readw_b2l((char *)np->reg + ncr_offw(o))#define INL_OFF(o) readl_b2l((char *)np->reg + (o))#define OUTW_OFF(o, val) writew_l2b((val), (char *)np->reg + ncr_offw(o))#define OUTL_OFF(o, val) writel_l2b((val), (char *)np->reg + (o))#else#define INW_OFF(o) readw_raw((char *)np->reg + ncr_offw(o))#define INL_OFF(o) readl_raw((char *)np->reg + (o))#define OUTW_OFF(o, val) writew_raw((val), (char *)np->reg + ncr_offw(o))#define OUTL_OFF(o, val) writel_raw((val), (char *)np->reg + (o))#endif#endif /* defined NCR_IOMAPPED */#define INB(r) INB_OFF (offsetof(struct ncr_reg,r))#define INW(r) INW_OFF (offsetof(struct ncr_reg,r))#define INL(r) INL_OFF (offsetof(struct ncr_reg,r))#define OUTB(r, val) OUTB_OFF (offsetof(struct ncr_reg,r), (val))#define OUTW(r, val) OUTW_OFF (offsetof(struct ncr_reg,r), (val))#define OUTL(r, val) OUTL_OFF (offsetof(struct ncr_reg,r), (val))/*** Set bit field ON, OFF */#define OUTONB(r, m) OUTB(r, INB(r) | (m))#define OUTOFFB(r, m) OUTB(r, INB(r) & ~(m))#define OUTONW(r, m) OUTW(r, INW(r) | (m))#define OUTOFFW(r, m) OUTW(r, INW(r) & ~(m))#define OUTONL(r, m) OUTL(r, INL(r) | (m))#define OUTOFFL(r, m) OUTL(r, INL(r) & ~(m))/*==========================================================**** Command control block states.****==========================================================*/#define HS_IDLE (0)#define HS_BUSY (1)#define HS_NEGOTIATE (2) /* sync/wide data transfer*/#define HS_DISCONNECT (3) /* Disconnected by target */#define HS_DONEMASK (0x80)#define HS_COMPLETE (4|HS_DONEMASK)#define HS_SEL_TIMEOUT (5|HS_DONEMASK) /* Selection timeout */#define HS_RESET (6|HS_DONEMASK) /* SCSI reset */#define HS_ABORTED (7|HS_DONEMASK) /* Transfer aborted */#define HS_TIMEOUT (8|HS_DONEMASK) /* Software timeout */#define HS_FAIL (9|HS_DONEMASK) /* SCSI or PCI bus errors */#define HS_UNEXPECTED (10|HS_DONEMASK)/* Unexpected disconnect */#define DSA_INVALID 0xffffffff/*==========================================================**** Software Interrupt Codes****==========================================================*/#define SIR_BAD_STATUS (1)#define SIR_SEL_ATN_NO_MSG_OUT (2)#define SIR_MSG_RECEIVED (3)#define SIR_MSG_WEIRD (4)#define SIR_NEGO_FAILED (5)#define SIR_NEGO_PROTO (6)#define SIR_SCRIPT_STOPPED (7)#define SIR_REJECT_TO_SEND (8)#define SIR_SWIDE_OVERRUN (9)#define SIR_SODL_UNDERRUN (10)#define SIR_RESEL_NO_MSG_IN (11)#define SIR_RESEL_NO_IDENTIFY (12)#define SIR_RESEL_BAD_LUN (13)#define SIR_TARGET_SELECTED (14)#define SIR_RESEL_BAD_I_T_L (15)#define SIR_RESEL_BAD_I_T_L_Q (16)#define SIR_ABORT_SENT (17)#define SIR_RESEL_ABORTED (18)#define SIR_MSG_OUT_DONE (19)#define SIR_AUTO_SENSE_DONE (20)#define SIR_DUMMY_INTERRUPT (21)#define SIR_MAX (21)/*==========================================================**** Extended error bits.** xerr_status field of struct ccb.****==========================================================*/#define XE_EXTRA_DATA (1) /* unexpected data phase */#define XE_BAD_PHASE (2) /* illegal phase (4/5) */#define XE_PARITY_ERR (4) /* unrecovered SCSI parity error */#define XE_SODL_UNRUN (1<<3)#define XE_SWIDE_OVRUN (1<<4)/*==========================================================**** Negotiation status.** nego_status field of struct ccb.****==========================================================*/#define NS_NOCHANGE (0)#define NS_SYNC (1)#define NS_WIDE (2)#define NS_PPR (4)/*==========================================================**** "Special features" of targets.** quirks field of struct tcb.** actualquirks field of struct ccb.****==========================================================*/#define QUIRK_AUTOSAVE (0x01)/*==========================================================**** Capability bits in Inquire response byte 7.****==========================================================*/#define INQ7_QUEUE (0x02)#define INQ7_SYNC (0x10)#define INQ7_WIDE16 (0x20)/*==========================================================**** A CCB hashed table is used to retrieve CCB address ** from DSA value.****==========================================================*/#define CCB_HASH_SHIFT 8#define CCB_HASH_SIZE (1UL << CCB_HASH_SHIFT)#define CCB_HASH_MASK (CCB_HASH_SIZE-1)#define CCB_HASH_CODE(dsa) (((dsa) >> 11) & CCB_HASH_MASK)/*==========================================================**** Declaration of structs.****==========================================================*/struct tcb;struct lcb;struct ccb;struct ncb;struct script;typedef struct ncb * ncb_p;typedef struct tcb * tcb_p;typedef struct lcb * lcb_p;typedef struct ccb * ccb_p;struct link { ncrcmd l_cmd; ncrcmd l_paddr;};struct usrcmd { u_long target; u_long lun; u_long data; u_long cmd;};#define UC_SETSYNC 10#define UC_SETTAGS 11#define UC_SETDEBUG 12#define UC_SETORDER 13#define UC_SETWIDE 14#define UC_SETFLAG 15#define UC_CLEARPROF 16#define UC_SETVERBOSE 17#define UC_RESETDEV 18#define UC_CLEARDEV 19#define UF_TRACE (0x01)#define UF_NODISC (0x02)#define UF_NOSCAN (0x04)#ifdef SCSI_NCR_PROFILE_SUPPORT/*** profiling data (per host)*/struct profile { u_long num_trans; u_long num_disc; u_long num_disc0; u_long num_break; u_long num_int; u_long num_fly; u_long num_kbytes;#if 000 u_long num_br1k; u_long num_br2k; u_long num_br4k; u_long num_br8k; u_long num_brnk;#endif};#endif/*========================================================================**** Declaration of structs: target control block****========================================================================*/struct tcb { /*---------------------------------------------------------------- ** LUN tables. ** An array of bus addresses is used on reselection by ** the SCRIPT. **---------------------------------------------------------------- */ u_int32 *luntbl; /* lcbs bus address table */ u_int32 b_luntbl; /* bus address of this table */ u_int32 b_lun0; /* bus address of lun0 */ lcb_p l0p; /* lcb of LUN #0 (normal case) */#if MAX_LUN > 1 lcb_p *lmp; /* Other lcb's [1..MAX_LUN] */#endif /*---------------------------------------------------------------- ** Target capabilities. **---------------------------------------------------------------- */ u_char inq_done; /* Target capabilities received */ u_char inq_byte7; /* Contains these capabilities */ /*---------------------------------------------------------------- ** Some flags. **---------------------------------------------------------------- */ u_char to_reset; /* This target is to be reset */ /*---------------------------------------------------------------- ** Pointer to the ccb used for negotiation. ** Prevent from starting a negotiation for all queued commands ** when tagged command queuing is enabled. **---------------------------------------------------------------- */ ccb_p nego_cp; /*---------------------------------------------------------------- ** statistical data **---------------------------------------------------------------- */ u_long transfers; u_long bytes; /*---------------------------------------------------------------- ** negotiation of wide and synch transfer and device quirks. ** sval, wval and uval are read from SCRIPTS and so have alignment ** constraints. **---------------------------------------------------------------- *//*0*/ u_char minsync;/*1*/ u_char sval;/*2*/ u_short period;/*0*/ u_char maxoffs;/*1*/ u_char quirks;/*2*/ u_char widedone;/*3*/ u_char wval;/*0*/ u_char uval;#ifdef SCSI_NCR_INTEGRITY_CHECKING u_char ic_min_sync; u_char ic_max_width; u_char ic_done;#endif u_char ic_maximums_set; u_char ppr_negotiation; /*---------------------------------------------------------------- ** User settable limits and options. ** These limits are read from the NVRAM if present. **---------------------------------------------------------------- */ u_char usrsync; u_char usrwide; u_short usrtags; u_char usrflag;};/*========================================================================**** Declaration of structs: lun control block****========================================================================*/struct lcb { /*---------------------------------------------------------------- ** On reselection, SCRIPTS use this value as a JUMP address ** after the IDENTIFY has been successfully received. ** This field is set to 'resel_tag' if TCQ is enabled and ** to 'resel_notag' if TCQ is disabled. ** (Must be at zero due to bad lun handling on reselection) **---------------------------------------------------------------- *//*0*/ u_int32 resel_task; /*---------------------------------------------------------------- ** Task table used by the script processor to retrieve the ** task corresponding to a reselected nexus. The TAG is used ** as offset to determine the corresponding entry. ** Each entry contains the associated CCB bus address. **---------------------------------------------------------------- */ u_int32 tasktbl_0; /* Used if TCQ not enabled */ u_int32 *tasktbl; u_int32 b_tasktbl; /*---------------------------------------------------------------- ** CCB queue management. **---------------------------------------------------------------- */ XPT_QUEHEAD busy_ccbq; /* Queue of busy CCBs */ XPT_QUEHEAD wait_ccbq; /* Queue of waiting for IO CCBs */ u_short busyccbs; /* CCBs busy for this lun */ u_short queuedccbs; /* CCBs queued to the controller*/ u_short queuedepth; /* Queue depth for this lun */ u_short scdev_depth; /* SCSI device queue depth */ u_short maxnxs; /* Max possible nexuses */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -