| plan 9 kernel history: overview | file list | diff list |
1990/0321/gnot/devdk.c (diff list | history)
| 1990/0312/sys/src/9/gnot/devdk.c:287,293 – 1990/0315/sys/src/9/gnot/devdk.c:287,293 (short | long) | ||
| 1990/0312 | line = bp->rptr[0] | (bp->rptr[1]<<8); bp->rptr += 2; if(line<0 || line>=dp->lines){ | |
| 1990/0315 | DPRINT("dkmuxiput bad line %d\n", line); | |
| 1990/0312 | freeb(bp); return; } | |
| 1990/0312/sys/src/9/gnot/devdk.c:297,308 – 1990/0315/sys/src/9/gnot/devdk.c:297,308 | ||
| 1990/0312 | if(lp->rq) PUTNEXT(lp->rq, bp); else{ | |
| 1990/0315 | DPRINT("dkmuxiput unopened line %d\n", line); | |
| 1990/0312 | freeb(bp); } qunlock(lp); } else { | |
| 1990/0315 | DPRINT("dkmuxiput unopened line %d\n", line); | |
| 1990/0312 | freeb(bp); } } | |
| 1990/0312/sys/src/9/gnot/devdk.c:412,417 – 1990/0315/sys/src/9/gnot/devdk.c:412,419 | ||
| 1990/0312 | if(bp->base && bp->rptr - bp->base >= 2) bp->rptr -= 2; | |
| 1990/0315 | else panic("dkoput"); | |
| 1990/0312 | bp->rptr[0] = line; bp->rptr[1] = line>>8; | |
| 1990/0312/sys/src/9/gnot/devdk.c:574,580 – 1990/0315/sys/src/9/gnot/devdk.c:576,581 | ||
| 1990/0312 | { Chan *c; Dk *dp; | |
| 1990/0312/sys/src/9/gnot/devdk.c:581,587 – 1990/0315/sys/src/9/gnot/devdk.c:582,587 | ||
| 1990/0312 | */ for(dp = dk; dp < &dk[Ndk]; dp++){ qlock(dp); | |
| 1990/0312/sys/src/9/gnot/devdk.c:593,599 – 1990/0315/sys/src/9/gnot/devdk.c:593,598 | ||
| 1990/0312 | error(0, Enoifc); c = devattach('k', spec); c->dev = dp - dk; | |
| 1990/0312/sys/src/9/gnot/devdk.c:1115,1127 – 1990/0315/sys/src/9/gnot/devdk.c:1114,1126 | ||
| 1990/0312 | * for the call to come in on). */ if(!canqlock(lp)){ | |
| 1990/0315 | DPRINT("DKbusy1\n"); | |
| 1990/0312 | dkanswer(c, lineno, DKbusy); continue; } else { if(lp->state != Lclosed){ qunlock(lp); | |
| 1990/0315 | DPRINT("DKbusy2 %ux\n", lp->state); | |
| 1990/0312 | dkanswer(c, lineno, DKbusy); continue; } | |
| 1990/0315/sys/src/9/gnot/devdk.c:644,651 – 1990/0319/sys/src/9/gnot/devdk.c:644,658 (short | long) | ||
| 1990/0312 | Dk *dp; int line; | |
| 1990/0319 | if(c->qid & CHDIR){ | |
| 1990/0312 | /* | |
| 1990/0319 | * directories are read only */ if(omode != OREAD) error(0, Ebadarg); } else switch(STREAMTYPE(c->qid)){ case Dcloneqid: /* | |
| 1990/0312 | * get an unused device and open it's control file */ dp = &dk[c->dev]; | |
| 1990/0315/sys/src/9/gnot/devdk.c:665,671 – 1990/0319/sys/src/9/gnot/devdk.c:672,679 | ||
| 1990/0312 | error(0, Enodev); streamopen(c, &dkinfo); pushq(c->stream, &urpinfo); | |
| 1990/0319 | break; case Dlistenqid: | |
| 1990/0312 | /* * listen for a call and open the control file for the * channel on which the call arrived. | |
| 1990/0315/sys/src/9/gnot/devdk.c:675,687 – 1990/0319/sys/src/9/gnot/devdk.c:683,707 | ||
| 1990/0312 | streamopen(c, &dkinfo); pushq(c->stream, &urpinfo); dkwindow(c); | |
| 1990/0319 | break; case Daddrqid: case Draddrqid: case Duserqid: case Dotherqid: | |
| 1990/0312 | /* | |
| 1990/0319 | * read only files */ if(omode != OREAD) error(0, Ebadarg); break; default: /* | |
| 1990/0312 | * open whatever c points to, make sure it has an urp */ streamopen(c, &dkinfo); if(strcmp(c->stream->procq->next->info->name, "urp")!=0) pushq(c->stream, &urpinfo); | |
| 1990/0319 | break; | |
| 1990/0312 | } c->mode = openmode(omode); | |
| 1990/0315/sys/src/9/gnot/devdk.c:702,708 – 1990/0319/sys/src/9/gnot/devdk.c:722,728 | ||
| 1990/0312 | Dk *dp; /* real closing happens in lancestclose */ | |
| 1990/0319 | if(c->stream) | |
| 1990/0312 | streamclose(c); dp = &dk[c->dev]; | |
| 1990/0315/sys/src/9/gnot/devdk.c:714,730 – 1990/0319/sys/src/9/gnot/devdk.c:734,753 | ||
| 1990/0312 | long dkread(Chan *c, void *a, long n) { | |
| 1990/0319 | if(c->stream) | |
| 1990/0312 | return streamread(c, a, n); | |
| 1990/0319 | if(c->qid & CHDIR){ if(c->qid == CHDIR) return devdirread(c, a, n, dkdir, dk[c->dev].lines, devgen); else return devdirread(c, a, n, dksubdir, Nsubdir, streamgen); } | |
| 1990/0312 | lp = &dk[c->dev].line[STREAMID(c->qid)]; | |
| 1990/0319 | switch(STREAMTYPE(c->qid)){ | |
| 1990/0312 | case Daddrqid: return stringread(c, a, n, lp->addr); case Draddrqid: | |
| 1990/0315/sys/src/9/gnot/devdk.c:781,789 – 1990/0319/sys/src/9/gnot/devdk.c:804,809 | ||
| 1990/0312 | return streamwrite(c, a, n, 0); return n; } | |
| 1990/0319/sys/src/9/gnot/devdk.c:538,543 – 1990/0321/sys/src/9/gnot/devdk.c:538,545 (short | long) | ||
| 1990/0312 | void dkreset(void) { | |
| 1990/0321 | newqinfo(&dkmuxinfo); newqinfo(&urpinfo); | |
| 1990/0312 | } /* | |
| 1990/0321/sys/src/9/gnot/devdk.c:417,423 – 1990/0331/sys/src/9/gnot/devdk.c:417,427 (short | long) | ||
| 1990/0312 | bp->rptr[0] = line; bp->rptr[1] = line>>8; | |
| 1990/0331 | if(dp->wq->len >= Streamhi){ print("dkoput free\n"); freeb(bp); } else PUTNEXT(dp->wq, bp); | |
| 1990/0312 | } /* | |
| 1990/0331/sys/src/9/gnot/devdk.c:417,427 – 1990/0403/sys/src/9/gnot/devdk.c:417,423 (short | long) | ||
| 1990/0312 | bp->rptr[0] = line; bp->rptr[1] = line>>8; | |
| 1990/0331 |
| |
| 1990/0403 | PUTNEXT(dp->wq, bp); | |
| 1990/0312 | } /* | |
| 1990/0331/sys/src/9/gnot/devdk.c:1132,1137 – 1990/0403/sys/src/9/gnot/devdk.c:1128,1135 | ||
| 1990/0312 | */ if(ts == lp->timestamp){ print("dklisten: repeat timestamp %d\n", lineno); | |
| 1990/0403 | if(lp->state != Lconnected) dkanswer(c, lineno, DKbusy); | |
| 1990/0312 | continue; } | |
| 1990/0403/sys/src/9/gnot/devdk.c:329,334 – 1990/05313/sys/src/9/gnot/devdk.c:329,336 (short | long) | ||
| 1990/0312 | q->other->ptr = q->ptr = lp = &dp->line[s->id]; lp->dp = dp; lp->rq = q; | |
| 1990/05313 | if(lp->state == Lclosed) lp->state = Lopened; | |
| 1990/0312 | } /* | |
| 1990/0403/sys/src/9/gnot/devdk.c:417,423 – 1990/05313/sys/src/9/gnot/devdk.c:419,429 | ||
| 1990/0312 | bp->rptr[0] = line; bp->rptr[1] = line>>8; | |
| 1990/0403 |
| |
| 1990/05313 | if(QFULL(dp->wq->next)){ print("dk wq full\n"); freeb(bp); } else PUTNEXT(dp->wq, bp); | |
| 1990/0312 | } /* | |
| 1990/0403/sys/src/9/gnot/devdk.c:666,672 – 1990/05313/sys/src/9/gnot/devdk.c:672,677 | ||
| 1990/0312 | continue; } c->qid = STREAMQID(lp-dp->line, Sctlqid); | |
| 1990/0403/sys/src/9/gnot/devdk.c:674,679 – 1990/05313/sys/src/9/gnot/devdk.c:679,685 | ||
| 1990/0312 | error(0, Enodev); streamopen(c, &dkinfo); pushq(c->stream, &urpinfo); | |
| 1990/05313 | qunlock(lp); | |
| 1990/0319 | break; case Dlistenqid: | |
| 1990/0312 | /* | |
| 1990/0403/sys/src/9/gnot/devdk.c:723,729 – 1990/05313/sys/src/9/gnot/devdk.c:729,735 | ||
| 1990/0312 | { Dk *dp; | |
| 1990/05313 | /* real closing happens in dkstclose */ | |
| 1990/0319 | if(c->stream) | |
| 1990/0312 | streamclose(c); | |
| 1990/0403/sys/src/9/gnot/devdk.c:895,901 – 1990/05313/sys/src/9/gnot/devdk.c:901,907 | ||
| 1990/0312 | /* * only dial on virgin lines */ | |
| 1990/05313 | if(lp->state != Lopened) | |
| 1990/0312 | error(0, Ebadarg); DPRINT("dkcall(line=%d, type=%d, dest=%s)\n", line, type, addr); | |
| 1990/0403/sys/src/9/gnot/devdk.c:1198,1203 – 1990/05313/sys/src/9/gnot/devdk.c:1204,1210 | ||
| 1990/0312 | DPRINT("dklisten returns %d\n", lineno); return lineno; } | |
| 1990/05313 | panic("dklisten terminates strangely\n"); | |
| 1990/0312 | } /* | |
| 1990/05313/sys/src/9/gnot/devdk.c:66,72 – 1990/0617/sys/src/9/gnot/devdk.c:66,72 (short | long) | ||
| 1990/0312 | #define D_OK 1 /* not used */ #define D_OPEN 2 /* (dkmux to host) connection established */ #define D_FAIL 3 /* (dkmux to host) connection failed */ | |
| 1990/0617 | #define T_CHG 3 /* change the status of a connection */ | |
| 1990/0312 | #define D_CLOSE 1 /* close the connection */ #define D_ISCLOSED 2 /* (dkmux to host) confirm a close */ #define D_CLOSEALL 3 /* (dkmux to host) close all connections */ | |
| 1990/05313/sys/src/9/gnot/devdk.c:1003,1009 – 1990/0617/sys/src/9/gnot/devdk.c:1003,1009 | ||
| 1990/0312 | } /* | |
| 1990/0617 | * change state if serving | |
| 1990/0312 | */ if(type == D_SERV){ lp->state = Llistening; | |
| 1990/05313/sys/src/9/gnot/devdk.c:1075,1081 – 1990/0617/sys/src/9/gnot/devdk.c:1075,1083 | ||
| 1990/0312 | n = streamread(dc, dialstr, sizeof(dialstr)-1); DPRINT("returns %d\n", n); if(n <= 0) | |
| 1990/0617 | {print("bad n\n"); | |
| 1990/0312 | error(0, Eio); | |
| 1990/0617 | } | |
| 1990/0312 | dialstr[n] = 0; DPRINT("dialstr = %s\n", dialstr); | |
| 1990/05313/sys/src/9/gnot/devdk.c:1085,1090 – 1990/0617/sys/src/9/gnot/devdk.c:1087,1093 | ||
| 1990/0312 | n = getfields(dialstr, line, 12, '\n'); if (n < 2) { DPRINT("bad dialstr from dk (1 line)\n"); | |
| 1990/0617 | print("bad dialstr %d '%s'\n", n, dialstr); | |
| 1990/0312 | error(0, Eio); } | |
| 1990/05313/sys/src/9/gnot/devdk.c:1289,1294 – 1990/0617/sys/src/9/gnot/devdk.c:1292,1302 | ||
| 1990/0312 | int i; dp = (Dk *)a; | |
| 1990/0617 | /* * tell datakit we've rebooted. It should close all channels. */ dkmesg(dp, T_CHG, D_CLOSEALL, 0, 0); | |
| 1990/0312 | /* * loop forever listening | |
| 1990/0617/sys/src/9/gnot/devdk.c:123,128 – 1990/0707/sys/src/9/gnot/devdk.c:123,129 (short | long) | ||
| 1990/0312 | int ncsc; /* csc line number */ Chan *csc; /* common signalling line */ Line line[Nline]; | |
| 1990/0707 | int restart; | |
| 1990/0312 | }; static Dk dk[Ndk]; | |
| 1990/0617/sys/src/9/gnot/devdk.c:427,436 – 1990/0707/sys/src/9/gnot/devdk.c:428,438 | ||
| 1990/0312 | } /* | |
| 1990/0707 | * configure a datakit multiplexor. this takes 4 arguments separated | |
| 1990/0312 | * by spaces: * the line number of the common signalling channel (must be > 0) * the number of lines in the device (optional) | |
| 1990/0707 | * the word `restart' or `norestart' (optional/default==restart) | |
| 1990/0312 | * the name of the dk (optional) * * we can configure only once | |
| 1990/0617/sys/src/9/gnot/devdk.c:439,445 – 1990/0707/sys/src/9/gnot/devdk.c:441,447 | ||
| 1990/0312 | dkmuxconfig(Dk *dp, Block *bp) { Chan *c; | |
| 1990/0707 | char *fields[4]; | |
| 1990/0312 | int n; char buf[64]; static int dktimeron; | |
| 1990/0617/sys/src/9/gnot/devdk.c:452,461 – 1990/0707/sys/src/9/gnot/devdk.c:454,467 | ||
| 1990/0312 | /* * parse */ | |
| 1990/0707 | dp->restart = 1; n = getfields((char *)bp->rptr, fields, 4, ' '); | |
| 1990/0312 | switch(n){ | |
| 1990/0707 | case 4: strncpy(dp->name, fields[3], sizeof(dp->name)); | |
| 1990/0312 | case 3: | |
| 1990/0707 | if(strcmp(fields[2], "restart")!=0) dp->restart = 0; | |
| 1990/0312 | case 2: dp->lines = strtoul(fields[1], 0, 0); case 1: | |
| 1990/0617/sys/src/9/gnot/devdk.c:893,898 – 1990/0707/sys/src/9/gnot/devdk.c:899,905 | ||
| 1990/0312 | Dk *dp; Line *lp; Chan *dc; | |
| 1990/0707 | char *bang, *dot; | |
| 1990/0312 | line = STREAMID(c->qid); dp = &dk[c->dev]; | |
| 1990/0617/sys/src/9/gnot/devdk.c:907,913 – 1990/0707/sys/src/9/gnot/devdk.c:914,922 | ||
| 1990/0312 | DPRINT("dkcall(line=%d, type=%d, dest=%s)\n", line, type, addr); /* | |
| 1990/0707 | * build dial string * - guard against new lines * - change ! into . to delimit service | |
| 1990/0312 | */ if(strchr(addr, '\n')) error(0, Ebadarg); | |
| 1990/0617/sys/src/9/gnot/devdk.c:914,919 – 1990/0707/sys/src/9/gnot/devdk.c:923,934 | ||
| 1990/0312 | if(strlen(addr)+strlen(u->p->pgrp->user)+2 >= sizeof(dialstr)) error(0, Ebadarg); strcpy(dialstr, addr); | |
| 1990/0707 | bang = strchr(dialstr, '!'); if(bang){ dot = strchr(dialstr, '.'); if(dot==0 || dot > bang) *bang = '.'; } | |
| 1990/0312 | switch(type){ case Dial: t_val = T_SRV; | |
| 1990/0617/sys/src/9/gnot/devdk.c:1296,1301 – 1990/0707/sys/src/9/gnot/devdk.c:1311,1318 | ||
| 1990/0617 | /* * tell datakit we've rebooted. It should close all channels. */ | |
| 1990/0707 | if(dp->restart) dkmesg(dp, T_ALIVE, D_RESTART, 0, 0); | |
| 1990/0617 | dkmesg(dp, T_CHG, D_CLOSEALL, 0, 0); | |
| 1990/0312 | /* | |
| 1990/0707/sys/src/9/gnot/devdk.c:551,557 – 1990/0717/sys/src/9/gnot/devdk.c:551,557 (short | long) | ||
| 1990/0312 | dkreset(void) { | |
| 1990/0321 | newqinfo(&dkmuxinfo); | |
| 1990/0717 | urpreset(); | |
| 1990/0312 | } /* | |
| 1990/0717/sys/src/9/gnot/devdk.c:456,461 – 1990/0725/sys/src/9/gnot/devdk.c:456,462 (short | long) | ||
| 1990/0312 | */ | |
| 1990/0707 | dp->restart = 1; n = getfields((char *)bp->rptr, fields, 4, ' '); | |
| 1990/0725 | strcpy(dp->name, "dk"); | |
| 1990/0312 | switch(n){ | |
| 1990/0707 | case 4: strncpy(dp->name, fields[3], sizeof(dp->name)); | |
| 1990/0717/sys/src/9/gnot/devdk.c:494,500 – 1990/0725/sys/src/9/gnot/devdk.c:495,501 | ||
| 1990/0312 | /* * start a process to deal with it */ | |
| 1990/0725 | sprint(buf, "csckproc%d", dp->ncsc); | |
| 1990/0312 | kproc(buf, dkcsckproc, dp); poperror(); | |
| 1990/0717/sys/src/9/gnot/devdk.c:503,509 – 1990/0725/sys/src/9/gnot/devdk.c:504,510 | ||
| 1990/0312 | */ if(dktimeron == 0){ dktimeron = 1; | |
| 1990/0725 | kproc("dktimer", dktimer, 0); | |
| 1990/0312 | } } | |
| 1990/0717/sys/src/9/gnot/devdk.c:592,599 – 1990/0725/sys/src/9/gnot/devdk.c:593,602 | ||
| 1990/0312 | Dk *dp; /* | |
| 1990/0725 | * find a multiplexor with the same name (default dk) | |
| 1990/0312 | */ | |
| 1990/0725 | if(*spec == 0) spec = "dk"; | |
| 1990/0312 | for(dp = dk; dp < &dk[Ndk]; dp++){ qlock(dp); if(dp->wq && strcmp(spec, dp->name)==0) { | |
| 1990/0725/sys/src/9/gnot/devdk.c:456,462 – 1990/0726/sys/src/9/gnot/devdk.c:456,461 (short | long) | ||
| 1990/0312 | */ | |
| 1990/0707 | dp->restart = 1; n = getfields((char *)bp->rptr, fields, 4, ' '); | |
| 1990/0725 |
| |
| 1990/0312 | switch(n){ | |
| 1990/0707 | case 4: strncpy(dp->name, fields[3], sizeof(dp->name)); | |
| 1990/0725/sys/src/9/gnot/devdk.c:495,501 – 1990/0726/sys/src/9/gnot/devdk.c:494,500 | ||
| 1990/0312 | /* * start a process to deal with it */ | |
| 1990/0725 |
| |
| 1990/0726 | sprint(buf, "**csckproc%d**", dp->ncsc); | |
| 1990/0312 | kproc(buf, dkcsckproc, dp); poperror(); | |
| 1990/0725/sys/src/9/gnot/devdk.c:504,510 – 1990/0726/sys/src/9/gnot/devdk.c:503,509 | ||
| 1990/0312 | */ if(dktimeron == 0){ dktimeron = 1; | |
| 1990/0725 |
| |
| 1990/0726 | kproc("**dktimer**", dktimer, 0); | |
| 1990/0312 | } } | |
| 1990/0725/sys/src/9/gnot/devdk.c:593,602 – 1990/0726/sys/src/9/gnot/devdk.c:592,599 | ||
| 1990/0312 | Dk *dp; /* | |
| 1990/0725 |
| |
| 1990/0726 | * find a multiplexor with the same name | |
| 1990/0312 | */ | |
| 1990/0725 |
| |
| 1990/0312 | for(dp = dk; dp < &dk[Ndk]; dp++){ qlock(dp); if(dp->wq && strcmp(spec, dp->name)==0) { | |
| 1990/0726/sys/src/9/gnot/devdk.c:456,461 – 1990/0728/sys/src/9/gnot/devdk.c:456,462 (short | long) | ||
| 1990/0312 | */ | |
| 1990/0707 | dp->restart = 1; n = getfields((char *)bp->rptr, fields, 4, ' '); | |
| 1990/0728 | strcpy(dp->name, "dk"); | |
| 1990/0312 | switch(n){ | |
| 1990/0707 | case 4: strncpy(dp->name, fields[3], sizeof(dp->name)); | |
| 1990/0726/sys/src/9/gnot/devdk.c:494,500 – 1990/0728/sys/src/9/gnot/devdk.c:495,501 | ||
| 1990/0312 | /* * start a process to deal with it */ | |
| 1990/0726 |
| |
| 1990/0728 | sprint(buf, "csckproc%d", dp->ncsc); | |
| 1990/0312 | kproc(buf, dkcsckproc, dp); poperror(); | |
| 1990/0726/sys/src/9/gnot/devdk.c:503,509 – 1990/0728/sys/src/9/gnot/devdk.c:504,510 | ||
| 1990/0312 | */ if(dktimeron == 0){ dktimeron = 1; | |
| 1990/0726 |
| |
| 1990/0728 | kproc("dktimer", dktimer, 0); | |
| 1990/0312 | } } | |
| 1990/0726/sys/src/9/gnot/devdk.c:592,599 – 1990/0728/sys/src/9/gnot/devdk.c:593,602 | ||
| 1990/0312 | Dk *dp; /* | |
| 1990/0726 |
| |
| 1990/0728 | * find a multiplexor with the same name (default dk) | |
| 1990/0312 | */ | |
| 1990/0728 | if(*spec == 0) spec = "dk"; | |
| 1990/0312 | for(dp = dk; dp < &dk[Ndk]; dp++){ qlock(dp); if(dp->wq && strcmp(spec, dp->name)==0) { | |
| 1990/0726/sys/src/9/gnot/devdk.c:859,866 – 1990/0728/sys/src/9/gnot/devdk.c:862,871 | ||
| 1990/0312 | if(dp->csc == 0) return -1; | |
| 1990/0728 | if(waserror()){ print("dkmesg: error\n"); | |
| 1990/0312 | return -1; | |
| 1990/0728 | } | |
| 1990/0312 | d.type = type; d.srv = srv; d.param0l = p0; | |
| 1990/0726/sys/src/9/gnot/devdk.c:1477,1483 – 1990/0728/sys/src/9/gnot/devdk.c:1482,1489 | ||
| 1990/0312 | Dk *dp; Line *lp; | |
| 1990/0728 | while(waserror()) print("dktimer: error\n"); | |
| 1990/0312 | for(;;){ /* | |
| 1990/0728/sys/src/9/gnot/devdk.c:6,14 – 1990/08101/sys/src/9/gnot/devdk.c:6,15 (short | long) | ||
| 1990/0312 | #include "io.h" #include "errno.h" | |
| 1990/08101 | #define DPRINT if(0) /*kprint*/ | |
| 1990/0312 | ||
| 1990/08101 | #define NOW (MACHP(0)->ticks) | |
| 1990/0312 | enum { /* * configuration parameters | |
| 1990/0728/sys/src/9/gnot/devdk.c:477,482 – 1990/08101/sys/src/9/gnot/devdk.c:478,485 | ||
| 1990/0312 | dp->lines = 16; error(0, Ebadarg); } | |
| 1990/08101 | DPRINT("dkmuxconfig: ncsc=%d, lines=%d, restart=%d, name=\"%s\"\n", dp->ncsc, dp->lines, dp->restart, dp->name); | |
| 1990/0312 | /* * open a stream for the csc and push urp onto it | |
| 1990/0728/sys/src/9/gnot/devdk.c:495,501 – 1990/08101/sys/src/9/gnot/devdk.c:498,504 | ||
| 1990/0312 | /* * start a process to deal with it */ | |
| 1990/0728 |
| |
| 1990/08101 | sprint(buf, "csc.%s.%d", dp->name, dp->ncsc); | |
| 1990/0312 | kproc(buf, dkcsckproc, dp); poperror(); | |
| 1990/0728/sys/src/9/gnot/devdk.c:1316,1323 – 1990/08101/sys/src/9/gnot/devdk.c:1319,1329 | ||
| 1990/0617 | /* * tell datakit we've rebooted. It should close all channels. */ | |
| 1990/0707 |
| |
| 1990/08101 | if(dp->restart) { DPRINT("dkcsckproc: restart %s\n", dp->name); | |
| 1990/0707 | dkmesg(dp, T_ALIVE, D_RESTART, 0, 0); | |
| 1990/08101 | } DPRINT("dkcsckproc: closeall %s\n", dp->name); | |
| 1990/0617 | dkmesg(dp, T_CHG, D_CLOSEALL, 0, 0); | |
| 1990/0312 | /* | |
| 1990/08101/sys/src/9/gnot/devdk.c:125,130 – 1990/08163/sys/src/9/gnot/devdk.c:125,131 (short | long) | ||
| 1990/0312 | Chan *csc; /* common signalling line */ Line line[Nline]; | |
| 1990/0707 | int restart; | |
| 1990/08163 | int urpwindow; | |
| 1990/0312 | }; static Dk dk[Ndk]; | |
| 1990/08101/sys/src/9/gnot/devdk.c:429,440 – 1990/08163/sys/src/9/gnot/devdk.c:430,442 | ||
| 1990/0312 | } /* | |
| 1990/0707 |
| |
| 1990/08163 | * configure a datakit multiplexor. this takes 5 arguments separated | |
| 1990/0312 | * by spaces: * the line number of the common signalling channel (must be > 0) * the number of lines in the device (optional) | |
| 1990/0707 | * the word `restart' or `norestart' (optional/default==restart) | |
| 1990/0312 |
| |
| 1990/08163 | * the name of the dk (default==dk) * the urp window size (default==WS_2K) | |
| 1990/0312 | * * we can configure only once */ | |
| 1990/08101/sys/src/9/gnot/devdk.c:442,448 – 1990/08163/sys/src/9/gnot/devdk.c:444,450 | ||
| 1990/0312 | dkmuxconfig(Dk *dp, Block *bp) { Chan *c; | |
| 1990/0707 |
| |
| 1990/08163 | char *fields[5]; | |
| 1990/0312 | int n; char buf[64]; static int dktimeron; | |
| 1990/08101/sys/src/9/gnot/devdk.c:456,464 – 1990/08163/sys/src/9/gnot/devdk.c:458,469 | ||
| 1990/0312 | * parse */ | |
| 1990/0707 | dp->restart = 1; | |
| 1990/08163 | n = getfields((char *)bp->rptr, fields, 5, ' '); | |
| 1990/0728 | strcpy(dp->name, "dk"); | |
| 1990/08163 | dp->urpwindow = WS_2K; | |
| 1990/0312 | switch(n){ | |
| 1990/08163 | case 5: dp->urpwindow = strtoul(fields[4], 0, 0); | |
| 1990/0707 | case 4: strncpy(dp->name, fields[3], sizeof(dp->name)); | |
| 1990/0312 | case 3: | |
| 1990/08101/sys/src/9/gnot/devdk.c:978,984 – 1990/08163/sys/src/9/gnot/devdk.c:983,989 | ||
| 1990/0312 | * tell the controller we want to make a call */ DPRINT("dialout\n"); | |
| 1990/08163 | dkmesg(dp, t_val, d_val, line, W_WINDOW(dp->urpwindow,dp->urpwindow,2)); | |
| 1990/0312 | /* * if redial, wait for a dial tone (otherwise we might send | |
| 1990/08163/sys/src/9/gnot/devdk.c:397,403 – 1990/0905/sys/src/9/gnot/devdk.c:397,404 (short | long) | ||
| 1990/0312 | /* * we assume that each put is a message. * | |
| 1990/0905 | * add a 2 byte channel number to the start of each message, * low order byte first. | |
| 1990/0312 | */ static void dkoput(Queue *q, Block *bp) | |
| 1990/08163/sys/src/9/gnot/devdk.c:415,424 – 1990/0905/sys/src/9/gnot/devdk.c:416,422 | ||
| 1990/0312 | dp = lp->dp; line = lp - dp->line; | |
| 1990/0315 |
| |
| 1990/0905 | bp = padb(bp, 2); | |
| 1990/0312 | bp->rptr[0] = line; bp->rptr[1] = line>>8; | |
| 1990/0905/sys/src/9/gnot/devdk.c:558,564 – 1990/0911/sys/src/9/gnot/devdk.c:558,563 (short | long) | ||
| 1990/0312 | dkreset(void) { | |
| 1990/0321 | newqinfo(&dkmuxinfo); | |
| 1990/0717 |
| |
| 1990/0312 | } /* | |
| 1990/0911/sys/src/9/gnot/devdk.c:499,504 – 1990/1004/sys/src/9/gnot/devdk.c:499,512 (short | long) | ||
| 1990/0312 | dp->csc = c; /* | |
| 1990/1004 | * tell datakit we've rebooted. It should close all channels. */ if(dp->restart) { DPRINT("dkmuxconfig: restart %s\n", dp->name); dkmesg(dp, T_ALIVE, D_RESTART, 0, 0); } /* | |
| 1990/0312 | * start a process to deal with it */ | |
| 1990/08101 | sprint(buf, "csc.%s.%d", dp->name, dp->ncsc); | |
| 1990/0911/sys/src/9/gnot/devdk.c:1100,1108 – 1990/1004/sys/src/9/gnot/devdk.c:1108,1114 | ||
| 1990/0312 | n = streamread(dc, dialstr, sizeof(dialstr)-1); DPRINT("returns %d\n", n); if(n <= 0) | |
| 1990/0617 |
| |
| 1990/0312 | error(0, Eio); | |
| 1990/0617 |
| |
| 1990/0312 | dialstr[n] = 0; DPRINT("dialstr = %s\n", dialstr); | |
| 1990/0911/sys/src/9/gnot/devdk.c:1112,1118 – 1990/1004/sys/src/9/gnot/devdk.c:1118,1123 | ||
| 1990/0312 | n = getfields(dialstr, line, 12, '\n'); if (n < 2) { DPRINT("bad dialstr from dk (1 line)\n"); | |
| 1990/0617 |
| |
| 1990/0312 | error(0, Eio); } | |
| 1990/0911/sys/src/9/gnot/devdk.c:1317,1332 – 1990/1004/sys/src/9/gnot/devdk.c:1322,1327 | ||
| 1990/0312 | int i; dp = (Dk *)a; | |
| 1990/0617 |
| |
| 1990/08101 |
| |
| 1990/0707 |
| |
| 1990/08101 |
| |
| 1990/0617 |
| |
| 1990/0312 | /* * loop forever listening | |
| 1990/1004/sys/src/9/gnot/devdk.c:118,124 – 1990/1018/sys/src/9/gnot/devdk.c:118,124 (short | long) | ||
| 1990/0312 | struct Dk { QLock; int ref; | |
| 1990/1018 | char name[64]; /* dk name */ | |
| 1990/0312 | Queue *wq; /* dk output queue */ int lines; /* number of lines */ int ncsc; /* csc line number */ | |
| 1990/1004/sys/src/9/gnot/devdk.c:420,430 – 1990/1018/sys/src/9/gnot/devdk.c:420,427 | ||
| 1990/0312 | bp->rptr[0] = line; bp->rptr[1] = line>>8; | |
| 1990/05313 |
| |
| 1990/1018 | FLOWCTL(dp->wq); PUTNEXT(dp->wq, bp); | |
| 1990/0312 | } /* | |
| 1990/1018/sys/src/9/gnot/devdk.c:206,211 – 1990/1020/sys/src/9/gnot/devdk.c:206,212 (short | long) | ||
| 1990/0312 | dkmuxopen(Queue *q, Stream *s) { Dk *dp; | |
| 1990/1020 | Line *lp; | |
| 1990/0312 | int i; for(dp = dk; dp < &dk[Ndk]; dp++){ | |
| 1990/1018/sys/src/9/gnot/devdk.c:222,227 – 1990/1020/sys/src/9/gnot/devdk.c:223,231 | ||
| 1990/0312 | dp->lines = 16; dp->name[0] = 0; dp->wq = WR(q); | |
| 1990/1020 | for(lp = dp->line; lp < &dp->line[Nline]; lp++) if(lp->state != 0) panic("dkmuxopen l %d s %lux", lp-dp->line, lp->state); | |
| 1990/0312 | qunlock(dp); return; } | |
| 1990/1018/sys/src/9/gnot/devdk.c:1368,1382 – 1990/1020/sys/src/9/gnot/devdk.c:1372,1386 | ||
| 1990/0312 | { Line *lp; | |
| 1990/1020 | if (line <= 0 || line >= dp->lines) { /* tell controller this line is not in use */ dkmesg(dp, T_CHG, D_CLOSE, line, 0); return; } lp = &dp->line[line]; | |
| 1990/0312 | switch (lp->state) { case Ldialing: | |
| 1990/1018/sys/src/9/gnot/devdk.c:1407,1412 – 1990/1020/sys/src/9/gnot/devdk.c:1411,1422 | ||
| 1990/0312 | break; case D_ISCLOSED: /* acknowledging a local shutdown */ | |
| 1990/1020 | if (line <= 0 || line >= dp->lines) { /* tell controller this line is not in use */ dkmesg(dp, T_CHG, D_CLOSE, line, 0); return; } lp = &dp->line[line]; | |
| 1990/0312 | switch (lp->state) { case Llclose: case Lclosed: | |
| 1990/1018/sys/src/9/gnot/devdk.c:1421,1426 – 1990/1020/sys/src/9/gnot/devdk.c:1431,1466 | ||
| 1990/0312 | } break; | |
| 1990/1020 | case D_CLOSEALL: for(line = dp->ncsc+1; line < dp->lines; line++){ lp = &dp->line[line]; switch (lp->state) { case Ldialing: /* simulate a failed connection */ dkreplymesg(dp, (Dkmsg *)0, line); lp->state = Lrclose; break; case Lrclose: case Lconnected: case Llistening: case Lackwait: dkhangup(lp); lp->state = Lrclose; break; case Lopened: break; case Llclose: case Lclosed: lp->state = Lclosed; break; } } break; | |
| 1990/0312 | default: print("unrecognized T_CHG\n"); } | |
| 1990/1018/sys/src/9/gnot/devdk.c:1503,1509 – 1990/1020/sys/src/9/gnot/devdk.c:1543,1549 | ||
| 1990/0312 | * remind controller of dead lines and * timeout calls that take to long */ | |
| 1990/1020 | for (i=dp->ncsc+1; i<dp->lines; i++){ | |
| 1990/0312 | lp = &dp->line[i]; switch(lp->state){ case Llclose: | |
| 1990/1020/sys/src/9/gnot/devdk.c:206,212 – 1990/1022/sys/src/9/gnot/devdk.c:206,211 (short | long) | ||
| 1990/0312 | dkmuxopen(Queue *q, Stream *s) { Dk *dp; | |
| 1990/1020 |
| |
| 1990/0312 | int i; for(dp = dk; dp < &dk[Ndk]; dp++){ | |
| 1990/1020/sys/src/9/gnot/devdk.c:223,231 – 1990/1022/sys/src/9/gnot/devdk.c:222,227 | ||
| 1990/0312 | dp->lines = 16; dp->name[0] = 0; dp->wq = WR(q); | |
| 1990/1020 |
| |
| 1990/0312 | qunlock(dp); return; } | |
| 1990/1022/sys/src/9/gnot/devdk.c:116,125 – 1990/1024/sys/src/9/gnot/devdk.c:116,125 (short | long) | ||
| 1990/0312 | * dkmux line discipline is pushed onto. */ struct Dk { | |
| 1990/1024 | Lock; | |
| 1990/1018 | char name[64]; /* dk name */ | |
| 1990/0312 | Queue *wq; /* dk output queue */ | |
| 1990/1024 | Stream *s; | |
| 1990/0312 | int lines; /* number of lines */ int ncsc; /* csc line number */ Chan *csc; /* common signalling line */ | |
| 1990/1022/sys/src/9/gnot/devdk.c:189,194 – 1990/1024/sys/src/9/gnot/devdk.c:189,195 | ||
| 1990/0312 | static void dkchgmesg(Dk*, Dkmsg*, int); static void dkreplymesg(Dk*, Dkmsg*, int); Chan* dkopen(Chan*, int); | |
| 1990/1024 | static void dkhangup(Line*); | |
| 1990/0312 | /* * the datakit multiplexor stream module definition | |
| 1990/1022/sys/src/9/gnot/devdk.c:201,206 – 1990/1024/sys/src/9/gnot/devdk.c:202,208 | ||
| 1990/0312 | /* * a new dkmux. find a free dk structure and assign it to this queue. | |
| 1990/1024 | * when we get though here dp->s is meaningful and the name is set to "/". | |
| 1990/0312 | */ static void dkmuxopen(Queue *q, Stream *s) | |
| 1990/1022/sys/src/9/gnot/devdk.c:209,219 – 1990/1024/sys/src/9/gnot/devdk.c:211,221 | ||
| 1990/0312 | int i; for(dp = dk; dp < &dk[Ndk]; dp++){ | |
| 1990/1024 | if(dp->name[0]==0){ lock(dp); if(dp->name[0]){ | |
| 1990/0312 | /* someone was faster than us */ | |
| 1990/1024 | unlock(dp); | |
| 1990/0312 | continue; } q->ptr = q->other->ptr = (void *)dp; | |
| 1990/1022/sys/src/9/gnot/devdk.c:220,228 – 1990/1024/sys/src/9/gnot/devdk.c:222,231 | ||
| 1990/0312 | dp->csc = 0; dp->ncsc = 4; dp->lines = 16; | |
| 1990/1024 | strcpy(dp->name, "/"); | |
| 1990/0312 | dp->wq = WR(q); | |
| 1990/1024 | dp->s = s; unlock(dp); | |
| 1990/0312 | return; } } | |
| 1990/1022/sys/src/9/gnot/devdk.c:236,248 – 1990/1024/sys/src/9/gnot/devdk.c:239,260 | ||
| 1990/0312 | dkmuxclose(Queue *q) { Dk *dp; | |
| 1990/1024 | int i; | |
| 1990/0312 | dp = (Dk *)q->ptr; | |
| 1990/1024 | /* * if we're the last user of the stream, * free the Dk structure */ if(dp->s->inuse == 1) dp->name[0] = 0; /* * hang up all datakit connections */ for(i=dp->ncsc; i < dp->lines; i++) dkhangup(&dp->line[i]); | |
| 1990/0312 | } /* | |
| 1990/1022/sys/src/9/gnot/devdk.c:272,278 – 1990/1024/sys/src/9/gnot/devdk.c:284,290 | ||
| 1990/0312 | * * Simplifying assumption: one put == one message && the channel number * is in the first block. If this isn't true, demultiplexing will not | |
| 1990/1024 | * work. | |
| 1990/0312 | */ static void dkmuxiput(Queue *q, Block *bp) | |
| 1990/1022/sys/src/9/gnot/devdk.c:608,628 – 1990/1024/sys/src/9/gnot/devdk.c:620,664 | ||
| 1990/0728 | if(*spec == 0) spec = "dk"; | |
| 1990/0312 | for(dp = dk; dp < &dk[Ndk]; dp++){ | |
| 1990/1024 | lock(dp); if(strcmp(spec, dp->name)==0) | |
| 1990/0312 | break; | |
| 1990/1024 | unlock(dp); | |
| 1990/0312 | } if(dp == &dk[Ndk]) error(0, Enoifc); | |
| 1990/1024 | /* * don't let the multiplexed stream disappear under us */ if(streamenter(dp->s) < 0){ /* * it's closing down, forget it */ unlock(dp); error(0, Ehungup); } /* * return the new channel */ if(waserror()){ if(streamexit(dp->s, 0) == 0) dp->name[0] = 0; unlock(dp); nexterror(); } | |
| 1990/0312 | c = devattach('k', spec); c->dev = dp - dk; | |
| 1990/1024 | unlock(dp); poperror(); | |
| 1990/0312 | return c; } | |
| 1990/1024 | /* * clone as long as the multiplexed channel is not closing * down */ | |
| 1990/0312 | Chan* dkclone(Chan *c, Chan *nc) { | |
| 1990/1022/sys/src/9/gnot/devdk.c:629,637 – 1990/1024/sys/src/9/gnot/devdk.c:665,672 | ||
| 1990/0312 | Dk *dp; dp = &dk[c->dev]; | |
| 1990/1024 | if(streamenter(dp->s) < 0) error(0, Ehungup); | |
| 1990/0312 | return devclone(c, nc); } | |
| 1990/1022/sys/src/9/gnot/devdk.c:679,688 – 1990/1024/sys/src/9/gnot/devdk.c:714,723 | ||
| 1990/0319 | error(0, Ebadarg); } else switch(STREAMTYPE(c->qid)){ case Dcloneqid: | |
| 1990/1024 | dp = &dk[c->dev]; | |
| 1990/0319 | /* | |
| 1990/0312 | * get an unused device and open it's control file */ | |
| 1990/1022/sys/src/9/gnot/devdk.c:752,761 – 1990/1024/sys/src/9/gnot/devdk.c:787,799 | ||
| 1990/0319 | if(c->stream) | |
| 1990/0312 | streamclose(c); | |
| 1990/1024 | /* * Let go of the mulitplexed stream. If we're the last out, * free dp. */ | |
| 1990/0312 | dp = &dk[c->dev]; | |
| 1990/1024 | if(streamexit(dp->s, 0) == 0) dp->name[0] = 0; | |
| 1990/0312 | } long | |
| 1990/1022/sys/src/9/gnot/devdk.c:1320,1325 – 1990/1024/sys/src/9/gnot/devdk.c:1358,1374 | ||
| 1990/0312 | dp = (Dk *)a; | |
| 1990/1024 | if(waserror()){ Chan *csc; csc = dp->csc; lock(dp); dp->csc = 0; unlock(dp); close(csc); return; } | |
| 1990/0312 | /* * loop forever listening */ | |
| 1990/1022/sys/src/9/gnot/devdk.c:1326,1331 – 1990/1024/sys/src/9/gnot/devdk.c:1375,1382 | ||
| 1990/0312 | for(;;){ n = streamread(dp->csc, (char *)&d, (long)sizeof(d)); if(n != sizeof(d)){ | |
| 1990/1024 | if(n == 0) error(0, Ehungup); | |
| 1990/0312 | print("strange csc message %d\n", n); continue; } | |
| 1990/1022/sys/src/9/gnot/devdk.c:1527,1534 – 1990/1024/sys/src/9/gnot/devdk.c:1578,1589 | ||
| 1990/0312 | */ for(dki=0; dki<Ndk; dki++){ dp = &dk[dki]; | |
| 1990/1024 | if(!canlock(dp)) | |
| 1990/0312 | continue; | |
| 1990/1024 | if(dp->csc==0){ unlock(dp); continue; } | |
| 1990/0312 | /* * send keep alive | |
| 1990/1022/sys/src/9/gnot/devdk.c:1553,1558 – 1990/1024/sys/src/9/gnot/devdk.c:1608,1614 | ||
| 1990/0312 | break; } } | |
| 1990/1024 | unlock(dp); | |
| 1990/0312 | } tsleep(&dkt, fuckit, 0, 7500); } | |
| 1990/1024/sys/src/9/gnot/devdk.c:117,133 – 1990/1026/sys/src/9/gnot/devdk.c:117,136 (short | long) | ||
| 1990/0312 | */ struct Dk { | |
| 1990/1024 | Lock; | |
| 1990/1026 | int opened; | |
| 1990/1018 | char name[64]; /* dk name */ | |
| 1990/0312 | Queue *wq; /* dk output queue */ | |
| 1990/1024 | Stream *s; | |
| 1990/0312 | int lines; /* number of lines */ int ncsc; /* csc line number */ | |
| 1990/1026 | Chan *csc; | |
| 1990/0312 | Line line[Nline]; | |
| 1990/0707 | int restart; | |
| 1990/08163 | int urpwindow; | |
| 1990/1026 | Rendez timer; | |
| 1990/0312 | }; static Dk dk[Ndk]; | |
| 1990/1026 | static Lock dklock; | |
| 1990/0312 | /* * conversation states (for Line.state) | |
| 1990/1024/sys/src/9/gnot/devdk.c:178,185 – 1990/1026/sys/src/9/gnot/devdk.c:181,189 | ||
| 1990/0312 | * predeclared */ Chan* dkattach(char*); | |
| 1990/1026 | static void dkmuxconfig(Queue*, Block*); static Chan* dkopenline(Dk*, int); static int dkmesg(Chan*, int, int, int, int); | |
| 1990/0312 | static void dkcsckproc(void*); static int dklisten(Chan*); static void dkanswer(Chan*, int, int); | |
| 1990/1024/sys/src/9/gnot/devdk.c:186,192 – 1990/1026/sys/src/9/gnot/devdk.c:190,196 | ||
| 1990/0312 | static void dkwindow(Chan*); static void dkcall(int, Chan*, char*, char*, char*); static void dktimer(void*); | |
| 1990/1026 | static void dkchgmesg(Chan*, Dk*, Dkmsg*, int); | |
| 1990/0312 | static void dkreplymesg(Dk*, Dkmsg*, int); Chan* dkopen(Chan*, int); | |
| 1990/1024 | static void dkhangup(Line*); | |
| 1990/1024/sys/src/9/gnot/devdk.c:201,238 – 1990/1026/sys/src/9/gnot/devdk.c:205,253 | ||
| 1990/0312 | Qinfo dkmuxinfo = { dkmuxiput, dkmuxoput, dkmuxopen, dkmuxclose, "dkmux" }; /* | |
| 1990/1024 |
| |
| 1990/0312 |
| |
| 1990/1026 | * Look for a dk struct with a name. If none exists, create one. */ static Dk * dkalloc(char *name) | |
| 1990/0312 | { Dk *dp; | |
| 1990/1026 | Dk *freep; | |
| 1990/0312 | ||
| 1990/1026 | lock(&dklock); freep = 0; | |
| 1990/0312 | for(dp = dk; dp < &dk[Ndk]; dp++){ | |
| 1990/1024 |
| |
| 1990/0312 |
| |
| 1990/1024 |
| |
| 1990/0312 |
| |
| 1990/1024 |
| |
| 1990/0312 |
| |
| 1990/1024 |
| |
| 1990/0312 |
| |
| 1990/1026 | if(strcmp(name, dp->name) == 0){ unlock(&dklock); return dp; | |
| 1990/0312 | } | |
| 1990/1026 | if(dp->name[0] == 0) freep = dp; | |
| 1990/0312 | } | |
| 1990/1026 | if(freep == 0){ unlock(&dklock); error(0, Enoifc); } dp = freep; dp->opened = 0; dp->s = 0; dp->ncsc = 1; strncpy(dp->name, name, sizeof(freep->name)); unlock(&dklock); return dp; | |
| 1990/0312 | } /* | |
| 1990/1026 | * a new dkmux. find a free dk structure and assign it to this queue. * when we get though here dp->s is meaningful and the name is set to "/". */ static void dkmuxopen(Queue *q, Stream *s) { RD(q)->ptr = s; WR(q)->ptr = 0; } /* | |
| 1990/0312 | * close down a dkmux */ static void | |
| 1990/1024/sys/src/9/gnot/devdk.c:241,254 – 1990/1026/sys/src/9/gnot/devdk.c:256,272 | ||
| 1990/0312 | Dk *dp; | |
| 1990/1024 | int i; | |
| 1990/0312 |
| |
| 1990/1026 | dp = WR(q)->ptr; if(dp == 0) return; | |
| 1990/1024 | /* | |
| 1990/1026 | * disallow new dkstopens() on this line. * the lock syncs with dkstopen(). | |
| 1990/1024 | */ | |
| 1990/1026 | lock(dp); dp->opened = 0; unlock(dp); | |
| 1990/1024 | /* * hang up all datakit connections | |
| 1990/1024/sys/src/9/gnot/devdk.c:255,260 – 1990/1026/sys/src/9/gnot/devdk.c:273,283 | ||
| 1990/1024 | */ for(i=dp->ncsc; i < dp->lines; i++) dkhangup(&dp->line[i]); | |
| 1990/1026 | /* * wakeup the timer so it can die */ wakeup(&dp->timer); | |
| 1990/0312 | } /* | |
| 1990/1024/sys/src/9/gnot/devdk.c:263,274 – 1990/1026/sys/src/9/gnot/devdk.c:286,294 | ||
| 1990/0312 | static void dkmuxoput(Queue *q, Block *bp) { | |
| 1990/1026 | dkmuxconfig(q, bp); | |
| 1990/0312 | else PUTNEXT(q, bp); return; | |
| 1990/1024/sys/src/9/gnot/devdk.c:293,298 – 1990/1026/sys/src/9/gnot/devdk.c:313,326 | ||
| 1990/0312 | Line *lp; int line; | |
| 1990/1026 | /* * not configured yet */ if(q->other->ptr == 0){ freeb(bp); return; } | |
| 1990/0312 | dp = (Dk *)q->ptr; if(bp->type != M_DATA){ PUTNEXT(q, bp); | |
| 1990/1024/sys/src/9/gnot/devdk.c:341,346 – 1990/1026/sys/src/9/gnot/devdk.c:369,380 | ||
| 1990/0312 | Line *lp; dp = &dk[s->dev]; | |
| 1990/1026 | lock(dp); if(dp->opened==0 || streamenter(dp->s)<0){ unlock(dp); error(0, Ehungup); } unlock(dp); | |
| 1990/0312 | q->other->ptr = q->ptr = lp = &dp->line[s->id]; lp->dp = dp; lp->rq = q; | |
| 1990/1024/sys/src/9/gnot/devdk.c:356,366 – 1990/1026/sys/src/9/gnot/devdk.c:390,421 | ||
| 1990/0312 | { Dk *dp; Line *lp; | |
| 1990/1026 | Chan *c; | |
| 1990/0312 | lp = (Line *)q->ptr; dp = lp->dp; /* | |
| 1990/1026 | * decrement ref count on mux'd line */ streamexit(dp->s, 0); /* * don't tell controller about closing down the csc */ if(lp - dp->line == dp->ncsc) goto out; c = 0; if(waserror()){ if(c) close(c); lp->state = Lclosed; goto out; } c = dkopenline(dp, dp->ncsc); /* | |
| 1990/0312 | * shake hands with dk */ switch(lp->state){ | |
| 1990/1024/sys/src/9/gnot/devdk.c:369,390 – 1990/1026/sys/src/9/gnot/devdk.c:424,445 | ||
| 1990/0312 | break; case Lrclose: | |
| 1990/1026 | dkmesg(c, T_CHG, D_CLOSE, lp - dp->line, 0); | |
| 1990/0312 | lp->state = Lclosed; break; case Lackwait: | |
| 1990/1026 | dkmesg(c, T_CHG, D_CLOSE, lp - dp->line, 0); | |
| 1990/0312 | lp->state = Llclose; break; case Llistening: | |
| 1990/1026 | dkmesg(c, T_CHG, D_CLOSE, lp - dp->line, 0); | |
| 1990/0312 | lp->state = Llclose; break; case Lconnected: | |
| 1990/1026 | dkmesg(c, T_CHG, D_CLOSE, lp - dp->line, 0); | |
| 1990/0312 | lp->state = Llclose; break; | |
| 1990/1024/sys/src/9/gnot/devdk.c:391,397 – 1990/1026/sys/src/9/gnot/devdk.c:446,455 | ||
| 1990/0312 | case Lopened: lp->state = Lclosed; } | |
| 1990/1026 | poperror(); close(c); | |
| 1990/0312 | ||
| 1990/1026 | out: | |
| 1990/0312 | qlock(lp); lp->rq = 0; qunlock(lp); | |
| 1990/1024/sys/src/9/gnot/devdk.c:448,485 – 1990/1026/sys/src/9/gnot/devdk.c:506,553 | ||
| 1990/0312 | * we can configure only once */ static void | |
| 1990/1026 | dkmuxconfig(Queue *q, Block *bp) | |
| 1990/0312 | { | |
| 1990/1026 | Dk *dp; | |
| 1990/08163 | char *fields[5]; | |
| 1990/0312 | int n; char buf[64]; | |
| 1990/1026 | char name[NAMELEN]; int lines; int ncsc; int restart; int window; | |
| 1990/0312 |
| |
| 1990/1026 | if(WR(q)->ptr){ | |
| 1990/0312 | freeb(bp); | |
| 1990/1026 | error(0, Egreg); | |
| 1990/0312 | } /* | |
| 1990/1026 | * defaults */ ncsc = 1; restart = 1; lines = 16; window = WS_2K; strcpy(name, "dk"); /* | |
| 1990/0312 | * parse */ | |
| 1990/0707 |
| |
| 1990/08163 | n = getfields((char *)bp->rptr, fields, 5, ' '); | |
| 1990/0728 |
| |
| 1990/08163 |
| |
| 1990/0312 | switch(n){ | |
| 1990/08163 | case 5: | |
| 1990/1026 | window = strtoul(fields[4], 0, 0); | |
| 1990/0707 | case 4: | |
| 1990/1026 | strncpy(name, fields[3], sizeof(name)); | |
| 1990/0312 | case 3: | |
| 1990/0707 | if(strcmp(fields[2], "restart")!=0) | |
| 1990/1026 | restart = 0; | |
| 1990/0312 | case 2: | |
| 1990/1026 | lines = strtoul(fields[1], 0, 0); | |
| 1990/0312 | case 1: | |
| 1990/1026 | ncsc = strtoul(fields[0], 0, 0); | |
| 1990/0312 | break; default: freeb(bp); | |
| 1990/1024/sys/src/9/gnot/devdk.c:486,534 – 1990/1026/sys/src/9/gnot/devdk.c:554,607 | ||
| 1990/0312 | error(0, Ebadarg); } freeb(bp); | |
| 1990/1026 | if(ncsc <= 0 || lines <= ncsc) | |
| 1990/0312 | error(0, Ebadarg); | |
| 1990/08101 |
| |
| 1990/0312 | /* | |
| 1990/1026 | * set up | |
| 1990/0312 | */ | |
| 1990/1026 | dp = dkalloc(name); lock(dp); if(dp->opened){ unlock(dp); error(0, Ebadarg); | |
| 1990/0312 | } | |
| 1990/1026 | dp->ncsc = ncsc; dp->lines = lines; dp->restart = restart; dp->urpwindow = window; dp->s = RD(q)->ptr; q->ptr = q->other->ptr = dp; dp->opened = 1; dp->wq = WR(q); unlock(dp); | |
| 1990/0312 | /* | |
| 1990/1026 | * open csc here so that boot, dktimer, and dkcsckproc aren't * all fighting for it at once. */ dp->csc = dkopenline(dp, dp->ncsc); /* | |
| 1990/1004 | * tell datakit we've rebooted. It should close all channels. | |
| 1990/1026 | * do this here to get it done before trying to open a channel. | |
| 1990/1004 | */ if(dp->restart) { | |
| 1990/1026 | DPRINT("dktimer: restart %s\n", dp->name); dkmesg(dp->csc, T_ALIVE, D_RESTART, 0, 0); | |
| 1990/1004 | } /* | |
| 1990/0312 |
| |
| 1990/1026 | * start a process to listen to csc messages | |
| 1990/0312 | */ | |
| 1990/08101 | sprint(buf, "csc.%s.%d", dp->name, dp->ncsc); | |
| 1990/0312 | kproc(buf, dkcsckproc, dp); | |
| 1990/1026 | * start a keepalive process | |
| 1990/0312 | */ | |
| 1990/0728 |
| |
| 1990/0312 |
| |
| 1990/1026 | sprint(buf, "timer.%s.%d", dp->name, dp->ncsc); kproc(buf, dktimer, dp); | |
| 1990/0312 | } /* | |
| 1990/1024/sys/src/9/gnot/devdk.c:619,672 – 1990/1026/sys/src/9/gnot/devdk.c:692,710 | ||
| 1990/0312 | */ | |
| 1990/0728 | if(*spec == 0) spec = "dk"; | |
| 1990/0312 |
| |
| 1990/1024 |
| |
| 1990/0312 |
| |
| 1990/1024 |
| |
| 1990/0312 |
| |
| 1990/1026 | dp = dkalloc(spec); | |
| 1990/1024 | /* | |
| 1990/0312 | c = devattach('k', spec); c->dev = dp - dk; | |
| 1990/1024 |
| |
| 1990/0312 | return c; } | |
| 1990/1024 |
| |
| 1990/0312 | Chan* dkclone(Chan *c, Chan *nc) { | |
| 1990/1024 |
| |
| 1990/0312 | return devclone(c, nc); } | |
| 1990/1024/sys/src/9/gnot/devdk.c:783,799 – 1990/1026/sys/src/9/gnot/devdk.c:821,828 | ||
| 1990/0312 | { Dk *dp; | |
| 1990/05313 |
| |
| 1990/0319 | if(c->stream) | |
| 1990/0312 | streamclose(c); | |
| 1990/1024 |
| |
| 1990/0312 |
| |
| 1990/1024 |
| |
| 1990/0312 | } long | |
| 1990/1024/sys/src/9/gnot/devdk.c:900,915 – 1990/1026/sys/src/9/gnot/devdk.c:929,963 | ||
| 1990/0312 | } /* | |
| 1990/1026 | * open the common signalling channel */ static Chan* dkopenline(Dk *dp, int line) { Chan *c; c = 0; if(waserror()){ if(c) close(c); nexterror(); } c = dkattach(dp->name); c->qid = STREAMQID(line, Sdataqid); dkopen(c, ORDWR); poperror(); return c; } /* | |
| 1990/0312 | * send a message to the datakit on the common signaling line */ static int | |
| 1990/1026 | dkmesg(Chan *c, int type, int srv, int p0, int p1) | |
| 1990/0312 | { Dkmsg d; | |
| 1990/0728 | if(waserror()){ print("dkmesg: error\n"); | |
| 1990/0312 | return -1; | |
| 1990/1024/sys/src/9/gnot/devdk.c:926,932 – 1990/1026/sys/src/9/gnot/devdk.c:974,980 | ||
| 1990/0312 | d.param3h = 0; d.param4l = 0; d.param4h = 0; | |
| 1990/1026 | streamwrite(c, (char *)&d, sizeof(Dkmsg), 1); | |
| 1990/0312 | poperror(); return 0; } | |
| 1990/1024/sys/src/9/gnot/devdk.c:952,959 – 1990/1026/sys/src/9/gnot/devdk.c:1000,1008 | ||
| 1990/0312 | Dk *dp; Line *lp; Chan *dc; | |
| 1990/1026 | Chan *csc; | |
| 1990/0707 | char *bang, *dot; | |
| 1990/0312 | ||
| 1990/1026 | ||
| 1990/0312 | line = STREAMID(c->qid); dp = &dk[c->dev]; lp = &dp->line[line]; | |
| 1990/1024/sys/src/9/gnot/devdk.c:1006,1021 – 1990/1026/sys/src/9/gnot/devdk.c:1055,1076 | ||
| 1990/0312 | } /* | |
| 1990/1026 | * close temporary channels on error | |
| 1990/0312 | */ | |
| 1990/1026 | dc = 0; csc = 0; | |
| 1990/0312 | if(waserror()){ | |
| 1990/1026 | if(csc) close(csc); if(dc) close(dc); | |
| 1990/0312 | nexterror(); } | |
| 1990/1026 | /* * open the data file */ dc = dkopenline(dp, line); | |
| 1990/0312 | lp->calltolive = 4; lp->state = Ldialing; | |
| 1990/1024/sys/src/9/gnot/devdk.c:1023,1029 – 1990/1026/sys/src/9/gnot/devdk.c:1078,1087 | ||
| 1990/0312 | * tell the controller we want to make a call */ DPRINT("dialout\n"); | |
| 1990/08163 |
| |
| 1990/1026 | csc = dkopenline(dp, dp->ncsc); dkmesg(csc, t_val, d_val, line, W_WINDOW(dp->urpwindow,dp->urpwindow,2)); close(csc); csc = 0; | |
| 1990/0312 | /* * if redial, wait for a dial tone (otherwise we might send | |
| 1990/1024/sys/src/9/gnot/devdk.c:1354,1371 – 1990/1026/sys/src/9/gnot/devdk.c:1412,1422 | ||
| 1990/0312 | Dk *dp; Dkmsg d; int line; | |
| 1990/1026 | dp = a; | |
| 1990/0312 | ||
| 1990/1024 | if(waserror()){ | |
| 1990/1026 | close(dp->csc); | |
| 1990/1024 | return; } | |
| 1990/1024/sys/src/9/gnot/devdk.c:1385,1391 – 1990/1026/sys/src/9/gnot/devdk.c:1436,1442 | ||
| 1990/0312 | switch (d.type) { case T_CHG: /* controller wants to close a line */ | |
| 1990/1026 | dkchgmesg(dp->csc, dp, &d, line); | |
| 1990/0312 | break; case T_REPLY: /* reply to a dial request */ | |
| 1990/1024/sys/src/9/gnot/devdk.c:1415,1421 – 1990/1026/sys/src/9/gnot/devdk.c:1466,1472 | ||
| 1990/0312 | * datakit requests or confirms closing a line */ static void | |
| 1990/1026 | dkchgmesg(Chan *c, Dk *dp, Dkmsg *dialp, int line) | |
| 1990/0312 | { Line *lp; | |
| 1990/1024/sys/src/9/gnot/devdk.c:1424,1430 – 1990/1026/sys/src/9/gnot/devdk.c:1475,1481 | ||
| 1990/0312 | case D_CLOSE: /* remote shutdown */ | |
| 1990/1020 | if (line <= 0 || line >= dp->lines) { /* tell controller this line is not in use */ | |
| 1990/1026 | dkmesg(c, T_CHG, D_CLOSE, line, 0); | |
| 1990/1020 | return; } lp = &dp->line[line]; | |
| 1990/1024/sys/src/9/gnot/devdk.c:1445,1457 – 1990/1026/sys/src/9/gnot/devdk.c:1496,1508 | ||
| 1990/0312 | break; case Lopened: | |
| 1990/1026 | dkmesg(c, T_CHG, D_CLOSE, line, 0); | |
| 1990/0312 | break; case Llclose: case Lclosed: dkhangup(lp); | |
| 1990/1026 | dkmesg(c, T_CHG, D_CLOSE, line, 0); | |
| 1990/0312 | lp->state = Lclosed; break; } | |
| 1990/1024/sys/src/9/gnot/devdk.c:1460,1466 – 1990/1026/sys/src/9/gnot/devdk.c:1511,1517 | ||
| 1990/0312 | case D_ISCLOSED: /* acknowledging a local shutdown */ | |
| 1990/1020 | if (line <= 0 || line >= dp->lines) { /* tell controller this line is not in use */ | |
| 1990/1026 | dkmesg(c, T_CHG, D_CLOSE, line, 0); | |
| 1990/1020 | return; } lp = &dp->line[line]; | |
| 1990/1024/sys/src/9/gnot/devdk.c:1554,1567 – 1990/1026/sys/src/9/gnot/devdk.c:1605,1613 | ||
| 1990/0312 | } /* | |
| 1990/1026 | * send a I'm alive message every 7.5 seconds and remind the dk of * any closed channels it hasn't acknowledged. | |
| 1990/0312 | */ | |
| 1990/1024/sys/src/9/gnot/devdk.c:1568,1615 – 1990/1026/sys/src/9/gnot/devdk.c:1614,1661 | ||
| 1990/0312 | int dki, i; Dk *dp; Line *lp; | |
| 1990/1026 | Chan *c; | |
| 1990/0312 | ||
| 1990/0728 |
| |
| 1990/1026 | c = 0; if(waserror()){ if(c) close(c); return; } | |
| 1990/0312 | ||
| 1990/1026 | /* * open csc */ dp = (Dk *)a; c = dkopenline(dp, dp->ncsc); | |
| 1990/0312 | for(;;){ | |
| 1990/1026 | if(dp->opened==0) error(0, Ehungup); | |
| 1990/0312 | /* | |
| 1990/1026 | * send keep alive | |
| 1990/0312 | */ | |
| 1990/1024 |
| |
| 1990/0312 |
| |
| 1990/1024 |
| |
| 1990/1026 | dkmesg(c, T_ALIVE, D_CONTINUE, 0, 0); | |
| 1990/0312 |
| |
| 1990/1026 | /* * remind controller of dead lines and * timeout calls that take to long */ for (i=dp->ncsc+1; i<dp->lines; i++){ lp = &dp->line[i]; switch(lp->state){ case Llclose: dkmesg(c, T_CHG, D_CLOSE, i, 0); break; | |
| 1990/0312 |
| |
| 1990/1020 |
| |
| 1990/0312 |
| |
| 1990/1026 | case Ldialing: if(lp->calltolive==0 || --lp->calltolive!=0) | |
| 1990/0312 | break; | |
| 1990/1026 | dkreplymesg(dp, (Dkmsg *)0, i); break; | |
| 1990/0312 | } | |
| 1990/1024 |
| |
| 1990/0312 | } | |
| 1990/1026 | tsleep(&dp->timer, return0, 0, 7500); | |
| 1990/0312 | } } | |
| 1990/1026/sys/src/9/gnot/devdk.c:369,374 – 1990/1101/sys/src/9/gnot/devdk.c:369,376 (short | long) | ||
| 1990/0312 | Line *lp; dp = &dk[s->dev]; | |
| 1990/1101 | q->other->ptr = q->ptr = lp = &dp->line[s->id]; lp->dp = dp; | |
| 1990/1026 | lock(dp); if(dp->opened==0 || streamenter(dp->s)<0){ unlock(dp); | |
| 1990/1026/sys/src/9/gnot/devdk.c:375,385 – 1990/1101/sys/src/9/gnot/devdk.c:377,385 | ||
| 1990/1026 | error(0, Ehungup); } unlock(dp); | |
| 1990/0312 |
| |
| 1990/05313 |
| |
| 1990/1101 | if(lp->state==Lclosed) | |
| 1990/05313 | lp->state = Lopened; | |
| 1990/1101 | lp->rq = q; | |
| 1990/0312 | } /* | |
| 1990/1026/sys/src/9/gnot/devdk.c:396,416 – 1990/1101/sys/src/9/gnot/devdk.c:396,429 | ||
| 1990/0312 | dp = lp->dp; /* | |
| 1990/1101 | * if we never got going, we're done */ if(lp->rq == 0){ lp->state = Lclosed; return; } /* | |
| 1990/1026 | * decrement ref count on mux'd line */ streamexit(dp->s, 0); /* | |
| 1990/1101 | * these states don't need the datakit | |
| 1990/1026 | */ | |
| 1990/1101 | switch(lp->state){ case Lclosed: case Llclose: case Lopened: lp->state = Lclosed; | |
| 1990/1026 | goto out; | |
| 1990/1101 | } | |
| 1990/1026 | c = 0; if(waserror()){ | |
| 1990/1101 | lp->state = Lclosed; | |
| 1990/1026 | if(c) close(c); | |
| 1990/1026/sys/src/9/gnot/devdk.c:419,428 – 1990/1101/sys/src/9/gnot/devdk.c:432,437 | ||
| 1990/0312 | * shake hands with dk */ switch(lp->state){ | |
| 1990/1026 | dkmesg(c, T_CHG, D_CLOSE, lp - dp->line, 0); | |
| 1990/0312 | lp->state = Lclosed; | |
| 1990/1026/sys/src/9/gnot/devdk.c:442,450 – 1990/1101/sys/src/9/gnot/devdk.c:451,456 | ||
| 1990/1026 | dkmesg(c, T_CHG, D_CLOSE, lp - dp->line, 0); | |
| 1990/0312 | lp->state = Llclose; break; | |
| 1990/1026 | poperror(); close(c); | |
| 1990/1026/sys/src/9/gnot/devdk.c:769,777 – 1990/1101/sys/src/9/gnot/devdk.c:775,784 | ||
| 1990/0312 | } if(lp == end) error(0, Enodev); | |
| 1990/1101 | lp->state = Lopened; qunlock(lp); | |
| 1990/0312 | streamopen(c, &dkinfo); pushq(c->stream, &urpinfo); | |
| 1990/05313 |
| |
| 1990/0319 | break; case Dlistenqid: | |
| 1990/0312 | /* | |
| 1990/1026/sys/src/9/gnot/devdk.c:819,826 – 1990/1101/sys/src/9/gnot/devdk.c:826,831 | ||
| 1990/0312 | void dkclose(Chan *c) { | |
| 1990/0319 | if(c->stream) | |
| 1990/0312 | streamclose(c); } | |
| 1990/1026/sys/src/9/gnot/devdk.c:1183,1195 – 1990/1101/sys/src/9/gnot/devdk.c:1188,1198 | ||
| 1990/0312 | /* * open the data file */ | |
| 1990/1101 | dc = dkopenline(dp, STREAMID(c->qid)); | |
| 1990/0312 | if(waserror()){ close(dc); nexterror(); } | |
| 1990/1026/sys/src/9/gnot/devdk.c:1448,1458 – 1990/1101/sys/src/9/gnot/devdk.c:1451,1458 | ||
| 1990/0312 | break; case T_RESTART: /* datakit reboot */ | |
| 1990/1101 | if(line >=0 && line<dp->lines) | |
| 1990/0312 | dp->lines=line+1; | |
| 1990/1026/sys/src/9/gnot/devdk.c:1530,1535 – 1990/1101/sys/src/9/gnot/devdk.c:1530,1538 | ||
| 1990/0312 | break; | |
| 1990/1020 | case D_CLOSEALL: | |
| 1990/1101 | /* * datakit wants us to close all lines */ | |
| 1990/1020 | for(line = dp->ncsc+1; line < dp->lines; line++){ lp = &dp->line[line]; switch (lp->state) { | |
| 1990/1026/sys/src/9/gnot/devdk.c:1544,1551 – 1990/1101/sys/src/9/gnot/devdk.c:1547,1554 | ||
| 1990/1020 | case Lconnected: case Llistening: case Lackwait: | |
| 1990/1101 | dkhangup(lp); | |
| 1990/1020 | break; case Lopened: | |
| 1990/1026/sys/src/9/gnot/devdk.c:1618,1623 – 1990/1101/sys/src/9/gnot/devdk.c:1621,1641 | ||
| 1990/0312 | ||
| 1990/1026 | c = 0; if(waserror()){ | |
| 1990/1101 | /* * hang up any calls waiting for the dk */ for (i=dp->ncsc+1; i<dp->lines; i++){ lp = &dp->line[i]; switch(lp->state){ case Llclose: lp->state = Lclosed; break; case Ldialing: dkreplymesg(dp, (Dkmsg *)0, i); break; } } | |
| 1990/1026 | if(c) close(c); return; | |
| 1990/1101/sys/src/9/gnot/devdk.c:377,385 – 1990/1104/sys/src/9/gnot/devdk.c:377,385 (short | long) | ||
| 1990/1026 | error(0, Ehungup); } unlock(dp); | |
| 1990/1104 | lp->rq = q; | |
| 1990/1101 | if(lp->state==Lclosed) | |
| 1990/05313 | lp->state = Lopened; | |
| 1990/1101 |
| |
| 1990/0312 | } /* | |
| 1990/1104/sys/src/9/gnot/devdk.c:202,208 – 1990/11151/sys/src/9/gnot/devdk.c:202,215 (short | long) | ||
| 1990/0312 | static void dkmuxclose(Queue *); static void dkmuxoput(Queue *, Block *); static void dkmuxiput(Queue *, Block *); | |
| 1990/11151 | Qinfo dkmuxinfo = { dkmuxiput, dkmuxoput, dkmuxopen, dkmuxclose, "dkmux" }; | |
| 1990/0312 | /* | |
| 1990/1026 | * Look for a dk struct with a name. If none exists, create one. | |
| 1990/1104/sys/src/9/gnot/devdk.c:357,363 – 1990/11151/sys/src/9/gnot/devdk.c:364,377 | ||
| 1990/0312 | static void dkstclose(Queue *); static void dkoput(Queue *, Block *); static void dkiput(Queue *, Block *); | |
| 1990/11151 | Qinfo dkinfo = { dkiput, dkoput, dkstopen, dkstclose, "dk" }; | |
| 1990/0312 | /* * open and save a pointer to the conversation | |
| Too many diffs (26 > 25). Stopping. | ||