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