1 /* sys_frv.c: FRV arch-specific syscall wrappers
3 * Copyright (C) 2003-5 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 * - Derived from arch/m68k/kernel/sys_m68k.c
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
13 #include <linux/errno.h>
14 #include <linux/sched.h>
17 #include <linux/smp.h>
18 #include <linux/sem.h>
19 #include <linux/msg.h>
20 #include <linux/shm.h>
21 #include <linux/stat.h>
22 #include <linux/mman.h>
23 #include <linux/file.h>
24 #include <linux/utsname.h>
25 #include <linux/syscalls.h>
26 #include <linux/ipc.h>
28 #include <asm/setup.h>
29 #include <asm/uaccess.h>
32 * sys_pipe() is the normal C calling standard for creating
33 * a pipe. It's not the way unix traditionally does this, though.
35 asmlinkage
long sys_pipe(unsigned long __user
* fildes
)
42 if (copy_to_user(fildes
, fd
, 2*sizeof(int)))
48 asmlinkage
long sys_mmap2(unsigned long addr
, unsigned long len
,
49 unsigned long prot
, unsigned long flags
,
50 unsigned long fd
, unsigned long pgoff
)
53 struct file
* file
= NULL
;
55 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
56 if (!(flags
& MAP_ANONYMOUS
)) {
62 /* As with sparc32, make sure the shift for mmap2 is constant
63 (12), no matter what PAGE_SIZE we have.... */
65 /* But unlike sparc32, don't just silently break if we're
66 trying to map something we can't */
67 if (pgoff
& ((1<<(PAGE_SHIFT
-12))-1))
70 pgoff
>>= (PAGE_SHIFT
- 12);
72 down_write(¤t
->mm
->mmap_sem
);
73 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, pgoff
);
74 up_write(¤t
->mm
->mmap_sem
);
82 #if 0 /* DAVIDM - do we want this */
83 struct mmap_arg_struct64
{
88 __u64 offset
; /* 64 bits */
92 asmlinkage
long sys_mmap64(struct mmap_arg_struct64
*arg
)
95 struct file
* file
= NULL
;
96 struct mmap_arg_struct64 a
;
99 if (copy_from_user(&a
, arg
, sizeof(a
)))
102 if ((long)a
.offset
& ~PAGE_MASK
)
105 pgoff
= a
.offset
>> PAGE_SHIFT
;
106 if ((a
.offset
>> PAGE_SHIFT
) != pgoff
)
109 if (!(a
.flags
& MAP_ANONYMOUS
)) {
115 a
.flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
117 down_write(¤t
->mm
->mmap_sem
);
118 error
= do_mmap_pgoff(file
, a
.addr
, a
.len
, a
.prot
, a
.flags
, pgoff
);
119 up_write(¤t
->mm
->mmap_sem
);
128 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
130 * This is really horribly ugly.
132 asmlinkage
long sys_ipc(unsigned long call
,
134 unsigned long second
,
141 version
= call
>> 16; /* hack for backward compatibility */
146 return sys_semtimedop(first
, (struct sembuf __user
*)ptr
, second
, NULL
);
148 return sys_semtimedop(first
, (struct sembuf __user
*)ptr
, second
,
149 (const struct timespec __user
*)fifth
);
152 return sys_semget (first
, second
, third
);
157 if (get_user(fourth
.__pad
, (void * __user
*) ptr
))
159 return sys_semctl (first
, second
, third
, fourth
);
163 return sys_msgsnd (first
, (struct msgbuf __user
*) ptr
,
168 struct ipc_kludge tmp
;
172 if (copy_from_user(&tmp
,
173 (struct ipc_kludge __user
*) ptr
,
176 return sys_msgrcv (first
, tmp
.msgp
, second
,
180 return sys_msgrcv (first
,
181 (struct msgbuf __user
*) ptr
,
182 second
, fifth
, third
);
185 return sys_msgget ((key_t
) first
, second
);
187 return sys_msgctl (first
, second
, (struct msqid_ds __user
*) ptr
);
193 ret
= do_shmat (first
, (char __user
*) ptr
, second
, &raddr
);
196 return put_user (raddr
, (ulong __user
*) third
);
198 case 1: /* iBCS2 emulator entry point */
199 if (!segment_eq(get_fs(), get_ds()))
201 /* The "(ulong *) third" is valid _only_ because of the kernel segment thing */
202 return do_shmat (first
, (char __user
*) ptr
, second
, (ulong
*) third
);
205 return sys_shmdt ((char __user
*)ptr
);
207 return sys_shmget (first
, second
, third
);
209 return sys_shmctl (first
, second
,
210 (struct shmid_ds __user
*) ptr
);