Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/pc/devconfig.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname pc/devconfig.c 1992/0825
## diff -e /dev/null /n/bootesdump/1992/0825/sys/src/9/pc/devconfig.c
0a
#include	"u.h"
#include	"../port/lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"io.h"
#include	"../port/error.h"

#include	<libg.h>
#include	<gnot.h>
#include	"devtab.h"
#include	"vga.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,
	Qvgaport=	4,
	Qvgamem=	5,
	Qmouse=		6,
	Nvga=		6,
};

Dirtab vgadir[]={
	"mouseconf",	{Qmouse},	0,		0666,
	"vgamonitor",	{Qvgamonitor},	0,		0666,
	"vgatype",	{Qvgatype},	0,		0666,
	"vgasize",	{Qvgasize},	0,		0666,
	"vgaport",	{Qvgaport},	0,		0666,
	"vgamem",	{Qvgamem},	0,		0666,
};

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

void
configsetup(void) {
}

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

void
configinit(void)
{
}

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

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

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

void
configstat(Chan *c, char *dp)
{
	devstat(c, dp, vgadir, Nvga, devgen);
}

Chan*
configopen(Chan *c, int omode)
{
	return devopen(c, omode, vgadir, Nvga, devgen);
}

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

void
configclose(Chan *c)
{
	USED(c);
}

long
configread(Chan *c, void *buf, long n, ulong offset)
{
	char obuf[60];
	int port;
	uchar *cp = buf;

	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, "%d %d",
			gscreen.r.max.x, gscreen.r.max.y);
		return readstr(offset, buf, n, obuf);
	case Qvgaport:
		if (offset + n >= 0x8000)
			error(Ebadarg);
		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;
	}
	error(Eperm);
	return 0;
}

long
configwrite(Chan *c, void *buf, long n, ulong offset)
{
	char cbuf[20], *cp;
	int port, maxx, maxy;

	switch(c->qid.path&~CHDIR){
	case Qdir:
		error(Eperm);
	case Qvgamonitor:
		error(Eperm);
	case Qvgatype:
		error(Eperm);
	case Qvgasize:
		if(offset != 0)
			error(Ebadarg);
		if(n >= sizeof(cbuf))
			n = sizeof(cbuf) - 1;
		memmove(cbuf, buf, n);
		cbuf[n] = 0;
		cp = cbuf;
		maxx = strtoul(cp, &cp, 0);
		maxy = strtoul(cp, &cp, 0);
		if (maxx == 0 || maxy == 0 ||
		    maxx > 1280 || maxy > 1024)
			error(Ebadarg);
		setscreen(maxx, maxy, 1);
		return n;
	case Qvgaport:
		cp = buf;
		if (offset + n >= 0x8000)
			error(Ebadarg);
		for (port=offset; port<offset+n; port++) {
			outb(port, *cp++);
		}
		return n;
	case Qvgamem:
		if (offset + n > 0x10000)
			error(Ebadarg);
		memmove((void *)(SCREENMEM+offset), buf, n);
		return n;
	case Qmouse:
		if(n >= sizeof(cbuf))
			n = sizeof(cbuf) - 1;
		memmove(cbuf, buf, n);
		cbuf[n] = 0;
		if(strncmp("accelerated", cbuf, 11) == 0)
			mouseaccelerate(1);
		else if(strncmp("linear", cbuf, 6) == 0)
			mouseaccelerate(0);
		return n;
	}
	error(Eperm);
	return 0;
}

void
configremove(Chan *c)
{
	USED(c);
	error(Eperm);
}

void
configwstat(Chan *c, char *dp)
{
	USED(c, dp);
	error(Eperm);
}
.
## diffname pc/devconfig.c 1992/0904
## diff -e /n/bootesdump/1992/0825/sys/src/9/pc/devconfig.c /n/bootesdump/1992/0904/sys/src/9/pc/devconfig.c
196a
		else if(strncmp("serial", cbuf, 6) == 0)
			mouseserial(atoi(cbuf+6));
		else if(strncmp("ps2", cbuf, 3) == 0)
			mouseps2();
		else if(strncmp("resolution", cbuf, 10) == 0)
			mouseres(atoi(cbuf+10));
