From d80a9f49d702541c241535b5e592f26f725693c0 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 10 Nov 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-11-10 --- port/devproc.c | 267 +++++++++++++++++++++++++++++++++++-------------- port/fault.c | 7 +- port/pgrp.c | 8 +- port/portdat.h | 9 +- port/proc.c | 83 ++++++++------- port/sysproc.c | 16 +-- power/boot.h | 264 +++++++++++++++++++++++++----------------------- power/clock.c | 3 +- power/dat.h | 5 +- power/fns.h | 1 + power/main.c | 1 + power/trap.c | 42 ++++---- 12 files changed, 436 insertions(+), 270 deletions(-) diff --git a/port/devproc.c b/port/devproc.c index 3e2063fbe5784eb2e8857c0cf6f891415f17ca29..f71bb4a1d74cbba46130f132ad6c4f306ac409b5 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -5,6 +5,7 @@ #include "fns.h" #include "errno.h" #include "fcall.h" +#include "ureg.h" #include "devtab.h" @@ -51,7 +52,10 @@ char *sname[]={ "Text", "Data", "Bss", "Stack", "Shared", "Phys" }; void procctlreq(Proc*, char*, int); int procctlmemio(Proc*, ulong, int, void*, int); -Chan *procctlnotepg(Chan*, void *va, int n); +Chan *procctlnotepg(Chan*, void*, int); +Chan *proctext(Chan*, Proc*); +Segment *txt2data(Proc*, Segment*); +int procstopped(void*); int procgen(Chan *c, Dirtab *tab, int ntab, int s, Dir *dp) @@ -145,35 +149,20 @@ procopen(Chan *c, int omode) p = proctab(SLOT(c->qid)); pg = p->pgrp; if(p->pid != PID(c->qid)) - Died: error(Eprocdied); + omode = openmode(omode); switch(QID(c->qid)){ case Qtext: - s = p->seg[TSEG]; - if(s==0 || p->state==Dead || s->image==0) - goto Died; - - tc = s->image->c; - if(tc == 0) - goto Died; - - if(incref(tc) == 0){ - Close: - close(tc); - goto Died; - } - if(!(tc->flag&COPEN) || tc->mode!=OREAD) - goto Close; - - if(p->pid != PID(c->qid)) - goto Close; - + tc = proctext(c, p); tc->offset = 0; + return tc; + case Qctl: case Qnote: + case Qmem: case Qsegment: break; @@ -185,7 +174,6 @@ procopen(Chan *c, int omode) break; case Qdir: - case Qmem: case Qproc: case Qstatus: if(omode != OREAD) @@ -195,9 +183,8 @@ procopen(Chan *c, int omode) pprint("unknown qid in devopen\n"); error(Egreg); } - /* - * Affix pid to qid - */ + + /* Affix pid to qid */ if(p->state != Dead) c->qid.vers = p->pid; done: @@ -264,12 +251,6 @@ procread(Chan *c, void *va, long n, ulong offset) switch(QID(c->qid)){ case Qmem: - /* - * One page at a time - */ - if(((offset+n)&~(BY2PG-1)) != (offset&~(BY2PG-1))) - n = BY2PG - (offset&(BY2PG-1)); - if(offset >= USERADDR && offset < USERADDR+BY2PG) { if(offset+n > USERADDR+BY2PG) n = USERADDR+BY2PG - offset; @@ -283,18 +264,19 @@ procread(Chan *c, void *va, long n, ulong offset) return n; } - if(offset >= KZERO && offset < KZERO+conf.npage0*BY2PG){ - if(offset+n > KZERO+conf.npage0*BY2PG) - n = KZERO+conf.npage0*BY2PG - offset; - memmove(a, (char*)offset, n); - return n; - } - - if(offset >= KZERO && offset < KZERO+conf.base1+conf.npage1*BY2PG){ - if(offset+n > KZERO+conf.base1+conf.npage1*BY2PG) - n = KZERO+conf.base1+conf.npage1*BY2PG - offset; - memmove(a, (char*)offset, n); - return n; + if(offset >= KZERO) { + if(offset < KZERO+conf.npage0*BY2PG){ + if(offset+n > KZERO+conf.npage0*BY2PG) + n = KZERO+conf.npage0*BY2PG - offset; + memmove(a, (char*)offset, n); + return n; + } + if(offset < KZERO+conf.base1+conf.npage1*BY2PG){ + if(offset+n > KZERO+conf.base1+conf.npage1*BY2PG) + n = KZERO+conf.base1+conf.npage1*BY2PG - offset; + memmove(a, (char*)offset, n); + return n; + } } return procctlmemio(p, offset, n, va, 1); @@ -353,6 +335,7 @@ procread(Chan *c, void *va, long n, ulong offset) } memmove(a, statbuf+offset, n); return n; + case Qsegment: j = 0; for(i = 0; i < NSEG; i++) @@ -378,6 +361,10 @@ procwrite(Chan *c, void *va, long n, ulong offset) User *up; KMap *k; char buf[ERRLEN]; + Ureg *ur; + User *pxu; + Page *pg; + char *a = va, *b; if(c->qid.path & CHDIR) error(Eisdir); @@ -400,10 +387,32 @@ procwrite(Chan *c, void *va, long n, ulong offset) switch(QID(c->qid)){ case Qmem: - return procctlmemio(p, offset, n, va, 0); + if(p->state != Stopped) + errors("not stopped"); + + if(offset >= USERADDR && offset < USERADDR+BY2PG) { + pg = p->upage; + if(pg==0 || p->pid!=PID(c->qid)) + error(Eprocdied); + k = kmap(pg); + b = (char*)VA(k); + pxu = (User*)b; + if(offset < (ulong)pxu->dbgreg || offset+n >= (ulong)pxu->dbgreg+sizeof(Ureg)) { + kunmap(k); + errors("bad u-area address"); + } + ur = (Ureg*)(b+((ulong)pxu->dbgreg-USERADDR)); + setregisters(ur, (char*)pxu+(offset-USERADDR), a, n); + kunmap(k); + } + else + n = procctlmemio(p, offset, n, va, 0); + break; + case Qctl: procctlreq(p, va, n); - return n; + break; + case Qnote: k = kmap(p->upage); up = (User*)VA(k); @@ -422,6 +431,7 @@ procwrite(Chan *c, void *va, long n, ulong offset) if(!postnote(p, 0, buf, NUser)) error(Enonote); break; + default: pprint("unknown qid in procwrite\n"); error(Egreg); @@ -431,6 +441,49 @@ procwrite(Chan *c, void *va, long n, ulong offset) return n; } +Chan * +proctext(Chan *c, Proc *p) +{ + Chan *tc; + Image *i; + Segment *s; + + s = p->seg[TSEG]; + if(s==0 || p->state==Dead) + error(Eprocdied); + + lock(s); + i = s->image; + if(i == 0) { + unlock(s); + error(Eprocdied); + } + unlock(s); + + lock(i); + if(waserror()) { + unlock(i); + nexterror(); + } + + tc = i->c; + if(tc == 0) + error(Eprocdied); + + if(incref(tc) == 1 || (tc->flag&COPEN) == 0 || tc->mode!=OREAD) { + close(tc); + error(Eprocdied); + } + + if(p->pid != PID(c->qid)) + error(Eprocdied); + + unlock(i); + poperror(); + + return tc; +} + Chan * procctlnotepg(Chan *c, void *va, int n) { @@ -451,6 +504,34 @@ procctlnotepg(Chan *c, void *va, int n) qunlock(&pg->debug); } +void +procstopwait(Proc *p, int ctl) +{ + int pid; + + if(p->pdbg) + errors("debugged already"); + if(procstopped(p)) + return; + + if(ctl != 0) + p->procctl = ctl; + p->pdbg = u->p; + pid = p->pid; + unlock(&p->debug); + u->p->psstate = "Stopwait"; + if(waserror()) { + p->pdbg = 0; + lock(&p->debug); + nexterror(); + } + sleep(&u->p->sleep, procstopped, p); + poperror(); + lock(&p->debug); + if(p->pid != pid) + error(Eprocdied); +} + void procctlreq(Proc *p, char *va, int n) { @@ -461,7 +542,7 @@ procctlreq(Proc *p, char *va, int n) return; } if(strncmp(va, "stop", 4) == 0) { - p->procctl = Proc_stopme; + procstopwait(p, Proc_stopme); return; } if(strncmp(va, "kill", 4) == 0) { @@ -469,57 +550,62 @@ procctlreq(Proc *p, char *va, int n) p->procctl = Proc_exitme; return; } + if(strncmp(va, "hang", 4) == 0) { + p->hang = 1; + return; + } } + if(n >= 8 && strncmp(va, "waitstop", 8) == 0) { + procstopwait(p, 0); + return; + } + + if(n >= 9 && strncmp(va, "startstop", 9) == 0) { + if(p->state != Stopped) + errors("not stopped"); + p->procctl = Proc_traceme; + ready(p); + procstopwait(p, Proc_traceme); + return; + } if(n >= 5 && strncmp(va, "start", 5) == 0) { if(p->state != Stopped) errors("not stopped"); ready(p); return; } + error(Ebadctl); } +int +procstopped(void *a) +{ + Proc *p = a; + return p->state == Stopped; +} + int procctlmemio(Proc *p, ulong offset, int n, void *va, int read) { Pte **pte; Page *pg; KMap *k; - Segment *ps, *s; + Segment *s; ulong soff; - int i; char *a = va, *b; +Again: s = seg(p, offset, 1); if(s == 0) errors("not in address space"); - /* Revert a text segment to data */ - if(read == 0 && (s->type&SG_TYPE) == SG_TEXT) { - ps = newseg(SG_DATA, s->base, s->size); - ps->image = s->image; - incref(ps->image); - ps->fstart = s->fstart; - ps->flen = s->flen; + if(offset+n >= s->top) + n = s->top-offset; - for(i = 0; i < NSEG; i++) - if(p->seg[i] == s) - break; - if(p->seg[i] != s) - panic("segment gone"); - - qunlock(&s->lk); - putseg(s); - p->seg[i] = ps; - } - else - qunlock(&s->lk); - -Again: - s = seg(p, offset, 1); - if(s == 0) - errors("not in address space"); + if(read == 0 && (s->type&SG_TYPE) == SG_TEXT) + s = txt2data(p, s); s->steal++; soff = offset-s->base; @@ -557,10 +643,45 @@ Again: k = kmap(pg); b = (char*)VA(k); - memmove(a, b+(offset&(BY2PG-1)), n); + if(read == 1) + memmove(a, b+(offset&(BY2PG-1)), n); + else + memmove(b+(offset&(BY2PG-1)), a, n); + kunmap(k); s->steal--; qunlock(&s->lk); + + if(read == 0) + p->newtlb = 1; + return n; } + +Segment * +txt2data(Proc *p, Segment *s) +{ + Segment *ps; + int i; + + ps = newseg(SG_DATA, s->base, s->size); + ps->image = s->image; + incref(ps->image); + ps->fstart = s->fstart; + ps->flen = s->flen; + ps->flushme = 1; + + for(i = 0; i < NSEG; i++) + if(p->seg[i] == s) + break; + if(p->seg[i] != s) + panic("segment gone"); + + qunlock(&s->lk); + putseg(s); + qlock(&ps->lk); + p->seg[i] = ps; + + return ps; +} diff --git a/port/fault.c b/port/fault.c index 5a2c0e1ced1542e3f7785160c37d49360eeae39d..66fb795cb637ff15358108be5a734b9b77af135c 100644 --- a/port/fault.c +++ b/port/fault.c @@ -123,6 +123,9 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu) panic("fault"); } + if(s->flushme) + memset((*pg)->cachectl, PG_TXTFLUSH, sizeof(new->cachectl)); + qunlock(&s->lk); /* @@ -201,8 +204,6 @@ pio(Segment *s, ulong addr, ulong soff, Page **p) new->daddr = daddr; cachepage(new, s->image); *p = new; - if(s->flushme) - memset(new->cachectl, PG_TXTFLUSH, sizeof(new->cachectl)); } else putpage(new); @@ -234,8 +235,6 @@ pio(Segment *s, ulong addr, ulong soff, Page **p) cachepage(new, &swapimage); putswap(*p); *p = new; - if(s->flushme) - memset(new->cachectl, PG_TXTFLUSH, sizeof(new->cachectl)); } else putpage(new); diff --git a/port/pgrp.c b/port/pgrp.c index 323341ffeba80adeeee5b4b659401b47b1292079..7848df9628fb873a012f121628a5e348e907da2e 100644 --- a/port/pgrp.c +++ b/port/pgrp.c @@ -185,13 +185,19 @@ dupfgrp(Fgrp *f) void resrcwait(char *reason) { - if(reason) + char *p; + + p = u->p->psstate; + if(reason) { + u->p->psstate = reason; print("%s\n", reason); + } if(u == 0) panic("resrcwait"); u->p->state = Wakeme; alarm(1000, wakeme, u->p); sched(); + u->p->psstate = p; } void diff --git a/port/portdat.h b/port/portdat.h index ea68fe29e7d73c24a07cff03a6e60e8772561129..62ed151826a07ca36771912ddb02df38e855a434 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -470,6 +470,7 @@ enum { Proc_stopme = 1, Proc_exitme = 2, + Proc_traceme = 3, }; /* @@ -518,18 +519,20 @@ struct Proc int fpstate; Lock debug; /* to access debugging elements of User */ + Proc *pdbg; /* the debugging process */ ulong procmode; /* proc device file mode */ + int hang; /* hang at next exec for debug */ + int procctl; /* Control for /proc debugging */ + ulong pc; /* DEBUG only */ Rendez *r; /* rendezvous point slept on */ - Rendez sleep; /* place for tsleep and syssleep */ + Rendez sleep; /* place for tsleep/syssleep/debug */ int notepending; /* note issued but not acted on */ - ulong pc; /* DEBUG only */ int kp; /* true if a kernel process */ Proc *palarm; /* Next alarm time */ ulong alarm; /* Time of call */ int hasspin; /* I hold a spin lock */ int newtlb; /* Pager has touched my tables so I must flush */ - int procctl; /* Control for /proc debugging */ ulong rendtag; /* Tag for rendezvous */ ulong rendval; /* Value for rendezvous */ diff --git a/port/proc.c b/port/proc.c index 202f87ed1967648b6ffba66ef275bd981eb58e24..f1901889a68c658b2db1822a4e9ae675aba1ee39 100644 --- a/port/proc.c +++ b/port/proc.c @@ -213,42 +213,37 @@ newproc(void) { Proc *p; -loop: - lock(&procalloc); - if(p = procalloc.free){ /* assign = */ - procalloc.free = p->qnext; - p->state = Scheding; - p->psstate = "New"; + for(;;) { + lock(&procalloc); + if(p = procalloc.free){ /* assign = */ + procalloc.free = p->qnext; + p->state = Scheding; + p->psstate = "New"; + unlock(&procalloc); + p->mach = 0; + p->qnext = 0; + p->nchild = 0; + p->nwait = 0; + p->waitq = 0; + p->pgrp = 0; + p->egrp = 0; + p->fgrp = 0; + p->pdbg = 0; + p->fpstate = FPinit; + p->kp = 0; + p->procctl = 0; + p->notepending = 0; + memset(p->seg, 0, sizeof p->seg); + lock(&pidalloc); + p->pid = ++pidalloc.pid; + unlock(&pidalloc); + if(p->pid == 0) + panic("pidalloc"); + return p; + } unlock(&procalloc); - p->mach = 0; - p->qnext = 0; - p->nchild = 0; - p->nwait = 0; - p->waitq = 0; - p->pgrp = 0; - p->egrp = 0; - p->fgrp = 0; - p->procmode = 0644; - p->fpstate = FPinit; - p->kp = 0; - p->procctl = 0; - p->notepending = 0; - memset(p->seg, 0, sizeof p->seg); - lock(&pidalloc); - p->pid = ++pidalloc.pid; - unlock(&pidalloc); - if(p->pid == 0) - panic("pidalloc"); - return p; + resrcwait("no procs"); } - unlock(&procalloc); - print("no procs\n"); - if(u == 0) - panic("newproc"); - u->p->state = Wakeme; - alarm(1000, wakeme, u->p); - sched(); - goto loop; } void @@ -584,8 +579,14 @@ pexit(char *exitstr, int freemem) /* * sched() cannot wait on these locks */ - lock(&procalloc); lock(&c->debug); + /* release debuggers */ + if(c->pdbg) { + wakeup(&c->pdbg->sleep); + c->pdbg = 0; + } + + lock(&procalloc); lock(&palloc); c->state = Moribund; @@ -740,11 +741,21 @@ procctl(Proc *p) switch(p->procctl) { case Proc_exitme: pexit("Killed", 1); + case Proc_traceme: + if(u->nnote == 0) + return; + /* No break */ case Proc_stopme: p->procctl = 0; state = p->psstate; p->psstate = "Stopped"; - + /* free a waiting debugger */ + lock(&p->debug); + if(p->pdbg) { + wakeup(&p->pdbg->sleep); + p->pdbg = 0; + } + unlock(&p->debug); p->state = Stopped; sched(); p->psstate = state; diff --git a/port/sysproc.c b/port/sysproc.c index 6d6e3493f3790259acb5d78cfebddde67d56c3a8..fad7c920a960ee74bbdd73694b6194efe94d3f92 100644 --- a/port/sysproc.c +++ b/port/sysproc.c @@ -53,10 +53,8 @@ rfork(ulong flag) k = kmap(p->upage); upa = VA(k); - /* - * Save time: only copy u-> data and useful stack - */ - clearmmucache(); /* so child doesn't inherit any of your mappings */ + /* Save time: only copy u-> data and useful stack */ + clearmmucache(); memmove((void*)upa, u, sizeof(User)); n = USERADDR+BY2PG - (ulong)&lastvar; n = (n+32) & ~(BY2WD-1); /* be safe & word align */ @@ -69,9 +67,7 @@ rfork(ulong flag) if(u->p->seg[i]) p->seg[i] = dupseg(u->p->seg[i]); - /* - * Refs - */ + /* Refs */ incref(u->dot); /* File descriptors etc. */ if(flag & Forkfd) @@ -99,6 +95,9 @@ rfork(ulong flag) incref(p->egrp); } + p->hang = u->p->hang; + p->procmode = u->p->procmode; + /* * Sched */ @@ -355,6 +354,9 @@ sysexec(ulong *arg) u->notified = 0; procsetup(p); unlock(&p->debug); + if(p->hang) + p->procctl = Proc_stopme; + return (USTKTOP-BY2WD); /* address of user-level clock */ } diff --git a/power/boot.h b/power/boot.h index 1b4ef0547b88506fee4a338cfbec539b5f8c74df..dc7ed4637de17d0c6c74e018257b38a9b8865180 100644 --- a/power/boot.h +++ b/power/boot.h @@ -1,6 +1,6 @@ ulong bootcode[]={ 0x000000407, - 0x000005bf0, + 0x000005c38, 0x000000710, 0x000001390, 0x000000000, @@ -1480,7 +1480,7 @@ ulong bootcode[]={ 0x014400008, 0x000000027, 0x0afa50004, - 0x00c001855, + 0x00c001867, 0x0afa00008, 0x08fa20000, 0x000000027, @@ -1492,7 +1492,7 @@ ulong bootcode[]={ 0x000000027, 0x000042600, 0x000042603, - 0x00c001855, + 0x00c001867, 0x0afa40008, 0x010200004, 0x000000027, @@ -1591,7 +1591,7 @@ ulong bootcode[]={ 0x08fa20010, 0x000000027, 0x0afa20004, - 0x00c001855, + 0x00c001867, 0x0afa00008, 0x08fa30010, 0x08fa20000, @@ -1675,7 +1675,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x02003001c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x08fa3001c, @@ -1685,7 +1685,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x02003001c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x08fa3001c, @@ -1695,7 +1695,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x02003001c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa5001c, 0x08fa20010, @@ -1890,7 +1890,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x020020040, - 0x00c00199d, + 0x00c0019af, 0x0afa2000c, 0x08fa30010, 0x008000b4f, @@ -1921,7 +1921,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x02003001c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x08fa3001c, @@ -1931,7 +1931,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x02003001c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x08fa3001c, @@ -1941,7 +1941,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x02003001c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x008000b4f, @@ -2028,7 +2028,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x02003001c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x008000b4f, @@ -2126,7 +2126,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x02003001c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa6001c, 0x08fa20010, @@ -2481,7 +2481,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x020020074, - 0x00c00199d, + 0x00c0019af, 0x0afa2000c, 0x08fa30010, 0x008000b4f, @@ -2499,7 +2499,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x020030074, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x008000b4f, @@ -2525,7 +2525,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x02002001c, - 0x00c00199d, + 0x00c0019af, 0x0afa2000c, 0x08fa30010, 0x008000b4f, @@ -2556,7 +2556,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x02002001e, - 0x00c00199d, + 0x00c0019af, 0x0afa2000c, 0x08fa30010, 0x008000b4f, @@ -2574,7 +2574,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x02003001c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x08fa3001c, @@ -2584,7 +2584,7 @@ ulong bootcode[]={ 0x0afa50010, 0x0afa50008, 0x020030024, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x008000b4f, @@ -2651,7 +2651,7 @@ ulong bootcode[]={ 0x024a30008, 0x0afa30008, 0x020020040, - 0x00c00199d, + 0x00c0019af, 0x0afa2000c, 0x08fa30010, 0x08fa2001c, @@ -2688,7 +2688,7 @@ ulong bootcode[]={ 0x024a20008, 0x0afa20008, 0x02003001c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x02003001c, @@ -2699,7 +2699,7 @@ ulong bootcode[]={ 0x000000027, 0x024420024, 0x0afa20008, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x02003001c, @@ -2710,7 +2710,7 @@ ulong bootcode[]={ 0x000000027, 0x024420040, 0x0afa20008, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x000000027, @@ -2816,7 +2816,7 @@ ulong bootcode[]={ 0x024a2000e, 0x0afa20008, 0x02003001c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x000000027, @@ -2942,7 +2942,7 @@ ulong bootcode[]={ 0x024a2000e, 0x0afa20008, 0x02003001c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa70018, 0x08fa20010, @@ -3179,7 +3179,7 @@ ulong bootcode[]={ 0x000000027, 0x0afa20008, 0x08ca3000c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20018, 0x08fa30010, @@ -3216,7 +3216,7 @@ ulong bootcode[]={ 0x000000027, 0x0afa20008, 0x08ca3000c, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20018, 0x08fa30010, @@ -3414,7 +3414,7 @@ ulong bootcode[]={ 0x024a30008, 0x0afa30008, 0x020020074, - 0x00c00199d, + 0x00c0019af, 0x0afa2000c, 0x08fa30010, 0x08fa2001c, @@ -3438,7 +3438,7 @@ ulong bootcode[]={ 0x024a20008, 0x0afa20008, 0x020030074, - 0x00c00199d, + 0x00c0019af, 0x0afa3000c, 0x08fa20010, 0x000000027, @@ -3473,7 +3473,7 @@ ulong bootcode[]={ 0x024a3000e, 0x0afa30008, 0x02002001c, - 0x00c00199d, + 0x00c0019af, 0x0afa2000c, 0x08fa30010, 0x08fa2001c, @@ -3510,7 +3510,7 @@ ulong bootcode[]={ 0x024a30024, 0x0afa30008, 0x02002001e, - 0x00c00199d, + 0x00c0019af, 0x0afa2000c, 0x08fa30010, 0x08fa2001c, @@ -3534,7 +3534,7 @@ ulong bootcode[]={ 0x024a30008, 0x0afa30008, 0x02002001c, - 0x00c00199d, + 0x00c0019af, 0x0afa2000c, 0x08fa30010, 0x020020024, @@ -3545,7 +3545,7 @@ ulong bootcode[]={ 0x000000027, 0x024630024, 0x0afa30008, - 0x00c00199d, + 0x00c0019af, 0x0afa2000c, 0x08fa30010, 0x08fa2001c, @@ -3565,14 +3565,14 @@ ulong bootcode[]={ 0x0afa20004, 0x0afa00008, 0x0200300a0, - 0x00c001908, + 0x00c00191a, 0x0afa3000c, 0x023c68112, 0x020050001, 0x000051880, 0x000661821, 0x03c040000, - 0x0348454ec, + 0x034845534, 0x0ac640000, 0x0a3c597b9, 0x0a3c597bb, @@ -3594,7 +3594,7 @@ ulong bootcode[]={ 0x000051880, 0x000661821, 0x03c040000, - 0x0348455d4, + 0x03484561c, 0x0ac640000, 0x0a3c597f3, 0x0a3c597f4, @@ -3605,21 +3605,21 @@ ulong bootcode[]={ 0x000051080, 0x000461021, 0x03c040000, - 0x034845418, + 0x034845460, 0x0ac440000, 0x0a3c597f1, 0x024a50001, 0x000051080, 0x000461021, 0x03c040000, - 0x03484546c, + 0x0348454b4, 0x0ac440000, 0x0a3c59801, 0x024a50001, 0x000051080, 0x000461021, 0x03c040000, - 0x0348454bc, + 0x034845504, 0x0ac440000, 0x0a3c597b3, 0x024a30001, @@ -3698,7 +3698,7 @@ ulong bootcode[]={ 0x0afa60044, 0x0afa60004, 0x023a40020, - 0x00c001a41, + 0x00c001a53, 0x0afa40008, 0x08fa30020, 0x000012825, @@ -3740,7 +3740,7 @@ ulong bootcode[]={ 0x08fc3805e, 0x000000027, 0x0afa30004, - 0x00c001a0b, + 0x00c001a1d, 0x0afa50008, 0x08fa60044, 0x008001267, @@ -3761,7 +3761,7 @@ ulong bootcode[]={ 0x000000027, 0x0afa60004, 0x023a40020, - 0x00c001a41, + 0x00c001a53, 0x0afa40008, 0x08fa30020, 0x000012825, @@ -4167,17 +4167,17 @@ ulong bootcode[]={ 0x034e70020, 0x023bdffe8, 0x0afbf0000, - 0x08fcc80e2, - 0x08fab0020, - 0x08fca80de, + 0x08fac0020, + 0x08fcb80de, + 0x08fca80e2, 0x08fa90024, 0x08fa8001c, 0x08fc7805e, 0x0afa00014, 0x02003fc18, - 0x011630003, + 0x011830003, 0x000002825, - 0x00561005d, + 0x00581006f, 0x000000027, 0x081020000, 0x000000027, @@ -4186,15 +4186,15 @@ ulong bootcode[]={ 0x0304600ff, 0x02002007f, 0x00046202a, - 0x010800051, + 0x010800063, 0x000000027, 0x0afa80004, 0x023a4000c, - 0x00c001a41, + 0x00c001a53, 0x0afa40008, - 0x08fcc80e2, - 0x08fab0020, - 0x08fca80de, + 0x08fac0020, + 0x08fcb80de, + 0x08fca80e2, 0x08fa90024, 0x08fc7805e, 0x08fa50014, @@ -4207,19 +4207,19 @@ ulong bootcode[]={ 0x014c0001a, 0x000000027, 0x02003fc18, - 0x011630003, + 0x011830003, 0x000000027, - 0x005600005, + 0x005800005, 0x000000027, 0x08fa20000, 0x000000027, 0x000400008, 0x023bd0018, - 0x0000b3023, + 0x0000c3023, 0x000a6202a, 0x01080fff9, 0x000000027, - 0x000ea202b, + 0x000eb202b, 0x010800006, 0x000000027, 0x000071025, @@ -4227,10 +4227,10 @@ ulong bootcode[]={ 0x0afc7805e, 0x020040020, 0x0a0440000, - 0x0258c0001, + 0x0254a0001, 0x024a50001, 0x008001479, - 0x0afcc80e2, + 0x0afca80e2, 0x024a50001, 0x02002fc18, 0x011220005, @@ -4239,31 +4239,49 @@ ulong bootcode[]={ 0x000000027, 0x008001454, 0x000000027, - 0x000ea202b, + 0x000eb202b, 0x010800009, 0x000000027, 0x02003007f, 0x00066202a, - 0x01480000b, + 0x01480001b, 0x000000027, 0x000071025, 0x024e70001, 0x0afc7805e, 0x0a0460000, 0x02002fc18, - 0x01122ffb7, + 0x011220003, 0x000000027, 0x02529ffff, - 0x008001454, 0x0afa90024, + 0x020030009, + 0x010c3000a, + 0x000000027, + 0x02003000a, + 0x010c30004, + 0x000000027, + 0x0254a0001, + 0x008001454, + 0x0afca80e2, + 0x0afc080e2, + 0x008001454, + 0x000005025, + 0x025430008, + 0x0201cfff8, + 0x0007c5024, + 0x008001454, + 0x0afca80e2, 0x0afa70004, - 0x00c001a0b, + 0x0afa60010, + 0x00c001a1d, 0x0afa60008, - 0x08fcc80e2, - 0x08fab0020, - 0x08fca80de, + 0x08fac0020, + 0x08fcb80de, + 0x08fca80e2, 0x08fa90024, 0x08fa8001c, + 0x08fa60010, 0x08fa50014, 0x0afc1805e, 0x00800149b, @@ -4271,19 +4289,19 @@ ulong bootcode[]={ 0x025080001, 0x00800146d, 0x0afa8001c, - 0x00c001add, + 0x00c001aef, 0x0afa80004, - 0x08fcc80e2, - 0x08fab0020, - 0x08fca80de, + 0x08fac0020, + 0x08fcb80de, + 0x08fca80e2, 0x08fa90024, 0x08fa8001c, 0x08fc7805e, 0x000012825, - 0x000ab202a, - 0x01080ff99, + 0x000ac202a, + 0x01080ff87, 0x0afa50014, - 0x000ea202b, + 0x000eb202b, 0x010800006, 0x000000027, 0x000071025, @@ -4291,10 +4309,10 @@ ulong bootcode[]={ 0x0afc7805e, 0x020040020, 0x0a0440000, - 0x0258c0001, + 0x0254a0001, 0x024a50001, - 0x0080014b9, - 0x0afcc80e2, + 0x0080014cb, + 0x0afca80e2, 0x023bdffd8, 0x0afbf0000, 0x08fc2808e, @@ -4338,7 +4356,7 @@ ulong bootcode[]={ 0x000000027, 0x000052e00, 0x000052e03, - 0x0080014d7, + 0x0080014e9, 0x000000027, 0x023a20018, 0x0afa20004, @@ -4364,7 +4382,7 @@ ulong bootcode[]={ 0x08fa40020, 0x000000027, 0x08c840000, - 0x00c001a0b, + 0x00c001a1d, 0x0afa40008, 0x0a0200000, 0x023a20010, @@ -4479,7 +4497,7 @@ ulong bootcode[]={ 0x0e7a6004c, 0x0e7a70004, 0x0e7a60008, - 0x00c001944, + 0x00c001956, 0x000000027, 0x01020000e, 0x000000027, @@ -4501,7 +4519,7 @@ ulong bootcode[]={ 0x020030001, 0x0e7a10004, 0x0e7a00008, - 0x00c001974, + 0x00c001986, 0x0afa3000c, 0x01020000e, 0x000000027, @@ -4523,7 +4541,7 @@ ulong bootcode[]={ 0x02003ffff, 0x0e7a10004, 0x0e7a00008, - 0x00c001974, + 0x00c001986, 0x0afa3000c, 0x08fad00b4, 0x08fac00ac, @@ -4581,7 +4599,7 @@ ulong bootcode[]={ 0x023a20034, 0x0e7a10004, 0x0e7a00008, - 0x00c001881, + 0x00c001893, 0x0afa2000c, 0x08fa20034, 0x04444f800, @@ -4605,7 +4623,7 @@ ulong bootcode[]={ 0x000023043, 0x0afa60030, 0x000061023, - 0x00c00182c, + 0x00c00183e, 0x0afa20004, 0x0c7a30048, 0x0c7a2004c, @@ -4617,7 +4635,7 @@ ulong bootcode[]={ 0x08fa30034, 0x000000027, 0x000431023, - 0x00c00182c, + 0x00c00183e, 0x0afa20004, 0x08fad00b4, 0x023ae0078, @@ -4640,7 +4658,7 @@ ulong bootcode[]={ 0x08fa30034, 0x000000027, 0x000431023, - 0x00c00182c, + 0x00c00183e, 0x0afa20004, 0x08fad00b4, 0x08fac00ac, @@ -4649,7 +4667,7 @@ ulong bootcode[]={ 0x0c7a2003c, 0x000000027, 0x046201182, - 0x008001615, + 0x008001627, 0x023ae0078, 0x0c7c180e6, 0x0c7c080ea, @@ -4666,7 +4684,7 @@ ulong bootcode[]={ 0x08fa30034, 0x000000027, 0x000431023, - 0x00c00182c, + 0x00c00183e, 0x0afa20004, 0x08fad00b4, 0x08fac00ac, @@ -4675,7 +4693,7 @@ ulong bootcode[]={ 0x0c7a2003c, 0x000000027, 0x046201182, - 0x00800162c, + 0x00800163e, 0x023ae0078, 0x02003fc18, 0x015830002, @@ -4710,7 +4728,7 @@ ulong bootcode[]={ 0x0200cffff, 0x0afac00ac, 0x0200d0065, - 0x0080015d9, + 0x0080015eb, 0x0afad00b4, 0x0c7a70048, 0x0c7a6004c, @@ -4724,7 +4742,7 @@ ulong bootcode[]={ 0x08fa30034, 0x02002ffff, 0x000431023, - 0x00c00182c, + 0x00c00183e, 0x0afa20004, 0x08fad00b4, 0x023ae0078, @@ -4746,7 +4764,7 @@ ulong bootcode[]={ 0x000671823, 0x004600134, 0x0afa7002c, - 0x00c00182c, + 0x00c00183e, 0x0afa30004, 0x0c7a30040, 0x0c7a20044, @@ -4755,7 +4773,7 @@ ulong bootcode[]={ 0x046201083, 0x0e7a30004, 0x0e7a20008, - 0x00c0017ea, + 0x00c0017fc, 0x000000027, 0x08fad00b4, 0x023ae0078, @@ -4813,7 +4831,7 @@ ulong bootcode[]={ 0x024e70001, 0x02484fff6, 0x0a0440001, - 0x0080016bc, + 0x0080016ce, 0x024c6ffff, 0x010e00007, 0x0200b0001, @@ -4881,7 +4899,7 @@ ulong bootcode[]={ 0x020030030, 0x0a0430000, 0x024e7ffff, - 0x008001703, + 0x008001715, 0x024c60001, 0x019000013, 0x000000027, @@ -4901,7 +4919,7 @@ ulong bootcode[]={ 0x0256b0001, 0x0a0430000, 0x02508ffff, - 0x008001714, + 0x008001726, 0x024c60001, 0x08fa300b0, 0x000000027, @@ -4986,19 +5004,19 @@ ulong bootcode[]={ 0x000001810, 0x024630030, 0x0a0430000, - 0x00800173b, + 0x00800174d, 0x024c60001, 0x000061825, 0x001231021, 0x02003002b, 0x0a0430000, - 0x00800175c, + 0x00800176e, 0x024c60001, 0x000061025, 0x001221821, 0x020020065, 0x0a0620000, - 0x008001752, + 0x008001764, 0x024c60001, 0x020030067, 0x011a30006, @@ -5006,7 +5024,7 @@ ulong bootcode[]={ 0x020030068, 0x011a30003, 0x000000027, - 0x008001735, + 0x008001747, 0x000000027, 0x024c7ffff, 0x004e00006, @@ -5026,11 +5044,11 @@ ulong bootcode[]={ 0x000000027, 0x01107ff93, 0x000073025, - 0x008001735, + 0x008001747, 0x024c60001, - 0x00800179a, + 0x0080017ac, 0x02508ffff, - 0x008001792, + 0x0080017a4, 0x024e7ffff, 0x08fa30034, 0x02002ffff, @@ -5040,7 +5058,7 @@ ulong bootcode[]={ 0x000003825, 0x08fa30034, 0x0200d0068, - 0x0080016f0, + 0x008001702, 0x001835023, 0x08fa200b0, 0x000000027, @@ -5051,7 +5069,7 @@ ulong bootcode[]={ 0x001221821, 0x02002002b, 0x0a0620000, - 0x0080016e1, + 0x0080016f3, 0x024c60001, 0x0c7c180e6, 0x0c7c080ea, @@ -5061,7 +5079,7 @@ ulong bootcode[]={ 0x0e7a60044, 0x0e7a70004, 0x0e7a60008, - 0x00c0017ea, + 0x00c0017fc, 0x000000027, 0x08fad00b4, 0x023ae0078, @@ -5088,14 +5106,14 @@ ulong bootcode[]={ 0x046222181, 0x0e7a70040, 0x0e7a60044, - 0x0080016b3, + 0x0080016c5, 0x000000027, - 0x00800164f, + 0x008001661, 0x0258cffff, 0x020020001, 0x0afa20014, 0x025ad0020, - 0x0080015d9, + 0x0080015eb, 0x0afad00b4, 0x023bdffe8, 0x0afbf0000, @@ -5112,7 +5130,7 @@ ulong bootcode[]={ 0x04624c081, 0x0e7a30004, 0x0e7a20008, - 0x00c0018cf, + 0x00c0018e1, 0x0afa2000c, 0x04620c032, 0x000000027, @@ -5141,7 +5159,7 @@ ulong bootcode[]={ 0x023a2001c, 0x0e7a30004, 0x0e7a20008, - 0x00c0018cf, + 0x00c0018e1, 0x0afa2000c, 0x0c7a1001c, 0x0c7a00020, @@ -5157,7 +5175,7 @@ ulong bootcode[]={ 0x04624c081, 0x0e7a30004, 0x0e7a20008, - 0x00c0017ea, + 0x00c0017fc, 0x000000027, 0x08fa20000, 0x023bd000c, @@ -5170,7 +5188,7 @@ ulong bootcode[]={ 0x004810008, 0x000000027, 0x000041023, - 0x00c00182c, + 0x00c00183e, 0x0afa20004, 0x08fa20000, 0x023bd0014, @@ -5191,12 +5209,12 @@ ulong bootcode[]={ 0x000042843, 0x0afa50010, 0x000851823, - 0x00c00182c, + 0x00c00183e, 0x0afa30004, 0x0e7a10008, 0x0e7a0000c, 0x08fa20010, - 0x00c00182c, + 0x00c00183e, 0x0afa20004, 0x0c7a30008, 0x0c7a2000c, @@ -5381,7 +5399,7 @@ ulong bootcode[]={ 0x08fa4000c, 0x000000027, 0x000821024, - 0x0080018f0, + 0x008001902, 0x0afa2000c, 0x023bdfff0, 0x08fa3001c, @@ -5462,7 +5480,7 @@ ulong bootcode[]={ 0x000000825, 0x0e7a50004, 0x0e7a40008, - 0x00c001974, + 0x00c001986, 0x0afa0000c, 0x014200005, 0x000000027, @@ -5640,7 +5658,7 @@ ulong bootcode[]={ 0x000000027, 0x0a0c8ffff, 0x024c6ffff, - 0x008001a03, + 0x008001a15, 0x024e7ffff, 0x08fa50004, 0x08fa20008, @@ -5781,7 +5799,7 @@ ulong bootcode[]={ 0x020030083, 0x010430003, 0x000000027, - 0x008001a56, + 0x008001a68, 0x000000027, 0x080c30001, 0x000000027, @@ -5869,7 +5887,7 @@ ulong bootcode[]={ 0x0afa6001c, 0x0afa60004, 0x023a40014, - 0x00c001a41, + 0x00c001a53, 0x0afa40008, 0x08fa70010, 0x000012825, @@ -5882,7 +5900,7 @@ ulong bootcode[]={ 0x000400008, 0x000070825, 0x024e70001, - 0x008001ae2, + 0x008001af4, 0x0afa70010, 0x014a0fffc, 0x024c60001, @@ -5959,7 +5977,7 @@ ulong bootcode[]={ 0x000000000, 0x0001fffff, 0x07fffffff, - 0x000005320, + 0x000005368, 0x000000000, 0x000000000, 0x000000000, @@ -6343,8 +6361,6 @@ ulong bootcode[]={ 0x0632f7469, 0x06d650000, 0x000000000, - 0x00006320, - 0x0, - 0x00006320, + 0x00006368, 0x0, }; diff --git a/power/clock.c b/power/clock.c index e232c4920108fd78695c16cb9ae5c2154d4461f1..73df99bb986c9543db0c3aff73dd31c2cd8a31c6 100644 --- a/power/clock.c +++ b/power/clock.c @@ -111,8 +111,7 @@ clock(Ureg *ur) } if(ur->status & KUP){ (*(ulong*)(USTKTOP-BY2WD)) += TK2MS(1); /* profiling clock */ - if(u->nnote) - notify(ur); + notify(ur); } } return; diff --git a/power/dat.h b/power/dat.h index dc262948c53bb6141ebe7e8e30d61e4fde000970..8b0cca27cb0554ea132b0060863cb901248cc40c 100644 --- a/power/dat.h +++ b/power/dat.h @@ -216,7 +216,7 @@ struct User int nerrlab; Label errlab[NERR]; char error[ERRLEN]; - FPsave fpsave; /* address of this is known by vdb */ + FPsave fpsave; /* address of this is known by db */ char elem[NAMELEN]; /* last name element from namec */ Chan *slash; Chan *dot; @@ -229,7 +229,8 @@ struct User short notified; /* sysnoted is due */ Note lastnote; int (*notify)(void*, char*); - void *ureg; + void *ureg; /* User registers for notes */ + void *dbgreg; /* User registers for debugging in proc */ ulong svstatus; /* * machine dependent User stuff diff --git a/power/fns.h b/power/fns.h index 6d9749bc80ad53ec1061839ea2be0fe4ef483d11..089383b90be81f838509e53284feafe7b4007b3c 100644 --- a/power/fns.h +++ b/power/fns.h @@ -55,6 +55,7 @@ int readlog(ulong, char*, ulong); void restfpregs(FPsave*, ulong); #define screenputs void setvmevec(int, void (*)(int)); +void setregisters(Ureg*, char*, char*, int); void sinit(void); uchar* smap(int, uchar*); void sunmap(int, uchar*); diff --git a/power/main.c b/power/main.c index ba3f6744e78b6a594e01ef944cea8ad5dc53f64b..42ef900da4f9cca1bd0e86574e9da6397d05fa23 100644 --- a/power/main.c +++ b/power/main.c @@ -253,6 +253,7 @@ userinit(void) p->pgrp = newpgrp(); p->egrp = newegrp(); p->fgrp = newfgrp(); + p->procmode = 0644; strcpy(p->text, "*init*"); strcpy(p->user, eve); diff --git a/power/trap.c b/power/trap.c index e32394fe0003957eebfa37b2e54e33055f509519..37c0b6334e8045e0bdc6267ce9817e2ba049e645 100644 --- a/power/trap.c +++ b/power/trap.c @@ -82,9 +82,10 @@ trap(Ureg *ur) SET(x); ecode = EXCCODE(ur->cause); user = ur->status&KUP; - if(u) + if(u) { u->p->pc = ur->pc; /* BUG */ - + u->dbgreg = ur; + } switch(ecode){ case CINT: if(u && u->p->state==Running){ @@ -165,12 +166,8 @@ trap(Ureg *ur) } } - if(user) { - if(u->p->procctl) - procctl(u->p); - if(u->nnote) - notify(ur); - } + if(user) + notify(ur); splhi(); if(user && u && u->p->fpstate == FPinactive) { @@ -372,11 +369,11 @@ notify(Ureg *ur) { ulong sp; - lock(&u->p->debug); - if(u->nnote==0){ - unlock(&u->p->debug); + if(u->p->procctl) + procctl(u->p); + if(u->nnote == 0) return; - } + lock(&u->p->debug); u->p->notepending = 0; if(u->note[0].flag!=NUser && (u->notified || u->notify==0)){ if(u->note[0].flag == NDebug) @@ -484,6 +481,7 @@ syscall(Ureg *aur) u->p->insyscall = 1; ur = aur; u->p->pc = ur->pc; /* BUG */ + u->dbgreg = aur; ur->cause = 15<<2; /* for debugging: system call is undef 15; /* * since the system call interface does not @@ -497,9 +495,6 @@ syscall(Ureg *aur) } spllo(); - if(u->p->procctl) - procctl(u->p); - r1 = ur->r1; sp = ur->sp; u->nerrlab = 0; @@ -528,15 +523,13 @@ syscall(Ureg *aur) } ur->pc += 4; u->nerrlab = 0; - if(u->p->procctl) - procctl(u->p); splhi(); u->p->psstate = 0; u->p->insyscall = 0; if(r1 == NOTED) /* ugly hack */ noted(&aur, *(ulong*)(sp+BY2WD)); /* doesn't return */ - if(u->nnote && r1!=FORK){ + if(u->p->procctl || (u->nnote && r1!=FORK)){ ur->r1 = ret; notify(ur); } @@ -572,3 +565,16 @@ setvmevec(int v, void (*f)(int)) print("second setvmevec to 0x%.2x\n", v); vmevec[v] = f; } + +/* This routine must save the values of registers the user is not permitted to write from devproc + * and the restore them before returning + */ +void +setregisters(Ureg *xp, char *pureg, char *uva, int n) +{ + ulong status; + + status = xp->status; + memmove(pureg, uva, n); + xp->status = status; +}