595057191c9cc9245e2287ee7aa03e3e84c8552f
[sfrench/cifs-2.6.git] / arch / c6x / include / asm / syscall.h
1 /*
2  * Copyright (C) 2011 Texas Instruments Incorporated
3  * Author: Mark Salter <msalter@redhat.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  */
10
11 #ifndef __ASM_C6X_SYSCALL_H
12 #define __ASM_C6X_SYSCALL_H
13
14 #include <uapi/linux/audit.h>
15 #include <linux/err.h>
16 #include <linux/sched.h>
17
18 static inline int syscall_get_nr(struct task_struct *task,
19                                  struct pt_regs *regs)
20 {
21         return regs->b0;
22 }
23
24 static inline void syscall_rollback(struct task_struct *task,
25                                     struct pt_regs *regs)
26 {
27         /* do nothing */
28 }
29
30 static inline long syscall_get_error(struct task_struct *task,
31                                      struct pt_regs *regs)
32 {
33         return IS_ERR_VALUE(regs->a4) ? regs->a4 : 0;
34 }
35
36 static inline long syscall_get_return_value(struct task_struct *task,
37                                             struct pt_regs *regs)
38 {
39         return regs->a4;
40 }
41
42 static inline void syscall_set_return_value(struct task_struct *task,
43                                             struct pt_regs *regs,
44                                             int error, long val)
45 {
46         regs->a4 = error ?: val;
47 }
48
49 static inline void syscall_get_arguments(struct task_struct *task,
50                                          struct pt_regs *regs, unsigned int i,
51                                          unsigned int n, unsigned long *args)
52 {
53         switch (i) {
54         case 0:
55                 if (!n--)
56                         break;
57                 *args++ = regs->a4;
58         case 1:
59                 if (!n--)
60                         break;
61                 *args++ = regs->b4;
62         case 2:
63                 if (!n--)
64                         break;
65                 *args++ = regs->a6;
66         case 3:
67                 if (!n--)
68                         break;
69                 *args++ = regs->b6;
70         case 4:
71                 if (!n--)
72                         break;
73                 *args++ = regs->a8;
74         case 5:
75                 if (!n--)
76                         break;
77                 *args++ = regs->b8;
78         case 6:
79                 if (!n--)
80                         break;
81         default:
82                 BUG();
83         }
84 }
85
86 static inline void syscall_set_arguments(struct task_struct *task,
87                                          struct pt_regs *regs,
88                                          unsigned int i, unsigned int n,
89                                          const unsigned long *args)
90 {
91         switch (i) {
92         case 0:
93                 if (!n--)
94                         break;
95                 regs->a4 = *args++;
96         case 1:
97                 if (!n--)
98                         break;
99                 regs->b4 = *args++;
100         case 2:
101                 if (!n--)
102                         break;
103                 regs->a6 = *args++;
104         case 3:
105                 if (!n--)
106                         break;
107                 regs->b6 = *args++;
108         case 4:
109                 if (!n--)
110                         break;
111                 regs->a8 = *args++;
112         case 5:
113                 if (!n--)
114                         break;
115                 regs->a9 = *args++;
116         case 6:
117                 if (!n)
118                         break;
119         default:
120                 BUG();
121         }
122 }
123
124 static inline int syscall_get_arch(struct task_struct *task)
125 {
126         return IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
127                 ? AUDIT_ARCH_C6XBE : AUDIT_ARCH_C6X;
128 }
129
130 #endif /* __ASM_C6X_SYSCALLS_H */