From 246a6789ba5c87b622f80ac0daac5646abb2ad15 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 8 Jan 2000 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2000-01-08 --- alphapc/cga.c | 5 +++++ alphapc/kbd.c | 33 +++++++++++++++++++-------------- alphapc/l.s | 3 +++ alphapc/main.c | 10 ++++++++-- alphapc/ns16552.h | 20 ++------------------ alphapc/trap.c | 9 +++++++++ port/devbridge.c | 2 +- port/devproc.c | 2 +- 8 files changed, 48 insertions(+), 36 deletions(-) diff --git a/alphapc/cga.c b/alphapc/cga.c index c216617b7a79e9eb6e669d72ebbd3f3dc946b4c1..a96d659084cacac7a8724ab1ef1dbb4dd59bac4d 100644 --- a/alphapc/cga.c +++ b/alphapc/cga.c @@ -91,6 +91,7 @@ screeninit(void) static void cgascreenputs(char* s, int n) { +#ifdef notdef if(!screeninitdone) return; if(!islo()){ @@ -108,6 +109,10 @@ cgascreenputs(char* s, int n) cgascreenputc(*s++); unlock(&cgascreenlock); +#else + while(n-- > 0) + cgascreenputc(*s++); +#endif /* notdef */ } void (*screenputs)(char*, int) = cgascreenputs; diff --git a/alphapc/kbd.c b/alphapc/kbd.c index dd3ba8ed039f71ef3a39ee97f16159dba448cc11..acdd7faca17d84e5e2a561fbed41bfad28135919 100644 --- a/alphapc/kbd.c +++ b/alphapc/kbd.c @@ -25,7 +25,7 @@ enum { PF= Spec|0x20, /* num pad function key */ View= Spec|0x00, /* view (shift window up) */ - KF= Spec|0x40, /* function key */ + KF= 0xF000, /* function key (begin Unicode private space) */ Shift= Spec|0x60, Break= Spec|0x61, Ctrl= Spec|0x62, @@ -39,16 +39,21 @@ enum { Up= KF|14, Pgup= KF|15, Print= KF|16, - Left= View, - Right= View, + Left= KF|17, + Right= KF|18, End= '\r', Down= View, - Pgdown= View, + Pgdown= KF|19, Ins= KF|20, + Scroll= KF|21, Del= 0x7F, }; -uchar kbtab[] = +/* + * The codes at 0x79 and 0x81 are produed by the PFU Happy Hacking keyboard. + * A 'standard' keyboard doesn't produce anything above 0x58. + */ +Rune kbtab[] = { [0x00] No, 0x1b, '1', '2', '3', '4', '5', '6', [0x08] '7', '8', '9', '0', '-', '=', '\b', '\t', @@ -58,17 +63,17 @@ uchar kbtab[] = [0x28] '\'', '`', Shift, '\\', 'z', 'x', 'c', 'v', [0x30] 'b', 'n', 'm', ',', '.', '/', Shift, '*', [0x38] Latin, ' ', Ctrl, KF|1, KF|2, KF|3, KF|4, KF|5, -[0x40] KF|6, KF|7, KF|8, KF|9, KF|10, Num, KF|12, '7', +[0x40] KF|6, KF|7, KF|8, KF|9, KF|10, Num, Scroll, '7', [0x48] '8', '9', '-', '4', '5', '6', '+', '1', [0x50] '2', '3', '0', '.', No, No, No, KF|11, [0x58] KF|12, No, No, No, No, No, No, No, [0x60] No, No, No, No, No, No, No, No, [0x68] No, No, No, No, No, No, No, No, [0x70] No, No, No, No, No, No, No, No, -[0x78] No, View, No, KF|14, No, No, No, No, +[0x78] No, View, No, Up, No, No, No, No, }; -uchar kbtabshift[] = +Rune kbtabshift[] = { [0x00] No, 0x1b, '!', '@', '#', '$', '%', '^', [0x08] '&', '*', '(', ')', '_', '+', '\b', '\t', @@ -78,17 +83,17 @@ uchar kbtabshift[] = [0x28] '"', '~', Shift, '|', 'Z', 'X', 'C', 'V', [0x30] 'B', 'N', 'M', '<', '>', '?', Shift, '*', [0x38] Latin, ' ', Ctrl, KF|1, KF|2, KF|3, KF|4, KF|5, -[0x40] KF|6, KF|7, KF|8, KF|9, KF|10, Num, KF|12, '7', +[0x40] KF|6, KF|7, KF|8, KF|9, KF|10, Num, Scroll, '7', [0x48] '8', '9', '-', '4', '5', '6', '+', '1', [0x50] '2', '3', '0', '.', No, No, No, KF|11, [0x58] KF|12, No, No, No, No, No, No, No, [0x60] No, No, No, No, No, No, No, No, [0x68] No, No, No, No, No, No, No, No, [0x70] No, No, No, No, No, No, No, No, -[0x78] No, KF|14, No, KF|14, No, No, No, No, +[0x78] No, Up, No, Up, No, No, No, No, }; -uchar kbtabesc1[] = +Rune kbtabesc1[] = { [0x00] No, No, No, No, No, No, No, No, [0x08] No, No, No, No, No, No, No, No, @@ -105,7 +110,7 @@ uchar kbtabesc1[] = [0x60] No, No, No, No, No, No, No, No, [0x68] No, No, No, No, No, No, No, No, [0x70] No, No, No, No, No, No, No, No, -[0x78] No, KF|14, No, No, No, No, No, No, +[0x78] No, Up, No, No, No, No, No, No, }; enum @@ -231,7 +236,7 @@ i8042intr(Ureg*, void*) static int esc1, esc2; static int alt, caps, ctl, num, shift; static int collecting, nk; - static uchar kc[5]; + static Rune kc[5]; int keyup; /* @@ -314,7 +319,7 @@ i8042intr(Ureg*, void*) /* * normal character */ - if(!(c & Spec)){ + if(!(c & (Spec|KF))){ if(ctl){ if(alt && c == Del) exit(0); diff --git a/alphapc/l.s b/alphapc/l.s index e1ff930bd4b86112ad15d1aba5ceb67ccab26b91..80d916c9410beab2e1e81d238c57533ee9ab9cd2 100644 --- a/alphapc/l.s +++ b/alphapc/l.s @@ -80,6 +80,9 @@ GLOBL init_ptbr(SB), $8 TEXT firmware(SB), $-8 CALL_PAL $PALhalt +TEXT xxfirmware(SB), $-8 + CALL_PAL $PALhalt + TEXT splhi(SB), $0 MOVL R26, 4(R(MACH)) /* save PC in m->splpc */ diff --git a/alphapc/main.c b/alphapc/main.c index e79942b90aca79f59f788423690d3871df10afbe..9d63c4f4a850c4ddd7263821346c58e44a2c43ff 100644 --- a/alphapc/main.c +++ b/alphapc/main.c @@ -29,13 +29,19 @@ main(void) archinit(); mmuinit(); xinit(); - printinit(); if (arch->coreinit) arch->coreinit(); trapinit(); + screeninit(); +screenputs("Hello Squidboy\n", 15); +{ static Lock l; + ilock(&l); +xxfirmware(); + iunlock(&l); +} + printinit(); /* console */ - screeninit(); ns16552install(); ns16552special(0, 9600, 0, &printq, kbdcr2nl); kbdinit(); diff --git a/alphapc/ns16552.h b/alphapc/ns16552.h index eb2b9064fe4b95a9006855fdd7d43328c8e3c511..68e293689b7445447402b28bdb415210f4a365af 100644 --- a/alphapc/ns16552.h +++ b/alphapc/ns16552.h @@ -5,6 +5,7 @@ void ns16552setup(ulong, ulong, char*, int); void ns16552intr(int); +void uartclock(void); /* * handle an interrupt to a single uart @@ -28,6 +29,7 @@ ns16552install(void) intrenable(VectorUART0, ns16552intrx, (void*)0, BUSUNKNOWN); ns16552setup(Uart1, UartFREQ, "eia1", Ns550); intrenable(VectorUART1, ns16552intrx, (void*)0, BUSUNKNOWN); + addclock0link(uartclock); } #define RD(r) inb(Uart0+(r)) @@ -43,21 +45,3 @@ ns16552iputc(char c) mb(); } -int -iprint(char *fmt, ...) -{ - int n, i, s; - char buf[512]; - va_list arg; - - va_start(arg, fmt); - n = doprint(buf, buf+sizeof(buf), fmt, arg) - buf; - va_end(arg); - - s = splhi(); - for(i = 0; i < n; i++) - ns16552iputc(buf[i]); - splx(s); - - return n; -} diff --git a/alphapc/trap.c b/alphapc/trap.c index e986ae165f8906a7fa52f19209a0f8e94b810580..877b309cbedb213e0089776d385f819e347f7c2f 100644 --- a/alphapc/trap.c +++ b/alphapc/trap.c @@ -279,6 +279,15 @@ dumpstack(void) } } +void +callwithureg(void (*fn)(Ureg*)) +{ + Ureg ureg; + ureg.pc = getcallerpc(&fn); + ureg.sp = (ulong)&fn; + fn(&ureg); +} + void dumpregs(Ureg *ur) { diff --git a/port/devbridge.c b/port/devbridge.c index 8905be7e762ea11c53101ffec498546fe49c30d6..bbab81fb471b3a24899537bb1ab6f14895b1fda3 100644 --- a/port/devbridge.c +++ b/port/devbridge.c @@ -420,7 +420,7 @@ bridgegen(Chan *c, Dirtab*, int, int s, Dir *dp) switch(TYPE(c->qid)){ case Qtopdir: case Qbridgedir: - snprint(buf, "#B%d", c->dev); + snprint(buf, sizeof(buf), "#B%ld", c->dev); devdir(c, (Qid){CHDIR|Qtopdir, 0}, buf, 0, eve, 0555, dp); break; case Qportdir: diff --git a/port/devproc.c b/port/devproc.c index df75beadd8c3fda54175e062061da61f8e784dda..1047204e7097584e7d4e9b553c11d8c9db38dc16 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -374,7 +374,7 @@ procread(Chan *c, void *va, long n, vlong off) return procctlmemio(p, offset, n, va, 1); /* Protect crypt key memory */ - if(offset >= palloc.cmembase&&offset < palloc.cmemtop) + if(offset+n >= palloc.cmembase && offset < palloc.cmemtop) error(Eperm); /* validate physical kernel addresses */