kern_ipc_10.c revision 1.1 1 1.1 christos /* $NetBSD: kern_ipc_10.c,v 1.1 1995/06/24 20:16:15 christos Exp $ */
2 1.1 christos
3 1.1 christos /*
4 1.1 christos * Copyright (c) 1994 Adam Glass and Charles Hannum. All rights reserved.
5 1.1 christos *
6 1.1 christos * Redistribution and use in source and binary forms, with or without
7 1.1 christos * modification, are permitted provided that the following conditions
8 1.1 christos * are met:
9 1.1 christos * 1. Redistributions of source code must retain the above copyright
10 1.1 christos * notice, this list of conditions and the following disclaimer.
11 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 christos * notice, this list of conditions and the following disclaimer in the
13 1.1 christos * documentation and/or other materials provided with the distribution.
14 1.1 christos * 3. All advertising materials mentioning features or use of this software
15 1.1 christos * must display the following acknowledgement:
16 1.1 christos * This product includes software developed by Adam Glass and Charles
17 1.1 christos * Hannum.
18 1.1 christos * 4. The names of the authors may not be used to endorse or promote products
19 1.1 christos * derived from this software without specific prior written permission.
20 1.1 christos *
21 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
22 1.1 christos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 christos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 christos * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 christos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 christos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 christos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 christos */
32 1.1 christos
33 1.1 christos #include <sys/param.h>
34 1.1 christos #include <sys/systm.h>
35 1.1 christos #include <sys/kernel.h>
36 1.1 christos #include <sys/proc.h>
37 1.1 christos #include <sys/sem.h>
38 1.1 christos #include <sys/malloc.h>
39 1.1 christos
40 1.1 christos #include <sys/mount.h>
41 1.1 christos #include <sys/syscallargs.h>
42 1.1 christos
43 1.1 christos #include <vm/vm.h>
44 1.1 christos #include <vm/vm_map.h>
45 1.1 christos #include <vm/vm_map.h>
46 1.1 christos #include <vm/vm_kern.h>
47 1.1 christos
48 1.1 christos int
49 1.1 christos compat_10_semsys(p, uap, retval)
50 1.1 christos struct proc *p;
51 1.1 christos struct compat_10_semsys_args /* {
52 1.1 christos syscallarg(int) which;
53 1.1 christos syscallarg(int) a2;
54 1.1 christos syscallarg(int) a3;
55 1.1 christos syscallarg(int) a4;
56 1.1 christos syscallarg(int) a5;
57 1.1 christos } */ *uap;
58 1.1 christos register_t *retval;
59 1.1 christos {
60 1.1 christos struct __semctl_args /* {
61 1.1 christos syscallarg(int) semid;
62 1.1 christos syscallarg(int) semnum;
63 1.1 christos syscallarg(int) cmd;
64 1.1 christos syscallarg(union semun *) arg;
65 1.1 christos } */ __semctl_args;
66 1.1 christos struct semget_args /* {
67 1.1 christos syscallarg(key_t) key;
68 1.1 christos syscallarg(int) nsems;
69 1.1 christos syscallarg(int) semflg;
70 1.1 christos } */ semget_args;
71 1.1 christos struct semop_args /* {
72 1.1 christos syscallarg(int) semid;
73 1.1 christos syscallarg(struct sembuf *) sops;
74 1.1 christos syscallarg(u_int) nsops;
75 1.1 christos } */ semop_args;
76 1.1 christos struct semconfig_args /* {
77 1.1 christos syscallarg(int) flag;
78 1.1 christos } */ semconfig_args;
79 1.1 christos
80 1.1 christos switch (SCARG(uap, which)) {
81 1.1 christos case 0: /* __semctl() */
82 1.1 christos SCARG(&__semctl_args, semid) = SCARG(uap, a2);
83 1.1 christos SCARG(&__semctl_args, semnum) = SCARG(uap, a3);
84 1.1 christos SCARG(&__semctl_args, cmd) = SCARG(uap, a4);
85 1.1 christos SCARG(&__semctl_args, arg) = (union semun *)SCARG(uap, a5);
86 1.1 christos return (__semctl(p, &__semctl_args, retval));
87 1.1 christos
88 1.1 christos case 1: /* semget() */
89 1.1 christos SCARG(&semget_args, key) = SCARG(uap, a2);
90 1.1 christos SCARG(&semget_args, nsems) = SCARG(uap, a3);
91 1.1 christos SCARG(&semget_args, semflg) = SCARG(uap, a4);
92 1.1 christos return (semget(p, &semget_args, retval));
93 1.1 christos
94 1.1 christos case 2: /* semop() */
95 1.1 christos SCARG(&semop_args, semid) = SCARG(uap, a2);
96 1.1 christos SCARG(&semop_args, sops) = (struct sembuf *)SCARG(uap, a3);
97 1.1 christos SCARG(&semop_args, nsops) = SCARG(uap, a4);
98 1.1 christos return (semop(p, &semop_args, retval));
99 1.1 christos
100 1.1 christos case 3: /* semconfig() */
101 1.1 christos SCARG(&semconfig_args, flag) = SCARG(uap, a2);
102 1.1 christos return (semconfig(p, &semconfig_args, retval));
103 1.1 christos
104 1.1 christos default:
105 1.1 christos return (EINVAL);
106 1.1 christos }
107 1.1 christos }
108 1.1 christos
109 1.1 christos
110 1.1 christos int
111 1.1 christos compat_10_shmsys(p, uap, retval)
112 1.1 christos struct proc *p;
113 1.1 christos struct compat_10_shmsys_args /* {
114 1.1 christos syscallarg(int) which;
115 1.1 christos syscallarg(int) a2;
116 1.1 christos syscallarg(int) a3;
117 1.1 christos syscallarg(int) a4;
118 1.1 christos } */ *uap;
119 1.1 christos register_t *retval;
120 1.1 christos {
121 1.1 christos struct shmat_args /* {
122 1.1 christos syscallarg(int) shmid;
123 1.1 christos syscallarg(void *) shmaddr;
124 1.1 christos syscallarg(int) shmflg;
125 1.1 christos } */ shmat_args;
126 1.1 christos struct shmctl_args /* {
127 1.1 christos syscallarg(int) shmid;
128 1.1 christos syscallarg(int) cmd;
129 1.1 christos syscallarg(struct shmid_ds *) buf;
130 1.1 christos } */ shmctl_args;
131 1.1 christos struct shmdt_args /* {
132 1.1 christos syscallarg(void *) shmaddr;
133 1.1 christos } */ shmdt_args;
134 1.1 christos struct shmget_args /* {
135 1.1 christos syscallarg(key_t) key;
136 1.1 christos syscallarg(int) size;
137 1.1 christos syscallarg(int) shmflg;
138 1.1 christos } */ shmget_args;
139 1.1 christos
140 1.1 christos switch (SCARG(uap, which)) {
141 1.1 christos case 0: /* shmat() */
142 1.1 christos SCARG(&shmat_args, shmid) = SCARG(uap, a2);
143 1.1 christos SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a3);
144 1.1 christos SCARG(&shmat_args, shmflg) = SCARG(uap, a4);
145 1.1 christos return (shmat(p, &shmat_args, retval));
146 1.1 christos
147 1.1 christos case 1: /* shmctl() */
148 1.1 christos SCARG(&shmctl_args, shmid) = SCARG(uap, a2);
149 1.1 christos SCARG(&shmctl_args, cmd) = SCARG(uap, a3);
150 1.1 christos SCARG(&shmctl_args, buf) = (struct shmid_ds *)SCARG(uap, a4);
151 1.1 christos return (shmctl(p, &shmctl_args, retval));
152 1.1 christos
153 1.1 christos case 2: /* shmdt() */
154 1.1 christos SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a2);
155 1.1 christos return (shmdt(p, &shmdt_args, retval));
156 1.1 christos
157 1.1 christos case 3: /* shmget() */
158 1.1 christos SCARG(&shmget_args, key) = SCARG(uap, a2);
159 1.1 christos SCARG(&shmget_args, size) = SCARG(uap, a3);
160 1.1 christos SCARG(&shmget_args, shmflg) = SCARG(uap, a4);
161 1.1 christos return (shmget(p, &shmget_args, retval));
162 1.1 christos
163 1.1 christos default:
164 1.1 christos return (EINVAL);
165 1.1 christos }
166 1.1 christos }
167 1.1 christos
168 1.1 christos
169 1.1 christos int
170 1.1 christos compat_10_msgsys(p, uap, retval)
171 1.1 christos struct caller *p;
172 1.1 christos struct compat_10_msgsys_args /* {
173 1.1 christos syscallarg(int) which;
174 1.1 christos syscallarg(int) a2;
175 1.1 christos syscallarg(int) a3;
176 1.1 christos syscallarg(int) a4;
177 1.1 christos syscallarg(int) a5;
178 1.1 christos syscallarg(int) a6;
179 1.1 christos } */ *uap;
180 1.1 christos register_t *retval;
181 1.1 christos {
182 1.1 christos struct msgctl_args /* {
183 1.1 christos syscallarg(int) msqid;
184 1.1 christos syscallarg(int) cmd;
185 1.1 christos syscallarg(struct msqid_ds *) buf;
186 1.1 christos } */ msgctl_args;
187 1.1 christos struct msgget_args /* {
188 1.1 christos syscallarg(key_t) key;
189 1.1 christos syscallarg(int) msgflg;
190 1.1 christos } */ msgget_args;
191 1.1 christos struct msgsnd_args /* {
192 1.1 christos syscallarg(int) msqid;
193 1.1 christos syscallarg(void *) msgp;
194 1.1 christos syscallarg(size_t) msgsz;
195 1.1 christos syscallarg(int) msgflg;
196 1.1 christos } */ msgsnd_args;
197 1.1 christos struct msgrcv_args /* {
198 1.1 christos syscallarg(int) msqid;
199 1.1 christos syscallarg(void *) msgp;
200 1.1 christos syscallarg(size_t) msgsz;
201 1.1 christos syscallarg(long) msgtyp;
202 1.1 christos syscallarg(int) msgflg;
203 1.1 christos } */ msgrcv_args;
204 1.1 christos
205 1.1 christos switch (SCARG(uap, which)) {
206 1.1 christos case 0: /* msgctl()*/
207 1.1 christos SCARG(&msgctl_args, msqid) = SCARG(uap, a2);
208 1.1 christos SCARG(&msgctl_args, cmd) = SCARG(uap, a3);
209 1.1 christos SCARG(&msgctl_args, buf) =
210 1.1 christos (struct msqid_ds *)SCARG(uap, a4);
211 1.1 christos return (msgctl(p, &msgctl_args, retval));
212 1.1 christos
213 1.1 christos case 1: /* msgget() */
214 1.1 christos SCARG(&msgget_args, key) = SCARG(uap, a2);
215 1.1 christos SCARG(&msgget_args, msgflg) = SCARG(uap, a3);
216 1.1 christos return (msgget(p, &msgget_args, retval));
217 1.1 christos
218 1.1 christos case 2: /* msgsnd() */
219 1.1 christos SCARG(&msgsnd_args, msqid) = SCARG(uap, a2);
220 1.1 christos SCARG(&msgsnd_args, msgp) = (void *)SCARG(uap, a3);
221 1.1 christos SCARG(&msgsnd_args, msgsz) = SCARG(uap, a4);
222 1.1 christos SCARG(&msgsnd_args, msgflg) = SCARG(uap, a5);
223 1.1 christos return (msgsnd(p, &msgsnd_args, retval));
224 1.1 christos
225 1.1 christos case 3: /* msgrcv() */
226 1.1 christos SCARG(&msgrcv_args, msqid) = SCARG(uap, a2);
227 1.1 christos SCARG(&msgrcv_args, msgp) = (void *)SCARG(uap, a3);
228 1.1 christos SCARG(&msgrcv_args, msgsz) = SCARG(uap, a4);
229 1.1 christos SCARG(&msgrcv_args, msgtyp) = SCARG(uap, a5);
230 1.1 christos SCARG(&msgrcv_args, msgflg) = SCARG(uap, a6);
231 1.1 christos return (msgrcv(p, &msgrcv_args, retval));
232 1.1 christos
233 1.1 christos default:
234 1.1 christos return (EINVAL);
235 1.1 christos }
236 1.1 christos }
237