📄 sym_hipd.h
字号:
/* * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family * of PCI-SCSI IO processors. * * Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr> * * This driver is derived from the Linux sym53c8xx driver. * Copyright (C) 1998-2000 Gerard Roudier * * The sym53c8xx driver is derived from the ncr53c8xx driver that had been * a port of the FreeBSD ncr driver to Linux-1.2.13. * * The original ncr driver has been written for 386bsd and FreeBSD by * Wolfgang Stanglmeier <wolf@cologne.de> * Stefan Esser <se@mi.Uni-Koeln.de> * Copyright (C) 1994 Wolfgang Stanglmeier * * Other major contributions: * * NVRAM detection and reading. * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk> * *----------------------------------------------------------------------------- * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include <linux/gfp.h>#ifndef SYM_HIPD_H#define SYM_HIPD_H/* * Generic driver options. * * They may be defined in platform specific headers, if they * are useful. * * SYM_OPT_HANDLE_DIR_UNKNOWN * When this option is set, the SCRIPTS used by the driver * are able to handle SCSI transfers with direction not * supplied by user. * (set for Linux-2.0.X) * * SYM_OPT_HANDLE_DEVICE_QUEUEING * When this option is set, the driver will use a queue per * device and handle QUEUE FULL status requeuing internally. * * SYM_OPT_LIMIT_COMMAND_REORDERING * When this option is set, the driver tries to limit tagged * command reordering to some reasonnable value. * (set for Linux) */#if 0#define SYM_OPT_HANDLE_DIR_UNKNOWN#define SYM_OPT_HANDLE_DEVICE_QUEUEING#define SYM_OPT_LIMIT_COMMAND_REORDERING#endif/* * Active debugging tags and verbosity. * Both DEBUG_FLAGS and sym_verbose can be redefined * by the platform specific code to something else. */#define DEBUG_ALLOC (0x0001)#define DEBUG_PHASE (0x0002)#define DEBUG_POLL (0x0004)#define DEBUG_QUEUE (0x0008)#define DEBUG_RESULT (0x0010)#define DEBUG_SCATTER (0x0020)#define DEBUG_SCRIPT (0x0040)#define DEBUG_TINY (0x0080)#define DEBUG_TIMING (0x0100)#define DEBUG_NEGO (0x0200)#define DEBUG_TAGS (0x0400)#define DEBUG_POINTER (0x0800)#ifndef DEBUG_FLAGS#define DEBUG_FLAGS (0x0000)#endif#ifndef sym_verbose#define sym_verbose (np->verbose)#endif/* * These ones should have been already defined. */#ifndef assert#define assert(expression) { \ if (!(expression)) { \ (void)panic( \ "assertion \"%s\" failed: file \"%s\", line %d\n", \ #expression, \ __FILE__, __LINE__); \ } \}#endif/* * Number of tasks per device we want to handle. */#if SYM_CONF_MAX_TAG_ORDER > 8#error "more than 256 tags per logical unit not allowed."#endif#define SYM_CONF_MAX_TASK (1<<SYM_CONF_MAX_TAG_ORDER)/* * Donnot use more tasks that we can handle. */#ifndef SYM_CONF_MAX_TAG#define SYM_CONF_MAX_TAG SYM_CONF_MAX_TASK#endif#if SYM_CONF_MAX_TAG > SYM_CONF_MAX_TASK#undef SYM_CONF_MAX_TAG#define SYM_CONF_MAX_TAG SYM_CONF_MAX_TASK#endif/* * This one means 'NO TAG for this job' */#define NO_TAG (256)/* * Number of SCSI targets. */#if SYM_CONF_MAX_TARGET > 16#error "more than 16 targets not allowed."#endif/* * Number of logical units per target. */#if SYM_CONF_MAX_LUN > 64#error "more than 64 logical units per target not allowed."#endif/* * Asynchronous pre-scaler (ns). Shall be 40 for * the SCSI timings to be compliant. */#define SYM_CONF_MIN_ASYNC (40)/* * MEMORY ALLOCATOR. */#define SYM_MEM_WARN 1 /* Warn on failed operations */#define SYM_MEM_PAGE_ORDER 0 /* 1 PAGE maximum */#define SYM_MEM_CLUSTER_SHIFT (PAGE_SHIFT+SYM_MEM_PAGE_ORDER)#define SYM_MEM_FREE_UNUSED /* Free unused pages immediately *//* * Shortest memory chunk is (1<<SYM_MEM_SHIFT), currently 16. * Actual allocations happen as SYM_MEM_CLUSTER_SIZE sized. * (1 PAGE at a time is just fine). */#define SYM_MEM_SHIFT 4#define SYM_MEM_CLUSTER_SIZE (1UL << SYM_MEM_CLUSTER_SHIFT)#define SYM_MEM_CLUSTER_MASK (SYM_MEM_CLUSTER_SIZE-1)/* * Number of entries in the START and DONE queues. * * We limit to 1 PAGE in order to succeed allocation of * these queues. Each entry is 8 bytes long (2 DWORDS). */#ifdef SYM_CONF_MAX_START#define SYM_CONF_MAX_QUEUE (SYM_CONF_MAX_START+2)#else#define SYM_CONF_MAX_QUEUE (7*SYM_CONF_MAX_TASK+2)#define SYM_CONF_MAX_START (SYM_CONF_MAX_QUEUE-2)#endif#if SYM_CONF_MAX_QUEUE > SYM_MEM_CLUSTER_SIZE/8#undef SYM_CONF_MAX_QUEUE#define SYM_CONF_MAX_QUEUE (SYM_MEM_CLUSTER_SIZE/8)#undef SYM_CONF_MAX_START#define SYM_CONF_MAX_START (SYM_CONF_MAX_QUEUE-2)#endif/* * For this one, we want a short name :-) */#define MAX_QUEUE SYM_CONF_MAX_QUEUE/* * Common definitions for both bus space based and legacy IO methods. */#define INB_OFF(np, o) ioread8(np->s.ioaddr + (o))#define INW_OFF(np, o) ioread16(np->s.ioaddr + (o))#define INL_OFF(np, o) ioread32(np->s.ioaddr + (o))#define OUTB_OFF(np, o, val) iowrite8((val), np->s.ioaddr + (o))#define OUTW_OFF(np, o, val) iowrite16((val), np->s.ioaddr + (o))#define OUTL_OFF(np, o, val) iowrite32((val), np->s.ioaddr + (o))#define INB(np, r) INB_OFF(np, offsetof(struct sym_reg, r))#define INW(np, r) INW_OFF(np, offsetof(struct sym_reg, r))#define INL(np, r) INL_OFF(np, offsetof(struct sym_reg, r))#define OUTB(np, r, v) OUTB_OFF(np, offsetof(struct sym_reg, r), (v))#define OUTW(np, r, v) OUTW_OFF(np, offsetof(struct sym_reg, r), (v))#define OUTL(np, r, v) OUTL_OFF(np, offsetof(struct sym_reg, r), (v))#define OUTONB(np, r, m) OUTB(np, r, INB(np, r) | (m))#define OUTOFFB(np, r, m) OUTB(np, r, INB(np, r) & ~(m))#define OUTONW(np, r, m) OUTW(np, r, INW(np, r) | (m))#define OUTOFFW(np, r, m) OUTW(np, r, INW(np, r) & ~(m))#define OUTONL(np, r, m) OUTL(np, r, INL(np, r) | (m))#define OUTOFFL(np, r, m) OUTL(np, r, INL(np, r) & ~(m))/* * We normally want the chip to have a consistent view * of driver internal data structures when we restart it. * Thus these macros. */#define OUTL_DSP(np, v) \ do { \ MEMORY_WRITE_BARRIER(); \ OUTL(np, nc_dsp, (v)); \ } while (0)#define OUTONB_STD() \ do { \ MEMORY_WRITE_BARRIER(); \ OUTONB(np, nc_dcntl, (STD|NOCOM)); \ } while (0)/* * 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_WAIT (4) /* waiting for resource */#define HS_DONEMASK (0x80)#define HS_COMPLETE (4|HS_DONEMASK)#define HS_SEL_TIMEOUT (5|HS_DONEMASK) /* Selection timeout */#define HS_UNEXPECTED (6|HS_DONEMASK) /* Unexpected disconnect */#define HS_COMP_ERR (7|HS_DONEMASK) /* Completed with error *//* * Software Interrupt Codes */#define SIR_BAD_SCSI_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_COMPLETE_ERROR (20)#define SIR_DATA_OVERRUN (21)#define SIR_BAD_PHASE (22)#if SYM_CONF_DMA_ADDRESSING_MODE == 2#define SIR_DMAP_DIRTY (23)#define SIR_MAX (23)#else#define SIR_MAX (22)#endif/* * Extended error bit codes. * xerr_status field of struct sym_ccb. */#define XE_EXTRA_DATA (1) /* unexpected data phase */#define XE_BAD_PHASE (1<<1) /* illegal phase (4/5) */#define XE_PARITY_ERR (1<<2) /* unrecovered SCSI parity error */#define XE_SODL_UNRUN (1<<3) /* ODD transfer in DATA OUT phase */#define XE_SWIDE_OVRUN (1<<4) /* ODD transfer in DATA IN phase *//* * Negotiation status. * nego_status field of struct sym_ccb. */#define NS_SYNC (1)#define NS_WIDE (2)#define NS_PPR (3)/* * 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)#if 1#define CCB_HASH_CODE(dsa) \ (((dsa) >> (_LGRU16_(sizeof(struct sym_ccb)))) & CCB_HASH_MASK)#else#define CCB_HASH_CODE(dsa) (((dsa) >> 9) & CCB_HASH_MASK)#endif#if SYM_CONF_DMA_ADDRESSING_MODE == 2/* * We may want to use segment registers for 64 bit DMA. * 16 segments registers -> up to 64 GB addressable. */#define SYM_DMAP_SHIFT (4)#define SYM_DMAP_SIZE (1u<<SYM_DMAP_SHIFT)#define SYM_DMAP_MASK (SYM_DMAP_SIZE-1)#endif/* * Device flags. */#define SYM_DISC_ENABLED (1)#define SYM_TAGS_ENABLED (1<<1)#define SYM_SCAN_BOOT_DISABLED (1<<2)#define SYM_SCAN_LUNS_DISABLED (1<<3)/* * Host adapter miscellaneous flags. */#define SYM_AVOID_BUS_RESET (1)/* * Misc. */#define SYM_SNOOP_TIMEOUT (10000000)#define BUS_8_BIT 0#define BUS_16_BIT 1/* * Gather negotiable parameters value */struct sym_trans { u8 period; u8 offset; unsigned int width:1; unsigned int iu:1; unsigned int dt:1; unsigned int qas:1; unsigned int check_nego:1;};/* * Global TCB HEADER. * * Due to lack of indirect addressing on earlier NCR chips, * this substructure is copied from the TCB to a global * address after selection. * For SYMBIOS chips that support LOAD/STORE this copy is * not needed and thus not performed. */struct sym_tcbh { /* * Scripts bus addresses of LUN table accessed from scripts. * LUN #0 is a special case, since multi-lun devices are rare, * and we we want to speed-up the general case and not waste * resources. */ u32 luntbl_sa; /* bus address of this table */ u32 lun0_sa; /* bus address of LCB #0 */ /* * Actual SYNC/WIDE IO registers value for this target. * 'sval', 'wval' and 'uval' are read from SCRIPTS and * so have alignment constraints. *//*0*/ u_char uval; /* -> SCNTL4 register *//*1*/ u_char sval; /* -> SXFER io register *//*2*/ u_char filler1;/*3*/ u_char wval; /* -> SCNTL3 io register */};/* * Target Control Block */struct sym_tcb { /* * TCB header. * Assumed at offset 0. *//*0*/ struct sym_tcbh head; /* * LUN table used by the SCRIPTS processor. * An array of bus addresses is used on reselection. */ u32 *luntbl; /* LCBs bus address table */ /* * LUN table used by the C code. */ struct sym_lcb *lun0p; /* LCB of LUN #0 (usual case) */#if SYM_CONF_MAX_LUN > 1 struct sym_lcb **lunmp; /* Other LCBs [1..MAX_LUN] */#endif /* * Bitmap that tells about LUNs that succeeded at least * 1 IO and therefore assumed to be a real device. * Avoid useless allocation of the LCB structure. */ u32 lun_map[(SYM_CONF_MAX_LUN+31)/32]; /* * Bitmap that tells about LUNs that haven't yet an LCB * allocated (not discovered or LCB allocation failed). */ u32 busy0_map[(SYM_CONF_MAX_LUN+31)/32];#ifdef SYM_HAVE_STCB /* * O/S specific data structure. */ struct sym_stcb s;#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -