| plan 9 kernel history: overview | file list | diff list |
1992/0711/pc/devvga.c (diff list | history)
| pc/devvga.c on 1992/0527 | ||
| 1992/0527 | #include "u.h" #include "../port/lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" #include "../port/error.h" | |
| 1992/0603 | #include <libg.h> #include <gnot.h> | |
| 1992/0527 | #include "devtab.h" | |
| 1992/0528 | #include "vga.h" | |
| 1992/0527 | /* * 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, | |
| 1992/0528 | Qvgaport= 4, | |
| 1992/0604 | Qvgamem= 5, Nvga= 5, | |
| 1992/0527 | }; Dirtab vgadir[]={ "vgamonitor", {Qvgamonitor}, 0, 0666, "vgatype", {Qvgatype}, 0, 0666, "vgasize", {Qvgasize}, 0, 0666, | |
| 1992/0528 | "vgaport", {Qvgaport}, 0, 0666, | |
| 1992/0604 | "vgamem", {Qvgamem}, 0, 0666, | |
| 1992/0527 | }; /* 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: | |
| 1992/0528 | case Qvgaport: | |
| 1992/0604 | case Qvgamem: | |
| 1992/0527 | break; } return devopen(c, omode, vgadir, Nvga, devgen); } void vgacreate(Chan *c, char *name, int omode, ulong perm) { | |
| 1992/0711 | USED(c, name, omode, perm); | |
| 1992/0527 | error(Eperm); } void vgaclose(Chan *c) { | |
| 1992/0711 | USED(c); | |
| 1992/0527 | } long vgaread(Chan *c, void *buf, long n, ulong offset) { char obuf[60]; | |
| 1992/0711 | int port; | |
| 1992/0528 | uchar *cp = buf; void *outfunc(int, int); | |
| 1992/0527 | 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: | |
| 1992/0603 | sprint(obuf, "%d %d", gscreen.r.max.x, gscreen.r.max.y); | |
| 1992/0527 | return readstr(offset, buf, n, obuf); | |
| 1992/0528 | case Qvgaport: if (offset + n >= 0x8000) error(Ebadarg); | |
| 1992/0604 | for (port=offset; port<offset+n; port++) | |
| 1992/0528 | *cp++ = inb(port); return n; | |
| 1992/0604 | case Qvgamem: if (offset > 0x10000) return 0; if (offset + n > 0x10000) n = 0x10000 - offset; memmove(cp, (void *)(SCREENMEM+offset), n); return n; | |
| 1992/0527 | } } long | |
| 1992/0528 | vgawrite(Chan *c, void *buf, long n, ulong offset) | |
| 1992/0527 | { | |
| 1992/0603 | char cbuf[20], *cp; | |
| 1992/0711 | int port, maxx, maxy; | |
| 1992/0528 | ||
| 1992/0527 | switch(c->qid.path&~CHDIR){ case Qdir: error(Eperm); case Qvgamonitor: | |
| 1992/0528 | if(offset != 0) error(Ebadarg); error(Eperm); | |
| 1992/0527 | case Qvgatype: | |
| 1992/0528 | if(offset != 0) error(Ebadarg); error(Eperm); | |
| 1992/0527 | case Qvgasize: | |
| 1992/0528 | if(offset != 0) error(Ebadarg); | |
| 1992/0604 | if(n >= sizeof(cbuf)) n = sizeof(cbuf) - 1; | |
| 1992/0603 | memmove(cbuf, buf, n); | |
| 1992/0604 | cbuf[n] = 0; | |
| 1992/0603 | 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; | |
| 1992/0528 | case Qvgaport: | |
| 1992/0603 | cp = buf; | |
| 1992/0528 | if (offset + n >= 0x8000) error(Ebadarg); | |
| 1992/0603 | for (port=offset; port<offset+n; port++) { | |
| 1992/0528 | outb(port, *cp++); | |
| 1992/0603 | } | |
| 1992/0604 | return n; case Qvgamem: if (offset + n > 0x10000) error(Ebadarg); memmove((void *)(SCREENMEM+offset), buf, n); | |
| 1992/0528 | return n; | |
| 1992/0527 | } } void vgaremove(Chan *c) { | |
| 1992/0711 | USED(c); | |
| 1992/0527 | error(Eperm); } void vgawstat(Chan *c, char *dp) { | |
| 1992/0711 | USED(c, dp); | |
| 1992/0527 | error(Eperm); } | |