~kris/9p

9hist

22c3b720ac168e9417d1521c395ac0cb936bb63b — David du Colombier 32 years ago 2abcf03
Plan 9 from Bell Labs 1993-11-19
6 files changed, 26 insertions(+), 31 deletions(-)

M pc/devether.c
M pc/ether509.c
M pc/ether8003.c
M pc/ether8390.c
M pc/etherif.h
M port/devcons.c
M pc/devether.c => pc/devether.c +2 -3
@@ 138,18 138,17 @@ etherintr(Ureg *ur)
	}
}

#define NCARD 32
static struct {
	char	*type;
	int	(*reset)(Ether*);
} cards[NCARD+1];
} cards[MaxEther+1];

void
addethercard(char *t, int (*r)(Ether*))
{
	static int ncard;

	if(ncard == NCARD)
	if(ncard == MaxEther)
		panic("too many ether cards");
	cards[ncard].type = t;
	cards[ncard].reset = r;

M pc/ether509.c => pc/ether509.c +3 -10
@@ 221,17 221,13 @@ write(Ether *ether, void *buf, long n)

	port = ether->port;

	qlock(&ether->tlock);
	if(waserror()) {
		qunlock(&ether->tlock);
		nexterror();
	}

	ether->tlen = n;
	len = ROUNDUP(ether->tlen, 4);
	tsleep(&ether->tr, istxfifo, ether, 10000);
	if(len+4 > ins(port+TxFreeBytes))
	if(len+4 > ins(port+TxFreeBytes)){
		print("ether509: transmitter jammed\n");
		return 0;
	}

	/*
	 * We know there's room, copy the packet to the FIFO.


@@ 247,9 243,6 @@ write(Ether *ether, void *buf, long n)
	outss(port+Fifo, ether->ea, Eaddrlen/2);
	outss(port+Fifo, (uchar*)buf+2*Eaddrlen, (len-2*Eaddrlen)/2);

	poperror();
	qunlock(&ether->tlock);

	return n;
}


M pc/ether8003.c => pc/ether8003.c +5 -0
@@ 57,6 57,10 @@ static int intrmap[] = {
	9, 3, 5, 7, 10, 11, 15, 4,
};

static uchar debugea[6] = {
	0x00, 0x60, 0x8c, 0x00, 0x1a, 0x42,
};

/*
 * Get configuration parameters, enable memory.
 * There are opportunities here for buckets of code.


@@ 184,6 188,7 @@ reset(Ether *ether)
	 * ethernet address.
	 */
	dp8390reset(ether);
memmove(ether->ea, debugea, 6);
	dp8390setea(ether);

	return 0;

M pc/ether8390.c => pc/ether8390.c +12 -15
@@ 446,7 446,10 @@ receive(Ether *ether)
			for(fp = ether->f; fp < ep; fp++) {
				f = *fp;
				if(f && (f->type == type || f->type < 0))
{
print("Q%d|", len);
					qproduce(f->in, &ether->rpkt, len);
}
			}
		}



@@ 464,9 467,9 @@ receive(Ether *ether)
}

static int
istxbusy(void *arg)
istxavail(void *arg)
{
	return ((Dp8390*)arg)->busy == 0;
	return ((Ether*)arg)->tlen == 0;
}

static long


@@ 478,16 481,12 @@ write(Ether *ether, void *buf, long n)
	dp8390 = ether->private;
	port = dp8390->dp8390;

	qlock(&ether->tlock);
	if(waserror()) {
		qunlock(&ether->tlock);
		nexterror();
	}

	tsleep(&ether->tr, istxbusy, dp8390, 10000);
	if(dp8390->busy)
	tsleep(&ether->tr, istxavail, ether, 10000);
	if(ether->tlen){
		print("dp8390: transmitter jammed\n");
	dp8390->busy = 1;
		return 0;
	}
	ether->tlen = n;

	if(dp8390->ram)
		memmove((void*)(ether->mem+dp8390->tstart*Dp8390BufSz), buf, n);


@@ 498,9 497,6 @@ write(Ether *ether, void *buf, long n)
	dp8390outb(port+Tbcr1, (n>>8) & 0xFF);
	dp8390outb(port+Cr, Page0|RDMAabort|Txp|Sta);

	poperror();
	qunlock(&ether->tlock);

	return n;
}



@@ 555,6 551,7 @@ interrupt(Ether *ether)
	 */
	dp8390outb(port+Imr, 0x00);
	while(isr = dp8390inb(port+Isr)){
print("I%2.2ux|", isr);

		if(isr & Ovw){
			overflow(ether);


@@ 588,7 585,7 @@ interrupt(Ether *ether)

			if(isr & Ptx)
				ether->outpackets++;
			dp8390->busy = 0;
			ether->tlen = 0;
			wakeup(&ether->tr);
		}


M pc/etherif.h => pc/etherif.h +1 -2
@@ 17,7 17,7 @@ struct Ether {

	QLock	tlock;			/* lock for grabbing transmitter queue */
	Rendez	tr;			/* wait here for free xmit buffer */
	long	tlen;			/* length of data in tb for txfifo management */
	long	tlen;			/* length of data in tpkt */

	Netif;
};


@@ 30,7 30,6 @@ typedef struct {
	ulong	data;			/* I/O data port if no shared memory */

	uchar	nxtpkt;			/* receive: software bndry */
	uchar	busy;			/* transmit: busy */
	uchar	tstart;			/* 8390 ring addresses */
	uchar	pstart;
	uchar	pstop;

M port/devcons.c => port/devcons.c +3 -1
@@ 313,7 313,9 @@ kbdclock(void)
int
consactive(void)
{
	return qlen(printq) > 0;
	if(printq)
		return qlen(printq) > 0;
	return 0;
}

enum{