~kris/9p

9hist

0b0146825b4e205b913bc73420f44c654d562fd5 — David du Colombier 36 years ago 50dc394
Plan 9 from Bell Labs 1990-06-19
M gnot/devcons.c => gnot/devcons.c +1 -1
@@ 377,7 377,7 @@ conscreate(Chan *c, char *name, int omode, ulong perm)
void
consclose(Chan *c)
{
	if(c->qid == Qrcons)
	if(c->qid==Qrcons && (c->flag&COPEN))
		decref(&raw);
}


M gnot/devincon.c => gnot/devincon.c +2 -6
@@ 783,14 783,10 @@ inconintr(Ureg *ur)

	/* check for exceptional conditions */
	if(status&(OVERFLOW|CRC_ERROR)){
		if(status&OVERFLOW){
			screenputc('^');
		if(status&OVERFLOW)
			ip->overflow++;
		}
		if(status&CRC_ERROR){
			screenputc('+');
		if(status&CRC_ERROR)
			ip->crc++;
		}
	}

	/* see if it died underneath us */

M gnot/devmnt.c => gnot/devmnt.c +14 -17
@@ 167,7 167,6 @@ mqfree(MntQ *mq)

	lock(mq);
	if(--mq->ref == 0){
print("mqfree %lux %lux\n", mq->reader, mq->writer);
		msg = mq->msg;
		mq->msg = 0;
		lock(&mntqalloc);


@@ 675,16 674,16 @@ void
mntxmit(Mnt *m, Mnthdr *mh)
{
	ulong n;
	Mntbuf *mbr, *mbw;
	Mntbuf *mbw;
	Mnthdr *w, *ow;
	Chan *mntpt;
	MntQ *q;
	int qlocked;

	mbr = mballoc();
	mh->mbr = mballoc();
	mbw = mballoc();
	if(waserror()){
		mbfree(mbr);
		mbfree(mh->mbr);
		mbfree(mbw);
		nexterror();
	}


@@ 713,11 712,11 @@ mntxmit(Mnt *m, Mnthdr *mh)
	/*
	 * Read response
	 */
	n = (*devtab[q->msg->type].read)(q->msg, mbr->buf, BUFSIZE);
	n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE);
	mqfree(q);
	poperror();

	if(convM2S(mbr->buf, &mh->rhdr, n) == 0){
	if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){
		print("format error in mntxmit\n");
		error(0, Ebadmsg);
	}


@@ 745,7 744,7 @@ mntxmit(Mnt *m, Mnthdr *mh)
	 */
	if(mh->thdr.type == Tread)
		memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count);
	mbfree(mbr);
	mbfree(mh->mbr);
	mbfree(mbw);
	poperror();
	return;


@@ 770,9 769,9 @@ mntxmit(Mnt *m, Mnthdr *mh)
    Read:
		qunlock(q);
		qlocked = 0;
		n = (*devtab[q->msg->type].read)(q->msg, mbr->buf, BUFSIZE);
		if(convM2S(mbr->buf, &mh->rhdr, n) == 0){
			print("%lux %lux %lux %d format error in mntxmit %s\n", u->p, q->reader, q->writer, n, u->p->text);
		n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE);
		if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){
			print("format error in mntxmit\n");
			mnterrdequeue(q, mh);
			error(0, Ebadmsg);
		}


@@ 796,13 795,13 @@ mntxmit(Mnt *m, Mnthdr *mh)
		/*
		 * Hand response to correct recipient
		 */
