~kris/9p

9hist

e2c5e7270740c7a8f058aa0edcb75d2bab6bf95a — David du Colombier 34 years ago 8e6bf28
Plan 9 from Bell Labs 1992-03-01
8 files changed, 82 insertions(+), 87 deletions(-)

M gnot/l.s
M port/devmnt.c
M port/devwren.c
M port/ipdat.h
M port/proc.c
M port/stil.c
M port/swap.c
M power/devhotrod.c
M gnot/l.s => gnot/l.s +8 -4
@@ 193,7 193,8 @@ TEXT	illegal(SB), $0
	MOVL	((8+8)*BY2WD)(A7), A0
	MOVL	A0, USP
	MOVEM	(A7), $0x7FFF
	ADDL	$((8+8+1)*BY2WD+BY2WD), A7
	ADDL	$((8+8+1)*BY2WD), A7
	MOVL	$0, (A7)+
	RTE

TEXT	systrap(SB), $0


@@ 210,7 211,8 @@ TEXT	systrap(SB), $0
	MOVL	((1+8+8)*BY2WD)(A7), A0
	MOVL	A0, USP
	MOVL	((1+8+6)*BY2WD)(A7), A6
	ADDL	$((1+8+8+1)*BY2WD+BY2WD), A7
	ADDL	$((1+8+8+1)*BY2WD), A7
	MOVL	$0, (A7)+
	RTE

TEXT	buserror(SB), $0


@@ 228,7 230,8 @@ TEXT	buserror(SB), $0
	MOVL	((8+8)*BY2WD)(A7), A0
	MOVL	A0, USP
	MOVEM	(A7), $0x7FFF
	ADDL	$((8+8+1)*BY2WD+BY2WD), A7
	ADDL	$((8+8+1)*BY2WD), A7
	MOVL	$0, (A7)+
	RTE

TEXT	tacintr(SB), $0			/* level 1 */


@@ 307,7 310,8 @@ retintr:
	MOVL	((8+8)*BY2WD)(A7), A0
	MOVL	A0, USP
	MOVEM	(A7), $0x7FFF
	ADDL	$((8+8+1)*BY2WD+BY2WD), A7
	ADDL	$((8+8+1)*BY2WD), A7
	MOVL	$0, (A7)+
	RTE

GLOBL	duarttimer+0(SB),$4

M port/devmnt.c => port/devmnt.c +14 -1
@@ 73,6 73,8 @@ enum
	Tagspace = 1,
	Flushspace = 64,
	Flushtag = 512,

	ALIGN = 256,		/* Vme block mode alignment */
};

void


@@ 81,6 83,8 @@ mntreset(void)
	Mnt *me, *md;
	Mntrpc *re, *rd;
	ushort tag, ftag;
	ulong p;
	int i;

	mntalloc.mntarena = ialloc(conf.nmntdev*sizeof(Mnt), 0);
	mntalloc.mntfree = mntalloc.mntarena;


@@ 99,13 103,22 @@ mntreset(void)
	mntalloc.rpcfree = ialloc(conf.nmntbuf*sizeof(Mntrpc), 0);
	mntalloc.rpcarena = mntalloc.rpcfree;
	re = &mntalloc.rpcfree[conf.nmntbuf];

	/* Align mount buffers to 256 byte boundaries so we can use burst mode vme transfers */
	p = (ulong)ialloc(0, 0);
	if(p&(ALIGN-1))
		ialloc(ALIGN-(p&(ALIGN-1)), 0);

	i = MAXRPC+(ALIGN-1);
	i &= ~(ALIGN-1);

	for(rd = mntalloc.rpcfree; rd < re; rd++) {
		rd->list = rd+1;
		rd->request.tag = tag++;
		rd->flushbase = ftag;
		rd->flushtag = ftag;
		ftag += Flushspace;
		rd->rpc = ialloc(MAXRPC, 0);
		rd->rpc = ialloc(i, 0);
	}
	re[-1].list = 0;


M port/devwren.c => port/devwren.c +32 -25
@@ 33,9 33,11 @@ struct Partition

struct Drive
{
	QLock;
	ulong		bytes;			/* bytes per block */
	int		npart;			/* actual number of partitions */
	int		drive;
	int		ready;			/* true if ever ready */
	Partition	p[Npart];
};



