home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / t / twindv21.zip / TWIN.H < prev    next >
C/C++ Source or Header  |  1992-09-07  |  12KB  |  351 lines

  1. /****************************************************************************
  2. *
  3. *            COPYRIGHT 1990,91,92 BY GRACILIS INC.
  4. *
  5. *             623 Palace St.
  6. *             Aurora, Il. 60506
  7. *
  8. *             (708)-801-8800        Office
  9. *             (708)-844-0183        (FAX - Support BBS)
  10. *
  11. * GRACILIS, INC., MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS 
  12. * SOFTWARE FOR ANY PURPOSE.  
  13. *
  14. * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
  15. * Permission is granted for non-commercial use/distribution only, as long as
  16. * this copyright header is included intact and unaltered.
  17. *
  18. ******************************************************************************/
  19.  
  20.  
  21.  
  22. /********************************************************************
  23. *                        TWIN.H                                     *
  24. *                                                                   *
  25. * File: twin.h                                                      * 
  26. * Rev : 3.0                                                         *
  27. *                                                                   *
  28. *********************************************************************
  29. *
  30. *
  31. * DESCRIPTION: 
  32. * -----------
  33. * This section defines PackeTwin card's hardware interface regs etc.
  34. *
  35. *
  36. *
  37. *****************************************************************/
  38.  
  39. #define    PKTWIN_IO_BASE    0x230        /* default base address */
  40.  
  41. #define SCCB_CMD    0x00
  42. #define SCCB_DATA   0x01
  43. #define SCCA_CMD    0x02
  44. #define SCCA_DATA   0x03
  45. #define TMR_CNT0    0x04
  46. #define TMR_CNT1    0x05
  47. #define TMR_CNT2    0x06
  48. #define TMR_CTRL    0x07
  49.  
  50. /* READ ONLY REGS */
  51. #define INT_REG        0x08
  52. #define CLR_TMR1       0x09
  53. #define CLR_TMR2       0x0a
  54. #define SPARE_1        0x0b
  55.  
  56. /* WRITE ONLY REGS */
  57. #define    DMA_CFG        0x08
  58. #define    SERIAL_CFG     0x09
  59. #define    INT_CFG        0x09    /* port shared with serial config */
  60. #define    DMA_CLR_FF     0x0a
  61. #define    SPARE_2        0x0b
  62.  
  63.  
  64. /* INT_REG mask values for pending ints */
  65. #define PKTWIN_SCC_MSK  0x01
  66. #define PKTWIN_TMR1_MSK 0x02
  67. #define PKTWIN_TMR2_MSK 0x04
  68.  
  69.  
  70. /* SERIAL_CFG /  INT_CFG values */
  71. #define PKTWIN_DTRA_ON    0x01
  72. #define PKTWIN_DTRB_ON    0x02
  73. #define PKTWIN_EXTCLKA    0x04
  74. #define PKTWIN_EXTCLKB    0x08
  75. #define PKTWIN_LOOPA_ON   0x10
  76. #define PKTWIN_LOOPB_ON   0x20
  77. #define PKTWIN_EI         0x80
  78.  
  79.  
  80. /*=======================================================================
  81. DMA_CFG reg bit definitions 
  82.  
  83.     7        6        5        4        3        2        1        0
  84.    Aux1    Aux0        X      DMA3       DMA1       Sel1   Sel0      HDX/FDX
  85.                          Enable      Enable
  86.  
  87. Aux1,Aux0        configuration bits for DE Modems.
  88.  
  89.  
  90. DMA3 Enable        0 = DMA channel 3 disabled
  91.                 1 = Enabled
  92.  
  93. DMA1 Enable        0 = DMA channel 1 disabled
  94.                 1 = Enabled
  95.  
  96.  
  97.                DMA3       DMA1       Sel1       Sel0     HDX/FDX
  98. Tx Chan 1 HDX    0        1        0        0        0
  99. Rx Chan 1 HDX    0        1        0        1        0
  100. Tx Chan 3 HDX    1        0        1        0        0
  101. Rx Chan 3 HDX    1        0        1        1        0
  102. ILLEGAL!!!      X        X        0        0        1
  103. Rx1 Tx3 FDX        1        1        0        1        1
  104. Rx3 Tx1 FDX        1        1        1        0        1
  105. ILLEGAL!!!      X        X        1        1        1
  106.  
  107. =======================================================================*/
  108.  
  109. /* DMA_CFG values */
  110. /* Half Duplex settings for channels */
  111. #define PKTWIN_DMA_HDX_T1    0x08    /* Tx on channel 1 */
  112. #define PKTWIN_DMA_HDX_R1    0x0a    /* Rx on channel 1 */
  113. #define PKTWIN_DMA_HDX_T3    0x14    /* Tx on channel 3 */
  114. #define PKTWIN_DMA_HDX_R3    0x16    /* Rx on channel 3 */
  115. /* Full Duplex settings... */
  116. #define PKTWIN_DMA_FDX_T3R1    0x01b    /* Tx on channel 3, Rx on channel 1 */
  117. #define PKTWIN_DMA_FDX_T1R3    0x01d    /* Tx on channel 1, Rx on channel 3 */
  118.  
  119.  
  120. /* 8237 stuff */
  121. #define BASE8237    0x00
  122.  
  123. #define DMA0ADR    BASE8237 + 0x00
  124. #define DMA0CNT    BASE8237 + 0x01
  125. #define DMA1ADR    BASE8237 + 0x02
  126. #define DMA1CNT    BASE8237 + 0x03
  127. #define DMA2ADR    BASE8237 + 0x04
  128. #define DMA2CNT    BASE8237 + 0x05
  129. #define DMA3ADR    BASE8237 + 0x06
  130. #define DMA3CNT    BASE8237 + 0x07
  131. #define DMACTRL    BASE8237 + 0x08
  132. #define DMASTA     BASE8237 + 0x08
  133. #define DMAWRRG    BASE8237 + 0x09
  134. #define DMAWSMR    BASE8237 + 0x0a
  135. #define DMAMODE    BASE8237 + 0x0b
  136. #define DMAFFCL    BASE8237 + 0x0c
  137. #define DMAMCLR    BASE8237 + 0x0d
  138. #define DMATMPR    BASE8237 + 0x0d
  139. #define DMACLRM    BASE8237 + 0x0e
  140. #define DMAWAMR    BASE8237 + 0x0f
  141.  
  142. #define    RX_DMA    0x44        /* Write Xfers, Autoinitialization OFF, */
  143.                                  /* increment addresses, single transfer mode */
  144. #define    TX_DMA    0x48        /* Read Xfers, Autoinitialization OFF, */
  145.                                  /* increment addresses, single transfer mode */
  146.  
  147.  
  148.  
  149. /*
  150. * Description:    
  151. *
  152. *    This section contains the data structures used by drivers.
  153. *
  154. */
  155.  
  156. #define    TSYNC_DEBUG  1        /* generate debugging trace of 8530 reg usage */
  157. #undef     TSYNC_DEBUG_PRT        /* turn on runtime printf's */
  158.  
  159.  
  160. #define    TWINCOMM1        0    /*  Twin_udcb[0] is for PackeTwin port #1 */
  161. #define TWINCOMM2        1    /*  Twin_udcb[1] is for PackeTwin port #2 */
  162.  
  163.  
  164. /* Supported driver Types for the PackeTwin driver */
  165. #define    ASYNC_8530    1    /* its a 8530 SCC driver */
  166. #define    SYNC_8530    2
  167.  
  168.  
  169. /*
  170.  * 8530 SCC control and data registers' addresses 
  171.  */
  172.  
  173. typedef struct zscc_hw {
  174.                         int16    ctl;    /* address of Channel's control reg */
  175.                         int16    data;    /* address of Channel's data reg */
  176. } HW_REGS_8530;
  177.  
  178.  
  179. /*
  180.  * SZ_DRIVER'S I/O Control Parameters
  181.  */ 
  182. struct tsync_ioctl {
  183.     int16   xmitdelay;    /* Transmit delay 1 ms/count */
  184.     int16    persist;     /* Persistance, as a percent from 0 to 255 */
  185.     int16    slotime;    /* Delay to wait for persistance hit */
  186.     int16    squelch;    /* Squelch delay */
  187.     int16    rxavailbufs;    /* num of pre-allocated RX mbufs' to have */
  188.     int16    cputype;    /* CPU type defaults to 8086 (0) */
  189.                         /*                        80186(1) */
  190.                         /*                        80286(2) */
  191.                         /*                        80386(3) */
  192. };
  193.  
  194. /* Driver Control Block */
  195. typedef struct dcblock {
  196.     char    txstate;    /* transmit state */
  197.     char    rxstate;    /* receive state */
  198.     char    dev;        /* device number, i.e. COMMA_8530,COMMB_8530 */ 
  199.     char    extsts;        /* current mask value for WR15 */
  200.     char    extreg;        /* current READ register value for RR15 */
  201.     struct  drvbuf *xmtq;    /* xmit queue of packets this one is being */
  202.                             /* transmitted!!! */
  203.     struct  drvbuf *xmtqtail; /* tail ptr to xmit queue of packets */
  204.     char    *cur_xbufp;    /* address of current xmit packet */
  205.     int16    cur_xbytes;    /* num. bytes left to transmit */
  206.     struct    drvbuf *freem;    /* queue of packets to free - from task level */
  207.  
  208.     struct mbuf_qhat rxqhat; /* FIFO Head And Tail control structure for */
  209.                 /*  received packets */
  210.     struct    mbuf *rxbufp;    /* address of current receive buffer */
  211.     int16    rxbufsize;    /* size of rxbufp */
  212.     char    *rxcurp;    /* addr of spot in rxbufp where last received */
  213.                 /* char was put */
  214.     struct mbuf *rxavailq;    /* queue of pre-allocated mbufs */
  215.                 /* used to get rid of alloc_mbuf */
  216.                 /* while in sz_rxisr */
  217.     ulong   rxavailcount;    /* num. of mbufs in rxavailq */
  218.     ulong    rxnqued;    /* packets received and sent up */
  219.     ulong    rxpackcnt;    /* received packet count */
  220.     ulong    rxbytecnt;    /* received chars count */
  221.     ulong    txpackcnt;    /* transmitted packet count */
  222.     ulong    txbytecnt;    /* transmitted chars count */
  223.     ulong    txunderun;    /* transmitted underrun count */
  224.     ulong    txctslost;    /* CTS went away during xmit */
  225.     ulong    rxtruncnt;    /* receive packet exceeds rxbufp, truncated rx*/
  226.     ulong    rxovercnt;    /* receiver overuns */
  227.     ulong    rxabortcnt;    /* receiver aborts */
  228.     ulong    rxcrcerrcnt;    /* receiver CRC error count */
  229.     ulong    nobufs;        /* no memory for pre-allocated */
  230.                 /* receive buffers */
  231.     ulong    baud;        /* e.g. 300, 19200, 4000000 */
  232.     bool    hduplex;    /* TRUE half-duplex, FALSE full-duplex */
  233.     bool    dma_flg;    /* TRUE DMA used, FALSE int per char */
  234.     uint    dma_rx_chan;
  235.     uint    dma_rx_mode;    /* value to use in the DMA MODE reg for receive */
  236.     uint    dma_rx_pagereg;
  237.     uint    dma_rx_cnt_reg;
  238.     uint    dma_rx_addr_reg;
  239.     uint    dma_tx_chan;
  240.     uint    dma_tx_mode;    /* value to use in the DMA MODE reg for transmit */
  241.     uint    dma_tx_pagereg;
  242.     uint    dma_tx_cnt_reg;
  243.     uint    dma_tx_addr_reg;
  244.     bool    txclk_extrn;    /* Tx clock source: (internal-external) */
  245.     bool    rxclk_extrn;    /* Rx clock source: (internal-external) */
  246.     bool    nrzi_flg;    /* NRZ/NRZI mode spec */
  247.     struct tsync_ioctl    *ioctlparams;    /* address to driver specific params */
  248.     HW_REGS_8530 zhwmap;    /* address of 8530 SCC control data structure */
  249.     uchar    wr0;        /* WR0 current values... */
  250.     uchar    wr1;        /* WR1 current values... */
  251.     uchar    wr2;        /* WR2 current values... */
  252.     uchar    wr3;        /* WR3 current values... */
  253.     uchar    wr4;        /* WR4 current values... */
  254.     uchar    wr5;        /* WR5 current values... */
  255.     uchar    wr6;        /* WR6 current values... */
  256.     uchar    wr7;        /* WR7 current values... */
  257.     uchar    wr9;        /* WR9 current values... */
  258.     uchar    wr10;        /* WR10 current values... */
  259.     uchar    wr11;        /* WR11 current values... */
  260.     uchar    wr12;        /* WR12 current values... */
  261.     uchar    wr13;        /* WR13 current values... */
  262.     uchar    wr14;        /* WR14 current values... */
  263.     uchar    wr15;        /* WR15 current values... */
  264.     int        maxtxbytes;    /* Highest number of bytes loaded into */
  265.                         /* the TX FIFO at one time */
  266.     struct drv_timer *timer1; /* driver control block */
  267.     struct iface *iface;     /* For NOS need iface's address */
  268.     struct proc *rxavproc; /* addr of created process for sz_rxavget() */
  269.     struct proc *txkickproc; /* addr of created process for sz_txkick() */
  270.     struct proc *freetxproc; /* addr of created process for sz_freetx() */
  271. } DCB; 
  272.  
  273. /*
  274.  *  DCB txstate values
  275.  */
  276. #define    IDLE                0
  277. #define    DEFER                 1
  278. #define    TX_ACTIVE            2
  279. #define    KEYED_UP            3
  280. #define    CRCING                4
  281. #define TX_KEYUP_DELAY        5 
  282. #define TX_KEYDOWN_DELAY    6
  283. #define TX_PERSIST            7
  284. #define    TX_DONE                8 
  285.  
  286.  
  287.  
  288. /* Normal state is ACTIVE if Receive enabled */
  289. #define RXNORM 0x55
  290. #define RXERROR 2        /* Error -- Aborting current Frame */
  291. #define RXABORT 3        /* ABORT sequence detected */
  292. #define TOOBIG 4        /* too large a frame to store */
  293. #define TXDELAY 0        /* Transmit Delay 10 ms/cnt */
  294. #define PERSIST 1        /* Persistence (0-255) as a % */
  295. #define SLOTIME 2        /* Delay to wait on persistence hit */
  296. #define SQUELDELAY 3    /* Delay after XMTR OFF for squelch tail */
  297.  
  298.  
  299. #define OFF    0
  300. #define ON    1
  301.  
  302. /* 8530 clock/frequency  */
  303. #define XTAL    ((long) 6144000)     /* 8530's baud rate clock */
  304.  
  305. /* Special stuff in addition to the stuff in 8530.h */
  306.  
  307. /* Vector Masks for Interrupt vector as read from RR2 Channel B */
  308. /* This are the masks if the part is programed for "status low" */
  309.  
  310. #define    VEC_CHB_TBE        0x00
  311. #define    VEC_CHB_XTS        0x02
  312. #define    VEC_CHB_RCAV    0x04
  313. #define    VEC_CHB_SRC        0x06
  314. #define    VEC_CHA_TBE        0x08
  315. #define    VEC_CHA_XTS        0x0A
  316. #define    VEC_CHA_RCAV    0x0C
  317. #define    VEC_CHA_SRC        0x0E
  318.  
  319.  
  320. /* image copies of i/o control regs */
  321. extern uchar Twin_sercfg;
  322. extern uchar Twin_dmacfg;
  323.  
  324.  
  325. /* The pwait/psignal inter-process communication wake-up array */
  326. /* for getting pre-allocated receive buffers */
  327.  
  328. extern int  Twin_bufpp[];
  329.  
  330.  
  331. /* The pwait/psignal inter-process communication wake-up array */
  332. /* for kicking the transmitter */
  333.  
  334. extern int  Twin_kickpp[];
  335.  
  336. /* The pwait/psignal inter-process communication wake-up array */
  337. /* for free-ing transmitted messages */
  338.  
  339. extern int  Twin_freetxpp[];
  340.  
  341. extern void tsync_rxavget();
  342. extern void tsync_txkick();
  343. extern void tsync_freetx();
  344.  
  345. extern unsigned char Twin_read_scc();
  346. extern void Twin_write_scc();
  347. extern int    tsync_hwinit();
  348. extern int    rxprime_dma();
  349. extern int    tsync_rxdmaisr();
  350.