~kris/9p

9hist

f339d31adb013ab8cc866bbd099caf58106f711c — David du Colombier 34 years ago b74636d
Plan 9 from Bell Labs 1992-05-28
5 files changed, 82 insertions(+), 36 deletions(-)

M pc/devvga.c
M pc/vga.c
A pc/vga.h
M port/devip.c
M port/error.h
M pc/devvga.c => pc/devvga.c +55 -13
@@ 7,6 7,7 @@
#include	"../port/error.h"

#include	"devtab.h"
#include	"vga.h"

/*
 *  Driver for various VGA cards


@@ 25,15 26,17 @@ enum {
	Qvgamonitor=	1,
	Qvgasize=	2,
	Qvgatype=	3,
	Qvgaportio=	4,
	Nvga=		4,
	Qvgaport=	4,
	Qvgaiport=	5,
	Nvga=		5,
};

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

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


@@ 93,7 96,7 @@ vgaopen(Chan *c, int omode)
	case Qvgamonitor:
	case Qvgatype:
	case Qvgasize:
	case Qvgaportio:
	case Qvgaport:
		break;
	}



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

	switch(c->qid.path&~CHDIR){
	case Qdir:
		return devdirread(c, buf, n, vgadir, Nvga, devgen);


@@ 125,27 132,62 @@ vgaread(Chan *c, void *buf, long n, ulong offset)
	case Qvgasize:
		sprint(obuf, "%dx%d%x%d %s",
			screeninfo.maxx, screeninfo.maxy,
			screeninfo.packed ? 16 : 256,
			screeninfo.interlaced ? "interlaced" : "non-interlaced");
			(screeninfo.packed == 0) ? 256 : 16,
			(screeninfo.interlaced != 0) ? "interlaced" : "non-interlaced");
		return readstr(offset, buf, n, obuf);
	case Qvgaportio:
		return 0;
	case Qvgaport:
		if (offset + n >= 0x8000)
			error(Ebadarg);
		for (port=offset; port<offset+n; port++)
			*cp++ = inb(port);
		return n;
	case Qvgaiport:
		error(Eio);
	}
}

long
vgawrite(Chan *c, void *va, long n, ulong offset)
vgawrite(Chan *c, void *buf, long n, ulong offset)
{
	if(offset != 0)
		error(Ebadarg);
	uchar *cp = buf;
	void (*outfunc)(int, int);
	int port, i;

	switch(c->qid.path&~CHDIR){
	case Qdir:
		error(Eperm);
	case Qvgamonitor:
		if(offset != 0)
			error(Ebadarg);
		error(Eperm);
	case Qvgatype:
		if(offset != 0)
			error(Ebadarg);
		error(Eperm);
	case Qvgasize:
	case Qvgaportio:
		return 0;
		if(offset != 0)
			error(Ebadarg);
		error(Eperm);
	case Qvgaport:
		if (offset + n >= 0x8000)
			error(Ebadarg);
		for (port=offset; port<offset+n; port++)
			outb(port, *cp++);
		return n;
	case Qvgaiport:
		port = offset / 256;
		switch (port) {
		case EMISCW:	outfunc = genout;	break;
		case SRX:	outfunc = srout;	break;
		case GRX:	outfunc = grout;	break;
		case ARW:	outfunc = arout;	break;
		case CRX:	outfunc = crout;	break;
		default:
			error(Ebadarg);
		}
		for (i = offset%256; i < (offset%256) + n; i++)
			outfunc(i, *cp++);
		return n;
	}
}


M pc/vga.c => pc/vga.c +1 -22
@@ 8,6 8,7 @@
#include	<libg.h>
#include	<gnot.h>
#include	"screen.h"
#include	"vga.h"

#define	MINX	8



@@ 42,25 43,6 @@ GBitmap	gscreen =
	0
};

enum
{
	EMISCR=		0x3CC,		/* control sync polarity */
	EMISCW=		0x3C2,
	EFCW=		0x3DA,		/* feature control */
	EFCR=		0x3CA,
	GRX=		0x3CE,		/* index to graphics registers */
	GR=		0x3CF,		/* graphics registers */
	 Grms=		 0x04,		/*  read map select register */
	SRX=		0x3C4,		/* index to sequence registers */
	SR=		0x3C5,		/* sequence registers */
	 Smmask=	 0x02,		/*  map mask */
	CRX=		0x3D4,		/* index to crt registers */
	CR=		0x3D5,		/* crt registers */
	 Cvre=		 0x11,		/*  vertical retrace end */
	ARW=		0x3C0,		/* attribute registers (writing) */
	ARR=		0x3C1,		/* attribute registers (reading) */
};

typedef struct VGAmode	VGAmode;
struct VGAmode
{


@@ 128,9 110,6 @@ genout(int reg, int val)
void
srout(int reg, int val)
{
	/*
	 * needed or the screen goes blank on an ultra VGA card
	 */
	outb(SRX, reg);
	outb(SR, val);
}

A pc/vga.h => pc/vga.h +24 -0
@@ 0,0 1,24 @@
enum
{
	EMISCR=		0x3CC,		/* control sync polarity */
	EMISCW=		0x3C2,
	EFCW=		0x3DA,		/* feature control */
	EFCR=		0x3CA,
	GRX=		0x3CE,		/* index to graphics registers */
	GR=		0x3CF,		/* graphics registers */
	 Grms=		 0x04,		/*  read map select register */
	SRX=		0x3C4,		/* index to sequence registers */
	SR=		0x3C5,		/* sequence registers */
	 Smmask=	 0x02,		/*  map mask */
	CRX=		0x3D4,		/* index to crt registers */
	CR=		0x3D5,		/* crt registers */
	 Cvre=		 0x11,		/*  vertical retrace end */
	ARW=		0x3C0,		/* attribute registers (writing) */
	ARR=		0x3C1,		/* attribute registers (reading) */
};

extern	void genout(int, int);
extern	void srout(int, int);
extern	void grout(int, int);
extern	void arout(int, int);
extern	void crout(int, int);

M port/devip.c => port/devip.c +1 -1
@@ 249,7 249,7 @@ ipwrite(Chan *c, char *a, long n, ulong offset)

		switch(getfields(field[1], ctlarg, 5, '!')) {
		default:
			error(Ebadarg);
			error(Eneedservice);
		case 2:
			priv = 0;
			break;

M port/error.h => port/error.h +1 -0
@@ 50,4 50,5 @@ extern char Etimedout[];	/* connection timed out */
extern char Econrefused[];	/* connection refused */
extern char Enetunreach[];	/* network unreachable */
extern char Eintr[];		/* interrupted */
extern char Eneedservice[];	/* service required for tcp/udp/il calls */
extern char Egreg[];		/* it's a thermal problem */