x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub
[linux/fpc-iii.git] / arch / sparc / include / asm / syscall.h
blob025a02ad2e31c9a87c15350241234b8943e04ae6
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 /*
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,
17 struct pt_regs *regs)
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,
25 struct pt_regs *regs)
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.
36 #ifdef CONFIG_SPARC32
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)
43 regs->psr |= PSR_C;
45 static inline void syscall_clear_error(struct pt_regs *regs)
47 regs->psr &= ~PSR_C;
49 #else
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);
62 #endif
64 static inline long syscall_get_error(struct task_struct *task,
65 struct pt_regs *regs)
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,
73 struct pt_regs *regs)
75 long val = regs->u_regs[UREG_I0];
77 return val;
80 static inline void syscall_set_return_value(struct task_struct *task,
81 struct pt_regs *regs,
82 int error, long val)
84 if (error) {
85 syscall_set_error(regs);
86 regs->u_regs[UREG_I0] = -error;
87 } else {
88 syscall_clear_error(regs);
89 regs->u_regs[UREG_I0] = val;
93 static inline void syscall_get_arguments(struct task_struct *task,
94 struct pt_regs *regs,
95 unsigned int i, unsigned int n,
96 unsigned long *args)
98 int zero_extend = 0;
99 unsigned int j;
101 #ifdef CONFIG_SPARC64
102 if (test_tsk_thread_flag(task, TIF_32BIT))
103 zero_extend = 1;
104 #endif
106 for (j = 0; j < n; j++) {
107 unsigned long val = regs->u_regs[UREG_I0 + i + j];
109 if (zero_extend)
110 args[j] = (u32) val;
111 else
112 args[j] = val;
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)
121 unsigned int j;
123 for (j = 0; j < n; j++)
124 regs->u_regs[UREG_I0 + i + j] = args[j];
127 #endif /* __ASM_SPARC_SYSCALL_H */