Full support for Ginger Console
[linux-ginger.git] / arch / s390 / include / asm / syscall.h
blobe0a73d3eb8371be3bb599413aa09cd65a7f7da56
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 <linux/sched.h>
16 #include <asm/ptrace.h>
18 static inline long syscall_get_nr(struct task_struct *task,
19 struct pt_regs *regs)
21 return regs->svcnr ? regs->svcnr : -1;
24 static inline void syscall_rollback(struct task_struct *task,
25 struct pt_regs *regs)
27 regs->gprs[2] = regs->orig_gpr2;
30 static inline long syscall_get_error(struct task_struct *task,
31 struct pt_regs *regs)
33 return (regs->gprs[2] >= -4096UL) ? -regs->gprs[2] : 0;
36 static inline long syscall_get_return_value(struct task_struct *task,
37 struct pt_regs *regs)
39 return regs->gprs[2];
42 static inline void syscall_set_return_value(struct task_struct *task,
43 struct pt_regs *regs,
44 int error, long val)
46 regs->gprs[2] = error ? -error : val;
49 static inline void syscall_get_arguments(struct task_struct *task,
50 struct pt_regs *regs,
51 unsigned int i, unsigned int n,
52 unsigned long *args)
54 unsigned long mask = -1UL;
56 BUG_ON(i + n > 6);
57 #ifdef CONFIG_COMPAT
58 if (test_tsk_thread_flag(task, TIF_31BIT))
59 mask = 0xffffffff;
60 #endif
61 if (i + n == 6)
62 args[--n] = regs->args[0] & mask;
63 while (n-- > 0)
64 if (i + n > 0)
65 args[n] = regs->gprs[2 + i + n] & mask;
66 if (i == 0)
67 args[0] = regs->orig_gpr2 & mask;
70 static inline void syscall_set_arguments(struct task_struct *task,
71 struct pt_regs *regs,
72 unsigned int i, unsigned int n,
73 const unsigned long *args)
75 BUG_ON(i + n > 6);
76 if (i + n == 6)
77 regs->args[0] = args[--n];
78 while (n-- > 0)
79 if (i + n > 0)
80 regs->gprs[2 + i + n] = args[n];
81 if (i == 0)
82 regs->orig_gpr2 = args[0];
85 #endif /* _ASM_SYSCALL_H */