From d18618540d38152d46ec6f5553080e0081fd0bda Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 3 Feb 1995 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1995-02-03 --- boot/boot.c | 19 ++------------ boot/local.c | 38 +++++++++++++++++++--------- carrera/trap.c | 3 +-- pc/devvga.c | 9 ------- pc/main.c | 1 - pc/trap.c | 5 ++-- pc/vgaclgd542x.c | 29 ++++++++++++++++++++++ pc/vgaet4000.c | 2 +- pc/vgas3.c | 2 +- port/sysproc.c | 1 + power/conf.h | 22 ----------------- power/dat.h | 3 +-- power/mem.h | 4 +++ power/trap.c | 64 +++++++++++++++++++++++++++++++++++++++--------- 14 files changed, 120 insertions(+), 82 deletions(-) create mode 100644 pc/vgaclgd542x.c delete mode 100644 power/conf.h diff --git a/boot/boot.c b/boot/boot.c index 505c00c5da7b8a39f698207e550e4f1e405bdbb0..c2377223bedaa81250d412c99846b26161d9abb9 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -19,8 +19,6 @@ int mflag; int fflag; int kflag; int aflag; -int nflag; -int pflag; int afd = -1; char *bargv[Nbarg]; @@ -53,9 +51,6 @@ boot(int argc, char *argv[]) print("\n"); #endif DEBUG - if(argc <= 1) - pflag = 1; - ARGBEGIN{ case 'a': aflag = 1; @@ -66,16 +61,9 @@ boot(int argc, char *argv[]) case 'k': kflag = 1; break; - case 'n': - nflag = 1; - break; case 'm': - pflag = 1; mflag = 1; break; - case 'p': - pflag = 1; - break; case 'f': fflag = 1; break; @@ -129,8 +117,6 @@ boot(int argc, char *argv[]) if(mount(fd, "/", MAFTER|MCREATE, "") < 0) fatal("mount"); close(fd); - if(cpuflag == 0 && nflag == 0) - newkernel(); /* * if a local file server exists and it's not @@ -215,9 +201,8 @@ rootserver(char *arg) strcpy(reply, method->name); /* parse replies */ - for(notfirst = 0;; notfirst = 1){ - if(pflag || notfirst) - outin(prompt, reply, sizeof(reply)); + for(;;){ + outin(prompt, reply, sizeof(reply)); mp = findmethod(reply); if(mp){ for(cp = reply; bargc < Nbarg-1 && *cp;){ diff --git a/boot/local.c b/boot/local.c index 54ede9d73ae21a15a8e6dab863a8cb43520000e5..79cc7480948953f52cb0d1f26c6ff8d3df62923f 100644 --- a/boot/local.c +++ b/boot/local.c @@ -4,7 +4,6 @@ static char diskname[2*NAMELEN]; static char *disk; -static char *niob; void configlocal(Method *mp) @@ -12,20 +11,39 @@ configlocal(Method *mp) char *p; int n; - disk = mp->arg; /* 1st try from config file */ - if(disk && (niob = strchr(disk, ' '))) /* assign = */ - *niob++ = 0; - if(strncmp(argv0, "dksc(0,", 7) == 0){ + if(*sys == '/' || *sys == '#'){ + /* + * if the user specifies the disk in the boot cmd or + * 'root is from' prompt, use it + */ + disk = sys; + } else if(strncmp(argv0, "dksc(0,", 7) == 0){ + /* + * on many mips arg0 of the boot command specifies the + * scsi logical unit number + */ p = strchr(argv0, ','); n = strtoul(p+1, 0, 10); sprint(diskname, "#w%d/sd%dfs", n, n); disk = diskname; - /*print("argv0=\"%s\" --> disk = \"%s\"\n", argv0, disk);/**/ + } else if(mp->arg){ + /* + * a default is supplied when the kernel is made + */ + disk = mp->arg; + } else if(*bootdisk){ + /* + * an environment variable from a pc's plan9.ini or + * from the mips nvram or generated by the kernel + * is the last resort. + */ + disk = bootdisk; } - if(*sys == '/' || *sys == '#') - disk = sys; + + /* if we've decided on one, pass it on to all programs */ if(disk) setenv("bootdisk", disk); + USED(mp); } @@ -72,10 +90,6 @@ connectlocal(void) close(p[1]); argp = args; *argp++ = "fs"; - if(niob){ - *argp++ = "-B"; - *argp++ = niob; - } *argp++ = "-f"; *argp++ = partition; *argp++ = "-s"; diff --git a/carrera/trap.c b/carrera/trap.c index 226c1c6b1f2a46cf16dcac8e42988f00b204ea8d..385444ff73bd96386674bbec4ea448fa99753d87 100644 --- a/carrera/trap.c +++ b/carrera/trap.c @@ -596,8 +596,7 @@ noted(Ureg *kur, Ureg **urp, ulong arg0) nur = up->ureg; oureg = (ulong)nur; - if(oureg>=USTKTOP || ouregdebug); diff --git a/pc/devvga.c b/pc/devvga.c index a2c6834efc4fdf23f5f7dbedf1d6f8d8fec854d7..de5f16f8a0e4420d4f22b787e1fe587f28e8200f 100644 --- a/pc/devvga.c +++ b/pc/devvga.c @@ -1051,21 +1051,12 @@ screenputs(char *s, int n) unlock(&screenlock); } -/* - * paging routines for different cards - */ static void nopage(int page) { USED(page); } -static void -cirruspage(int page) -{ - vgaxo(Grx, 0x09, page<<4); -} - /* * character mode console */ diff --git a/pc/main.c b/pc/main.c index 78fe48714de82cadc92273b1506f4b70db38f2d3..5f5fb208bf23cdb0ca346d13c11d71b2aab4c2d8 100644 --- a/pc/main.c +++ b/pc/main.c @@ -219,7 +219,6 @@ bootargs(ulong base) ac = 0; av[ac++] = pusharg("/386/9dos"); - av[ac++] = pusharg("-p"); cp[64] = 0; buf[0] = 0; if(strncmp(cp, "fd!", 3) == 0){ diff --git a/pc/trap.c b/pc/trap.c index 50ec39da903c4edee52e7c7110f30c66a8ff6ca1..03e28deaf062d3666f34a7dbf75867a5d1c6cd0f 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -523,7 +523,7 @@ notify(Ureg *ur) sp -= sizeof(Ureg); if(!okaddr((ulong)up->notify, 1, 0) - || !okaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN-3*BY2WD, 0)){ + || !okaddr(sp-ERRLEN-4*BY2WD, sizeof(Ureg)+ERRLEN+4*BY2WD, 1)){ pprint("suicide: bad address in notify\n"); qunlock(&up->debug); pexit("Suicide", 0); @@ -572,8 +572,7 @@ noted(Ureg *ur, ulong arg0) /* sanity clause */ oureg = (ulong)nur; - if(oureg>=USTKTOP || ouregdebug); pexit("Suicide", 0); diff --git a/pc/vgaclgd542x.c b/pc/vgaclgd542x.c new file mode 100644 index 0000000000000000000000000000000000000000..7c9f61fd792eda1302de3cf7b85630483aeebc04 --- /dev/null +++ b/pc/vgaclgd542x.c @@ -0,0 +1,29 @@ +#include "u.h" +#include "../port/lib.h" +#include "mem.h" +#include "dat.h" +#include "fns.h" +#include "../port/error.h" + +#include +#include "screen.h" +#include "vga.h" + +static void +clgd542xpage(int page) +{ + vgaxo(Grx, 0x09, page<<4); +} + +static Vgac clgd542x = { + "clgd542x", + clgd542xpage, + + 0, +}; + +void +vgaclgd542xlink(void) +{ + addvgaclink(&clgd542x); +} diff --git a/pc/vgaet4000.c b/pc/vgaet4000.c index 77dab93dac9eb8a634ab2a21b02a4056861f24ba..c149ce19fccc6e54aeb7c4d13c1a9a7e15c4c616 100644 --- a/pc/vgaet4000.c +++ b/pc/vgaet4000.c @@ -258,7 +258,7 @@ Hwgc et4000hwgc = { 0, }; -void +static void et4000page(int page) { if(hwgc == &et4000hwgc){ diff --git a/pc/vgas3.c b/pc/vgas3.c index 03e58d417c251b265825c4c59483a4c66492e160..5ab0880bc1b335a1212fcde5c589f3da00347bcd 100644 --- a/pc/vgas3.c +++ b/pc/vgas3.c @@ -231,7 +231,7 @@ Hwgc s3hwgc = { 0, }; -void +static void s3page(int page) { if(hwgc == &s3hwgc){ diff --git a/port/sysproc.c b/port/sysproc.c index 9ff311bb21eeeedda08506895f57aeec56a9c2b3..635958fca509bbb634466214a67025022e1dbf84 100644 --- a/port/sysproc.c +++ b/port/sysproc.c @@ -567,6 +567,7 @@ syssegbrk(ulong *arg) switch(s->type&SG_TYPE) { case SG_TEXT: case SG_DATA: + case SG_STACK: error(Ebadarg); default: return ibrk(arg[1], i); diff --git a/power/conf.h b/power/conf.h deleted file mode 100644 index 600b90f38dc532007e1611d291942bb1791cbe72..0000000000000000000000000000000000000000 --- a/power/conf.h +++ /dev/null @@ -1,22 +0,0 @@ -Conftab conftab[] = { - {"nmach", &conf.nmach }, - {"nproc", &conf.nproc }, - {"npage0", &conf.npage0 }, - {"npage1", &conf.npage1 }, - {"npage", &conf.npage }, - {"upages", &conf.upages }, - {"nimage", &conf.nimage }, - {"nswap", &conf.nswap }, - {"base0", &conf.base0 }, - {"base1", &conf.base1 }, - {"copymode", &conf.copymode }, - {"ipif", &conf.ipif }, - {"ip", &conf.ip }, - {"arp", &conf.arp }, - {"frag", &conf.frag }, - {"debugger", &conf.debugger }, - {"ialloc", &conf.ialloc }, - {"pipeqsize", &conf.pipeqsize }, - { 0, 0 }, -}; - diff --git a/power/dat.h b/power/dat.h index 5871dde70e696a25755be0bec8a181b2ba3461ab..88c11a2acef936894bceab4e90fd690204b821a5 100644 --- a/power/dat.h +++ b/power/dat.h @@ -84,8 +84,7 @@ struct PMMU */ struct Notsave { - ulong svstatus; - ulong svr1; + int UNUSED; }; #include "../port/portdat.h" diff --git a/power/mem.h b/power/mem.h index 1b5fab0f2eea33c36383c7ba245c703115f0b486..88795af90ea8ab89330ebf19adc0ebf0d3138060 100644 --- a/power/mem.h +++ b/power/mem.h @@ -50,6 +50,8 @@ #define KUC 0x00000002 #define IEP 0x00000004 #define KUP 0x00000008 +#define IEO 0x00000010 +#define KUO 0x00000020 #define INTMASK 0x0000ff00 #define SW0 0x00000100 #define SW1 0x00000200 @@ -61,6 +63,8 @@ #define INTR5 0x00008000 #define ISC 0x00010000 #define SWC 0x00020000 +#define CM 0x00080000 +#define PE 0x00100000 #define CU1 0x20000000 /* diff --git a/power/trap.c b/power/trap.c index 899492cb8a47e4180671349ee7f525377c1651c8..27a75d38b509c480afe436257499283e982ef833 100644 --- a/power/trap.c +++ b/power/trap.c @@ -8,7 +8,7 @@ #include "../port/error.h" void (*vmevec[256])(int); -void noted(Ureg**, ulong); +void noted(Ureg*, Ureg**, ulong); void rfnote(Ureg**); char *excname[] = @@ -398,23 +398,22 @@ notify(Ureg *ur) qunlock(&up->debug); pexit(n->msg, n->flag!=NDebug); } - up->svstatus = ur->status; sp = ur->usp - sizeof(Ureg); - if(sp&0x3 || !okaddr((ulong)up->notify, BY2WD, 0) - || !okaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN+3*BY2WD, 1)) { + if(sp&(BY2WD-1) || !okaddr((ulong)up->notify, BY2WD, 0) + || !okaddr(sp-ERRLEN-4*BY2WD, sizeof(Ureg)+ERRLEN+4*BY2WD, 1)) { pprint("suicide: bad address or sp in notify\n"); qunlock(&up->debug); pexit("Suicide", 0); } - up->ureg = (void*)sp; memmove((Ureg*)sp, ur, sizeof(Ureg)); - sp -= ERRLEN; + *(Ureg**)(sp-BY2WD) = up->ureg; /* word under Ureg is old up->ureg */ + up->ureg = (void*)sp; + sp -= BY2WD+ERRLEN; memmove((char*)sp, up->note[0].msg, ERRLEN); sp -= 3*BY2WD; *(ulong*)(sp+2*BY2WD) = sp+3*BY2WD; /* arg 2 is string */ - up->svr1 = ur->r1; /* save away r1 */ ur->r1 = (ulong)up->ureg; /* arg 1 is ureg* */ *(ulong*)(sp+1*BY2WD) = (ulong)up->ureg;/* arg 1 0(FP) is ureg* (for Alef) */ *(ulong*)(sp+0*BY2WD) = 0; /* arg 0 is pc */ @@ -430,16 +429,32 @@ notify(Ureg *ur) return 1; } +/* + * Check that status is OK to return from note. + */ +int +validstatus(ulong kstatus, ulong ustatus) +{ + if((kstatus & INTMASK) != (ustatus & INTMASK)) + return 0; + if((ustatus&(KUO|IEO|KUP|IEP|KUC|IE)) != (KUP|IEP)) + return 0; + if(ustatus & (0xFFFF0000&~(CU1|CM|PE))) /* no CU3, CU2, CU0, BEV, TS, PZ, SWC, ISC */ + return 0; + return 1; +} + /* * Return user to state before notify() */ void -noted(Ureg **urp, ulong arg0) +noted(Ureg *kur, Ureg **urp, ulong arg0) { Ureg *nur; + ulong oureg, sp; qlock(&up->debug); - if(!up->notified) { + if(arg0!=NRSTR && !up->notified) { qunlock(&up->debug); pprint("call to noted() when not notified\n"); pexit("Suicide", 0); @@ -447,16 +462,25 @@ noted(Ureg **urp, ulong arg0) up->notified = 0; nur = up->ureg; - if(nur->status != up->svstatus) { + + oureg = (ulong)nur; + if((oureg & (BY2WD-1)) + || !okaddr((ulong)oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){ + pprint("bad ureg in noted or call to noted() when not notified\n"); + qunlock(&up->debug); + pexit("Suicide", 0); + } + + if(!validstatus(kur->status, nur->status)) { qunlock(&up->debug); pprint("bad noted ureg status %lux\n", nur->status); pexit("Suicide", 0); } memmove(*urp, up->ureg, sizeof(Ureg)); - (*urp)->r1 = up->svr1; switch(arg0) { case NCONT: + case NRSTR: if(!okaddr(nur->pc, 1, 0) || !okaddr(nur->usp, BY2WD, 0)){ pprint("suicide: trap in noted\n"); qunlock(&up->debug); @@ -467,6 +491,22 @@ noted(Ureg **urp, ulong arg0) rfnote(urp); break; + case NSAVE: + if(!okaddr(nur->pc, BY2WD, 0) || !okaddr(nur->usp, BY2WD, 0)){ + pprint("suicide: trap in noted\n"); + qunlock(&up->debug); + pexit("Suicide", 0); + } + qunlock(&up->debug); + sp = oureg-4*BY2WD-ERRLEN; + splhi(); + (*urp)->sp = sp; + ((ulong*)sp)[1] = oureg; /* arg 1 0(FP) is ureg* */ + ((ulong*)sp)[0] = 0; /* arg 0 is pc */ + (*urp)->r1 = oureg; /* arg 1 is ureg* */ + rfnote(urp); + break; + default: pprint("unknown noted arg 0x%lux\n", arg0); up->lastnote.flag = NDebug; @@ -542,7 +582,7 @@ syscall(Ureg *aur) up->psstate = 0; up->insyscall = 0; if(up->scallnr == NOTED) /* ugly hack */ - noted(&aur, *(ulong*)(sp+BY2WD)); /* doesn't return */ + noted(ur, &aur, *(ulong*)(sp+BY2WD)); /* doesn't return */ splhi(); if(up->scallnr!=RFORK && (up->procctl || up->nnote)){