@@ 263,31 265,34 @@ wrenpart(int dev)
	ulong n;
	int i;

	if(scsiready(dev)){
	dp = &wren[dev];
	if(waserror()){
		qunlock(dp);
		nexterror();
	}
	qlock(dp);
	if(!dp->ready){
		scsiready(dev);
		scsisense(dev, buf);
		if(scsiready(dev))
			print("scsi %d.%d not ready: sense 0x%2.2ux, code 0x%2.2ux\n",
				dev>>3, dev&7, buf[2], buf[12]);
		if (scsicap(dev, buf))
			error(Eio);
		dp->drive = dev;
		dp->ready = 1;

		/*
		 *  we always have a partition for the whole disk
		 *  and one for the partition table
		 */
		dp->bytes = (buf[4]<<24)+(buf[5]<<16)+(buf[6]<<8)+(buf[7]);
		pp = &dp->p[0];
		strcpy(pp->name, "disk");
		pp->start = 0;
		pp->end = (buf[0]<<24)+(buf[1]<<16)+(buf[2]<<8)+(buf[3]) + 1;
		pp++;
		strcpy(pp->name, "partition");
		pp->start = dp->p[0].end - 1;
		pp->end = dp->p[0].end;
	}
	if(scsicap(dev, buf))
		error(Eio);
	dp = &wren[dev];
	dp->drive = dev;

	/*
	 *  we always have a partition for the whole disk
	 *  and one for the partition table
	 */
	dp->bytes = (buf[4]<<24)+(buf[5]<<16)+(buf[6]<<8)+(buf[7]);
	pp = &dp->p[0];
	strcpy(pp->name, "disk");
	pp->start = 0;
	pp->end = (buf[0]<<24)+(buf[1]<<16)+(buf[2]<<8)+(buf[3]) + 1;
	pp++;
	strcpy(pp->name, "partition");
	pp->start = dp->p[0].end - 1;
	pp->end = dp->p[0].end;
	dp->npart = 2;

	/*
	 *  read partition table from disk, null terminate


@@ 304,10 309,10 @@ wrenpart(int dev)
	/*
	 *  parse partition table.
	 */
	pp = &dp->p[2];
	n = getfields(rawpart, line, Npart+1, '\n');
	if(strncmp(line[0], MAGIC, sizeof(MAGIC)-1) == 0){
		for(i = 1; i < n; i++){
			pp++;
			if(getfields(line[i], field, 3, ' ') != 3)
				break;
			strncpy(pp->name, field[0], NAMELEN);


@@ 315,9 320,11 @@ wrenpart(int dev)
			pp->end = strtoul(field[2], 0, 0);
			if(pp->start > pp->end || pp->start >= dp->p[0].end)
				break;
			dp->npart++;
			pp++;
		}
	}
	dp->npart = pp - dp->p;
	poperror();
	scsifree(b);
	qunlock(dp);
}

M port/ipdat.h => port/ipdat.h +2 -0
@@ 115,6 115,8 @@ struct Ilcb				/* Control block */
	int	slowtime;		/* Slow time counter */
	int	fasttime;		/* Retransmission timer */
	int	acktime;		/* Acknowledge timer */
	int	querytime;		/* Query timer */
	int	deathtime;		/* Time to kill connection */

	int	rtt;			/* Average round trip time */
	ulong	rttack;			/* The ack we are waiting for */

M port/proc.c => port/proc.c +0 -3
@@ 65,9 65,6 @@ schedinit(void)		/* never returns */
		if(p->state == Running)
			ready(p);
		else if(p->state == Moribund) {
			/*
			 * The Grim Reaper lays waste the bodies of the dead
			 */
			p->pid = 0;
			/* 
			 * Holding locks from pexit:

M port/stil.c => port/stil.c +18 -1
@@ 28,10 28,12 @@ enum
	Fasttime 	= 4*Iltickms,
	Acktime		= 2*Iltickms,
	Ackkeepalive	= 6000*Iltickms,
	Querytime	= 60*Iltickms,		/* time between queries */
	Keepalivetime	= 10*Querytime,		/* keep alive time */
	Defaultwin	= 20,
};

#define Starttimer(s)	{(s)->timeout = 0; (s)->fasttime = Fasttime;}
#define Starttimer(s)	{(s)->timeout = 0; (s)->fasttime = Fasttime; }
/* Packet dropping putnext for testing */
#define DPUTNEXT(q, b)	if((MACHP(0)->ticks&7) != 3)PUTNEXT(q, b);else{freeb(b);print(".");}



@@ 299,6 301,8 @@ ilrcvmsg(Ipconv *ipc, Block *bp)
			ic->recvd = 0;
			ic->rstart = nhgetl(ih->ilid);
			ic->slowtime = Slowtime;
			ic->querytime = Keepalivetime;
			ic->deathtime = Keepalivetime;
			ic->window = Defaultwin;
			ilprocess(new, ih, bp);



