Annotation of coherent/b/kernel/coh.386/clist.c, revision 1.1.1.1

1.1       root        1: /* $Header: /y/coh.386/RCS/clist.c,v 1.4 93/04/14 10:06:18 root Exp $ */
                      2: /* (lgl-
                      3:  *     The information contained herein is a trade secret of Mark Williams
                      4:  *     Company, and  is confidential information.  It is provided  under a
                      5:  *     license agreement,  and may be  copied or disclosed  only under the
                      6:  *     terms of  that agreement.  Any  reproduction or disclosure  of this
                      7:  *     material without the express written authorization of Mark Williams
                      8:  *     Company or persuant to the license agreement is unlawful.
                      9:  *
                     10:  *     COHERENT Version 5.0
                     11:  *     Copyright (c) 1982, 1983, 1984, 1993.
                     12:  *     An unpublished work by Mark Williams Company, Chicago.
                     13:  *     All rights reserved.
                     14:  -lgl) */
                     15: /*
                     16:  * Coherent.
                     17:  * Character list management.
                     18:  */
                     19: #include <sys/coherent.h>
                     20: #include <sys/clist.h>
                     21: #include <sys/sched.h>
                     22: 
                     23: #define        cvirt(p)        ((CLIST *)(p))
                     24: #ifdef TRACER
                     25: int nclfree = 0;
                     26: #endif
                     27: 
                     28: /*
                     29:  * Initialise character list queues.
                     30:  *
                     31:  * Clist are not mapped.
                     32:  */
                     33: cltinit()
                     34: {
                     35:        register cmap_t cm;
                     36:        register cmap_t lm;
                     37:        register paddr_t p;
                     38:        register int s;
                     39: 
                     40:        s = sphi();
                     41:        lm = 0;
                     42:        for (p = clistp+NCLIST*sizeof(CLIST); (p-=sizeof(CLIST)) >= clistp; ) {
                     43:                cm = p;
                     44:                cvirt(cm)->cl_fp = lm;
                     45:                lm = cm;
                     46:        }
                     47:        cltfree = lm;
                     48: #ifdef TRACER
                     49:        nclfree = NCLIST;
                     50: #endif
                     51:        spl(s);
                     52: }
                     53: 
                     54: /*
                     55:  * Get a character from the given queue.
                     56:  */
                     57: cltgetq(cqp)
                     58: register CQUEUE *cqp;
                     59: {
                     60:        register cmap_t op;
                     61:        register cmap_t np;
                     62:        register int ox;
                     63:        register int c;
                     64:        register int s;
                     65: 
                     66:        if (cqp->cq_cc == 0)
                     67:                return (-1);
                     68:        s = sphi();
                     69:        op = cqp->cq_op;
                     70:        ox = cqp->cq_ox;
                     71:        c = cvirt(op)->cl_ch[ox]&0377;
                     72:        if (--cqp->cq_cc==0 || ++cqp->cq_ox==NCPCL) {
                     73:                cqp->cq_ox = 0;
                     74:                np = cvirt(op)->cl_fp;
                     75:                cvirt(op)->cl_fp = cltfree;
                     76:                cqp->cq_op = np;
                     77:                cltfree = op;
                     78:                if (np == 0) {
                     79:                        cqp->cq_ip = 0;
                     80:                        cqp->cq_ix = 0;
                     81:                }
                     82:                if (cltwant) {
                     83:                        cltwant = 0;
                     84:                        wakeup((char *)&cltwant);
                     85:                }
                     86: #ifdef TRACER
                     87:                T_HAL(0x0040, {nclfree++; printf("F%d ", nclfree);});
                     88: #endif
                     89:        }
                     90:        spl(s);
                     91:        return (c);
                     92: }
                     93: 
                     94: /*
                     95:  * Put a character on the given queue.
                     96:  */
                     97: cltputq(cqp, c)
                     98: register CQUEUE *cqp;
                     99: {
                    100:        register cmap_t ip;
                    101:        register int ix;
                    102:        register int s;
                    103:        register cmap_t np;
                    104: 
                    105:        s = sphi();
                    106:        ip = cqp->cq_ip;
                    107:        if ((ix=cqp->cq_ix) == 0) {
                    108:                if ((ip=cltfree) == 0) {
                    109:                        spl(s);
                    110:                        return (-1);
                    111:                }
                    112:                cltfree = cvirt(ip)->cl_fp;
                    113:                cvirt(ip)->cl_fp = 0;
                    114:                if ((np=cqp->cq_ip) == 0)
                    115:                        cqp->cq_op = ip;
                    116:                else {
                    117:                        cvirt(np)->cl_fp = ip;
                    118:                }
                    119:                cqp->cq_ip = ip;
                    120:                T_HAL(0x0040, { nclfree--; printf("f%d ", nclfree);});
                    121:        }
                    122:        cvirt(ip)->cl_ch[ix] = c;
                    123:        if (++cqp->cq_ix == NCPCL)
                    124:                cqp->cq_ix = 0;
                    125:        cqp->cq_cc++;
                    126:        spl(s);
                    127:        return c;
                    128: }
                    129: 
                    130: /*
                    131:  * Clear a character queue.
                    132:  */
                    133: clrq(cqp)
                    134: register CQUEUE *cqp;
                    135: {
                    136:        register int s;
                    137: 
                    138:        s = sphi();
                    139:        while (cltgetq(cqp) >= 0)
                    140:                ;
                    141:        spl(s);
                    142: }
                    143: 
                    144: /*
                    145:  * Wait for more character queues to become available.
                    146:  */
                    147: waitq()
                    148: {
                    149:        while (cltfree == 0) {
                    150:                T_HAL(0x0080, putchar('+'));
                    151:                cltwant = 1;
                    152:                x_sleep((char *)&cltwant, pritty, slpriNoSig, "waitq");
                    153:                /* Wait for more character queues to become available.  */
                    154:        }
                    155: }

unix.superglobalmegacorp.com

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