1 #ifndef __ASM_SPARC_SYSCALL_H
2 #define __ASM_SPARC_SYSCALL_H
4 #include <linux/kernel.h>
5 #include <linux/sched.h>
6 #include <asm/ptrace.h>
9 * The syscall table always contains 32 bit pointers since we know that the
10 * address of the function to be called is (way) below 4GB. So the "int"
11 * type here is what we want [need] for both 32 bit and 64 bit systems.
13 extern const unsigned int sys_call_table[];
15 /* The system call number is given by the user in %g1 */
16 static inline long syscall_get_nr(struct task_struct *task,
19 int syscall_p = pt_regs_is_syscall(regs);
21 return (syscall_p ? regs->u_regs[UREG_G1] : -1L);
24 static inline void syscall_rollback(struct task_struct *task,
27 /* XXX This needs some thought. On Sparc we don't
28 * XXX save away the original %o0 value somewhere.
29 * XXX Instead we hold it in register %l5 at the top
30 * XXX level trap frame and pass this down to the signal
31 * XXX dispatch code which is the only place that value
32 * XXX ever was needed.
37 static inline bool syscall_has_error(struct pt_regs *regs)
39 return (regs->psr & PSR_C) ? true : false;
41 static inline void syscall_set_error(struct pt_regs *regs)
45 static inline void syscall_clear_error(struct pt_regs *regs)
50 static inline bool syscall_has_error(struct pt_regs *regs)
52 return (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY)) ? true : false;
54 static inline void syscall_set_error(struct pt_regs *regs)
56 regs->tstate |= (TSTATE_XCARRY | TSTATE_ICARRY);
58 static inline void syscall_clear_error(struct pt_regs *regs)
60 regs->tstate &= ~(TSTATE_XCARRY | TSTATE_ICARRY);
64 static inline long syscall_get_error(struct task_struct *task,
67 long val = regs->u_regs[UREG_I0];
69 return (syscall_has_error(regs) ? -val : 0);
72 static inline long syscall_get_return_value(struct task_struct *task,
75 long val = regs->u_regs[UREG_I0];
80 static inline void syscall_set_return_value(struct task_struct *task,
85 syscall_set_error(regs);
86 regs->u_regs[UREG_I0] = -error;
88 syscall_clear_error(regs);
89 regs->u_regs[UREG_I0] = val;
93 static inline void syscall_get_arguments(struct task_struct *task,
95 unsigned int i, unsigned int n,
101 #ifdef CONFIG_SPARC64
102 if (test_tsk_thread_flag(task, TIF_32BIT))
106 for (j = 0; j < n; j++) {
107 unsigned long val = regs->u_regs[UREG_I0 + i + j];
116 static inline void syscall_set_arguments(struct task_struct *task,
117 struct pt_regs *regs,
118 unsigned int i, unsigned int n,
119 const unsigned long *args)
123 for (j = 0; j < n; j++)
124 regs->u_regs[UREG_I0 + i + j] = args[j];
127 #endif /* __ASM_SPARC_SYSCALL_H */