|
|
1.1 ! root 1: /* $Header: /kernel/kersrc/coh.286/RCS/clist.c,v 1.1 92/07/17 15:17:59 bin Exp Locker: bin $ */ ! 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 2.3.37 ! 11: * Copyright (c) 1982, 1983, 1984. ! 12: * An unpublished work by Mark Williams Company, Chicago. ! 13: * All rights reserved. ! 14: -lgl) */ ! 15: /* ! 16: * Coherent. ! 17: * Character list management. ! 18: * ! 19: * $Log: clist.c,v $ ! 20: * Revision 1.1 92/07/17 15:17:59 bin ! 21: * Initial revision ! 22: * ! 23: * Revision 1.1 88/03/24 16:13:33 src ! 24: * Initial revision ! 25: * ! 26: */ ! 27: #include <sys/coherent.h> ! 28: #include <clist.h> ! 29: #include <sched.h> ! 30: ! 31: /* ! 32: * Initialise character list queues. ! 33: */ ! 34: cltinit() ! 35: { ! 36: register cmap_t cm; ! 37: register cmap_t lm; ! 38: register paddr_t p; ! 39: register int s; ! 40: cold_t om; ! 41: ! 42: s = sphi(); ! 43: csave(om); ! 44: lm = 0; ! 45: for (p = clistp+NCLIST*sizeof(CLIST); (p-=sizeof(CLIST)) >= clistp; ) { ! 46: cm = cconv(p); ! 47: cmapv(cm); ! 48: cvirt(cm)->cl_fp = lm; ! 49: lm = cm; ! 50: } ! 51: cltfree = lm; ! 52: crest(om); ! 53: spl(s); ! 54: } ! 55: ! 56: /* ! 57: * Get a character from the given queue. ! 58: */ ! 59: getq(cqp) ! 60: register CQUEUE *cqp; ! 61: { ! 62: register cmap_t op; ! 63: register cmap_t np; ! 64: register int ox; ! 65: register int c; ! 66: register int s; ! 67: cold_t om; ! 68: ! 69: if (cqp->cq_cc == 0) ! 70: return (-1); ! 71: s = sphi(); ! 72: op = cqp->cq_op; ! 73: ox = cqp->cq_ox; ! 74: csave(om); ! 75: cmapv(op); ! 76: c = cvirt(op)->cl_ch[ox]&0377; ! 77: crest(om); ! 78: if (--cqp->cq_cc==0 || ++cqp->cq_ox==NCPCL) { ! 79: cqp->cq_ox = 0; ! 80: cmapv(op); ! 81: np = cvirt(op)->cl_fp; ! 82: cvirt(op)->cl_fp = cltfree; ! 83: crest(om); ! 84: cqp->cq_op = np; ! 85: cltfree = op; ! 86: if (np == 0) { ! 87: cqp->cq_ip = 0; ! 88: cqp->cq_ix = 0; ! 89: } ! 90: if (cltwant) { ! 91: cltwant = 0; ! 92: wakeup((char *)&cltwant); ! 93: } ! 94: } ! 95: spl(s); ! 96: return (c); ! 97: } ! 98: ! 99: /* ! 100: * Put a character on the given queue. ! 101: */ ! 102: putq(cqp, c) ! 103: register CQUEUE *cqp; ! 104: { ! 105: register cmap_t ip; ! 106: register int ix; ! 107: register int s; ! 108: register cmap_t np; ! 109: cold_t om; ! 110: ! 111: s = sphi(); ! 112: ip = cqp->cq_ip; ! 113: csave(om); ! 114: if ((ix=cqp->cq_ix) == 0) { ! 115: if ((ip=cltfree) == 0) { ! 116: spl(s); ! 117: return (-1); ! 118: } ! 119: cmapv(ip); ! 120: cltfree = cvirt(ip)->cl_fp; ! 121: cvirt(ip)->cl_fp = 0; ! 122: crest(om); ! 123: if ((np=cqp->cq_ip) == 0) ! 124: cqp->cq_op = ip; ! 125: else { ! 126: cmapv(np); ! 127: cvirt(np)->cl_fp = ip; ! 128: crest(om); ! 129: } ! 130: cqp->cq_ip = ip; ! 131: } ! 132: cmapv(ip); ! 133: cvirt(ip)->cl_ch[ix] = c; ! 134: crest(om); ! 135: if (++cqp->cq_ix == NCPCL) ! 136: cqp->cq_ix = 0; ! 137: cqp->cq_cc++; ! 138: spl(s); ! 139: return (c); ! 140: } ! 141: ! 142: /* ! 143: * Clear a character queue. ! 144: */ ! 145: clrq(cqp) ! 146: register CQUEUE *cqp; ! 147: { ! 148: register int s; ! 149: ! 150: s = sphi(); ! 151: while (getq(cqp) >= 0) ! 152: ; ! 153: spl(s); ! 154: } ! 155: ! 156: /* ! 157: * Wait for more character queues to become available. ! 158: */ ! 159: waitq() ! 160: { ! 161: while (cltfree == 0) { ! 162: cltwant = 1; ! 163: sleep((char *)&cltwant, CVCLIST, IVCLIST, SVCLIST); ! 164: } ! 165: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.