1 /* $NetBSD: freebsd_ipc.c,v 1.15.8.1 2008/03/29 20:46:58 christos Exp $ */
4 * Copyright (c) 1994 Adam Glass and Charles M. Hannum. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Adam Glass and Charles M.
18 * 4. The names of the authors may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: freebsd_ipc.c,v 1.15.8.1 2008/03/29 20:46:58 christos Exp $");
36 #if defined(_KERNEL_OPT)
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/kernel.h>
46 #include <sys/malloc.h>
48 #include <sys/mount.h>
49 #include <sys/syscallargs.h>
51 #include <compat/sys/shm.h>
52 #include <compat/freebsd/freebsd_syscallargs.h>
56 freebsd_sys_semsys(struct lwp
*l
, const struct freebsd_sys_semsys_args
*uap
, register_t
*retval
)
59 syscallarg(int) which;
65 struct compat_14_sys___semctl_args
/* {
66 syscallarg(int) semid;
67 syscallarg(int) semnum;
69 syscallarg(union __semun *) arg;
71 struct sys_semget_args
/* {
72 syscallarg(key_t) key;
73 syscallarg(int) nsems;
74 syscallarg(int) semflg;
76 struct sys_semop_args
/* {
77 syscallarg(int) semid;
78 syscallarg(struct sembuf *) sops;
79 syscallarg(u_int) nsops;
81 struct sys_semconfig_args
/* {
85 switch (SCARG(uap
, which
)) {
86 case 0: /* __semctl() */
87 SCARG(&__semctl_args
, semid
) = SCARG(uap
, a2
);
88 SCARG(&__semctl_args
, semnum
) = SCARG(uap
, a3
);
89 SCARG(&__semctl_args
, cmd
) = SCARG(uap
, a4
);
90 SCARG(&__semctl_args
, arg
) = (union __semun
*)SCARG(uap
, a5
);
91 return (compat_14_sys___semctl(l
, &__semctl_args
, retval
));
93 case 1: /* semget() */
94 SCARG(&semget_args
, key
) = SCARG(uap
, a2
);
95 SCARG(&semget_args
, nsems
) = SCARG(uap
, a3
);
96 SCARG(&semget_args
, semflg
) = SCARG(uap
, a4
);
97 return (sys_semget(l
, &semget_args
, retval
));
100 SCARG(&semop_args
, semid
) = SCARG(uap
, a2
);
101 SCARG(&semop_args
, sops
) = (struct sembuf
*)SCARG(uap
, a3
);
102 SCARG(&semop_args
, nsops
) = SCARG(uap
, a4
);
103 return (sys_semop(l
, &semop_args
, retval
));
105 case 3: /* semconfig() */
106 SCARG(&semconfig_args
, flag
) = SCARG(uap
, a2
);
107 return (sys_semconfig(l
, &semconfig_args
, retval
));
117 freebsd_sys_shmsys(struct lwp
*l
, const struct freebsd_sys_shmsys_args
*uap
, register_t
*retval
)
120 syscallarg(int) which;
125 struct sys_shmat_args
/* {
126 syscallarg(int) shmid;
127 syscallarg(void *) shmaddr;
128 syscallarg(int) shmflg;
130 struct compat_14_sys_shmctl_args
/* {
131 syscallarg(int) shmid;
133 syscallarg(struct shmid_ds14 *) buf;
135 struct sys_shmdt_args
/* {
136 syscallarg(void *) shmaddr;
138 struct sys_shmget_args
/* {
139 syscallarg(key_t) key;
140 syscallarg(int) size;
141 syscallarg(int) shmflg;
144 switch (SCARG(uap
, which
)) {
145 case 0: /* shmat() */
146 SCARG(&shmat_args
, shmid
) = SCARG(uap
, a2
);
147 SCARG(&shmat_args
, shmaddr
) = (void *)SCARG(uap
, a3
);
148 SCARG(&shmat_args
, shmflg
) = SCARG(uap
, a4
);
149 return (sys_shmat(l
, &shmat_args
, retval
));
151 case 1: /* oshmctl() */
152 /* XXX Need to translate shmid_ds format. */
155 case 2: /* shmdt() */
156 SCARG(&shmdt_args
, shmaddr
) = (void *)SCARG(uap
, a2
);
157 return (sys_shmdt(l
, &shmdt_args
, retval
));
159 case 3: /* shmget() */
160 SCARG(&shmget_args
, key
) = SCARG(uap
, a2
);
161 SCARG(&shmget_args
, size
) = SCARG(uap
, a3
);
162 SCARG(&shmget_args
, shmflg
) = SCARG(uap
, a4
);
163 return (sys_shmget(l
, &shmget_args
, retval
));
165 case 4: /* shmctl() */
166 SCARG(&shmctl_args
, shmid
) = SCARG(uap
, a2
);
167 SCARG(&shmctl_args
, cmd
) = SCARG(uap
, a3
);
168 SCARG(&shmctl_args
, buf
) = (struct shmid_ds14
*)SCARG(uap
, a4
);
169 return (compat_14_sys_shmctl(l
, &shmctl_args
, retval
));
179 freebsd_sys_msgsys(struct lwp
*l
, const struct freebsd_sys_msgsys_args
*uap
, register_t
*retval
)
182 syscallarg(int) which;
189 struct compat_14_sys_msgctl_args
/* {
190 syscallarg(int) msqid;
192 syscallarg(struct msqid_ds14 *) buf;
194 struct sys_msgget_args
/* {
195 syscallarg(key_t) key;
196 syscallarg(int) msgflg;
198 struct sys_msgsnd_args
/* {
199 syscallarg(int) msqid;
200 syscallarg(void *) msgp;
201 syscallarg(size_t) msgsz;
202 syscallarg(int) msgflg;
204 struct sys_msgrcv_args
/* {
205 syscallarg(int) msqid;
206 syscallarg(void *) msgp;
207 syscallarg(size_t) msgsz;
208 syscallarg(long) msgtyp;
209 syscallarg(int) msgflg;
212 switch (SCARG(uap
, which
)) {
213 case 0: /* msgctl()*/
214 SCARG(&msgctl_args
, msqid
) = SCARG(uap
, a2
);
215 SCARG(&msgctl_args
, cmd
) = SCARG(uap
, a3
);
216 SCARG(&msgctl_args
, buf
) =
217 (struct msqid_ds14
*)SCARG(uap
, a4
);
218 return (compat_14_sys_msgctl(l
, &msgctl_args
, retval
));
220 case 1: /* msgget() */
221 SCARG(&msgget_args
, key
) = SCARG(uap
, a2
);
222 SCARG(&msgget_args
, msgflg
) = SCARG(uap
, a3
);
223 return (sys_msgget(l
, &msgget_args
, retval
));
225 case 2: /* msgsnd() */
226 SCARG(&msgsnd_args
, msqid
) = SCARG(uap
, a2
);
227 SCARG(&msgsnd_args
, msgp
) = (void *)SCARG(uap
, a3
);
228 SCARG(&msgsnd_args
, msgsz
) = SCARG(uap
, a4
);
229 SCARG(&msgsnd_args
, msgflg
) = SCARG(uap
, a5
);
230 return (sys_msgsnd(l
, &msgsnd_args
, retval
));
232 case 3: /* msgrcv() */
233 SCARG(&msgrcv_args
, msqid
) = SCARG(uap
, a2
);
234 SCARG(&msgrcv_args
, msgp
) = (void *)SCARG(uap
, a3
);
235 SCARG(&msgrcv_args
, msgsz
) = SCARG(uap
, a4
);
236 SCARG(&msgrcv_args
, msgtyp
) = SCARG(uap
, a5
);
237 SCARG(&msgrcv_args
, msgflg
) = SCARG(uap
, a6
);
238 return (sys_msgrcv(l
, &msgrcv_args
, retval
));