1
2
3
4
5
6
7
8#include <linux/kernel.h>
9#include <linux/sched.h>
10#include <linux/mm.h>
11#include <linux/errno.h>
12#include <linux/smp.h>
13#include <linux/smp_lock.h>
14#include <linux/time.h>
15#include <linux/ptrace.h>
16
17#include <asm/ptrace.h>
18#include <asm/uaccess.h>
19
20#undef DEBUG_SIG
21
22#define _S(nr) (1<<((nr)-1))
23
24#define _BLOCKABLE (~(_S(SIGKILL) | _S(SIGSTOP)))
25
26typedef struct {
27 unsigned long sig[4];
28} irix_sigset_t;
29
30struct sigctx_irix5 {
31 u32 rmask, cp0_status;
32 u64 pc;
33 u64 regs[32];
34 u64 fpregs[32];
35 u32 usedfp, fpcsr, fpeir, sstk_flags;
36 u64 hi, lo;
37 u64 cp0_cause, cp0_badvaddr, _unused0;
38 irix_sigset_t sigset;
39 u64 weird_fpu_thing;
40 u64 _unused1[31];
41};
42
43#ifdef DEBUG_SIG
44
45static inline void dump_irix5_sigctx(struct sigctx_irix5 *c)
46{
47 int i;
48
49 printk("misc: rmask[%08lx] status[%08lx] pc[%08lx]\n",
50 (unsigned long) c->rmask,
51 (unsigned long) c->cp0_status,
52 (unsigned long) c->pc);
53 printk("regs: ");
54 for(i = 0; i < 16; i++)
55 printk("[%d]<%08lx> ", i, (unsigned long) c->regs[i]);
56 printk("\nregs: ");
57 for(i = 16; i < 32; i++)
58 printk("[%d]<%08lx> ", i, (unsigned long) c->regs[i]);
59 printk("\nfpregs: ");
60 for(i = 0; i < 16; i++)
61 printk("[%d]<%08lx> ", i, (unsigned long) c->fpregs[i]);
62 printk("\nfpregs: ");
63 for(i = 16; i < 32; i++)
64 printk("[%d]<%08lx> ", i, (unsigned long) c->fpregs[i]);
65 printk("misc: usedfp[%d] fpcsr[%08lx] fpeir[%08lx] stk_flgs[%08lx]\n",
66 (int) c->usedfp, (unsigned long) c->fpcsr,
67 (unsigned long) c->fpeir, (unsigned long) c->sstk_flags);
68 printk("misc: hi[%08lx] lo[%08lx] cause[%08lx] badvaddr[%08lx]\n",
69 (unsigned long) c->hi, (unsigned long) c->lo,
70 (unsigned long) c->cp0_cause, (unsigned long) c->cp0_badvaddr);
71 printk("misc: sigset<0>[%08lx] sigset<1>[%08lx] sigset<2>[%08lx] "
72 "sigset<3>[%08lx]\n", (unsigned long) c->sigset.sig[0],
73 (unsigned long) c->sigset.sig[1],
74 (unsigned long) c->sigset.sig[2],
75 (unsigned long) c->sigset.sig[3]);
76}
77#endif
78
79static void setup_irix_frame(struct k_sigaction *ka, struct pt_regs *regs,
80 int signr, sigset_t *oldmask)
81{
82 unsigned long sp;
83 struct sigctx_irix5 *ctx;
84 int i;
85
86 sp = regs->regs[29];
87 sp -= sizeof(struct sigctx_irix5);
88 sp &= ~(0xf);
89 ctx = (struct sigctx_irix5 *) sp;
90 if (!access_ok(VERIFY_WRITE, ctx, sizeof(*ctx)))
91 goto segv_and_exit;
92
93 __put_user(0, &ctx->weird_fpu_thing);
94 __put_user(~(0x00000001), &ctx->rmask);
95 __put_user(0, &ctx->regs[0]);
96 for(i = 1; i < 32; i++)
97 __put_user((u64) regs->regs[i], &ctx->regs[i]);
98
99 __put_user((u64) regs->hi, &ctx->hi);
100 __put_user((u64) regs->lo, &ctx->lo);
101 __put_user((u64) regs->cp0_epc, &ctx->pc);
102 __put_user(!!used_math(), &ctx->usedfp);
103 __put_user((u64) regs->cp0_cause, &ctx->cp0_cause);
104 __put_user((u64) regs->cp0_badvaddr, &ctx->cp0_badvaddr);
105
106 __put_user(0, &ctx->sstk_flags);
107
108 __copy_to_user(&ctx->sigset, oldmask, sizeof(irix_sigset_t));
109
110#ifdef DEBUG_SIG
111 dump_irix5_sigctx(ctx);
112#endif
113
114 regs->regs[4] = (unsigned long) signr;
115 regs->regs[5] = 0;
116 regs->regs[6] = regs->regs[29] = sp;
117 regs->regs[7] = (unsigned long) ka->sa.sa_handler;
118 regs->regs[25] = regs->cp0_epc = (unsigned long) ka->sa_restorer;
119
120 return;
121
122segv_and_exit:
123 force_sigsegv(signr, current);
124}
125
126static void inline
127setup_irix_rt_frame(struct k_sigaction * ka, struct pt_regs *regs,
128 int signr, sigset_t *oldmask, siginfo_t *info)
129{
130 printk("Aiee: setup_tr_frame wants to be written");
131 do_exit(SIGSEGV);
132}
133
134static inline void handle_signal(unsigned long sig, siginfo_t *info,
135 struct k_sigaction *ka, sigset_t *oldset, struct pt_regs * regs)
136{
137 switch(regs->regs[0]) {
138 case ERESTARTNOHAND:
139 regs->regs[2] = EINTR;
140 break;
141 case ERESTARTSYS:
142 if(!(ka->sa.sa_flags & SA_RESTART)) {
143 regs->regs[2] = EINTR;
144 break;
145 }
146
147 case ERESTARTNOINTR:
148 regs->cp0_epc -= 8;
149 }
150
151 regs->regs[0] = 0;
152
153 if (ka->sa.sa_flags & SA_SIGINFO)
154 setup_irix_rt_frame(ka, regs, sig, oldset, info);
155 else
156 setup_irix_frame(ka, regs, sig, oldset);
157
158 if (!(ka->sa.sa_flags & SA_NODEFER)) {
159 spin_lock_irq(¤t->sighand->siglock);
160 sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
161 sigaddset(¤t->blocked,sig);
162 recalc_sigpending();
163 spin_unlock_irq(¤t->sighand->siglock);
164 }
165}
166
167asmlinkage int do_irix_signal(sigset_t *oldset, struct pt_regs *regs)
168{
169 struct k_sigaction ka;
170 siginfo_t info;
171 int signr;
172
173
174
175
176
177
178 if (!user_mode(regs))
179 return 1;
180
181 if (try_to_freeze(0))
182 goto no_signal;
183
184 if (!oldset)
185 oldset = ¤t->blocked;
186
187 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
188 if (signr > 0) {
189 handle_signal(signr, &info, &ka, oldset, regs);
190 return 1;
191 }
192
193no_signal:
194
195
196
197
198
199 if (regs->regs[0]) {
200 if (regs->regs[2] == ERESTARTNOHAND ||
201 regs->regs[2] == ERESTARTSYS ||
202 regs->regs[2] == ERESTARTNOINTR) {
203 regs->cp0_epc -= 8;
204 }
205 }
206 return 0;
207}
208
209asmlinkage void
210irix_sigreturn(struct pt_regs *regs)
211{
212 struct sigctx_irix5 *context, *magic;
213 unsigned long umask, mask;
214 u64 *fregs;
215 int sig, i, base = 0;
216 sigset_t blocked;
217
218
219 current_thread_info()->restart_block.fn = do_no_restart_syscall;
220
221 if (regs->regs[2] == 1000)
222 base = 1;
223
224 context = (struct sigctx_irix5 *) regs->regs[base + 4];
225 magic = (struct sigctx_irix5 *) regs->regs[base + 5];
226 sig = (int) regs->regs[base + 6];
227#ifdef DEBUG_SIG
228 printk("[%s:%d] IRIX sigreturn(scp[%p],ucp[%p],sig[%d])\n",
229 current->comm, current->pid, context, magic, sig);
230#endif
231 if (!context)
232 context = magic;
233 if (!access_ok(VERIFY_READ, context, sizeof(struct sigctx_irix5)))
234 goto badframe;
235
236#ifdef DEBUG_SIG
237 dump_irix5_sigctx(context);
238#endif
239
240 __get_user(regs->cp0_epc, &context->pc);
241 umask = context->rmask; mask = 2;
242 for (i = 1; i < 32; i++, mask <<= 1) {
243 if(umask & mask)
244 __get_user(regs->regs[i], &context->regs[i]);
245 }
246 __get_user(regs->hi, &context->hi);
247 __get_user(regs->lo, &context->lo);
248
249 if ((umask & 1) && context->usedfp) {
250 fregs = (u64 *) ¤t->thread.fpu;
251 for(i = 0; i < 32; i++)
252 fregs[i] = (u64) context->fpregs[i];
253 __get_user(current->thread.fpu.hard.fcr31, &context->fpcsr);
254 }
255
256
257
258 if (__copy_from_user(&blocked, &context->sigset, sizeof(blocked)))
259 goto badframe;
260
261 sigdelsetmask(&blocked, ~_BLOCKABLE);
262 spin_lock_irq(¤t->sighand->siglock);
263 current->blocked = blocked;
264 recalc_sigpending();
265 spin_unlock_irq(¤t->sighand->siglock);
266
267
268
269
270 if (current_thread_info()->flags & TIF_SYSCALL_TRACE)
271 do_syscall_trace(regs, 1);
272 __asm__ __volatile__(
273 "move\t$29,%0\n\t"
274 "j\tsyscall_exit"
275 :
276 :"r" (®s));
277
278
279badframe:
280 force_sig(SIGSEGV, current);
281}
282
283struct sigact_irix5 {
284 int flags;
285 void (*handler)(int);
286 u32 sigset[4];
287 int _unused0[2];
288};
289
290#ifdef DEBUG_SIG
291static inline void dump_sigact_irix5(struct sigact_irix5 *p)
292{
293 printk("<f[%d] hndlr[%08lx] msk[%08lx]>", p->flags,
294 (unsigned long) p->handler,
295 (unsigned long) p->sigset[0]);
296}
297#endif
298
299asmlinkage int
300irix_sigaction(int sig, const struct sigaction *act,
301 struct sigaction *oact, void *trampoline)
302{
303 struct k_sigaction new_ka, old_ka;
304 int ret;
305
306#ifdef DEBUG_SIG
307 printk(" (%d,%s,%s,%08lx) ", sig, (!new ? "0" : "NEW"),
308 (!old ? "0" : "OLD"), trampoline);
309 if(new) {
310 dump_sigact_irix5(new); printk(" ");
311 }
312#endif
313 if (act) {
314 sigset_t mask;
315 if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
316 __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
317 __get_user(new_ka.sa.sa_flags, &act->sa_flags))
318 return -EFAULT;
319
320 __copy_from_user(&mask, &act->sa_mask, sizeof(sigset_t));
321
322
323
324
325
326
327 new_ka.sa_restorer = trampoline;
328 }
329
330
331 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
332
333 if (!ret && oact) {
334 if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
335 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
336 __put_user(old_ka.sa.sa_flags, &oact->sa_flags))
337 return -EFAULT;
338 __copy_to_user(&old_ka.sa.sa_mask, &oact->sa_mask,
339 sizeof(sigset_t));
340 }
341
342 return ret;
343}
344
345asmlinkage int irix_sigpending(irix_sigset_t *set)
346{
347 return do_sigpending(set, sizeof(*set));
348}
349
350asmlinkage int irix_sigprocmask(int how, irix_sigset_t *new, irix_sigset_t *old)
351{
352 sigset_t oldbits, newbits;
353 int error;
354
355 if (new) {
356 error = verify_area(VERIFY_READ, new, sizeof(*new));
357 if (error)
358 return error;
359 __copy_from_user(&newbits, new, sizeof(unsigned long)*4);
360 sigdelsetmask(&newbits, ~_BLOCKABLE);
361
362 spin_lock_irq(¤t->sighand->siglock);
363 oldbits = current->blocked;
364
365 switch(how) {
366 case 1:
367 sigorsets(&newbits, &oldbits, &newbits);
368 break;
369
370 case 2:
371 sigandsets(&newbits, &oldbits, &newbits);
372 break;
373
374 case 3:
375 break;
376
377 case 256:
378 siginitset(&newbits, newbits.sig[0]);
379 break;
380
381 default:
382 return -EINVAL;
383 }
384 recalc_sigpending();
385 spin_unlock_irq(¤t->sighand->siglock);
386 }
387 if(old) {
388 error = verify_area(VERIFY_WRITE, old, sizeof(*old));
389 if(error)
390 return error;
391 __copy_to_user(old, ¤t->blocked, sizeof(unsigned long)*4);
392 }
393
394 return 0;
395}
396
397asmlinkage int irix_sigsuspend(struct pt_regs *regs)
398{
399 sigset_t *uset, saveset, newset;
400
401 uset = (sigset_t *) regs->regs[4];
402 if (copy_from_user(&newset, uset, sizeof(sigset_t)))
403 return -EFAULT;
404 sigdelsetmask(&newset, ~_BLOCKABLE);
405
406 spin_lock_irq(¤t->sighand->siglock);
407 saveset = current->blocked;
408 current->blocked = newset;
409 recalc_sigpending();
410 spin_unlock_irq(¤t->sighand->siglock);
411
412 regs->regs[2] = -EINTR;
413 while (1) {
414 current->state = TASK_INTERRUPTIBLE;
415 schedule();
416 if (do_irix_signal(&saveset, regs))
417 return -EINTR;
418 }
419}
420
421
422struct irix5_siginfo {
423 int sig, code, error;
424 union {
425 char unused[128 - (3 * 4)];
426 struct {
427 int pid;
428 union {
429 int uid;
430 struct {
431 int utime, status, stime;
432 } child;
433 } procdata;
434 } procinfo;
435
436 unsigned long fault_addr;
437
438 struct {
439 int fd;
440 long band;
441 } fileinfo;
442
443 unsigned long sigval;
444 } stuff;
445};
446
447static inline unsigned long timespectojiffies(struct timespec *value)
448{
449 unsigned long sec = (unsigned) value->tv_sec;
450 long nsec = value->tv_nsec;
451
452 if (sec > (LONG_MAX / HZ))
453 return LONG_MAX;
454 nsec += 1000000000L / HZ - 1;
455 nsec /= 1000000000L / HZ;
456 return HZ * sec + nsec;
457}
458
459asmlinkage int irix_sigpoll_sys(unsigned long *set, struct irix5_siginfo *info,
460 struct timespec *tp)
461{
462 long expire = MAX_SCHEDULE_TIMEOUT;
463 sigset_t kset;
464 int i, sig, error, timeo = 0;
465
466#ifdef DEBUG_SIG
467 printk("[%s:%d] irix_sigpoll_sys(%p,%p,%p)\n",
468 current->comm, current->pid, set, info, tp);
469#endif
470
471
472 if(!set)
473 return -EINVAL;
474
475 error = verify_area(VERIFY_READ, set, sizeof(kset));
476 if (error)
477 goto out;
478
479 __copy_from_user(&kset, set, sizeof(set));
480 if (error)
481 goto out;
482
483 if (info && clear_user(info, sizeof(*info))) {
484 error = -EFAULT;
485 goto out;
486 }
487
488 if(tp) {
489 error = verify_area(VERIFY_READ, tp, sizeof(*tp));
490 if(error)
491 return error;
492 if(!tp->tv_sec && !tp->tv_nsec) {
493 error = -EINVAL;
494 goto out;
495 }
496 expire = timespectojiffies(tp)+(tp->tv_sec||tp->tv_nsec);
497 }
498
499 while(1) {
500 long tmp = 0;
501
502 current->state = TASK_INTERRUPTIBLE;
503 expire = schedule_timeout(expire);
504
505 for (i=0; i<=4; i++)
506 tmp |= (current->pending.signal.sig[i] & kset.sig[i]);
507
508 if (tmp)
509 break;
510 if (!expire) {
511 timeo = 1;
512 break;
513 }
514 if (signal_pending(current))
515 return -EINTR;
516 }
517 if (timeo)
518 return -EAGAIN;
519
520 for(sig = 1; i <= 65 ; sig++) {
521 if (sigismember (&kset, sig))
522 continue;
523 if (sigismember (¤t->pending.signal, sig)) {
524
525 if (info)
526 info->sig = sig;
527 error = 0;
528 goto out;
529 }
530 }
531
532
533 error = -EINTR;
534
535out:
536 return error;
537}
538
539
540#define IRIX_P_PID 0
541#define IRIX_P_PGID 2
542#define IRIX_P_ALL 7
543
544extern int getrusage(struct task_struct *, int, struct rusage __user *);
545
546#define W_EXITED 1
547#define W_TRAPPED 2
548#define W_STOPPED 4
549#define W_CONT 8
550#define W_NOHANG 64
551
552#define W_MASK (W_EXITED | W_TRAPPED | W_STOPPED | W_CONT | W_NOHANG)
553
554asmlinkage int irix_waitsys(int type, int pid, struct irix5_siginfo *info,
555 int options, struct rusage *ru)
556{
557 int flag, retval;
558 DECLARE_WAITQUEUE(wait, current);
559 struct task_struct *tsk;
560 struct task_struct *p;
561 struct list_head *_p;
562
563 if (!info) {
564 retval = -EINVAL;
565 goto out;
566 }
567 retval = verify_area(VERIFY_WRITE, info, sizeof(*info));
568 if(retval)
569 goto out;
570 if (ru) {
571 retval = verify_area(VERIFY_WRITE, ru, sizeof(*ru));
572 if(retval)
573 goto out;
574 }
575 if (options & ~(W_MASK)) {
576 retval = -EINVAL;
577 goto out;
578 }
579 if (type != IRIX_P_PID && type != IRIX_P_PGID && type != IRIX_P_ALL) {
580 retval = -EINVAL;
581 goto out;
582 }
583 add_wait_queue(¤t->signal->wait_chldexit, &wait);
584repeat:
585 flag = 0;
586 current->state = TASK_INTERRUPTIBLE;
587 read_lock(&tasklist_lock);
588 tsk = current;
589 list_for_each(_p,&tsk->children) {
590 p = list_entry(_p,struct task_struct,sibling);
591 if ((type == IRIX_P_PID) && p->pid != pid)
592 continue;
593 if ((type == IRIX_P_PGID) && process_group(p) != pid)
594 continue;
595 if ((p->exit_signal != SIGCHLD))
596 continue;
597 flag = 1;
598 switch (p->state) {
599 case TASK_STOPPED:
600 if (!p->exit_code)
601 continue;
602 if (!(options & (W_TRAPPED|W_STOPPED)) &&
603 !(p->ptrace & PT_PTRACED))
604 continue;
605 read_unlock(&tasklist_lock);
606
607
608 write_lock_irq(&tasklist_lock);
609 remove_parent(p);
610 add_parent(p, p->parent);
611 write_unlock_irq(&tasklist_lock);
612 retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0;
613 if (!retval && ru) {
614 retval |= __put_user(SIGCHLD, &info->sig);
615 retval |= __put_user(0, &info->code);
616 retval |= __put_user(p->pid, &info->stuff.procinfo.pid);
617 retval |= __put_user((p->exit_code >> 8) & 0xff,
618 &info->stuff.procinfo.procdata.child.status);
619 retval |= __put_user(p->utime, &info->stuff.procinfo.procdata.child.utime);
620 retval |= __put_user(p->stime, &info->stuff.procinfo.procdata.child.stime);
621 }
622 if (!retval) {
623 p->exit_code = 0;
624 }
625 goto end_waitsys;
626
627 case EXIT_ZOMBIE:
628 current->signal->cutime += p->utime + p->signal->cutime;
629 current->signal->cstime += p->stime + p->signal->cstime;
630 if (ru != NULL)
631 getrusage(p, RUSAGE_BOTH, ru);
632 __put_user(SIGCHLD, &info->sig);
633 __put_user(1, &info->code);
634 __put_user(p->pid, &info->stuff.procinfo.pid);
635 __put_user((p->exit_code >> 8) & 0xff,
636 &info->stuff.procinfo.procdata.child.status);
637 __put_user(p->utime,
638 &info->stuff.procinfo.procdata.child.utime);
639 __put_user(p->stime,
640 &info->stuff.procinfo.procdata.child.stime);
641 retval = 0;
642 if (p->real_parent != p->parent) {
643 write_lock_irq(&tasklist_lock);
644 remove_parent(p);
645 p->parent = p->real_parent;
646 add_parent(p, p->parent);
647 do_notify_parent(p, SIGCHLD);
648 write_unlock_irq(&tasklist_lock);
649 } else
650 release_task(p);
651 goto end_waitsys;
652 default:
653 continue;
654 }
655 tsk = next_thread(tsk);
656 }
657 read_unlock(&tasklist_lock);
658 if (flag) {
659 retval = 0;
660 if (options & W_NOHANG)
661 goto end_waitsys;
662 retval = -ERESTARTSYS;
663 if (signal_pending(current))
664 goto end_waitsys;
665 current->state = TASK_INTERRUPTIBLE;
666 schedule();
667 goto repeat;
668 }
669 retval = -ECHILD;
670end_waitsys:
671 current->state = TASK_RUNNING;
672 remove_wait_queue(¤t->signal->wait_chldexit, &wait);
673
674out:
675 return retval;
676}
677
678struct irix5_context {
679 u32 flags;
680 u32 link;
681 u32 sigmask[4];
682 struct { u32 sp, size, flags; } stack;
683 int regs[36];
684 u32 fpregs[32];
685 u32 fpcsr;
686 u32 _unused0;
687 u32 _unused1[47];
688 u32 weird_graphics_thing;
689};
690
691asmlinkage int irix_getcontext(struct pt_regs *regs)
692{
693 int error, i, base = 0;
694 struct irix5_context *ctx;
695 unsigned long flags;
696
697 if (regs->regs[2] == 1000)
698 base = 1;
699 ctx = (struct irix5_context *) regs->regs[base + 4];
700
701#ifdef DEBUG_SIG
702 printk("[%s:%d] irix_getcontext(%p)\n",
703 current->comm, current->pid, ctx);
704#endif
705
706 error = verify_area(VERIFY_WRITE, ctx, sizeof(*ctx));
707 if(error)
708 goto out;
709 __put_user(current->thread.irix_oldctx, &ctx->link);
710
711 __copy_to_user(&ctx->sigmask, ¤t->blocked, sizeof(irix_sigset_t));
712
713
714 __put_user(0, &ctx->stack.sp);
715 __put_user(0, &ctx->stack.size);
716 __put_user(0, &ctx->stack.flags);
717
718 __put_user(0, &ctx->weird_graphics_thing);
719 __put_user(0, &ctx->regs[0]);
720 for (i = 1; i < 32; i++)
721 __put_user(regs->regs[i], &ctx->regs[i]);
722 __put_user(regs->lo, &ctx->regs[32]);
723 __put_user(regs->hi, &ctx->regs[33]);
724 __put_user(regs->cp0_cause, &ctx->regs[34]);
725 __put_user(regs->cp0_epc, &ctx->regs[35]);
726
727 flags = 0x0f;
728 if(!used_math()) {
729 flags &= ~(0x08);
730 } else {
731
732 printk("Wheee, no code for saving IRIX FPU context yet.\n");
733 }
734 __put_user(flags, &ctx->flags);
735 error = 0;
736
737out:
738 return error;
739}
740
741asmlinkage unsigned long irix_setcontext(struct pt_regs *regs)
742{
743 int error, base = 0;
744 struct irix5_context *ctx;
745
746 if(regs->regs[2] == 1000)
747 base = 1;
748 ctx = (struct irix5_context *) regs->regs[base + 4];
749
750#ifdef DEBUG_SIG
751 printk("[%s:%d] irix_setcontext(%p)\n",
752 current->comm, current->pid, ctx);
753#endif
754
755 error = verify_area(VERIFY_READ, ctx, sizeof(*ctx));
756 if (error)
757 goto out;
758
759 if (ctx->flags & 0x02) {
760
761 printk("Wheee, cannot do sigstack stuff in setcontext\n");
762 }
763
764 if (ctx->flags & 0x04) {
765 int i;
766
767
768 for(i = 1; i < 32; i++)
769 regs->regs[i] = ctx->regs[i];
770 regs->lo = ctx->regs[32];
771 regs->hi = ctx->regs[33];
772 regs->cp0_epc = ctx->regs[35];
773 }
774
775 if (ctx->flags & 0x08) {
776
777 printk("Wheee, cannot restore FPU context yet...\n");
778 }
779 current->thread.irix_oldctx = ctx->link;
780 error = regs->regs[2];
781
782out:
783 return error;
784}
785
786struct irix_sigstack { unsigned long sp; int status; };
787
788asmlinkage int irix_sigstack(struct irix_sigstack *new, struct irix_sigstack *old)
789{
790 int error;
791
792#ifdef DEBUG_SIG
793 printk("[%s:%d] irix_sigstack(%p,%p)\n",
794 current->comm, current->pid, new, old);
795#endif
796 if(new) {
797 error = verify_area(VERIFY_READ, new, sizeof(*new));
798 if(error)
799 goto out;
800 }
801
802 if(old) {
803 error = verify_area(VERIFY_WRITE, old, sizeof(*old));
804 if(error)
805 goto out;
806 }
807 error = 0;
808
809out:
810 return error;
811}
812
813struct irix_sigaltstack { unsigned long sp; int size; int status; };
814
815asmlinkage int irix_sigaltstack(struct irix_sigaltstack *new,
816 struct irix_sigaltstack *old)
817{
818 int error;
819
820#ifdef DEBUG_SIG
821 printk("[%s:%d] irix_sigaltstack(%p,%p)\n",
822 current->comm, current->pid, new, old);
823#endif
824 if (new) {
825 error = verify_area(VERIFY_READ, new, sizeof(*new));
826 if(error)
827 goto out;
828 }
829
830 if (old) {
831 error = verify_area(VERIFY_WRITE, old, sizeof(*old));
832 if(error)
833 goto out;
834 }
835 error = 0;
836
837out:
838 error = 0;
839
840 return error;
841}
842
843struct irix_procset {
844 int cmd, ltype, lid, rtype, rid;
845};
846
847asmlinkage int irix_sigsendset(struct irix_procset *pset, int sig)
848{
849 int error;
850
851 error = verify_area(VERIFY_READ, pset, sizeof(*pset));
852 if(error)
853 goto out;
854#ifdef DEBUG_SIG
855 printk("[%s:%d] irix_sigsendset([%d,%d,%d,%d,%d],%d)\n",
856 current->comm, current->pid,
857 pset->cmd, pset->ltype, pset->lid, pset->rtype, pset->rid,
858 sig);
859#endif
860 error = -EINVAL;
861
862out:
863 return error;
864}
865