Commit | Line | Data |
---|---|---|
7dcbbb2b MS |
1 | /* |
2 | * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu> | |
3 | * Copyright (C) 2007-2009 PetaLogix | |
4 | * Copyright (C) 2007 John Williams <john.williams@petalogix.com> | |
5 | * | |
6 | * Copyright (C) 2006 Atmark Techno, Inc. | |
7 | * Yasushi SHOJI <yashi@atmark-techno.com> | |
8 | * Tetsuya OHKAWA <tetsuya@atmark-techno.com> | |
9 | * | |
10 | * This file is subject to the terms and conditions of the GNU General Public | |
11 | * License. See the file "COPYING" in the main directory of this archive | |
12 | * for more details. | |
13 | */ | |
14 | ||
15 | #include <linux/errno.h> | |
16 | #include <linux/mm.h> | |
17 | #include <linux/smp.h> | |
7dcbbb2b MS |
18 | #include <linux/syscalls.h> |
19 | #include <linux/sem.h> | |
20 | #include <linux/msg.h> | |
21 | #include <linux/shm.h> | |
22 | #include <linux/stat.h> | |
23 | #include <linux/mman.h> | |
24 | #include <linux/sys.h> | |
25 | #include <linux/ipc.h> | |
7dcbbb2b MS |
26 | #include <linux/file.h> |
27 | #include <linux/module.h> | |
28 | #include <linux/err.h> | |
29 | #include <linux/fs.h> | |
7dcbbb2b | 30 | #include <linux/semaphore.h> |
7dcbbb2b MS |
31 | #include <linux/uaccess.h> |
32 | #include <linux/unistd.h> | |
5a0e3ad6 | 33 | #include <linux/slab.h> |
7dcbbb2b MS |
34 | |
35 | #include <asm/syscalls.h> | |
7dcbbb2b | 36 | |
e513588f | 37 | asmlinkage long microblaze_vfork(struct pt_regs *regs) |
7dcbbb2b MS |
38 | { |
39 | return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->r1, | |
40 | regs, 0, NULL, NULL); | |
41 | } | |
42 | ||
e513588f | 43 | asmlinkage long microblaze_clone(int flags, unsigned long stack, struct pt_regs *regs) |
7dcbbb2b MS |
44 | { |
45 | if (!stack) | |
46 | stack = regs->r1; | |
47 | return do_fork(flags, stack, regs, 0, NULL, NULL); | |
48 | } | |
49 | ||
c7887325 | 50 | asmlinkage long microblaze_execve(const char __user *filenamei, char __user *__user *argv, |
7dcbbb2b MS |
51 | char __user *__user *envp, struct pt_regs *regs) |
52 | { | |
53 | int error; | |
54 | char *filename; | |
55 | ||
56 | filename = getname(filenamei); | |
57 | error = PTR_ERR(filename); | |
58 | if (IS_ERR(filename)) | |
59 | goto out; | |
60 | error = do_execve(filename, argv, envp, regs); | |
61 | putname(filename); | |
62 | out: | |
63 | return error; | |
64 | } | |
65 | ||
e513588f | 66 | asmlinkage long sys_mmap(unsigned long addr, unsigned long len, |
7dcbbb2b | 67 | unsigned long prot, unsigned long flags, |
e513588f | 68 | unsigned long fd, off_t pgoff) |
7dcbbb2b | 69 | { |
f8b72560 AV |
70 | if (pgoff & ~PAGE_MASK) |
71 | return -EINVAL; | |
7dcbbb2b | 72 | |
f8b72560 | 73 | return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff >> PAGE_SHIFT); |
7dcbbb2b MS |
74 | } |
75 | ||
76 | /* | |
77 | * Do a system call from kernel instead of calling sys_execve so we | |
78 | * end up with proper pt_regs. | |
79 | */ | |
80 | int kernel_execve(const char *filename, char *const argv[], char *const envp[]) | |
81 | { | |
82 | register const char *__a __asm__("r5") = filename; | |
83 | register const void *__b __asm__("r6") = argv; | |
84 | register const void *__c __asm__("r7") = envp; | |
85 | register unsigned long __syscall __asm__("r12") = __NR_execve; | |
86 | register unsigned long __ret __asm__("r3"); | |
87 | __asm__ __volatile__ ("brki r14, 0x8" | |
88 | : "=r" (__ret), "=r" (__syscall) | |
89 | : "1" (__syscall), "r" (__a), "r" (__b), "r" (__c) | |
90 | : "r4", "r8", "r9", | |
91 | "r10", "r11", "r14", "cc", "memory"); | |
92 | return __ret; | |
93 | } |