~kris/9p

9hist

b74636d55d82b84e08dde0c54a607bb1042f8d1d — David du Colombier 34 years ago fe5ddfb
Plan 9 from Bell Labs 1992-05-27
7 files changed, 185 insertions(+), 45 deletions(-)

A pc/devvga.c
M pc/vga.c
M port/devproc.c
M port/proc.c
M port/tcpinput.c
M power/io.h
M power/trap.c
A pc/devvga.c => pc/devvga.c +162 -0
@@ 0,0 1,162 @@
#include	"u.h"
#include	"../port/lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"io.h"
#include	"../port/error.h"

#include	"devtab.h"

/*
 *  Driver for various VGA cards
 */

char	monitor[NAMELEN];	/* monitor name and type */
char	vgacard[NAMELEN];	/* vga card type */
struct screeninfo {
	int	maxx, maxy;	/* current bits per screen */
	int	packed;		/* 0=planar, 1=packed */
	int	interlaced;	/* != 0 if interlaced */
} screeninfo;

enum {
	Qdir=		0,
	Qvgamonitor=	1,
	Qvgasize=	2,
	Qvgatype=	3,
	Qvgaportio=	4,
	Nvga=		4,
};

Dirtab vgadir[]={
	"vgamonitor",	{Qvgamonitor},	0,		0666,
	"vgatype",	{Qvgatype},	0,		0666,
	"vgasize",	{Qvgasize},	0,		0666,
	"vgaportio",	{Qvgaportio},	0,		0666,
};

/* a routine from ../port/devcons.c */
extern	int readstr(ulong, char *, ulong, char *);

void
vgasetup(void) {
}

void
vgareset(void) {
	strcpy(monitor, "generic");
	strcpy(vgacard, "generic");
	screeninfo.maxx = 640;
	screeninfo.maxy = 480;
	screeninfo.packed = 0;
	screeninfo.interlaced = 0;
}

void
vgainit(void)
{
}

Chan*
vgaattach(char *upec)
{
	return devattach('v', upec);
}

Chan*
vgaclone(Chan *c, Chan *nc)
{
	return devclone(c, nc);
}

int
vgawalk(Chan *c, char *name)
{
	return devwalk(c, name, vgadir, Nvga, devgen);
}

void
vgastat(Chan *c, char *dp)
{
	switch(c->qid.path){
	default:
		devstat(c, dp, vgadir, Nvga, devgen);
		break;
	}
}

