Add generic sys_old_mmap()
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / h8300 / kernel / sys_h8300.c
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/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>
20 #include <linux/fs.h>
21 #include <linux/ipc.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/unistd.h>
28
29 /*
30 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
31 *
32 * This is really horribly ugly.
33 */
34 asmlinkage int sys_ipc (uint call, int first, int second,
35 int third, void *ptr, long fifth)
36 {
37 int version, ret;
38
39 version = call >> 16; /* hack for backward compatibility */
40 call &= 0xffff;
41
42 if (call <= SEMCTL)
43 switch (call) {
44 case SEMOP:
45 return sys_semop (first, (struct sembuf *)ptr, second);
46 case SEMGET:
47 return sys_semget (first, second, third);
48 case SEMCTL: {
49 union semun fourth;
50 if (!ptr)
51 return -EINVAL;
52 if (get_user(fourth.__pad, (void **) ptr))
53 return -EFAULT;
54 return sys_semctl (first, second, third, fourth);
55 }
56 default:
57 return -EINVAL;
58 }
59 if (call <= MSGCTL)
60 switch (call) {
61 case MSGSND:
62 return sys_msgsnd (first, (struct msgbuf *) ptr,
63 second, third);
64 case MSGRCV:
65 switch (version) {
66 case 0: {
67 struct ipc_kludge tmp;
68 if (!ptr)
69 return -EINVAL;
70 if (copy_from_user (&tmp,
71 (struct ipc_kludge *)ptr,
72 sizeof (tmp)))
73 return -EFAULT;
74 return sys_msgrcv (first, tmp.msgp, second,
75 tmp.msgtyp, third);
76 }
77 default:
78 return sys_msgrcv (first,
79 (struct msgbuf *) ptr,
80 second, fifth, third);
81 }
82 case MSGGET:
83 return sys_msgget ((key_t) first, second);
84 case MSGCTL:
85 return sys_msgctl (first, second,
86 (struct msqid_ds *) ptr);
87 default:
88 return -EINVAL;
89 }
90 if (call <= SHMCTL)
91 switch (call) {
92 case SHMAT:
93 switch (version) {
94 default: {
95 ulong raddr;
96 ret = do_shmat (first, (char *) ptr,
97 second, &raddr);
98 if (ret)
99 return ret;
100 return put_user (raddr, (ulong *) third);
101 }
102 }
103 case SHMDT:
104 return sys_shmdt ((char *)ptr);
105 case SHMGET:
106 return sys_shmget (first, second, third);
107 case SHMCTL:
108 return sys_shmctl (first, second,
109 (struct shmid_ds *) ptr);
110 default:
111 return -EINVAL;
112 }
113
114 return -EINVAL;
115 }
116
117 /* sys_cacheflush -- no support. */
118 asmlinkage int
119 sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
120 {
121 return -EINVAL;
122 }
123
124 asmlinkage int sys_getpagesize(void)
125 {
126 return PAGE_SIZE;
127 }
128
129 #if defined(CONFIG_SYSCALL_PRINT)
130 asmlinkage void syscall_print(void *dummy,...)
131 {
132 struct pt_regs *regs = (struct pt_regs *) ((unsigned char *)&dummy-4);
133 printk("call %06lx:%ld 1:%08lx,2:%08lx,3:%08lx,ret:%08lx\n",
134 ((regs->pc)&0xffffff)-2,regs->orig_er0,regs->er1,regs->er2,regs->er3,regs->er0);
135 }
136 #endif
137
138 /*
139 * Do a system call from kernel instead of calling sys_execve so we
140 * end up with proper pt_regs.
141 */
142 int kernel_execve(const char *filename, char *const argv[], char *const envp[])
143 {
144 register long res __asm__("er0");
145 register char *const *_c __asm__("er3") = envp;
146 register char *const *_b __asm__("er2") = argv;
147 register const char * _a __asm__("er1") = filename;
148 __asm__ __volatile__ ("mov.l %1,er0\n\t"
149 "trapa #0\n\t"
150 : "=r" (res)
151 : "g" (__NR_execve),
152 "g" (_a),
153 "g" (_b),
154 "g" (_c)
155 : "cc", "memory");
156 return res;
157 }
158
159