~kris/9p

9hist

65e59791087fd19f9ccdc91c2a3543a92aab96d7 — David du Colombier 34 years ago 21f299f
Plan 9 from Bell Labs 1992-04-25
3 files changed, 52 insertions(+), 22 deletions(-)

M pc/devether.c
M pc/devhard.c
M pc/l.s
M pc/devether.c => pc/devether.c +19 -12
@@ 108,9 108,10 @@ struct Ctlr {
};
static Ctlr ctlr[Nctlr];

void
etherinit(void)
Chan*
etherattach(char *spec)
{
	return devattach('l', spec);
}

Chan*


@@ 179,7 180,7 @@ isobuf(void *arg)
{
	Ctlr *cp = arg;

	cp->tb[cp->th].owner == Host;
	return cp->tb[cp->th].owner == Host;
}

static void


@@ 246,7 247,6 @@ etheroput(Queue *q, Block *bp)
	 * wait till we get an output buffer.
	 * should try to restart.
	 */
print("oput sleep\n");
	sleep(&cp->tr, isobuf, cp);

	tb = &cp->tb[cp->th];


@@ 291,7 291,6 @@ print("oput sleep\n");

	freeb(bp);
	qunlock(&cp->tlock);
print("oput done\n");
	poperror();
}



@@ 509,8 508,8 @@ etherreset(void)
	cp->net.info[1].fill = typefill;
}

Chan*
etherattach(char *spec)
void
etherinit(void)
{
	int ctlrno = 0;
	Ctlr *cp = &ctlr[ctlrno];


@@ 536,7 535,6 @@ etherattach(char *spec)
		sprint(cp->name, "ether%dkproc", ctlrno);
		kproc(cp->name, etherkproc, cp);
	}
	return devattach('l', spec);
}

typedef struct {


@@ 610,7 608,6 @@ wd8013reset(Ctlr *cp)
	int i;
	uchar msr;

print("reset\n");
	cp->rb = ialloc(sizeof(Buffer)*Nrb, 0);
	cp->nrb = Nrb;
	cp->tb = ialloc(sizeof(Buffer)*Ntb, 0);


@@ 705,7 702,7 @@ wd8013receive(Ctlr *cp)
		uchar	data[256-4];
	} Ring;
	Ring *p;
	int len;
	int len0, len1;

	bnry = IN(hw, r.bnry);
	next = NEXT(bnry, HOWMANY(hw->ramsz, 256));


@@ 719,12 716,22 @@ wd8013receive(Ctlr *cp)
			break;
		cp->inpackets++;
		p = &((Ring*)hw->ram)[next];
		len = (p->len1<<8)|p->len0;
		len0 = (p->len1<<8)|p->len0-4;
		len1 = 0;

		rb = &cp->rb[cp->ri];
		if(rb->owner == Interface){
			rb->len = len;
			rb->len = len0;
			/*copy in packet*/
			if(p->data+len0 >= (uchar*)hw->ram+hw->ramsz){
				len1 = p->data+len0 - (uchar*)hw->ram+hw->ramsz;
				len0 = (uchar*)hw->ram+hw->ramsz - p->data;
			}
			memmove((uchar*)&rb->pkt, p->data, len0);
			if(len1)
				memmove((uchar*)&rb->pkt+len0,
					(uchar*)hw->ram+ROUNDUP(sizeof(Etherpkt), 256),
					len1);
			rb->owner = Host;
			cp->ri = NEXT(cp->ri, Nrb);
		}

M pc/devhard.c => pc/devhard.c +32 -9
@@ 128,6 128,7 @@ struct Controller
	 *  current operation
	 */
	int	cmd;		/* current command */
	int	lastcmd;	/* debugging info */
	Rendez	r;		/* wait here for command termination */
	char	*buf;		/* xfer buffer */
	int	tcyl;		/* target cylinder */


