~kris/9p

9hist

854cf1d75978472b8fffb204d0f578c8bd08fef1 — David du Colombier 35 years ago fd71a85
Plan 9 from Bell Labs 1991-04-26
7 files changed, 31 insertions(+), 86 deletions(-)

M port/chan.c
M port/devdup.c
M port/devmnt.c
M port/sturp.c
M power/l.s
M power/main.c
M power/mmu.c
M port/chan.c => port/chan.c +0 -12
@@ 111,18 111,6 @@ loop:
}

void
freechan(Chan *c)
{
	if(decref(c) == 0){
		c->flag = CFREE;
		lock(&chanalloc);
		c->next = chanalloc.free;
		chanalloc.free = c;
		unlock(&chanalloc);
	}
}

void
close(Chan *c)
{
	if(c->flag & CFREE)

M port/devdup.c => port/devdup.c +1 -12
@@ 61,18 61,7 @@ dupwalk(Chan *c, char *name)
void
dupstat(Chan *c, char *db)
{
	int fd;
	Chan *f;

	if(c->qid.path == CHDIR){
		devstat(c, db, (Dirtab *)0, 0L, dupgen);
	}else{
		fd = c->qid.path;
		SET(f);
		if(fd<0 || NFD<=fd || (f=u->fd[fd])==0)
			error(Ebadfd);
		(*devtab[f->type].stat)(f, (char*)db);
	}
	devstat(c, db, (Dirtab *)0, 0L, dupgen);
}

Chan *

M port/devmnt.c => port/devmnt.c +15 -24
@@ 398,16 398,6 @@ mntclwalk(Chan *c, char *name)
	Chan *nc;

	nc = newchan();
	nc->type = c->type;
	nc->dev = c->dev;
	nc->qid = c->qid;
	nc->mode = c->mode;
	nc->flag = c->flag;
	nc->offset = c->offset;
	nc->mnt = c->mnt;
	nc->aux = c->aux;
	nc->mchan = c->mchan;
	nc->mqid = c->qid;
	mh = 0;
	if(waserror()){
		close(nc);


@@ 422,21 412,24 @@ mntclwalk(Chan *c, char *name)
	mh->thdr.newfid = nc->fid;
	strcpy(mh->thdr.name, name);
	mntxmit(m, mh);
	poperror();
	if(mh->rhdr.fid == mh->thdr.fid){
		/*
		 *  just free the chan, the other side has
		 *  already clunked
		 */
		freechan(nc);
		nc = 0;
	} else {
		/*
		 *  it worked, keep the channel
		 *  hack to indicate the most common error
		 */
		nc->qid = mh->rhdr.qid;
		incref(m);
		errors("directory entry not found");
	}
	nc->type = c->type;
	nc->dev = c->dev;
	nc->mode = c->mode;
	nc->flag = c->flag;
	nc->offset = c->offset;
	nc->mnt = c->mnt;
	nc->aux = c->aux;
	nc->mchan = c->mchan;
	nc->mqid = c->qid;
	nc->qid = mh->rhdr.qid;
	incref(m);
	poperror();
	mhfree(mh);
	return nc;
}


@@ 791,12 784,10 @@ mntxmit(Mnt *m, Mnthdr *mh)
		print("type mismatch %d %d\n", mh->rhdr.type, mh->thdr.type+1);
		error(Ebadmsg);
	}
