2 * arch/ubicom32/kernel/sys_ubicom32.c
3 * Ubicom32 architecture system call support implementation.
5 * (C) Copyright 2009, Ubicom, Inc.
7 * This file is part of the Ubicom32 Linux Kernel Port.
9 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10 * it and/or modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation, either version 2 of the
12 * License, or (at your option) any later version.
14 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with the Ubicom32 Linux Kernel Port. If not,
21 * see <http://www.gnu.org/licenses/>.
23 * Ubicom32 implementation derived from (with many thanks):
28 * This file contains various random system calls that
29 * have a non-standard calling sequence on the Linux/ubicom32
33 #include <linux/module.h>
34 #include <linux/errno.h>
35 #include <linux/sched.h>
37 #include <linux/smp.h>
38 #include <linux/sem.h>
39 #include <linux/msg.h>
40 #include <linux/shm.h>
41 #include <linux/stat.h>
42 #include <linux/syscalls.h>
43 #include <linux/mman.h>
44 #include <linux/file.h>
45 #include <linux/utsname.h>
46 #include <linux/ipc.h>
48 #include <linux/uaccess.h>
49 #include <linux/unistd.h>
51 #include <asm/setup.h>
52 #include <asm/traps.h>
53 #include <asm/cacheflush.h>
55 /* common code for old and new mmaps */
56 static inline long do_mmap2(
57 unsigned long addr
, unsigned long len
,
58 unsigned long prot
, unsigned long flags
,
59 unsigned long fd
, unsigned long pgoff
)
62 struct file
*file
= NULL
;
64 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
65 if (!(flags
& MAP_ANONYMOUS
)) {
71 down_write(¤t
->mm
->mmap_sem
);
72 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, pgoff
);
73 up_write(¤t
->mm
->mmap_sem
);
81 asmlinkage
long sys_mmap2(unsigned long addr
, unsigned long len
,
82 unsigned long prot
, unsigned long flags
,
83 unsigned long fd
, unsigned long pgoff
)
85 return do_mmap2(addr
, len
, prot
, flags
, fd
, pgoff
);
89 * Perform the select(nd, in, out, ex, tv) and mmap() system
90 * calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
91 * handle more than 4 system call parameters, so these system calls
92 * used a memory block for parameter passing..
95 struct mmap_arg_struct
{
101 unsigned long offset
;
104 asmlinkage
int old_mmap(struct mmap_arg_struct
*arg
)
106 struct mmap_arg_struct a
;
109 if (copy_from_user(&a
, arg
, sizeof(a
)))
113 if (a
.offset
& ~PAGE_MASK
)
116 a
.flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
118 error
= do_mmap2(a
.addr
, a
.len
, a
.prot
, a
.flags
, a
.fd
,
119 a
.offset
>> PAGE_SHIFT
);
124 struct sel_arg_struct
{
126 fd_set
*inp
, *outp
, *exp
;
130 asmlinkage
int old_select(struct sel_arg_struct
*arg
)
132 struct sel_arg_struct a
;
134 if (copy_from_user(&a
, arg
, sizeof(a
)))
136 /* sys_select() does the appropriate kernel locking */
137 return sys_select(a
.n
, a
.inp
, a
.outp
, a
.exp
, a
.tvp
);
141 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
143 * This is really horribly ugly.
145 asmlinkage
int sys_ipc(uint call
, int first
, int second
,
146 int third
, void *ptr
, long fifth
)
150 version
= call
>> 16; /* hack for backward compatibility */
156 return sys_semop(first
, (struct sembuf
*)ptr
, second
);
158 return sys_semget(first
, second
, third
);
163 if (get_user(fourth
.__pad
, (void **) ptr
))
165 return sys_semctl(first
, second
, third
, fourth
);
173 return sys_msgsnd(first
, (struct msgbuf
*) ptr
,
178 struct ipc_kludge tmp
;
181 if (copy_from_user(&tmp
,
182 (struct ipc_kludge
*)ptr
,
185 return sys_msgrcv(first
, tmp
.msgp
, second
,
189 return sys_msgrcv(first
,
190 (struct msgbuf
*) ptr
,
191 second
, fifth
, third
);
194 return sys_msgget((key_t
) first
, second
);
196 return sys_msgctl(first
, second
,
197 (struct msqid_ds
*) ptr
);
207 ret
= do_shmat(first
, ptr
, second
, &raddr
);
210 return put_user(raddr
, (ulong __user
*) third
);
214 return sys_shmdt(ptr
);
216 return sys_shmget(first
, second
, third
);
218 return sys_shmctl(first
, second
, ptr
);
226 /* sys_cacheflush -- flush (part of) the processor cache. */
228 sys_cacheflush(unsigned long addr
, int scope
, int cache
, unsigned long len
)
234 asmlinkage
int sys_getpagesize(void)