~kris/9p

9hist

82c8bd9155eb43b22edb049dfa12fa196a2917fe — David du Colombier 34 years ago fa5fb28
Plan 9 from Bell Labs 1992-04-09
M pc/devether.c => pc/devether.c +30 -27
@@ 111,7 111,6 @@ struct Ctlr {
	Queue	rq;
	uchar	bnry;
	uchar	curr;
	uchar	ovw;

	Etherpkt *xpkt;
	QLock	xl;


@@ 145,7 144,7 @@ isxfree(void *arg)
{
	Ctlr *cp = arg;

	return cp->xbusy == 0 && cp->ovw == 0;
	return cp->xbusy == 0;
}

static void


@@ 378,22 377,8 @@ intr(Ureg *ur)
			cp->xbusy = 0;
			wakeup(&cp->xr);
		}
		/*
		 * the receive ring is full.
		 * put the NIC into loopback mode to give
		 * kproc a chance to process some packets.
		 */
		if(isr & Ovw){
			outb(cp->iobase+Cr, 0x21);	/* Page0, RD2|STP */
			outb(cp->iobase+Rbcr0, 0);
			outb(cp->iobase+Rbcr1, 0);
			while((inb(cp->iobase+Isr) & Rst) == 0)
				delay(1);
			outb(cp->iobase+Tcr, 0x20);	/* LB0 */
			outb(cp->iobase+Cr, 0x22);	/* Page0, RD2|STA */
			cp->ovw = 1;
		if(isr & Ovw)
			cp->overflows++;
		}
		/*
		 * we have received packets.
		 * this is the only place, other than the init code,


@@ 404,6 389,8 @@ intr(Ureg *ur)
		if(isr & (Ovw|Prx)){
			outb(cp->iobase+Cr, 0x62);	/* Page1, RD2|STA */
			cp->curr = inb(cp->iobase+Curr);
if(cp->curr == 0)
    print("C0: b%d i%ux\n", cp->bnry, isr);
			outb(cp->iobase+Cr, 0x22);	/* Page0, RD2|STA */
			wakeup(&cp->rr);
		}


@@ 451,8 438,14 @@ etherreset(void)
{
	Ctlr *cp = &ctlr[0];
	int i;
	uchar msr;

	cp->iobase = IObase;
	msr = 0x40|inb(cp->iobase);
	outb(cp->iobase, msr);
for(i = 0; i < 0x10; i++)
    print("#%2.2ux ", inb(cp->iobase+i));
print("\n");
	for(i = 0; i < sizeof(cp->ea); i++)
		cp->ea[i] = inb(cp->iobase+EA+i);
	init(cp);


@@ 574,16 567,6 @@ etherkproc(void *arg)
			cp->bnry = PREV(bnry, 32);
			outb(cp->iobase+Bnry, cp->bnry);
		}

		/*
		 * if we idled input because of overflow,
		 * restart
		 */
		if(cp->ovw){
			cp->ovw = 0;
			outb(cp->iobase+Tcr, 0);
			wakeup(&cp->xr);
		}
	}
}



@@ 669,3 652,23 @@ etherwrite(Chan *c, char *a, long n, ulong offset)
{
	return streamwrite(c, a, n, 0);
}

void
etherdump(void)
{
	Ctlr *cp = &ctlr[0];
	uchar bnry, curr, isr;
	int s;

	s = splhi();
	bnry = inb(cp->iobase+Bnry);
	outb(cp->iobase+Cr, 0x62);			/* Page1, RD2|STA */
	curr = inb(cp->iobase+Curr);
	outb(cp->iobase+Cr, 0x22);			/* Page0, RD2|STA */
	isr = inb(cp->iobase+Isr);
	print("b%d c%d x%d B%d C%d I%ux",
	    cp->bnry, cp->curr, cp->xbusy, bnry, curr, isr);
	print("\t%d %d %d %d %d %d %d\n", cp->inpackets, cp->opackets,
	    cp->crcs, cp->oerrs, cp->frames, cp->overflows, cp->buffs);
	splx(s);
}

M pc/devuart.c => pc/devuart.c +6 -2
@@ 236,8 236,10 @@ uartintr(Uart *up)
			break;
	
		case 4:	/* received data available */
			cq = up->iq;
			ch = uartrdreg(up, Data) & 0xff;
			cq = up->iq;
			if(cq == 0)
				break;
			if(cq->putc)
				(*cq->putc)(cq, ch);
			else


