~kris/9p

9hist

f69b4516f8c94eae71145f83586912e18d909ba9 — David du Colombier 34 years ago 49c39b1
Plan 9 from Bell Labs 1992-06-04
11 files changed, 124 insertions(+), 29 deletions(-)

M gnot/devduart.c
M gnot/io.h
M gnot/screen.c
M pc/devvga.c
M pc/fns.h
M pc/vga.c
M pc/vga.h
M port/devbit.c
M port/devlance.c
M port/proc.c
M ss/screen.c
M gnot/devduart.c => gnot/devduart.c +0 -1
@@ 97,7 97,6 @@ struct Duartport
	/* stream interface */
	Queue	*wq;		/* write queue */
	Rendez	r;		/* kproc waiting for input */
	Alarm	*a;		/* alarm for waking the kernel process */
 	int	kstarted;	/* kproc started */
};
Duartport	duartport[1];

M gnot/io.h => gnot/io.h +52 -0
@@ 4,3 4,55 @@ typedef struct	Duart	Duart;
#define	DISPLAYRAM	0x02000000
#define	DUARTREG	((Duart*)0x40100000)
#define	PORT		((uchar *)0x40300000)

/*
 * Balu
 */
typedef struct Balu Balu;

struct Balu{
	ulong	src[4];
	ulong	dst[4];
	ulong	res[4];
	ulong	cr0;
	ulong	cr1;
};

#define BALU	((Balu *) 0xc0000000)
#define OR(x,n)	(ulong *) (((ulong) (x)) | n)
#define SOR(x)	(OR(x,0x30000000))
#define DOR(x)	(OR(x,0x20000000))

/* goo for cr0 manipulations */
#define	OPLENMA		0x0000ffff /* 15 bits only needed */
#define	OPLENSH		0
#define	OPCNTMA		0xffff0000 /* 16 bit signed */
#define	OPCNTSH		16

/* goo for cr1 manipulations */
#define	ALUOPMA		0x0000001f /* 5bits */
#define	ALUOPSH		0
#define	PIXELMA		0x00000060 /* 2bits */
#define	PIXELSH		5
#define	SHMAGMA		0x00000f80 /* 5bits */
#define	SHMAGSH		7
#define	ALIGNMA		0x00003000 /* 2bits */
#define	ALIGNSH		12
#define	RLSCANMA	0x00004000 /* 1bit */
#define	RLSCANSH	14
#define	QOPMA		0x00008000 /* 1bit */
#define	QOPSH		15
#define	RMASKMA		0x001f0000 /* 5bits */
#define	RMASKSH		16
#define	LMASKMA		0x03e00000 /* 5bits */
#define	LMASKSH		21

enum
{
	SUB		= 0x10,		/* balu arithmetic codes */
	SSUB		= 0x11,
	ADD		= 0x12,
	SADD		= 0x13,
	MIN		= 0x14,
	MAX		= 0x15
};

M gnot/screen.c => gnot/screen.c +2 -1
@@ 29,7 29,8 @@ GBitmap	gscreen =
	0,
	64,
	0,
	0, 0, 1024, 1024,
	{ 0, 0, 1024, 1024, },
	{ 0, 0, 1024, 1024, },
	0
};


M pc/devvga.c => pc/devvga.c +21 -7
@@ 29,7 29,8 @@ enum {
	Qvgasize=	2,
	Qvgatype=	3,
	Qvgaport=	4,
	Nvga=		4,
	Qvgamem=	5,
	Nvga=		5,
};

Dirtab vgadir[]={


@@ 37,6 38,7 @@ Dirtab vgadir[]={
	"vgatype",	{Qvgatype},	0,		0666,
	"vgasize",	{Qvgasize},	0,		0666,
	"vgaport",	{Qvgaport},	0,		0666,
	"vgamem",	{Qvgamem},	0,		0666,
};

/* a routine from ../port/devcons.c */


@@ 97,9 99,9 @@ vgaopen(Chan *c, int omode)
	case Qvgatype:
	case Qvgasize:
	case Qvgaport:
	case Qvgamem:
		break;
	}

	return devopen(c, omode, vgadir, Nvga, devgen);
}



