From 94fab7720a0f9bb7462ae58f0d1794e231ed5a64 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 11 Dec 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-12-11 --- pc/dat.h | 1 - pc/devhard.c | 26 +++++++++++------- pc/devrtc.c | 4 +++ pc/kbd.c | 43 +++++++++++++++++++++--------- pc/l.s | 22 ++++++++------- pc/main.c | 4 +-- pc/mmu.c | 1 + pc/vga.c | 8 +++--- port/devcons.c | 14 +++++----- port/portfns.h | 3 ++- ss/screen.c | 72 +++++++++++++++++++++++++++++++------------------- 11 files changed, 124 insertions(+), 74 deletions(-) diff --git a/pc/dat.h b/pc/dat.h index 29bc3cd40c75e0697fc47ca8897ff7424cf5736a..e1606e52513b1b9e2d5fc20892ef22089addbfff 100644 --- a/pc/dat.h +++ b/pc/dat.h @@ -181,7 +181,6 @@ struct Segdesc ulong d1; }; - struct { Lock; diff --git a/pc/devhard.c b/pc/devhard.c index a59ecb6cf047064189240daa8255e20c7a5edf66..8871fa09fb0f90003bbd8f614de8c8de2e1d34d4 100644 --- a/pc/devhard.c +++ b/pc/devhard.c @@ -226,9 +226,21 @@ hardattach(char *spec) dp->bytes = 512; hardsetbuf(dp, 1); hardident(dp); - dp->cyl = dp->id.lcyls; - dp->heads = dp->id.lheads; - dp->sectors = dp->id.ls2t; + switch(dp->id.magic){ + case 0xA5A: /* conner drive on the AT&T NSX (safari) */ + dp->cyl = dp->id.lcyls; + dp->heads = dp->id.lheads; + dp->sectors = dp->id.ls2t; + break; + case 0x324A: /* hard drive on the AT&T 6386 */ + dp->cyl = dp->id.lcyls - 4; + dp->heads = dp->id.lheads; + dp->sectors = dp->id.ls2t - 1; + break; + default: + print("unknown hard disk type\n"); + errors("unknown hard disk type"); + } dp->bytes = 512; dp->cap = dp->bytes * dp->cyl * dp->heads * dp->sectors; dp->online = 1; @@ -542,7 +554,6 @@ hardident(Drive *dp) cp = dp->cp; qlock(cp); if(waserror()){ -print("waserror in hardident\n"); qunlock(cp); nexterror(); } @@ -557,16 +568,11 @@ print("waserror in hardident\n"); outb(cp->pbase+Pcmd, Cident); sleep(&cp->r, cmddone, cp); if(cp->status & Serr){ -print("bad disk magic\n"); + print("bad disk ident status\n"); errors("disk I/O error"); } memmove(&dp->id, cp->buf, dp->bytes); - if(dp->id.magic != 0xA5A){ -print("bad disk magic\n"); - errors("bad disk magic"); - } - poperror(); qunlock(cp); } diff --git a/pc/devrtc.c b/pc/devrtc.c index 5b2b961130d6e6712e84b7776614dca6ba3bacd1..d046445d0c741ba30edc2b7ddfc31fd0e1b445c5 100644 --- a/pc/devrtc.c +++ b/pc/devrtc.c @@ -6,6 +6,10 @@ #include "errno.h" #include "devtab.h" +/* + * real time clock and non-volatile ram + */ + enum { Paddr= 0x70, /* address port */ Pdata= 0x71, /* data port */ diff --git a/pc/kbd.c b/pc/kbd.c index e44519062ffc19ceb1e6d747bf6e8f70d204e5c6..867ec4bb61c8039e5f7599744307a0cb6ba0cdd3 100644 --- a/pc/kbd.c +++ b/pc/kbd.c @@ -191,7 +191,7 @@ i8042reset(void) outready(); outb(Cmd, 0xD1); outready(); - outb(Data, 0xDE); + outb(Data, 0x0); outready(); } @@ -299,13 +299,14 @@ middle(int newval) int kbdintr0(void) { - int s, c, nc; + int s, c, i, nk, nc; static int esc1, esc2; static int shift; static int caps; static int ctl; static int num; - static int lstate, k1, k2; + static int lstate; + static uchar kc[5]; int keyup; /* @@ -343,7 +344,6 @@ kbdintr0(void) c &= 0x7f; if(c > sizeof kbtab){ print("unknown key %ux\n", c|keyup); - kbdputc(&kbdq, k1); return 0; } @@ -390,21 +390,38 @@ kbdintr0(void) c &= 0x1f; switch(lstate){ case 1: - k1 = c; + kc[0] = c; lstate = 2; - return 0; + if(c == 'X') + lstate = 3; + break; case 2: - k2 = c; + kc[1] = c; + c = latin1(kc); + nk = 2; + putit: lstate = 0; - c = latin1(k1, k2); - if(c == 0){ - kbdputc(&kbdq, k1); - c = k2; - } - /* fall through */ + if(c != -1) + kbdputc(&kbdq, c); + else for(i=0; iqid.path){ case Qrcons: - if(conf.cntrlp) + if(strcmp(u->p->user, eve) != 0) error(Eperm); if(incref(&raw) == 1){ lock(&lineq); diff --git a/port/portfns.h b/port/portfns.h index a677df43dcfb818f78d83de89fbcfbf3da3359e3..96543dd0500e261e6ab3d3f887786d08fc2cbd51 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -106,7 +106,7 @@ int kprint(char*, ...); void kproc(char*, void(*)(void*), void*); void ksetenv(char*, char*); void ksetterm(char*); -int latin1(int, int); +long latin1(uchar*); void lights(int); void lock(Lock*); void lockinit(void); @@ -238,6 +238,7 @@ void uncachepage(Page*); long unionread(Chan*, void*, long); void unlock(Lock*); void unlockpage(Page*); +long unicode(uchar*); void userinit(void); void validaddr(ulong, ulong, int); void* vmemchr(void*, int, int); diff --git a/ss/screen.c b/ss/screen.c index f78207b54acd04c7f95d18d4def69c0a49623b22..929c2cdced71d1ab313123ce783870b957e22b0d 100644 --- a/ss/screen.c +++ b/ss/screen.c @@ -244,66 +244,84 @@ kbdstate(IOQ *q, int c) static caps = 0; static long startclick; static int repeatc; - static int kbdstate, k1, k2; - int tc; + static int lstate; + static uchar kc[4]; + uchar ch, code; + int i, nk; - tc = kbdmap[shift][c&0x7F]; + ch = kbdmap[shift][c&0x7F]; if(c==0x7F){ /* all keys up */ norepeat: kbdrepeat(0); return; } - if(tc == 0xFF) /* shouldn't happen; ignore */ + if(ch == 0xFF) /* shouldn't happen; ignore */ return; if(c & 0x80){ /* key went up */ - if(tc == 0xF0){ /* control */ + if(ch == 0xF0){ /* control */ shift &= ~2; goto norepeat; } - if(tc == 0xF1){ /* shift */ + if(ch == 0xF1){ /* shift */ shift &= ~1; goto norepeat; } - if(tc == 0xF2){ /* caps */ + if(ch == 0xF2){ /* caps */ goto norepeat; } goto norepeat; } - if(tc == 0xF0){ /* control */ + if(ch == 0xF0){ /* control */ shift |= 2; goto norepeat; } - if(tc==0xF1){ /* shift */ + if(ch==0xF1){ /* shift */ shift |= 1; goto norepeat; } - if(tc==0xF2){ /* caps */ + if(ch==0xF2){ /* caps */ caps ^= 1; goto norepeat; } - if(caps && 'a'<=tc && tc<='z') - tc |= ' '; - repeatc = tc; + if(caps && 'a'<=ch && ch<='z') + ch |= ' '; + repeatc = ch; kbdrepeat(1); - if(tc == 0xB6) /* Compose */ - kbdstate = 1; + if(ch == 0xB6) /* Compose */ + lstate = 1; else{ - switch(kbdstate){ + switch(lstate){ case 1: - k1 = tc; - kbdstate = 2; + kc[0] = ch; + lstate = 2; + if(ch == 'X') + lstate = 3; break; case 2: - k2 = tc; - tc = latin1(k1, k2); - if(c == 0){ - kbdputc(&kbdq, k1); - tc = k2; - } - /* fall through */ + kc[1] = ch; + c = latin1(kc); + nk = 2; + putit: + lstate = 0; + if(c != -1) + kbdputc(&kbdq, c); + else for(i=0; i