home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / pub / wkermit / asic.h next >
C/C++ Source or Header  |  2020-01-01  |  9KB  |  253 lines

  1. /* include for things that use asi buffer structure
  2. */
  3. #define N_ASPORTS 2        /* actual number of ports */
  4. #define MAX_ASPORTS 8
  5. #define max_asbuf_len 32000  /* max buffer size - user selectable */
  6.  
  7. struct AS_FLAGS {
  8.   unsigned alert :  1;        /* alert when 1     */
  9.   unsigned rxempty: 1;        /* Rx Buffer Empty    */
  10.   unsigned rxfull:  1;        /* Rx Buffer Full    */
  11.   unsigned txempty: 1;        /* Tx Buffer Empty    */
  12.   unsigned txfull:  1;        /* Tx Buffer Full    */
  13.   unsigned linerr:  1;        /* line error        */
  14.   unsigned modchg:  1;        /* modem status change    */
  15.   unsigned chkerr:  1;        /* checksum error    */
  16.   unsigned xchrun:  1;        /* transmit interrupts are running */
  17.   unsigned rchrun:  1;        /* receive interrupts are running */
  18.   unsigned igalert: 1;        /* ignore alert     */
  19.   unsigned igcts:   1;        /* ignore CTS        */
  20.   unsigned igdsr:   1;        /* ignore DTR        */
  21.   unsigned igcd:    1;        /* ignore carrier detect CD */
  22.   unsigned igmstat: 1;        /* ignore modem status changes */
  23.   unsigned igrcver: 1;        /* ignore receive errors */
  24.   };
  25.  
  26. /*  L I N E   S T A T U S   B I T S
  27. *
  28. *   These are set by the interrupts and status functions.  asilrst()
  29. *   resets the static portion.
  30. *
  31. *   Use the macros (below) to test individual bits.
  32. */
  33. struct AS_LSTAT {        /* First 8 are dynamic    */
  34.   unsigned dready:  1;        /* Rx data ready    */
  35.   unsigned overrun: 1;        /* Overrun Error    */
  36.   unsigned parerr:  1;        /* Parity Error     */
  37.   unsigned framerr: 1;        /* Framing Error    */
  38.   unsigned breakdet:1;        /* Break Signal Detect    */
  39.   unsigned txhempty:1;        /* Tx Holding Reg Empty */
  40.   unsigned txsempty:1;        /* Tx Shift Reg Empty    */
  41.   unsigned timeout: 1;        /* Timeout (not used)    */
  42.   unsigned sdready: 1;    /* the next 8 are STATIC repeat */
  43.   unsigned soverrun:1;    /*  of the last 8 bits        */
  44.   unsigned sparerr: 1;
  45.   unsigned sframerr: 1;
  46.   unsigned sbreakdet:1;
  47.   unsigned stxhempty:1;
  48.   unsigned stxsempty:1;
  49.   unsigned stimeout: 1;
  50.   };
  51.  
  52. /*  M O D E M    S T A T U S   B I T S
  53. *
  54. *   These are set by the interrupts and status functions.  asimrst() resets
  55. *   the static portion.
  56. *
  57. *   Use macros (below) to read individual bits.
  58. */
  59. struct AS_MSTAT {    /* first 8 are dynamic    */
  60.   unsigned dcts:    1;    /* delta CTS        */
  61.   unsigned ddsr:    1;    /* delta DSR        */
  62.   unsigned teri:    1;    /* trailing edge of RI    */
  63.   unsigned drlsd:   1;    /* delta CD        */
  64.   unsigned cts:     1;    /* CTS            */
  65.   unsigned dsr:     1;    /* DSR            */
  66.   unsigned ri:        1;    /* RI            */
  67.   unsigned rlsd:    1;    /* CD            */
  68.   unsigned sdcts:   1;    /* the next 8 are static */
  69.   unsigned sddsr:   1;    /*  repeats of last 8    */
  70.   unsigned steri:   1;
  71.   unsigned sdrlsd:  1;
  72.   unsigned scts:    1;
  73.   unsigned sdsr:    1;
  74.   unsigned sri:     1;
  75.   unsigned srlsd:   1;
  76.   };
  77.  
  78. struct CHK_FLAGS {
  79.   unsigned no_usef: 7;
  80.   unsigned chk2flg: 1;    /* Check character 2 has been detected */
  81.   unsigned chk1flg: 1;    /* Check character 1 has been detected */
  82.   unsigned chk0flg: 1;    /* Check character 0 has been detected */
  83.   unsigned reserve: 6;    /* Hands off these */
  84. };
  85.  
  86. struct ASITABLE {
  87.     int port;    /* port number 0...    */
  88.     int intnum;    /* interrupt no. 0C...    */
  89.    unsigned ioaddr;    /* base address of 8250 */
  90.    unsigned flags;    /* major status flags    */
  91.    unsigned lstat;    /* line status        */
  92.    unsigned mstat;    /* modem status     */
  93.     int mode;
  94.    unsigned rseg;    /* Rx Buffer segment    */
  95.    unsigned rbob;    /* Beginning of Buf (Rx)*/
  96.    unsigned rpi;    /* Pointer In        (Rx)*/
  97.    unsigned rpo;    /* Pointer Out        (Rx)*/
  98.    int        rsize;    /* size of receive queue */
  99.    int        rfree;    /* free space in receive queue */
  100.    unsigned tseg;    /* Tx Buffer segment    */
  101.    unsigned tbob;    /* Beginning of Buf (Tx)*/
  102.    unsigned tpi;    /* Pointer In        (Tx)*/
  103.    unsigned tpo;    /* Pointer Out        (Tx)*/
  104.    int        tsize;    /* size of transmit queue */
  105.    int        tcnt;    /* number of bytes in transmit queue */
  106.    int        xmcount;    /* count/is rx active    */
  107.    unsigned chkflag;    /* flags for check characters */
  108.    char     chkchr0;    /* Check character 0 */
  109.    char     chkchr1;       /* Check character 1 */
  110.    char     chkchr2;    /* Check character 2 */
  111.    unsigned irq8259;    /* Interrupt # in 8259 (com0 = 4) */
  112.    unsigned port8259;    /* I/O Address of 8259 */
  113.    char not_used[15];    /* Pad to 64 bytes    */
  114.    };
  115.  
  116. /*
  117. *  Structure for Local Parameters for XMODEM functions.
  118. */
  119. struct XMBUF {
  120.   int xblocknum;
  121.   char first;
  122.   int xstatus;
  123.   };
  124.  
  125. /*
  126. *  The next declarations must be exactly as stated.
  127. *
  128. */
  129. extern int n_asi_ports;
  130. extern struct ASITABLE asi_parms[ N_ASPORTS ];
  131. extern int as_intnums[];
  132. extern int as_port[];
  133. extern int _as_wcts;
  134. extern int as_wtime[];
  135. extern int as_rtime[];
  136. extern int as_8259ports[];
  137. extern int as_8259irq[];
  138.  
  139. /*
  140. *  End of mandatory declarations.
  141. */
  142.  
  143. /*
  144. *  Macros to define status and flag bits.
  145. */
  146. /*  T E S T   IF RECEIVER DETECTED A PARTICULAR CHECK CHARACTER
  147. *
  148. *  Use these in conjunction with asirchk().
  149. */
  150. #define ischk2(x)    (asi_parms[x].chkflag&256)?1:0
  151. #define ischk1(x)    (asi_parms[x].chkflag&128)?1:0
  152. #define ischk0(x)    (asi_parms[x].chkflag&64)?1:0
  153.  
  154. /*  F L A G   B I T   T E S T S
  155. *
  156. *  These just test flag bits.  The first 8 are for  general applications,
  157. *  the next 8 are provided for completeness and to test when the system
  158. *  has been told to ignore certain conditions.    Never write into these.
  159. */
  160. #define isalert(x)   (asi_parms[x].flags&1)?1:0
  161. #define isrxempty(x) (asi_parms[x].flags&2)?1:0
  162. #define isrxfull(x)  (asi_parms[x].flags&4)?1:0
  163. #define istxempty(x) (asi_parms[x].flags&8)?1:0
  164. #define istxfull(x)  (asi_parms[x].flags&16)?1:0
  165. #define islnerr(x)   (asi_parms[x].flags&32)?1:0
  166. #define ismderr(x)   (asi_parms[x].flags&64)?1:0
  167. #define isckerr(x)   (asi_parms[x].flags&128)?1:0
  168. #define isxchrun(x)  (asi_parms[x].flags&256)?1:0
  169. #define isrchrun(x)  (asi_parms[x].flags&512)?1:0
  170. #define isigalert(x) (asi_parms[x].flags&1024)?1:0
  171. #define isigcts(x)   (asi_parms[x].flags&2048)?1:0
  172. #define isigdtr(x)   (asi_parms[x].flags&4096)?1:0
  173. #define isigcd(x)    (asi_parms[x].flags&8192)?1:0
  174. #define isigmstat(x) (asi_parms[x].flags&16384)?1:0
  175. #define isigrcver(x) (asi_parms[x].flags&32768)?1:0
  176.  
  177. /* Return DYNAMIC Line Status */
  178. #define isdatardy(x)   (asi_parms[x].lstat&1)?1:0  /* DATA READY    */
  179. #define isoverrun(x)   (asi_parms[x].lstat&2)?1:0  /* OVERRUN ERROR */
  180. #define isparityerr(x) (asi_parms[x].lstat&4)?1:0  /* PARITY ERROR  */
  181. #define isframerr(x)   (asi_parms[x].lstat&8)?1:0  /* FRAMING ERROR */
  182. #define isbreak(x)     (asi_parms[x].lstat&16)?1:0 /* BREAK DETECT  */
  183. #define ishrempty(x)   (asi_parms[x].lstat&32)?1:0 /* TX HOLDING REG */
  184. #define issrempty(x)   (asi_parms[x].lstat&64)?1:0 /* TX SHIFT REG  */
  185. #define istimeout(x)   (asi_parms[x].lstat&128)?1:0 /* NOT USED     */
  186.  
  187. /* Return STATIC Line Status */
  188. #define issdatardy(x)    (asi_parms[x].lstat&256)?1:0
  189. #define issoverrun(x)    (asi_parms[x].lstat&512)?1:0
  190. #define issparityerr(x) (asi_parms[x].lstat&1024)?1:0
  191. #define issframerr(x)    (asi_parms[x].lstat&2048)?1:0
  192. #define issbreak(x)    (asi_parms[x].lstat&4096)?1:0
  193. #define isshrempty(x)    (asi_parms[x].lstat&8192)?1:0
  194. #define isssrempty(x)    (asi_parms[x].lstat&0x4000)?1:0
  195. #define isstimeout(x)    (asi_parms[x].lstat&0x8000)?1:0
  196.  
  197.  
  198. /* Return DYNAMIC Modem Status */
  199. #define ischgcts(x) (asi_parms[x].mstat&1)?1:0
  200. #define ischgdsr(x) (asi_parms[x].mstat&2)?1:0
  201. #define ischgri(x)  (asi_parms[x].mstat&4)?1:0
  202. #define ischgcd(x)  (asi_parms[x].mstat&8)?1:0
  203. #define iscts(x)    (asi_parms[x].mstat&16)?1:0
  204. #define isdsr(x)    (asi_parms[x].mstat&32)?1:0
  205. #define isri(x)     (asi_parms[x].mstat&64)?1:0
  206. #define iscd(x)     (asi_parms[x].mstat&128)?1:0
  207.  
  208. /* Return STATIC Modem Status */
  209. #define isschgcts(x) (asi_parms[x].mstat&256)?1:0
  210. #define isschgdsr(x) (asi_parms[x].mstat&512)?1:0
  211. #define isschgri(x)  (asi_parms[x].mstat&1024)?1:0
  212. #define isschgcd(x)  (asi_parms[x].mstat&2048)?1:0
  213. #define isscts(x)    (asi_parms[x].mstat&4096)?1:0
  214. #define issdsr(x)    (asi_parms[x].mstat&8192)?1:0
  215. #define issri(x)     (asi_parms[x].mstat&0x4000)?1:0
  216. #define isscd(x)     (asi_parms[x].mstat&0x8000)?1:0
  217.  
  218. /* Boolean:  Has receiver gotten one or more characters ? */
  219. #define isxmrxing(x)  (asi_parms[x].xmcount>0)?1:0
  220.  
  221. /* Boolean:  Has receiver gotten a specified number of characters ? */
  222. #define isxmrxcnt(x,y) (asi_parms[x].xmcount>=y)?1:0
  223.  
  224. /*  Misc. definitions
  225. */
  226. #define ASIN 1        /* mode = input */
  227. #define ASOUT 2     /* mode = out    */
  228. #define ASINOUT 3    /* mode = in,out*/
  229. #define ASCIINONE 1    /* protocol = ASCII, no protocol    */
  230. #define ASCIIXM 5    /* protocol = ASCII, XMODEM        */
  231. #define BINARYNONE 2    /* protocol = Binary, no protocol    */
  232. #define BINARYXM 6    /* protocol = Binary XMODEM        */
  233.  
  234. /*  ASCII Protocol Characters
  235. */
  236. #define NUL 0
  237. #define SOH 1
  238. #define STX 2
  239. #define ETX 3
  240. #define EOT 4
  241. #define ACK 6
  242. #define DLE 0x10
  243. #define DC1 0x11
  244. #define DC2 0x12
  245. #define DC3 0x13
  246. #define DC4 0x14
  247. #define NAK 0x15
  248. #define ETB 0x17
  249. #define XON 0x11
  250. #define XOFF 0x13
  251.  
  252.  
  253.