]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
sh: Provide asm/syscall.h for SH-5.
authorPaul Mundt <lethal@linux-sh.org>
Wed, 10 Dec 2008 10:46:18 +0000 (19:46 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Mon, 22 Dec 2008 09:44:04 +0000 (18:44 +0900)
This provides the asm/syscall.h implementation for sh64 parts.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/include/asm/syscall_64.h
arch/sh/kernel/signal_32.c
arch/sh/kernel/signal_64.c

index bcaaa8ca4d700c29425188e58cbf6eea7137def3..e95f3ae30affc237308a463ab39cda8c7b6f2bdf 100644 (file)
@@ -1,6 +1,80 @@
 #ifndef __ASM_SH_SYSCALL_64_H
 #define __ASM_SH_SYSCALL_64_H
 
-#include <asm-generic/syscall.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <asm/ptrace.h>
+
+/* The system call number is given by the user in R9 */
+static inline long syscall_get_nr(struct task_struct *task,
+                                 struct pt_regs *regs)
+{
+       return (regs->syscall_nr >= 0) ? regs->regs[9] : -1L;
+}
+
+static inline void syscall_rollback(struct task_struct *task,
+                                   struct pt_regs *regs)
+{
+       /*
+        * XXX: This needs some thought. On SH we don't
+        * save away the original R9 value anywhere.
+        */
+}
+
+static inline bool syscall_has_error(struct pt_regs *regs)
+{
+       return (regs->sr & 0x1) ? true : false;
+}
+static inline void syscall_set_error(struct pt_regs *regs)
+{
+       regs->sr |= 0x1;
+}
+static inline void syscall_clear_error(struct pt_regs *regs)
+{
+       regs->sr &= ~0x1;
+}
+
+static inline long syscall_get_error(struct task_struct *task,
+                                    struct pt_regs *regs)
+{
+       return syscall_has_error(regs) ? regs->regs[9] : 0;
+}
+
+static inline long syscall_get_return_value(struct task_struct *task,
+                                           struct pt_regs *regs)
+{
+       return regs->regs[9];
+}
+
+static inline void syscall_set_return_value(struct task_struct *task,
+                                           struct pt_regs *regs,
+                                           int error, long val)
+{
+       if (error) {
+               syscall_set_error(regs);
+               regs->regs[9] = -error;
+       } else {
+               syscall_clear_error(regs);
+               regs->regs[9] = val;
+       }
+}
+
+static inline void syscall_get_arguments(struct task_struct *task,
+                                        struct pt_regs *regs,
+                                        unsigned int i, unsigned int n,
+                                        unsigned long *args)
+{
+       BUG_ON(i + n > 6);
+       memcpy(args, &regs->reg[2 + i], n * sizeof(args[0]));
+}
+
+static inline void syscall_set_arguments(struct task_struct *task,
+                                        struct pt_regs *regs,
+                                        unsigned int i, unsigned int n,
+                                        const unsigned long *args)
+{
+       BUG_ON(i + n > 6);
+       memcpy(&regs->reg[2 + i], args, n * sizeof(args[0]));
+}
 
 #endif /* __ASM_SH_SYSCALL_64_H */
index 69d09c0b3498e672057fc92f7a5d740be853ef6b..77c21bde376aa7d203870969c8571182049df6db 100644 (file)
@@ -533,7 +533,6 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
 {
        int ret;
 
-
        /* Set up the stack frame */
        if (ka->sa.sa_flags & SA_SIGINFO)
                ret = setup_rt_frame(sig, ka, info, oldset, regs);
index 08828ddd97ffc9145587a9cc71a0801d310cc29d..b22fdfaaa19188667e3d926d3f8433378e8544df 100644 (file)
@@ -47,6 +47,34 @@ static int
 handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
                sigset_t *oldset, struct pt_regs * regs);
 
+static inline void
+handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa)
+{
+       /* If we're not from a syscall, bail out */
+       if (regs->syscall_nr < 0)
+               return;
+
+       /* check for system call restart.. */
+       switch (regs->regs[REG_RET]) {
+               case -ERESTART_RESTARTBLOCK:
+               case -ERESTARTNOHAND:
+               no_system_call_restart:
+                       regs->regs[REG_RET] = -EINTR;
+                       regs->sr |= 1;
+                       break;
+
+               case -ERESTARTSYS:
+                       if (!(sa->sa_flags & SA_RESTART))
+                               goto no_system_call_restart;
+               /* fallthrough */
+               case -ERESTARTNOINTR:
+                       /* Decode syscall # */
+                       regs->regs[REG_RET] = regs->syscall_nr;
+                       regs->pc -= 4;
+                       break;
+       }
+}
+
 /*
  * Note that 'init' is a special process: it doesn't get signals it doesn't
  * want to handle. Thus you cannot kill init even with a SIGKILL even by
@@ -81,6 +109,9 @@ static int do_signal(struct pt_regs *regs, sigset_t *oldset)
 
        signr = get_signal_to_deliver(&info, &ka, regs, 0);
        if (signr > 0) {
+               if (regs->sr & 1)
+                       handle_syscall_restart(regs, &ka.sa);
+
                /* Whee!  Actually deliver the signal.  */
                if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
                        /*
@@ -128,7 +159,6 @@ no_signal:
 /*
  * Atomically swap in the new signal mask, and wait for a signal.
  */
-
 asmlinkage int
 sys_sigsuspend(old_sigset_t mask,
               unsigned long r3, unsigned long r4, unsigned long r5,
@@ -234,20 +264,16 @@ sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
        return do_sigaltstack(uss, uoss, REF_REG_SP);
 }
 
-
 /*
  * Do a signal return; undo the signal stack.
  */
-
-struct sigframe
-{
+struct sigframe {
        struct sigcontext sc;
        unsigned long extramask[_NSIG_WORDS-1];
        long long retcode[2];
 };
 
-struct rt_sigframe
-{
+struct rt_sigframe {
        struct siginfo __user *pinfo;
        void *puc;
        struct siginfo info;
@@ -449,7 +475,6 @@ badframe:
 /*
  * Set up a signal frame.
  */
-
 static int
 setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
                 unsigned long mask)
@@ -714,34 +739,12 @@ give_sigsegv:
 /*
  * OK, we're invoking a handler
  */
-
 static int
 handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
                sigset_t *oldset, struct pt_regs * regs)
 {
        int ret;
 
-       /* Are we from a system call? */
-       if (regs->syscall_nr >= 0) {
-               /* If so, check system call restarting.. */
-               switch (regs->regs[REG_RET]) {
-                       case -ERESTART_RESTARTBLOCK:
-                       case -ERESTARTNOHAND:
-                       no_system_call_restart:
-                               regs->regs[REG_RET] = -EINTR;
-                               break;
-
-                       case -ERESTARTSYS:
-                               if (!(ka->sa.sa_flags & SA_RESTART))
-                                       goto no_system_call_restart;
-                       /* fallthrough */
-                       case -ERESTARTNOINTR:
-                               /* Decode syscall # */
-                               regs->regs[REG_RET] = regs->syscall_nr;
-                               regs->pc -= 4;
-               }
-       }
-
        /* Set up the stack frame */
        if (ka->sa.sa_flags & SA_SIGINFO)
                ret = setup_rt_frame(sig, ka, info, oldset, regs);