]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/arch/m68knommu/kernel/sys_m68k.c | |
3 | * | |
4 | * This file contains various random system calls that | |
5 | * have a non-standard calling sequence on the Linux/m68k | |
6 | * platform. | |
7 | */ | |
8 | ||
9 | #include <linux/errno.h> | |
10 | #include <linux/sched.h> | |
11 | #include <linux/mm.h> | |
12 | #include <linux/smp.h> | |
1da177e4 LT |
13 | #include <linux/sem.h> |
14 | #include <linux/msg.h> | |
15 | #include <linux/shm.h> | |
16 | #include <linux/stat.h> | |
17 | #include <linux/syscalls.h> | |
18 | #include <linux/mman.h> | |
19 | #include <linux/file.h> | |
cba4fbbf | 20 | #include <linux/ipc.h> |
405d2965 | 21 | #include <linux/fs.h> |
1da177e4 LT |
22 | |
23 | #include <asm/setup.h> | |
24 | #include <asm/uaccess.h> | |
25 | #include <asm/cachectl.h> | |
26 | #include <asm/traps.h> | |
1da177e4 | 27 | #include <asm/cacheflush.h> |
fe74290d | 28 | #include <asm/unistd.h> |
1da177e4 | 29 | |
1da177e4 LT |
30 | /* |
31 | * sys_ipc() is the de-multiplexer for the SysV IPC calls.. | |
32 | * | |
33 | * This is really horribly ugly. | |
34 | */ | |
35 | asmlinkage int sys_ipc (uint call, int first, int second, | |
36 | int third, void *ptr, long fifth) | |
37 | { | |
1bddcc50 | 38 | int version, ret; |
1da177e4 LT |
39 | |
40 | version = call >> 16; /* hack for backward compatibility */ | |
41 | call &= 0xffff; | |
42 | ||
43 | if (call <= SEMCTL) | |
44 | switch (call) { | |
45 | case SEMOP: | |
46 | return sys_semop (first, (struct sembuf *)ptr, second); | |
47 | case SEMGET: | |
48 | return sys_semget (first, second, third); | |
49 | case SEMCTL: { | |
50 | union semun fourth; | |
51 | if (!ptr) | |
52 | return -EINVAL; | |
53 | if (get_user(fourth.__pad, (void **) ptr)) | |
54 | return -EFAULT; | |
55 | return sys_semctl (first, second, third, fourth); | |
56 | } | |
57 | default: | |
58 | return -EINVAL; | |
59 | } | |
60 | if (call <= MSGCTL) | |
61 | switch (call) { | |
62 | case MSGSND: | |
63 | return sys_msgsnd (first, (struct msgbuf *) ptr, | |
64 | second, third); | |
65 | case MSGRCV: | |
66 | switch (version) { | |
67 | case 0: { | |
68 | struct ipc_kludge tmp; | |
69 | if (!ptr) | |
70 | return -EINVAL; | |
71 | if (copy_from_user (&tmp, | |
72 | (struct ipc_kludge *)ptr, | |
73 | sizeof (tmp))) | |
74 | return -EFAULT; | |
75 | return sys_msgrcv (first, tmp.msgp, second, | |
76 | tmp.msgtyp, third); | |
77 | } | |
78 | default: | |
79 | return sys_msgrcv (first, | |
80 | (struct msgbuf *) ptr, | |
81 | second, fifth, third); | |
82 | } | |
83 | case MSGGET: | |
84 | return sys_msgget ((key_t) first, second); | |
85 | case MSGCTL: | |
86 | return sys_msgctl (first, second, | |
87 | (struct msqid_ds *) ptr); | |
88 | default: | |
89 | return -EINVAL; | |
90 | } | |
1bddcc50 DW |
91 | if (call <= SHMCTL) |
92 | switch (call) { | |
93 | case SHMAT: | |
94 | switch (version) { | |
95 | default: { | |
96 | ulong raddr; | |
97 | ret = do_shmat (first, ptr, second, &raddr); | |
98 | if (ret) | |
99 | return ret; | |
100 | return put_user (raddr, (ulong __user *) third); | |
101 | } | |
102 | } | |
103 | case SHMDT: | |
104 | return sys_shmdt (ptr); | |
105 | case SHMGET: | |
106 | return sys_shmget (first, second, third); | |
107 | case SHMCTL: | |
108 | return sys_shmctl (first, second, ptr); | |
109 | default: | |
110 | return -ENOSYS; | |
111 | } | |
1da177e4 LT |
112 | |
113 | return -EINVAL; | |
114 | } | |
115 | ||
116 | /* sys_cacheflush -- flush (part of) the processor cache. */ | |
117 | asmlinkage int | |
118 | sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len) | |
119 | { | |
120 | flush_cache_all(); | |
121 | return(0); | |
122 | } | |
123 | ||
124 | asmlinkage int sys_getpagesize(void) | |
125 | { | |
126 | return PAGE_SIZE; | |
127 | } | |
128 | ||
fe74290d AB |
129 | /* |
130 | * Do a system call from kernel instead of calling sys_execve so we | |
131 | * end up with proper pt_regs. | |
132 | */ | |
133 | int kernel_execve(const char *filename, char *const argv[], char *const envp[]) | |
134 | { | |
135 | register long __res asm ("%d0") = __NR_execve; | |
136 | register long __a asm ("%d1") = (long)(filename); | |
137 | register long __b asm ("%d2") = (long)(argv); | |
138 | register long __c asm ("%d3") = (long)(envp); | |
139 | asm volatile ("trap #0" : "+d" (__res) | |
140 | : "d" (__a), "d" (__b), "d" (__c)); | |
141 | return __res; | |
142 | } | |
a58f7534 MK |
143 | |
144 | asmlinkage unsigned long sys_get_thread_area(void) | |
145 | { | |
146 | return current_thread_info()->tp_value; | |
147 | } | |
148 | ||
149 | asmlinkage int sys_set_thread_area(unsigned long tp) | |
150 | { | |
151 | current_thread_info()->tp_value = tp; | |
152 | return 0; | |
153 | } | |
154 | ||
155 | /* This syscall gets its arguments in A0 (mem), D2 (oldval) and | |
156 | D1 (newval). */ | |
157 | asmlinkage int | |
158 | sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5, | |
159 | unsigned long __user * mem) | |
160 | { | |
161 | struct mm_struct *mm = current->mm; | |
162 | unsigned long mem_value; | |
163 | ||
164 | down_read(&mm->mmap_sem); | |
165 | ||
166 | mem_value = *mem; | |
167 | if (mem_value == oldval) | |
168 | *mem = newval; | |
169 | ||
170 | up_read(&mm->mmap_sem); | |
171 | return mem_value; | |
172 | } | |
173 | ||
174 | asmlinkage int sys_atomic_barrier(void) | |
175 | { | |
176 | /* no code needed for uniprocs */ | |
177 | return 0; | |
178 | } |