···11+#ifndef __ASM_SH_SYSCALL_H22+#define __ASM_SH_SYSCALL_H33+44+#ifdef CONFIG_SUPERH3255+# include "syscall_32.h"66+#else77+# include "syscall_64.h"88+#endif99+1010+#endif /* __ASM_SH_SYSCALL_H */
+110
arch/sh/include/asm/syscall_32.h
···11+#ifndef __ASM_SH_SYSCALL_32_H22+#define __ASM_SH_SYSCALL_32_H33+44+#include <linux/kernel.h>55+#include <linux/sched.h>66+#include <asm/ptrace.h>77+88+/* The system call number is given by the user in %g1 */99+static inline long syscall_get_nr(struct task_struct *task,1010+ struct pt_regs *regs)1111+{1212+ return (regs->tra >= 0) ? regs->regs[3] : -1L;1313+}1414+1515+static inline void syscall_rollback(struct task_struct *task,1616+ struct pt_regs *regs)1717+{1818+ /*1919+ * XXX: This needs some thought. On SH we don't2020+ * save away the original r0 value anywhere.2121+ */2222+}2323+2424+static inline bool syscall_has_error(struct pt_regs *regs)2525+{2626+ return (regs->sr & 0x1) ? true : false;2727+}2828+static inline void syscall_set_error(struct pt_regs *regs)2929+{3030+ regs->sr |= 0x1;3131+}3232+static inline void syscall_clear_error(struct pt_regs *regs)3333+{3434+ regs->sr &= ~0x1;3535+}3636+3737+static inline long syscall_get_error(struct task_struct *task,3838+ struct pt_regs *regs)3939+{4040+ return syscall_has_error(regs) ? regs->regs[0] : 0;4141+}4242+4343+static inline long syscall_get_return_value(struct task_struct *task,4444+ struct pt_regs *regs)4545+{4646+ return regs->regs[0];4747+}4848+4949+static inline void syscall_set_return_value(struct task_struct *task,5050+ struct pt_regs *regs,5151+ int error, long val)5252+{5353+ if (error) {5454+ syscall_set_error(regs);5555+ regs->regs[0] = -error;5656+ } else {5757+ syscall_clear_error(regs);5858+ regs->regs[0] = val;5959+ }6060+}6161+6262+static inline void syscall_get_arguments(struct task_struct *task,6363+ struct pt_regs *regs,6464+ unsigned int i, unsigned int n,6565+ unsigned long *args)6666+{6767+ /*6868+ * Do this simply for now. If we need to start supporting6969+ * fetching arguments from arbitrary indices, this will need some7070+ * extra logic. Presently there are no in-tree users that depend7171+ * on this behaviour.7272+ */7373+ BUG_ON(i);7474+7575+ /* Argument pattern is: R4, R5, R6, R7, R0, R1 */7676+ switch (n) {7777+ case 6: args[5] = regs->regs[1];7878+ case 5: args[4] = regs->regs[0];7979+ case 4: args[3] = regs->regs[7];8080+ case 3: args[2] = regs->regs[6];8181+ case 2: args[1] = regs->regs[5];8282+ case 1: args[0] = regs->regs[4];8383+ break;8484+ default:8585+ BUG();8686+ }8787+}8888+8989+static inline void syscall_set_arguments(struct task_struct *task,9090+ struct pt_regs *regs,9191+ unsigned int i, unsigned int n,9292+ const unsigned long *args)9393+{9494+ /* Same note as above applies */9595+ BUG_ON(i);9696+9797+ switch (n) {9898+ case 6: regs->regs[1] = args[5];9999+ case 5: regs->regs[0] = args[4];100100+ case 4: regs->regs[7] = args[3];101101+ case 3: regs->regs[6] = args[2];102102+ case 2: regs->regs[5] = args[1];103103+ case 1: regs->regs[4] = args[0];104104+ break;105105+ default:106106+ BUG();107107+ }108108+}109109+110110+#endif /* __ASM_SH_SYSCALL_32_H */