~kris/9p

9hist

4910614536d4a073e991ca243bc20ab1484a9100 — David du Colombier 33 years ago e44d7f6
Plan 9 from Bell Labs 1993-01-23
9 files changed, 78 insertions(+), 36 deletions(-)

M pc/ether509.c
M port/chan.c
M port/devenv.c
M port/devkprof.c
M port/stil.c
M port/stip.c
M power/main.c
M ss/l.s
M ss/mmu.c
M pc/ether509.c => pc/ether509.c +46 -7
@@ 17,6 17,7 @@ enum {
	StartCoax	= 0x02,		/* Start Coaxial Transceiver */
	RxDisable	= 0x03,		/* RX Disable */
	RxEnable	= 0x04,		/* RX Enable */
	RxReset		= 0x05,		/* RX Reset */
	RxDiscard	= 0x08,		/* RX Discard Top Packet */
	TxEnable	= 0x09,		/* TX Enable */
	TxDisable	= 0x0A,		/* TX Disable */


@@ 49,6 50,7 @@ enum {

					/* Status/Interrupt Bits */
	Latch		= 0x0001,	/* Interrupt Latch */
	Failure		= 0x0002,	/* Adapter Failure */
	TxComplete	= 0x0004,	/* TX Complete */
	TxAvailable	= 0x0008,	/* TX Available */
	RxComplete	= 0x0010,	/* RX Complete */


@@ 71,6 73,15 @@ enum {
	RxErrCRC	= 0x2800,	/*   CRC */
	RxError		= 0x4000,	/* Error */
	RxEmpty		= 0x8000,	/* Incomplete or FIFO empty */

	FIFOdiag	= 0x04,		/* window 4 */

					/* FIFOdiag bits */
	TxOverrun	= 0x0400,	/* TX Overrrun */
	RxOverrun	= 0x0800,	/* RX Overrun */
	RxStatusOverrun	= 0x1000,	/* RX Status Overrun */
	RxUnderrun	= 0x2000,	/* RX Underrun */
	RxReceiving	= 0x8000,	/* RX Receiving */
};

#define COMMAND(board, cmd, a)	outs(board->io+Command, ((cmd)<<11)|(a))


@@ 252,7 263,7 @@ getdiag(Board *board)
	int bytes;

	COMMAND(board, SelectWindow, 4);
	bytes = ins(board->io+0x04);
	bytes = ins(board->io+FIFOdiag);
	COMMAND(board, SelectWindow, 1);
	return bytes & 0xFFFF;
}


@@ 341,21 352,22 @@ transmit(Ctlr *ctlr)
		/*
		 * If there's no room in the FIFO for this packet,
		 * set up an interrupt for when space becomes available.
		 * Output packet must be a multiple of 4 in length and
		 * we need 4 bytes for the preamble.
		 */
		if(tb->len > ins(board->io+TxFreeBytes)){
			COMMAND(board, SetTxAvailable, tb->len);
		len = ROUNDUP(tb->len, 4);
		if(len > ins(board->io+TxFreeBytes)+4){
			COMMAND(board, SetTxAvailable, len);
			break;
		}

		/*
		 * There's room, copy the packet to the FIFO and free
		 * the buffer back to the host.
		 * Output packet must be a multiple of 4 in length.
		 */
		len = ROUNDUP(tb->len, 4)/2;
		outs(board->io+Fifo, tb->len);
		outs(board->io+Fifo, 0);
		outss(board->io+Fifo, tb->pkt, len);
		outss(board->io+Fifo, tb->pkt, len/2);
		tb->owner = Host;
		ctlr->ti = NEXT(ctlr->ti, ctlr->ntb);
	}


@@ 366,11 378,38 @@ static void
interrupt(Ctlr *ctlr)
{
	Board *board = ctlr->board;
	ushort status;
	ushort status, diag;
	uchar txstatus, x;

	status = ins(board->io+Status);

	if(status & Failure){
		/*
		 * Adapter failure, try to find out why.
		 * Reset if necessary.
		 * What happens if Tx is active and we reset,
		 * need to retransmit?
		 * This probably isn't right.
		 */
		diag = getdiag(board);
		print("ether509: status #%ux, diag #%ux\n", status, diag);

		if(diag & TxOverrun){
			COMMAND(board, TxReset, 0);
			COMMAND(board, TxEnable, 0);
		}

		if(diag & RxUnderrun){
			COMMAND(board, RxReset, 0);
			attach(ctlr);
		}

		if(diag & TxOverrun)
			transmit(ctlr);

		return;
	}

	if(status & RxComplete){
		receive(ctlr);
		wakeup(&ctlr->rr);

M port/chan.c => port/chan.c +6 -6
@@ 671,20 671,20 @@ char*
nextelem(char *name, char *elem)
{
	int w;
	char *end;
	char *nend;
	Rune r;

	if(*name == '/')
		error(Efilename);
	end = utfrune(name, '/');
	if(end == 0)
		end = strchr(name, 0);
	w = end-name;
	nend = utfrune(name, '/');
	if(nend == 0)
		nend = strchr(name, 0);
	w = nend-name;
	if(w >= NAMELEN)
		error(Efilename);
	memmove(elem, name, w);
	elem[w] = 0;
	while(name < end){
	while(name < nend){
		name += chartorune(&r, name);
		if(r<sizeof(isfrog) && isfrog[r])
			error(Ebadchar);

M port/devenv.c => port/devenv.c +0 -3
@@ 264,13 264,10 @@ void
envcpy(Egrp *to, Egrp *from)
{
	Evalue **l, *ne, *e;
	char *p;

	l = &to->entries;
	qlock(from);
	for(e = from->entries; e; e = e->link) {
if(e->name == 0) panic("e->name == 0");
for(p = e->name; *p; p++) if(p - e->name >= NAMELEN) panic("e->name %.*s", NAMELEN, e->name);
		ne = smalloc(sizeof(Evalue));
		ne->name = smalloc(strlen(e->name)+1);
		strcpy(ne->name, e->name);

M port/devkprof.c => port/devkprof.c +5 -5
@@ 124,7 124,7 @@ kprofclose(Chan *c)
long
kprofread(Chan *c, void *va, long n, ulong offset)
{
	ulong end;
	ulong tabend;
	ulong w, *bp;
	uchar *a, *ea;



@@ 133,15 133,15 @@ kprofread(Chan *c, void *va, long n, ulong offset)
		return devdirread(c, va, n, kproftab, Nkproftab, devgen);

	case Kprofdataqid:
		end = kprof.nbuf*SZ;
		tabend = kprof.nbuf*SZ;
		if(offset & (SZ-1))
			error(Ebadarg);
		if(offset >= end){
		if(offset >= tabend){
			n = 0;
			break;
		}
		if(offset+n > end)
			n = end-offset;
		if(offset+n > tabend)
			n = tabend-offset;
		n &= ~(SZ-1);
		a = va;
		ea = a + n;

M port/stil.c => port/stil.c +3 -3
@@ 736,16 736,16 @@ void
ilackproc(void *a)
{
	Ipifc *ifc;
	Ipconv **base, **p, **end, *s;
	Ipconv **base, **p, **last, *s;
	Ilcb *ic;

	ifc = (Ipifc*)a;
	base = ifc->conv;
	end = &base[Nipconv];
	last = &base[Nipconv];

	for(;;) {
		tsleep(&ilackr, return0, 0, Iltickms);
		for(p = base; p < end && *p; p++) {
		for(p = base; p < last && *p; p++) {
			s = *p;
			ic = &s->ilctl;
			ic->timeout += Iltickms;

M port/stip.c => port/stip.c +3 -3
@@ 370,7 370,7 @@ ip_reassemble(int offset, Block *bp, Etherhdr *ip)
	ushort id;
	Block *bl, **l, *last, *prev;
	int ovlap, len, fragsize, pktposn;
	int end;
	int fend;

	/* Check ethrnet has handed us a contiguous buffer */
	if(bp->next)


@@ 453,10 453,10 @@ ip_reassemble(int offset, Block *bp, Etherhdr *ip)
	/* Check to see if succeeding segments overlap */
	if(bp->next) {
		l = &bp->next;
		end = BLKFRAG(bp)->foff + BLKFRAG(bp)->flen;
		fend = BLKFRAG(bp)->foff + BLKFRAG(bp)->flen;
		/* Take completely covered segements out */
		while(*l){
			ovlap = end - BLKFRAG(*l)->foff;
			ovlap = fend - BLKFRAG(*l)->foff;
			if(ovlap <= 0)
				break;
			fragstat.succ++;

M power/main.c => power/main.c +4 -4
@@ 464,16 464,16 @@ void
confread(void)
{
	char *line;
	char *end;
	char *lend;

	/*
	 *  process configuration file
	 */
	line = confbuf;
	while(end = strchr(line, '\n')){
		*end = 0;
	while(lend = strchr(line, '\n')){
		*lend = 0;
		confset(line);
		line = end+1;
		line = lend+1;
	}
}


M ss/l.s => ss/l.s +8 -2
@@ 7,12 7,18 @@ TEXT	start(SB), $-4

	/* get virtual, fast */
	/* we are executing in segment 0, mapped to pmeg 0. stack is there too */
	/* get virtual by mapping segment(KZERO) to pmeg 0., and next to 1 */
	/* get virtual by mapping segment(KZERO) to pmeg 0, and next to 1, etc. */
	MOVW	$KZERO, R7
	MOVB	R0, (R7, 3)
	MOVW	$(KZERO+BY2SEGM), R7
	ADD	$(BY2SEGM), R7
	MOVW	$1, R9
	MOVB	R9, (R7, 3)
	ADD	$(BY2SEGM), R7
	MOVW	$2, R9
	MOVB	R9, (R7, 3)
	ADD	$(BY2SEGM), R7
	MOVW	$3, R9
	MOVB	R9, (R7, 3)
	/* now mapped correctly.  jmpl to where we want to be */
	MOVW	$setSB(SB), R2


M ss/mmu.c => ss/mmu.c +3 -3
@@ 324,9 324,9 @@ mmuinit(void)
	Ctx *ctx;

	/*
	 *  mmuinit is entered with PMEG's 0 & 1 providing mappng
	 *  for virtual addresses KZERO<->KZERO+2*BY2SEGM to physical
	 *  0<->2*BY2SEGM
	 *  mmuinit is entered with PMEG's 0-3 providing mapping
	 *  for virtual addresses KZERO<->KZERO+4*BY2SEGM to physical
	 *  0<->4*BY2SEGM
	 */
	compile();