kern_ipc_10.c revision 1.1 1 /* $NetBSD: kern_ipc_10.c,v 1.1 1995/06/24 20:16:15 christos Exp $ */
2
3 /*
4 * Copyright (c) 1994 Adam Glass and Charles Hannum. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
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
17 * Hannum.
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.
20 *
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.
31 */
32
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/proc.h>
37 #include <sys/sem.h>
38 #include <sys/malloc.h>
39
40 #include <sys/mount.h>
41 #include <sys/syscallargs.h>
42
43 #include <vm/vm.h>
44 #include <vm/vm_map.h>
45 #include <vm/vm_map.h>
46 #include <vm/vm_kern.h>
47
48 int
49 compat_10_semsys(p, uap, retval)
50 struct proc *p;
51 struct compat_10_semsys_args /* {
52 syscallarg(int) which;
53 syscallarg(int) a2;
54 syscallarg(int) a3;
55 syscallarg(int) a4;
56 syscallarg(int) a5;
57 } */ *uap;
58 register_t *retval;
59 {
60 struct __semctl_args /* {
61 syscallarg(int) semid;
62 syscallarg(int) semnum;
63 syscallarg(int) cmd;
64 syscallarg(union semun *) arg;
65 } */ __semctl_args;
66 struct semget_args /* {
67 syscallarg(key_t) key;
68 syscallarg(int) nsems;
69 syscallarg(int) semflg;
70 } */ semget_args;
71 struct semop_args /* {
72 syscallarg(int) semid;
73 syscallarg(struct sembuf *) sops;
74 syscallarg(u_int) nsops;
75 } */ semop_args;
76 struct semconfig_args /* {
77 syscallarg(int) flag;
78 } */ semconfig_args;
79
80 switch (SCARG(uap, which)) {
81 case 0: /* __semctl() */
82 SCARG(&__semctl_args, semid) = SCARG(uap, a2);
83 SCARG(&__semctl_args, semnum) = SCARG(uap, a3);
84 SCARG(&__semctl_args, cmd) = SCARG(uap, a4);
85 SCARG(&__semctl_args, arg) = (union semun *)SCARG(uap, a5);
86 return (__semctl(p, &__semctl_args, retval));
87
88 case 1: /* semget() */
89 SCARG(&semget_args, key) = SCARG(uap, a2);
90 SCARG(&semget_args, nsems) = SCARG(uap, a3);
91 SCARG(&semget_args, semflg) = SCARG(uap, a4);
92 return (semget(p, &semget_args, retval));
93
94 case 2: /* semop() */
95 SCARG(&semop_args, semid) = SCARG(uap, a2);
96 SCARG(&semop_args, sops) = (struct sembuf *)SCARG(uap, a3);
97 SCARG(&semop_args, nsops) = SCARG(uap, a4);
98 return (semop(p, &semop_args, retval));
99
100 case 3: /* semconfig() */
101 SCARG(&semconfig_args, flag) = SCARG(uap, a2);
102 return (semconfig(p, &semconfig_args, retval));
103
104 default:
105 return (EINVAL);
106 }
107 }
108
109
110 int
111 compat_10_shmsys(p, uap, retval)
112 struct proc *p;
113 struct compat_10_shmsys_args /* {
114 syscallarg(int) which;
115 syscallarg(int) a2;
116 syscallarg(int) a3;
117 syscallarg(int) a4;
118 } */ *uap;
119 register_t *retval;
120 {
121 struct shmat_args /* {
122 syscallarg(int) shmid;
123 syscallarg(void *) shmaddr;
124 syscallarg(int) shmflg;
125 } */ shmat_args;
126 struct shmctl_args /* {
127 syscallarg(int) shmid;
128 syscallarg(int) cmd;
129 syscallarg(struct shmid_ds *) buf;
130 } */ shmctl_args;
131 struct shmdt_args /* {
132 syscallarg(void *) shmaddr;
133 } */ shmdt_args;
134 struct shmget_args /* {
135 syscallarg(key_t) key;
136 syscallarg(int) size;
137 syscallarg(int) shmflg;
138 } */ shmget_args;
139
140 switch (SCARG(uap, which)) {
141 case 0: /* shmat() */
142 SCARG(&shmat_args, shmid) = SCARG(uap, a2);
143 SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a3);
144 SCARG(&shmat_args, shmflg) = SCARG(uap, a4);
145 return (shmat(p, &shmat_args, retval));
146
147 case 1: /* shmctl() */
148 SCARG(&shmctl_args, shmid) = SCARG(uap, a2);
149 SCARG(&shmctl_args, cmd) = SCARG(uap, a3);
150 SCARG(&shmctl_args, buf) = (struct shmid_ds *)SCARG(uap, a4);
151 return (shmctl(p, &shmctl_args, retval));
152
153 case 2: /* shmdt() */
154 SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a2);
155 return (shmdt(p, &shmdt_args, retval));
156
157 case 3: /* shmget() */
158 SCARG(&shmget_args, key) = SCARG(uap, a2);
159 SCARG(&shmget_args, size) = SCARG(uap, a3);
160 SCARG(&shmget_args, shmflg) = SCARG(uap, a4);
161 return (shmget(p, &shmget_args, retval));
162
163 default:
164 return (EINVAL);
165 }
166 }
167
168
169 int
170 compat_10_msgsys(p, uap, retval)
171 struct caller *p;
172 struct compat_10_msgsys_args /* {
173 syscallarg(int) which;
174 syscallarg(int) a2;
175 syscallarg(int) a3;
176 syscallarg(int) a4;
177 syscallarg(int) a5;
178 syscallarg(int) a6;
179 } */ *uap;
180 register_t *retval;
181 {
182 struct msgctl_args /* {
183 syscallarg(int) msqid;
184 syscallarg(int) cmd;
185 syscallarg(struct msqid_ds *) buf;
186 } */ msgctl_args;
187 struct msgget_args /* {
188 syscallarg(key_t) key;
189 syscallarg(int) msgflg;
190 } */ msgget_args;
191 struct msgsnd_args /* {
192 syscallarg(int) msqid;
193 syscallarg(void *) msgp;
194 syscallarg(size_t) msgsz;
195 syscallarg(int) msgflg;
196 } */ msgsnd_args;
197 struct msgrcv_args /* {
198 syscallarg(int) msqid;
199 syscallarg(void *) msgp;
200 syscallarg(size_t) msgsz;
201 syscallarg(long) msgtyp;
202 syscallarg(int) msgflg;
203 } */ msgrcv_args;
204
205 switch (SCARG(uap, which)) {
206 case 0: /* msgctl()*/
207 SCARG(&msgctl_args, msqid) = SCARG(uap, a2);
208 SCARG(&msgctl_args, cmd) = SCARG(uap, a3);
209 SCARG(&msgctl_args, buf) =
210 (struct msqid_ds *)SCARG(uap, a4);
211 return (msgctl(p, &msgctl_args, retval));
212
213 case 1: /* msgget() */
214 SCARG(&msgget_args, key) = SCARG(uap, a2);
215 SCARG(&msgget_args, msgflg) = SCARG(uap, a3);
216 return (msgget(p, &msgget_args, retval));
217
218 case 2: /* msgsnd() */
219 SCARG(&msgsnd_args, msqid) = SCARG(uap, a2);
220 SCARG(&msgsnd_args, msgp) = (void *)SCARG(uap, a3);
221 SCARG(&msgsnd_args, msgsz) = SCARG(uap, a4);
222 SCARG(&msgsnd_args, msgflg) = SCARG(uap, a5);
223 return (msgsnd(p, &msgsnd_args, retval));
224
225 case 3: /* msgrcv() */
226 SCARG(&msgrcv_args, msqid) = SCARG(uap, a2);
227 SCARG(&msgrcv_args, msgp) = (void *)SCARG(uap, a3);
228 SCARG(&msgrcv_args, msgsz) = SCARG(uap, a4);
229 SCARG(&msgrcv_args, msgtyp) = SCARG(uap, a5);
230 SCARG(&msgrcv_args, msgflg) = SCARG(uap, a6);
231 return (msgrcv(p, &msgrcv_args, retval));
232
233 default:
234 return (EINVAL);
235 }
236 }
237