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

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