• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _INC_SYSCALL_DEFS_H_
18 #define _INC_SYSCALL_DEFS_H_
19 
20 #include <cpu/syscallDo.h>
21 
22 /* it is always safe to use this, but using syscallDo0P .. syscallDo4P macros may produce faster code for free */
syscallDoGeneric(uint32_t syscallNo,...)23 static inline uintptr_t syscallDoGeneric(uint32_t syscallNo, ...)
24 {
25     uintptr_t ret;
26     va_list vl;
27 
28     va_start(vl, syscallNo);
29     #ifdef SYSCALL_PARAMS_PASSED_AS_PTRS
30         ret = cpuSyscallDo(syscallNo, &vl);
31     #else
32         ret = cpuSyscallDo(syscallNo, *(uint32_t*)&vl);
33     #endif
34     va_end(vl);
35 
36     return ret;
37 }
38 
39 #ifdef cpuSyscallDo0P
40     #define syscallDo0P(syscallNo) cpuSyscallDo0P(syscallNo)
41 #else
42     #define syscallDo0P(syscallNo) syscallDoGeneric(syscallNo)
43 #endif
44 
45 #ifdef cpuSyscallDo1P
46     #define syscallDo1P(syscallNo,p1) cpuSyscallDo1P(syscallNo,p1)
47 #else
48     #define syscallDo1P(syscallNo,p1) syscallDoGeneric(syscallNo,p1)
49 #endif
50 
51 #ifdef cpuSyscallDo2P
52     #define syscallDo2P(syscallNo,p1,p2) cpuSyscallDo2P(syscallNo,p1,p2)
53 #else
54     #define syscallDo2P(syscallNo,p1,p2) syscallDoGeneric(syscallNo,p1,p2)
55 #endif
56 
57 #ifdef cpuSyscallDo3P
58     #define syscallDo3P(syscallNo,p1,p2,p3) cpuSyscallDo3P(syscallNo,p1,p2,p3)
59 #else
60     #define syscallDo3P(syscallNo,p1,p2,p3) syscallDoGeneric(syscallNo,p1,p2,p3)
61 #endif
62 
63 #ifdef cpuSyscallDo4P
64     #define syscallDo4P(syscallNo,p1,p2,p3,p4) cpuSyscallDo4P(syscallNo,p1,p2,p3,p4)
65 #else
66     #define syscallDo4P(syscallNo,p1,p2,p3,p4) syscallDoGeneric(syscallNo,p1,p2,p3,p4)
67 #endif
68 
69 #ifdef cpuSyscallDo5P
70     #define syscallDo5P(syscallNo,p1,p2,p3,p4,p5) cpuSyscallDo5P(syscallNo,p1,p2,p3,p4,p5)
71 #else
72     #define syscallDo5P(syscallNo,p1,p2,p3,p4,p5) syscallDoGeneric(syscallNo,p1,p2,p3,p4,p5)
73 #endif
74 
75 #ifdef cpuSyscallDo6P
76     #define syscallDo6P(syscallNo,p1,p2,p3,p4,p5,p6) cpuSyscallDo5P(syscallNo,p1,p2,p3,p4,p5,p6)
77 #else
78     #define syscallDo6P(syscallNo,p1,p2,p3,p4,p5,p6) syscallDoGeneric(syscallNo,p1,p2,p3,p4,p5,p6)
79 #endif
80 
81 #endif /* _INC_SYSCALL_DEFS_H_ */
82