home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / TWIN.H < prev    next >
C/C++ Source or Header  |  1994-04-17  |  14KB  |  370 lines

  1.   
  2. /****************************************************************************
  3. *
  4. *            COPYRIGHT 1990,91,92 BY GRACILIS INC.
  5. *
  6. *              623 Palace St.
  7. *            Aurora, Il. 60506
  8. *
  9. * GRACILIS, INC., MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS
  10. * SOFTWARE FOR ANY PURPOSE.
  11. *
  12. * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
  13. *
  14. * Permission is granted for non-commercial distribution only.
  15. *
  16. ******************************************************************************/
  17.   
  18.   
  19.   
  20. /********************************************************************
  21. *                        TWIN.H                                     *
  22. *                                                                   *
  23. * File: twin.h                                                      *
  24. * Rev : 3.0                                                         *
  25. *                                                                   *
  26. *********************************************************************
  27. *
  28. *
  29. * DESCRIPTION:
  30. * -----------
  31. * This section defines PackeTwin card's hardware interface regs etc.
  32. *
  33. *
  34. *
  35. *****************************************************************/
  36. #ifndef _TWIN_H
  37. #define _TWIN_H
  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. /* Gracilis Universal driver control block */
  274. /* UNI_DCB's are declared as an array; each entry is initialized */
  275. /* by an "attach" routine.   */
  276.   
  277. typedef struct udcbblock {
  278.     unsigned char   attached;   /* TRUE then type TenPackSwitch hw is */
  279.                                 /* attached, FALSE it is not attached */
  280.                                 /* MUST BE INITIALIZED TO FALSE */
  281.     char    type;               /* ASYNC_8530, SYNC_8530, */
  282.     void (*prev_vec1)(DCB *);   /* previous vectors, i.e. an address */
  283.     void (*prev_vec2)(DCB *);   /* for the vector's ISR */
  284.     void (*prev_vec3)(DCB *);   /* Allow for up to 4 vectors/channel */
  285.     void (*prev_vec4)(DCB *);
  286.     char *dcbp;                 /* address of driver specific control block */
  287.   
  288. } UNI_DCB;
  289.   
  290. /*
  291.  *  DCB txstate values
  292.  */
  293. #define IDLE                0
  294. #define DEFER               1
  295. #define TX_ACTIVE           2
  296. #define KEYED_UP            3
  297. #define CRCING              4
  298. #define TX_KEYUP_DELAY      5
  299. #define TX_KEYDOWN_DELAY    6
  300. #define TX_PERSIST          7
  301. #define TX_DONE             8
  302.   
  303.   
  304.   
  305. /* Normal state is ACTIVE if Receive enabled */
  306. #define RXNORM 0x55
  307. #define RXERROR 2       /* Error -- Aborting current Frame */
  308. #define RXABORT 3       /* ABORT sequence detected */
  309. #define TOOBIG 4        /* too large a frame to store */
  310. #define TXDELAY 0       /* Transmit Delay 10 ms/cnt */
  311. #define PERSIST 1       /* Persistence (0-255) as a % */
  312. #define SLOTIME 2       /* Delay to wait on persistence hit */
  313. #define SQUELDELAY 3    /* Delay after XMTR OFF for squelch tail */
  314.   
  315.   
  316. #define OFF 0
  317. #define ON  1
  318.   
  319. /* 8530 clock/frequency  */
  320. #define XTAL    ((long) 6144000L)     /* 8530's baud rate clock */
  321.   
  322. /* Special stuff in addition to the stuff in 8530.h */
  323.   
  324. /* Vector Masks for Interrupt vector as read from RR2 Channel B */
  325. /* This are the masks if the part is programed for "status low" */
  326.   
  327. #define VEC_CHB_TBE     0x00
  328. #define VEC_CHB_XTS     0x02
  329. #define VEC_CHB_RCAV    0x04
  330. #define VEC_CHB_SRC     0x06
  331. #define VEC_CHA_TBE     0x08
  332. #define VEC_CHA_XTS     0x0A
  333. #define VEC_CHA_RCAV    0x0C
  334. #define VEC_CHA_SRC     0x0E
  335.   
  336.   
  337. /* image copies of i/o control regs */
  338. extern uchar Twin_sercfg;
  339. extern uchar Twin_dmacfg;
  340.   
  341.   
  342. /* The pwait/psignal inter-process communication wake-up array */
  343. /* for getting pre-allocated receive buffers */
  344.   
  345. extern int  Twin_bufpp[];
  346.   
  347.   
  348. /* The pwait/psignal inter-process communication wake-up array */
  349. /* for kicking the transmitter */
  350.   
  351. extern int  Twin_kickpp[];
  352.   
  353. /* The pwait/psignal inter-process communication wake-up array */
  354. /* for free-ing transmitted messages */
  355.   
  356. extern int  Twin_freetxpp[];
  357.   
  358. void tsync_rxavget __ARGS((int,void *,void *));
  359. void tsync_txkick __ARGS((int,void *,void *));
  360. void tsync_freetx __ARGS((int,void *,void *));
  361.   
  362. unsigned char Twin_read_scc __ARGS((int,char));
  363. void Twin_write_scc __ARGS((int,char,char));
  364. int  tsync_hwinit __ARGS((DCB *));
  365. void rxprime_dma __ARGS((DCB *));
  366. void txprime_dma __ARGS((DCB *));
  367. int  tsync_rxdmaisr __ARGS((DCB *));
  368.   
  369. #endif /* _TWIN_H */
  370.