Linux 2.6.28-rc5
[cris-mirror.git] / arch / s390 / include / asm / syscall.h
blob6e623971fbb9ae234ad80c450b6da43fa2a68fc4
1 /*
2 * Access to user system call parameters and results
4 * Copyright IBM Corp. 2008
5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License (version 2 only)
9 * as published by the Free Software Foundation.
12 #ifndef _ASM_SYSCALL_H
13 #define _ASM_SYSCALL_H 1
15 #include <asm/ptrace.h>
17 static inline long syscall_get_nr(struct task_struct *task,
18 struct pt_regs *regs)
20 if (regs->trap != __LC_SVC_OLD_PSW)
21 return -1;
22 return regs->gprs[2];
25 static inline void syscall_rollback(struct task_struct *task,
26 struct pt_regs *regs)
28 regs->gprs[2] = regs->orig_gpr2;
31 static inline long syscall_get_error(struct task_struct *task,
32 struct pt_regs *regs)
34 return (regs->gprs[2] >= -4096UL) ? -regs->gprs[2] : 0;
37 static inline long syscall_get_return_value(struct task_struct *task,
38 struct pt_regs *regs)
40 return regs->gprs[2];
43 static inline void syscall_set_return_value(struct task_struct *task,
44 struct pt_regs *regs,
45 int error, long val)
47 regs->gprs[2] = error ? -error : val;
50 static inline void syscall_get_arguments(struct task_struct *task,
51 struct pt_regs *regs,
52 unsigned int i, unsigned int n,
53 unsigned long *args)
55 BUG_ON(i + n > 6);
56 #ifdef CONFIG_COMPAT
57 if (test_tsk_thread_flag(task, TIF_31BIT)) {
58 if (i + n == 6)
59 args[--n] = (u32) regs->args[0];
60 while (n-- > 0)
61 args[n] = (u32) regs->gprs[2 + i + n];
63 #endif
64 if (i + n == 6)
65 args[--n] = regs->args[0];
66 memcpy(args, &regs->gprs[2 + i], n * sizeof(args[0]));
69 static inline void syscall_set_arguments(struct task_struct *task,
70 struct pt_regs *regs,
71 unsigned int i, unsigned int n,
72 const unsigned long *args)
74 BUG_ON(i + n > 6);
75 if (i + n == 6)
76 regs->args[0] = args[--n];
77 memcpy(&regs->gprs[2 + i], args, n * sizeof(args[0]));
80 #endif /* _ASM_SYSCALL_H */