From f339d31adb013ab8cc866bbd099caf58106f711c Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 28 May 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-05-28 --- pc/devvga.c | 68 ++++++++++++++++++++++++++++++++++++++++++---------- pc/vga.c | 23 +----------------- pc/vga.h | 24 +++++++++++++++++++ port/devip.c | 2 +- port/error.h | 1 + 5 files changed, 82 insertions(+), 36 deletions(-) create mode 100644 pc/vga.h diff --git a/pc/devvga.c b/pc/devvga.c index f72f898d098fd2ece5b3faec5c1f1259e9a7c4d9..64f6f239094aa07a8787afd3702f8bb8d3c45c1c 100644 --- a/pc/devvga.c +++ b/pc/devvga.c @@ -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; portqid.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 #include #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); } diff --git a/pc/vga.h b/pc/vga.h new file mode 100644 index 0000000000000000000000000000000000000000..87f559fc83e911667bead4082dcf68e7ccfec1ea --- /dev/null +++ b/pc/vga.h @@ -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); diff --git a/port/devip.c b/port/devip.c index b25a4f3ddec3781c76060827ad229efe91fd73ef..e45665bacfa4594255fedd04640d676e82044d30 100644 --- a/port/devip.c +++ b/port/devip.c @@ -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; diff --git a/port/error.h b/port/error.h index 3fb3f8ca275626f18c3d5adfc217eb74b0bf5c71..7e774fcf400d6267eebc0e1da1b5a8d571d74654 100644 --- a/port/error.h +++ b/port/error.h @@ -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 */