diff options
author | Richard Kuo <rkuo@codeaurora.org> | 2011-10-31 19:35:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-01 10:34:18 -0400 |
commit | b9398a84590be3a828c168ed25bf1fd3d637988a (patch) | |
tree | 8467675f8d6787c7036beb3ddf599249a7903658 /arch/hexagon/kernel | |
parent | 750850189b2b7e43c03f33bf5741887e8ca07d16 (diff) |
Hexagon: Add syscalls
Signed-off-by: Richard Kuo <rkuo@codeaurora.org>
Signed-off-by: Linas Vepstas <linas@codeaurora.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/hexagon/kernel')
-rw-r--r-- | arch/hexagon/kernel/syscall.c | 90 | ||||
-rw-r--r-- | arch/hexagon/kernel/syscalltab.c | 32 |
2 files changed, 122 insertions, 0 deletions
diff --git a/arch/hexagon/kernel/syscall.c b/arch/hexagon/kernel/syscall.c new file mode 100644 index 000000000000..620dd18197a0 --- /dev/null +++ b/arch/hexagon/kernel/syscall.c | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | * Hexagon system calls | ||
3 | * | ||
4 | * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 and | ||
8 | * only version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
18 | * 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/file.h> | ||
22 | #include <linux/fs.h> | ||
23 | #include <linux/linkage.h> | ||
24 | #include <linux/mm.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/sched.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/syscalls.h> | ||
29 | #include <linux/unistd.h> | ||
30 | #include <asm/mman.h> | ||
31 | #include <asm/registers.h> | ||
32 | |||
33 | /* | ||
34 | * System calls with architecture-specific wrappers. | ||
35 | * See signal.c for signal-related system call wrappers. | ||
36 | */ | ||
37 | |||
38 | asmlinkage int sys_execve(char __user *ufilename, | ||
39 | const char __user *const __user *argv, | ||
40 | const char __user *const __user *envp) | ||
41 | { | ||
42 | struct pt_regs *pregs = current_thread_info()->regs; | ||
43 | char *filename; | ||
44 | int retval; | ||
45 | |||
46 | filename = getname(ufilename); | ||
47 | retval = PTR_ERR(filename); | ||
48 | if (IS_ERR(filename)) | ||
49 | return retval; | ||
50 | |||
51 | retval = do_execve(filename, argv, envp, pregs); | ||
52 | putname(filename); | ||
53 | |||
54 | return retval; | ||
55 | } | ||
56 | |||
57 | asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, | ||
58 | unsigned long parent_tidp, unsigned long child_tidp) | ||
59 | { | ||
60 | struct pt_regs *pregs = current_thread_info()->regs; | ||
61 | |||
62 | if (!newsp) | ||
63 | newsp = pregs->SP; | ||
64 | return do_fork(clone_flags, newsp, pregs, 0, (int __user *)parent_tidp, | ||
65 | (int __user *)child_tidp); | ||
66 | } | ||
67 | |||
68 | /* | ||
69 | * Do a system call from the kernel, so as to have a proper pt_regs | ||
70 | * and recycle the sys_execvpe infrustructure. | ||
71 | */ | ||
72 | int kernel_execve(const char *filename, | ||
73 | const char *const argv[], const char *const envp[]) | ||
74 | { | ||
75 | register unsigned long __a0 asm("r0") = (unsigned long) filename; | ||
76 | register unsigned long __a1 asm("r1") = (unsigned long) argv; | ||
77 | register unsigned long __a2 asm("r2") = (unsigned long) envp; | ||
78 | int retval; | ||
79 | |||
80 | __asm__ volatile( | ||
81 | " R6 = #%4;\n" | ||
82 | " trap0(#1);\n" | ||
83 | " %0 = R0;\n" | ||
84 | : "=r" (retval) | ||
85 | : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_execve) | ||
86 | ); | ||
87 | |||
88 | return retval; | ||
89 | } | ||
90 | EXPORT_SYMBOL(kernel_execve); | ||
diff --git a/arch/hexagon/kernel/syscalltab.c b/arch/hexagon/kernel/syscalltab.c new file mode 100644 index 000000000000..c550f4177ab8 --- /dev/null +++ b/arch/hexagon/kernel/syscalltab.c | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | * System call table for Hexagon | ||
3 | * | ||
4 | * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 and | ||
8 | * only version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
18 | * 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/syscalls.h> | ||
22 | #include <linux/signal.h> | ||
23 | #include <linux/unistd.h> | ||
24 | |||
25 | #include <asm/syscall.h> | ||
26 | |||
27 | #undef __SYSCALL | ||
28 | #define __SYSCALL(nr, call) [nr] = (call), | ||
29 | |||
30 | void *sys_call_table[__NR_syscalls] = { | ||
31 | #include <asm/unistd.h> | ||
32 | }; | ||