wd33c93_2.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:12k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* wd33c93_2.h - Western Digital WD33C93 SBIC (SCSI-2 Interface Ctrl) header */
  2. /* Copyright 1984-1995 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 03b,20jul95,jds  changed wd33c93Intr to sbicIntr to keep it consistent with
  7.  previous incarnations of this driver. Integrated into
  8.  vxWorks5.2
  9. 03a,16mar95,ihw  modified for use with generic SCSI thread manager
  10. 02a,14jan94,ihw  modified for enhanced SCSI library: multiple initiators,
  11.               disconnect/reconnect and synchronous transfer supported
  12. 01n,22sep92,rrr  added support for c++
  13. 01m,22jul92,wmd  added definition of WDREG.
  14. 01l,03jun92,ccc  added control register bits.
  15. 01k,26may92,rrr  the tree shuffle
  16. 01j,26may92,ajm  got rid of HOST_DEC def's (new compiler)
  17. 01i,21apr92,ccc  added sbicXferCountSet() declaration.
  18. 01h,04oct91,rrr  passed through the ansification filter
  19.   -fixed #else and #endif
  20.   -changed VOID to void
  21.   -changed ASMLANGUAGE to _ASMLANGUAGE
  22.   -changed copyright notice
  23. 01g,28sep91,ajm  ifdef'd HOST_DEC for compiler problem
  24. 01f,24oct90,dnw  declarations for void routines.
  25. 01e,19oct90,jcc  changed SBIC to WD_33C93_SCSI_CTRL in ANSI function prototypes;
  26.  removed unused macros.
  27. 01d,05oct90,shl  added ANSI function prototypes.
  28.                  made #endif ANSI style.
  29.                  added copyright notice.
  30. 01c,20aug90,jcc  changed UTINY to UINT8.
  31. 01b,18jul90,jcc  moved _ASMLANGUAGE conditionals to encompass entire file.
  32. 01a,27feb90,jcc  written based on old version from EDI
  33. */
  34. #ifndef __INCwd33c93_2h
  35. #define __INCwd33c93_2h
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. #ifndef _ASMLANGUAGE
  40. #ifndef INCLUDE_SCSI2
  41. #define INCLUDE_SCSI2
  42. #endif
  43. #include "scsiLib.h"
  44. #include "semLib.h"
  45. #include "msgQLib.h"
  46. /* SBIC state enumeration */
  47. typedef enum sbicState
  48.     {
  49.     SBIC_STATE_IDLE = 0,
  50.     SBIC_STATE_SELECT_PENDING,
  51.     SBIC_STATE_CONNECTED
  52.     } SBIC_STATE;
  53. typedef struct                  /* WD_33C93_SCSI_CTRL - Western Digital wd33c93
  54.                                    SCSI controller info */
  55.     {
  56.     SCSI_CTRL  scsiCtrl;        /* generic SCSI controller info */
  57.     SEMAPHORE  xferDoneSem; /* semaphore for waiting on transfer */
  58.     UINT       clkPeriod; /* period of the controller clock (nsec) */
  59.     UINT       defSelTimeOut; /* default dev. select time-out (usec) */
  60.     int        devType;      /* type of device (see definitions below) */
  61.     FUNCPTR    sysScsiDmaStart; /* function for starting SCSI DMA transfer */
  62.     FUNCPTR    sysScsiDmaAbort; /* function for aborting SCSI DMA transfer */
  63.     FUNCPTR    sysScsiBusReset; /* function for resetting SCSI bus */
  64.     int        sysScsiDmaArg;   /* call-back argument for SCSI DMA funcs. */
  65.     int        sysScsiResetArg; /* call-back argument for bus reset func. */
  66.     SBIC_STATE state; /* current state of controller */
  67.     volatile BOOL initPending; /* need to call post-reset initialisation ? */
  68.     volatile BOOL xferPending;  /* information transfer in progress */
  69.     volatile UINT8 *pAdrsReg; /* ptr address reg.*/
  70.     volatile UINT8 *pAuxStatReg;/* ptr aux. status reg.*/
  71.     volatile UINT8 *pRegFile;   /* ptr register file */
  72.     } WD_33C93_SCSI_CTRL;
  73.  /* 
  74.   * Structure that defines the functions that are common between the SCSI-2
  75.   * version of the driver and the SCSI-1 version of the driver. This structure
  76.   * provides the facilities so that both versions of the driver can co-exist
  77.   * in the same driver library
  78.   */
  79. typedef struct wd33c93functbl 
  80.     {
  81.     FUNCPTR sbicCommand;
  82.     FUNCPTR sbicIntr;
  83.     FUNCPTR sbicRegRead;
  84.     FUNCPTR sbicRegWrite;
  85.     FUNCPTR sbicXferCountGet;
  86.     FUNCPTR sbicXferCountSet;
  87.     FUNCPTR wd33c93CtrlInit;
  88.     FUNCPTR wd33c93Show;
  89.     } SCSIDRV_FUNC_TBL;
  90. /* SBIC device type */
  91. #define SBIC_WD33C93 0
  92. #define SBIC_WD33C93A 1
  93. /* SBIC command set */
  94. #define SBIC_CMD_RESET ((UINT8) 0x00)
  95. #define SBIC_CMD_ABORT ((UINT8) 0x01)
  96. #define SBIC_CMD_SET_ATN ((UINT8) 0x02)
  97. #define SBIC_CMD_NEG_ACK ((UINT8) 0x03)
  98. #define SBIC_CMD_DISCONNECT ((UINT8) 0x04)
  99. #define SBIC_CMD_RESELECT ((UINT8) 0x05)
  100. #define SBIC_CMD_SEL_ATN ((UINT8) 0x06)
  101. #define SBIC_CMD_SELECT ((UINT8) 0x07)
  102. #define SBIC_CMD_SEL_ATN_XFER ((UINT8) 0x08)
  103. #define SBIC_CMD_SELECT_XFER ((UINT8) 0x09)
  104. #define SBIC_CMD_RESELECT_RECV ((UINT8) 0x0a)
  105. #define SBIC_CMD_RESELECT_SEND ((UINT8) 0x0b)
  106. #define SBIC_CMD_WAIT_SEL_RCV ((UINT8) 0x0c)
  107. #define SBIC_CMD_RECV_CMD ((UINT8) 0x10)
  108. #define SBIC_CMD_RECV_DATA ((UINT8) 0x11)
  109. #define SBIC_CMD_RECV_MSG_OUT ((UINT8) 0x12)
  110. #define SBIC_CMD_RECV_INFO_OUT ((UINT8) 0x13)
  111. #define SBIC_CMD_SEND_STATUS ((UINT8) 0x14)
  112. #define SBIC_CMD_SEND_DATA ((UINT8) 0x15)
  113. #define SBIC_CMD_SEND_MSG_IN ((UINT8) 0x16)
  114. #define SBIC_CMD_SEND_INFO_IN ((UINT8) 0x17)
  115. #define SBIC_CMD_XLATE_ADDR ((UINT8) 0x18)
  116. #define SBIC_CMD_XFER_INFO ((UINT8) 0x20)
  117. #define SBIC_CMD_XFER_PAD ((UINT8) 0x21)
  118. #define SBIC_CMD_SING_BYTE_XFER ((UINT8) 0x80)
  119. /*  Status Register Codes   */
  120. #define STAT_GROUP(arg) ((arg) & 0xf0)  /* reason for interrupt */
  121. #define STAT_CODE(arg) ((arg) & 0x0f)  /* detail about reason */
  122. #define STAT_XFER(arg)       ((arg) & 0x08)  /* transfer was in progress */
  123. #define STAT_MCI_BITS ((UINT8) 0x07) /* MSG, C/D and I/O bits */
  124. #define STAT_PHASE_REQ   ((UINT8) 0x08)
  125. #define STAT_GROUP_RESET  ((UINT8) 0x00)
  126. #define STAT_GROUP_SUCCESSFUL  ((UINT8) 0x10)
  127. #define STAT_GROUP_PAUSE_ABORTED ((UINT8) 0x20)
  128. #define STAT_GROUP_TERMINATED  ((UINT8) 0x40)
  129. #define STAT_GROUP_SERVICE_REQ  ((UINT8) 0x80)
  130. #define STAT_SUCC_RESET ((UINT8) 0x00)
  131. #define STAT_SUCC_RESET_ADV  ((UINT8) 0x01) /* reset w. advanced features */
  132. #define STAT_SUCC_RESELECT ((UINT8) 0x10)
  133. #define STAT_SUCC_SELECT ((UINT8) 0x11)
  134. #define STAT_SUCC_SEND_RECV ((UINT8) 0x13)
  135. #define STAT_SUCC_SEND_RECV_ATN ((UINT8) 0x14)
  136. #define STAT_SUCC_XLATE_ADRS ((UINT8) 0x15)
  137. #define STAT_SUCC_SEL_XFER ((UINT8) 0x16)
  138. #define STAT_SUCC_XFER_MCI ((UINT8) 0x1f)
  139. #define STAT_PAUSE_MSG_IN ((UINT8) 0x20)
  140. #define STAT_ABORT_SELX_SAVP    ((UINT8) 0x21) /* SEL/Xfer Aborted; Save Ptrs */
  141. #define STAT_ABORT_SELECT ((UINT8) 0x22) /* SELECT Aborted */
  142. #define STAT_ABORT_RESELECT ((UINT8) 0x22) /* RESELECT Aborted */
  143. #define STAT_ABORT_RECV ((UINT8) 0x23) /* ReCeiVe Aborted; No ATN */
  144. #define STAT_ABORT_SEND ((UINT8) 0x23) /* SeND Aborted; No ATN */
  145. #define STAT_ABORT_RECV_ATN ((UINT8) 0x24) /* ReCeiVe Aborted; w/ATN */
  146. #define STAT_ABORT_SEND_ATN ((UINT8) 0x24) /* SeND Aborted; w/ATN */
  147. #define STAT_ABORT_XFER_MCI ((UINT8) 0x2f) /* Xfer Aborted; new MCI rqst */
  148. #define STAT_TERM_INVALID_CMD ((UINT8) 0x40) /* Invalid Command */
  149. #define STAT_TERM_UNEXP_DISCON ((UINT8) 0x41) /* Unexpected Disconnect */
  150. #define STAT_TERM_TIMEOUT ((UINT8) 0x42) /* Selection Timeout */
  151. #define STAT_TERM_PAR_ERR ((UINT8) 0x43) /* Parity Error; No ATN */
  152. #define STAT_TERM_PAR_ERR_ATN ((UINT8) 0x44) /* Parity Error; w/ATN */
  153. #define STAT_TERM_ADRS_ERR ((UINT8) 0x45) /* Address exceeds disk bounds */
  154. #define STAT_TERM_BAD_RESEL ((UINT8) 0x46) /* Wrong target reselected */
  155. #define STAT_TERM_BAD_BYTE ((UINT8) 0x47) /* Incorrect Message Byte rcvd */
  156. #define STAT_TERM_UNX_PHASE   ((UINT8) 0x4f) /* Unexpected MCI (new phase) */
  157. #define STAT_SERV_REQ_RESELECT ((UINT8) 0x80) /* Reselected */
  158. #define STAT_SERV_REQ_RESEL_ADV ((UINT8) 0x81) /* Reselected, advanced mode */
  159. #define STAT_SERV_REQ_SEL ((UINT8) 0x82) /* Selected; No ATN */
  160. #define STAT_SERV_REQ_SEL_ATN ((UINT8) 0x83) /* Selected; w/ATN */
  161. #define STAT_SERV_REQ_ATN ((UINT8) 0x84) /* ATN asserted */
  162. #define STAT_SERV_REQ_DISCON ((UINT8) 0x85) /* Disconnect */
  163. #define STAT_SERV_REQ_ASSERTED ((UINT8) 0x8f) /* Request -- MCI gives reason */
  164. #define AUX_STAT_REG            (0x00)
  165. #define ADDRESS_REG             (0x00)
  166. #define GENERIC_REG             (0x01)
  167. #define SBIC_REG_OWN_ID ((UINT8) 0x00)
  168. #define SBIC_REG_CONTROL ((UINT8) 0x01)
  169. #define SBIC_REG_TO_PERIOD ((UINT8) 0x02)
  170. #define SBIC_REG_CDB_1 ((UINT8) 0x03)
  171. #define SBIC_REG_CDB_2 ((UINT8) 0x04)
  172. #define SBIC_REG_TOT_CLY_MSB ((UINT8) 0x05)
  173. #define SBIC_REG_TOT_CLY_LSB ((UINT8) 0x06)
  174. #define SBIC_REG_LOG_ADR_MSB ((UINT8) 0x07)
  175. #define SBIC_REG_LOG_ADR_2SB ((UINT8) 0x08)
  176. #define SBIC_REG_LOG_ADR_3SB ((UINT8) 0x09)
  177. #define SBIC_REG_LOG_ADR_LSB ((UINT8) 0x0a)
  178. #define SBIC_REG_SECTOR_NUM ((UINT8) 0x0b)
  179. #define SBIC_REG_HEAD_NUM ((UINT8) 0x0c)
  180. #define SBIC_REG_CYL_NUM_MSB ((UINT8) 0x0d)
  181. #define SBIC_REG_CYL_NUM_LSB ((UINT8) 0x0e)
  182. #define SBIC_REG_TARGET_LUN ((UINT8) 0x0f)
  183. #define SBIC_REG_TARGET_STAT ((UINT8) 0x0f)
  184. #define SBIC_REG_COMMAND_PHASE ((UINT8) 0x10)
  185. #define SBIC_REG_SYNC_XFER ((UINT8) 0x11)
  186. #define SBIC_REG_XFER_COUNT_MSB ((UINT8) 0x12)
  187. #define SBIC_REG_XFER_COUNT_2SB ((UINT8) 0x13)
  188. #define SBIC_REG_XFER_COUNT_LSB ((UINT8) 0x14)
  189. #define SBIC_REG_DEST_ID ((UINT8) 0x15)
  190. #define SBIC_REG_SOURCE_ID ((UINT8) 0x16)
  191. #define SBIC_REG_SCSI_STATUS ((UINT8) 0x17)
  192. #define SBIC_REG_COMMAND ((UINT8) 0x18)
  193. #define SBIC_REG_DATA ((UINT8) 0x19)
  194. #define SBIC_REG_PADa ((UINT8) 0x1a)
  195. #define SBIC_REG_PADb ((UINT8) 0x1b)
  196. #define SBIC_REG_PADc ((UINT8) 0x1c)
  197. #define SBIC_REG_PADd ((UINT8) 0x1d)
  198. #define SBIC_REG_PADe ((UINT8) 0x1e)
  199. #define SBIC_REG_AUX_STATUS ((UINT8) 0x1f)
  200. /* auxiliary status register bits */
  201. #define SBIC_AUX_STAT_INT_PEND   ((UINT8) 0x80) /* interrupt pending bit */
  202. #define SBIC_AUX_STAT_LCI   ((UINT8) 0x40) /* last commmand ignored bit */
  203. #define SBIC_AUX_STAT_BUSY   ((UINT8) 0x20) /* busy bit */
  204. #define SBIC_AUX_STAT_CMD_IN_PROG ((UINT8) 0x10) /* command in progress bit */
  205. #define SBIC_AUX_STAT_PAR_ERROR   ((UINT8) 0x02) /* parity erro bit */
  206. #define SBIC_AUX_STAT_DBUF_READY  ((UINT8) 0x01) /* data buffer ready bit */
  207. /* control register bits */
  208. #define SBIC_CTRL_HALT_SPE ((UINT8) 0x01) /* halt on SCSI parity error */
  209. #define SBIC_CTRL_HALT_ATN ((UINT8) 0x02) /* halt on attention */
  210. #define SBIC_CTRL_INTM_DIS ((UINT8) 0x04) /* intermediate disconnect */
  211. #define SBIC_CTRL_END_DIS_INT ((UINT8) 0x08) /* ending disconnect inter */
  212. #define SBIC_CTRL_HALT_HPE ((UINT8) 0x10) /* halt on host parity error */
  213. #define SBIC_CTRL_DMA_POLLED ((UINT8) 0x00) /* polled i/o; on DMA */
  214. #define SBIC_CTRL_DMA_BURST ((UINT8) 0x20) /* burst mode; demand mode */
  215. #define SBIC_CTRL_DMA_WDBUS ((UINT8) 0x40) /* wd bus mode */
  216. #define SBIC_CTRL_DMA_BYTE ((UINT8) 0x80) /* regular DMA mode */
  217. /* synchronous transfer register bits and constants */
  218. #define SBIC_SYNC_XFER_PERIOD_SHIFT  4
  219. #define SBIC_SYNC_XFER_PARAMS_ASYNC  0x00
  220. /* source ID register bits */
  221. #define SBIC_SRC_ID_RESEL_ENABLE  ((UINT8) 0x80)
  222. /* control register bits */
  223. #define SBIC_CONTROL_DMA_ENABLE   ((UINT8) 0x80)
  224. /* miscellaneous constants */
  225. #define SBIC_MAX_REQ_ACK_OFFSET     4     /* possibly 12 for 33C93A ?      */
  226. #define SBIC_MIN_XFER_PERIOD     3     /* native 33C93 units (2 on 93A) */
  227. #define SBIC_MAX_XFER_PERIOD     8     /* native 33C93 units            */
  228. #define SBIC_MAX_RESET_WAIT     2      /* max # ticks wait for reset */
  229. /* frequency select codes (wd33c93a only) */
  230. #define SBIC_FREQ_SELECT_LOW 0x00 /*  8 - 10 MHz clock */
  231. #define SBIC_FREQ_SELECT_MID 0x40 /* 12 - 15 MHz clock */
  232. #define SBIC_FREQ_SELECT_HIGH 0x80 /*      16 MHz clock */
  233. /* global imported varaibles */
  234. extern SCSI_CTRL *pSysScsiCtrl;
  235. extern SCSIDRV_FUNC_TBL *pWd33c93IfTbl;
  236. /* function declarations */
  237. #if defined(__STDC__) || defined(__cplusplus)
  238. extern void wd33c93IfTblInit ();
  239. IMPORT void wd33c93Scsi2IfInit ();
  240. IMPORT WD_33C93_SCSI_CTRL * wd33c93CtrlCreateScsi2 (UINT8  *sbicBaseAdrs,
  241.           int     regOffset,
  242. UINT    clkPeriod,
  243.           FUNCPTR sysScsiBusReset,
  244. int     sysScsiResetArg,
  245. UINT    sysScsiDmaMaxBytes,
  246. FUNCPTR sysScsiDmaXfer,
  247.           FUNCPTR sysScsiDmaAbort,
  248. int     sysScsiDmaArg);
  249. #ifndef WD33C93_2_LOCAL_FUNCS
  250. IMPORT STATUS wd33c93CtrlInit (WD_33C93_SCSI_CTRL *pSbic,
  251.  int                 scsiCtrlBusId,
  252.  UINT                defaultSelTimeOut);
  253. IMPORT STATUS wd33c93Show (SCSI_CTRL *pScsiCtrl);
  254. IMPORT  void    sbicIntr (WD_33C93_SCSI_CTRL *pSbic);
  255. IMPORT  void    sbicCommand (WD_33C93_SCSI_CTRL *, UINT8);
  256. IMPORT  void    sbicRegWrite (WD_33C93_SCSI_CTRL *, UINT8, UINT8);
  257. IMPORT  STATUS  sbicXferCountSet (WD_33C93_SCSI_CTRL *, UINT);
  258. #endif
  259. #else
  260. extern void wd33c93IfTblInit ();
  261. IMPORT void wd33c93Scsi2IfInit ();
  262. IMPORT WD_33C93_SCSI_CTRL * wd33c93CtrlCreateScsi2 ();
  263. #ifndef WD33C93_2_LOCAL_FUNCS
  264. IMPORT STATUS wd33c93CtrlInit ();
  265. IMPORT STATUS wd33c93Show ();
  266. IMPORT  void    sbicIntr ();
  267. IMPORT  void    sbicCommand ();
  268. IMPORT  void    sbicRegWrite ();
  269. IMPORT  STATUS  sbicXferCountSet ();
  270. #endif
  271. #endif /* __STDC__ */
  272. #endif /* _ASMLANGUAGE */
  273. #ifdef __cplusplus
  274. }
  275. #endif
  276. #endif /* __INCwd33c93_2h */