~kris/9p

9hist

1d1285d53b346bc78b8aa35b566870badaa9d595 — David du Colombier 24 years ago 262712d
Plan 9 from Bell Labs 2002-06-13
4 files changed, 71 insertions(+), 22 deletions(-)

M bitsy/dat.h
M bitsy/devether.c
M bitsy/devpcmcia.c
M port/qio.c
M bitsy/dat.h => bitsy/dat.h +1 -0
@@ 255,6 255,7 @@ struct PCMslot
 */
struct DevConf
{
	RWlock;			/* write: configure/unconfigure/suspend; read: normal access */
	ulong	mem;	/* mapped memory address */
	ulong	port;		/* mapped i/o regs */
	int		size;		/* access size */

M bitsy/devether.c => bitsy/devether.c +66 -19
@@ 37,14 37,15 @@ etherconfig(int on, char *spec, DevConf *cf)
	char name[32], buf[128];
	char *p, *e;

	/* can't unconfigure yet */
	if(on == 0)
		return -1;

	ctlrno = atoi(spec);
	if(etherxx[ctlrno] != nil)
		return -1;

	/* can't unconfigure yet */
	if(on == 0){
		return -1;
	}

	ether = malloc(sizeof(Ether));
	if(ether == nil)
		panic("etherconfig");


@@ 122,29 123,46 @@ etherattach(char* spec)
	if(etherxx[ctlrno] == 0)
		error(Enodev);

	rlock(etherxx[ctlrno]);
	chan = devattach('l', spec);
	chan->dev = ctlrno;
	if(etherxx[ctlrno]->attach)
		etherxx[ctlrno]->attach(etherxx[ctlrno]);
	runlock(etherxx[ctlrno]);
	return chan;
}

static Walkqid*
etherwalk(Chan* chan, Chan* nchan, char** name, int nname)
{
	return netifwalk(etherxx[chan->dev], chan, nchan, name, nname);
	Walkqid *q;

	rlock(etherxx[chan->dev]);
	q = netifwalk(etherxx[chan->dev], chan, nchan, name, nname);
	runlock(etherxx[chan->dev]);
	return q;
}

static int
etherstat(Chan* chan, uchar* dp, int n)
{
	return netifstat(etherxx[chan->dev], chan, dp, n);
	int s;

	rlock(etherxx[chan->dev]);
	s = netifstat(etherxx[chan->dev], chan, dp, n);
	runlock(etherxx[chan->dev]);
	return s;
}

static Chan*
etheropen(Chan* chan, int omode)
{
	return netifopen(etherxx[chan->dev], chan, omode);
	Chan *c;

	rlock(etherxx[chan->dev]);
	c = netifopen(etherxx[chan->dev], chan, omode);
	runlock(etherxx[chan->dev]);
	return c;
}

static void


@@ 155,7 173,9 @@ ethercreate(Chan*, char*, int, ulong)
static void
etherclose(Chan* chan)
{
	rlock(etherxx[chan->dev]);
	netifclose(etherxx[chan->dev], chan);
	runlock(etherxx[chan->dev]);
}

static long


@@ 163,8 183,10 @@ etherread(Chan* chan, void* buf, long n, vlong off)
{
	Ether *ether;
	ulong offset = off;
	long n;

	ether = etherxx[chan->dev];
	rlock(ether);
	if((chan->qid.type & QTDIR) == 0 && ether->ifstat){
		/*
		 * With some controllers it is necessary to reach


@@ 176,19 198,29 @@ etherread(Chan* chan, void* buf, long n, vlong off)
			ether->ifstat(ether, buf, 0, offset);
	}

	return netifread(ether, chan, buf, n, offset);
	n = netifread(ether, chan, buf, n, offset);
	runlock(ether);
	return n;
}

static Block*
etherbread(Chan* chan, long n, ulong offset)
{
	return netifbread(etherxx[chan->dev], chan, n, offset);
	Block *b;

	rlock(etherxx[chan->dev]);
	b = netifbread(etherxx[chan->dev], chan, n, offset);
	runlock(etherxx[chan->dev]);
	return b;
}

static int
etherwstat(Chan* chan, uchar* dp, int n)
{
	return netifwstat(etherxx[chan->dev], chan, dp, n);
	rlock(etherxx[chan->dev]);
	n = netifwstat(etherxx[chan->dev], chan, dp, n);
	runlock(etherxx[chan->dev]);
	return n;
}

static void


@@ 334,30 366,41 @@ etherwrite(Chan* chan, void* buf, long n, vlong)
	Ether *ether;
	Block *bp;
	int nn;
	long l;

	ether = etherxx[chan->dev];
	rlock(etherxx[chan->dev]);
	if(NETTYPE(chan->qid.path) != Ndataqid) {
		nn = netifwrite(ether, chan, buf, n);
		if(nn >= 0)
		if(nn >= 0){
			runlock(etherxx[chan->dev]);
			return nn;

		if(ether->ctl!=nil)
			return ether->ctl(ether,buf,n);
			
		}
		if(ether->ctl!=nil){
			l = ether->ctl(ether,buf,n);
			runlock(etherxx[chan->dev]);
			return l;
		}
		runlock(etherxx[chan->dev]);
		error(Ebadctl);
	}

	if(n > ether->maxmtu)
	if(n > ether->maxmtu){
		runlock(etherxx[chan->dev]);
		error(Etoobig);
	if(n < ether->minmtu)
	}
	if(n < ether->minmtu){
		runlock(etherxx[chan->dev]);
		error(Etoosmall);

	}
	bp = allocb(n);
	memmove(bp->rp, buf, n);
	memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen);
	bp->wp += n;

	return etheroq(ether, bp);
	l = etheroq(ether, bp);
	runlock(etherxx[chan->dev]);
	return l;
}

static long


@@ 377,16 420,20 @@ etherbwrite(Chan* chan, Block* bp, ulong)
		freeb(bp);
		return n;
	}
	rlock(etherxx[chan->dev]);
	ether = etherxx[chan->dev];

	if(n > ether->maxmtu){
		freeb(bp);
		runlock(etherxx[chan->dev]);
		error(Etoobig);
	}
	if(n < ether->minmtu){
		freeb(bp);
		runlock(etherxx[chan->dev]);
		error(Etoosmall);
	}
	runlock(etherxx[chan->dev]);

	return etheroq(ether, bp);
}

M bitsy/devpcmcia.c => bitsy/devpcmcia.c +3 -2
@@ 348,15 348,16 @@ pcmctlwrite(char *p, long n, ulong, PCMslot *sp)
		}

		/* configure device */
		cf.type = nil;
		memset(&cf, 0, sizeof cf);
		wlock(&cf);
		kstrdup(&cf.type, cmd->f[2]);
		cf.mem = (ulong)sp->mem;
		cf.port = (ulong)sp->regs;
		cf.itype = GPIOfalling;
		cf.interrupt = bitno(sp == slot ? GPIO_CARD_IRQ0_i : GPIO_CARD_IRQ1_i);
		cf.size = 0;
		if(devtab[dtx]->config(1, p, &cf) < 0)
			error("couldn't configure device");
		wunlock(&cf);

		wunlock(sp);
		poperror();

M port/qio.c => port/qio.c +1 -1
@@ 57,7 57,7 @@ enum
	Qflow		= (1<<3),
	Qcoalesce	= (1<<4),	/* coallesce packets on read */

	Maxatomic	= 32*1024,
	Maxatomic	= 64*1024,
};

uint	qiomaxatomic = Maxatomic;