Chan*
vgaopen(Chan *c, int omode)
{
	switch(c->qid.path){
	case Qvgamonitor:
	case Qvgatype:
	case Qvgasize:
	case Qvgaportio:
		break;
	}

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

void
vgacreate(Chan *c, char *name, int omode, ulong perm)
{
	error(Eperm);
}

void
vgaclose(Chan *c)
{
}

long
vgaread(Chan *c, void *buf, long n, ulong offset)
{
	char obuf[60];
	switch(c->qid.path&~CHDIR){
	case Qdir:
		return devdirread(c, buf, n, vgadir, Nvga, devgen);
	case Qvgamonitor:
		return readstr(offset, buf, n, monitor);
	case Qvgatype:
		return readstr(offset, buf, n, vgacard);
	case Qvgasize:
		sprint(obuf, "%dx%d%x%d %s",
			screeninfo.maxx, screeninfo.maxy,
			screeninfo.packed ? 16 : 256,
			screeninfo.interlaced ? "interlaced" : "non-interlaced");
		return readstr(offset, buf, n, obuf);
	case Qvgaportio:
		return 0;
	}
}

long
vgawrite(Chan *c, void *va, long n, ulong offset)
{
	if(offset != 0)
		error(Ebadarg);
	switch(c->qid.path&~CHDIR){
	case Qdir:
		error(Eperm);
	case Qvgamonitor:
	case Qvgatype:
	case Qvgasize:
	case Qvgaportio:
		return 0;
	}
}

void
vgaremove(Chan *c)
{
	error(Eperm);
}

void
vgawstat(Chan *c, char *dp)
{
	error(Eperm);
}

M pc/vga.c => pc/vga.c +9 -36
@@ 23,12 23,12 @@ struct{
 *  screen dimensions
 */

/*
#define MAXX	640
#define MAXY	480
*/
/*
#define MAXX	800
#define MAXY	600
*/

#define SCREENMEM	(0xA0000 | KZERO)



@@ 95,18 95,18 @@ VGAmode mode12 =
};

/*
 *  VESA standard (?) 800x600 display, 16 bit color. 
 *  cardinal (tseng labs) 800x600 display, 16 bit color. 
 */
VGAmode mode6a = 
VGAmode mode25 = 
{
	/* general */
	0x67, 0x00,  /* 0x70, 0x04, these are read-only */
	0xe3, 0x00,  /* 0x70, 0x04, these are read-only */
	/* sequence */
	0x03, 0x01, 0x0f, 0x00, 0x06,
	/* crt */
	0x7a, 0x63, 0x65, 0x9d, 0x68, 0x99, 0x38, 0x1f,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x2c, 0x8e, 0x2b, 0x32, 0x0f, 0x32, 0x34, 0xe7,
	0x5f, 0x4f, 0x50, 0x02, 0x54, 0x80, 0x0b, 0x3e,
	0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0,
	0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3,
	0xff,
	/* graphics */
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,


@@ 115,24 115,6 @@ VGAmode mode6a =
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x3f,
	0x01, 0x10, 0x0f, 0x00, 0x00,
#ifdef almost
	/* general */
	0xe7, 0x00,  /* 0x70, 0x04, these are read-only */
	/* sequence */
	0x03, 0x01, 0x0f, 0x00, 0x06,
	/* crt */
	0x7a, 0x63, 0x65, 0x9d, 0x67, 0x92, 0x39, 0x1f,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x33, 0x82, 0x2b, 0x32, 0x0f, 0x33, 0x36, 0xe7,
	0xff,
	/* graphics */
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,
	0xff,
	/* attribute */
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x3f,
	0x01, 0x10, 0x0f, 0x00, 0x00,
#endif
};

void


@@ 161,9 143,6 @@ grout(int reg, int val)
void
arout(int reg, int val)
{
	/*
	 * if this print is missing, we are left with a blank white screen.
	 */
	inb(0x3DA);
	if (reg <= 0xf) {
		outb(ARW, reg | 0x0);


@@ 321,8 300,7 @@ screeninit(void)
	ulong *l;
	VGAmode testmode;

	setmode(&mode6a);
	getmode(&testmode);
	setmode(&mode12);

	/*
	 *  swizzle the font longs.


@@ 338,11 316,6 @@ screeninit(void)
	out.pos.x = MINX;
	out.pos.y = 0;
	out.bwid = defont0.info[' '].width;
delay(50000);
	setmode(&mode12);
	printmode(&testmode);
	getmode(&testmode);
	printmode(&testmode);
}

void

M port/devproc.c => port/devproc.c +1 -1
@@ 454,7 454,7 @@ procwrite(Chan *c, void *va, long n, ulong offset)
		memmove(buf, va, n);
		buf[n] = 0;
		if(!postnote(p, 0, buf, NUser))
			exhausted("notes");
			error("note not posted");
		break;

	default:

M port/proc.c => port/proc.c +1 -1
@@ 394,7 394,7 @@ postnote(Proc *p, int dolock, char *n, int flag)
	if(p->upage == 0){
		if(dolock)
			qunlock(&p->debug);
		error(Eprocdied);
		return 0;
	}

	SET(k);

M port/tcpinput.c => port/tcpinput.c +6 -4
@@ 390,13 390,15 @@ tcp_input(Ipconv *ipc, Block *bp)
		else if(seq_gt(tcb->rcv.nxt, tcb->rcv.up))
			tcb->rcv.up = tcb->rcv.nxt;

		if(length == 0)
			freeb(bp);
		else {
		if(length == 0){
			if(bp)
				freeb(bp);
		} else {
			switch(tcb->state){
			default:
				/* Ignore segment text */
				freeb(bp);
				if(bp)
					freeb(bp);
				break;

			case Syn_received:

M power/io.h => power/io.h +4 -3
@@ 9,9 9,10 @@
#define	LED		((char*)0xBF200001)
enum
{
	LEDhotintr=	1<<0,
	LEDclock=	1<<1,
	LEDfault=	1<<2,
	LEDtrapmask=	0xf<<0,
	LEDhotintr=	1<<4,
	LEDclock=	1<<5,
	LEDfault=	1<<6,
	LEDpulse=	1<<7,
};
#define LEDON(x) 	(m->ledval &= ~x, *LED = m->ledval)

M power/trap.c => power/trap.c +2 -0
@@ 81,6 81,7 @@ trap(Ureg *ur)

	SET(x);
	ecode = EXCCODE(ur->cause);
	LEDON(ecode);
	user = ur->status&KUP;
	if(u) {
		u->p->pc = ur->pc;		/* BUG */


@@ 175,6 176,7 @@ trap(Ureg *ur)
			ur->status |= CU1;
		}
	}
	LEDOFF(ecode);
}

void