@@ 119,6 121,7 @@ vgaread(Chan *c, void *buf, long n, ulong offset)
{
	char obuf[60];
	int port, i;
	uchar *mem;
	uchar *cp = buf;
	void *outfunc(int, int);



@@ 136,9 139,15 @@ vgaread(Chan *c, void *buf, long n, ulong offset)
	case Qvgaport:
		if (offset + n >= 0x8000)
			error(Ebadarg);
		for (port=offset; port<offset+n; port++) {
		for (port=offset; port<offset+n; port++)
			*cp++ = inb(port);
		}
		return n;
	case Qvgamem:
		if (offset > 0x10000)
			return 0;
		if (offset + n > 0x10000)
			n = 0x10000 - offset;
		memmove(cp, (void *)(SCREENMEM+offset), n);
		return n;
	}
}


@@ 163,10 172,10 @@ vgawrite(Chan *c, void *buf, long n, ulong offset)
	case Qvgasize:
		if(offset != 0)
			error(Ebadarg);
		if(n >= sizeof cbuf)
			n = sizeof cbuf - 1;
		if(n >= sizeof(cbuf))
			n = sizeof(cbuf) - 1;
		memmove(cbuf, buf, n);
		cbuf[n-1] = 0;
		cbuf[n] = 0;
		cp = cbuf;
		maxx = strtoul(cp, &cp, 0);
		maxy = strtoul(cp, &cp, 0);


@@ 183,6 192,11 @@ vgawrite(Chan *c, void *buf, long n, ulong offset)
			outb(port, *cp++);
		}
		return n;
	case Qvgamem:
		if (offset + n > 0x10000)
			error(Ebadarg);
		memmove((void *)(SCREENMEM+offset), buf, n);
		return n;
	}
}


M pc/fns.h => pc/fns.h +1 -0
@@ 58,6 58,7 @@ void	screenputs(char*, int);
int	serial(int);
void	setvec(int, void (*)(Ureg*));
void	systrap(void);
void	toscreen(void*);
void	touser(void*);
void	trapinit(void);
int	tas(void*);

M pc/vga.c => pc/vga.c +3 -3
@@ 27,15 27,14 @@ struct{
#define MAXX	640
#define MAXY	480

#define SCREENMEM	(0xA0000 | KZERO)

GBitmap	gscreen =
{
	(ulong*)SCREENMEM,
	0,
	640/32,
	0,
	0, 0, MAXX, MAXY,
	{ 0, 0, MAXX, MAXY, },
	{ 0, 0, MAXX, MAXY, },
	0
};



@@ 229,6 228,7 @@ setscreen(int maxx, int maxy, int bpp) {
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, flipD[S]);
	gscreen.width = maxx/32;
	gscreen.r.max = Pt(maxx, maxy);
	gscreen.clipr.max = gscreen.r.max;
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, flipD[0]);
	out.pos.x = MINX;
	out.pos.y = 0;

M pc/vga.h => pc/vga.h +2 -1
@@ 17,6 17,7 @@ enum
	ARR=		0x3C1,		/* attribute registers (reading) */
};

extern	void setscreen(int, int, int);
#define SCREENMEM	(0xA0000 | KZERO)

extern	void setscreen(int, int, int);
extern	struct GBitmap	gscreen;

M port/devbit.c => port/devbit.c +32 -5
@@ 97,6 97,7 @@ GBitmap	set =
	0,
	1,
	0,
	{0, 0, 16, 16},
	{0, 0, 16, 16}
};



@@ 107,6 108,7 @@ GBitmap	clr =
	0,
	1,
	0,
	{0, 0, 16, 16},
	{0, 0, 16, 16}
};



@@ 117,6 119,7 @@ GBitmap cursorback =
	0,
	1,
	0,
	{0, 0, 16, 16},
	{0, 0, 16, 16}
};



@@ 193,6 196,7 @@ bitinit(void)
Chan*
bitattach(char *spec)
{
	bit.map[0] = gscreen;	/* bitmap 0 is screen */
	return devattach('b', spec);
}