#ifdef PHILW_HACK
	if(mh->rhdr.fid != mh->thdr.fid){
	if(mh->rhdr.fid!=mh->thdr.fid && mh->thdr.type!=Tclwalk){
		print("fid mismatch %d %d type %d\n", mh->rhdr.fid, mh->thdr.fid, mh->rhdr.type);
		error(Ebadmsg);
	}
#endif

	/*
	 * Copy out on read

M port/sturp.c => port/sturp.c +1 -0
@@ 861,6 861,7 @@ rcvack(Urp *up, int msg)
	}

	wakeup(&urpkr);
	wakeup(&up->r);
}

/*

M power/l.s => power/l.s +5 -11
@@ 246,12 246,13 @@ TEXT	vector0(SB), $-4

	MOVW	$utlbmiss(SB), R26
	MOVW	M(TLBVIRT), R27
	SLL	$(STLBLOG-9), R27		/* delay slot fodder */
	SRL	$(6-3), R27			/* delay slot fodder, right adjust */
	JMP	(R26)

TEXT	utlbmiss(SB), $-4

	SRL	$(STLBLOG), R27, R26
	SRL	$6, R27, R26			/* right adjusted vpn */
	SLL	$(STLBLOG-6), R27		/* left adjusted pid */
	XOR	R26, R27
	AND	$((STLBSIZE-1)<<3), R27
	MOVW	R27, M(TLBPHYS)			/* scratch register, store */


@@ 273,17 274,10 @@ TEXT	utlbmiss(SB), $-4
	MOVW	(R27), R27
	BNE	R26, R27, stlbm

	TLBP
	MOVW	M(EPC), R27
	MOVW	M(INDEX), R26
	BGEZ	R26, uind
	TLBWR
	NOOP
	MOVW	M(EPC), R27
	RFE	(R27)
uind:
	TLBWI
	NOOP
	RFE	(R27)		

stlbm:	
	MOVW	$exception(SB), R26
	JMP	(R26)

M power/main.c => power/main.c +1 -1
@@ 106,7 106,7 @@ vecinit(void)
		*p++ = *q++;
	p = (ulong*)UTLBMISS;
	q = (ulong*)vector0;
	for(size=0; size<4; size++)
	for(size=0; size<0x80/sizeof(*q); size++)
		*p++ = *q++;
}


M power/mmu.c => power/mmu.c +8 -26
@@ 38,7 38,7 @@ newtlbpid(Proc *p)
	int i, s;
	Proc *sp;
	char *h;
/*

	s = m->lastpid;
	if(s >= NTLBPID)
		s = 1;


@@ 51,26 51,16 @@ newtlbpid(Proc *p)
	}while(h[i] && i != s);
	
	if(i == s){
		sp = m->pidproc[i];
		if(sp){
			if(sp->pidonmach[m->machno] == i)
				sp->pidonmach[m->machno] = 0;
			purgetlb(i);
		}
		i++;
		if(i >= NTLBPID)
			i = 1;
	}
*/
	i = m->lastpid+1;
	if(i >= NTLBPID)
		i = 1;
	sp = m->pidproc[i];
	if(sp){
		if(sp->pidonmach[m->machno] == i)
			sp->pidonmach[m->machno] = 0;

		sp->pidonmach[m->machno] = 0;
		purgetlb(i);
	}

	m->lastpid = i;
	m->pidproc[i] = p;
	return i;


@@ 105,16 95,16 @@ void
purgetlb(int pid)
{
	Softtlb *entry, *etab;
	char p[NTLBPID];
	char *p;
	Proc *sp;
	int i, rpid;

	if(m->pidproc[pid] == 0)
	if(m->pidhere[pid] == 0)
		return;

	m->tlbpurge++;
	m->pidproc[pid] = 0;
	memset(p, 0, sizeof p);
	p = m->pidhere;
	memset(m->pidhere, 0, sizeof m->pidhere);
	for(i=TLBROFF; i<NTLB; i++)
		if(TLBPID(gettlbvirt(i)) == pid)
			puttlbx(i, KZERO | PTEPID(i), 0);


@@ 128,14 118,6 @@ purgetlb(int pid)
		}else
			p[rpid] = 1;
	}
	for(i = 0; i < NTLBPID; i++)
		if(p[i] == 0){
			sp = m->pidproc[i];
			if(sp && sp->pidonmach[m->machno] == i)
				sp->pidonmach[m->machno] = 0;
			m->pidproc[i] = 0;
			m->pidhere[i] = 0;
		}
}

void