home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR3 / KA9Q212.ZIP / DRSI.H < prev    next >
C/C++ Source or Header  |  1993-07-16  |  7KB  |  182 lines

  1. /****************************************************************************
  2. *    $Id: drsi.h 1.2 93/07/16 11:44:10 ROOT_DOS Exp $
  3. *    15 Jul 93    1.2        GT    Fix warnings.                                    *
  4. ****************************************************************************/
  5. #ifndef    _DRSI_H
  6. #define _DRSI_H
  7.  
  8. /* Hardware-dependent routines for the DRSI card for the PC
  9.  * This card contains a Zilog 8530, ZILOG 8536 and a modem.
  10.  */
  11. #ifndef    _GLOBAL_H
  12. #include "global.h"
  13. #endif
  14.  
  15. #ifndef    _MBUF_H
  16. #include "mbuf.h"
  17. #endif
  18.  
  19. #ifndef    _IFACE_H
  20. #include "iface.h"
  21. #endif
  22.  
  23. #define DRMAX    1        /* One card max */
  24. #define AX_MTU    512
  25. #define INTMASK 0x21        /* Intel 8259 interrupt controller mask */
  26.  
  27. struct DRTAB {
  28.         /* Original interrupt vector contents */
  29.     INTERRUPT (*oldvec) __ARGS((void));
  30.     int16 addr;        /* Base I/O address */
  31.     int16 vec;        /* Vector */
  32.     long ints;        /* Interrupt count */
  33. };
  34. extern struct DRTAB drsi[];
  35.  
  36. /* Register offset info, specific to the DRSI
  37.  * E.g., to read the data port on channel A, use
  38.  *    inportb(drchan[dev].base + CHANA + DATA)
  39.  */
  40. #define CHANB        0    /* Base of channel B regs */
  41. #define CHANA        2    /* Base of channel A regs */
  42.  
  43. /* 8530 ports on each channel */
  44. #define CTL    0
  45. #define DATA    1
  46. #define DMACTRL     4    /* Base of channel + 4 */
  47.  
  48. /* 8536 ports */
  49. #define Z8536_MASTER    7    /* 8536 master register offset from BASE */
  50.  
  51. /* Struct used to contain wakeup data */
  52.  
  53. struct dr_wakeup {
  54.     void (*wcall) __ARGS((struct drchan *hp));
  55.     int wakecnt;
  56. };
  57.  
  58. #define RX    0        /* Index into wake array */
  59. #define TX    1        /* ----------""--------- */
  60. struct drchan {
  61.     long rxints;        /* Receiver interrupts */
  62.     long txints;        /* Transmitter interrupts */
  63.     long exints;        /* External/status interrupts */
  64.     long spints;        /* Special receiver interrupts */
  65.  
  66.     long enqueued;        /* Packets actually forwarded */
  67.     long rxframes;        /* Number of Frames Actally Received */
  68.     long toobig;        /* Giant receiver packets */
  69.     long crcerr;        /* CRC Errors */
  70.     long aborts;        /* Receiver aborts */
  71.     long rovers;        /* Receiver Overruns */
  72.     long txdefers;        /* Number of defered transmit attempts */
  73.     long txppersist;    /* Tx attempts defered due to p-persist */
  74.     long nomem;        /* No TX buffer available for local buffer */
  75.     char status;        /* Copy of R0 at last external interrupt */
  76.     struct mbuf *rcvbuf;    /* Buffer for current rx packet */
  77.     int16 bufsiz;        /* Size of rcvbuf */
  78.     char *rcp;        /* Pointer into rcvbuf */
  79.  
  80.     struct mbuf *sndq;    /* Packets awaiting transmission */
  81.     int16 sndcnt;        /* Number of packets on sndq */
  82.     struct mbuf *sndbuf;    /* Current buffer being transmitted */
  83.     int16 drtx_cnt;        /* Number of chars left in local buffer */
  84.     char *drtx_buffer;    /* Local Tx buffer (copy of data buffer) */
  85.     char *drtx_tcp;        /* Pointer into local buffer */
  86.     struct dr_wakeup w[2];    /* One wakeup for Rx and one for Tx */
  87.         /* Tx state machine - state processor */
  88.     void (*tx_state) __ARGS((struct drchan *hp));
  89.         /* Rx state machine - state processor */
  90.     void (*rx_state) __ARGS((struct drchan *hp));
  91.     char tstate;        /* Tranmsitter state */
  92. #define IDLE    0        /* Transmitter off, no data pending */
  93. #define ACTIVE    1        /* Transmitter on, sending data */
  94. #define UNDERRUN 2        /* Transmitter on, flushing CRC */
  95. #define FLAGOUT 3        /* CRC sent - attempt to start next frame */
  96. #define DEFER 4         /* Receive Active - DEFER Transmit */
  97. #define RRTS  5            /* Raise RTS */
  98. #define TFIRST 6        /* Transmit first character */
  99. #define DOWNTX 7        /* Return to receive after ENDDELAY */
  100.     char rstate;        /* Set when !DCD goes to 0 (TRUE) */
  101. /* Normal state is ACTIVE if Receive enabled */
  102. #define RXERROR 2        /* Error -- Aborting current Frame */
  103. #define RXABORT 3        /* ABORT sequence detected */
  104. #define TOOBIG 4        /* too large a frame to store */
  105. #define ENABLE 5        /* Enable RX */
  106.     int16 dev;        /* Device number */
  107.     int16 base;        /* Base of I/O registers */
  108.     int16 stata;        /* address of Channel A status regs */
  109.     int16 statb;        /* address of Channel B status regs */
  110.     int16 dmactrl;        /* address of DMA/INTERRUPT reg on card */
  111.     int16 speed;        /* Line speed, bps */
  112.     int txdelay;        /* Transmit Delay 10 ms/cnt */
  113.     int persist;        /* Persistence (0-255) as a % */
  114.     int slotime;        /* Delay to wait on persistence hit */
  115.     int squeldelay;        /* Delay after XMTR OFF for seuelch tail */
  116.     int enddelay;        /* Hold up after sending last char in frame */
  117.     struct iface *iface;    /* Associated interface */
  118. };
  119. extern struct drchan drchan[];
  120.  
  121. /* In drsi.c: */
  122. void drint __ARGS((int dev));
  123.  
  124. /* Interrupt vector handlers (assembler) in drsivec.asm */
  125. INTERRUPT dr0vec __ARGS((void));
  126.  
  127.  
  128. #define OFF    0
  129. #define ON    1
  130. #define INIT    2
  131.  
  132. /* 8530 clock speed */
  133.  
  134. #define XTAL    ((long) 4915200L/2L)     /* 32X clock constant */
  135.  
  136. /*************************************************************/
  137. /* TEMP FOR DEBUG ONLY - eliminates Divide by zero interrupt */
  138. /*               - preset for 1200 BAUD !!!!!!!!!!!!!! */
  139. /*************************************************************/
  140. #define TXCONST 2046    /* (XTAL/1200L)-2 */
  141. #define RXCONST 62    /* ((XTAL/32)/1200L)-2 */
  142.  
  143.  
  144. /* Baud rate generator definitions */
  145. struct baudrate {
  146.     int16 speed;
  147.     char val;
  148. };
  149.  
  150.  
  151. /* 8536 register definitions */
  152.  
  153. #define Z8536_MICR  0x00    /* Master interrupt control register */
  154. #define Z8536_MCCR  0x01    /* Master configuration control register */
  155. #define Z8536_CTMS1 0x1c    /* Counter/timer mode specification #1 */
  156. #define Z8536_CTMS2 0x1d    /* Counter/timer mode specification #2 */
  157. #define Z8536_CTMS3 0x1e    /* Counter/timer mode specification #3 */
  158. #define Z8536_IVR   0x04    /* Interrupt vector register */
  159.  
  160. #define Z8536_CSR1  0x0a    /* Command and status register CTC #1 */
  161. #define Z8536_CSR2  0x0b    /* Command and status register CTC #2 */
  162. #define Z8536_CSR3  0x0c    /* Command and status register CTC #3 */
  163.  
  164. #define Z8536_CC3LSB 0x15    /* CTC #3 Current count - LSB  */
  165.  
  166. #define    Z8536_CT1MSB 0x16    /* CTC #1 Timer constant - MSB */
  167. #define    Z8536_CT1LSB 0x17    /* CTC #1 Timer constant - LSB */
  168. #define    Z8536_CT2MSB 0x18    /* CTC #2 Timer constant - MSB */
  169. #define    Z8536_CT2LSB 0x19    /* CTC #2 Timer constant - LSB */
  170. #define    Z8536_CT3MSB 0x1a    /* CTC #3 Timer constant - MSB */
  171. #define    Z8536_CT3LSB 0x1b    /* CTC #3 Timer constant - LSB */
  172. #define Z8536_PDCA   0x23    /* Port A data direction control */
  173. #define Z8536_PDCB   0x2b    /* Port B data direction control */
  174.  
  175. #define Z_GCB        0x04    /* CTC Gate command bit */
  176. #define Z_TCB        0x02    /* CTC Trigger command bit */
  177. #define Z_IE        0xc0    /* CTC Interrupt enable (set) */
  178. #define Z_CIP        0x20    /* CTC Clear interrupt pending */
  179. #define Z_IP        0x20    /* CTC Interrupt pending */
  180.  
  181. #endif    /* _DRSI_H */
  182.