diff options
Diffstat (limited to 'arch/h8300/kernel/sys_h8300.c')
-rw-r--r-- | arch/h8300/kernel/sys_h8300.c | 282 |
1 files changed, 282 insertions, 0 deletions
diff --git a/arch/h8300/kernel/sys_h8300.c b/arch/h8300/kernel/sys_h8300.c new file mode 100644 index 000000000000..0f61b7ad69ab --- /dev/null +++ b/arch/h8300/kernel/sys_h8300.c | |||
@@ -0,0 +1,282 @@ | |||
1 | /* | ||
2 | * linux/arch/h8300/kernel/sys_h8300.c | ||
3 | * | ||
4 | * This file contains various random system calls that | ||
5 | * have a non-standard calling sequence on the H8/300 | ||
6 | * platform. | ||
7 | */ | ||
8 | |||
9 | #include <linux/errno.h> | ||
10 | #include <linux/sched.h> | ||
11 | #include <linux/mm.h> | ||
12 | #include <linux/smp.h> | ||
13 | #include <linux/smp_lock.h> | ||
14 | #include <linux/sem.h> | ||
15 | #include <linux/msg.h> | ||
16 | #include <linux/shm.h> | ||
17 | #include <linux/stat.h> | ||
18 | #include <linux/syscalls.h> | ||
19 | #include <linux/mman.h> | ||
20 | #include <linux/file.h> | ||
21 | #include <linux/utsname.h> | ||
22 | |||
23 | #include <asm/setup.h> | ||
24 | #include <asm/uaccess.h> | ||
25 | #include <asm/cachectl.h> | ||
26 | #include <asm/traps.h> | ||
27 | #include <asm/ipc.h> | ||
28 | |||
29 | /* | ||
30 | * sys_pipe() is the normal C calling standard for creating | ||
31 | * a pipe. It's not the way unix traditionally does this, though. | ||
32 | */ | ||
33 | asmlinkage int sys_pipe(unsigned long * fildes) | ||
34 | { | ||
35 | int fd[2]; | ||
36 | int error; | ||
37 | |||
38 | error = do_pipe(fd); | ||
39 | if (!error) { | ||
40 | if (copy_to_user(fildes, fd, 2*sizeof(int))) | ||
41 | error = -EFAULT; | ||
42 | } | ||
43 | return error; | ||
44 | } | ||
45 | |||
46 | /* common code for old and new mmaps */ | ||
47 | static inline long do_mmap2( | ||
48 | unsigned long addr, unsigned long len, | ||
49 | unsigned long prot, unsigned long flags, | ||
50 | unsigned long fd, unsigned long pgoff) | ||
51 | { | ||
52 | int error = -EBADF; | ||
53 | struct file * file = NULL; | ||
54 | |||
55 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | ||
56 | if (!(flags & MAP_ANONYMOUS)) { | ||
57 | file = fget(fd); | ||
58 | if (!file) | ||
59 | goto out; | ||
60 | } | ||
61 | |||
62 | down_write(¤t->mm->mmap_sem); | ||
63 | error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); | ||
64 | up_write(¤t->mm->mmap_sem); | ||
65 | |||
66 | if (file) | ||
67 | fput(file); | ||
68 | out: | ||
69 | return error; | ||
70 | } | ||
71 | |||
72 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, | ||
73 | unsigned long prot, unsigned long flags, | ||
74 | unsigned long fd, unsigned long pgoff) | ||
75 | { | ||
76 | return do_mmap2(addr, len, prot, flags, fd, pgoff); | ||
77 | } | ||
78 | |||
79 | /* | ||
80 | * Perform the select(nd, in, out, ex, tv) and mmap() system | ||
81 | * calls. Linux/m68k cloned Linux/i386, which didn't use to be able to | ||
82 | * handle more than 4 system call parameters, so these system calls | ||
83 | * used a memory block for parameter passing.. | ||
84 | */ | ||
85 | |||
86 | struct mmap_arg_struct { | ||
87 | unsigned long addr; | ||
88 | unsigned long len; | ||
89 | unsigned long prot; | ||
90 | unsigned long flags; | ||
91 | unsigned long fd; | ||
92 | unsigned long offset; | ||
93 | }; | ||
94 | |||
95 | asmlinkage int old_mmap(struct mmap_arg_struct *arg) | ||
96 | { | ||
97 | struct mmap_arg_struct a; | ||
98 | int error = -EFAULT; | ||
99 | |||
100 | if (copy_from_user(&a, arg, sizeof(a))) | ||
101 | goto out; | ||
102 | |||
103 | error = -EINVAL; | ||
104 | if (a.offset & ~PAGE_MASK) | ||
105 | goto out; | ||
106 | |||
107 | a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | ||
108 | |||
109 | error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT); | ||
110 | out: | ||
111 | return error; | ||
112 | } | ||
113 | |||
114 | #if 0 /* DAVIDM - do we want this */ | ||
115 | struct mmap_arg_struct64 { | ||
116 | __u32 addr; | ||
117 | __u32 len; | ||
118 | __u32 prot; | ||
119 | __u32 flags; | ||
120 | __u64 offset; /* 64 bits */ | ||
121 | __u32 fd; | ||
122 | }; | ||
123 | |||
124 | asmlinkage long sys_mmap64(struct mmap_arg_struct64 *arg) | ||
125 | { | ||
126 | int error = -EFAULT; | ||
127 | struct file * file = NULL; | ||
128 | struct mmap_arg_struct64 a; | ||
129 | unsigned long pgoff; | ||
130 | |||
131 | if (copy_from_user(&a, arg, sizeof(a))) | ||
132 | return -EFAULT; | ||
133 | |||
134 | if ((long)a.offset & ~PAGE_MASK) | ||
135 | return -EINVAL; | ||
136 | |||
137 | pgoff = a.offset >> PAGE_SHIFT; | ||
138 | if ((a.offset >> PAGE_SHIFT) != pgoff) | ||
139 | return -EINVAL; | ||
140 | |||
141 | if (!(a.flags & MAP_ANONYMOUS)) { | ||
142 | error = -EBADF; | ||
143 | file = fget(a.fd); | ||
144 | if (!file) | ||
145 | goto out; | ||
146 | } | ||
147 | a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | ||
148 | |||
149 | down_write(¤t->mm->mmap_sem); | ||
150 | error = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, pgoff); | ||
151 | up_write(¤t->mm->mmap_sem); | ||
152 | if (file) | ||
153 | fput(file); | ||
154 | out: | ||
155 | return error; | ||
156 | } | ||
157 | #endif | ||
158 | |||
159 | struct sel_arg_struct { | ||
160 | unsigned long n; | ||
161 | fd_set *inp, *outp, *exp; | ||
162 | struct timeval *tvp; | ||
163 | }; | ||
164 | |||
165 | asmlinkage int old_select(struct sel_arg_struct *arg) | ||
166 | { | ||
167 | struct sel_arg_struct a; | ||
168 | |||
169 | if (copy_from_user(&a, arg, sizeof(a))) | ||
170 | return -EFAULT; | ||
171 | /* sys_select() does the appropriate kernel locking */ | ||
172 | return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp); | ||
173 | } | ||
174 | |||
175 | /* | ||
176 | * sys_ipc() is the de-multiplexer for the SysV IPC calls.. | ||
177 | * | ||
178 | * This is really horribly ugly. | ||
179 | */ | ||
180 | asmlinkage int sys_ipc (uint call, int first, int second, | ||
181 | int third, void *ptr, long fifth) | ||
182 | { | ||
183 | int version, ret; | ||
184 | |||
185 | version = call >> 16; /* hack for backward compatibility */ | ||
186 | call &= 0xffff; | ||
187 | |||
188 | if (call <= SEMCTL) | ||
189 | switch (call) { | ||
190 | case SEMOP: | ||
191 | return sys_semop (first, (struct sembuf *)ptr, second); | ||
192 | case SEMGET: | ||
193 | return sys_semget (first, second, third); | ||
194 | case SEMCTL: { | ||
195 | union semun fourth; | ||
196 | if (!ptr) | ||
197 | return -EINVAL; | ||
198 | if (get_user(fourth.__pad, (void **) ptr)) | ||
199 | return -EFAULT; | ||
200 | return sys_semctl (first, second, third, fourth); | ||
201 | } | ||
202 | default: | ||
203 | return -EINVAL; | ||
204 | } | ||
205 | if (call <= MSGCTL) | ||
206 | switch (call) { | ||
207 | case MSGSND: | ||
208 | return sys_msgsnd (first, (struct msgbuf *) ptr, | ||
209 | second, third); | ||
210 | case MSGRCV: | ||
211 | switch (version) { | ||
212 | case 0: { | ||
213 | struct ipc_kludge tmp; | ||
214 | if (!ptr) | ||
215 | return -EINVAL; | ||
216 | if (copy_from_user (&tmp, | ||
217 | (struct ipc_kludge *)ptr, | ||
218 | sizeof (tmp))) | ||
219 | return -EFAULT; | ||
220 | return sys_msgrcv (first, tmp.msgp, second, | ||
221 | tmp.msgtyp, third); | ||
222 | } | ||
223 | default: | ||
224 | return sys_msgrcv (first, | ||
225 | (struct msgbuf *) ptr, | ||
226 | second, fifth, third); | ||
227 | } | ||
228 | case MSGGET: | ||
229 | return sys_msgget ((key_t) first, second); | ||
230 | case MSGCTL: | ||
231 | return sys_msgctl (first, second, | ||
232 | (struct msqid_ds *) ptr); | ||
233 | default: | ||
234 | return -EINVAL; | ||
235 | } | ||
236 | if (call <= SHMCTL) | ||
237 | switch (call) { | ||
238 | case SHMAT: | ||
239 | switch (version) { | ||
240 | default: { | ||
241 | ulong raddr; | ||
242 | ret = do_shmat (first, (char *) ptr, | ||
243 | second, &raddr); | ||
244 | if (ret) | ||
245 | return ret; | ||
246 | return put_user (raddr, (ulong *) third); | ||
247 | } | ||
248 | } | ||
249 | case SHMDT: | ||
250 | return sys_shmdt ((char *)ptr); | ||
251 | case SHMGET: | ||
252 | return sys_shmget (first, second, third); | ||
253 | case SHMCTL: | ||
254 | return sys_shmctl (first, second, | ||
255 | (struct shmid_ds *) ptr); | ||
256 | default: | ||
257 | return -EINVAL; | ||
258 | } | ||
259 | |||
260 | return -EINVAL; | ||
261 | } | ||
262 | |||
263 | /* sys_cacheflush -- no support. */ | ||
264 | asmlinkage int | ||
265 | sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len) | ||
266 | { | ||
267 | return -EINVAL; | ||
268 | } | ||
269 | |||
270 | asmlinkage int sys_getpagesize(void) | ||
271 | { | ||
272 | return PAGE_SIZE; | ||
273 | } | ||
274 | |||
275 | #if defined(CONFIG_SYSCALL_PRINT) | ||
276 | asmlinkage void syscall_print(void *dummy,...) | ||
277 | { | ||
278 | struct pt_regs *regs = (struct pt_regs *) ((unsigned char *)&dummy-4); | ||
279 | printk("call %06lx:%ld 1:%08lx,2:%08lx,3:%08lx,ret:%08lx\n", | ||
280 | ((regs->pc)&0xffffff)-2,regs->orig_er0,regs->er1,regs->er2,regs->er3,regs->er0); | ||
281 | } | ||
282 | #endif | ||