From 345fba81e1340ee618b63e59865eb9defc7fe1eb Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 4 Sep 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-09-04 --- pc/dat.h | 23 ----------- pc/devconfig.c | 6 +++ pc/fns.h | 4 ++ pc/io.h | 10 ++--- pc/kbd.c | 109 +++++++++++++++++++++++++++++++------------------ pc/main.c | 16 +++++--- port/stil.c | 5 ++- ss/fns.h | 2 +- ss/io.h | 7 ++-- ss/l.s | 3 +- ss/main.c | 81 ++++++++++++++++++++---------------- ss/screen.c | 84 ++++++++++++++++++++++++------------- 12 files changed, 207 insertions(+), 143 deletions(-) diff --git a/pc/dat.h b/pc/dat.h index 0bdcc569e2dfef566e7f439671d65bdf1f183b8b..7312a0a1a7304db2a19401eecb64b3474c3f8c7e 100644 --- a/pc/dat.h +++ b/pc/dat.h @@ -186,26 +186,3 @@ extern int flipD[]; /* for flipping bitblt destination polarity */ * bootline passed by boot program */ #define BOOTLINE ((char *)0x80000100) - -/* - * configuration info - */ -enum -{ - /* what kind of power management */ - PMUother= 0, - PMUnsx20= 1, - - /* what kind of mouse */ - Mouseother= 0, - Mouseserial= 1, - MousePS2= 2, - - /* how to reset the processor */ - Resetother= 0, - Reset8042= 1, - Resetheadland= 2, -}; -extern int mousetype; -extern int pmutype; -extern int resettype; diff --git a/pc/devconfig.c b/pc/devconfig.c index 6727693f38ef96c17aaae6a6c721f9564659038a..d8d9af2eab5764e21fc2b5e0065cc773199040ad 100644 --- a/pc/devconfig.c +++ b/pc/devconfig.c @@ -194,6 +194,12 @@ configwrite(Chan *c, void *buf, long n, ulong offset) mouseaccelerate(1); else if(strncmp("linear", cbuf, 6) == 0) mouseaccelerate(0); + 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)); return n; } error(Eperm); diff --git a/pc/fns.h b/pc/fns.h index c1a00cb091aabb4e66b64dc036205c1c8d9ff771..49865288cd63c227025e554540acc0c893866105 100644 --- a/pc/fns.h +++ b/pc/fns.h @@ -37,7 +37,11 @@ void ksetpcinfo(void); void mathinit(void); void mmuinit(void); int modem(int); +void mouseserial(int); +void mouseps2(void); void mouseaccelerate(int); +void mouseres(int); +void mousespeed(int); void outb(int, int); void outss(int, void*, int); void pmubuzz(int, int); diff --git a/pc/io.h b/pc/io.h index e157e8a31b3b69ce523bee4dd78d79cc7ba51808..16fafa80fcfde8564b2b71b21421fd60d039cb52 100644 --- a/pc/io.h +++ b/pc/io.h @@ -14,13 +14,13 @@ enum Kbdvec= Int0vec+1, /* keyboard interrupts */ Uart1vec= Int0vec+3, /* modem line */ Uart0vec= Int0vec+4, /* serial line */ - Ethervec= Int0vec+5, /* ethernet interrupt */ Floppyvec= Int0vec+6, /* floppy interrupts */ Parallelvec= Int0vec+7, /* parallel port interrupts */ - Int1vec= Int0vec+8, /* second 8259 */ - Mousevec= Int1vec+4, /* mouse interrupt */ - Matherr2vec= Int1vec+5, /* math coprocessor */ - Hardvec= Int1vec+6, /* hard disk */ + Int1vec= Int0vec+8, + Ethervec= Int0vec+10, /* ethernet interrupt */ + Mousevec= Int0vec+12, /* mouse interrupt */ + Matherr2vec= Int0vec+13, /* math coprocessor */ + Hardvec= Int0vec+14, /* hard disk */ Syscallvec= 64, }; diff --git a/pc/kbd.c b/pc/kbd.c index 226e23a0e99054b1f65856b99550f79798238af4..817577d1a04a78cbfec9287c8473365277d944fe 100644 --- a/pc/kbd.c +++ b/pc/kbd.c @@ -112,6 +112,14 @@ static int keybuttons; */ static void kbdintr(Ureg*); +enum +{ + /* what kind of mouse */ + Mouseother= 0, + Mouseserial= 1, + MousePS2= 2, +}; +static int mousetype; /* * wait for output no longer busy @@ -207,46 +215,52 @@ kbdinit(void) if(c & Inready) inb(Data); - switch(mousetype){ - case MousePS2: - bigcursor(); - setvec(Mousevec, kbdintr); - - /* enable kbd/mouse xfers and interrupts */ - outb(Cmd, 0x60); - if(outready() < 0) - print("kbd init failed\n"); - outb(Data, 0x47); - if(outready() < 0) - print("kbd init failed\n"); - outb(Cmd, 0xA8); - - /* make mouse streaming, enabled */ - if(mousecmd(0xEA) < 0 - || mousecmd(0xF4) < 0) - print("can't initialize mouse\n"); - - /* turn on mouse acceleration */ - mouseaccelerate(0); - break; - case Mouseserial: - /* enable kbd xfers and interrupts */ - outb(Cmd, 0x60); - if(outready() < 0) - print("kbd init failed\n"); - outb(Data, 0x65); - - /* set up /dev/eia0 as the mouse */ - uartspecial(0, 0, &mouseq, 1200); - break; - case Mouseother: - /* enable kbd xfers and interrupts */ - outb(Cmd, 0x60); - if(outready() < 0) - print("kbd init failed\n"); - outb(Data, 0x65); - break; - } + /* enable kbd xfers and interrupts */ + outb(Cmd, 0x60); + if(outready() < 0) + print("kbd init failed\n"); + outb(Data, 0x65); +} + +/* + * setup a serial mouse + */ +void +mouseserial(int port) +{ + if(mousetype) + return; + + /* set up /dev/eia0 as the mouse */ + uartspecial(port, 0, &mouseq, 1200); + mousetype = Mouseserial; +} + +/* + * set up a ps2 mouse + */ +void +mouseps2(void) +{ + if(mousetype) + return; + + bigcursor(); + setvec(Mousevec, kbdintr); + + /* enable kbd/mouse xfers and interrupts */ + outb(Cmd, 0x60); + if(outready() < 0) + print("kbd init failed\n"); + outb(Data, 0x47); + if(outready() < 0) + print("kbd init failed\n"); + outb(Cmd, 0xA8); + + /* make mouse streaming, enabled */ + mousecmd(0xEA); + mousecmd(0xF4); + mousetype = MousePS2; } /* @@ -266,6 +280,21 @@ mouseaccelerate(int on) } } +/* + * set mouse resolution + */ +void +mouseres(int res) +{ + + switch(mousetype){ + case MousePS2: + mousecmd(0xE8); + mousecmd(res); + break; + } +} + /* * mouse message is three bytes * diff --git a/pc/main.c b/pc/main.c index 0f273617e00fc0b3d6d35dd583204772cbb67721..1b1c8ab0871b8e3b3fc6c170b6b4fad760b03ebe 100644 --- a/pc/main.c +++ b/pc/main.c @@ -8,7 +8,17 @@ #include "init.h" /* configuration parameters */ -int mousetype; +enum +{ + /* what kind of power management */ + PMUother= 0, + PMUnsx20= 1, + + /* how to reset the processor */ + Resetother= 0, + Reset8042= 1, + Resetheadland= 2, +}; int pmutype; int resettype; @@ -54,14 +64,10 @@ ident(void) char *id = (char*)(ROMBIOS + 0xFF40); if(strncmp(id, "AT&TNSX", 7) == 0){ - mousetype = MousePS2; pmutype = PMUnsx20; resettype = Resetheadland; }else if(strncmp(id, "NCRD.0", 6) == 0){ - mousetype = MousePS2; resettype = Reset8042; - }else{ - mousetype = Mouseserial; } } diff --git a/port/stil.c b/port/stil.c index 5227c18fb9e9d243f8f5007f395d0d2928777598..d5f2e65b1a5e2027024ede45577dfa81f2edf6b8 100644 --- a/port/stil.c +++ b/port/stil.c @@ -788,7 +788,10 @@ ilbackoff(Ilcb *ic) static int notsyncer(void *ic) { - return ((Ilcb*)ic)->state != Ilsyncer; + Ilcb *i; + + i = ic; + return i->state != Ilsyncer; } void ilstart(Ipconv *ipc, int type, int window) diff --git a/ss/fns.h b/ss/fns.h index a55c753da9b70e960d6e1eb62b13e430329e3f2d..578d8b2468427f3da64bee77d437b0f0c38ed3b1 100644 --- a/ss/fns.h +++ b/ss/fns.h @@ -56,7 +56,7 @@ void puttbr(ulong); void putw4(ulong, ulong); /* needed only at boot time */ void systemreset(void); void restfpregs(FPsave*, ulong); -void screeninit(char*); +void screeninit(char*, int); void screenputc(int); void screenputs(char*, int); void scsiintr(void); diff --git a/ss/io.h b/ss/io.h index 69e0766c1b2c9fa0122afc261bfc969a209d8d0d..95b92b67e77bf171511dbe8950b891eea1e1f2af 100644 --- a/ss/io.h +++ b/ss/io.h @@ -1,6 +1,7 @@ -#define FRAMEBUF 0xFE000000 -#define FRAMEBUFID (FRAMEBUF+0x000000) -#define DISPLAYRAM (FRAMEBUF+0x800000) +#define SBUS(n) (0xF8000000+(n)*0x2000000) +#define FRAMEBUF(n) SBUS(n) +#define FRAMEBUFID(n) (SBUS(n)+0x000000) +#define DISPLAYRAM(n) (SBUS(n)+0x800000) #define EPROM 0xF6000000 #define CLOCK 0xF3000000 #define CLOCKFREQ 1000000 /* one microsecond increments */ diff --git a/ss/l.s b/ss/l.s index 148f01a834d56487dce4568fb7f2963cf206fe5f..d8678cee979c3339e15bf4acde1e4dd885002f2e 100644 --- a/ss/l.s +++ b/ss/l.s @@ -39,7 +39,8 @@ TEXT startvirt(SB), $-4 MOVW $(0x35<<22), R7 /* NVM OFM DZM NS */ MOVW R7, fsr+0(SB) - MOVW fsr+0(SB), FSR + MOVW $fsr+0(SB), R8 + MOVW (R8), FSR FMOVD $0.5, F26 /* 0.5 -> F26 */ FSUBD F26, F26, F24 /* 0.0 -> F24 */ FADDD F26, F26, F28 /* 1.0 -> F28 */ diff --git a/ss/main.c b/ss/main.c index 707ddc793d26da6ff027858efde2f61b3d2e5323..e06154af9a2626a3884790d665414276468757a3 100644 --- a/ss/main.c +++ b/ss/main.c @@ -17,6 +17,7 @@ ulong romputcxsegm; ulong bank[2]; char mempres[256]; char fbstr[32]; +ulong fbslot; Label catch; int NKLUDGE; @@ -61,7 +62,7 @@ main(void) mmuinit(); kmapinit(); if(conf.monitor) - screeninit(fbstr); + screeninit(fbstr, fbslot); printinit(); ioinit(); if(conf.monitor == 0) @@ -138,8 +139,9 @@ init0(void) print("Sun Sparcstation %s\n", sparam->name); print("bank 0: %dM 1: %dM\n", bank[0], bank[1]); - print("frame buffer id %lux %s\n", conf.monitor, fbstr); + print("frame buffer id %lux slot %ld %s\n", conf.monitor, fbslot, fbstr); print("NKLUDGE %d\n", NKLUDGE); +mapcrap(); if(conf.npage1 != conf.base1) print("kernel mem from second bank: reboot and fix!\n"); @@ -278,7 +280,7 @@ void confinit(void) { int mul; - ulong i, j; + ulong i, j, f; ulong ktop, va, mbytes, npg, v; conf.nmach = 1; @@ -310,48 +312,55 @@ confinit(void) case 0x52: /* IPC */ case 0x54: /* SLC */ conf.monitor = 1; + fbslot = 3; strcpy(fbstr, "bwtwo"); break; case 0x57: /* IPX */ conf.monitor = 1; + fbslot = 3; strcpy(fbstr, "cgsix"); break; default: - /* map frame buffer id in SBUS slot 3 */ - putw4(va, ((FRAMEBUFID>>PGSHIFT)&0xFFFF)|PTEPROBEIO); - conf.monitor = 0; - /* if frame buffer not present, we will trap, so prepare to catch it */ - if(setlabel(&catch) == 0){ - conf.monitor = *(ulong*)va; - switch(conf.monitor){ - case 0xFE010101: - strcpy(fbstr, "cgthree"); - break; - case 0xFE010104: - strcpy(fbstr, "bwtwo"); - break; - } - if(fbstr[0] == 0){ - j = *(ulong*)(va+4); - if(j > BY2PG-8) - j = BY2PG - 8; /* -8 for safety */ - for(i=0; i>PGSHIFT)&0xFFFF)|PTEPROBEIO); + conf.monitor = 0; + /* if frame buffer not present, we will trap, so prepare to catch it */ + if(setlabel(&catch) == 0){ + conf.monitor = *(ulong*)va; + switch(conf.monitor & 0xF0FFFFFF){ + case 0xF0010101: + strcpy(fbstr, "cgthree"); + break; + case 0xF0010104: + strcpy(fbstr, "bwtwo"); + break; + } + if(fbstr[0] == 0){ + j = *(ulong*)(va+4); + if(j > BY2PG-8) + j = BY2PG - 8; /* -8 for safety */ + for(i=0; iid; sparam++) diff --git a/ss/screen.c b/ss/screen.c index ff335eb19c55acdca82fe9a8da2cd2635c33f09a..4077847c2363f8dd2303d9c7d2af44e65229114a 100644 --- a/ss/screen.c +++ b/ss/screen.c @@ -23,10 +23,10 @@ struct{ static ulong rep(ulong, int); void (*kprofp)(ulong); -/* Brooktree 458/451 */ -typedef struct DAC DAC; -struct DAC +typedef struct Video Video; +struct Video { + /* Brooktree 458/451 */ uchar addr; /* address register */ uchar pad0[3]; uchar color; /* color palette */ @@ -35,7 +35,24 @@ struct DAC uchar pad2[3]; uchar ovrl; /* overlay palette */ uchar pad3[3]; -}*dac; + /* Sun-4 video chip */ + uchar mcr; /* master control register */ + uchar sr; /* status register */ + uchar csa; /* cursor start address */ + uchar cea; /* cursor end address */ + uchar hbs; /* horizontal blank set */ + uchar hbc; /* horizontal blank clear */ + uchar hss; /* horizontal sync set */ + uchar hsc; /* horizontal sync clear */ + uchar csc; /* composite sync clear */ + uchar vbsh; /* vertical blank set high byte */ + uchar vbsl; /* vertical blank set low byte */ + uchar vbc; /* vertical blank clear */ + uchar vss; /* vertical sync set */ + uchar vsc; /* vertical sync clear */ + uchar xcs; /* transfer cycle hold off set */ + uchar xcc; /* transfer cycle hold off clear */ +}*vid; GBitmap gscreen; @@ -45,7 +62,7 @@ struct screens int x; int y; int ld; - ulong dacaddr; + ulong vidaddr; }screens[] = { { "bwtwo", 1152, 900, 0, 0x400000 }, { "cgsix", 1152, 900, 3, 0x200000 }, @@ -56,7 +73,7 @@ struct screens Lock screenlock; void -screeninit(char *str) +screeninit(char *str, int slot) { struct screens *s; ulong n, r, g, b; @@ -78,7 +95,7 @@ screeninit(char *str) gscreen.zero = 0; gscreen.width = (s->x<ld)/(8*sizeof(ulong)); n = sizeof(ulong) * gscreen.width * s->y; - gscreen.base = (ulong*)kmapregion(DISPLAYRAM, n, PTENOCACHE|PTEIO); + gscreen.base = (ulong*)kmapregion(DISPLAYRAM(slot), n, PTENOCACHE|PTEIO); gscreen.ldepth = s->ld; gscreen.r = Rect(0, 0, s->x, s->y); gscreen.clipr = gscreen.r; @@ -88,16 +105,16 @@ screeninit(char *str) out.pos.x = MINX; out.pos.y = 0; out.bwid = defont0.info[' '].width; - dac = (DAC*)(kmappa(FRAMEBUF+s->dacaddr, PTENOCACHE|PTEIO)->va); + vid = (Video*)(kmappa(FRAMEBUF(slot)+s->vidaddr, PTENOCACHE|PTEIO)->va); if(gscreen.ldepth == 3){ - dac->addr = 4; - dac->cntrl = 0xFF; /* enable all planes */ - dac->addr = 5; - dac->cntrl = 0x00; /* no blinking */ - dac->addr = 6; - dac->cntrl = 0x43; /* enable palette ram and display */ - dac->addr = 7; - dac->cntrl = 0x00; /* no tests */ + vid->addr = 4; + vid->cntrl = 0xFF; /* enable all planes */ + vid->addr = 5; + vid->cntrl = 0x00; /* no blinking */ + vid->addr = 6; + vid->cntrl = 0x43; /* enable palette ram and display */ + vid->addr = 7; + vid->cntrl = 0x00; /* no tests */ havecol = 0; if(havecol) { /* @@ -116,16 +133,27 @@ screeninit(char *str) setcolor(85, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA); setcolor(170, 0x55555555, 0x55555555, 0x55555555); } else { - dac->addr = 0; + vid->addr = 0; for(i=255; i>=0; i--){ - dac->color = i; - dac->color = i; - dac->color = i; + vid->color = i; + vid->color = i; + vid->color = i; } } } } +void +mapcrap(void) +{ + uchar *v; + int i; + + v = &vid->mcr; + for(i=0; i<16; i++,v++) + print("%lux %.2ux\n", v, *v); +} + void screenputnl(void) { @@ -461,10 +489,10 @@ getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb) ans = 0; *pr = *pg = *pb = ans; } else { - *(uchar *)&dac->addr = p & 0xFF; - r = dac->color; - g = dac->color; - b = dac->color; + *(uchar *)&vid->addr = p & 0xFF; + r = vid->color; + g = vid->color; + b = vid->color; *pr = (r<<24) | (r<<16) | (r<<8) | r; *pg = (g<<24) | (g<<16) | (g<<8) | g; *pb = (b<<24) | (b<<16) | (b<<8) | b; @@ -478,10 +506,10 @@ setcolor(ulong p, ulong r, ulong g, ulong b) if(gscreen.ldepth == 0) return 0; /* can't change mono screen colormap */ else{ - dac->addr = p & 0xFF; - dac->color = r >> 24; - dac->color = g >> 24; - dac->color = b >> 24; + vid->addr = p & 0xFF; + vid->color = r >> 24; + vid->color = g >> 24; + vid->color = b >> 24; return 1; } }