@@ 201,6 202,7 @@ hardreset(void)
		dp->cp = cp;
		if((drive&1) == 0){
			cp->buf = ialloc(Maxxfer, 0);
			cp->lastcmd = cp->cmd;
			cp->cmd = 0;
			cp->pbase = Pbase + (cp-hardc)*8;	/* BUG!! guessing */
			setvec(Hardvec + (cp-hardc)*8, hardintr); /* BUG!! guessing */


@@ 674,11 676,15 @@ hardintr(Ureg *ur)

	loop = 0;
	while((cp->status = inb(cp->pbase+Pstatus)) & Sbusy)
		if(++loop > 10000)
			panic("hardintr 0");
		if(++loop > 10000) {
			print("cmd=%lux status=%lux\n",
				cp->cmd, inb(cp->pbase+Pstatus));
			panic("hardintr: wait busy");
		}
	switch(cp->cmd){
	case Cwrite:
		if(cp->status & Serr){
			cp->lastcmd = cp->cmd;
			cp->cmd = 0;
			cp->error = inb(cp->pbase+Perror);
			wakeup(&cp->r);


@@ 688,18 694,30 @@ hardintr(Ureg *ur)
		if(cp->sofar < cp->nsecs){
			loop = 0;
			while((inb(cp->pbase+Pstatus) & Sdrq) == 0)
				if(++loop > 10000)
					panic("hardintr 1");
				if(++loop > 10000) {
					print("cmd=%lux status=%lux\n",
						cp->cmd, inb(cp->pbase+Pstatus));
					panic("hardintr: write");
				}
			outss(cp->pbase+Pdata, &cp->buf[cp->sofar*dp->bytes],
				dp->bytes/2);
		} else{
			cp->lastcmd = cp->cmd;
			cp->cmd = 0;
			wakeup(&cp->r);
		}
		break;
	case Cread:
	case Cident:
		loop = 0;
		while((inb(cp->pbase+Pstatus) & Sbusy) != 0)
			if(++loop > 10000) {
				print("cmd=%lux status=%lux\n",
					cp->cmd, inb(cp->pbase+Pstatus));
				panic("hardintr: wait busy");
		}
		if(cp->status & Serr){
			cp->lastcmd = cp->cmd;
			cp->cmd = 0;
			cp->error = inb(cp->pbase+Perror);
			wakeup(&cp->r);


@@ 707,23 725,28 @@ hardintr(Ureg *ur)
		}
		loop = 0;
		while((inb(cp->pbase+Pstatus) & Sdrq) == 0)
			if(++loop > 10000)
				panic("hardintr 2");
			if(++loop > 10000) {
				print("cmd=%lux status=%lux\n",
					cp->cmd, inb(cp->pbase+Pstatus));
				panic("hardintr: read/ident");
		}
		inss(cp->pbase+Pdata, &cp->buf[cp->sofar*dp->bytes],
			dp->bytes/2);
		cp->sofar++;
		if(cp->sofar >= cp->nsecs){
			cp->lastcmd = cp->cmd;
			cp->cmd = 0;
			wakeup(&cp->r);
		}
		break;
	case Csetbuf:
		cp->lastcmd = cp->cmd;
		cp->cmd = 0;
		wakeup(&cp->r);
		break;
	case 0:	/*
		 * These don't seem to mean anything.  Should we wakeup?
		 */
	case 0:
		print("interrupt cmd=0, lastcmd=%02x status=%02x\n",
			cp->lastcmd, cp->status);
		break;
	default:
		print("weird disk interrupt, cmd=%02x, status=%02x\n",

M pc/l.s => pc/l.s +1 -1
@@ 54,7 54,7 @@ TEXT	lowcore(SB),$0
	MOVL	AX,CR0

/*
 *	clear prefetch queue (wierd code to avoid optimizations)
 *	clear prefetch queue (weird code to avoid optimizations)
 */
	CLC
	JCC	flush