if(q->writer == 0) print("response with empty queue %d %d %d: %d %d\n", mh->rhdr.type, mh->rhdr.err, mh->rhdr.fid, mh->thdr.type, mh->thdr.fid);
		if(q->writer==0) print("response with empty queue\n");
		for(ow=0,w=q->writer; w; ow=w,w=w->next)
			if(mh->rhdr.fid == w->thdr.fid
			&& mh->rhdr.type == w->thdr.type+1){
				Mntbuf *t;
				t = mbr;
				mbr = w->mbr;
				t = mh->mbr;
				mh->mbr = w->mbr;
				w->mbr = t;
				memcpy(&w->rhdr, &mh->rhdr, sizeof mh->rhdr);
				/* take recipient from queue */


@@ 815,7 814,6 @@ if(q->writer == 0) print("response with empty queue %d %d %d: %d %d\n", mh->rhdr
			}
		goto Read;
	}else{
		mh->mbr = mbr;
		mh->p = u->p;
		/* put self in queue */
		mh->next = q->writer;


@@ 823,7 821,7 @@ if(q->writer == 0) print("response with empty queue %d %d %d: %d %d\n", mh->rhdr
		qunlock(q);
		qlocked = 0;
		if(waserror()){		/* interrupted sleep */
			print("%lux interrupted i/o %d %d\n", u->p, mh->thdr.type, mh->thdr.fid);
			print("interrupted i/o\n");
			mnterrdequeue(q, mh);
			nexterror();
		}


@@ 833,7 831,6 @@ if(q->writer == 0) print("response with empty queue %d %d %d: %d %d\n", mh->rhdr
		qlocked = 1;
		if(q->reader == u->p)	/* i got promoted */
			goto Read;
		mbr = mh->mbr;		/* pick up my buffer */
		qunlock(q);
		qlocked = 0;
		goto Respond;


@@ 853,7 850,7 @@ if(q->writer == 0) print("response with empty queue %d %d %d: %d %d\n", mh->rhdr
	 */
	if(mh->thdr.type == Tread)
		memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count);
	mbfree(mbr);
	mbfree(mh->mbr);
	mbfree(mbw);
	poperror();
}

M gnot/lock.c => gnot/lock.c +2 -1
@@ 35,7 35,8 @@ lock(Lock *l)
			return;
		}
	l->key = 0;
	panic("lock loop %lux pc %lux held by pc %lux\n", l, ((ulong*)&i)[PCOFF], l->pc);
dumpstack();
	panic("lock loop %lux pc %lux held by pc %lux\n", l, ((ulong*)&l)[PCOFF], l->pc);
}

int

M gnot/proc.c => gnot/proc.c +1 -0
@@ 184,6 184,7 @@ loop:
	print("no procs\n");
	if(u == 0)
		panic("newproc");
	u->p->state = Wakeme;
	alarm(1000, wakeme, u->p);
	sched();
	goto loop;

M gnot/sysproc.c => gnot/sysproc.c +0 -2
@@ 404,8 404,6 @@ return0(void *a)
long
syssleep(ulong *arg)
{
	int ms;

	tsleep(&u->p->sleep, return0, 0, arg[0]);
	return 0;
}

M gnot/trap.c => gnot/trap.c +4 -0
@@ 186,6 186,10 @@ noted(Ureg **urp)
{
	#ifdef asdfasdf
	lock(&u->p->debug);
	if(!u->notified){
		unlock(&u->p->debug);
		return;
	}
	u->notified = 0;
	memcpy(*urp, u->ureg, sizeof(Ureg));
	unlock(&u->p->debug);

M port/devmnt.c => port/devmnt.c +18 -20
@@ 65,6 65,7 @@ struct
struct
{
	Lock;
	QLock;
	MntQ	*arena;
	MntQ	*free;
}mntqalloc;


@@ 141,7 142,7 @@ mhfree(Mnthdr *mh)
}

