~kris/9p

9hist

006b04b503ed2daaf43e7ab0e056c687497813ef — David du Colombier 32 years ago fecf34a
Plan 9 from Bell Labs 1994-02-02
6 files changed, 36 insertions(+), 73 deletions(-)

M pc/devether.c
M pc/ether509.c
M pc/ether8003.c
M pc/ether8390.c
M pc/etherif.h
M pc/l.s
M pc/devether.c => pc/devether.c +2 -13
@@ 103,19 103,8 @@ etherrloop(Ether *ctlr, Etherpkt *pkt, long len)
	type = (pkt->type[0]<<8)|pkt->type[1];
	ep = &ctlr->f[Ntypes];
	for(fp = ctlr->f; fp < ep; fp++){
		f = *fp;
		if(f && (f->type == type || f->type < 0)){
			switch(qproduce(f->in, pkt->d, len)){

			case -1:
				print("etherrloop overflow\n");
				break;

			case -2:
				print("etherrloop memory\n");
				break;
			}
		}
		if((f = *fp) && (f->type == type || f->type < 0))
			qproduce(f->in, pkt->d, len);
	}
}


M pc/ether509.c => pc/ether509.c +2 -9
@@ 122,10 122,9 @@ promiscuous(void *arg, int on)
static void
receive(Ether *ether)
{
	ushort status, type;
	ushort status;
	int len;
	ulong port;
	Netfile *f, **fp, **ep;

	port = ether->port;
	while(((status = ins(port+RxStatus)) & RxEmpty) == 0){


@@ 169,13 168,7 @@ receive(Ether *ether)
			/*
			 * Copy the packet to whoever wants it.
			 */
			type = (ether->rpkt.type[0]<<8)|ether->rpkt.type[1];
			ep = &ether->f[Ntypes];
			for(fp = ether->f; fp < ep; fp++) {
				f = *fp;
				if(f && (f->type == type || f->type < 0))
					qproduce(f->in, &ether->rpkt, len);
			}
			etherrloop(ether, &ether->rpkt, len);
		}

		/*

M pc/ether8003.c => pc/ether8003.c +1 -1
@@ 96,7 96,7 @@ reset(Ether *ether)
	sum = 0;
	for(i = 0; i < sizeof(ether->ea); i++){
		ea[i] = inb(port+Lar+i);
		sum += ether->ea[i];
		sum += ea[i];
		ic[i] = inb(port+i);
	}
	sum += inb(port+Id);

M pc/ether8390.c => pc/ether8390.c +17 -16
@@ 287,7 287,12 @@ dp8390write(Dp8390 *dp8390, ulong to, void *from, ulong len)
	uchar cr;
	int s, tries;

	/*
	 * Keep out interrupts since reading and writing
	 * use the same DMA engine.
	 */
	s = splhi();

	/*
	 * Write some data to offset 'to' in the card's memory
	 * using the DP8390 remote DMA facility, reading it at


@@ 338,22 343,23 @@ dp8390write(Dp8390 *dp8390, ulong to, void *from, ulong len)
		outss(dp8390->data, from, len/2);
	else
		outsb(dp8390->data, from, len);
	splx(s);

	/*
	 * Wait for the remote DMA to finish. We'll need
	 * a timeout here if this ever gets called before
	 * we know there really is a chip there.
	 * Wait for the remote DMA to finish. It should
	 * be almost immediate.
	 */
	tries = 0;
	while((slowinb(port+Isr) & Rdc) == 0)
		if(tries++ >= 10000000){
			print("dp8390write whoops\n");
	while((slowinb(port+Isr) & Rdc) == 0){
		if(tries++ >= 100000){
			print("dp8390write dma timed out\n");
			break;
		}
	}

	slowoutb(port+Isr, Rdc);
	slowoutb(port+Cr, cr);
	splx(s);

	return (void*)to;
}



@@ 377,8 383,6 @@ receive(Ether *ether)
	uchar curr, *pkt;
	Hdr hdr;
	ulong port, data, len, len1;
	ushort type;
	Netfile *f, **fp, **ep;

	dp8390 = ether->private;
	port = dp8390->dp8390;


@@ 421,6 425,9 @@ receive(Ether *ether)
		/*
		 * If it's a good packet read it in to the software buffer.
		 * If the packet wraps round the hardware ring, read it in two pieces.
		 *
		 * We could conceivably remove the copy into rpkt here by wrapping
		 * this up with the etherrloop code.
		 */
		if((hdr.status & (Fo|Fae|Crce|Prxok)) == Prxok){
			pkt = (uchar*)&ether->rpkt;


@@ 448,13 455,7 @@ receive(Ether *ether)
			/*
			 * Copy the packet to whoever wants it.
			 */
			type = (ether->rpkt.type[0]<<8)|ether->rpkt.type[1];
			ep = &ether->f[Ntypes];
			for(fp = ether->f; fp < ep; fp++) {
				f = *fp;
				if(f && (f->type == type || f->type < 0))
					qproduce(f->in, &ether->rpkt, len);
			}
			etherrloop(ether, &ether->rpkt, len);
		}

		/*

M pc/etherif.h => pc/etherif.h +8 -2
@@ 22,6 22,14 @@ struct Ether {
	Netif;
};

extern void etherrloop(Ether*, Etherpkt*, long);
extern void addethercard(char*, int(*)(Ether*));

/*
 * Stuff for the boards using the National Semiconductor DP8390
 * and SMC 83C90 Network Interface Controller.
 * Common code is in ether8390.c.
 */
typedef struct {
	uchar	bit16;			/* true if a 16 bit interface */
	uchar	ram;			/* true if card has shared memory */


@@ 46,5 54,3 @@ extern void dp8390setea(Ether*);
#define NEXT(x, l)	(((x)+1)%(l))
#define	HOWMANY(x, y)	(((x)+((y)-1))/(y))
#define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))

extern void addethercard(char*, int(*)(Ether*));

M pc/l.s => pc/l.s +6 -32
@@ 733,58 733,32 @@ l20:
	LOOP	l20
	RET

#ifdef notdef
/*
 * The DP8390 ethernet chip needs some time between
 * successive chip selects, so we force a jump into
 * the instruction stream to break the pipeline.
 */
TEXT dp8390inb(SB), $0
TEXT slowinb(SB), $0
	MOVL	p+0(FP),DX
	XORL	AX,AX				/* CF = 0 */
	INB

	JCC	_dp8390inb0			/* always true */
	JCC	_slowinb0			/* always true */
	MOVL	AX,AX

_dp8390inb0:
_slowinb0:
	RET

TEXT dp8390outb(SB), $0
TEXT slowoutb(SB), $0
	MOVL	p+0(FP),DX
	MOVL	b+4(FP),AX
	OUTB

	CLC					/* CF = 0 */
	JCC	_dp8390outb0			/* always true */
	JCC	_slowoutb0			/* always true */
	MOVL	AX,AX

_dp8390outb0:
	RET
#endif

TEXT slowinb(SB), $0
	MOVL	$0x84, DX
	INB
	INB

	MOVL	p+0(FP),DX
	XORL	AX,AX
	INB
	RET

TEXT slowoutb(SB),$0
	MOVL	$0x84, DX
	INB
	INB

	MOVL	p+0(FP),DX
	MOVL	b+4(FP),AX
	OUTB

	MOVL	$0x84, DX
	INB

_slowoutb0:
	RET

/*