2 * linux/arch/sh/kernel/sys_sh.c
4 * This file contains various random system calls that
5 * have a non-standard calling sequence on the Linux/SuperH
8 * Taken from i386 version.
10 #include <linux/errno.h>
11 #include <linux/sched.h>
13 #include <linux/smp.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 #include <linux/module.h>
24 #include <linux/ipc.h>
25 #include <asm/syscalls.h>
26 #include <asm/uaccess.h>
27 #include <asm/unistd.h>
28 #include <asm/cacheflush.h>
29 #include <asm/cachectl.h>
32 do_mmap2(unsigned long addr
, unsigned long len
, unsigned long prot
,
33 unsigned long flags
, int fd
, unsigned long pgoff
)
36 struct file
*file
= NULL
;
38 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
39 if (!(flags
& MAP_ANONYMOUS
)) {
45 down_write(¤t
->mm
->mmap_sem
);
46 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, pgoff
);
47 up_write(¤t
->mm
->mmap_sem
);
55 asmlinkage
int old_mmap(unsigned long addr
, unsigned long len
,
56 unsigned long prot
, unsigned long flags
,
57 int fd
, unsigned long off
)
61 return do_mmap2(addr
, len
, prot
, flags
, fd
, off
>>PAGE_SHIFT
);
64 asmlinkage
long sys_mmap2(unsigned long addr
, unsigned long len
,
65 unsigned long prot
, unsigned long flags
,
66 unsigned long fd
, unsigned long pgoff
)
69 * The shift for mmap2 is constant, regardless of PAGE_SIZE
72 if (pgoff
& ((1 << (PAGE_SHIFT
- 12)) - 1))
75 pgoff
>>= PAGE_SHIFT
- 12;
77 return do_mmap2(addr
, len
, prot
, flags
, fd
, pgoff
);
81 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
83 * This is really horribly ugly.
85 asmlinkage
int sys_ipc(uint call
, int first
, int second
,
86 int third
, void __user
*ptr
, long fifth
)
90 version
= call
>> 16; /* hack for backward compatibility */
93 if (call
<= SEMTIMEDOP
)
96 return sys_semtimedop(first
,
97 (struct sembuf __user
*)ptr
,
100 return sys_semtimedop(first
,
101 (struct sembuf __user
*)ptr
, second
,
102 (const struct timespec __user
*)fifth
);
104 return sys_semget (first
, second
, third
);
109 if (get_user(fourth
.__pad
, (void __user
* __user
*) ptr
))
111 return sys_semctl (first
, second
, third
, fourth
);
120 return sys_msgsnd (first
, (struct msgbuf __user
*) ptr
,
126 struct ipc_kludge tmp
;
131 if (copy_from_user(&tmp
,
132 (struct ipc_kludge __user
*) ptr
,
136 return sys_msgrcv (first
, tmp
.msgp
, second
,
140 return sys_msgrcv (first
,
141 (struct msgbuf __user
*) ptr
,
142 second
, fifth
, third
);
145 return sys_msgget ((key_t
) first
, second
);
147 return sys_msgctl (first
, second
,
148 (struct msqid_ds __user
*) ptr
);
158 ret
= do_shmat (first
, (char __user
*) ptr
,
162 return put_user (raddr
, (ulong __user
*) third
);
164 case 1: /* iBCS2 emulator entry point */
165 if (!segment_eq(get_fs(), get_ds()))
167 return do_shmat (first
, (char __user
*) ptr
,
168 second
, (ulong
*) third
);
171 return sys_shmdt ((char __user
*)ptr
);
173 return sys_shmget (first
, second
, third
);
175 return sys_shmctl (first
, second
,
176 (struct shmid_ds __user
*) ptr
);
184 /* sys_cacheflush -- flush (part of) the processor cache. */
185 asmlinkage
int sys_cacheflush(unsigned long addr
, unsigned long len
, int op
)
187 struct vm_area_struct
*vma
;
189 if ((op
<= 0) || (op
> (CACHEFLUSH_D_PURGE
|CACHEFLUSH_I
)))
193 * Verify that the specified address region actually belongs
196 if (addr
+ len
< addr
)
199 down_read(¤t
->mm
->mmap_sem
);
200 vma
= find_vma (current
->mm
, addr
);
201 if (vma
== NULL
|| addr
< vma
->vm_start
|| addr
+ len
> vma
->vm_end
) {
202 up_read(¤t
->mm
->mmap_sem
);
206 switch (op
& CACHEFLUSH_D_PURGE
) {
207 case CACHEFLUSH_D_INVAL
:
208 __flush_invalidate_region((void *)addr
, len
);
210 case CACHEFLUSH_D_WB
:
211 __flush_wback_region((void *)addr
, len
);
213 case CACHEFLUSH_D_PURGE
:
214 __flush_purge_region((void *)addr
, len
);
218 if (op
& CACHEFLUSH_I
)
221 up_read(¤t
->mm
->mmap_sem
);
225 asmlinkage
int sys_uname(struct old_utsname __user
*name
)
231 err
= copy_to_user(name
, utsname(), sizeof(*name
));
233 return err
?-EFAULT
:0;