|
@@ -39,25 +39,25 @@ typedef struct {
|
|
void
|
|
void
|
|
noted(Ureg* cur, uintptr_t arg0)
|
|
noted(Ureg* cur, uintptr_t arg0)
|
|
{
|
|
{
|
|
- Mach *m = machp();
|
|
|
|
|
|
+ Proc *up = machp()->externup;
|
|
NFrame *nf;
|
|
NFrame *nf;
|
|
Note note;
|
|
Note note;
|
|
Ureg *nur;
|
|
Ureg *nur;
|
|
|
|
|
|
- qlock(&m->externup->debug);
|
|
|
|
- if(arg0 != NRSTR && !m->externup->notified){
|
|
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ qlock(&up->debug);
|
|
|
|
+ if(arg0 != NRSTR && !up->notified){
|
|
|
|
+ qunlock(&up->debug);
|
|
pprint("suicide: call to noted when not notified\n");
|
|
pprint("suicide: call to noted when not notified\n");
|
|
pexit("Suicide", 0);
|
|
pexit("Suicide", 0);
|
|
}
|
|
}
|
|
- m->externup->notified = 0;
|
|
|
|
|
|
+ up->notified = 0;
|
|
fpunoted();
|
|
fpunoted();
|
|
|
|
|
|
- nf = m->externup->ureg;
|
|
|
|
|
|
+ nf = up->ureg;
|
|
|
|
|
|
/* sanity clause */
|
|
/* sanity clause */
|
|
if(!okaddr(PTR2UINT(nf), sizeof(NFrame), 0)){
|
|
if(!okaddr(PTR2UINT(nf), sizeof(NFrame), 0)){
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ qunlock(&up->debug);
|
|
pprint("suicide: bad ureg %#p in noted\n", nf);
|
|
pprint("suicide: bad ureg %#p in noted\n", nf);
|
|
pexit("Suicide", 0);
|
|
pexit("Suicide", 0);
|
|
}
|
|
}
|
|
@@ -67,7 +67,7 @@ noted(Ureg* cur, uintptr_t arg0)
|
|
*/
|
|
*/
|
|
nur = &nf->ureg;
|
|
nur = &nf->ureg;
|
|
if(nur->cs != SSEL(SiUCS, SsRPL3) || nur->ss != SSEL(SiUDS, SsRPL3)) {
|
|
if(nur->cs != SSEL(SiUCS, SsRPL3) || nur->ss != SSEL(SiUDS, SsRPL3)) {
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ qunlock(&up->debug);
|
|
pprint("suicide: bad segment selector in noted\n");
|
|
pprint("suicide: bad segment selector in noted\n");
|
|
pexit("Suicide", 0);
|
|
pexit("Suicide", 0);
|
|
}
|
|
}
|
|
@@ -82,22 +82,22 @@ noted(Ureg* cur, uintptr_t arg0)
|
|
case NCONT:
|
|
case NCONT:
|
|
case NRSTR:
|
|
case NRSTR:
|
|
if(!okaddr(nur->ip, BY2SE, 0) || !okaddr(nur->sp, BY2SE, 0)){
|
|
if(!okaddr(nur->ip, BY2SE, 0) || !okaddr(nur->sp, BY2SE, 0)){
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ qunlock(&up->debug);
|
|
pprint("suicide: trap in noted pc=%#p sp=%#p\n",
|
|
pprint("suicide: trap in noted pc=%#p sp=%#p\n",
|
|
nur->ip, nur->sp);
|
|
nur->ip, nur->sp);
|
|
pexit("Suicide", 0);
|
|
pexit("Suicide", 0);
|
|
}
|
|
}
|
|
- m->externup->ureg = nf->old;
|
|
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ up->ureg = nf->old;
|
|
|
|
+ qunlock(&up->debug);
|
|
break;
|
|
break;
|
|
case NSAVE:
|
|
case NSAVE:
|
|
if(!okaddr(nur->ip, BY2SE, 0) || !okaddr(nur->sp, BY2SE, 0)){
|
|
if(!okaddr(nur->ip, BY2SE, 0) || !okaddr(nur->sp, BY2SE, 0)){
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ qunlock(&up->debug);
|
|
pprint("suicide: trap in noted pc=%#p sp=%#p\n",
|
|
pprint("suicide: trap in noted pc=%#p sp=%#p\n",
|
|
nur->ip, nur->sp);
|
|
nur->ip, nur->sp);
|
|
pexit("Suicide", 0);
|
|
pexit("Suicide", 0);
|
|
}
|
|
}
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ qunlock(&up->debug);
|
|
|
|
|
|
splhi();
|
|
splhi();
|
|
nf->arg1 = nf->msg;
|
|
nf->arg1 = nf->msg;
|
|
@@ -107,14 +107,14 @@ noted(Ureg* cur, uintptr_t arg0)
|
|
cur->sp = PTR2UINT(nf);
|
|
cur->sp = PTR2UINT(nf);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- memmove(¬e, &m->externup->lastnote, sizeof(Note));
|
|
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ memmove(¬e, &up->lastnote, sizeof(Note));
|
|
|
|
+ qunlock(&up->debug);
|
|
pprint("suicide: bad arg %#p in noted: %s\n", arg0, note.msg);
|
|
pprint("suicide: bad arg %#p in noted: %s\n", arg0, note.msg);
|
|
pexit(note.msg, 0);
|
|
pexit(note.msg, 0);
|
|
break;
|
|
break;
|
|
case NDFLT:
|
|
case NDFLT:
|
|
- memmove(¬e, &m->externup->lastnote, sizeof(Note));
|
|
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ memmove(¬e, &up->lastnote, sizeof(Note));
|
|
|
|
+ qunlock(&up->debug);
|
|
if(note.flag == NDebug)
|
|
if(note.flag == NDebug)
|
|
pprint("suicide: %s\n", note.msg);
|
|
pprint("suicide: %s\n", note.msg);
|
|
pexit(note.msg, note.flag != NDebug);
|
|
pexit(note.msg, note.flag != NDebug);
|
|
@@ -129,7 +129,7 @@ noted(Ureg* cur, uintptr_t arg0)
|
|
int
|
|
int
|
|
notify(Ureg* ureg)
|
|
notify(Ureg* ureg)
|
|
{
|
|
{
|
|
- Mach *m = machp();
|
|
|
|
|
|
+ Proc *up = machp()->externup;
|
|
int l;
|
|
int l;
|
|
Mpl pl;
|
|
Mpl pl;
|
|
Note note;
|
|
Note note;
|
|
@@ -139,18 +139,18 @@ notify(Ureg* ureg)
|
|
/*
|
|
/*
|
|
* Calls procctl splhi, see comment in procctl for the reasoning.
|
|
* Calls procctl splhi, see comment in procctl for the reasoning.
|
|
*/
|
|
*/
|
|
- if(m->externup->procctl)
|
|
|
|
- procctl(m->externup);
|
|
|
|
- if(m->externup->nnote == 0)
|
|
|
|
|
|
+ if(up->procctl)
|
|
|
|
+ procctl(up);
|
|
|
|
+ if(up->nnote == 0)
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
fpunotify(ureg);
|
|
fpunotify(ureg);
|
|
|
|
|
|
pl = spllo();
|
|
pl = spllo();
|
|
- qlock(&m->externup->debug);
|
|
|
|
|
|
+ qlock(&up->debug);
|
|
|
|
|
|
- m->externup->notepending = 0;
|
|
|
|
- memmove(¬e, &m->externup->note[0], sizeof(Note));
|
|
|
|
|
|
+ up->notepending = 0;
|
|
|
|
+ memmove(¬e, &up->note[0], sizeof(Note));
|
|
if(strncmp(note.msg, "sys:", 4) == 0){
|
|
if(strncmp(note.msg, "sys:", 4) == 0){
|
|
l = strlen(note.msg);
|
|
l = strlen(note.msg);
|
|
if(l > ERRMAX-sizeof(" pc=0x0123456789abcdef"))
|
|
if(l > ERRMAX-sizeof(" pc=0x0123456789abcdef"))
|
|
@@ -158,41 +158,41 @@ notify(Ureg* ureg)
|
|
sprint(note.msg+l, " pc=%#p", ureg->ip);
|
|
sprint(note.msg+l, " pc=%#p", ureg->ip);
|
|
}
|
|
}
|
|
|
|
|
|
- if(note.flag != NUser && (m->externup->notified || m->externup->notify == nil)){
|
|
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ if(note.flag != NUser && (up->notified || up->notify == nil)){
|
|
|
|
+ qunlock(&up->debug);
|
|
if(note.flag == NDebug)
|
|
if(note.flag == NDebug)
|
|
pprint("suicide: %s\n", note.msg);
|
|
pprint("suicide: %s\n", note.msg);
|
|
pexit(note.msg, note.flag != NDebug);
|
|
pexit(note.msg, note.flag != NDebug);
|
|
}
|
|
}
|
|
|
|
|
|
- if(m->externup->notified){
|
|
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ if(up->notified){
|
|
|
|
+ qunlock(&up->debug);
|
|
splhi();
|
|
splhi();
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
- if(m->externup->notify == nil){
|
|
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ if(up->notify == nil){
|
|
|
|
+ qunlock(&up->debug);
|
|
pexit(note.msg, note.flag != NDebug);
|
|
pexit(note.msg, note.flag != NDebug);
|
|
}
|
|
}
|
|
- if(!okaddr(PTR2UINT(m->externup->notify), sizeof(ureg->ip), 0)){
|
|
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ if(!okaddr(PTR2UINT(up->notify), sizeof(ureg->ip), 0)){
|
|
|
|
+ qunlock(&up->debug);
|
|
pprint("suicide: bad function address %#p in notify\n",
|
|
pprint("suicide: bad function address %#p in notify\n",
|
|
- m->externup->notify);
|
|
|
|
|
|
+ up->notify);
|
|
pexit("Suicide", 0);
|
|
pexit("Suicide", 0);
|
|
}
|
|
}
|
|
|
|
|
|
sp = ureg->sp - sizeof(NFrame);
|
|
sp = ureg->sp - sizeof(NFrame);
|
|
if(!okaddr(sp, sizeof(NFrame), 1)){
|
|
if(!okaddr(sp, sizeof(NFrame), 1)){
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ qunlock(&up->debug);
|
|
pprint("suicide: bad stack address %#p in notify\n", sp);
|
|
pprint("suicide: bad stack address %#p in notify\n", sp);
|
|
pexit("Suicide", 0);
|
|
pexit("Suicide", 0);
|
|
}
|
|
}
|
|
|
|
|
|
nf = UINT2PTR(sp);
|
|
nf = UINT2PTR(sp);
|
|
memmove(&nf->ureg, ureg, sizeof(Ureg));
|
|
memmove(&nf->ureg, ureg, sizeof(Ureg));
|
|
- nf->old = m->externup->ureg;
|
|
|
|
- m->externup->ureg = nf; /* actually the NFrame, for noted */
|
|
|
|
|
|
+ nf->old = up->ureg;
|
|
|
|
+ up->ureg = nf; /* actually the NFrame, for noted */
|
|
memmove(nf->msg, note.msg, ERRMAX);
|
|
memmove(nf->msg, note.msg, ERRMAX);
|
|
nf->arg1 = nf->msg;
|
|
nf->arg1 = nf->msg;
|
|
nf->arg0 = &nf->ureg;
|
|
nf->arg0 = &nf->ureg;
|
|
@@ -203,13 +203,13 @@ notify(Ureg* ureg)
|
|
nf->ip = 0;
|
|
nf->ip = 0;
|
|
|
|
|
|
ureg->sp = sp;
|
|
ureg->sp = sp;
|
|
- ureg->ip = PTR2UINT(m->externup->notify);
|
|
|
|
- m->externup->notified = 1;
|
|
|
|
- m->externup->nnote--;
|
|
|
|
- memmove(&m->externup->lastnote, ¬e, sizeof(Note));
|
|
|
|
- memmove(&m->externup->note[0], &m->externup->note[1], m->externup->nnote*sizeof(Note));
|
|
|
|
|
|
+ ureg->ip = PTR2UINT(up->notify);
|
|
|
|
+ up->notified = 1;
|
|
|
|
+ up->nnote--;
|
|
|
|
+ memmove(&up->lastnote, ¬e, sizeof(Note));
|
|
|
|
+ memmove(&up->note[0], &up->note[1], up->nnote*sizeof(Note));
|
|
|
|
|
|
- qunlock(&m->externup->debug);
|
|
|
|
|
|
+ qunlock(&up->debug);
|
|
splx(pl);
|
|
splx(pl);
|
|
|
|
|
|
return 1;
|
|
return 1;
|
|
@@ -218,18 +218,18 @@ notify(Ureg* ureg)
|
|
void
|
|
void
|
|
noerrorsleft(void)
|
|
noerrorsleft(void)
|
|
{
|
|
{
|
|
- Mach *m = machp();
|
|
|
|
|
|
+ Proc *up = machp()->externup;
|
|
int i;
|
|
int i;
|
|
|
|
|
|
- if(m->externup->nerrlab){
|
|
|
|
|
|
+ if(up->nerrlab){
|
|
/* NIX processes will have a waserror in their handler */
|
|
/* NIX processes will have a waserror in their handler */
|
|
- if(m->externup->ac != nil && m->externup->nerrlab == 1)
|
|
|
|
|
|
+ if(up->ac != nil && up->nerrlab == 1)
|
|
return;
|
|
return;
|
|
|
|
|
|
- print("bad errstack: %d extra\n", m->externup->nerrlab);
|
|
|
|
|
|
+ print("bad errstack: %d extra\n", up->nerrlab);
|
|
for(i = 0; i < NERR; i++)
|
|
for(i = 0; i < NERR; i++)
|
|
print("sp=%#p pc=%#p\n",
|
|
print("sp=%#p pc=%#p\n",
|
|
- m->externup->errlab[i].sp, m->externup->errlab[i].pc);
|
|
|
|
|
|
+ up->errlab[i].sp, up->errlab[i].pc);
|
|
panic("error stack");
|
|
panic("error stack");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -239,7 +239,7 @@ void
|
|
syscall(int badscallnr, Ureg *ureg)
|
|
syscall(int badscallnr, Ureg *ureg)
|
|
{
|
|
{
|
|
// can only handle 4 args right now.
|
|
// can only handle 4 args right now.
|
|
- uintptr_t a0, a1, a2, a3;
|
|
|
|
|
|
+ uintptr_t a0, a1, a2, a3;
|
|
uintptr_t a4, a5 = 0;
|
|
uintptr_t a4, a5 = 0;
|
|
|
|
|
|
a0 = ureg->di;
|
|
a0 = ureg->di;
|
|
@@ -247,7 +247,7 @@ syscall(int badscallnr, Ureg *ureg)
|
|
a2 = ureg->dx;
|
|
a2 = ureg->dx;
|
|
a3 = ureg->r10;
|
|
a3 = ureg->r10;
|
|
a4 = ureg->r8;
|
|
a4 = ureg->r8;
|
|
- Mach *m = machp();
|
|
|
|
|
|
+ Proc *up = machp()->externup;
|
|
unsigned int scallnr = (unsigned int) badscallnr;
|
|
unsigned int scallnr = (unsigned int) badscallnr;
|
|
if (0) iprint("Syscall %d, %lx, %lx, %lx %lx %lx\n", scallnr, a0, a1, a2, a3, a4);
|
|
if (0) iprint("Syscall %d, %lx, %lx, %lx %lx %lx\n", scallnr, a0, a1, a2, a3, a4);
|
|
char *e;
|
|
char *e;
|
|
@@ -266,27 +266,27 @@ syscall(int badscallnr, Ureg *ureg)
|
|
if(!userureg(ureg))
|
|
if(!userureg(ureg))
|
|
panic("syscall: cs %#llux\n", ureg->cs);
|
|
panic("syscall: cs %#llux\n", ureg->cs);
|
|
|
|
|
|
- cycles(&m->externup->kentry);
|
|
|
|
|
|
+ cycles(&up->kentry);
|
|
|
|
|
|
m->syscall++;
|
|
m->syscall++;
|
|
- m->externup->nsyscall++;
|
|
|
|
- m->externup->nqsyscall++;
|
|
|
|
- m->externup->insyscall = 1;
|
|
|
|
- m->externup->pc = ureg->ip;
|
|
|
|
- m->externup->dbgreg = ureg;
|
|
|
|
|
|
+ up->nsyscall++;
|
|
|
|
+ up->nqsyscall++;
|
|
|
|
+ up->insyscall = 1;
|
|
|
|
+ up->pc = ureg->ip;
|
|
|
|
+ up->dbgreg = ureg;
|
|
sp = ureg->sp;
|
|
sp = ureg->sp;
|
|
startns = 0;
|
|
startns = 0;
|
|
if (0) hi("so far syscall!\n");
|
|
if (0) hi("so far syscall!\n");
|
|
if (printallsyscalls) {
|
|
if (printallsyscalls) {
|
|
syscallfmt(scallnr, a0, a1, a2, a3, a4, a5);
|
|
syscallfmt(scallnr, a0, a1, a2, a3, a4, a5);
|
|
- if(m->externup->syscalltrace) {
|
|
|
|
- if(1) iprint("E %s\n", m->externup->syscalltrace);
|
|
|
|
- free(m->externup->syscalltrace);
|
|
|
|
- m->externup->syscalltrace = nil;
|
|
|
|
|
|
+ if(up->syscalltrace) {
|
|
|
|
+ if(1) iprint("E %s\n", up->syscalltrace);
|
|
|
|
+ free(up->syscalltrace);
|
|
|
|
+ up->syscalltrace = nil;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if(m->externup->procctl == Proc_tracesyscall){
|
|
|
|
|
|
+ if(up->procctl == Proc_tracesyscall){
|
|
/*
|
|
/*
|
|
* Redundant validaddr. Do we care?
|
|
* Redundant validaddr. Do we care?
|
|
* Tracing syscalls is not exactly a fast path...
|
|
* Tracing syscalls is not exactly a fast path...
|
|
@@ -294,39 +294,39 @@ syscall(int badscallnr, Ureg *ureg)
|
|
* than an error if there's a problem; that might
|
|
* than an error if there's a problem; that might
|
|
* change in the future.
|
|
* change in the future.
|
|
*/
|
|
*/
|
|
- if(sp < (USTKTOP-BIGPGSZ) || sp > (USTKTOP-sizeof(m->externup->arg)-BY2SE))
|
|
|
|
- validaddr(UINT2PTR(sp), sizeof(m->externup->arg)+BY2SE, 0);
|
|
|
|
|
|
+ if(sp < (USTKTOP-BIGPGSZ) || sp > (USTKTOP-sizeof(up->arg)-BY2SE))
|
|
|
|
+ validaddr(UINT2PTR(sp), sizeof(up->arg)+BY2SE, 0);
|
|
|
|
|
|
syscallfmt(scallnr, a0, a1, a2, a3, a4, a5);
|
|
syscallfmt(scallnr, a0, a1, a2, a3, a4, a5);
|
|
- m->externup->procctl = Proc_stopme;
|
|
|
|
- procctl(m->externup);
|
|
|
|
- if(m->externup->syscalltrace)
|
|
|
|
- free(m->externup->syscalltrace);
|
|
|
|
- m->externup->syscalltrace = nil;
|
|
|
|
|
|
+ up->procctl = Proc_stopme;
|
|
|
|
+ procctl(up);
|
|
|
|
+ if(up->syscalltrace)
|
|
|
|
+ free(up->syscalltrace);
|
|
|
|
+ up->syscalltrace = nil;
|
|
startns = todget(nil);
|
|
startns = todget(nil);
|
|
}
|
|
}
|
|
if (0) hi("more syscall!\n");
|
|
if (0) hi("more syscall!\n");
|
|
- m->externup->scallnr = scallnr;
|
|
|
|
|
|
+ up->scallnr = scallnr;
|
|
if(scallnr == RFORK)
|
|
if(scallnr == RFORK)
|
|
fpusysrfork(ureg);
|
|
fpusysrfork(ureg);
|
|
spllo();
|
|
spllo();
|
|
|
|
|
|
sp = ureg->sp;
|
|
sp = ureg->sp;
|
|
- m->externup->nerrlab = 0;
|
|
|
|
|
|
+ up->nerrlab = 0;
|
|
ar0 = zar0;
|
|
ar0 = zar0;
|
|
if(!waserror()){
|
|
if(!waserror()){
|
|
if(scallnr >= nsyscall || systab[scallnr].f == nil){
|
|
if(scallnr >= nsyscall || systab[scallnr].f == nil){
|
|
pprint("bad sys call number %d pc %#llux\n",
|
|
pprint("bad sys call number %d pc %#llux\n",
|
|
scallnr, ureg->ip);
|
|
scallnr, ureg->ip);
|
|
- postnote(m->externup, 1, "sys: bad sys call", NDebug);
|
|
|
|
|
|
+ postnote(up, 1, "sys: bad sys call", NDebug);
|
|
error(Ebadarg);
|
|
error(Ebadarg);
|
|
}
|
|
}
|
|
|
|
|
|
- if(sp < (USTKTOP-BIGPGSZ) || sp > (USTKTOP-sizeof(m->externup->arg)-BY2SE))
|
|
|
|
- validaddr(UINT2PTR(sp), sizeof(m->externup->arg)+BY2SE, 0);
|
|
|
|
|
|
+ if(sp < (USTKTOP-BIGPGSZ) || sp > (USTKTOP-sizeof(up->arg)-BY2SE))
|
|
|
|
+ validaddr(UINT2PTR(sp), sizeof(up->arg)+BY2SE, 0);
|
|
|
|
|
|
- memmove(m->externup->arg, UINT2PTR(sp+BY2SE), sizeof(m->externup->arg));
|
|
|
|
- m->externup->psstate = systab[scallnr].n;
|
|
|
|
|
|
+ memmove(up->arg, UINT2PTR(sp+BY2SE), sizeof(up->arg));
|
|
|
|
+ up->psstate = systab[scallnr].n;
|
|
if (0) hi("call syscall!\n");
|
|
if (0) hi("call syscall!\n");
|
|
systab[scallnr].f(&ar0, a0, a1, a2, a3, a4, a5);
|
|
systab[scallnr].f(&ar0, a0, a1, a2, a3, a4, a5);
|
|
if (0) hi("it returned!\n");
|
|
if (0) hi("it returned!\n");
|
|
@@ -339,7 +339,7 @@ syscall(int badscallnr, Ureg *ureg)
|
|
* already return from the system call, when dispatching
|
|
* already return from the system call, when dispatching
|
|
* the user code to the AC. The only thing left is to
|
|
* the user code to the AC. The only thing left is to
|
|
* return. The user registers should be ok, because
|
|
* return. The user registers should be ok, because
|
|
- * m->externup->dbgreg has been the user context for the process.
|
|
|
|
|
|
+ * up->dbgreg has been the user context for the process.
|
|
*/
|
|
*/
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -347,12 +347,12 @@ syscall(int badscallnr, Ureg *ureg)
|
|
}
|
|
}
|
|
else{
|
|
else{
|
|
/* failure: save the error buffer for errstr */
|
|
/* failure: save the error buffer for errstr */
|
|
- e = m->externup->syserrstr;
|
|
|
|
- m->externup->syserrstr = m->externup->errstr;
|
|
|
|
- m->externup->errstr = e;
|
|
|
|
- if(DBGFLG && m->externup->pid == 1)
|
|
|
|
|
|
+ e = up->syserrstr;
|
|
|
|
+ up->syserrstr = up->errstr;
|
|
|
|
+ up->errstr = e;
|
|
|
|
+ if(DBGFLG && up->pid == 1)
|
|
iprint("%s: syscall %s error %s\n",
|
|
iprint("%s: syscall %s error %s\n",
|
|
- m->externup->text, systab[scallnr].n, m->externup->syserrstr);
|
|
|
|
|
|
+ up->text, systab[scallnr].n, up->syserrstr);
|
|
ar0 = systab[scallnr].r;
|
|
ar0 = systab[scallnr].r;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -372,40 +372,40 @@ syscall(int badscallnr, Ureg *ureg)
|
|
if (printallsyscalls) {
|
|
if (printallsyscalls) {
|
|
stopns = todget(nil);
|
|
stopns = todget(nil);
|
|
sysretfmt(scallnr, &ar0, startns, stopns, a0, a1, a2, a3, a4, a5);
|
|
sysretfmt(scallnr, &ar0, startns, stopns, a0, a1, a2, a3, a4, a5);
|
|
- if(m->externup->syscalltrace) {
|
|
|
|
- if (1) iprint("X %s\n", m->externup->syscalltrace);
|
|
|
|
- free(m->externup->syscalltrace);
|
|
|
|
- m->externup->syscalltrace = nil;
|
|
|
|
|
|
+ if(up->syscalltrace) {
|
|
|
|
+ if (1) iprint("X %s\n", up->syscalltrace);
|
|
|
|
+ free(up->syscalltrace);
|
|
|
|
+ up->syscalltrace = nil;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if(m->externup->procctl == Proc_tracesyscall){
|
|
|
|
|
|
+ if(up->procctl == Proc_tracesyscall){
|
|
stopns = todget(nil);
|
|
stopns = todget(nil);
|
|
- m->externup->procctl = Proc_stopme;
|
|
|
|
|
|
+ up->procctl = Proc_stopme;
|
|
sysretfmt(scallnr, &ar0, startns, stopns, a0, a1, a2, a3, a4, a5);
|
|
sysretfmt(scallnr, &ar0, startns, stopns, a0, a1, a2, a3, a4, a5);
|
|
s = splhi();
|
|
s = splhi();
|
|
- procctl(m->externup);
|
|
|
|
|
|
+ procctl(up);
|
|
splx(s);
|
|
splx(s);
|
|
- if(m->externup->syscalltrace)
|
|
|
|
- free(m->externup->syscalltrace);
|
|
|
|
- m->externup->syscalltrace = nil;
|
|
|
|
- }else if(m->externup->procctl == Proc_totc || m->externup->procctl == Proc_toac)
|
|
|
|
- procctl(m->externup);
|
|
|
|
|
|
+ if(up->syscalltrace)
|
|
|
|
+ free(up->syscalltrace);
|
|
|
|
+ up->syscalltrace = nil;
|
|
|
|
+ }else if(up->procctl == Proc_totc || up->procctl == Proc_toac)
|
|
|
|
+ procctl(up);
|
|
|
|
|
|
if (0) hi("past sysretfmt\n");
|
|
if (0) hi("past sysretfmt\n");
|
|
- m->externup->insyscall = 0;
|
|
|
|
- m->externup->psstate = 0;
|
|
|
|
|
|
+ up->insyscall = 0;
|
|
|
|
+ up->psstate = 0;
|
|
|
|
|
|
if(scallnr == NOTED)
|
|
if(scallnr == NOTED)
|
|
noted(ureg, a0);
|
|
noted(ureg, a0);
|
|
|
|
|
|
if (0) hi("now to splihi\n");
|
|
if (0) hi("now to splihi\n");
|
|
splhi();
|
|
splhi();
|
|
- if(scallnr != RFORK && (m->externup->procctl || m->externup->nnote))
|
|
|
|
|
|
+ if(scallnr != RFORK && (up->procctl || up->nnote))
|
|
notify(ureg);
|
|
notify(ureg);
|
|
|
|
|
|
/* if we delayed sched because we held a lock, sched now */
|
|
/* if we delayed sched because we held a lock, sched now */
|
|
- if(m->externup->delaysched){
|
|
|
|
|
|
+ if(up->delaysched){
|
|
sched();
|
|
sched();
|
|
splhi();
|
|
splhi();
|
|
}
|
|
}
|
|
@@ -436,13 +436,13 @@ sysexecstack(uintptr_t stack, int argc)
|
|
void*
|
|
void*
|
|
sysexecregs(uintptr_t entry, uint32_t ssize, void *argv, uint32_t nargs, void *tos)
|
|
sysexecregs(uintptr_t entry, uint32_t ssize, void *argv, uint32_t nargs, void *tos)
|
|
{
|
|
{
|
|
- Mach *m = machp();
|
|
|
|
|
|
+ Proc *up = machp()->externup;
|
|
uintptr_t *sp;
|
|
uintptr_t *sp;
|
|
Ureg *ureg;
|
|
Ureg *ureg;
|
|
|
|
|
|
sp = (uintptr_t*)(USTKTOP - ssize);
|
|
sp = (uintptr_t*)(USTKTOP - ssize);
|
|
|
|
|
|
- ureg = m->externup->dbgreg;
|
|
|
|
|
|
+ ureg = up->dbgreg;
|
|
ureg->sp = PTR2UINT(sp);
|
|
ureg->sp = PTR2UINT(sp);
|
|
ureg->ip = entry;
|
|
ureg->ip = entry;
|
|
ureg->type = 64; /* fiction for acid */
|
|
ureg->type = 64; /* fiction for acid */
|
|
@@ -467,7 +467,7 @@ void
|
|
sysrforkchild(Proc* child, Proc* parent)
|
|
sysrforkchild(Proc* child, Proc* parent)
|
|
{
|
|
{
|
|
Ureg *cureg;
|
|
Ureg *cureg;
|
|
-// If STACKPAD is 1 things go very bad very quickly.
|
|
|
|
|
|
+// If STACKPAD is 1 things go very bad very quickly.
|
|
// But it is the right value ...
|
|
// But it is the right value ...
|
|
#define STACKPAD 1 /* for return PC? */
|
|
#define STACKPAD 1 /* for return PC? */
|
|
/*
|
|
/*
|