@@ 246,6 248,8 @@ uartintr(Uart *up)
	
		case 2:	/* transmitter empty */
			cq = up->oq;
			if(cq == 0)
				break;
			lock(cq);
			ch = getc(cq);
			if(ch < 0){


@@ 263,7 267,7 @@ uartintr(Uart *up)
		default:
			if(s&1)
				return;
/*			print("weird modem interrupt\n");/**/
			print("weird modem interrupt\n");
			break;
		}
	}

M pc/fns.h => pc/fns.h +1 -0
@@ 61,6 61,7 @@ void	trapinit(void);
int	tas(void*);
void	uartclock(void);
void	uartintr0(Ureg*);
void	uartspecial(int, IOQ*, IOQ*, int);
void	vgainit(void);
#define	waserror()	(u->nerrlab++, setlabel(&u->errlab[u->nerrlab-1]))
#define	kmapperm(x)	kmap(x)

M pc/kbd.c => pc/kbd.c +0 -2
@@ 223,8 223,6 @@ kbdinit(void)

		/* set up /dev/eia0 as the mouse */
		uartspecial(0, 0, &mouseq, 1200);
print("uartspecial done\n");
delay(1000);
		break;
	}
}

M pc/main.c => pc/main.c +3 -1
@@ 25,9 25,9 @@ main(void)
	mmuinit();
	trapinit();
	mathinit();
	kbdinit();
	clockinit();
	faultinit();
	kbdinit();
	procinit0();
	initseg();
	grpinit();


@@ 422,6 422,8 @@ exit(void)
{
	int i;

etherdump();
return;
	u = 0;
	print("exiting\n");
	switch(machtype){

M pc/trap.c => pc/trap.c +0 -1
@@ 253,7 253,6 @@ trap(Ureg *ur)
void
dumpregs(Ureg *ur)
{
splhi();
	if(u)
		print("registers for %s %d\n", u->p->text, u->p->pid);
	else

M pc/vga.c => pc/vga.c +0 -1
@@ 174,7 174,6 @@ screeninit(void)
	ulong *l;

	setmode(&mode12);
	bigcursor();

	/*
	 *  swizzle the font longs.

M port/devcons.c => port/devcons.c +1 -1
@@ 13,9 13,9 @@ struct {
	QLock;			/* qlock to getc */
}klogq;

IOQ	mouseq;
IOQ	lineq;			/* lock to getc; interrupt putc's */
IOQ	printq;
IOQ	mouseq;
KIOQ	kbdq;

static Ref	ctl;			/* number of opens to the control file */

M port/devdk.c => port/devdk.c +28 -1
@@ 95,6 95,7 @@ struct Line {
	char	addr[64];
	char	raddr[64];
	char	ruser[32];
	char	other[32];
	Dk *dp;			/* interface contianing this line */
};



@@ 200,6 201,7 @@ static int	dklisten(Chan*);
static void	dkfilladdr(Chan*, char*, int);
static void	dkfillraddr(Chan*, char*, int);
static void	dkfillruser(Chan*, char*, int);
static void	dkfillother(Chan*, char*, int);

extern Qinfo dkinfo;



@@ 293,7 295,7 @@ dkalloc(char *name, int ncsc, int lines)
	dp->net.listen = dklisten;
	dp->net.clone = dkcloneline;
	dp->net.prot = dp->prot;
	dp->net.ninfo = 4;
	dp->net.ninfo = 5;
	dp->net.info[0].name = "addr";
	dp->net.info[0].fill = dkfilladdr;
	dp->net.info[1].name = "raddr";


@@ 302,6 304,8 @@ dkalloc(char *name, int ncsc, int lines)
	dp->net.info[2].fill = dkfillruser;
	dp->net.info[3].name = "stats";
	dp->net.info[3].fill = urpfillstats;
	dp->net.info[4].name = "other";
	dp->net.info[4].fill = dkfillother;

	unlock(&dklock);
	return dp;


@@ 545,6 549,7 @@ out:
	if(lp->lineno == dp->ncsc)
		dp->csc = 0;
	netdisown(&dp->net, lp->lineno);
	lp->window = 0;

	lock(dp);
	dp->ref--;


@@ 945,6 950,11 @@ dkfillruser(Chan *c, char *buf, int len)
{
	strncpy(buf, dk[c->dev].linep[STREAMID(c->qid.path)]->ruser, len);
}
void
dkfillother(Chan *c, char *buf, int len)
{
	strncpy(buf, dk[c->dev].linep[STREAMID(c->qid.path)]->other, len);
}

/*
 *  send a message to the datakit on the common signaling line


@@ 1152,6 1162,7 @@ dkcall(int type, Chan *c, char *addr, char *nuser, char *machine)
	 */
	strncpy(lp->addr, addr, sizeof(lp->addr)-1);
	strncpy(lp->raddr, addr, sizeof(lp->raddr)-1);
	sprint(lp->other, "w=%d", lp->window);

	/*
	 *  reset the protocol


@@ 1366,6 1377,22 @@ dkanswer(Chan *c, int line, int code)
	streamwrite(dc, reply, strlen(reply), 1);
	close(dc);
	poperror();

	/*
 	 *  set window size
	 */
	if(code == 0){
		if(waserror()){
			close(dc);
			nexterror();
		}
		sprint(reply, "init %d %d", lp->window, Streamhi);
		dc = dkopenline(dp, line);
		dc->qid.path = STREAMQID(line, Sctlqid);
		streamwrite(dc, reply, strlen(reply), 1);
		close(dc);
		poperror();
	}
}

/*

M port/portdat.h => port/portdat.h +2 -2
@@ 642,8 642,8 @@ enum {
	Sdataqid = Shighqid,
	Sctlqid = Sdataqid-1,
	Slowqid = Sctlqid,
	Streamhi= (9*1024),		/* byte count high water mark */
	Streambhi= 32,			/* block count high water mark */
	Streamhi= (32*1024),		/* byte count high water mark */
	Streambhi= 128,			/* block count high water mark */
};

