From 34c50ddfb059a168ddeb0645250b776d8d2217ef Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 18 Sep 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-09-18 --- boot/boot.c | 10 +++++++--- pc/dat.h | 2 ++ pc/devether.c | 41 +++++++++++++++++++++++------------------ pc/fns.h | 1 - pc/kbd.c | 9 ++++++--- pc/main.c | 20 +++++++++++++++++--- pc/trap.c | 3 ++- 7 files changed, 57 insertions(+), 29 deletions(-) diff --git a/boot/boot.c b/boot/boot.c index 19193268bdc1e2a3a5de1238dca89f666cb94105..617a4dceb03a2264eafb2b7d576087d9853d82d7 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -149,7 +149,7 @@ rootserver(char *arg) char reply[64]; Method *mp; char *cp; - int n; + int n, j; int notfirst; mp = method; @@ -165,9 +165,13 @@ rootserver(char *arg) for(notfirst = 0;; notfirst = 1){ if(pflag || notfirst) outin(prompt, reply, sizeof(reply)); + cp = strchr(reply, '!'); + if(cp) + j = cp - reply; + else + j = strlen(reply); for(mp = method; mp->name; mp++) - if(*reply == *mp->name){ - cp = strchr(reply, '!'); + if(strncmp(reply, mp->name, j) == 0){ if(cp) strcpy(sys, cp+1); return mp; diff --git a/pc/dat.h b/pc/dat.h index 7312a0a1a7304db2a19401eecb64b3474c3f8c7e..5ecfd65ebe804584a8a9f329610fe85790b07483 100644 --- a/pc/dat.h +++ b/pc/dat.h @@ -186,3 +186,5 @@ extern int flipD[]; /* for flipping bitblt destination polarity */ * bootline passed by boot program */ #define BOOTLINE ((char *)0x80000100) + +extern char machtype[]; diff --git a/pc/devether.c b/pc/devether.c index 6f734d5e9afd664a8bbc6da25296ebeb061f6e1a..03dbe7a3acfc2495b3d53ac25e0fced772bd2670 100644 --- a/pc/devether.c +++ b/pc/devether.c @@ -693,7 +693,6 @@ int intrmap[] = 9, 3, 5, 7, 10, 11, 15, 4, }; - /* * get configuration parameters, enable memory */ @@ -702,18 +701,28 @@ wd8013reset(Ctlr *cp) { Hw *hw = cp->hw; int i; - uchar msr; - uchar icr; - uchar laar; - uchar irr; + uchar msr, icr, laar, irr; ulong ram; - msr = IN(hw, msr); - icr = IN(hw, icr); - irr = IN(hw, irr); - laar = IN(hw, laar); - - if(msr == 0xff || icr == 0xff || irr == 0xff || laar == 0xff) + /* find the ineterface */ + SET(msr, icr, irr, laar); + for(hw->addr = 0x200; hw->addr < 0x400; hw->addr += 0x20){ + msr = IN(hw, msr); + icr = IN(hw, icr); + irr = IN(hw, irr); + laar = IN(hw, laar); + if((msr&0x80) || (icr&0xf0) || irr == 0xff || laar == 0xff) + continue; /* nothing there */ + + /* ethernet address */ + for(i = 0; i < sizeof(cp->ea); i++) + cp->ea[i] = IN(hw, lan[i]); + + /* look for an elite ether address */ + if(cp->ea[0] == 0x00 && cp->ea[1] == 0x00 && cp->ea[2] == 0xC0) + break; + } + if(hw->addr >= 0x400) return -1; if(cp->rb == 0){ @@ -723,10 +732,6 @@ wd8013reset(Ctlr *cp) cp->ntb = Ntb; } - /* ethernet address */ - for(i = 0; i < sizeof(cp->ea); i++) - cp->ea[i] = IN(hw, lan[i]); - /* 16 bit operation? */ hw->bt16 = icr & 0x1; @@ -751,7 +756,7 @@ wd8013reset(Ctlr *cp) hw->pstart = HOWMANY(sizeof(Etherpkt), 256); hw->pstop = HOWMANY(hw->size, 256); -/* print("ether width %d addr %lux size %d lvl %d\n", hw->bt16?16:8, +print("elite at %lux width %d addr %lux size %d lvl %d\n", hw->addr, hw->bt16?16:8, hw->ram, hw->size, hw->lvl);/**/ /* enable interface RAM, set interface width */ @@ -902,7 +907,8 @@ wd8013receive(Ctlr *cp) OUT(hw, w.cr, Page0|RD2|STA); if(next == curr) break; - waitfordma(hw); + if(strcmp(machtype, "NCRD.0") == 0) + waitfordma(hw); cp->inpackets++; p = &((Ring*)hw->ram)[next]; len = ((p->len1<<8)|p->len0)-4; @@ -1009,5 +1015,4 @@ static Hw wd8013 = wd8013transmit, wd8013intr, wd8013tweek, - 0x360, /* I/O base address */ }; diff --git a/pc/fns.h b/pc/fns.h index 49865288cd63c227025e554540acc0c893866105..6a667074ebc8c2492e272b585d6b108fce1b1003 100644 --- a/pc/fns.h +++ b/pc/fns.h @@ -33,7 +33,6 @@ void idle(void); int inb(int); void inss(int, void*, int); void kbdinit(void); -void ksetpcinfo(void); void mathinit(void); void mmuinit(void); int modem(int); diff --git a/pc/kbd.c b/pc/kbd.c index 817577d1a04a78cbfec9287c8473365277d944fe..b65e9f79e653a5c8d5809f8d183754964ddfa3bc 100644 --- a/pc/kbd.c +++ b/pc/kbd.c @@ -295,19 +295,23 @@ mouseres(int res) } } +static int shift; + /* * mouse message is three bytes * * byte 0 - 0 0 SDY SDX 1 M R L * byte 1 - DX * byte 2 - DY + * + * shift & left button is the same as middle button */ static void mymouseputc(int c) { static short msg[3]; static int nb; - static uchar b[] = {0, 1, 4, 5, 2, 3, 6, 7}; + static uchar b[] = {0, 1, 4, 5, 2, 3, 6, 7, 0, 1, 2, 5, 2, 3, 6, 7 }; static lastdx, lastdy; extern Mouseinfo mouse; @@ -325,7 +329,7 @@ mymouseputc(int c) if(msg[0] & 0x20) msg[2] |= 0xFF00; - mousebuttons = b[msg[0]&7]; + mousebuttons = b[(msg[0]&7) | (shift ? 8 : 0)]; mouse.newbuttons = mousebuttons | keybuttons; mouse.dx = msg[1]; mouse.dy = -msg[2]; @@ -369,7 +373,6 @@ kbdintr0(void) { int s, c, i, nk; static int esc1, esc2; - static int shift; static int caps; static int ctl; static int num; diff --git a/pc/main.c b/pc/main.c index b40a2b2293dffcf87552ba1e09fac5ff77734aa3..9ce724601c1269c76bf1cf550d7c5c32a7df8862 100644 --- a/pc/main.c +++ b/pc/main.c @@ -6,6 +6,7 @@ #include "io.h" #include "ureg.h" #include "init.h" +#include /* configuration parameters */ enum @@ -21,6 +22,7 @@ enum }; int pmutype; int resettype; +char machtype[9]; uchar *sp; /* stack pointer for /boot */ @@ -62,11 +64,19 @@ void ident(void) { char *id = (char*)(ROMBIOS + 0xFF40); + int i; - if(strncmp(id, "AT&TNSX", 7) == 0){ + for(i = 0; i < 8; i++){ + if(isprint(id[i]) == 0) + break; + machtype[i] = id[i]; + } + if(i == 0) + strcpy(machtype, "generic"); + if(strcmp(machtype, "AT&TNSX") == 0){ pmutype = PMUnsx20; resettype = Resetheadland; - }else if(strncmp(id, "NCRD.0", 6) == 0){ + }else if(strcmp(machtype, "NCRD.0") == 0){ resettype = Reset8042; } } @@ -87,6 +97,8 @@ ulong garbage; void init0(void) { + char tstr[32]; + u->nerrlab = 0; m->proc = u->p; u->p->state = Running; @@ -105,7 +117,9 @@ init0(void) chandevinit(); if(!waserror()){ - ksetpcinfo(); + strcpy(tstr, machtype); + strcat(tstr, " %s"); + ksetterm(tstr); ksetenv("cputype", "386"); poperror(); } diff --git a/pc/trap.c b/pc/trap.c index a284c2c730e2f6df12581259ab1c806d30d93910..3265c37c1bf4f2c5ac30449e0eb9d122915b68c9 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -235,7 +235,8 @@ trap(Ureg *ur) panic("%s pc=0x%lux", excname[v], ur->pc); } } - panic("bad trap type %d pc=0x%lux\n", v, ur->pc); + print("bad trap type %d pc=0x%lux\n", v, ur->pc); + return; } (*ivec[v])(ur);