1: # 2: /* 3: */ 4: 5: /* 6: * GP DR11C driver used for C/A/T 7: */ 8: 9: #include <sys/param.h> 10: #include <sys/dir.h> 11: #include <sys/user.h> 12: #include <sys/tty.h> 13: 14: #ifdef UCB_SCCSID 15: static char sccs_id[] = "@(#)cat.c 3.1"; 16: #endif 17: 18: 19: #define CATADDR ((struct catdev *)0167770) 20: #define PCAT (PZERO+9) 21: #define CATHIWAT 100 22: #define CATLOWAT 30 23: 24: struct { 25: int catlock; 26: struct clist oq; 27: } cat; 28: 29: struct catdev { 30: int catcsr; 31: int catbuf; 32: }; 33: 34: ctopen(dev) 35: { 36: if (cat.catlock==0) { 37: cat.catlock++; 38: CATADDR->catcsr |= IENABLE; 39: } else 40: u.u_error = ENXIO; 41: } 42: 43: ctclose() 44: { 45: cat.catlock = 0; 46: catintr(); 47: } 48: 49: ctwrite(dev) 50: { 51: register c; 52: extern lbolt; 53: 54: while ((c=cpass()) >= 0) { 55: spl5(); 56: while (cat.oq.c_cc > CATHIWAT) 57: sleep((caddr_t)&cat.oq, PCAT); 58: while (putc(c, &cat.oq) < 0) 59: sleep((caddr_t)&lbolt, PCAT); 60: catintr(); 61: spl0(); 62: } 63: } 64: 65: catintr() 66: { 67: register int c; 68: 69: if (CATADDR->catcsr&DONE) { 70: if ((c = getc(&cat.oq)) >= 0) { 71: CATADDR->catbuf = c; 72: if (cat.oq.c_cc==0 || cat.oq.c_cc==CATLOWAT) 73: wakeup((caddr_t)&cat.oq); 74: } else { 75: if (cat.catlock==0) 76: CATADDR->catcsr = 0; 77: } 78: } 79: }