home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / ATCOM / COMINFO.H < prev    next >
Text File  |  1995-04-14  |  20KB  |  452 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. typedef struct IOCTLPacket {
  13.      CHAR      IPlen;
  14.      CHAR      IPunit;
  15.      CHAR      IPcommand;
  16.      USHORT    IPstatus;
  17.      ULONG     IPreserved;
  18.      ULONG     IPQlink;
  19.      CHAR      IPcategory;
  20.      CHAR      IPfunction;
  21.      ULONG     IPparameter;
  22.      ULONG     IPdata;
  23.      USHORT    IPsfn;
  24. } IOCTLPACKET;
  25.  
  26. typedef struct Flat_Pointer {
  27.      USHORT    fp_offlo;
  28.      USHORT    fp_offhi;
  29.      USHORT    fp_sel;
  30. } FLATPOINTER;
  31.  
  32. typedef struct Stack_Data {
  33.      USHORT    old_bp;
  34.      ULONG     old_cs;
  35.      ULONG     old_ip;
  36.      ULONG     ul2;
  37.      ULONG     ul1;
  38.      ULONG     uFunc;
  39. } STACK_DATA;
  40.  
  41. typedef struct Device_dependent_VCOM_data {
  42.      USHORT    ret_len;
  43.      USHORT    num_com;
  44.      USHORT    com1;
  45.      USHORT    com2;
  46.      USHORT    com3;
  47.      USHORT    com4;
  48.      USHORT    com1irq;
  49.      USHORT    com2irq;
  50.      USHORT    com3irq;
  51.      USHORT    com4irq;
  52. } DD_VCOM_DATA;
  53.  
  54. typedef struct IDC_Packet {
  55.      USHORT    Command_Flag;
  56.      USHORT    Com_Port_Num;
  57.      USHORT    Com_Port_Addr;
  58.      USHORT    Com_Port_IRQ;
  59.      USHORT    Return_Code;
  60. } IDC_PACKET;
  61.  
  62. /**     Machine Identifiers
  63.  *
  64.  *      ABIOS_COM          -   Identifies a ABIOS machine
  65.  *      NON_ABIOS_COM      -   Identifies a non ABIOS machine
  66.  *
  67.  */
  68. #define   NON_ABIOS_COM  1
  69. #define   ABIOS_COM      0
  70.  
  71. /**     Queue manifests, sizes and hi/lo water marks
  72.  *
  73.  *      Due to the implementation of the character queues, they
  74.  *      must be declared to be one byte greater than their
  75.  *      actual usable size.
  76.  */
  77. #define   QI_SIZE        5121                // input  queue size
  78. #define   QO_SIZE        2049                // output queue size
  79. #define   QI_SIZE_EVEN   (QI_SIZE+1)&0xFFFF  // even size for word alignment
  80. #define   QO_SIZE_EVEN   (QO_SIZE+1)&0xFFFF
  81.  
  82. /**     high/low water marks for when to send handshake
  83.  *   when input queue goes above high water, send XOFF and/or drop hardware lines
  84.  *   when input queue goes below low  water, send XON and/or raise hardware lines
  85.  */
  86. #define   RX_HIGH_HS     (QI_SIZE-1)-2048    // RX queue high water mark
  87. #define   RX_LOW_HS      (QI_SIZE-1)/2       // RX queue low water mark
  88.  
  89. /*   when input queue goes up to this, move data to user buffer            */
  90. #define   RX_MOVE_PROT   200                 // protect mode or below 1 meg
  91. #define   RX_MOVE_REAL   256                 // real mode and above 1 meg
  92.  
  93. /*   when output queue goes down to this, move data from user buffer       */
  94. #define   TX_MOVE_PROT   64                  // protect mode or below 1 meg
  95. #define   TX_MOVE_REAL   0                   // real mode and above 1 meg
  96.  
  97. #define   RX_STATE_HOLDING    1         //isr has no more room in buffer
  98.                                         //until consumer removes rx data
  99.  
  100. #define   RX_STATE_OK         2         //isr has room in buffer for rx data
  101.  
  102. /*****
  103.  **     ComInfo.ci_dcb_flags1 definitions
  104.  *****/
  105. #define   F1_DTR_MASK         0x03      //DTR control mask
  106. #define   F1_DTR_DISABLE      0x00      //   DTR disable
  107. #define   F1_DTR_ENABLE       0x01      //   DTR enable
  108. #define   F1_DTR_FLOW         0x02      //   DTR input handshaking
  109. #define   F1_DTR_INVALID      0x03      //   DTR invalid mode
  110. #define   F1_OUT_FLOW         0x38      //Output handshaking mask
  111. #define   F1_OUT_CTS_FLOW     0x08      //   output handshaking using CTS
  112. #define   F1_OUT_DSR_FLOW     0x10      //   output handshaking using DSR
  113. #define   F1_OUT_DCD_FLOW     0x20      //   output handshaking using DCD
  114. #define   F1_IN_DSR_SENSE     0x40      //input sensitivity to DSR
  115. #define   F1_RESERVED         0x80      //--reserved--
  116.  
  117. /*****
  118.  **     ComInfo.ci_dcb_flags2 definitions
  119.  *****/
  120. #define   F2_OUT_XO           0x01      //output XON/XOFF
  121. #define   F2_IN_XO            0x02      //input  XON/XOFF
  122.  
  123. #define   F2_ERR_CHAR         0x04      //error replacement character
  124. #define   F2_NULL_STRIP       0x08      //null stripping
  125. #define   F2_BRK_CHAR         0x10      //break replacement character
  126. #define   F2_FULL_DUP         0x20      //full duplex auto flow control
  127.  
  128. #define   F2_RTS_MASK         0xc0      //RTS control mask
  129. #define   F2_RTS_DISABLE      0x00      //   RTS disable
  130. #define   F2_RTS_ENABLE       0x40      //   RTS enable
  131. #define   F2_RTS_FLOW         0x80      //   RTS input handshaking
  132. #define   F2_RTS_TOGGLE       0xC0      //   RTS toggle on transmit
  133.  
  134. /*****
  135.  **     ComInfo.ci_dcb_flags3 definitions
  136.  *****/
  137. #define   F3_W_INF_TO         0x01      //write infinite timeout
  138.  
  139. #define   F3_READ_TO_MASK     0x06      //read timeout mask
  140. #define   F3_READ_TO_BAD      0x00      //    read timeout bad
  141. #define   F3_READ_TO_NORM     0x02      //    read timeout normal
  142. #define   F3_READ_TO_WFS      0x04      //    read timeout wait for something
  143. #define   F3_READ_TO_NW       0x06      //    read timeout no wait
  144.  
  145. #define   F3_FIFO_MASK        0x18      //FIFO mask
  146. #define   F3_FIFO_NA          0x00      //    FIFO not available
  147. #define   F3_FIFO_OFF         0x08      //    FIFO disabled
  148. #define   F3_FIFO_ON          0x10      //    FIFO enabled
  149. #define   F3_FIFO_APO         0x18      //    FIFO auto priority override
  150. #define   F3_FIFO_HW_ON       0x10      //    FIFO HW is on (either ON or APO)
  151.  
  152. #define   F3_RX_MASK          0x60      //Receive trigger level mask
  153. #define   F3_RX_1             0x00      //    receive trigger level 1
  154. #define   F3_RX_4             0x20      //    receive trigger level 4
  155. #define   F3_RX_8             0x40      //    receive trigger level 8
  156. #define   F3_RX_14            0x60      //    receive trigger level 14
  157.  
  158. #define   F3_TX_16            0x80      //Transmit buffer load count = 16
  159.  
  160. #define   F3_FIFO_ALL         0xF1      //All the FIFO bits
  161.  
  162.  
  163. /*****
  164.  **     ComInfo.ci_hsflag values
  165.  *****/
  166. #define   HS_XOFF_PENDING     0x01      //XOFF needs to be sent
  167. #define   HS_FLOW_OFF_LOCAL   0x02
  168. #define   HS_XON_PENDING      0x04      //XON needs to be sent
  169. #define   HS_XOFF_RECEIVED    0x08      //XOFF character received
  170. #define   HS_XOFF_SENT        0x10      //XOFF has been sent
  171. #define   HS_BREAK_SET        0x40      //break has been set
  172. #define   HS_TX_IMMED         0x80      //TxImmed character pending
  173.  
  174. /*****
  175.  *     IOCTL com status definitions
  176.  *
  177.  * Note: TX_IMMED is maintained in ci_hsflag.  All the other fields are
  178.  * calculated only when IOCTL Return Com Status is called.
  179.  *****/
  180. #define   CST_CTS_HOLD        0x01      //TX waiting for CTS to be asserted?
  181. #define   CST_DSR_HOLD        0x02      //TX waiting for DSR to be asserted?
  182. #define   CST_DCD_HOLD        0x04      //TX waiting for DCD to be asserted?
  183. #define   CST_XOFF_HOLD       0x08      //TX waiting, XOff received?
  184. #define   CST_XOFF_SENT       0x10      //TX waiting, XOff transmitted?
  185. #define   CST_BREAK_HOLD      0x20      //TX waiting, break being transmitted?
  186. #define   CST_TX_IMMED        0x40      //char waiting to be transmitted immed?
  187. #define   CST_RX_DSR_HOLD     0x80      //RX waiting for DSR to be asserted?
  188.  
  189. /*****
  190.  **     ComInfo.ci_comerr (IOCTL com error) definitions
  191.  *****/
  192. #define   CE_SW_OVERRUN       0x01      //receive SW queue overrun error
  193. #define   CE_HW_OVERRUN       0x02      //receive HW overrun error
  194. #define   CE_RX_PARITY        0x04      //receive parity error
  195. #define   CE_FRAME            0x08      //receive framing error
  196.  
  197. /*****
  198.  **     ComInfo.ci_event (IOCTL com event) definitions
  199.  *****/
  200. #define   EV_RX_CHAR          0x01      //set when any character is received
  201.                                         //and placed in the input queue.
  202. #define   EV_RESERVED         0x02      //reserved
  203. #define   EV_TX_EMPTY         0x04      //set when the last char in the
  204.                                         //transmit queue is transmitted
  205. #define   EV_CTS              0x08      //set when the CTS signal changes state
  206. #define   EV_DSR              0x10      //set when the DSR signal changes state
  207. #define   EV_DCD              0x20      //set when the DCD signal changes state
  208. #define   EV_BREAK            0x40      //set when a Break is detected on input
  209. #define   EV_ERR              0x80      //set when an error occurs
  210.                                         //(parity, framing or HW or SW overrun)
  211. #define   EV_RING             0x100     //set when Ring Indicator is detected
  212.  
  213. /*****
  214.  **     ComInfo.ci_flagx definitions
  215.  *****/
  216. #define   FX_DATA_MOVED       0x01      //data moved (PhysToVirt) in
  217.                                         //TxInt, so don't move Rx data
  218.                                         //this interrupt
  219. #define   FX_LAST_CLOSE       0x02      //last close in progress,
  220.                                         //so discard received data
  221. #define   FX_RTS_DROP_PENDING 0x04      //drop RTS at the first timer
  222.                                         //tick where the THR and TSR
  223.                                         //are empty
  224. #define   FX_WAITING_TX_EMPTY 0x08
  225. #define   FX_INT_NESTED       0x10      //nested interrupt occured
  226. #define   FX_IN_DSR_OK        0x20      //input DSR mode is off OR
  227.                                         //DSR was high OR DSR is high
  228.                                         //this bit MUST be the same as MS_DSR
  229.  
  230. #define   FX_CHIP_MASK        0xC0      //chip type 8250, 16450, 16550A
  231. #define   FX_8250             0x00      //8250x (PC chip)
  232. #define   FX_16450            0x40      //16450 or 16550 (bad FIFO)
  233. #define   FX_16550A           0x80      //16550A (good FIFO)
  234.  
  235. /*****
  236.  **     ComInfo.ci_flagx definitions
  237.  *****/
  238. #define   FX_XO_FOUND         0x20      //flag used in TxFlowDetect
  239. #define   FX_TX_IN_PROG       0x40      //flag used for Tx'ing
  240. #define   FX_INT_TIME         0x80      //flag used mode switching
  241.  
  242. /*****
  243.  **     ComInfo.ci_Flagx1 definitions
  244.  *****/
  245. #define   FX1_FLUSH_TX_IP     0x01      //flag for TX Flush in progress
  246. #define   FX1_FLUSH_RX_IP     0x02      //flag for RX Flush in progress
  247. #define   FX1_SET_BAUD_IP     0x04      //flag for set baud IOCTL in progress
  248. #define   FX1_PCMCIA_MODEM    0x08      //flag to show this is a special PCMCIA modem
  249.  
  250. /*****
  251.  *     ComInfo.ci_eflags definitions
  252.  *
  253.  * NOTE: bit positions must match SetEnhancedParmeters IOCtl (54H)
  254.  *       parameter packet format
  255.  *****/
  256. #define   EF_POSSIBLE_ENHANCED     0x01 //port CAN run in enhanced mode
  257. #define   EF_MODE_ENHANCED         0x02 //port is NOW in enhanced mode
  258. #define   EF_RX_REQUEST_NOT_PIO    0x04 //port NOT in rx PIO mode
  259. #define   EF_RX_REQUEST_DEF_DMA    0x08 //port DEFINITELY in rx DMA mode
  260. #define   EF_RX_REQUEST_MASK       0x0C //
  261. #define   EF_TX_REQUEST_NOT_PIO    0x10 //port NOT in rx PIO mode
  262. #define   EF_TX_REQUEST_DEF_DMA    0x20 //port DEFINITELY in rx DMA mode
  263. #define   EF_TX_REQUEST_MASK       0x30 //
  264. #define   EF_LAST_RX_WAS_DMA       0x40 //most recent receive for
  265.                                         //this port was in DMA mode
  266. #define   EF_LAST_TX_WAS_DMA       0x80 //most recent transmit for
  267.                                         //this port was in DMA mode
  268. #define   EF_GET_MASK              0xC1
  269.  
  270. /*****
  271.  *    Physical address structure
  272.  *****/
  273. typedef struct PhysAddr {
  274.      USHORT    _lo;
  275.      USHORT    _hi;
  276. } PHYSADDR;
  277.  
  278. /*****
  279.  *    I/O queue structure
  280.  *****/
  281. typedef struct IO_Queue {
  282.      CHAR      ioq_phys[sizeof(PHYSADDR)];
  283.      USHORT    ioq_page;
  284.      USHORT    ioq_base;
  285.      USHORT    ioq_end;
  286.      USHORT    ioq_in;
  287.      USHORT    ioq_out;
  288.      USHORT    ioq_count;
  289. } IO_QUEUE;
  290.  
  291. typedef struct ComInfo {
  292. //       start of device control block info
  293. //  WARNING: this must at the top of the ComInfo structure.
  294. //  WARNING: this must match the DCB structure exactly.
  295.  
  296.      USHORT    ci_dcb_writeto;     // write timeout
  297.      USHORT    ci_dcb_readto;      // read  timeout
  298.      CHAR      ci_dcb_flags1;      // first  flags byte
  299.      CHAR      ci_dcb_flags2;      // second flags byte
  300.      CHAR      ci_dcb_flags3;      // third  flags byte
  301.      CHAR      ci_dcb_ErrChar;     // error replacement char
  302.      CHAR      ci_dcb_BrkChar;     // break replacement char
  303.      CHAR      ci_dcb_XonChar;     // XON  character
  304.      CHAR      ci_dcb_XoffChar;    // XOFF character
  305.  
  306. // end of device control block info
  307.  
  308.      CHAR      ci_ier;             // word align rest of struc
  309.      USHORT    ci_signature;       // signature ID word
  310.      USHORT    ci_port;            // I/O port, 0 if non-existant
  311.      USHORT    ci_baud;            // baud rate
  312.  
  313.      CHAR      ci_linec;           // line control
  314.      CHAR      ci_bytesize;        // TX/RX byte size
  315.      CHAR      ci_parity;          // parity
  316.      CHAR      ci_stopbits;        // stop bits
  317.      CHAR      ci_cmask;           // received character mask
  318.      CHAR      ci_tximm;           // transmit immediate character
  319.  
  320.      CHAR      ci_irq;             // interrupt number
  321.      CHAR      ci_depth;           // interrupt depth
  322.      USHORT    ci_isr;             // interrupt service routine
  323.      USHORT    ci_visr;            // vdm interrupt service routine
  324.      USHORT    ci_badmax;          //     interrupt maximum
  325.  
  326.      USHORT    ci_nopens;          // number of outstanding opens
  327.      USHORT    ci_nvdmopens;       // number of outstanding vdm opens CP20D1390
  328.      ULONG     ci_oci_sem;         // open/close/ioctl exclusion sem
  329.      ULONG     ci_oci_sem_own;     // oci_sem owner RP address
  330.      USHORT    ci_comerr;          // I/O error
  331.      USHORT    ci_event;           // event flags
  332.  
  333.      USHORT    ci_GDTSelRead;      // GDT selectors for the user buffer
  334.      USHORT    ci_GDTSelWrite;     // for use in the interrupt routines
  335.  
  336.      HADAPTER  ci_hAdapter;
  337.      HLDEV     ci_hLDev;
  338.      HSYSNAME  ci_hSysName;
  339.  
  340.      CHAR      ci_flagx;           // extra flags
  341.      CHAR      ci_flagx1;          // extra flags
  342.      CHAR      ci_hsflag ;         // handshake flag
  343.      CHAR      ci_hhslines;        // DTR/RTS bits for handshaking
  344.      CHAR      ci_outhhslines;     // output handshake lines
  345.  
  346.      CHAR      ci_lsrshadow;       // line  status register shadow
  347.      CHAR      ci_msrshadow;       // modem status register shadow
  348.      CHAR      ci_port_number;     // VDM port number of this CIDA
  349.      USHORT    ci_LID;             // to remember LID on PS/2s
  350.      USHORT    ci_flagGA;          // Log Facility Alert conditons
  351.                                    // read request packet list
  352.      ULONG     ci_r_rpl;           // head
  353.      ULONG     ci_r_rpl2;          // tail
  354.      USHORT    ci_r_sig;
  355.  
  356.                                    // write request packet list
  357.      ULONG     ci_w_rpl;           // head
  358.      ULONG     ci_w_rpl2;          // tail
  359.      USHORT    ci_w_sig;
  360.  
  361.      ULONG     ci_r_rp;            // current read request
  362.      ULONG     ci_w_rp;            // current write request
  363.      USHORT    ci_r_to_move;       // bytes to move to satisfy r_rp
  364.      USHORT    ci_w_to_move;       // bytes to move to satisfy w_rp
  365.  
  366.      USHORT    ci_r_to;            // r_rp time out
  367.      USHORT    ci_w_to;            // w_rp time out
  368.      USHORT    ci_r_to_start;      // r_rp time out start value
  369.      USHORT    ci_w_to_start;      // w_rp time out start value
  370.  
  371.      CHAR      ci_vdm_flag;        // VDM information flag
  372.                                    // VDM BIT 0 - InUse by VDM
  373.                                    // VDM BIT 1 - notify the VCOM Rx
  374.                                    // VDM BIT 2 - notify the VCOM Tx
  375.                                    // VDM BIT 3 - Blocked IOCTL
  376.                                    // VDM BIT 4-7 RESERVED, set to 0
  377.  
  378.      CHAR      ci_vdm_Rx_State;    // VDM BIT 0&1 - Rx_State
  379.                                    // VDM BIT 2-7 RESERVED, set to 0
  380.  
  381.      CHAR      ci_vdm_Tx_State;    // VDM BIT 0&1 - Tx_State
  382.                                    // VDM BIT 2-7 RESERVED, set to 0
  383.  
  384.      CHAR      ci_vdm_Rx_Count;    // VDM count of chars put in Tx
  385.                                    // VDM Queue since XOFF given to
  386.                                    // VDM DOS APP
  387.  
  388.      CHAR      ci_vdm_Tx_Count;    // VDM count of chars put in Rx
  389.                                    // VDM Queue since XOFF sent to
  390.                                    // VDM device
  391.  
  392.      CHAR      ci_vdm_LastMSR;     // VDM last MSR given to DOS App
  393.      CHAR      ci_vdm_LastLSR;     // VDM LSR to give to DOS app
  394.  
  395.      CHAR      ci_dummy3;          // mw put on word boundaries
  396.  
  397.      CHAR      ci_qin[sizeof(IO_QUEUE)];
  398.      CHAR      ci_qin_q[QI_SIZE_EVEN];
  399.  
  400.      CHAR      ci_qout[sizeof(IO_QUEUE)];
  401.      CHAR      ci_qout_q[QI_SIZE_EVEN];
  402.  
  403.      USHORT    ci_fifobaud;        // mw store baud latch values
  404.      USHORT    ci_sid;             // VDM App's Session ID CP20D1390
  405.  
  406.      USHORT    ci_vdm_OpenError;   // VDM Type of error to return to
  407.                                    // VDM VCOM from Open
  408.  
  409.      ULONG     ci_vdm_Blocked_IOCTL;// VDM IOCTL/Tx Queue
  410.                                     // VDM serialization mechanism
  411.  
  412.      CHAR      ci_req_pack[sizeof(IOCTLPACKET)];  // VDM IOCTL request packet
  413.  
  414.      CHAR      ci_qstat[QI_SIZE];  // VDM LSRQ
  415.      CHAR      ci_int_sharing;     // supports int. sharing
  416.      USHORT    ci_int_data;        // offset of SharedIntData
  417.      USHORT    ci_next_COM;        // ComInfo of next COM on this IRQ line
  418.      CHAR      ci_mult_COMs_IRQ;   // # of other COM ports on this IRQ line
  419.  
  420.      CHAR      ci_eflags;
  421.  
  422.      CHAR      dummy;
  423.      CHAR      ci_rx_request;
  424.      CHAR      ci_tx_request;
  425.  
  426. //*************************************************************
  427. //************                                     ************
  428. //******          Perfview Data Block                    ******
  429. //**************                                   ************
  430. #ifdef PERFVIEW
  431.      CHAR      ci_Data_Block[sizeof(pvdbh_s)];
  432.      ULONG     ci_Read_Time;
  433.      ULONG     ci_Read_Time2;
  434.      ULONG     ci_Write_Time;
  435.      ULONG     ci_Write_Time2;
  436.      ULONG     ci_Num_Reads;
  437.      ULONG     ci_Read_Bytes;
  438.      ULONG     ci_Num_Writes;
  439.      ULONG     ci_Write_Bytes;
  440.      ULONG     ci_HW_Overruns;
  441.      ULONG     ci_SW_Overruns;     // last item! Used to find data_block len
  442.  
  443. //************                                     ************
  444. //*******  If Adding Counters or Timers then see the     ******
  445. //*******  Number_Tmrs_Ctrs EQU. And change Procedure    ******
  446. //*******  Initialize_PerfView_Data to reference last    ******
  447. //*******  data item                                     ******
  448. //*************************************************************
  449. #endif
  450. } COMINFO;
  451. typedef COMINFO *PCOMINFO;
  452.