netbsd32_compat_10_sysv.c revision 1.1.2.1 1 1.1.2.1 pgoyette /* $NetBSD: netbsd32_compat_10_sysv.c,v 1.1.2.1 2018/09/12 04:35:22 pgoyette Exp $ */
2 1.1.2.1 pgoyette
3 1.1.2.1 pgoyette /*
4 1.1.2.1 pgoyette * Copyright (c) 1994 Adam Glass and Charles M. Hannum. All rights reserved.
5 1.1.2.1 pgoyette *
6 1.1.2.1 pgoyette * Redistribution and use in source and binary forms, with or without
7 1.1.2.1 pgoyette * modification, are permitted provided that the following conditions
8 1.1.2.1 pgoyette * are met:
9 1.1.2.1 pgoyette * 1. Redistributions of source code must retain the above copyright
10 1.1.2.1 pgoyette * notice, this list of conditions and the following disclaimer.
11 1.1.2.1 pgoyette * 2. Redistributions in binary form must reproduce the above copyright
12 1.1.2.1 pgoyette * notice, this list of conditions and the following disclaimer in the
13 1.1.2.1 pgoyette * documentation and/or other materials provided with the distribution.
14 1.1.2.1 pgoyette * 3. All advertising materials mentioning features or use of this software
15 1.1.2.1 pgoyette * must display the following acknowledgement:
16 1.1.2.1 pgoyette * This product includes software developed by Adam Glass and Charles M.
17 1.1.2.1 pgoyette * Hannum.
18 1.1.2.1 pgoyette * 4. The names of the authors may not be used to endorse or promote products
19 1.1.2.1 pgoyette * derived from this software without specific prior written permission.
20 1.1.2.1 pgoyette *
21 1.1.2.1 pgoyette * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
22 1.1.2.1 pgoyette * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1.2.1 pgoyette * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1.2.1 pgoyette * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1.2.1 pgoyette * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1.2.1 pgoyette * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1.2.1 pgoyette * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1.2.1 pgoyette * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1.2.1 pgoyette * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1.2.1 pgoyette * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1.2.1 pgoyette */
32 1.1.2.1 pgoyette
33 1.1.2.1 pgoyette #include <sys/cdefs.h>
34 1.1.2.1 pgoyette __KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_10_sysv.c,v 1.1.2.1 2018/09/12 04:35:22 pgoyette Exp $");
35 1.1.2.1 pgoyette
36 1.1.2.1 pgoyette #ifdef _KERNEL_OPT
37 1.1.2.1 pgoyette #include "opt_sysv.h"
38 1.1.2.1 pgoyette #include "opt_compat_netbsd.h"
39 1.1.2.1 pgoyette #endif
40 1.1.2.1 pgoyette
41 1.1.2.1 pgoyette #include <sys/param.h>
42 1.1.2.1 pgoyette #include <sys/systm.h>
43 1.1.2.1 pgoyette #include <sys/module.h>
44 1.1.2.1 pgoyette #include <sys/kernel.h>
45 1.1.2.1 pgoyette #include <sys/proc.h>
46 1.1.2.1 pgoyette #include <sys/sem.h>
47 1.1.2.1 pgoyette
48 1.1.2.1 pgoyette #include <sys/mount.h>
49 1.1.2.1 pgoyette #include <sys/syscallargs.h>
50 1.1.2.1 pgoyette #include <sys/syscallvar.h>
51 1.1.2.1 pgoyette
52 1.1.2.1 pgoyette #include <compat/netbsd32/netbsd32.h>
53 1.1.2.1 pgoyette #include <compat/netbsd32/netbsd32_syscall.h>
54 1.1.2.1 pgoyette #include <compat/netbsd32/netbsd32_syscallargs.h>
55 1.1.2.1 pgoyette #include <compat/sys/shm.h>
56 1.1.2.1 pgoyette
57 1.1.2.1 pgoyette #if defined(COMPAT_10)
58 1.1.2.1 pgoyette
59 1.1.2.1 pgoyette #if defined(SYSVSEM)
60 1.1.2.1 pgoyette int
61 1.1.2.1 pgoyette compat_10_netbsd32_semsys(struct lwp *l, const struct compat_10_netbsd32_semsys_args *uap, register_t *retval)
62 1.1.2.1 pgoyette {
63 1.1.2.1 pgoyette /* {
64 1.1.2.1 pgoyette syscallarg(int) which;
65 1.1.2.1 pgoyette syscallarg(int) a2;
66 1.1.2.1 pgoyette syscallarg(int) a3;
67 1.1.2.1 pgoyette syscallarg(int) a4;
68 1.1.2.1 pgoyette syscallarg(int) a5;
69 1.1.2.1 pgoyette } */
70 1.1.2.1 pgoyette struct compat_50_netbsd32___semctl14_args /* {
71 1.1.2.1 pgoyette syscallarg(int) semid;
72 1.1.2.1 pgoyette syscallarg(int) semnum;
73 1.1.2.1 pgoyette syscallarg(int) cmd;
74 1.1.2.1 pgoyette syscallarg(union semun *) arg;
75 1.1.2.1 pgoyette } */ __semctl_args;
76 1.1.2.1 pgoyette struct sys_semget_args /* {
77 1.1.2.1 pgoyette syscallarg(key_t) key;
78 1.1.2.1 pgoyette syscallarg(int) nsems;
79 1.1.2.1 pgoyette syscallarg(int) semflg;
80 1.1.2.1 pgoyette } */ semget_args;
81 1.1.2.1 pgoyette struct sys_semop_args /* {
82 1.1.2.1 pgoyette syscallarg(int) semid;
83 1.1.2.1 pgoyette syscallarg(struct sembuf *) sops;
84 1.1.2.1 pgoyette syscallarg(u_int) nsops;
85 1.1.2.1 pgoyette } */ semop_args;
86 1.1.2.1 pgoyette struct sys_semconfig_args /* {
87 1.1.2.1 pgoyette syscallarg(int) flag;
88 1.1.2.1 pgoyette } */ semconfig_args;
89 1.1.2.1 pgoyette int a5;
90 1.1.2.1 pgoyette
91 1.1.2.1 pgoyette switch (SCARG(uap, which)) {
92 1.1.2.1 pgoyette case 0: /* __semctl() */
93 1.1.2.1 pgoyette SCARG(&__semctl_args, semid) = SCARG(uap, a2);
94 1.1.2.1 pgoyette SCARG(&__semctl_args, semnum) = SCARG(uap, a3);
95 1.1.2.1 pgoyette SCARG(&__semctl_args, cmd) = SCARG(uap, a4);
96 1.1.2.1 pgoyette a5 = SCARG(uap, a5);
97 1.1.2.1 pgoyette return do_netbsd32___semctl14(l, &__semctl_args, retval, &a5);
98 1.1.2.1 pgoyette
99 1.1.2.1 pgoyette case 1: /* semget() */
100 1.1.2.1 pgoyette SCARG(&semget_args, key) = SCARG(uap, a2);
101 1.1.2.1 pgoyette SCARG(&semget_args, nsems) = SCARG(uap, a3);
102 1.1.2.1 pgoyette SCARG(&semget_args, semflg) = SCARG(uap, a4);
103 1.1.2.1 pgoyette return (sys_semget(l, &semget_args, retval));
104 1.1.2.1 pgoyette
105 1.1.2.1 pgoyette case 2: /* semop() */
106 1.1.2.1 pgoyette SCARG(&semop_args, semid) = SCARG(uap, a2);
107 1.1.2.1 pgoyette SCARG(&semop_args, sops) = NETBSD32IPTR64(SCARG(uap, a3));
108 1.1.2.1 pgoyette SCARG(&semop_args, nsops) = SCARG(uap, a4);
109 1.1.2.1 pgoyette return (sys_semop(l, &semop_args, retval));
110 1.1.2.1 pgoyette
111 1.1.2.1 pgoyette case 3: /* semconfig() */
112 1.1.2.1 pgoyette SCARG(&semconfig_args, flag) = SCARG(uap, a2);
113 1.1.2.1 pgoyette return (sys_semconfig(l, &semconfig_args, retval));
114 1.1.2.1 pgoyette
115 1.1.2.1 pgoyette default:
116 1.1.2.1 pgoyette return (EINVAL);
117 1.1.2.1 pgoyette }
118 1.1.2.1 pgoyette }
119 1.1.2.1 pgoyette #endif
120 1.1.2.1 pgoyette
121 1.1.2.1 pgoyette #if defined(SYSVSHM)
122 1.1.2.1 pgoyette int
123 1.1.2.1 pgoyette compat_10_netbsd32_shmsys(struct lwp *l, const struct compat_10_netbsd32_shmsys_args *uap, register_t *retval)
124 1.1.2.1 pgoyette {
125 1.1.2.1 pgoyette /* {
126 1.1.2.1 pgoyette syscallarg(int) which;
127 1.1.2.1 pgoyette syscallarg(int) a2;
128 1.1.2.1 pgoyette syscallarg(int) a3;
129 1.1.2.1 pgoyette syscallarg(int) a4;
130 1.1.2.1 pgoyette } */
131 1.1.2.1 pgoyette struct sys_shmat_args /* {
132 1.1.2.1 pgoyette syscallarg(int) shmid;
133 1.1.2.1 pgoyette syscallarg(void *) shmaddr;
134 1.1.2.1 pgoyette syscallarg(int) shmflg;
135 1.1.2.1 pgoyette } */ shmat_args;
136 1.1.2.1 pgoyette struct compat_14_sys_shmctl_args /* {
137 1.1.2.1 pgoyette syscallarg(int) shmid;
138 1.1.2.1 pgoyette syscallarg(int) cmd;
139 1.1.2.1 pgoyette syscallarg(struct shmid_ds50 *) buf;
140 1.1.2.1 pgoyette } */ shmctl_args;
141 1.1.2.1 pgoyette struct sys_shmdt_args /* {
142 1.1.2.1 pgoyette syscallarg(void *) shmaddr;
143 1.1.2.1 pgoyette } */ shmdt_args;
144 1.1.2.1 pgoyette struct sys_shmget_args /* {
145 1.1.2.1 pgoyette syscallarg(key_t) key;
146 1.1.2.1 pgoyette syscallarg(int) size;
147 1.1.2.1 pgoyette syscallarg(int) shmflg;
148 1.1.2.1 pgoyette } */ shmget_args;
149 1.1.2.1 pgoyette
150 1.1.2.1 pgoyette switch (SCARG(uap, which)) {
151 1.1.2.1 pgoyette case 0: /* shmat() */
152 1.1.2.1 pgoyette SCARG(&shmat_args, shmid) = SCARG(uap, a2);
153 1.1.2.1 pgoyette SCARG(&shmat_args, shmaddr) = NETBSD32IPTR64(SCARG(uap, a3));
154 1.1.2.1 pgoyette SCARG(&shmat_args, shmflg) = SCARG(uap, a4);
155 1.1.2.1 pgoyette return (sys_shmat(l, &shmat_args, retval));
156 1.1.2.1 pgoyette
157 1.1.2.1 pgoyette case 1: /* shmctl() */
158 1.1.2.1 pgoyette SCARG(&shmctl_args, shmid) = SCARG(uap, a2);
159 1.1.2.1 pgoyette SCARG(&shmctl_args, cmd) = SCARG(uap, a3);
160 1.1.2.1 pgoyette SCARG(&shmctl_args, buf) = NETBSD32IPTR64(SCARG(uap, a4));
161 1.1.2.1 pgoyette return (compat_14_sys_shmctl(l, &shmctl_args, retval));
162 1.1.2.1 pgoyette
163 1.1.2.1 pgoyette case 2: /* shmdt() */
164 1.1.2.1 pgoyette SCARG(&shmdt_args, shmaddr) = NETBSD32IPTR64(SCARG(uap, a2));
165 1.1.2.1 pgoyette return (sys_shmdt(l, &shmdt_args, retval));
166 1.1.2.1 pgoyette
167 1.1.2.1 pgoyette case 3: /* shmget() */
168 1.1.2.1 pgoyette SCARG(&shmget_args, key) = SCARG(uap, a2);
169 1.1.2.1 pgoyette SCARG(&shmget_args, size) = SCARG(uap, a3);
170 1.1.2.1 pgoyette SCARG(&shmget_args, shmflg) = SCARG(uap, a4);
171 1.1.2.1 pgoyette return (sys_shmget(l, &shmget_args, retval));
172 1.1.2.1 pgoyette
173 1.1.2.1 pgoyette default:
174 1.1.2.1 pgoyette return (EINVAL);
175 1.1.2.1 pgoyette }
176 1.1.2.1 pgoyette }
177 1.1.2.1 pgoyette #endif
178 1.1.2.1 pgoyette
179 1.1.2.1 pgoyette #if defined(SYSVMSG)
180 1.1.2.1 pgoyette int
181 1.1.2.1 pgoyette compat_10_netbsd32_msgsys(struct lwp *l, const struct compat_10_netbsd32_msgsys_args *uap, register_t *retval)
182 1.1.2.1 pgoyette {
183 1.1.2.1 pgoyette /* {
184 1.1.2.1 pgoyette syscallarg(int) which;
185 1.1.2.1 pgoyette syscallarg(int) a2;
186 1.1.2.1 pgoyette syscallarg(int) a3;
187 1.1.2.1 pgoyette syscallarg(int) a4;
188 1.1.2.1 pgoyette syscallarg(int) a5;
189 1.1.2.1 pgoyette syscallarg(int) a6;
190 1.1.2.1 pgoyette } */
191 1.1.2.1 pgoyette struct compat_14_sys_msgctl_args /* {
192 1.1.2.1 pgoyette syscallarg(int) msqid;
193 1.1.2.1 pgoyette syscallarg(int) cmd;
194 1.1.2.1 pgoyette syscallarg(struct msqid_ds *) buf;
195 1.1.2.1 pgoyette } */ msgctl_args;
196 1.1.2.1 pgoyette struct sys_msgget_args /* {
197 1.1.2.1 pgoyette syscallarg(key_t) key;
198 1.1.2.1 pgoyette syscallarg(int) msgflg;
199 1.1.2.1 pgoyette } */ msgget_args;
200 1.1.2.1 pgoyette struct sys_msgsnd_args /* {
201 1.1.2.1 pgoyette syscallarg(int) msqid;
202 1.1.2.1 pgoyette syscallarg(void *) msgp;
203 1.1.2.1 pgoyette syscallarg(size_t) msgsz;
204 1.1.2.1 pgoyette syscallarg(int) msgflg;
205 1.1.2.1 pgoyette } */ msgsnd_args;
206 1.1.2.1 pgoyette struct sys_msgrcv_args /* {
207 1.1.2.1 pgoyette syscallarg(int) msqid;
208 1.1.2.1 pgoyette syscallarg(void *) msgp;
209 1.1.2.1 pgoyette syscallarg(size_t) msgsz;
210 1.1.2.1 pgoyette syscallarg(long) msgtyp;
211 1.1.2.1 pgoyette syscallarg(int) msgflg;
212 1.1.2.1 pgoyette } */ msgrcv_args;
213 1.1.2.1 pgoyette
214 1.1.2.1 pgoyette switch (SCARG(uap, which)) {
215 1.1.2.1 pgoyette case 0: /* msgctl()*/
216 1.1.2.1 pgoyette SCARG(&msgctl_args, msqid) = SCARG(uap, a2);
217 1.1.2.1 pgoyette SCARG(&msgctl_args, cmd) = SCARG(uap, a3);
218 1.1.2.1 pgoyette SCARG(&msgctl_args, buf) = NETBSD32IPTR64(SCARG(uap, a4));
219 1.1.2.1 pgoyette return (compat_14_sys_msgctl(l, &msgctl_args, retval));
220 1.1.2.1 pgoyette
221 1.1.2.1 pgoyette case 1: /* msgget() */
222 1.1.2.1 pgoyette SCARG(&msgget_args, key) = SCARG(uap, a2);
223 1.1.2.1 pgoyette SCARG(&msgget_args, msgflg) = SCARG(uap, a3);
224 1.1.2.1 pgoyette return (sys_msgget(l, &msgget_args, retval));
225 1.1.2.1 pgoyette
226 1.1.2.1 pgoyette case 2: /* msgsnd() */
227 1.1.2.1 pgoyette SCARG(&msgsnd_args, msqid) = SCARG(uap, a2);
228 1.1.2.1 pgoyette SCARG(&msgsnd_args, msgp) = NETBSD32IPTR64(SCARG(uap, a3));
229 1.1.2.1 pgoyette SCARG(&msgsnd_args, msgsz) = SCARG(uap, a4);
230 1.1.2.1 pgoyette SCARG(&msgsnd_args, msgflg) = SCARG(uap, a5);
231 1.1.2.1 pgoyette return (sys_msgsnd(l, &msgsnd_args, retval));
232 1.1.2.1 pgoyette
233 1.1.2.1 pgoyette case 3: /* msgrcv() */
234 1.1.2.1 pgoyette SCARG(&msgrcv_args, msqid) = SCARG(uap, a2);
235 1.1.2.1 pgoyette SCARG(&msgrcv_args, msgp) = NETBSD32IPTR64(SCARG(uap, a3));
236 1.1.2.1 pgoyette SCARG(&msgrcv_args, msgsz) = SCARG(uap, a4);
237 1.1.2.1 pgoyette SCARG(&msgrcv_args, msgtyp) = SCARG(uap, a5);
238 1.1.2.1 pgoyette SCARG(&msgrcv_args, msgflg) = SCARG(uap, a6);
239 1.1.2.1 pgoyette return (sys_msgrcv(l, &msgrcv_args, retval));
240 1.1.2.1 pgoyette
241 1.1.2.1 pgoyette default:
242 1.1.2.1 pgoyette return (EINVAL);
243 1.1.2.1 pgoyette }
244 1.1.2.1 pgoyette }
245 1.1.2.1 pgoyette #endif
246 1.1.2.1 pgoyette
247 1.1.2.1 pgoyette #define _PKG_ENTRY(name) \
248 1.1.2.1 pgoyette { NETBSD32_SYS_ ## name, 0, (sy_call_t *)name }
249 1.1.2.1 pgoyette
250 1.1.2.1 pgoyette #define _PKG_ENTRY2(code, name) \
251 1.1.2.1 pgoyette { NETBSD32_SYS_ ## code, 0, (sy_call_t *)name }
252 1.1.2.1 pgoyette
253 1.1.2.1 pgoyette static const struct syscall_package compat_sysvipc_10_syscalls[] = {
254 1.1.2.1 pgoyette #if defined(SYSVSEM)
255 1.1.2.1 pgoyette _PKG_ENTRY2(compat_10_osemsys, compat_10_netbsd32_semsys),
256 1.1.2.1 pgoyette #endif
257 1.1.2.1 pgoyette #if defined(SYSVSHM)
258 1.1.2.1 pgoyette _PKG_ENTRY2(compat_10_oshmsys, compat_10_netbsd32_shmsys),
259 1.1.2.1 pgoyette #endif
260 1.1.2.1 pgoyette #if defined(SYSVMSG)
261 1.1.2.1 pgoyette _PKG_ENTRY2(compat_10_omsgsys, compat_10_netbsd32_msgsys),
262 1.1.2.1 pgoyette #endif
263 1.1.2.1 pgoyette { 0, 0, NULL }
264 1.1.2.1 pgoyette };
265 1.1.2.1 pgoyette
266 1.1.2.1 pgoyette #define REQ1 "sysv_ipc,compat_sysv_10,"
267 1.1.2.1 pgoyette #define REQ2 "compat_netbsd32,compat_netbsd32_sysvipc,"
268 1.1.2.1 pgoyette #define REQ3 "compat_netbsd32_sysvipc_14,compat_netbsd32_sysvipc_50"
269 1.1.2.1 pgoyette
270 1.1.2.1 pgoyette MODULE(MODULE_CLASS_EXEC, compat_netbsd32_sysvipc_10, REQ1 REQ2 REQ3 );
271 1.1.2.1 pgoyette
272 1.1.2.1 pgoyette static int
273 1.1.2.1 pgoyette compat_netbsd32_sysvipc_10_modcmd(modcmd_t cmd, void *arg)
274 1.1.2.1 pgoyette {
275 1.1.2.1 pgoyette
276 1.1.2.1 pgoyette switch (cmd) {
277 1.1.2.1 pgoyette case MODULE_CMD_INIT:
278 1.1.2.1 pgoyette return syscall_establish(&emul_netbsd32,
279 1.1.2.1 pgoyette compat_sysvipc_10_syscalls);
280 1.1.2.1 pgoyette
281 1.1.2.1 pgoyette case MODULE_CMD_FINI:
282 1.1.2.1 pgoyette return syscall_disestablish(&emul_netbsd32,
283 1.1.2.1 pgoyette compat_sysvipc_10_syscalls);
284 1.1.2.1 pgoyette
285 1.1.2.1 pgoyette default:
286 1.1.2.1 pgoyette return ENOTTY;
287 1.1.2.1 pgoyette }
288 1.1.2.1 pgoyette }
289 1.1.2.1 pgoyette
290 1.1.2.1 pgoyette #endif /* COMPAT_10 */
291