MntQ*
mqalloc(Chan *msg)	/* mntqalloc is locked */
mqalloc(Chan *msg)	/* mntqalloc is qlocked */
{
	MntQ *q;



@@ 166,7 167,6 @@ mqfree(MntQ *mq)

	lock(mq);
	if(--mq->ref == 0){
print("mqfree %lux %lux\n", mq->reader, mq->writer);
		msg = mq->msg;
		mq->msg = 0;
		lock(&mntqalloc);


@@ 271,7 271,7 @@ mntattach(char *spec)
	 * Look for queue to same msg channel
	 */
	q = mntqalloc.arena;
	lock(&mntqalloc);
	qlock(&mntqalloc);
	for(i=0; i<conf.nmntdev; i++,q++)
		if(q->msg==cm){
			lock(q);


@@ 286,7 286,7 @@ mntattach(char *spec)
	m->q = mqalloc(cm);

    out:
	unlock(&mntqalloc);
	qunlock(&mntqalloc);
	mh = mhalloc();
	if(waserror()){
		mhfree(mh);


@@ 674,16 674,16 @@ void
mntxmit(Mnt *m, Mnthdr *mh)
{
	ulong n;
	Mntbuf *mbr, *mbw;
	Mntbuf *mbw;
	Mnthdr *w, *ow;
	Chan *mntpt;
	MntQ *q;
	int qlocked;

	mbr = mballoc();
	mh->mbr = mballoc();
	mbw = mballoc();
	if(waserror()){
		mbfree(mbr);
		mbfree(mh->mbr);
		mbfree(mbw);
		nexterror();
	}


@@ 712,11 712,11 @@ mntxmit(Mnt *m, Mnthdr *mh)
	/*
	 * Read response
	 */
	n = (*devtab[q->msg->type].read)(q->msg, mbr->buf, BUFSIZE);
	n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE);
	mqfree(q);
	poperror();

	if(convM2S(mbr->buf, &mh->rhdr, n) == 0){
	if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){
		print("format error in mntxmit\n");
		error(0, Ebadmsg);
	}


@@ 744,7 744,7 @@ mntxmit(Mnt *m, Mnthdr *mh)
	 */
	if(mh->thdr.type == Tread)
		memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count);
	mbfree(mbr);
	mbfree(mh->mbr);
	mbfree(mbw);
	poperror();
	return;


@@ 769,9 769,9 @@ mntxmit(Mnt *m, Mnthdr *mh)
    Read:
		qunlock(q);
		qlocked = 0;
		n = (*devtab[q->msg->type].read)(q->msg, mbr->buf, BUFSIZE);
		if(convM2S(mbr->buf, &mh->rhdr, n) == 0){
			print("%lux %lux %lux %d format error in mntxmit %s\n", u->p, q->reader, q->writer, n, u->p->text);
		n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE);
		if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){
			print("format error in mntxmit\n");
			mnterrdequeue(q, mh);
			error(0, Ebadmsg);
		}


@@ 795,13 795,13 @@ mntxmit(Mnt *m, Mnthdr *mh)
		/*
		 * Hand response to correct recipient
		 */
if(q->writer == 0) print("response with empty queue %d %d %d: %d %d\n", mh->rhdr.type, mh->rhdr.err, mh->rhdr.fid, mh->thdr.type, mh->thdr.fid);
		if(q->writer==0) print("response with empty queue\n");
		for(ow=0,w=q->writer; w; ow=w,w=w->next)
			if(mh->rhdr.fid == w->thdr.fid
			&& mh->rhdr.type == w->thdr.type+1){
				Mntbuf *t;
				t = mbr;
				mbr = w->mbr;
				t = mh->mbr;
				mh->mbr = w->mbr;
				w->mbr = t;
				memcpy(&w->rhdr, &mh->rhdr, sizeof mh->rhdr);
				/* take recipient from queue */


@@ 814,7 814,6 @@ if(q->writer == 0) print("response with empty queue %d %d %d: %d %d\n", mh->rhdr
			}
		goto Read;
	}else{
		mh->mbr = mbr;
		mh->p = u->p;
		/* put self in queue */
		mh->next = q->writer;


@@ 822,7 821,7 @@ if(q->writer == 0) print("response with empty queue %d %d %d: %d %d\n", mh->rhdr
		qunlock(q);
		qlocked = 0;
		if(waserror()){		/* interrupted sleep */
			print("%lux interrupted i/o %d %d\n", u->p, mh->thdr.type, mh->thdr.fid);
			print("interrupted i/o\n");
			mnterrdequeue(q, mh);
			nexterror();
		}


@@ 832,7 831,6 @@ if(q->writer == 0) print("response with empty queue %d %d %d: %d %d\n", mh->rhdr
		qlocked = 1;
		if(q->reader == u->p)	/* i got promoted */
			goto Read;
		mbr = mh->mbr;		/* pick up my buffer */
		qunlock(q);
		qlocked = 0;
		goto Respond;


@@ 852,7 850,7 @@ if(q->writer == 0) print("response with empty queue %d %d %d: %d %d\n", mh->rhdr
	 */
	if(mh->thdr.type == Tread)
		memcpy(mh->thdr.data, mh->rhdr.data, mh->rhdr.count);
	mbfree(mbr);
	mbfree(mh->mbr);
	mbfree(mbw);
	poperror();
}

M port/proc.c => port/proc.c +1 -0
@@ 184,6 184,7 @@ loop:
	print("no procs\n");
	if(u == 0)
		panic("newproc");
	u->p->state = Wakeme;
	alarm(1000, wakeme, u->p);
	sched();
	goto loop;

M port/sysproc.c => port/sysproc.c +0 -2
@@ 404,8 404,6 @@ return0(void *a)
long
syssleep(ulong *arg)
{
	int ms;

	tsleep(&u->p->sleep, return0, 0, arg[0]);
	return 0;
}

M power/trap.c => power/trap.c +4 -0
@@ 361,6 361,10 @@ void
noted(Ureg **urp)
{
	lock(&u->p->debug);
	if(!u->notified){
		unlock(&u->p->debug);
		return;
	}
	u->notified = 0;
	memcpy(*urp, u->ureg, sizeof(Ureg));
	unlock(&u->p->debug);