-static void setup_frame(int sig, struct k_sigaction *ka,
- sigset_t *set, struct pt_regs *regs)
-{
- struct sigframe __user *frame;
- int err = 0;
- int signal;
-
- frame = get_sigframe(ka, regs->spu, sizeof(*frame));
-
- if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
- goto give_sigsegv;
-
- signal = current_thread_info()->exec_domain
- && current_thread_info()->exec_domain->signal_invmap
- && sig < 32
- ? current_thread_info()->exec_domain->signal_invmap[sig]
- : sig;
-
- err |= __put_user(signal, &frame->sig);
- if (err)
- goto give_sigsegv;
-
- err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);
- if (err)
- goto give_sigsegv;
-
- if (_NSIG_WORDS > 1) {
- err |= __copy_to_user(frame->extramask, &set->sig[1],
- sizeof(frame->extramask));
- if (err)
- goto give_sigsegv;
- }
-
- if (ka->sa.sa_flags & SA_RESTORER)
- regs->lr = (unsigned long)ka->sa.sa_restorer;
- else {
- /* This is : ldi r7, #__NR_sigreturn ; trap #2 */
- unsigned long code = 0x670010f2 | (__NR_sigreturn << 16);
-
- regs->lr = (unsigned long)frame->retcode;
- err |= __put_user(code, (long __user *)(frame->retcode+0));
- if (err)
- goto give_sigsegv;
- flush_cache_sigtramp((unsigned long)frame->retcode);
- }
-
- /* Set up registers for signal handler */
- regs->spu = (unsigned long)frame;
- regs->r0 = signal; /* Arg for signal handler */
- regs->r1 = (unsigned long)&frame->sc;
- regs->bpc = (unsigned long)ka->sa.sa_handler;
-
- set_fs(USER_DS);
-
-#if DEBUG_SIG
- printk("SIG deliver (%s:%d): sp=%p pc=%p\n",
- current->comm, current->pid, frame, regs->pc);
-#endif
-
- return;
-
-give_sigsegv:
- force_sigsegv(sig, current);
-}
-