home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / DASD / CDROM / ATAPI / ATAPITYP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-14  |  14.6 KB  |  440 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. /**************************************************************************
  13.  *
  14.  * SOURCE FILE NAME = ATAPITYP.H
  15.  *
  16.  * DESCRIPTION : Locally defined structures for this driver.
  17.  *
  18.  *
  19.  *
  20.  * VERSION = 1.0
  21.  *
  22.  * DATE
  23.  *
  24.  * DESCRIPTION :
  25.  *
  26.  * Purpose:
  27.  *
  28.  *
  29. */
  30.  
  31. typedef struct _ACB  NEAR *NPACB, FAR *PACB;
  32. typedef struct _UCB  NEAR *NPUCB;
  33. typedef struct _ATBL NEAR *NPATBL;
  34. typedef struct _UTBL NEAR *NPUTBL;
  35.  
  36. /* Works Space Flags */
  37. #define       WSF_PROC_BLOCK      0x01
  38.  
  39. typedef struct _Sense_Data
  40. {
  41.         USHORT  error_code                  : 7;
  42.         USHORT  valid                       : 1;
  43.         USHORT  segment_number              : 8;
  44.  
  45.         UCHAR   sense_key                   : 4;
  46.         UCHAR   reserved_1                  : 1;
  47.         UCHAR   ILI                         : 1;
  48.         UCHAR   EOM                         : 1;
  49.         UCHAR   filemark                    : 1;
  50.  
  51.         ULONG   information;
  52.         UCHAR   additional_sense_length;
  53.         UCHAR   command_specific_info[4];
  54.         UCHAR   additional_sense_code;
  55.         UCHAR   additional_sense_code_qualifier;
  56.         UCHAR   FRU_Code;
  57.         UCHAR   sensekey_specific[3];
  58. } SENSE_DATA, NEAR *NPSENSE_DATA, FAR *PSENSE_DATA;
  59.  
  60. typedef struct _GENCONFIGWORD
  61. {
  62. /*                       Bit Field(s)  ───┐   ┌─ Description                 */
  63. /*                                      ┌─┴─┐ │                              */
  64. /*                                      │   │ │                              */
  65.  
  66.    unsigned int CmdPktSize   : 2;    /*  0- 1 Command Packet Size            */
  67.    unsigned int              : 3;    /*  2- 4 Reserved                       */
  68.    unsigned int CmdDRQType   : 2;    /*  5- 6 CMD DRQ Type                   */
  69.    unsigned int Removable    : 1;    /*   7   Removable                      */
  70.    unsigned int DeviceType   : 5;    /*  8-12 Device Type                    */
  71.    unsigned int              : 1;    /*  13   Reserved                       */
  72.    unsigned int ProtocolType : 2;    /* 14-15 Protocol Type                  */
  73.  
  74. }GENCONFIGWORD;
  75.  
  76. /* defines for Identify Drive Data - Capabilities Word */
  77. #define IDD_VendorUniqueMask  0x00FF
  78. #define IDD_DMASupported      0x0100
  79. #define IDD_LBASupported      0x0200
  80. #define IDD_IORDYDisablable   0x0400
  81. #define IDD_IORDYSupported    0x0800
  82.  
  83. typedef struct _IDENTIFYDATA IDENTIFYDATA, NEAR *NPIDENTIFYDATA,
  84.                                            FAR *PIDENTIFYDATA;
  85.  
  86. typedef struct _IDENTIFYDATA
  87. {
  88.  
  89. /*                    word number in structure  ─┐ ┌─ Description
  90.                                                  │ │                         */
  91.  
  92.    GENCONFIGWORD     GenConfig;              /*  0 General configuration     */
  93.    USHORT            Reserved1[9];           /*  1 Not Used                  */
  94.    CHAR              Serial[20];             /* 10 Serial Number             */
  95.    USHORT            BufferType;             /* 20 Buffer Type               */
  96.    USHORT            BufferSize;             /* 21 Buffer Size               */
  97.    USHORT            Reserved2;              /* 22 Not Used                  */
  98.    CHAR              Firmware[8];            /* 23 Firmware Revision         */
  99.    CHAR              ModelNum[40];           /* 27 Model Number              */
  100.    USHORT            Reserved3[2];           /* 47 Not Used                  */
  101.    USHORT            Capabilities;           /* 49 Capabilities              */
  102.    USHORT            Reserved4;              /* 50 Not Used                  */
  103.    USHORT            PIOCycleTiming;         /* 51 PIO Cycle Timing          */
  104.    USHORT            DMACycleTiming;         /* 52 DMA Cycle Timing          */
  105.    USHORT            ValidityofOtherWords;   /* 53 Validity of words 54-58   */
  106.                                              /*                  and 64-70   */
  107.    USHORT            CurrentCylHdSec[3];     /* 54 Current                   */
  108.                                              /*    Cylinder/Heads/Sectors    */
  109.    USHORT            CurrentCapacity[2];     /* 57 Current Capacity          */
  110.    USHORT            Reserved5[3];           /* 59 Not Used                  */
  111.    USHORT            SingleDMAmode;          /* 62 Single DMA Mode           */
  112.    USHORT            MultiwordDMAmode;       /* 63 Multiword DMA Mode        */
  113.    USHORT            EnhancedPIOmode;        /* 64 Enhanced PIO Mode         */
  114.    USHORT            BlindPIOminCycTime;     /* 65 Blind PIO Minimum Cycle   */
  115.                                              /*    Time                      */
  116.    USHORT       RecMultiWordDMAxferCycleTime;/* 66 Recommended Multi Word    */
  117.                                              /*    DMA Transfer Cycle Time   */
  118.    USHORT      MinPIOxferCyclewithoutFlowCon;/* 67 Minimum PIO Transfer      */
  119.                                              /*    Cycle Time without Flow   */
  120.                                              /*    Control                   */
  121.    USHORT    MinPIOxferCyclewithIORDYFlowCon;/* 68 Minimum PIO Transfer      */
  122.                                              /*    Cycle Time with IORDY     */
  123.                                              /*    Flow Control              */
  124.    USHORT            Reserved6[256-69];      /* 69 Not Used                  */
  125. } IDENTIFYDATA;
  126.  
  127. /*-------------------------------*/
  128. /* Unit Control Block            */
  129. /* ------------------            */
  130. /*                               */
  131. /* One per drive on controller.  */
  132. /*                               */
  133. /*-------------------------------*/
  134.  
  135. typedef struct _UCB
  136. {
  137.   /*-----------------------------------*/
  138.   /* Associated Control Block Pointers */
  139.   /*-----------------------------------*/
  140.   NPACB            npACB;
  141.   USHORT           Flags;
  142.   USHORT           ReqFlags;
  143.  
  144.   PUNITINFO     pUnitInfo;
  145.  
  146.   /*--------------------*/
  147.   /* Unit Number (0/1)  */
  148.   /*--------------------*/
  149.   USHORT           UnitId;
  150.  
  151.   USHORT           Capabilities;
  152.   USHORT           CmdPacketLength;
  153.  
  154.   UCHAR            RequestSenseBuf[sizeof(SENSE_DATA)];
  155.  
  156. } UCB;
  157.  
  158. /* Flags definitions */
  159. #define UCBF_ALLOCATED      0x0001
  160. #define UCBF_READY          0x0002
  161. #define UCBF_DIAG_FAILED    0x0004
  162. #define UCBF_SMSENABLED     0x0008
  163. #define UCBF_MULTIPLEMODE   0x0010
  164. #define UCBF_LBAMODE        0x0020
  165. #define UCBF_IDENTIFYFAIL   0x0040
  166. #define UCBF_NODASDSUPPORT  0x0080
  167.  
  168. /* ReqFlags definitions */
  169. #define UCBR_RECAL          0x8000
  170. #define UCBR_SETPARAM       0x4000
  171. #define UCBR_IDENTIFY       0x2000
  172. #define UCBR_RESET          0x1000
  173.  
  174. /* Unit Capabilities */
  175. #define UCBC_ATA                   0x0001
  176. #define UCBC_ATAPI                 0x0002
  177. #define UCBC_DIRECT_ACCESS_DEVICE  0x0004
  178. #define UCBC_CDROM_DEVICE          0x0008
  179. #define UCBC_OPTICAL_MEMORY_DEVICE 0x0010
  180. #define UCBC_MICROPROCESSOR_DRQ    0x0020
  181. #define UCBC_INTERRUPT_DRQ         0x0040
  182. #define UCBC_ACCELERATED_DRQ       0X0080
  183. #define UCBC_DMA                   0x0100
  184. #define UCBC_LBA                   0x0200
  185. #define UCBC_IORDY                 0x0400
  186. #define UCBC_IORDY_DISABLE         0X0800
  187. #define UCBC_SPEC_REV_17B          0x1000
  188. #define UCBC_IRQ_ON_ATA_COMPLETE   0x8000
  189.  
  190. typedef struct _CMDIO
  191. {
  192.   ADD_XFER_IO   IOSGPtrs;
  193.   USHORT        cXferBytesRemain;
  194.   USHORT        cXferBytesComplete;
  195.   UCHAR         ATAPIPkt[16];
  196. } CMDIO, NEAR *NPCMDIO;
  197.  
  198.  
  199. /*-------------------------------*/
  200. /* Adapter Control Block         */
  201. /* ---------------------         */
  202. /*                               */
  203. /* One per controller.           */
  204. /*                               */
  205. /*-------------------------------*/
  206.  
  207.  
  208. #define FI_MAX_REGS     12
  209.  
  210. typedef struct _ACB
  211. {
  212.   /*--------------------------------------*/
  213.   /* IORB Queue for units on this adapter */
  214.   /*--------------------------------------*/
  215.   PIORBH        pHeadIORB;
  216.   PIORBH        pFootIORB;
  217.   PIORBH        pIORB;
  218.  
  219.   /*---------------------------------------------------*/
  220.   /* Controller Register addresses/contents, IRQ level */
  221.   /*---------------------------------------------------*/
  222.   USHORT        IOPorts[FI_MAX_REGS];
  223.   UCHAR         IORegs[FI_MAX_REGS];
  224.   USHORT        IOPendingMask;
  225.  
  226.   USHORT        IRQLevel;
  227.   USHORT        SpuriousIRQ;
  228.   USHORT        (FAR *IRQHandler)();
  229.  
  230.   /*-----------------------*/
  231.   /* Inner State Variables */
  232.   /*-----------------------*/
  233.   USHORT        ISMUseCount;
  234.   USHORT        ISMState;
  235.   USHORT        ISMFlags;
  236.  
  237.   VOID          (FAR *ISMDoneReturn)(NPACB npACB);
  238.  
  239.   /*-----------------------*/
  240.   /* Outer State Variables */
  241.   /*-----------------------*/
  242.   USHORT        OSMUseCount;
  243.   USHORT        OSMState;
  244.   USHORT        OSMFlags;
  245.   USHORT        OSMReqFlags;
  246.  
  247.   USHORT        ReqFlags;
  248.  
  249.   VOID          (FAR *OSMDoneReturn)(NPACB npACB);
  250.  
  251.   /*--------------------------------*/
  252.   /* Current operation variables    */
  253.   /*--------------------------------*/
  254.   USHORT        IORBStatus;
  255.   USHORT        IORBError;
  256.   NPCMDIO       npCmdIO;
  257.   CMDIO         ExternalCmd;
  258.   CMDIO         InternalCmd;
  259.  
  260.   /*--------------------------------*/
  261.   /* Timer Flags/Values             */
  262.   /*--------------------------------*/
  263.  
  264.   USHORT        TimerFlags;
  265.   ULONG         TimeOut;
  266.  
  267.   /*----------------------*/
  268.   /* Timer Loop Counters  */
  269.   /*----------------------*/
  270.   ULONG         DelayedResetInterval;
  271.   ULONG         DelayedResetCtr;
  272.   ULONG         DelayedRetryInterval;
  273.   ULONG         IRQTimeOut;
  274.  
  275.   /*--------------------------------------------------*/
  276.   /* Timer Handles                                    */
  277.   /*                                                  */
  278.   /* (Also update TIMERS_PER_ACB when adding timers)  */
  279.   /*--------------------------------------------------*/
  280.   ULONG         IRQTimeOutHandle;
  281. //  ULONG         RetryTimerHandle;
  282. //  ULONG         ResetTimerHandle;
  283.  
  284.   /*-------------------------------------------------*/
  285.   /* Unit Control Blocks - Unit specific information */
  286.   /*-------------------------------------------------*/
  287.   USHORT        cUnits;
  288.   UCB           UnitCB[MAX_UNITS];
  289.   USHORT        UnitId;
  290.   NPUCB         npUCB;
  291.   USHORT        cResetRequests;
  292.  
  293.   IORB_DEVICE_CONTROL IORB;
  294.  
  295.   VOID          (FAR *SharedDriverEP)();
  296.   USHORT        SharedDriverUnitHandle;
  297.   USHORT        ResourceFlags;
  298.   VOID          (FAR *CtxHookRoutine)(NPACB npACB);
  299.   ULONG         CtxHookHandle;
  300.   USHORT        iorbinuse;
  301.   USHORT        suspended;
  302.  
  303. } ACB;
  304.  
  305.  
  306. /* ACB->ISMFlags values */
  307.  
  308. #define ACBIF_COMPLETION_STATUS_ONLY 0x0001
  309. #define ACBIF_INTERRUPT              0x0002
  310. #define ACBIF_WAITSTATE              0x0004
  311. #define ACBIF_SINGLEIO               0x0008
  312. #define ACBIF_MULTIPLEIO             0x0010
  313. #define ACBIF_ODD_BYTE_XFER          0x0020
  314. #define ACBIF_ATA_OPERATION          0x0040
  315.  
  316. /* ACB->OSMFlags values */
  317.  
  318. #define ACBOF_WAITSTATE              0x0001
  319. #define ACBOF_SM_ACTIVE              0x0002
  320. #define ACBOF_PS2IDEPORT             0x0004
  321. #define ACBOF_DISABLERESET           0x0008
  322. #define ACBOF_SM_IDLE                0x0010
  323. #define ACBOF_RESET_ACTIVE           0x0020
  324. #define ACBOF_SENSE_DATA_ACTIVE      0x0040
  325.  
  326. /* ACB->ReqFlags values */
  327.  
  328. #define ACBR_RESET                   0x0001
  329. #define ACBR_SENSE_DATA              0X0002
  330. #define ACBR_CONFIGURE_ACB           0x0003
  331.  
  332. /* ACB->OSMState values */
  333.  
  334. #define ACBOS_START_IORB         1
  335. #define ACBOS_ISM_COMPLETE       2
  336. #define ACBOS_COMPLETE_IORB      3
  337. #define ACBOS_RESUME_COMPLETE    4
  338. #define ACBOS_SUSPEND_COMPLETE   5
  339.  
  340. /* ACB->ISMState values */
  341.  
  342. #define ACBIS_START_STATE              1
  343. #define ACBIS_INTERRUPT_STATE          2
  344. #define ACBIS_COMPLETE_STATE           3
  345. #define ACBIS_WRITE_ATAPI_PACKET_STATE 4
  346.  
  347. /* ACB->TimerFlags */
  348. #define ACBT_BUSY       0x0001
  349. #define ACBT_DRQ        0x0002
  350. #define ACBT_IRQ        0x0004
  351. #define ACBT_READY      0x0008
  352. #define ACBT_INTERRUPT  0x0010
  353.  
  354. /* ACB->ResourceFlags */
  355. #define ACBRF_SHARED     0x0001
  356. #define ACBRF_CURR_OWNER 0x0002
  357.  
  358. /*-------------------------------*/
  359. /* Unit Table                    */
  360. /* ----------                    */
  361. /*                               */
  362. /* One per unit (drive)          */
  363. /*                               */
  364. /*-------------------------------*/
  365.  
  366. typedef struct _UTBL
  367. {
  368.   USHORT        Flags;
  369.   USHORT        Status;
  370.   USHORT        DriveId;
  371.  
  372.   USHORT        TimeOut;
  373. //  IDENTIFYDATA  IDdata;
  374.  
  375.   UCHAR         ModelNum[41];
  376.   UCHAR         Firmware[9];
  377.   UCHAR         Serial[21];
  378.   UCHAR         Reserved;
  379.  
  380. } UTBL;
  381.  
  382.  
  383. #define UTS_OK                  0
  384. #define UTS_NOT_PRESENT         1
  385. //#define UTS_READ_0_FAILED       2
  386.  
  387.  
  388. /*-------------------------------*/
  389. /* Adapter Table                 */
  390. /* -------------                 */
  391. /*                               */
  392. /* One per controller.           */
  393. /*                               */
  394. /*-------------------------------*/
  395.  
  396. typedef struct _ATBL
  397. {
  398.   USHORT        BasePort;
  399.   USHORT        IRQLevel;
  400.   USHORT        (FAR *IRQHandler)();
  401.  
  402.   USHORT        Flags;
  403.   USHORT        Status;
  404.  
  405.   NPACB         npACB;
  406.  
  407.   USHORT        cUnits;
  408.   UTBL          Unit[MAX_UNITS];
  409.  
  410. } ATBL;
  411.  
  412.  
  413. #define ATBF_DISABLED             0x0001
  414. #define ATBF_IRQINSTALLED         0x0002
  415. #define ATBF_DISABLERESET         0x0004
  416. #define ATBF_ATAPI_PRESENT        0x0008
  417. #define ATBF_SHARED_ADAPTER       0x0010
  418.  
  419. #define ATS_OK                  0
  420. #define ATS_NOT_PRESENT         1
  421. #define ATS_SKIPPED             2
  422. #define ATS_SET_IRQ_FAILED      3
  423.  
  424.  
  425. /*-------------------------------*/
  426. /* ACB Pointer Block             */
  427. /* -----------------             */
  428. /*                               */
  429. /*                               */
  430. /*                               */
  431. /*-------------------------------*/
  432.  
  433. typedef struct _ACBPTRS
  434. {
  435.   NPACB         npACB;
  436.   USHORT        (FAR *IRQHandler)();
  437.  
  438. } ACBPTRS;
  439.  
  440.