From 8e37547482ceb4ca81af85d06474e82a897ee3e3 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 26 Jan 1995 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1995-01-26 --- carrera/segment.h | 2 +- pc/devvga.c | 147 +++++++++++++++++++++------------------------- pc/ether8003.c | 2 +- pc/io.h | 1 + pc/vga.h | 51 ++++++++++------ pc/vgabt485.c | 18 ++++-- pc/vgaet4000.c | 16 +++++ pc/vgas3.c | 27 ++++++--- pc/vgatvp3020.c | 16 +++-- port/proc.c | 8 --- port/qlock.c | 4 -- 11 files changed, 166 insertions(+), 126 deletions(-) diff --git a/carrera/segment.h b/carrera/segment.h index 49aee9746fe835438b18bb3851436383f752b19a..4e28d10b30ca0bd63d7e15305b73a3e8cf99ebef 100644 --- a/carrera/segment.h +++ b/carrera/segment.h @@ -10,6 +10,6 @@ Physseg physseg[] = { SG_PHYSICAL, "eisavga", Eisavgaphys, 128*1024, 0, 0 }, { SG_PHYSICAL, "bootrom", 0x1fc00000, 256*1024, 0, 0 }, { SG_PHYSICAL, "nvram", 0xe0009000, 12*1024, 0, 0 }, - { SG_PHYSICAL, "fb", 0x40000000, 4*1024*1024, 0, 0 }, + { SG_PHYSICAL, "fb", 0x40000000, 4*1024*1024, 0, 0 }, { 0, 0, 0, 0, 0, 0 }, }; diff --git a/pc/devvga.c b/pc/devvga.c index d9056d9d6b40b934a622d8439eb9a9125001f9fa..a2c6834efc4fdf23f5f7dbedf1d6f8d8fec854d7 100644 --- a/pc/devvga.c +++ b/pc/devvga.c @@ -18,6 +18,7 @@ enum /* imported */ extern Subfont defont0; +extern Cursor curs; /* barf */ /* exported */ Bitmap gscreen; @@ -26,7 +27,7 @@ Cursor curcursor; /* current cursor */ /* vga screen */ static Lock screenlock; -static ulong colormap[256][3]; +static ulong colormap[Pcolours][3]; /* cga screen */ static int cga = 1; /* true if in cga mode */ @@ -48,47 +49,20 @@ static Point curpos; #define SCREENMEM (0xA0000 | KZERO) #define CGASCREEN ((uchar*)(0xB8000 | KZERO)) -/* - * definitions of known cards - */ -typedef struct Vgacard Vgacard; -struct Vgacard -{ - char *name; - void (*setpage)(int); /* routine to page though display memory */ -}; - -static void nopage(int); -static void cirruspage(int); -extern void et4000page(int); -extern void s3page(int); - -Vgacard vgachips[] = -{ - { "vga", nopage, }, - { "clgd542x", cirruspage, }, - { "et4000", et4000page, }, - { "s3", s3page, }, - { 0, 0, }, -}; - -Vgacard *vgacard = &vgachips[0]; /* current vga card */ +static void nopage(int); -extern Hwgc bt485hwgc; -extern Hwgc et4000hwgc; -extern Hwgc s3hwgc; -extern Hwgc tvp3020hwgc; +static Vgac vga = { + "vga", + nopage, -static Hwgc *hwcursor[] = { - &bt485hwgc, - &et4000hwgc, - &s3hwgc, - &tvp3020hwgc, 0, }; -Hwgc *hwgc; -extern Cursor curs; /* barf */ +static Vgac *vgactlr = &vga; /* available VGA ctlrs */ +static Vgac *vgac; /* current VGA ctlr */ +static Hwgc *hwgctlr; /* available HWGC's */ +Hwgc *hwgc; /* current HWGC */ + static char interlaced[2]; /* @@ -203,12 +177,17 @@ vgaread(Chan *c, void *buf, long n, ulong offset) char cbuf[64]; ushort *sp; ulong *lp; + Vgac *vgacp; switch(c->qid.path&~CHDIR){ case Qdir: return devdirread(c, buf, n, vgadir, Nvga, devgen); case Qvgactl: - port = sprint(cbuf, "type: %s\n", vgacard->name); + if(vgac == 0) + vgacp = &vga; + else + vgacp = vgac; + port = sprint(cbuf, "type: %s\n", vgacp->name); port += sprint(cbuf+port, "size: %dx%dx%d%s\n", gscreen.r.max.x, gscreen.r.max.y, 1<name) == 0){ + for(hwgcp = hwgctlr; hwgcp; hwgcp = hwgcp->link){ + if(strcmp(field[1], hwgcp->name) == 0){ if(hwgc) (*hwgc->disable)(); else cursoroff(1); - hwgc = hwcursor[i]; + hwgc = hwgcp; (*hwgc->enable)(); setcursor(&curs); cursoron(1); @@ -284,9 +265,9 @@ vgactl(char *arg) } } else if(strcmp(field[0], "type") == 0){ - for(i = 0; vgachips[i].name; i++){ - if(strcmp(field[1], vgachips[i].name) == 0){ - vgacard = &vgachips[i]; + for(vgacp = vgactlr; vgacp; vgacp = vgacp->link){ + if(strcmp(field[1], vgacp->name) == 0){ + vgac = vgacp; return; } } @@ -577,21 +558,18 @@ setmode(VGAmode *vga) vgao(MiscW, vga->misc); - for(i = 1; i < NSeqx; i++){ - if(i == 1) - continue; + for(i = 2; i < sizeof(vga->sequencer); i++) vgaxo(Seqx, i, vga->sequencer[i]); - } vgaxo(Seqx, 0x00, seq00); vgaxo(Crtx, 0x11, vga->crt[0x11] & ~0x80); - for(i = 0; i < NCrtx; i++) + for(i = 0; i < sizeof(vga->crt); i++) vgaxo(Crtx, i, vga->crt[i]); - for(i = 0; i < NGrax; i++) + for(i = 0; i < sizeof(vga->graphics); i++) vgaxo(Grx, i, vga->graphics[i]); - for(i = 0; i < NAttrx; i++) + for(i = 0; i < sizeof(vga->attribute); i++) vgaxo(Attrx, i, vga->attribute[i]); vgaxo(Seqx, 0x01, seq01); @@ -648,7 +626,7 @@ setscreen(int maxx, int maxy, int ldepth) gscreen.r.max = Pt(maxx, maxy); gscreen.clipr = gscreen.r; for(i = 0; i < gscreen.width*BY2WD*maxy; i += Footprint){ - vgacard->setpage(i>>Footshift); + vgac->page(i>>Footshift); memset(gscreen.base, 0xff, Footprint); } @@ -685,7 +663,7 @@ setscreen(int maxx, int maxy, int ldepth) /* default color map (has to be outside the lock) */ switch(ldepth){ case 3: - for(i = 0; i < 256; i++) + for(i = 0; i < Pcolours; i++) setcolor(i, xnto32(i>>5, 3), xnto32(i>>2, 3), xnto32(i, 2)); setcolor(0x55, xnto32(0x15, 6), xnto32(0x15, 6), xnto32(0x15, 6)); setcolor(0xaa, xnto32(0x2a, 6), xnto32(0x2a, 6), xnto32(0x2a, 6)); @@ -734,7 +712,7 @@ byteload(uchar *q, uchar *data, int m, int *page, uchar *e) diff = 0; if(q >= e){ pg = ++*page; - vgacard->setpage(pg); + vgac->page(pg); q -= Footprint; diff -= Footprint; } @@ -755,7 +733,7 @@ lineload(uchar *q, uchar *data, int len, int *page, uchar *e) diff = 0; if(q >= e){ pg = ++*page; - vgacard->setpage(pg); + vgac->page(pg); q -= Footprint; diff -= Footprint; } @@ -765,7 +743,7 @@ lineload(uchar *q, uchar *data, int len, int *page, uchar *e) if(rem < len){ memmove(q, data, rem); pg = ++*page; - vgacard->setpage(pg); + vgac->page(pg); q -= Footprint; diff -= Footprint; memmove(q+rem, data+rem, len-rem); @@ -803,7 +781,7 @@ screenload(Rectangle r, uchar *data, int tl, int l, int dolock) off = q - (uchar*)gscreen.base; page = off>>Footshift; - vgacard->setpage(page); + vgac->page(page); q = ((uchar*)gscreen.base) + (off&(Footprint-1)); sw = gscreen.width*sizeof(ulong); @@ -890,7 +868,7 @@ byteunload(uchar *q, uchar *data, int m, int *page, uchar *e) diff = 0; if(q >= e){ pg = ++*page; - vgacard->setpage(pg); + vgac->page(pg); q -= Footprint; diff -= Footprint; } @@ -911,7 +889,7 @@ lineunload(uchar *q, uchar *data, int len, int *page, uchar *e) diff = 0; if(q >= e){ pg = ++*page; - vgacard->setpage(pg); + vgac->page(pg); q -= Footprint; diff -= Footprint; } @@ -921,7 +899,7 @@ lineunload(uchar *q, uchar *data, int len, int *page, uchar *e) if(rem < len){ memmove(data, q, rem); pg = ++*page; - vgacard->setpage(pg); + vgac->page(pg); q -= Footprint; diff -= Footprint; memmove(data+rem, q+rem, len-rem); @@ -960,7 +938,7 @@ screenunload(Rectangle r, uchar *data, int tl, int l, int dolock) off = q - (uchar*)gscreen.base; page = off>>Footshift; - vgacard->setpage(page); + vgac->page(page); q = ((uchar*)gscreen.base) + (off&(Footprint-1)); sw = gscreen.width*sizeof(ulong); @@ -1073,9 +1051,6 @@ screenputs(char *s, int n) unlock(&screenlock); } -/* - * expand n bits of color to 32 - */ /* * paging routines for different cards */ @@ -1227,18 +1202,18 @@ getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb) switch(gscreen.ldepth){ default: - x = 0xf; + x = 0xF; break; case 3: - x = 0xff; + x = 0xFF; break; } p &= x; p ^= x; lock(&palettelock); - *pr = colormap[p][0]; - *pg = colormap[p][1]; - *pb = colormap[p][2]; + *pr = colormap[p][Pred]; + *pg = colormap[p][Pgreen]; + *pb = colormap[p][Pblue]; unlock(&palettelock); } @@ -1249,22 +1224,22 @@ setcolor(ulong p, ulong r, ulong g, ulong b) switch(gscreen.ldepth){ default: - x = 0xf; + x = 0xF; break; case 3: - x = 0xff; + x = 0xFF; break; } p &= x; p ^= x; lock(&palettelock); - colormap[p][0] = r; - colormap[p][1] = g; - colormap[p][2] = b; - vgao(DACWx, p); - vgao(DACData, r>>(32-6)); - vgao(DACData, g>>(32-6)); - vgao(DACData, b>>(32-6)); + colormap[p][Pred] = r; + colormap[p][Pgreen] = g; + colormap[p][Pblue] = b; + vgao(PaddrW, p); + vgao(Pdata, r>>(32-6)); + vgao(Pdata, g>>(32-6)); + vgao(Pdata, b>>(32-6)); unlock(&palettelock); return ~0; } @@ -1461,3 +1436,17 @@ cursorunlock(void) cursor.frozen = 0; unlock(&cursor); } + +void +addhwgclink(Hwgc *hwgcp) +{ + hwgcp->link = hwgctlr; + hwgctlr = hwgcp; +} + +void +addvgaclink(Vgac *vgacp) +{ + vgacp->link = vgactlr; + vgactlr = vgacp; +} diff --git a/pc/ether8003.c b/pc/ether8003.c index b2c4d2c503a89bcdae5be47ed05f74dd28cdc5cb..fe21eac5b3a36d70aa8d9bbccb2c18f7ec9d145d 100644 --- a/pc/ether8003.c +++ b/pc/ether8003.c @@ -191,7 +191,7 @@ reset(Ether *ether) dp8390setea(ether); if(getisa(ether->mem, ether->size, 0) == 0) - panic("ether8003: %lux reused", ether->mem); + panic("ether8003: 0x%lux reused", ether->mem); return 0; } diff --git a/pc/io.h b/pc/io.h index db8e54968b2ab7c8671260afdea28fe561fde02e..c1c554e7901770460eb5b260c66325e46432a02b 100644 --- a/pc/io.h +++ b/pc/io.h @@ -31,4 +31,5 @@ enum enum { MaxEISA = 16, + EISAconfig = 0xC80, }; diff --git a/pc/vga.h b/pc/vga.h index 3b07ff826db4ab15094583c2342cb6818f865127..3ea97089bed61b8d909435308e309798b84ebcab 100644 --- a/pc/vga.h +++ b/pc/vga.h @@ -10,23 +10,23 @@ enum { FeatureW = 0x03DA, /* Feature Control (W) */ Seqx = 0x03C4, /* Sequencer Index, Data at Seqx+1 */ - NSeqx = 0x05, - Crtx = 0x03D4, /* CRT Controller Index, Data at Crtx+1 */ - NCrtx = 0x19, - Grx = 0x03CE, /* Graphics Controller Index, Data at Grx+1 */ - NGrax = 0x09, - Attrx = 0x03C0, /* Attribute Controller Index and Data */ - NAttrx = 0x15, - - DACMask = 0x03C6, /* DAC Mask */ - DACRx = 0x03C7, /* DAC Read Index (W) */ - DACSts = 0x03C7, /* DAC Status (R) */ - DACWx = 0x03C8, /* DAC Write Index */ - DACData = 0x03C9, /* DAC Data */ - NDACx = 0x100, + + PaddrW = 0x03C8, /* Palette Address Register, write */ + Pdata = 0x03C9, /* Palette Data Register */ + Pixmask = 0x03C6, /* Pixel Mask Register */ + PaddrR = 0x03C7, /* Palette Address Register, read */ + Pstatus = 0x03C7, /* DAC Status (RO) */ + + Pcolours = 256, /* Palette */ + Pred = 0, + Pgreen = 1, + Pblue = 2, + + Pblack = 0x00, + Pwhite = 0xFF, }; #define vgai(port) inb(port) @@ -36,15 +36,32 @@ extern int vgaxi(long, uchar); extern int vgaxo(long, uchar, uchar); /* - * Definitions of known hardware graphics cursors. + * Definitions of known VGA controllers. */ -typedef struct Hwgc { +typedef struct Vgac Vgac; +struct Vgac { char *name; + void (*page)(int); + + Vgac* link; +}; + +/* + * Definition of known hardware graphics cursors. + */ +typedef struct Hwgc Hwgc; +struct Hwgc { + char* name; void (*enable)(void); void (*load)(Cursor*); int (*move)(Point); void (*disable)(void); -} Hwgc; + + Hwgc* link; +}; + +extern void addvgaclink(Vgac*); +extern void addhwgclink(Hwgc*); extern Hwgc *hwgc; diff --git a/pc/vgabt485.c b/pc/vgabt485.c index da7f27cbb41c223551d277e8bde3dd2a1d17cfa0..6af4a75507a237c2a15e34a1beb793d5e4144d5e 100644 --- a/pc/vgabt485.c +++ b/pc/vgabt485.c @@ -45,7 +45,7 @@ enum { * addressing. */ static ushort dacxreg[4] = { - DACWx, DACData, DACMask, DACSts + PaddrW, Pdata, Pixmask, PaddrR }; static uchar @@ -183,12 +183,12 @@ enable(void) * cursor colour 2, 3 (black). */ bt485o(ColorW, 0x00); - bt485o(Color, 0xFF); bt485o(Color, 0xFF); bt485o(Color, 0xFF); + bt485o(Color, Pwhite); bt485o(Color, Pwhite); bt485o(Color, Pwhite); - bt485o(Color, 0xFF); bt485o(Color, 0xFF); bt485o(Color, 0xFF); + bt485o(Color, Pwhite); bt485o(Color, Pwhite); bt485o(Color, Pwhite); - bt485o(Color, 0x00); bt485o(Color, 0x00); bt485o(Color, 0x00); - bt485o(Color, 0x00); bt485o(Color, 0x00); bt485o(Color, 0x00); + bt485o(Color, Pblack); bt485o(Color, Pblack); bt485o(Color, Pblack); + bt485o(Color, Pblack); bt485o(Color, Pblack); bt485o(Color, Pblack); unlock(&palettelock); @@ -256,4 +256,12 @@ Hwgc bt485hwgc = { load, move, disable, + + 0, }; + +void +vgabt485link(void) +{ + addhwgclink(&bt485hwgc); +} diff --git a/pc/vgaet4000.c b/pc/vgaet4000.c index 64438a82f99d50d31b729b53e8a69b71d3768fc8..77dab93dac9eb8a634ab2a21b02a4056861f24ba 100644 --- a/pc/vgaet4000.c +++ b/pc/vgaet4000.c @@ -254,6 +254,8 @@ Hwgc et4000hwgc = { load, move, disable, + + 0, }; void @@ -267,3 +269,17 @@ et4000page(int page) else setet4000page(page); } + +static Vgac et4000 = { + "et4000", + et4000page, + + 0, +}; + +void +vgaet4000link(void) +{ + addvgaclink(&et4000); + addhwgclink(&et4000hwgc); +} diff --git a/pc/vgas3.c b/pc/vgas3.c index 9b85d1cd8952b811b9ad9834c69b86e2286fb482..03e58d417c251b265825c4c59483a4c66492e160 100644 --- a/pc/vgas3.c +++ b/pc/vgas3.c @@ -26,9 +26,6 @@ sets3page(int page) { uchar crt51; - /* - * I don't understand why these are different. - */ if(gscreen.ldepth == 3){ /* * The S3 registers need to be unlocked for this. @@ -84,14 +81,14 @@ enable(void) * stack in case we are using a 16-bit RAMDAC. * Why are these colours reversed? */ - vgaxo(Crtx, 0x0E, 0xFF); - vgaxo(Crtx, 0x0F, 0x00); + vgaxo(Crtx, 0x0E, Pwhite); + vgaxo(Crtx, 0x0F, Pblack); vgaxi(Crtx, 0x45); for(i = 0; i < 4; i++) - vgaxo(Crtx, 0x4A, 0xFF); + vgaxo(Crtx, 0x4A, Pwhite); vgaxi(Crtx, 0x45); for(i = 0; i < 4; i++) - vgaxo(Crtx, 0x4B, 0x00); + vgaxo(Crtx, 0x4B, Pblack); /* * Find a place for the cursor data in display memory. @@ -230,6 +227,8 @@ Hwgc s3hwgc = { load, move, disable, + + 0, }; void @@ -243,3 +242,17 @@ s3page(int page) else sets3page(page); } + +static Vgac s3 = { + "s3", + s3page, + + 0, +}; + +void +vgas3link(void) +{ + addvgaclink(&s3); + addhwgclink(&s3hwgc); +} diff --git a/pc/vgatvp3020.c b/pc/vgatvp3020.c index ff84cc48213b97beae282cd9654a76b380dfb9cb..77d7224931b386c1b5a69b1e014edd663e556cf3 100644 --- a/pc/vgatvp3020.c +++ b/pc/vgatvp3020.c @@ -30,7 +30,7 @@ enum { * addressing. */ static ushort dacxreg[4] = { - DACWx, DACData, DACMask, DACSts + PaddrW, Pdata, Pixmask, PaddrR }; static uchar @@ -182,9 +182,9 @@ enable(void) * cursor colour 1 (white), * cursor colour 2 (black). */ - tvp3020xo(0x20, 0xFF); tvp3020xo(0x21, 0xFF); tvp3020xo(0x22, 0xFF); - tvp3020xo(0x23, 0xFF); tvp3020xo(0x24, 0xFF); tvp3020xo(0x25, 0xFF); - tvp3020xo(0x26, 0x00); tvp3020xo(0x27, 0x00); tvp3020xo(0x28, 0x00); + tvp3020xo(0x20, Pwhite); tvp3020xo(0x21, Pwhite); tvp3020xo(0x22, Pwhite); + tvp3020xo(0x23, Pwhite); tvp3020xo(0x24, Pwhite); tvp3020xo(0x25, Pwhite); + tvp3020xo(0x26, Pblack); tvp3020xo(0x27, Pblack); tvp3020xo(0x28, Pblack); unlock(&palettelock); @@ -243,4 +243,12 @@ Hwgc tvp3020hwgc = { load, move, disable, + + 0, }; + +void +vgatvp3020link(void) +{ + addhwgclink(&tvp3020hwgc); +} diff --git a/port/proc.c b/port/proc.c index 523c31e1efbdbdc4af8ed5cc4494318f9bd84e8b..ebb7e04cd66a85c7fb76c3ee70dc1b33d70b0643 100644 --- a/port/proc.c +++ b/port/proc.c @@ -406,9 +406,6 @@ sleep(Rendez *r, int (*f)(void*), void *arg) { int s; - if((getstatus()&IE) == 0) - print("sleep hi %lux\n", getcallerpc(r)); - sleep1(r, f, arg); if(up->notepending == 0) sched(); /* notepending may go true while asleep */ @@ -437,9 +434,6 @@ tsleep(Rendez *r, int (*fn)(void*), void *arg, int ms) ulong when; Proc *f, **l; - if((getstatus()&IE) == 0) - print("tsleep hi %lux\n", getcallerpc(r)); - when = MS2TK(ms)+MACHP(0)->ticks; lock(&talarm); @@ -923,8 +917,6 @@ procctl(Proc *p) void error(char *err) { - if((getstatus()&IE) == 0) - print("error hi %lux\n", getcallerpc(err)); spllo(); strncpy(up->error, err, ERRLEN); nexterror(); diff --git a/port/qlock.c b/port/qlock.c index 33c0269a355e2ebcc139fbedd7c42c7042385338..7b7fbab557decc94227e4225425f5b2d6e409af0 100644 --- a/port/qlock.c +++ b/port/qlock.c @@ -10,8 +10,6 @@ qlock(QLock *q) { Proc *p, *mp; - if((getstatus()&IE)==0) - print("qlock hi %lux\n", getcallerpc(q)); lock(&q->use); if(!q->locked) { q->locked = 1; @@ -50,8 +48,6 @@ qunlock(QLock *q) { Proc *p; - if((getstatus()&IE)==0) - print("qunlock hi %lux\n", getcallerpc(q)); lock(&q->use); p = q->head; if(p) {