From b74636d55d82b84e08dde0c54a607bb1042f8d1d Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 27 May 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-05-27 --- pc/devvga.c | 162 ++++++++++++++++++++++++++++++++++++++++++++++++ pc/vga.c | 45 +++----------- port/devproc.c | 2 +- port/proc.c | 2 +- port/tcpinput.c | 10 +-- power/io.h | 7 ++- power/trap.c | 2 + 7 files changed, 185 insertions(+), 45 deletions(-) create mode 100644 pc/devvga.c diff --git a/pc/devvga.c b/pc/devvga.c new file mode 100644 index 0000000000000000000000000000000000000000..f72f898d098fd2ece5b3faec5c1f1259e9a7c4d9 --- /dev/null +++ b/pc/devvga.c @@ -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); +} diff --git a/pc/vga.c b/pc/vga.c index b8743e81a25e43d4f5356ea3d20d6aab1e3bf1f8..f86373fad20bcfdecd8b98e24111f6abdf3acf45 100644 --- a/pc/vga.c +++ b/pc/vga.c @@ -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 diff --git a/port/devproc.c b/port/devproc.c index 8bb707e5cac48467d324b664ab93981cec3db31f..eb3840fd8a0b2d2ee9dbdff25a58a8f2a241f14e 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -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: diff --git a/port/proc.c b/port/proc.c index 5157174adcad7bbd56b342dc2e805a647acbf6ff..387f5590916f4c2436580340d38728ee0e82759e 100644 --- a/port/proc.c +++ b/port/proc.c @@ -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); diff --git a/port/tcpinput.c b/port/tcpinput.c index c9833570a8be531b31e439b88b2e1fb26c6cb307..11bf8b57d8b4cf5876910af3fcb8e46fb132bf51 100644 --- a/port/tcpinput.c +++ b/port/tcpinput.c @@ -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: diff --git a/power/io.h b/power/io.h index b61838f354fa2de8af0fba81a585451dd8544445..7ca96decdd993639e1649df718b5230f7a4c0a33 100644 --- a/power/io.h +++ b/power/io.h @@ -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) diff --git a/power/trap.c b/power/trap.c index b3c91898191f4baf82b441e2dd75eb9f7cb499a0..cedd4cd099559ef32609fe922b21ce40b32cac06 100644 --- a/power/trap.c +++ b/power/trap.c @@ -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