home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / DASD / OS2SCSI / SCGEN.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-14  |  7.3 KB  |  211 lines

  1. /*DDK*************************************************************************/
  2. /*                                                                           */
  3. /* COPYRIGHT    Copyright (C) 1995 IBM Corporation                           */
  4. /*                                                                           */
  5. /*    The following IBM OS/2 WARP source code is provided to you solely for  */
  6. /*    the purpose of assisting you in your development of OS/2 WARP device   */
  7. /*    drivers. You may use this code in accordance with the IBM License      */
  8. /*    Agreement provided in the IBM Device Driver Source Kit for OS/2. This  */
  9. /*    Copyright statement may not be removed.                                */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12. /*static char *SCCSID = "src/dev/dasd/os2scsi/scgen.h, scsy, ddk_subset, b_bdd.032 93/03/19";*/
  13. /**************************************************************************
  14.  *
  15.  * SOURCE FILE NAME = SCGEN.H
  16.  *
  17.  * DESCRIPTIVE NAME = OS2SCSI.DMD - OS/2 SCSI.SYS Emulation
  18.  *
  19.  *
  20.  *
  21.  * VERSION = V2.0
  22.  *
  23.  * DATE
  24.  *
  25.  * DESCRIPTION : Internal control block structures
  26.  *
  27.  *
  28.  *
  29. */
  30.  
  31.  
  32. /***********************/
  33. /* Max CDB Buffer Size */
  34. /***********************/
  35.  
  36. #define  MAX_CDB_SIZE           sizeof(SCSICDB12)
  37.  
  38.  
  39. /*********************************/
  40. /* Unit Control Block Definition */
  41. /*********************************/
  42.  
  43. #define MAX_TIMEOUT_ENTRIES     4
  44.  
  45. typedef struct _QELE  QELE, near *NPQELE, far *PQELE;
  46.  
  47. typedef struct _QELE
  48. {
  49.   NPQELE        Next;
  50.   ULONG         pRP;
  51.  
  52. } QELE, near *NPQELE, far *PQELE;
  53.  
  54.  
  55. /*-------------------------------*/
  56. /* Unit Control Block Definition */
  57. /*-------------------------------*/
  58.  
  59. typedef struct _UnitControlBlock
  60. {
  61.   USHORT                Index;
  62.   UNITINFO              UnitInfo;               /* Additional Driver Info     */
  63.   USHORT                UnitStatus;             /* Unit Status                */
  64.   USHORT                IntUnitFlags;           /* Internal unit flags        */
  65.  
  66.   void                 (far *AdapterDriverEP)();/* ADD Entry Point            */
  67.  
  68.   USHORT                DeviceKeyIndex;
  69.   BYTE                  SCBArcCardLevel;
  70.   BYTE                  Reserved_1;
  71.  
  72.   ULONG                 Timeout;                /* Timeout value              */
  73.  
  74.   UCHAR                 hLockDataP[12];         /* lock handle of data pkt    */
  75.   ULONG                 ppDataPkt;              /* phys   addr for data pkt   */
  76.   ULONG                 lnDataPkt;              /* linear addr for data pkt   */
  77.  
  78.   USHORT                WaitReqCnt;             /* Count of waiting req pkts  */
  79.   USHORT                OtherReqCnt;            /* Count of waiting req pkts  */
  80.  
  81.   NPQELE                TimeOutQHead;
  82.   NPQELE                TimeOutQFoot;
  83.   NPQELE                TimeOutQFree;
  84.   QELE                  TimeOutQ[MAX_TIMEOUT_ENTRIES];
  85.  
  86.   PSCBHDR               pCurrentSCBH;           /* Current SCB chained        */
  87.   ULONG                 ppCurrentSCB;           /* Current SCB phys pointer   */
  88.  
  89.   IORBH                 XferSCB_IORB;
  90.   BYTE                  XferSCB_Reserved[MAX_IORB_SIZE-sizeof(IORBH)];
  91.   SCSI_STATUS_BLOCK     XferSCB_SSB;
  92.   BYTE                  Align_1;
  93.  
  94.   IORBH                 Other_IORB;
  95.   BYTE                  Other_Reserved[MAX_IORB_SIZE-sizeof(IORBH)];
  96.   SCSI_STATUS_BLOCK     Other_SSB;
  97.   BYTE                  Align_2;
  98.  
  99.   BYTE                  CDB_Buff[MAX_CDB_SIZE];
  100.  
  101.  
  102.   USHORT                SenseSel;
  103.   USHORT                lnSenseData;
  104.   PSCSI_REQSENSE_DATA   pSenseData;
  105.  
  106.   USHORT                LastStatus;             /* status       - last cmd    */
  107.   USHORT                LastErrCode;            /* error code   - last cmd    */
  108.   SCSI_STATUS_BLOCK     LastSSB;                /* status block - last cmd    */
  109.   BYTE                  Align_3;
  110.   ULONG                 ppLastSCB;              /* SCB o        - last cmd    */
  111.  
  112. } UNITCB, near *NPUCB;
  113.  
  114.  
  115. /*--------------------------------*/
  116. /* Internal Unit Flags Definition */
  117. /*--------------------------------*/
  118.  
  119. #define IUF_ALLOCATED           0x0001         /* Device already allocated    */
  120. #define IUF_IBM_SCB             0x0002         /* Supports IBM SCB commands   */
  121.  
  122. #define IUF_IORB_BUSY           0x8000         /* Xfer  SCB IORB buffer in use*/
  123. #define IUF_OTHERIORB_BUSY      0x4000         /* Other IORB     buffer in use*/
  124. #define IUF_REQ_FLUSH           0x2000         /* Q'd reqs should be flushed  */
  125. #define IUF_REQ_ABORT           0x1000         /* Abort in progress           */
  126.  
  127.  
  128. /**************************/
  129. /* Selectors for S/G List */
  130. /**************************/
  131.  
  132. typedef struct _SELARRAY
  133. {
  134.   SEL           GDTSel[];
  135. } SELARRAY, near *NPSELARRAY;
  136.  
  137. /********************/
  138. /* Macro Definition */
  139. /********************/
  140.  
  141. #define  CLEAR_IORB_BUFF  for(i=0; i<MAX_IORB_SIZE; i++) *((NPBYTE)npIORB+i)=0;  \
  142.                           ((NPIORBH)npIORB)->RequestControl = IORB_DISABLE_RETRY;\
  143.                           *(NPUCB *)((NPIORBH)npIORB->DMWorkSpace) = npUCB;
  144. #define  CLEAR_CDB_BUFF  for(i=0; i<MAX_CDB_SIZE; i++) *((NPBYTE)npCDB+i)=0
  145. #define  CLEAR_SSB_BUFF  for(i=0; i<sizeof(SCSI_STATUS_BLOCK); i++) *((NPBYTE)npSSB+i)=0
  146.  
  147. #define  DISABLE _asm {cli}
  148. #define  ENABLE  _asm {sti}
  149.  
  150. /*****************************/
  151. /* Return code from WaitIORB */
  152. /*****************************/
  153.  
  154. #define  REQ_FLUSHED     0xFFFF           /* Request was flushed              */
  155. #define  REQ_INTERRUPTED 0xFFFE           /* Request was interrupted (Ctrl-C) */
  156.  
  157. /***********************************************/
  158. /* Return code from Get Command Cmplete Status */
  159. /***********************************************/
  160.  
  161. #define  REQ_CMDCMPST 0x8000           /* Command was SCBCMDSTATUS            */
  162.                                        /* after call DistributeCommand        */
  163. #define  MAX_REQ_WAIT          (1000l)
  164.  
  165. /********************************/
  166. /* Allocate/Deallocate Selector */
  167. /********************************/
  168.  
  169. #define MAX_GDT_SEL_STACK            4
  170. #define R0_STACK_SEL            0x0030
  171. #define LDT_SEL                 0x0004
  172.  
  173. #define IDC_ENTRY               0
  174. #define STRAT1_ENTRY            1
  175.  
  176.  
  177. /************/
  178. /* (SCSI.H) */
  179. /************/
  180.  
  181. #define SCSI_FORMAT_UNIT        0x04
  182. #define DEFECT_BLOCK_FORMAT     0
  183. #define DEFAULT_TIMEOUT         60      /* 60 second default timeout          */
  184.  
  185. /***********/
  186. /* (SCB.H) */
  187. /***********/
  188.  
  189. #define RD_SCB                  SCBEfRD
  190. #define ES_SCB                  SCBEfES
  191. #define PT_SCB                  SCBEfPT
  192. #define SCB_ND_NS              (SCBCfND | SCBCfNS)
  193.  
  194. /**********/
  195. /* IORB.H */
  196. /**********/
  197.  
  198. #define IORB_ERR_MASK           0x7F00
  199.  
  200. /*--------------------------------------------------------------*/
  201. /* Init data allocated at the end of the data segment has the   */
  202. /* following structure:                                         */
  203. /*--------------------------------------------------------------*/
  204.  
  205. typedef struct _INITDATA
  206. {
  207.    UCHAR           ScratchBuffer[1024*4];      /* Scratch buffer              */
  208.    UCHAR           ScratchIORB[MAX_IORB_SIZE]; /* IORB used during init       */
  209. } INITDATA, NEAR *NPINITDATA;
  210.  
  211.