@@ 326,6 330,8 @@ _ilprocess(Ipconv *s, Ilhdr *h, Block *bp)
	ack = nhgetl(h->ilack);
	ic = &s->ilctl;

	ic->querytime = Keepalivetime;
	ic->deathtime = Keepalivetime;
	switch(ic->state) {
	default:
		panic("il unknown state");


@@ 711,6 717,17 @@ ilackproc(void *a)
				ic->acktime -= Iltickms;
				if(ic->acktime <= 0)
					ilsendctl(s, 0, Ilack, ic->next, ic->recvd);
				ic->querytime -= Iltickms;
				if(ic->querytime <= 0){
					ic->deathtime -= Querytime;
					if(ic->deathtime < 0){
						ic->state = Ilclosed;
						ilhangup(s, etime);
						break;
					}
					ilsendctl(s, 0, Ilquerey, ic->next, ic->recvd);
					ic->querytime = Querytime;
				}
				if(ic->unacked == 0) {
					ic->timeout = 0;
					break;

M port/swap.c => port/swap.c +8 -19
@@ 15,7 15,7 @@ int	canflush(Proc *p, Segment*);

enum
{
	Maxpages = 500,		/* Max number of pageouts per segment pass */
	Maxpages = 300,		/* Max number of pageouts per segment pass */
};

Image 	swapimage;


@@ 109,16 109,14 @@ pager(void *junk)
		if(waserror()) 
			panic("pager: os error\n");

		u->p->psstate = "Idle";
		sleep(&swapalloc.r, needpages, 0);
		u->p->psstate = "Pageout";

		for(p = proctab(0); p < ep; p++) {
			if(p->state == Dead || p->kp)
				continue;

			u->p->psstate = "Idle";
			sleep(&swapalloc.r, needpages, 0);
			u->p->psstate = "Pageout";

			if(p->state == Dead || p->kp)
				continue;
			if(swapimage.c) {
				for(i = 0; i < NSEG; i++)
					if(s = p->seg[i]) {


@@ 235,17 233,6 @@ pagepte(int type, Segment *s, Page **pg)
		*pg = 0;
		break;
	case SG_DATA:
		/* Unmodified data may be reverted to a demand load record if it
		 * is not the last page in the DSEG
		 */
/*							BUG: needs to check the last page
		if((outp->modref&PG_MOD) == 0) {
			putpage(outp);
			*pg = 0;
			break;
		}
*/
							/* NO break */	
	case SG_BSS:
	case SG_STACK:
	case SG_SHARED:


@@ 284,15 271,17 @@ executeio(void)

	for(i = 0; i < ioptr; i++) {
		out = iolist[i];
#ifdef asdf
		if(out->ref > 2) {
			lockpage(out);
			if(out->ref > 2) {		/* Page was reclaimed, abort io */
			if(out->ref > 2) {	
				out->ref -= 2;
				unlockpage(out);
				continue;
			}
			unlockpage(out);
		}
#endif
		k = kmap(out);
		kaddr = (char*)VA(k);
		qlock(&c->wrl);

M power/devhotrod.c => power/devhotrod.c +0 -34
@@ 181,40 181,6 @@ hotrodopen(Chan *c, int omode)
		hotwait(hmp);
		delay(100);
		print("reset\n");

#ifdef ENABMEMTEST
		/*
		 * Issue test
		 */
		mp = &u->khot;
		mp->cmd = Utest;
		mp->param[0] = MP2VME(testbuf);
		mp->param[1] = NTESTBUF;
		hmp = hotsend(hp, &((User*)(u->p->upage->pa|KZERO))->khot);
		hotwait(hmp);
		delay(100);
		print("testing addr %lux size %ld\n", mp->param[0], mp->param[1]);
		if(mp->param[0] == MP2VME(testbuf)){
			print("no way jose\n");
			unlock(&hp->busy);
			error(Egreg);
		}
			
		for(;;){
			print("-");
			mem(hp->addr, &hp->addr->ram[(mp->param[0]-0x40000)/sizeof(ulong)], mp->param[1]);
		}
#endif
#ifdef ENABBUSTEST
		/*
		 * Issue test
		 */
		mp = &u->khot;
		mp->cmd = Ubus;
		hmp = hotsend(hp, &((User*)(u->p->upage->pa|KZERO))->khot);
		hotwait(hmp);
for(;;) ;
#endif
	}
	c->mode = openmode(omode);
	c->flag |= COPEN;