Ŀ
                                                                      
           Remote I/O Communications Library for Synchronet           
                                                                      
           8250 UART Serial I/O Suboutines in 8086 Assembly           
           High Level C Interface and Functional Definition           
                                                                      



1. int rioini(int com,int irq);  Initialize/Terminate

     com: com port number (1,2,3,4) or UART base address to initialize
          0 to terminate operation
     irq: irq line 1-7 (required if UART base address specified)
          0 for default irq if com port number specified

 returns: 0 if no error
          -1 if called with com=0 without having been initialized
          -1 if called with com>0 while already initialized, or with a com
          port number specified for which there is no BIOS table entry


2. int setbaud(unsigned int rate);

    rate: UART baud rate, a factor of 115,200
          This function must be called at least once after rioini() is used
          to initialize the UART.  Subsequent calls will end an IDLE state.

 returns: 0 if no error
          -1 if UART not initialized


3. int dtr(char n);

       n: 0 turns DTR off and exits
          1 turns DTR on and exits
          2-255 turns DTR off then waits n seconds for DCD off
          If DCD is already off, the routine waits 100ms, then exits

 returns: 0 if no error
          -1 if UART not initialized or timeout


4. int outcom(int outpch);

  outpch: character to output (low byte)
 returns: state (high byte), zero (low byte)


5. int incom(void);
 returns: state (high byte), character from input buffer (low byte)


6. int rioifc(char intcc);
   intcc: defines what interrupts to intercept
 returns: -1 if no action taken, else 0


7. int rioctl(int action);
  action: flags (high byte), function (low byte)



prototypes and equates:
------------------------------------------------------------------------------
int rioini(int com,int irq);          /* initialize com,irq */
int setbaud(unsigned int rate);       /* set baud rate */
int rioctl(int action);               /* remote i/o control */
int dtr(char onoff);                  /* set/reset dtr */
int outcom(int ch);                   /* send character */
int incom(void);                      /* receive character */
int rioifc(char intcode);             /* local i/o redirection */

/* i/o mode and state flags */

#define CTSCK 0x1000    /* check cts (mode only) */
#define TXBOF 0x0800	/* transmit buffer overflow (outcom only) */
#define ABORT 0x0400    /* check for ^C (mode), aborting (state) */
#define PAUSE 0x0200    /* check for ^S (mode), pausing (state) */
#define NOINP 0x0100    /* input buffer empty (incom only) */

/* status flags */

#define DCD 0x80        /* DCD on */
#define RI 0x40		/* ring indication */
#define DSR 0x20	/* DSR on */
#define CTS 0x10        /* CTS on */
#define FMERR 8		/* frame error */
#define PAERR 4		/* parity error */
#define OVRRN 2		/* overrun error */
#define RXLOST 1        /* receive buffer overflow */

/* rioctl() arguments */
/* returns mode or state flags in high 8 bits, status flags in low 8 bits */

                    /* the following return mode in high 8 bits */
#define IOMODE 0        /* no operation */
#define IOSM 1          /* i/o set mode flags */
#define IOCM 2          /* i/o clear mode flags */
                    /* the following return state in high 8 bits */
#define IOSTATE 4       /* no operation */
#define IOSS 5          /* i/o set state flags */
#define IOCS 6          /* i/o clear state flags */
#define IOFB 0x308      /* i/o buffer flush */
#define IOFI 0x208      /* input buffer flush */
#define IOFO 0x108      /* output buffer flush */
#define IOCE 9          /* i/o clear error flags */
		    /* the following return 16-bit integers */
#define RXBC 0xa	/* return receive buffer count */
#define TXBC 0xb	/* return transmit buffer count */
#define TXSYNC 0xc	/* wait 110-165ms for txb empty, return count */
#define IDLE 0xd	/* inhibit local interface */
#define RESUME 0x10d	/* reset from IDLE state */
#define RXERCT 0xe	/* return and reset count of receiver errors */


/* rioifc() arguments */

#define INT29 1         /* copy int 29h output to remote */
#define INT29B 3        /* copy int 29h, use BIOS locally (_putlc) */
#define INT16 0x10      /* return remote chars to int 16h calls */
#define INTCLR 0        /* release int 16h, int 29h */
------------------------------------------------------------------------------