.
## diffname pc/devconfig.c 1992/1017
## diff -e /n/bootesdump/1992/0904/sys/src/9/pc/devconfig.c /n/bootesdump/1992/1017/sys/src/9/pc/devconfig.c
193,202c
		cp = strchr(cbuf, '\n');
		if(cp)
			*cp = 0;
		mousectl(cbuf);
.
## diffname pc/devconfig.c 1992/1020
## diff -e /n/bootesdump/1992/1017/sys/src/9/pc/devconfig.c /n/bootesdump/1992/1020/sys/src/9/pc/devconfig.c
187,196d
38d
33d
## diffname pc/devconfig.c 1992/1109
## diff -e /n/bootesdump/1992/1020/sys/src/9/pc/devconfig.c /n/bootesdump/1992/1109/sys/src/9/pc/devconfig.c
171c
		setscreen(maxx, maxy, ldepth);
.
168,169c
		ldepth = strtoul(cp, &cp, 0);
		if(maxx == 0 || maxy == 0
		|| maxx > 1280 || maxy > 1024
		|| ldepth > 3 || ldepth < 0)
.
149c
	int port, maxx, maxy, ldepth;
.
## diffname pc/devconfig.c 1992/1112
## diff -e /n/bootesdump/1992/1109/sys/src/9/pc/devconfig.c /n/bootesdump/1992/1112/sys/src/9/pc/devconfig.c
167a
		if(*cp!=0)
			cp++;
.
166a
		if(*cp!=0)
			cp++;
.
## diffname pc/devconfig.c 1992/1119
## diff -e /n/bootesdump/1992/1112/sys/src/9/pc/devconfig.c /n/bootesdump/1992/1119/sys/src/9/pc/devconfig.c
186,190d
172c
		switch(strtoul(cp, &cp, 0)){
		case 1:
			ldepth = 0;
			break;
		case 2:
			ldepth = 1;
			break;
		case 4:
			ldepth = 2;
			break;
		case 8:
			ldepth = 3;
			break;
		default:
			ldepth = -1;
		}
.
154,155d
133,139d
123,126d
119,120d
112d
53d
41d
37d
28,33c
	Qvgasize=	1,
	Qvgatype=	2,
	Qvgaport=	3,
	Nvga=		4,
.
18d
## diffname pc/devconfig.c 1994/0413
## diff -e /n/bootesdump/1992/1119/sys/src/9/pc/devconfig.c /n/fornaxdump/1994/0413/sys/src/brazil/pc/devconfig.c
10d
## diffname pc/devconfig.c 1995/0108
## diff -e /n/fornaxdump/1994/0413/sys/src/brazil/pc/devconfig.c /n/fornaxdump/1995/0108/sys/src/brazil/pc/devconfig.c
181a
}

long
configbwrite(Chan *c, Block *bp, ulong offset)
{
	return devbwrite(c, bp, offset);
.
123a
Block*
configbread(Chan *c, long n, ulong offset)
{
	return devbread(c, n, offset);
}

.
## diffname pc/devconfig.c 1995/0726
## diff -e /n/fornaxdump/1995/0108/sys/src/brazil/pc/devconfig.c /n/fornaxdump/1995/0726/sys/src/brazil/pc/devconfig.c
92d
90c
configcreate(Chan*, char*, int, ulong)
.
## diffname pc/devconfig.c 1996/0223 # deleted
## diff -e /n/fornaxdump/1995/0726/sys/src/brazil/pc/devconfig.c /n/fornaxdump/1996/0223/sys/src/brazil/pc/devconfig.c
1,207d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].