@@ 229,6 233,7 @@ bitopen(Chan *c, int omode)
			unlock(&bit);
			error(Einuse);
		}
		bit.map[0].clipr = gscreen.clipr;
		bit.lastid = -1;
		bit.lastfid = -1;
		bit.lastsubfid = -1;


@@ 913,6 918,31 @@ bitwrite(Chan *c, void *va, long n, ulong offset)
			p += 14;
			break;

		case 'q':
			/*
			 * clip rectangle
			 *	'q'		1
			 *	id		2
			 *	rect		16
			 */
			if(m < 19)
				error(Ebadblt);
			v = GSHORT(p+1);
			dst = &bit.map[v];
			if(v<0 || v>=conf.nbitmap || dst->ldepth<0)
				error(Ebadbitmap);
			rect.min.x = GLONG(p+3);
			rect.min.y = GLONG(p+7);
			rect.max.x = GLONG(p+11);
			rect.max.y = GLONG(p+15);
			if(rectclip(&rect, dst->r))
				dst->clipr = rect;
			else
				dst->clipr = dst->r;
			m -= 19;
			p += 19;
			break;

		case 'r':
			/*
			 * read


@@ 987,7 1017,7 @@ bitwrite(Chan *c, void *va, long n, ulong offset)
			 * texture
			 *	't'		1
			 *	dst id		2
			 *	Rectangle	16
			 *	rect		16
			 *	src id		2
			 *	fcode		2
			 */


@@ 1275,6 1305,7 @@ bitalloc(Rectangle rect, int ld)
	bp->width = l;
	bp->ldepth = ld;
	bp->r = rect;
	bp->clipr = rect;
	bp->cache = 0;
	return bp;
}


@@ 1352,10 1383,6 @@ bitloadchar(GFont *f, int ci, GSubfont *subf, int si)
	rect.max.x = (fi+1)->x;
	rect.max.y = subf->height;
	gbitblt(f->b, Pt(c->x, f->ascent-subf->ascent), subf->bits, rect, S);
/*
gbitblt(&gscreen, Pt(0,0), f->b, f->b->r, S);
gbitblt(&gscreen, Pt(0,30), f->b, Rect(c->x, 0, c->x+f->width,f->height), S);
*/
}

QLock	bitlock;

M port/devlance.c => port/devlance.c +9 -10
@@ 310,16 310,7 @@ lanceoput(Queue *q, Block *bp )
	}
	p = (Etherpkt *)bp->rptr;
	memmove(p->s, l.ea, sizeof(l.ea));
	if(memcmp(l.ea, p->d, sizeof(l.ea)) == 0){
		len = blen(bp);
		bp = expandb(bp, len >= ETHERMINTU ? len : ETHERMINTU);
		if(bp){
			putq(&l.self, bp);
			wakeup(&l.rr);
		}
		return;
	}
	if(memcmp(l.bcast, p->d, sizeof(l.bcast)) == 0 || l.prom || l.all){
	if(*p->d == 0xff || l.prom || l.all){
		len = blen(bp);
		nbp = copyb(bp, len);
		nbp = expandb(nbp, len >= ETHERMINTU ? len : ETHERMINTU);


@@ 328,6 319,14 @@ lanceoput(Queue *q, Block *bp )
			putq(&l.self, nbp);
			wakeup(&l.rr);
		}
	} else if(*p->d == *l.ea && memcmp(l.ea, p->d, sizeof(l.ea)) == 0){
		len = blen(bp);
		bp = expandb(bp, len >= ETHERMINTU ? len : ETHERMINTU);
		if(bp){
			putq(&l.self, bp);
			wakeup(&l.rr);
		}
		return;
	}

	/*

M port/proc.c => port/proc.c +1 -1
@@ 763,7 763,7 @@ procctl(Proc *p)
#include "errstr.h"

void
error(char err[])
error(char *err)
{
	strncpy(u->error, err, ERRLEN);
	nexterror();

M ss/screen.c => ss/screen.c +1 -0
@@ 29,6 29,7 @@ GBitmap	gscreen =
	1152/32,
	0,
	{0, 0, 1152, 900},
	{0, 0, 1152, 900},
	0
};