diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2022-08-17 15:21:22 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2022-08-17 15:21:22 +0000 |
commit | c8e25d2a18c0395431abc5818a1d2f0561b0181f (patch) | |
tree | a087f5850d7374b5cfd624244237e97b7937d5fe /sys/src/9/omap | |
parent | 7828ffb8a486e188b61394436a434e8cae4fd487 (diff) |
kernel: simplify notify() adding common popnote() function
Handlin notes is common for all architectures
except how the note has to be pushed on the user
stack.
This change adds a popnote() function that returns
only the note string or nil if the process should
not be notified (no notes or user notes hold off).
Popnote() also handles common errors like notify
during note handling or missing note handler and
will suicide the process in that case.
Diffstat (limited to 'sys/src/9/omap')
-rw-r--r-- | sys/src/9/omap/syscall.c | 36 |
1 files changed, 5 insertions, 31 deletions
diff --git a/sys/src/9/omap/syscall.c b/sys/src/9/omap/syscall.c index c97ce591c..91e27fa5f 100644 --- a/sys/src/9/omap/syscall.c +++ b/sys/src/9/omap/syscall.c @@ -98,11 +98,10 @@ noted(Ureg* cur, uintptr arg0) int notify(Ureg* ureg) { - int l; - Note *n; u32int s; uintptr sp; NFrame *nf; + char *msg; if(up->procctl) procctl(); @@ -113,33 +112,13 @@ notify(Ureg* ureg) s = spllo(); qlock(&up->debug); - - up->notepending = 0; - n = &up->note[0]; - if(strncmp(n->msg, "sys:", 4) == 0){ - l = strlen(n->msg); - if(l > ERRMAX-23) /* " pc=0x0123456789abcdef\0" */ - l = ERRMAX-23; - snprint(n->msg + l, sizeof n->msg - l, " pc=%#lux", ureg->pc); - } - - if(n->flag != NUser && (up->notified || up->notify == 0)){ - qunlock(&up->debug); - if(n->flag == NDebug) - pprint("suicide: %s\n", n->msg); - pexit(n->msg, n->flag != NDebug); - } - - if(up->notified){ + msg = popnote(ureg); + if(msg == nil){ qunlock(&up->debug); splhi(); return 0; } - - if(up->notify == nil){ - qunlock(&up->debug); - pexit(n->msg, n->flag != NDebug); - } + if(!okaddr((uintptr)up->notify, 1, 0)){ qunlock(&up->debug); pprint("suicide: notify function address %#p\n", up->notify); @@ -157,7 +136,7 @@ notify(Ureg* ureg) memmove(&nf->ureg, ureg, sizeof(Ureg)); nf->old = up->ureg; up->ureg = nf; - memmove(nf->msg, up->note[0].msg, ERRMAX); + memmove(nf->msg, msg, ERRMAX); nf->arg1 = nf->msg; nf->arg0 = &nf->ureg; nf->ip = 0; @@ -166,11 +145,6 @@ notify(Ureg* ureg) ureg->pc = (uintptr)up->notify; ureg->r0 = (uintptr)nf->arg0; - up->notified = 1; - up->nnote--; - memmove(&up->lastnote, &up->note[0], sizeof(Note)); - memmove(&up->note[0], &up->note[1], up->nnote*sizeof(Note)); - qunlock(&up->debug); splx(s); |