1*344aa361SAndroid Build Coastguard Worker /*
2*344aa361SAndroid Build Coastguard Worker * Copyright (c) 2013, Google, Inc. All rights reserved
3*344aa361SAndroid Build Coastguard Worker *
4*344aa361SAndroid Build Coastguard Worker * Permission is hereby granted, free of charge, to any person obtaining
5*344aa361SAndroid Build Coastguard Worker * a copy of this software and associated documentation files
6*344aa361SAndroid Build Coastguard Worker * (the "Software"), to deal in the Software without restriction,
7*344aa361SAndroid Build Coastguard Worker * including without limitation the rights to use, copy, modify, merge,
8*344aa361SAndroid Build Coastguard Worker * publish, distribute, sublicense, and/or sell copies of the Software,
9*344aa361SAndroid Build Coastguard Worker * and to permit persons to whom the Software is furnished to do so,
10*344aa361SAndroid Build Coastguard Worker * subject to the following conditions:
11*344aa361SAndroid Build Coastguard Worker *
12*344aa361SAndroid Build Coastguard Worker * The above copyright notice and this permission notice shall be
13*344aa361SAndroid Build Coastguard Worker * included in all copies or substantial portions of the Software.
14*344aa361SAndroid Build Coastguard Worker *
15*344aa361SAndroid Build Coastguard Worker * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16*344aa361SAndroid Build Coastguard Worker * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17*344aa361SAndroid Build Coastguard Worker * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18*344aa361SAndroid Build Coastguard Worker * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19*344aa361SAndroid Build Coastguard Worker * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20*344aa361SAndroid Build Coastguard Worker * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21*344aa361SAndroid Build Coastguard Worker * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22*344aa361SAndroid Build Coastguard Worker */
23*344aa361SAndroid Build Coastguard Worker
24*344aa361SAndroid Build Coastguard Worker /* System call table definition
25*344aa361SAndroid Build Coastguard Worker * ============================
26*344aa361SAndroid Build Coastguard Worker *
27*344aa361SAndroid Build Coastguard Worker * The user of this library must:
28*344aa361SAndroid Build Coastguard Worker *
29*344aa361SAndroid Build Coastguard Worker * - define WITH_SYSCALL_TABLE
30*344aa361SAndroid Build Coastguard Worker * - provide a file named syscall_table.h in the include path
31*344aa361SAndroid Build Coastguard Worker * - provide DEF_SYSCALL macros in syscall_table.h with
32*344aa361SAndroid Build Coastguard Worker * number, name, #args followed by argument type defintions.
33*344aa361SAndroid Build Coastguard Worker */
34*344aa361SAndroid Build Coastguard Worker #include <compiler.h>
35*344aa361SAndroid Build Coastguard Worker #include <debug.h>
36*344aa361SAndroid Build Coastguard Worker #include <err.h>
37*344aa361SAndroid Build Coastguard Worker #include <kernel/thread.h>
38*344aa361SAndroid Build Coastguard Worker
sys_undefined(int num)39*344aa361SAndroid Build Coastguard Worker long sys_undefined(int num) {
40*344aa361SAndroid Build Coastguard Worker dprintf(SPEW, "%p invalid syscall %d requested\n", get_current_thread(),
41*344aa361SAndroid Build Coastguard Worker num);
42*344aa361SAndroid Build Coastguard Worker return ERR_NOT_SUPPORTED;
43*344aa361SAndroid Build Coastguard Worker }
44*344aa361SAndroid Build Coastguard Worker
45*344aa361SAndroid Build Coastguard Worker #ifdef WITH_SYSCALL_TABLE
46*344aa361SAndroid Build Coastguard Worker
47*344aa361SAndroid Build Coastguard Worker /* Generate fake function prototypes */
48*344aa361SAndroid Build Coastguard Worker #define DEF_SYSCALL(nr, fn, rtype, nr_args, ...) rtype sys_##fn(void);
49*344aa361SAndroid Build Coastguard Worker #include <syscall_table.h>
50*344aa361SAndroid Build Coastguard Worker #undef DEF_SYSCALL
51*344aa361SAndroid Build Coastguard Worker
52*344aa361SAndroid Build Coastguard Worker #endif
53*344aa361SAndroid Build Coastguard Worker
54*344aa361SAndroid Build Coastguard Worker #define DEF_SYSCALL(nr, fn, rtype, nr_args, ...) \
55*344aa361SAndroid Build Coastguard Worker [(nr)] = (unsigned long)(sys_##fn),
56*344aa361SAndroid Build Coastguard Worker const unsigned long syscall_table[] = {
57*344aa361SAndroid Build Coastguard Worker
58*344aa361SAndroid Build Coastguard Worker #ifdef WITH_SYSCALL_TABLE
59*344aa361SAndroid Build Coastguard Worker #include <syscall_table.h>
60*344aa361SAndroid Build Coastguard Worker #endif
61*344aa361SAndroid Build Coastguard Worker
62*344aa361SAndroid Build Coastguard Worker };
63*344aa361SAndroid Build Coastguard Worker #undef DEF_SYSCALL
64*344aa361SAndroid Build Coastguard Worker
65*344aa361SAndroid Build Coastguard Worker unsigned long nr_syscalls = countof(syscall_table);
66