added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / arch / sparc / include / asm / syscall.h
blob7486c605e23cb36832ec74019c4adad2a68ec0a9
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>
8 /* The system call number is given by the user in %g1 */
9 static inline long syscall_get_nr(struct task_struct *task,
10 struct pt_regs *regs)
12 int syscall_p = pt_regs_is_syscall(regs);
14 return (syscall_p ? regs->u_regs[UREG_G1] : -1L);
17 static inline void syscall_rollback(struct task_struct *task,
18 struct pt_regs *regs)
20 /* XXX This needs some thought. On Sparc we don't
21 * XXX save away the original %o0 value somewhere.
22 * XXX Instead we hold it in register %l5 at the top
23 * XXX level trap frame and pass this down to the signal
24 * XXX dispatch code which is the only place that value
25 * XXX ever was needed.
29 #ifdef CONFIG_SPARC32
30 static inline bool syscall_has_error(struct pt_regs *regs)
32 return (regs->psr & PSR_C) ? true : false;
34 static inline void syscall_set_error(struct pt_regs *regs)
36 regs->psr |= PSR_C;
38 static inline void syscall_clear_error(struct pt_regs *regs)
40 regs->psr &= ~PSR_C;
42 #else
43 static inline bool syscall_has_error(struct pt_regs *regs)
45 return (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY)) ? true : false;
47 static inline void syscall_set_error(struct pt_regs *regs)
49 regs->tstate |= (TSTATE_XCARRY | TSTATE_ICARRY);
51 static inline void syscall_clear_error(struct pt_regs *regs)
53 regs->tstate &= ~(TSTATE_XCARRY | TSTATE_ICARRY);
55 #endif
57 static inline long syscall_get_error(struct task_struct *task,
58 struct pt_regs *regs)
60 long val = regs->u_regs[UREG_I0];
62 return (syscall_has_error(regs) ? -val : 0);
65 static inline long syscall_get_return_value(struct task_struct *task,
66 struct pt_regs *regs)
68 long val = regs->u_regs[UREG_I0];
70 return val;
73 static inline void syscall_set_return_value(struct task_struct *task,
74 struct pt_regs *regs,
75 int error, long val)
77 if (error) {
78 syscall_set_error(regs);
79 regs->u_regs[UREG_I0] = -error;
80 } else {
81 syscall_clear_error(regs);
82 regs->u_regs[UREG_I0] = val;
86 static inline void syscall_get_arguments(struct task_struct *task,
87 struct pt_regs *regs,
88 unsigned int i, unsigned int n,
89 unsigned long *args)
91 int zero_extend = 0;
92 unsigned int j;
94 #ifdef CONFIG_SPARC64
95 if (test_tsk_thread_flag(task, TIF_32BIT))
96 zero_extend = 1;
97 #endif
99 for (j = 0; j < n; j++) {
100 unsigned long val = regs->u_regs[UREG_I0 + i + j];
102 if (zero_extend)
103 args[j] = (u32) val;
104 else
105 args[j] = val;
109 static inline void syscall_set_arguments(struct task_struct *task,
110 struct pt_regs *regs,
111 unsigned int i, unsigned int n,
112 const unsigned long *args)
114 unsigned int j;
116 for (j = 0; j < n; j++)
117 regs->u_regs[UREG_I0 + i + j] = args[j];
120 #endif /* __ASM_SPARC_SYSCALL_H */