kernel: various cleanups

This commit is contained in:
cinap_lenrek 2014-01-20 02:16:42 +01:00
parent cb0393181a
commit ad1eefb355
9 changed files with 36 additions and 43 deletions

View file

@ -562,7 +562,7 @@ notify(Ureg *ur)
sp = ur->usp & ~(BY2V-1);
sp -= sizeof(Ureg);
if(!okaddr((ulong)up->notify, BY2WD, 0)
if(!okaddr((uintptr)up->notify, BY2WD, 0)
|| !okaddr(sp-ERRMAX-6*BY2WD, sizeof(Ureg)+ERRMAX-6*BY2WD, 1)) {
qunlock(&up->debug);
pprint("suicide: bad address or sp in notify\n");
@ -627,7 +627,7 @@ noted(Ureg *kur, Ureg **urp, ulong arg0)
oureg = (ulong)nur;
if((oureg & (BY2V-1))
|| !okaddr((ulong)oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
|| !okaddr(oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
qunlock(&up->debug);
pprint("bad ureg in noted or call to noted() when not notified\n");
pexit("Suicide", 0);

View file

@ -616,7 +616,7 @@ noted(Ureg* ureg, ulong arg0)
/* sanity clause */
oureg = (ulong)nureg;
if(!okaddr((ulong)oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
if(!okaddr(oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
qunlock(&up->debug);
pprint("bad ureg in noted or call to noted when not notified\n");
pexit("Suicide", 0);
@ -714,7 +714,7 @@ notify(Ureg* ureg)
sp = ureg->sp;
sp -= sizeof(Ureg);
if(!okaddr((ulong)up->notify, 1, 0)
if(!okaddr((uintptr)up->notify, 1, 0)
|| !okaddr(sp-ERRMAX-4*BY2WD, sizeof(Ureg)+ERRMAX+4*BY2WD, 1)){
qunlock(&up->debug);
pprint("suicide: bad address in notify\n");

View file

@ -648,7 +648,7 @@ casemu(ulong pc, ulong op, Ureg *ur)
rn = rp[op>>0 & 0x7];
rd = rp + (op>>12 & 0x7);
rp = (ulong*)*rd;
validaddr((ulong)rp, 4, 1);
validaddr((uintptr)rp, 4, 1);
splhi();
if(*rd = (*rp == ro))
*rp = rn;
@ -667,7 +667,7 @@ ldrex(ulong pc, ulong op, Ureg *ur)
rp = (ulong*)ur;
rd = rp + (op>>16 & 0x7);
addr = (ulong*)*rd;
validaddr((ulong)addr, 4, 0);
validaddr((uintptr)addr, 4, 0);
ldrexvalid = 1;
rp[op>>12 & 0x7] = *addr;
if(fpemudebug)
@ -686,7 +686,7 @@ strex(ulong pc, ulong op, Ureg *ur)
rd = rp + (op>>16 & 0x7);
rn = rp[op>>0 & 0x7];
addr = (ulong*)*rd;
validaddr((ulong)addr, 4, 1);
validaddr((uintptr)addr, 4, 1);
splhi();
if(ldrexvalid){
if(fpemudebug)

View file

@ -736,7 +736,7 @@ notify(Ureg* ur)
sp = ur->usp & ~(BY2V-1);
sp -= sizeof(Ureg);
if(!okaddr((ulong)up->notify, BY2WD, 0) ||
if(!okaddr((uintptr)up->notify, BY2WD, 0) ||
!okaddr(sp-ERRMAX-4*BY2WD, sizeof(Ureg)+ERRMAX+4*BY2WD, 1)) {
qunlock(&up->debug);
pprint("suicide: bad address or sp in notify\n");
@ -787,7 +787,7 @@ noted(Ureg* ureg, ulong arg0)
/* sanity clause */
oureg = (ulong)nureg;
if(!okaddr((ulong)oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
if(!okaddr(oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
qunlock(&up->debug);
pprint("bad ureg in noted or call to noted when not notified\n");
pexit("Suicide", 0);

View file

@ -648,7 +648,7 @@ casemu(ulong pc, ulong op, Ureg *ur)
rn = rp[op>>0 & 0x7];
rd = rp + (op>>12 & 0x7);
rp = (ulong*)*rd;
validaddr((ulong)rp, 4, 1);
validaddr((uintptr)rp, 4, 1);
splhi();
if(*rd = (*rp == ro))
*rp = rn;
@ -667,7 +667,7 @@ ldrex(ulong pc, ulong op, Ureg *ur)
rp = (ulong*)ur;
rd = rp + (op>>16 & 0x7);
addr = (ulong*)*rd;
validaddr((ulong)addr, 4, 0);
validaddr((uintptr)addr, 4, 0);
ldrexvalid = 1;
rp[op>>12 & 0x7] = *addr;
if(fpemudebug)
@ -686,7 +686,7 @@ strex(ulong pc, ulong op, Ureg *ur)
rd = rp + (op>>16 & 0x7);
rn = rp[op>>0 & 0x7];
addr = (ulong*)*rd;
validaddr((ulong)addr, 4, 1);
validaddr((uintptr)addr, 4, 1);
splhi();
if(ldrexvalid){
if(fpemudebug)

View file

@ -170,7 +170,7 @@ notify(Ureg *ureg)
}
sp = ureg->sp;
sp -= 256 + sizeof(Ureg);
if(!okaddr((ulong)up->notify, 1, 0)
if(!okaddr((uintptr)up->notify, 1, 0)
|| !okaddr(sp - ERRMAX - 4 * BY2WD, sizeof(Ureg) + ERRMAX + 4 * BY2WD, 1)){
qunlock(&up->debug);
pprint("suicide: bad address in notify\n");
@ -216,7 +216,7 @@ noted(Ureg *ureg, ulong arg0)
nureg = up->ureg;
oureg = (ulong) nureg;
if(!okaddr((ulong) oureg - BY2WD, BY2WD + sizeof(Ureg), 0)){
if(!okaddr(oureg - BY2WD, BY2WD + sizeof(Ureg), 0)){
qunlock(&up->debug);
pprint("bad ureg in noted or call to noted when not notified\n");
pexit("Suicide", 0);

View file

@ -867,7 +867,7 @@ notify(Ureg* ureg)
if(0) print("%s %lud: notify %.8lux %.8lux %.8lux %s\n",
up->text, up->pid, ureg->pc, ureg->usp, sp, n->msg);
if(!okaddr((ulong)up->notify, 1, 0)
if(!okaddr((uintptr)up->notify, 1, 0)
|| !okaddr(sp-ERRMAX-4*BY2WD, sizeof(Ureg)+ERRMAX+4*BY2WD, 1)){
qunlock(&up->debug);
pprint("suicide: bad address in notify\n");
@ -920,7 +920,7 @@ noted(Ureg* ureg, ulong arg0)
/* sanity clause */
oureg = (ulong)nureg;
if(!okaddr((ulong)oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
if(!okaddr(oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
qunlock(&up->debug);
pprint("bad ureg in noted or call to noted when not notified\n");
pexit("Suicide", 0);

View file

@ -221,7 +221,7 @@ sysrfork(va_list list)
procwired(p, wm->machno);
ready(p);
sched();
return (uintptr)pid;
return pid;
}
static ulong
@ -579,7 +579,7 @@ syssleep(va_list list)
uintptr
sysalarm(va_list list)
{
return (uintptr)procalarm(va_arg(list, ulong));
return procalarm(va_arg(list, ulong));
}
@ -612,34 +612,32 @@ sysexits(va_list list)
uintptr
sys_wait(va_list list)
{
int pid;
ulong pid;
Waitmsg w;
OWaitmsg *ow;
ow = va_arg(list, OWaitmsg*);
if(ow == 0)
if(ow == nil)
pid = pwait(nil);
else {
validaddr((uintptr)ow, sizeof(OWaitmsg), 1);
evenaddr((uintptr)ow);
pid = pwait(&w);
if(pid >= 0){
readnum(0, ow->pid, NUMSIZE, w.pid, NUMSIZE);
readnum(0, ow->time+TUser*NUMSIZE, NUMSIZE, w.time[TUser], NUMSIZE);
readnum(0, ow->time+TSys*NUMSIZE, NUMSIZE, w.time[TSys], NUMSIZE);
readnum(0, ow->time+TReal*NUMSIZE, NUMSIZE, w.time[TReal], NUMSIZE);
strncpy(ow->msg, w.msg, sizeof(ow->msg)-1);
ow->msg[sizeof(ow->msg)-1] = '\0';
}
}
return (uintptr)pid;
if(ow != nil){
readnum(0, ow->pid, NUMSIZE, w.pid, NUMSIZE);
readnum(0, ow->time+TUser*NUMSIZE, NUMSIZE, w.time[TUser], NUMSIZE);
readnum(0, ow->time+TSys*NUMSIZE, NUMSIZE, w.time[TSys], NUMSIZE);
readnum(0, ow->time+TReal*NUMSIZE, NUMSIZE, w.time[TReal], NUMSIZE);
strncpy(ow->msg, w.msg, sizeof(ow->msg)-1);
ow->msg[sizeof(ow->msg)-1] = '\0';
}
return pid;
}
uintptr
sysawait(va_list list)
{
int i;
int pid;
char *p;
Waitmsg w;
uint n;
@ -647,16 +645,11 @@ sysawait(va_list list)
p = va_arg(list, char*);
n = va_arg(list, uint);
validaddr((uintptr)p, n, 1);
pid = pwait(&w);
if(pid < 0)
i = -1;
else {
i = snprint(p, n, "%d %lud %lud %lud %q",
w.pid,
w.time[TUser], w.time[TSys], w.time[TReal],
w.msg);
}
return (uintptr)i;
pwait(&w);
return (uintptr)snprint(p, n, "%d %lud %lud %lud %q",
w.pid,
w.time[TUser], w.time[TSys], w.time[TReal],
w.msg);
}
void

View file

@ -748,7 +748,7 @@ notify(Ureg* ur)
sp = ur->usp & ~(BY2V-1);
sp -= sizeof(Ureg);
if(!okaddr((ulong)up->notify, BY2WD, 0) ||
if(!okaddr((uintptr)up->notify, BY2WD, 0) ||
!okaddr(sp-ERRMAX-4*BY2WD, sizeof(Ureg)+ERRMAX+4*BY2WD, 1)) {
qunlock(&up->debug);
pprint("suicide: bad address or sp in notify\n");
@ -799,7 +799,7 @@ noted(Ureg* ureg, ulong arg0)
/* sanity clause */
oureg = (ulong)nureg;
if(!okaddr((ulong)oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
if(!okaddr(oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
qunlock(&up->debug);
pprint("bad ureg in noted or call to noted when not notified\n");
pexit("Suicide", 0);