Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / mn10300 / include / asm / syscall.h
blobb44b0bb75a011b90bc3543198c1d73b116c8bbef
1 /* Access to user system call parameters and results
3 * See asm-generic/syscall.h for function descriptions.
5 * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
6 * Written by David Howells (dhowells@redhat.com)
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public Licence
10 * as published by the Free Software Foundation; either version
11 * 2 of the Licence, or (at your option) any later version.
14 #ifndef _ASM_SYSCALL_H
15 #define _ASM_SYSCALL_H
17 #include <linux/sched.h>
18 #include <linux/err.h>
20 extern const unsigned long sys_call_table[];
22 static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
24 return regs->orig_d0;
27 static inline void syscall_rollback(struct task_struct *task,
28 struct pt_regs *regs)
30 regs->d0 = regs->orig_d0;
33 static inline long syscall_get_error(struct task_struct *task,
34 struct pt_regs *regs)
36 unsigned long error = regs->d0;
37 return IS_ERR_VALUE(error) ? error : 0;
40 static inline long syscall_get_return_value(struct task_struct *task,
41 struct pt_regs *regs)
43 return regs->d0;
46 static inline void syscall_set_return_value(struct task_struct *task,
47 struct pt_regs *regs,
48 int error, long val)
50 regs->d0 = (long) error ?: val;
53 static inline void syscall_get_arguments(struct task_struct *task,
54 struct pt_regs *regs,
55 unsigned int i, unsigned int n,
56 unsigned long *args)
58 switch (i) {
59 case 0:
60 if (!n--) break;
61 *args++ = regs->a0;
62 case 1:
63 if (!n--) break;
64 *args++ = regs->d1;
65 case 2:
66 if (!n--) break;
67 *args++ = regs->a3;
68 case 3:
69 if (!n--) break;
70 *args++ = regs->a2;
71 case 4:
72 if (!n--) break;
73 *args++ = regs->d3;
74 case 5:
75 if (!n--) break;
76 *args++ = regs->d2;
77 case 6:
78 if (!n--) break;
79 default:
80 BUG();
81 break;
85 static inline void syscall_set_arguments(struct task_struct *task,
86 struct pt_regs *regs,
87 unsigned int i, unsigned int n,
88 const unsigned long *args)
90 switch (i) {
91 case 0:
92 if (!n--) break;
93 regs->a0 = *args++;
94 case 1:
95 if (!n--) break;
96 regs->d1 = *args++;
97 case 2:
98 if (!n--) break;
99 regs->a3 = *args++;
100 case 3:
101 if (!n--) break;
102 regs->a2 = *args++;
103 case 4:
104 if (!n--) break;
105 regs->d3 = *args++;
106 case 5:
107 if (!n--) break;
108 regs->d2 = *args++;
109 case 6:
110 if (!n--) break;
111 default:
112 BUG();
113 break;
117 #endif /* _ASM_SYSCALL_H */