Annotation of sbbs/steve/rciol, revision 1.1.1.1

1.1       root        1: 
                      2: rioini(int,int);
                      3:     1st arg: can be 1-4 (com port) or base address, or 0 to terminate
                      4:     2nd arg: can be irq line (presently 1-7) or 0 (com1/3=4, com2/4=3)
                      5:     returns: -1 if error, else 0
                      6: setbaud(int);
                      7:     returns: -1 if rioini() not called first, else 0
                      8: dtr(char);
                      9:     argument: 0 off, 1 on, 2-n off then wait n seconds for dcd off
                     10:     returns: -1 if rioini() not called or timeout, else 0
                     11: outcom(int);
                     12:     argument: character to output (low 8 bits)
                     13:     returns: state (high 8 bits)
                     14: incom(void);
                     15:     returns: character from input buffer (low 8 bits), state (high 8 bits)
                     16: rioctl(int);
                     17:     argument: action (see below)
                     18:     returns: mode or state (high 8 bits), status (low 8 bits)
                     19: rioifc(char);
                     20:     argument: defines what interrupts to intercept (see below)
                     21:     returns: -1 if no action taken, else 0
                     22: 
                     23: 
                     24: prototypes and equates:
                     25: ------------------------------------------------------------------------------
                     26: int rioini(int com,int irq);          /* initialize com,irq */
                     27: int setbaud(int rate);                /* set baud rate */
                     28: int rioctl(int action);               /* remote i/o control */
                     29: int dtr(char onoff);                  /* set/reset dtr */
                     30: int outcom(int ch);                   /* send character */
                     31: int incom(void);                      /* receive character */
                     32: int rioifc(char intcode);             /* local i/o redirection */
                     33: 
                     34: /* i/o mode and state flags */
                     35: 
                     36: #define CTSCK 0x800     /* check cts (mode only) */
                     37: #define ABORT 0x400     /* check for ^C (mode), aborting (state) */
                     38: #define PAUSE 0x200     /* check for ^S (mode), pausing (state) */
                     39: #define NOINP 0x100     /* input buffer empty (incom only) */
                     40: 
                     41: /* status flags */
                     42: 
                     43: #define DCD 0x80        /* DCD on */
                     44: #define CTS 0x10        /* CTS on */
                     45: #define RXLOST 1        /* Receive buffer overflow */
                     46: 
                     47: /* rioctl() arguments */
                     48: /* returns mode or state flags in high 8 bits, status flags in low 8 bits */
                     49: 
                     50:                     /* the following return mode in high 8 bits */
                     51: #define IOMODE 0        /* no operation */
                     52: #define IOSM 1          /* i/o set mode flags */
                     53: #define IOCM 2          /* i/o clear mode flags */
                     54:                     /* the following return state in high 8 bits */
                     55: #define IOSTATE 4       /* no operation */
                     56: #define IOSS 5          /* i/o set state flags */
                     57: #define IOCS 6          /* i/o clear state flags */
                     58: #define IOFB 0x308      /* i/o buffer flush */
                     59: #define IOFI 0x208      /* input buffer flush */
                     60: #define IOFO 0x108      /* output buffer flush */
                     61: #define IOSE 9          /* i/o set error flags */
                     62: 
                     63: /* rioifc() arguments */
                     64: 
                     65: #define INT29 1         /* copy int 29h output to remote */
                     66: #define INT29B 3        /* copy int 29h, use BIOS locally (_putlc) */
                     67: #define INT16 0x10      /* return remote chars to int 16h calls */
                     68: #define INTCLR 0        /* release int 16h, int 29h */
                     69: ------------------------------------------------------------------------------
                     70: You can make whatever permutations of these make things easy, e.g.,
                     71: 
                     72: #define INCHK IOSM|PAUSE|ABORT   /* check for ^C and ^S (mode) */
                     73: #define NOCHK IOCM|PAUSE|ABORT   /* turn off ^C and ^S checking */
                     74: 
                     75: Then rioctl(INCHK); turns checking on, and rioctl(NOCHK); turns it off.
                     76: 
                     77: A sample calling sequence:
                     78: 
                     79:     rioini(3,0);
                     80:     setbaud(2400);
                     81:     rioctl(INCHK);
                     82:     i=incom();
                     83:     if (!i&NOINP) putlc(i);
                     84:     else if (i&ABORT) {
                     85:         rioctl(IOCS|ABORT);  /* reset abort flag */
                     86:         lprintf("YAAA!\n"); }
                     87:     rioifc(INT29B|INT16);
                     88:     spawn(or something);
                     89:     rioifc(INTCLR); /* this puts the original int29/int16 vectors back */
                     90:     rioini(0,0);  /* this puts the original int0b vector back
                     91:                      and will release the irq line */
                     92: 
                     93: Note: incom() returns 500h (not 400h) when in an abort wait, because the
                     94:       input buffer is always cleared.  If output is paused, incom may return
                     95:       2xxh or 300h, depending on whether there is a character in the input
                     96:       buffer.  Pause (200h) and abort (400h) will never be set at the same
                     97:       time.
                     98: 
                     99: No questions, right?  Clear as a sky of azure blue?

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.