/*

M port/sturp.c => port/sturp.c +1 -1
@@ 943,7 943,7 @@ initoutput(Urp *up, int window)
	if(up->maxblock < 64)
		up->maxblock = 64;
	up->maxblock -= 4;
	up->maxout = 3;
	up->maxout = 4;

	/*
	 *  set sequence varialbles

M power/trap.c => power/trap.c +2 -1
@@ 421,6 421,7 @@ notify(Ureg *ur)
		memmove((char*)sp, u->note[0].msg, ERRLEN);
		sp -= 3*BY2WD;
		*(ulong*)(sp+2*BY2WD) = sp+3*BY2WD;	/* arg 2 is string */
		u->svr1 = ur->r1;			/* save away r1 */
		ur->r1 = (ulong)u->ureg;		/* arg 1 is ureg* */
		*(ulong*)(sp+0*BY2WD) = 0;		/* arg 0 is pc */
		ur->usp = sp;


@@ 550,7 551,7 @@ syscall(Ureg *aur)
		noted(&aur, *(ulong*)(sp+BY2WD));	/* doesn't return */
	splhi();
	if(r1!=FORK && (u->nnote || p->procctl)){
		u->svr1 = ret;
		ur->r1 = ret;				/* load up for noted() */
		if(notify(ur))
			return ur->r1;
	}

M ss/trap.c => ss/trap.c +2 -1
@@ 278,6 278,7 @@ notify(Ureg *ur)
		sp -= 3*BY2WD;
		*(ulong*)(sp+2*BY2WD) = sp+3*BY2WD;	/* arg 2 is string */
		*(ulong*)(sp+1*BY2WD) = (ulong)u->ureg;	/* arg 1 is ureg* (compat) */
		u->svr7 = ur->r7;			/* save away r7 */
		ur->r7 = (ulong)u->ureg;		/* arg 1 is ureg* */
		*(ulong*)(sp+0*BY2WD) = 0;		/* arg 0 is pc */
		ur->usp = sp;


@@ 410,7 411,7 @@ syscall(Ureg *aur)

	splhi();
	if(r7!=FORK && (u->p->procctl || u->nnote)){
		u->svr7 = ret;
		ur->r7 = ret;				/* load up for noted() */
		if(notify(ur))
			return ur->r7;
	}