home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cdrom.zip / DDK / BASE / SRC / DEV / DASD / CDROM / ATAPI / atapityp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-10  |  19.1 KB  |  542 lines

  1. /* SCCSID = %W% %E% */
  2. /**************************************************************************
  3.  *
  4.  * SOURCE FILE NAME = ATAPITYP.H
  5.  *
  6.  * DESCRIPTION : Locally defined structures for this driver.
  7.  *
  8.  *
  9.  * Copyright : COPYRIGHT IBM CORPORATION, 1991, 1992
  10.  *             LICENSED MATERIAL - PROGRAM PROPERTY OF IBM
  11.  *             REFER TO COPYRIGHT INSTRUCTION FORM#G120-2083
  12.  *             RESTRICTED MATERIALS OF IBM
  13.  *             IBM CONFIDENTIAL
  14.  *
  15.  * VERSION = 1.0
  16.  *
  17.  * DATE
  18.  *
  19.  * DESCRIPTION :
  20.  *
  21.  * Purpose:
  22.  *
  23.  *
  24.  * CHANGE ACTIVITY =
  25.  *   DATE      FLAG        DEFECT  CHANGE DESCRIPTION
  26.  *   --------  ----------  ------  --------------------------------------
  27.  *   08/22/94  V@93531     93531   1) Suspend/Resume logic passes IRQ handler
  28.  *                                 address. 2) DRQ polling is not valid while
  29.  *                                 BSY bit set.
  30.  *   04/05/96  @V151168            Merged warm dock/swap code.
  31.  *   05/24/96  @V155162            Thinkpad docking/swapping IDE update.
  32.  *   04/26/98  @V195083            Added Panasonic PD support.
  33.  ****************************************************************************/
  34. /*
  35.  * Edit History for Feature # 149178:
  36.  *
  37.  * Edit    Date    Comments
  38.  * ----- --------  -------------------------------------------------------------
  39.  * [001] 12-22-95  Added definitions for UCB flags to indicate Bus Master DMA is
  40.  *                 supported and active for a specific unit. /jlh
  41.  *
  42.  */
  43.  
  44. typedef struct _ACB  NEAR *NPACB, FAR *PACB;
  45. typedef struct _UCB  NEAR *NPUCB;
  46. typedef struct _ATBL NEAR *NPATBL;
  47. typedef struct _UTBL NEAR *NPUTBL;
  48.  
  49. /* Works Space Flags */
  50. #define       WSF_PROC_BLOCK      0x01
  51.  
  52. typedef struct _Sense_Data
  53. {
  54.         USHORT  error_code                  : 7;
  55.         USHORT  valid                       : 1;
  56.         USHORT  segment_number              : 8;
  57.  
  58.         UCHAR   sense_key                   : 4;
  59.         UCHAR   reserved_1                  : 1;
  60.         UCHAR   ILI                         : 1;
  61.         UCHAR   EOM                         : 1;
  62.         UCHAR   filemark                    : 1;
  63.  
  64.         ULONG   information;
  65.         UCHAR   additional_sense_length;
  66.         UCHAR   command_specific_info[4];
  67.         UCHAR   additional_sense_code;
  68.         UCHAR   additional_sense_code_qualifier;
  69.         UCHAR   FRU_Code;
  70.         UCHAR   sensekey_specific[3];
  71. } SENSE_DATA, NEAR *NPSENSE_DATA, FAR *PSENSE_DATA;
  72.  
  73. typedef struct _GENCONFIGWORD
  74. {
  75. /*                       Bit Field(s)  ───┐   ┌─ Description                 */
  76. /*                                      ┌─┴─┐ │                              */
  77. /*                                      │   │ │                              */
  78.  
  79.    unsigned int CmdPktSize   : 2;    /*  0- 1 Command Packet Size            */
  80.    unsigned int              : 3;    /*  2- 4 Reserved                       */
  81.    unsigned int CmdDRQType   : 2;    /*  5- 6 CMD DRQ Type                   */
  82.    unsigned int Removable    : 1;    /*   7   Removable                      */
  83.    unsigned int DeviceType   : 5;    /*  8-12 Device Type                    */
  84.    unsigned int              : 1;    /*  13   Reserved                       */
  85.    unsigned int ProtocolType : 2;    /* 14-15 Protocol Type                  */
  86.  
  87. }GENCONFIGWORD;
  88.  
  89. /* defines for Identify Drive Data - Capabilities Word */
  90. #define IDD_VendorUniqueMask  0x00FF
  91. #define IDD_DMASupported      0x0100
  92. #define IDD_LBASupported      0x0200
  93. #define IDD_IORDYDisablable   0x0400
  94. #define IDD_IORDYSupported    0x0800
  95.  
  96. typedef struct _IDENTIFYDATA IDENTIFYDATA, NEAR *NPIDENTIFYDATA,
  97.                                            FAR *PIDENTIFYDATA;
  98.  
  99. typedef struct _IDENTIFYDATA
  100. {
  101.  
  102. /*                    word number in structure  ─┐ ┌─ Description
  103.                                                  │ │                         */
  104.  
  105.    GENCONFIGWORD     GenConfig;              /*  0 General configuration     */
  106.    USHORT            Reserved1[9];           /*  1 Not Used                  */
  107.    CHAR              Serial[20];             /* 10 Serial Number             */
  108.    USHORT            BufferType;             /* 20 Buffer Type               */
  109.    USHORT            BufferSize;             /* 21 Buffer Size               */
  110.    USHORT            Reserved2;              /* 22 Not Used                  */
  111.    CHAR              Firmware[8];            /* 23 Firmware Revision         */
  112.    CHAR              ModelNum[40];           /* 27 Model Number              */
  113.    USHORT            Reserved3[2];           /* 47 Not Used                  */
  114.    USHORT            Capabilities;           /* 49 Capabilities              */
  115.    USHORT            Reserved4;              /* 50 Not Used                  */
  116.    USHORT            PIOCycleTiming;         /* 51 PIO Cycle Timing          */
  117.    USHORT            DMACycleTiming;         /* 52 DMA Cycle Timing          */
  118.    USHORT            ValidityofOtherWords;   /* 53 Validity of words 54-58   */
  119.                                              /*                  and 64-70   */
  120.    USHORT            CurrentCylHdSec[3];     /* 54 Current                   */
  121.                                              /*    Cylinder/Heads/Sectors    */
  122.    USHORT            CurrentCapacity[2];     /* 57 Current Capacity          */
  123.    USHORT            Reserved5[3];           /* 59 Not Used                  */
  124.    USHORT            SingleDMAmode;          /* 62 Single DMA Mode           */
  125.    USHORT            MultiwordDMAmode;       /* 63 Multiword DMA Mode        */
  126.    USHORT            EnhancedPIOmode;        /* 64 Enhanced PIO Mode         */
  127.    USHORT            BlindPIOminCycTime;     /* 65 Blind PIO Minimum Cycle   */
  128.                                              /*    Time                      */
  129.    USHORT       RecMultiWordDMAxferCycleTime;/* 66 Recommended Multi Word    */
  130.                                              /*    DMA Transfer Cycle Time   */
  131.    USHORT      MinPIOxferCyclewithoutFlowCon;/* 67 Minimum PIO Transfer      */
  132.                                              /*    Cycle Time without Flow   */
  133.                                              /*    Control                   */
  134.    USHORT    MinPIOxferCyclewithIORDYFlowCon;/* 68 Minimum PIO Transfer      */
  135.                                              /*    Cycle Time with IORDY     */
  136.                                              /*    Flow Control              */
  137.    USHORT            Reserved6[256-69];      /* 69 Not Used                  */
  138. } IDENTIFYDATA;
  139.  
  140. /* Begin [001] Physical Region Descriptor for SFF-8038i Bus Master DMA controllers */
  141.  
  142. /*----------------------------------*/
  143. /* Physical Region Descriptor       */
  144. /* --------------------------       */
  145. /*                                  */
  146. /* One per physical memory region.  */
  147. /*                                  */
  148. /*----------------------------------*/
  149.  
  150. typedef struct _PRD
  151. {
  152.   ULONG     MR_PhysicalBaseAddress;           /* memory region's physical base address */
  153.   ULONG     ByteCountAndEOT;                  /* byte count and End of Table flag */
  154. } PRD;
  155.  
  156. #define PRD_EOT_FLAG    0x80000000L           /* End of table indicator */
  157.  
  158. typedef struct _PRD  NEAR *NPPRD, FAR *PPRD;  /* typedef for pointers to PRD */
  159.  
  160. /* End [001] */
  161.  
  162. /*-------------------------------*/
  163. /* Unit Control Block            */
  164. /* ------------------            */
  165. /*                               */
  166. /* One per drive on controller.  */
  167. /*                               */
  168. /*-------------------------------*/
  169.  
  170. typedef struct _UCB
  171. {
  172.   /*-----------------------------------*/
  173.   /* Associated Control Block Pointers */
  174.   /*-----------------------------------*/
  175.   NPACB            npACB;
  176.   USHORT           Flags;
  177.   USHORT           ReqFlags;
  178.  
  179.   PUNITINFO     pUnitInfo;
  180.  
  181.   /*--------------------*/
  182.   /* Unit Number (0/1)  */
  183.   /*--------------------*/
  184.   USHORT           UnitId;
  185.  
  186.   USHORT           Capabilities;
  187.   USHORT           CmdPacketLength;
  188.  
  189.   UCHAR            RequestSenseBuf[sizeof(SENSE_DATA)];
  190.  
  191. } UCB;
  192.  
  193. /* Flags definitions */
  194. #define UCBF_ALLOCATED      0x0001
  195. #define UCBF_READY          0x0002
  196. #define UCBF_DIAG_FAILED    0x0004
  197. #define UCBF_SMSENABLED     0x0008
  198. #define UCBF_MULTIPLEMODE   0x0010
  199. #define UCBF_LBAMODE        0x0020
  200. #define UCBF_IDENTIFYFAIL   0x0040
  201. #define UCBF_NODASDSUPPORT  0x0080
  202. #define UCBF_BM_DMA         0x0100                                  /* [001] */
  203. /* For device swaping support */                                    /*@V151168*/
  204. #define UCBF_FORCE          0x0200                                  /*@V151168*/
  205. #define UCBF_NOTPRESENT     0x0400                                  /*@V151168*/
  206. #define UCBF_CONFIGCHANGE   0x0800                                  /*@V151168*/
  207. #define UCBF_MEDIACHANGED   0x1000                                  /*@V155162*/
  208.  
  209. /* ReqFlags definitions */
  210. #define UCBR_RECAL          0x8000
  211. #define UCBR_SETPARAM       0x4000
  212. #define UCBR_IDENTIFY       0x2000
  213. #define UCBR_RESET          0x1000
  214.  
  215. /* Unit Capabilities */
  216. #define UCBC_ATA                   0x0001
  217. #define UCBC_ATAPI                 0x0002
  218. #define UCBC_DIRECT_ACCESS_DEVICE  0x0004
  219. #define UCBC_CDROM_DEVICE          0x0008
  220. #define UCBC_OPTICAL_MEMORY_DEVICE 0x0010
  221. #define UCBC_MICROPROCESSOR_DRQ    0x0020
  222. #define UCBC_INTERRUPT_DRQ         0x0040
  223. #define UCBC_ACCELERATED_DRQ       0X0080
  224. #define UCBC_DMA                   0x0100
  225. #define UCBC_LBA                   0x0200
  226. #define UCBC_IORDY                 0x0400
  227. #define UCBC_IORDY_DISABLE         0X0800
  228. #define UCBC_SPEC_REV_17B          0x1000
  229. #define UCBC_IRQ_ON_ATA_COMPLETE   0x8000
  230.  
  231. typedef struct _CMDIO
  232. {
  233.   ADD_XFER_IO   IOSGPtrs;
  234.   USHORT        cXferBytesRemain;
  235.   USHORT        cXferBytesComplete;
  236.   UCHAR         ATAPIPkt[16];
  237. } CMDIO, NEAR *NPCMDIO;
  238.  
  239.  
  240. /*-------------------------------*/
  241. /* Adapter Control Block         */
  242. /* ---------------------         */
  243. /*                               */
  244. /* One per controller.           */
  245. /*                               */
  246. /*-------------------------------*/
  247.  
  248.  
  249. #define FI_MAX_REGS     12
  250.  
  251. typedef struct _ACB
  252. {
  253.   /*--------------------------------------*/
  254.   /* IORB Queue for units on this adapter */
  255.   /*--------------------------------------*/
  256.   PIORBH        pHeadIORB;
  257.   PIORBH        pFootIORB;
  258.   PIORBH        pIORB;
  259.  
  260.   /*---------------------------------------------------*/
  261.   /* Controller Register addresses/contents, IRQ level */
  262.   /*---------------------------------------------------*/
  263.   USHORT        IOPorts[FI_MAX_REGS];
  264.   UCHAR         IORegs[FI_MAX_REGS];
  265.   USHORT        IOPendingMask;
  266.  
  267.   USHORT        IRQLevel;
  268.   USHORT        SpuriousIRQ;
  269.   USHORT        (FAR *IRQHandler)();
  270.  
  271.   /*-----------------------*/
  272.   /* Inner State Variables */
  273.   /*-----------------------*/
  274.   USHORT        ISMUseCount;
  275.   USHORT        ISMState;
  276.   USHORT        ISMFlags;
  277.  
  278.   VOID          (FAR *ISMDoneReturn)(NPACB npACB);
  279.  
  280.   /*-----------------------*/
  281.   /* Outer State Variables */
  282.   /*-----------------------*/
  283.   USHORT        OSMUseCount;
  284.   USHORT        OSMState;
  285.   USHORT        OSMFlags;
  286.   USHORT        OSMReqFlags;
  287.  
  288.   USHORT        ReqFlags;
  289.  
  290.   VOID          (FAR *OSMDoneReturn)(NPACB npACB);
  291.  
  292.   /*--------------------------------*/
  293.   /* Current operation variables    */
  294.   /*--------------------------------*/
  295.   USHORT        IORBStatus;
  296.   USHORT        IORBError;
  297.   NPCMDIO       npCmdIO;
  298.   CMDIO         ExternalCmd;
  299.   CMDIO         InternalCmd;
  300.  
  301.   /*--------------------------------*/
  302.   /* Timer Flags/Values             */
  303.   /*--------------------------------*/
  304.  
  305.   USHORT        TimerFlags;
  306.   ULONG         TimeOut;
  307.  
  308.   /*----------------------*/
  309.   /* Timer Loop Counters  */
  310.   /*----------------------*/
  311.   ULONG         DelayedResetInterval;
  312.   ULONG         DelayedResetCtr;
  313.   ULONG         DelayedRetryInterval;
  314.   ULONG         IRQTimeOut;
  315.  
  316.   /*--------------------------------------------------*/
  317.   /* Timer Handles                                    */
  318.   /*                                                  */
  319.   /* (Also update TIMERS_PER_ACB when adding timers)  */
  320.   /*--------------------------------------------------*/
  321.   ULONG         IRQTimeOutHandle;
  322. //  ULONG         RetryTimerHandle;
  323. //  ULONG         ResetTimerHandle;
  324.  
  325.   /*-------------------------------------------------*/
  326.   /* Unit Control Blocks - Unit specific information */
  327.   /*-------------------------------------------------*/
  328.   USHORT        cUnits;
  329.   UCB           UnitCB[MAX_UNITS];
  330.   USHORT        UnitId;
  331.   NPUCB         npUCB;
  332.   USHORT        cResetRequests;
  333.  
  334.   IORB_DEVICE_CONTROL IORB;
  335.  
  336.   VOID          (FAR *SharedDriverEP)();
  337.   USHORT        SharedDriverUnitHandle;
  338.   USHORT        ResourceFlags;
  339.   VOID          (FAR *CtxHookRoutine)(NPACB npACB);
  340.   ULONG         CtxHookHandle;
  341.   USHORT        iorbinuse;
  342.   USHORT        suspended;
  343.  
  344.   /*--------------------------------------------------*/
  345.   /* Begin [001] Bus Master DMA Vars                  */
  346.   /*--------------------------------------------------*/
  347.  
  348.   USHORT        Flags;                      /* Initialized state flags */
  349.   ULONG         BMDMA_SGList;               /* Bus Master DMA scatter/gather list */
  350.   USHORT        BMDMA_SGListSize;           /* useable size of BMDMA_SGList */
  351.   USHORT        BMDMA_SGListCount;          /* maximum descriptor useable */
  352. //  USHORT        PIIX_IDETIM;                /* setting for IDETIM in PIIX */
  353. //  USHORT        PIIX3_SIDETIM;              /* [008] setting for SIDETIM in PIIX3 */
  354.   UCHAR         BM_CommandCode;             /* command for BMDMA controller */
  355. //  ULONG         BytesToTransfer;            /* total transfer length in bytes */
  356.   USHORT        BMICOM;                     /* IDE Command Register */
  357.   USHORT        BMISTA;                     /* IDE Status Register */
  358.   USHORT        BMIDTP;                     /* IDE Descriptor Table Pointer */
  359.  
  360. /* End [001] */
  361.  
  362. } ACB;
  363.  
  364. /* Begin [001] ACB->Flags values */
  365.  
  366. #define ACBF_BM_DMA                  0x0001
  367.  
  368. /* End [001] */
  369.  
  370. /* ACB->ISMFlags values */
  371.  
  372. #define ACBIF_COMPLETION_STATUS_ONLY 0x0001
  373. #define ACBIF_INTERRUPT              0x0002
  374. #define ACBIF_WAITSTATE              0x0004
  375. #define ACBIF_SINGLEIO               0x0008
  376. #define ACBIF_MULTIPLEIO             0x0010
  377. #define ACBIF_ODD_BYTE_XFER          0x0020
  378. #define ACBIF_ATA_OPERATION          0x0040
  379. #define ACBIF_BUSMASTERDMAIO         0x0080                         /* [001] */
  380. #define ACBIF_BUSMASTERDMA_FORCEPIO  0x0100                         /* [001] */
  381.  
  382. /* ACB->OSMFlags values */
  383.  
  384. #define ACBOF_WAITSTATE              0x0001
  385. #define ACBOF_SM_ACTIVE              0x0002
  386. #define ACBOF_PS2IDEPORT             0x0004
  387. #define ACBOF_DISABLERESET           0x0008
  388. #define ACBOF_SM_IDLE                0x0010
  389. #define ACBOF_RESET_ACTIVE           0x0020
  390. #define ACBOF_SENSE_DATA_ACTIVE      0x0040
  391. #define ACBOF_RETRY_AFTER_RESET      0x0080                         /*@V195083*/
  392.  
  393. /* ACB->ReqFlags values */
  394.  
  395. #define ACBR_RESET                   0x0001
  396. #define ACBR_SENSE_DATA              0X0002
  397. #define ACBR_CONFIGURE_ACB           0x0003
  398.  
  399. /* ACB->OSMState values */
  400.  
  401. #define ACBOS_START_IORB         1
  402. #define ACBOS_ISM_COMPLETE       2
  403. #define ACBOS_COMPLETE_IORB      3
  404. #define ACBOS_RESUME_COMPLETE    4
  405. #define ACBOS_SUSPEND_COMPLETE   5
  406.  
  407. /* ACB->ISMState values */
  408.  
  409. #define ACBIS_START_STATE              1
  410. #define ACBIS_INTERRUPT_STATE          2
  411. #define ACBIS_COMPLETE_STATE           3
  412. #define ACBIS_WRITE_ATAPI_PACKET_STATE 4
  413.  
  414. /* ACB->TimerFlags */
  415. #define ACBT_BUSY       0x0001
  416. #define ACBT_DRQ        0x0002
  417. #define ACBT_IRQ        0x0004
  418. #define ACBT_READY      0x0008
  419. #define ACBT_INTERRUPT  0x0010
  420.  
  421. /* ACB->ResourceFlags */
  422. #define ACBRF_SHARED     0x0001
  423. #define ACBRF_CURR_OWNER 0x0002
  424.  
  425. /* Begin [001] */
  426.  
  427. /* Bus Master DMA Variable and Register definitions */
  428.  
  429. /*
  430.  * These values are used to represent the bits stored in vars in ACB and
  431.  * also map one-to-one with the PCI Bus Master registers. This one-to-one
  432.  * mapping must not be affected.
  433.  */
  434.  
  435. #define ACBX_IDETIM_MODE0       0x8000  /* mode 0 PIO timing */
  436. #define ACBX_IDETIM_DTE1        0x0080  /* DMA fast timing only drive 1 */
  437. #define ACBX_IDETIM_PPE1        0x0040  /* prefetct/posting enable drive 1 */
  438. #define ACBX_IDETIM_IE1         0x0020  /* IORDY samply point drive 1 */
  439. #define ACBX_IDETIM_TIME1       0x0010  /* fast timing select drive 1 */
  440. #define ACBX_IDETIM_DTE0        0x0008  /* DMA fast timing only drive 0 */
  441. #define ACBX_IDETIM_PPE0        0x0004  /* prefetct/posting enable drive 0 */
  442. #define ACBX_IDETIM_IE0         0x0002  /* IORDY samply point drive 0 */
  443. #define ACBX_IDETIM_TIME0       0x0001  /* fast timing select drive 0 */
  444.  
  445. #define ACBX_IDETIM_ITE1        0x4000  /* [006] PIIX3 slave timing enable */
  446.  
  447. #define ACBX_BMICOM_RW          0x08    /* Read when 0, write when 1 */
  448. #define ACBX_BMICOM_START       0x01    /* Start when 1, stop when 0 */
  449.  
  450. #define ACBX_BMISTA_SIMPLEX     0x80    /* simplex DMA channels when 1 */
  451. #define ACBX_BMISTA_D1DMA       0x40    /* drive 1 DMA capable */
  452. #define ACBX_BMISTA_D0DMA       0x20    /* drive 0 DMA capable */
  453. #define ACBX_BMISTA_INTERRUPT   0x04    /* IDE interrupt was detected */
  454. #define ACBX_BMISTA_ERROR       0x02    /* transfer error detected */
  455. #define ACBX_BMISTA_ACTIVE      0x01    /* Bus Master DMA active */
  456.  
  457.  
  458. /* End [001] */
  459.  
  460. /*-------------------------------*/
  461. /* Unit Table                    */
  462. /* ----------                    */
  463. /*                               */
  464. /* One per unit (drive)          */
  465. /*                               */
  466. /*-------------------------------*/
  467.  
  468. typedef struct _UTBL
  469. {
  470.   USHORT        Flags;
  471.   USHORT        Status;
  472.   USHORT        DriveId;
  473.  
  474.   USHORT        TimeOut;
  475. //  IDENTIFYDATA  IDdata;
  476.  
  477.   UCHAR         ModelNum[41];
  478.   UCHAR         Firmware[9];
  479.   UCHAR         Serial[21];
  480.   UCHAR         Reserved;
  481.  
  482. } UTBL;
  483.  
  484.  
  485. #define UTS_OK                  0
  486. #define UTS_NOT_PRESENT         1
  487. //#define UTS_READ_0_FAILED       2
  488.  
  489.  
  490. /*-------------------------------*/
  491. /* Adapter Table                 */
  492. /* -------------                 */
  493. /*                               */
  494. /* One per controller.           */
  495. /*                               */
  496. /*-------------------------------*/
  497.  
  498. typedef struct _ATBL
  499. {
  500.   USHORT        BasePort;
  501.   USHORT        IRQLevel;
  502.   USHORT        (FAR *IRQHandler)();
  503.  
  504.   USHORT        Flags;
  505.   USHORT        Status;
  506.  
  507.   NPACB         npACB;
  508.  
  509.   USHORT        cUnits;
  510.   UTBL          Unit[MAX_UNITS];
  511.  
  512. } ATBL;
  513.  
  514.  
  515. #define ATBF_DISABLED             0x0001
  516. #define ATBF_IRQINSTALLED         0x0002
  517. #define ATBF_DISABLERESET         0x0004
  518. #define ATBF_ATAPI_PRESENT        0x0008
  519. #define ATBF_SHARED_ADAPTER       0x0010
  520.  
  521. #define ATS_OK                  0
  522. #define ATS_NOT_PRESENT         1
  523. #define ATS_SKIPPED             2
  524. #define ATS_SET_IRQ_FAILED      3
  525.  
  526.  
  527. /*-------------------------------*/
  528. /* ACB Pointer Block             */
  529. /* -----------------             */
  530. /*                               */
  531. /*                               */
  532. /*                               */
  533. /*-------------------------------*/
  534.  
  535. typedef struct _ACBPTRS
  536. {
  537.   NPACB         npACB;
  538.   USHORT        (FAR *IRQHandler)();
  539.  
  540. } ACBPTRS;
  541.  
  542.