makesyscalls.sh revision 1.169.10.1 1 # $NetBSD: makesyscalls.sh,v 1.169.10.1 2019/06/10 22:09:03 christos Exp $
2 #
3 # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou
4 # 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 for the NetBSD Project
17 # by Christopher G. Demetriou.
18 # 4. The name of the author 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 AUTHOR ``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 AUTHOR 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 # @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93
33
34 set -e
35
36 case $# in
37 2) ;;
38 *) echo "Usage: $0 config-file input-file" 1>&2
39 exit 1
40 ;;
41 esac
42
43 # the config file sets the following variables:
44 # sysalign check for alignment of off_t/dev_t/time_t
45 # sysnames the syscall names file
46 # sysnumhdr the syscall numbers file
47 # syssw the syscall switch file
48 # sysautoload the syscall autoload definitions file
49 # sysarghdr the syscall argument struct definitions
50 # compatopts those syscall types that are for 'compat' syscalls
51 # switchname the name for the 'struct sysent' we define
52 # namesname the name for the 'const char *[]' we define
53 # constprefix the prefix for the system call constants
54 # emulname the emulation name
55 # registertype the type for register_t
56 # nsysent the size of the sysent table
57 # sys_nosys [optional] name of function called for unsupported
58 # syscalls, if not sys_nosys()
59 # maxsysargs [optiona] the maximum number or arguments
60 #
61 # NOTE THAT THIS makesyscalls.sh DOES NOT SUPPORT 'SYSLIBCOMPAT'.
62
63 # source the config file.
64 sys_nosys="sys_nosys" # default is sys_nosys(), if not specified otherwise
65 maxsysargs=8 # default limit is 8 (32bit) arguments
66 systrace="/dev/null"
67 sysautoload="/dev/null"
68 rumpcalls="/dev/null"
69 rumpcallshdr="/dev/null"
70 rumpsysmap="/dev/null"
71 rumpsysent="rumpsysent.tmp"
72 rumpnoflags="\n\t\t.sy_flags = SYCALL_NOSYS,"
73 rumpnosys="(sy_call_t *)rumpns_enosys"
74 rumpnomodule="(sy_call_t *)rumpns_sys_nomodule"
75
76 case $1 in
77 /*) . $1;;
78 *) . ./$1;;
79 esac
80
81 errmsg()
82 {
83 fail=true;
84 printf '%s: %s\n' "$0" "$*" >&2
85 }
86
87 fail=false
88 case "${nsysent:-0}" in
89 *[!0-9]*) errmsg "Non numeric value for nsysent:" "${nsysent}";;
90 esac
91 case "${maxsysargs:-0}" in
92 *[!0-9]*) errmsg "Non numeric value for maxsysargs:" "${maxsysargs}";;
93 esac
94 $fail && exit 1
95
96 # tmp files:
97 sysdcl="sysent.dcl"
98 sysprotos="sys.protos"
99 syscompat_pref="sysent."
100 sysent="sysent.switch"
101 sysnamesbottom="$sysnames.bottom"
102 sysnamesfriendly="$sysnames.friendly"
103 rumptypes="rumphdr.types"
104 rumpprotos="rumphdr.protos"
105 systracetmp="systrace.$$"
106 systraceret="systraceret.$$"
107
108 cleanup() {
109 rm $sysdcl $sysprotos $sysent $sysnamesbottom $sysnamesfriendly $rumpsysent $rumptypes $rumpprotos $systracetmp $systraceret
110 }
111 trap "cleanup" 0
112
113 # Awk program (must support nawk extensions)
114 # Use "awk" at Berkeley, "nawk" or "gawk" elsewhere.
115 awk=${AWK:-awk}
116
117 # Does this awk have a "toupper" function?
118 have_toupper="$($awk 'BEGIN { print toupper("true"); exit; }' 2>/dev/null)"
119
120 # If this awk does not define "toupper" then define our own.
121 if [ "$have_toupper" = TRUE ] ; then
122 # Used awk (GNU awk or nawk) provides it
123 toupper=
124 else
125 # Provide our own toupper()
126 toupper='
127 function toupper(str) {
128 _toupper_cmd = "echo "str" |tr a-z A-Z"
129 _toupper_cmd | getline _toupper_str;
130 close(_toupper_cmd);
131 return _toupper_str;
132 }'
133 fi
134
135 # before handing it off to awk, make a few adjustments:
136 # (1) insert spaces around {, }, (, ), *, and commas.
137 # (2) get rid of any and all dollar signs (so that rcs id use safe)
138 #
139 # The awk script will deal with blank lines and lines that
140 # start with the comment character (';').
141
142 sed -e '
143 s/\$//g
144 :join
145 /\\$/{a\
146
147 N
148 s/\\\n//
149 b join
150 }
151 2,${
152 /^#/!s/\([{}()*,|]\)/ \1 /g
153 }
154 ' < $2 | $awk "
155 $toupper
156 BEGIN {
157 # Create a NetBSD tag that does not get expanded when checking
158 # this script out of CVS. (This part of the awk script is in a
159 # shell double-quoted string, so the backslashes are eaten by
160 # the shell.)
161 tag = \"\$\" \"NetBSD\" \"\$\"
162
163 # to allow nested #if/#else/#endif sets
164 savedepth = 0
165 auto_skip = 0
166 # to track already processed syscalls
167
168 sysnames = \"$sysnames\"
169 sysprotos = \"$sysprotos\"
170 sysnumhdr = \"$sysnumhdr\"
171 sysarghdr = \"$sysarghdr\"
172 sysarghdrextra = \"$sysarghdrextra\"
173 systrace = \"$systrace\"
174 systracetmp = \"$systracetmp\"
175 systraceret = \"$systraceret\"
176 sysautoload = \"$sysautoload\"
177 rumpcalls = \"$rumpcalls\"
178 rumpcallshdr = \"$rumpcallshdr\"
179 rumpsysent = \"$rumpsysent\"
180 rumpsysmap = \"$rumpsysmap\"
181 switchname = \"$switchname\"
182 namesname = \"$namesname\"
183 constprefix = \"$constprefix\"
184 emulname = \"$emulname\"
185 registertype = \"$registertype\"
186 sysalign=\"$sysalign\"
187 if (!registertype) {
188 registertype = \"register_t\"
189 }
190 nsysent = ${nsysent:-0}
191
192 sysdcl = \"$sysdcl\"
193 syscompat_pref = \"$syscompat_pref\"
194 sysent = \"$sysent\"
195 sysnamesbottom = \"${sysnames}.bottom\"
196 sysnamesfriendly = \"${sysnames}.friendly\"
197 rumpprotos = \"$rumpprotos\"
198 rumptypes = \"$rumptypes\"
199 sys_nosys = \"$sys_nosys\"
200 maxsysargs = ${maxsysargs:-8}
201 rumpnoflags=\"$rumpnoflags\"
202 rumpnosys=\"$rumpnosys\"
203 rumpnomodule=\"$rumpnomodule\"
204 infile = \"$2\"
205
206 compatopts = \"$compatopts\"
207 "'
208
209 if (rumpcalls != "/dev/null")
210 haverumpcalls = 1
211
212 printf "/* %s */\n\n", tag > sysdcl
213 printf "/*\n * System call switch table.\n *\n" > sysdcl
214 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl
215
216 ncompat = split(compatopts,compat)
217 for (i = 1; i <= ncompat; i++) {
218 compat_upper[i] = toupper(compat[i])
219
220 printf "\n#ifdef %s\n", compat_upper[i] > sysent
221 printf "#define %s(func) __CONCAT(%s_,func)\n", compat[i], \
222 compat[i] > sysent
223 printf "#else\n" > sysent
224 printf "#define %s(func) %s\n", compat[i], sys_nosys > sysent
225 printf "#endif\n" > sysent
226 }
227
228 printf "\n#define\ts(type)\tsizeof(type)\n" > sysent
229 printf "#define\tn(type)\t(sizeof(type)/sizeof (%s))\n", registertype > sysent
230 printf "#define\tns(type)\t.sy_narg = n(type), .sy_argsize = s(type)\n\n", registertype > sysent
231 printf "struct sysent %s[] = {\n",switchname > sysent
232
233 printf "/* %s */\n\n", tag > sysnames
234 printf "/*\n * System call names.\n *\n" > sysnames
235 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames
236
237 printf "\n/*\n * System call prototypes.\n */\n\n" > sysprotos
238 if (haverumpcalls)
239 printf("#ifndef RUMP_CLIENT\n") > sysprotos
240
241 printf "/* %s */\n\n", tag > sysnumhdr
242 printf "/*\n * System call numbers.\n *\n" > sysnumhdr
243 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnumhdr
244
245 printf "/* %s */\n\n", tag > sysarghdr
246 printf "/*\n * System call argument lists.\n *\n" > sysarghdr
247 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysarghdr
248
249 printf "/* %s */\n\n", tag > sysautoload
250 printf "/*\n * System call autoload table.\n *\n" > sysautoload
251 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysautoload
252
253 printf "/* %s */\n\n", tag > rumpcalls
254 printf "/*\n * System call vector and marshalling for rump.\n *\n" > rumpcalls
255 printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcalls
256
257 printf "/* %s */\n\n", tag > rumpcallshdr
258 printf "/*\n * System call protos in rump namespace.\n *\n" > rumpcallshdr
259 printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcallshdr
260
261 printf "/* %s */\n\n", tag > systrace
262 printf "/*\n * System call argument to DTrace register array converstion.\n *\n" > systrace
263 printf " * DO NOT EDIT-- this file is automatically generated.\n" > systrace
264 }
265 NR == 1 {
266 sub(/ $/, "")
267 printf " * created from%s\n */\n\n", $0 > sysdcl
268 printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysdcl
269
270 printf " * created from%s\n */\n\n", $0 > sysnames
271 printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysnames
272
273 printf " * created from%s\n */\n\n", $0 > sysautoload
274 printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysautoload
275 printf("#include <sys/proc.h>\n") > sysautoload
276 printf("static struct sc_autoload " emulname \
277 "_syscalls_autoload[] = {\n") > sysautoload
278
279 printf " * created from%s\n */\n\n", $0 > rumpcalls
280 printf "#ifdef RUMP_CLIENT\n" > rumpcalls
281 printf "#include <rump/rumpuser_port.h>\n" > rumpcalls
282 printf "#endif /* RUMP_CLIENT */\n\n" > rumpcalls
283 printf "#include <sys/param.h>\n\n" > rumpcalls
284 printf "#ifdef __NetBSD__\n" > rumpcalls
285 printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > rumpcalls
286
287 printf "#include <sys/fstypes.h>\n" > rumpcalls
288 printf "#include <sys/proc.h>\n" > rumpcalls
289 printf "#endif /* __NetBSD__ */\n\n" > rumpcalls
290 printf "#ifdef RUMP_CLIENT\n" > rumpcalls
291 printf "#include <errno.h>\n" > rumpcalls
292 printf "#include <stdint.h>\n" > rumpcalls
293 printf "#include <stdlib.h>\n" > rumpcalls
294 printf "#include <string.h>\n\n" > rumpcalls
295 printf "#include <srcsys/syscall.h>\n" > rumpcalls
296 printf "#include <srcsys/syscallargs.h>\n\n" > rumpcalls
297 printf "#include <rump/rumpclient.h>\n\n" > rumpcalls
298 printf "#define rsys_syscall(num, data, dlen, retval)\t\\\n" > rumpcalls
299 printf " rumpclient_syscall(num, data, dlen, retval)\n" > rumpcalls
300 printf "#define rsys_seterrno(error) errno = error\n" > rumpcalls
301 printf "#else\n" > rumpcalls
302 printf "#include <sys/syscall.h>\n" > rumpcalls
303 printf "#include <sys/syscallargs.h>\n\n" > rumpcalls
304 printf "#include <sys/syscallvar.h>\n\n" > rumpcalls
305 printf "#include <rump-sys/kern.h>\n\n" > rumpcalls
306 printf "#include <rump/rumpuser.h>\n" > rumpcalls
307 printf "#define rsys_syscall(num, data, dlen, retval)\t\\\n" > rumpcalls
308 printf " rump_syscall(num, data, dlen, retval)\n\n" > rumpcalls
309 printf "#define rsys_seterrno(error) rumpuser_seterrno(error)\n" \
310 > rumpcalls
311 printf "#endif\n\n" > rumpcalls
312
313 printf "#ifndef RUMP_KERNEL_IS_LIBC\n" > rumpcalls
314 printf "#define RUMP_SYS_COMPAT\n" > rumpcalls
315 printf "#endif\n\n" > rumpcalls
316
317 printf "#if\tBYTE_ORDER == BIG_ENDIAN\n" > rumpcalls
318 printf "#define SPARG(p,k)\t((p)->k.be.datum)\n" > rumpcalls
319 printf "#else /* LITTLE_ENDIAN, I hope dearly */\n" > rumpcalls
320 printf "#define SPARG(p,k)\t((p)->k.le.datum)\n" > rumpcalls
321 printf "#endif\n\n" > rumpcalls
322 printf "\nvoid rumpns_sys_nomodule(void);\n" > rumpcalls
323
324 printf "\n#ifndef RUMP_CLIENT\n" > rumpsysent
325 printf "int rumpns_enosys(void);\n" > rumpsysent
326 printf "#define\ts(type)\tsizeof(type)\n" > rumpsysent
327 printf "#define\tn(type)\t(sizeof(type)/sizeof (%s))\n", registertype > rumpsysent
328 printf "#define\tns(type)\tn(type), s(type)\n\n", registertype > rumpsysent
329 printf "struct sysent rump_sysent[] = {\n" > rumpsysent
330
331 # System call names are included by userland (kdump(1)), so
332 # hide the include files from it.
333 printf "#if defined(_KERNEL_OPT)\n" > sysnames
334
335 printf "#else /* _KERNEL_OPT */\n" > sysnamesbottom
336 printf "#include <sys/null.h>\n" > sysnamesbottom
337 printf "#endif /* _KERNEL_OPT */\n\n" > sysnamesbottom
338 printf "const char *const %s[] = {\n",namesname > sysnamesbottom
339 printf "\n\n/* libc style syscall names */\n" > sysnamesfriendly
340 printf "const char *const alt%s[] = {\n", namesname > sysnamesfriendly
341
342 printf " * created from%s\n */\n\n", $0 > sysnumhdr
343 printf "#ifndef _" constprefix "SYSCALL_H_\n" > sysnumhdr
344 printf "#define _" constprefix "SYSCALL_H_\n\n" > sysnumhdr
345
346 printf " * created from%s\n */\n\n", $0 > sysarghdr
347 printf "#ifndef _" constprefix "SYSCALLARGS_H_\n" > sysarghdr
348 printf "#define _" constprefix "SYSCALLARGS_H_\n\n" > sysarghdr
349
350 printf " * created from%s\n */\n\n", $0 > rumpcallshdr
351 printf "#ifndef _RUMP_RUMP_SYSCALLS_H_\n" > rumpcallshdr
352 printf "#define _RUMP_RUMP_SYSCALLS_H_\n\n" > rumpcallshdr
353 printf "#ifdef _KERNEL\n" > rumpcallshdr
354 printf "#error Interface not supported inside kernel\n" > rumpcallshdr
355 printf "#endif /* _KERNEL */\n\n" > rumpcallshdr
356 printf "#include <rump/rump_syscalls_compat.h>\n\n" > rumpcallshdr
357
358 printf "%s", sysarghdrextra > sysarghdr
359 printf "/* Forward declaration */\n" > sysarghdr
360 printf "struct lwp;\n" > sysarghdr
361 printf "\n" > sysarghdr
362
363 # Write max number of system call arguments to both headers
364 printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \
365 > sysnumhdr
366 printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \
367 > sysarghdr
368 printf "#undef\tsyscallarg\n" > sysarghdr
369 printf "#define\tsyscallarg(x)\t\t\t\t\t\t\t\\\n" > sysarghdr
370 printf "\tunion {\t\t\t\t\t\t\t\t\\\n" > sysarghdr
371 printf "\t\t%s pad;\t\t\t\t\t\t\\\n", registertype > sysarghdr
372 printf "\t\tstruct { x datum; } le;\t\t\t\t\t\\\n" > sysarghdr
373 printf "\t\tstruct { /* LINTED zero array dimension */\t\t\\\n" \
374 > sysarghdr
375 printf "\t\t\tint8_t pad[ /* CONSTCOND */\t\t\t\\\n" > sysarghdr
376 printf "\t\t\t\t(sizeof (%s) < sizeof (x))\t\\\n", \
377 registertype > sysarghdr
378 printf "\t\t\t\t? 0\t\t\t\t\t\\\n" > sysarghdr
379 printf "\t\t\t\t: sizeof (%s) - sizeof (x)];\t\\\n", \
380 registertype > sysarghdr
381 printf "\t\t\tx datum;\t\t\t\t\t\\\n" > sysarghdr
382 printf "\t\t} be;\t\t\t\t\t\t\t\\\n" > sysarghdr
383 printf "\t}\n" > sysarghdr
384 printf("\n#undef check_syscall_args\n") >sysarghdr
385 printf("#define check_syscall_args(call) /*LINTED*/ \\\n" \
386 "\ttypedef char call##_check_args" \
387 "[sizeof (struct call##_args) \\\n" \
388 "\t\t<= %sMAXSYSARGS * sizeof (%s) ? 1 : -1];\n", \
389 constprefix, registertype) >sysarghdr
390
391 printf " * This file is part of the DTrace syscall provider.\n */\n\n" > systrace
392 printf "static void\nsystrace_args(register_t sysnum, const void *params, uintptr_t *uarg, size_t *n_args)\n{\n" > systrace
393 printf "\tintptr_t *iarg = (intptr_t *)uarg;\n" > systrace
394 printf "\tswitch (sysnum) {\n" > systrace
395
396 printf "static void\nsystrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systracetmp
397 printf "\tswitch (sysnum) {\n" > systracetmp
398
399 printf "static void\nsystrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systraceret
400 printf "\tswitch (sysnum) {\n" > systraceret
401
402 # compat types from syscalls.master. this is slightly ugly,
403 # but given that we have so few compats from over 17 years,
404 # a more complicated solution is not currently warranted.
405 uncompattypes["struct timeval50"] = "struct timeval";
406 uncompattypes["struct timespec50"] = "struct timespec";
407 uncompattypes["struct stat30"] = "struct stat";
408
409 next
410 }
411 NF == 0 || $1 ~ /^;/ {
412 next
413 }
414 $0 ~ /^%%$/ {
415 intable = 1
416 next
417 }
418 $1 ~ /^#[ ]*include/ {
419 print > sysdcl
420 print > sysnames
421 next
422 }
423 $1 ~ /^#/ && !intable {
424 print > sysdcl
425 print > sysnames
426 next
427 }
428 $1 ~ /^#/ && intable {
429 if ($1 ~ /^#[ ]*if/) {
430 savedepth++
431 savesyscall[savedepth] = syscall
432 skip_auto[savedepth] = auto_skip
433 auto_skip = 0
434
435 # Special handling for sysautoload conditionals
436 #
437 # We ignore all conditions other than those for
438 # !defined(_LP64) which are used for SYSV* syscalls
439 # only
440
441 if ($0 ~ /!defined\(_LP64\)/) {
442 printf("#if !defined(_LP64)\n") > sysautoload
443 auto_skip = savedepth
444 }
445 }
446 if ($1 ~ /^#[ ]*else/) {
447 if (savedepth <= 0) {
448 printf("%s: line %d: unbalanced #else\n", \
449 infile, NR)
450 exit 1
451 }
452 if (auto_skip == savedepth) {
453 print > sysautoload
454 }
455 syscall = savesyscall[savedepth]
456 }
457 if ($1 ~ /^#[ ]*endif/) {
458 if (savedepth <= 0) {
459 printf("%s: line %d: unbalanced #endif\n", \
460 infile, NR)
461 exit 1
462 }
463 if (auto_skip == savedepth) {
464 print > sysautoload
465 }
466 auto_skip = skip_auto[savedepth];
467 savedepth--
468 }
469 print > sysent
470 print > sysarghdr
471 print > sysnumhdr
472 print > sysprotos
473 print > sysnamesbottom
474 print > sysnamesfriendly
475 print > systrace
476 print > systracetmp
477 print > systraceret
478
479 # XXX: technically we do not want to have conditionals in rump,
480 # but it is easier to just let the cpp handle them than try to
481 # figure out what we want here in this script
482 print > rumpsysent
483 next
484 }
485 syscall != $1 {
486 printf "%s: line %d: syscall number out of sync at %d\n", \
487 infile, NR, syscall
488 printf "line is:\n"
489 print
490 exit 1
491 }
492 function isarg64(type) {
493 gsub("netbsd32_", "", type);
494 return type == "quad_t" || type == "off_t" \
495 || type == "dev_t" || type == "time_t";
496 }
497 function parserr(was, wanted) {
498 printf "%s: line %d: unexpected %s (expected <%s>)\n", \
499 infile, NR, was, wanted
500 printf "line is:\n"
501 print
502 exit 1
503 }
504 function fillerpsysent(syscall, flags, name, comment) {
505 return sprintf("\t{%s\n\t\t.sy_call = %s,\n\t},\t\t/* %d = filler */",\
506 flags, name, syscall, comment);
507 }
508 function parseline() {
509 f=3 # toss number and type
510 if ($2 == "INDIR")
511 sycall_flags="SYCALL_INDIRECT"
512 else
513 sycall_flags="0"
514 if ($NF != "}") {
515 funcalias=$NF
516 end=NF-1
517 } else {
518 funcalias=""
519 end=NF
520 }
521 if ($f == "INDIR") { # allow for "NOARG INDIR"
522 sycall_flags = "SYCALL_INDIRECT | " sycall_flags
523 f++
524 }
525 if ($f == "MODULAR") { # registered at runtime
526 modular = 1
527 f++
528 modname = $f
529 f++
530 } else {
531 modular = 0;
532 }
533 if ($f == "RUMP") {
534 rumpable = 1
535 f++
536 } else {
537 rumpable = 0
538 }
539 if ($f ~ /^[a-z0-9_]*$/) { # allow syscall alias
540 funcalias=$f
541 f++
542 }
543 if ($f != "{")
544 parserr($f, "{")
545 f++
546 if ($end != "}")
547 parserr($end, "}")
548 end--
549 if ($end != ";")
550 parserr($end, ";")
551 end--
552 if ($end != ")")
553 parserr($end, ")")
554 end--
555
556 returntype = oldf = "";
557 do {
558 if (returntype != "" && oldf != "*")
559 returntype = returntype" ";
560 returntype = returntype$f;
561 oldf = $f;
562 f++
563 } while ($f != "|" && f < (end-1))
564 if (f == (end - 1)) {
565 parserr($f, "function argument definition (maybe \"|\"?)");
566 }
567 f++
568
569 fprefix=$f
570 f++
571 if ($f != "|") {
572 parserr($f, "function compat delimiter (maybe \"|\"?)");
573 }
574 f++
575
576 fcompat=""
577 if ($f != "|") {
578 fcompat=$f
579 f++
580 }
581
582 if ($f != "|") {
583 parserr($f, "function name delimiter (maybe \"|\"?)");
584 }
585 f++
586 fbase=$f
587
588 # pipe is special in how to returns its values.
589 # So just generate it manually if present.
590 if (rumpable == 1 && fbase == "pipe") {
591 rumpable = 0;
592 rumphaspipe = 1;
593 }
594
595 if (fcompat != "") {
596 funcname=fprefix "___" fbase "" fcompat
597 } else {
598 funcname=fprefix "_" fbase
599 }
600 if (isarg64(returntype)) {
601 if (sycall_flags == "0")
602 sycall_flags = "SYCALL_RET_64";
603 else
604 sycall_flags = "SYCALL_RET_64 | " sycall_flags;
605 }
606
607 if (funcalias == "") {
608 funcalias=funcname
609 sub(/^([^_]+_)*sys_/, "", funcalias)
610 realname=fbase
611 } else {
612 realname=funcalias
613 }
614 rumpfname=realname "" fcompat
615 f++
616
617 if ($f != "(")
618 parserr($f, "(")
619 f++
620
621 argc=0;
622 argalign=0;
623 if (f == end) {
624 if ($f != "void")
625 parserr($f, "argument definition")
626 isvarargs = 0;
627 varargc = 0;
628 argtype[0]="void";
629 return
630 }
631
632 # some system calls (open() and fcntl()) can accept a variable
633 # number of arguments. If syscalls accept a variable number of
634 # arguments, they must still have arguments specified for
635 # the remaining argument "positions," because of the way the
636 # kernel system call argument handling works.
637 #
638 # Indirect system calls, e.g. syscall(), are exceptions to this
639 # rule, since they are handled entirely by machine-dependent code
640 # and do not need argument structures built.
641
642 isvarargs = 0;
643 args64 = 0;
644 ptr = 0;
645 while (f <= end) {
646 if ($f == "...") {
647 f++;
648 isvarargs = 1;
649 varargc = argc;
650 continue;
651 }
652 argc++
653 argtype[argc]=""
654 oldf=""
655 while (f < end && $(f+1) != ",") {
656 if (argtype[argc] != "" && oldf != "*")
657 argtype[argc] = argtype[argc]" ";
658 argtype[argc] = argtype[argc]$f;
659 oldf = $f;
660 f++
661 }
662 if (argtype[argc] == "")
663 parserr($f, "argument definition")
664 if (argtype[argc] == "off_t" \
665 || argtype[argc] == "dev_t" \
666 || argtype[argc] == "time_t") {
667 if ((argalign % 2) != 0 && sysalign &&
668 funcname != "sys_posix_fadvise") # XXX for now
669 parserr($f, "a padding argument")
670 } else {
671 argalign++;
672 }
673 if (isarg64(argtype[argc])) {
674 if (sycall_flags == "0")
675 sycall_flags = "SYCALL_ARG"argc-1"_64";
676 else
677 sycall_flags = "SYCALL_ARG"argc-1"_64 | " sycall_flags;
678 args64++;
679 }
680 if (index(argtype[argc], "*") != 0 && ptr == 0) {
681 if (sycall_flags == "0")
682 sycall_flags = "SYCALL_ARG_PTR";
683 else
684 sycall_flags = "SYCALL_ARG_PTR | " sycall_flags;
685 ptr = 1;
686 }
687 argname[argc]=$f;
688 f += 2; # skip name, and any comma
689 }
690 if (args64 > 0)
691 sycall_flags = "SYCALL_NARGS64_VAL("args64") | " sycall_flags;
692 # must see another argument after varargs notice.
693 if (isvarargs) {
694 if (argc == varargc)
695 parserr($f, "argument definition")
696 } else
697 varargc = argc;
698 }
699
700 function printproto(wrap) {
701 printf("/* syscall: \"%s%s\" ret: \"%s\" args:", wrap, funcalias,
702 returntype) > sysnumhdr
703 for (i = 1; i <= varargc; i++)
704 printf(" \"%s\"", argtype[i]) > sysnumhdr
705 if (isvarargs)
706 printf(" \"...\"") > sysnumhdr
707 printf(" */\n") > sysnumhdr
708 printf("#define\t%s%s%s\t%d\n\n", constprefix, wrap, funcalias,
709 syscall) > sysnumhdr
710
711 # output entry for syscall autoload table, if modular
712 if (modular ) {
713 printf("\t { %s%s%s, \"%s\" },\n", constprefix, wrap,
714 funcalias, modname) > sysautoload
715 }
716
717
718 # rumpalooza
719 if (!rumpable)
720 return
721
722 # accumulate fbases we have seen. we want the last
723 # occurence for the default __RENAME()
724 seen = funcseen[fbase]
725 funcseen[fbase] = rumpfname
726 # special case for mknod as type of last argument changed from
727 # uint32_t to dev_t
728 if ((seen && fbase != "mknod") || (!seen && fbase == "mknod"))
729 return
730
731 printf("%s rump_sys_%s(", returntype, realname) > rumpprotos
732
733 for (i = 1; i < varargc; i++)
734 if (argname[i] != "PAD")
735 printf("%s, ", uncompattype(argtype[i])) > rumpprotos
736
737 if (isvarargs)
738 printf("%s, ...)", uncompattype(argtype[varargc]))>rumpprotos
739 else
740 printf("%s)", uncompattype(argtype[argc])) > rumpprotos
741
742 printf(" __RENAME(RUMP_SYS_RENAME_%s)", toupper(fbase))> rumpprotos
743 printf(";\n") > rumpprotos
744
745 # generate forward-declares for types, apart from the
746 # braindead typedef jungle we cannot easily handle here
747 for (i = 1; i <= varargc; i++) {
748 type=uncompattype(argtype[i])
749 sub("const ", "", type)
750 ntype=type
751 sub(" *\\*.*", "", ntype);
752 if (!typeseen[ntype] && \
753 match(type, "struct") && match(type, "\\*")) {
754 typeseen[ntype] = 1
755 printf("%s;\n", ntype) > rumptypes
756 }
757 }
758 }
759
760 function printrumpsysent(insysent, compatwrap) {
761 if (modular) {
762 fn = rumpnomodule
763 flags = rumpnoflags
764 } else {
765 fn = rumpnosys
766 flags = ""
767 }
768 if (!insysent) {
769 printf("\t{%s\n\t\t.sy_call = %s,\n},\t\t/* %d = %s */\n", \
770 flags, fn, syscall, funcalias) > rumpsysent
771 return
772 }
773
774 printf("\t{") > rumpsysent
775 if (argc != 0) {
776 printf("\n\t\tns(struct %ssys_%s_args),", compatwrap_, funcalias) > rumpsysent
777 }
778
779 printf("\n\t\t.sy_call = %s,\n\t},", fn) > rumpsysent
780 printf("\t\t/* %d = %s%s */\n", syscall, compatwrap_, funcalias) > rumpsysent
781 }
782
783 function iscompattype(type) {
784 for (var in uncompattypes) {
785 if (match(type, var)) {
786 return 1
787 }
788 }
789
790 return 0
791 }
792
793 function uncompattype(type) {
794 for (var in uncompattypes) {
795 if (match(type, var)) {
796 sub(var, uncompattypes[var], type)
797 return type
798 }
799 }
800
801 return type
802 }
803
804 function printrumpsysmap(syscall, wfn, funcalias, rumpentry) {
805 printf("%-4d %-22s %-18s %s\n",
806 syscall, wfn, funcalias, rumpentry) > rumpsysmap
807 }
808
809 function putsystrace(type, compatwrap_) {
810 printf("\t/* %s */\n\tcase %d: {\n", funcname, syscall) > systrace
811 printf("\t/* %s */\n\tcase %d:\n", funcname, syscall) > systracetmp
812 printf("\t/* %s */\n\tcase %d:\n", funcname, syscall) > systraceret
813 if (argc > 0) {
814 printf("\t\tswitch(ndx) {\n") > systracetmp
815 printf("\t\tconst struct %s%s_args *p = params;\n", compatwrap_, funcname) > systrace
816 for (i = 1; i <= argc; i++) {
817 arg = argtype[i]
818 sub("__restrict$", "", arg)
819 printf("\t\tcase %d:\n\t\t\tp = \"%s\";\n\t\t\tbreak;\n", i - 1, arg) > systracetmp
820 if (arg ~ /.*p_t$/ || arg ~ /.*p$/ || arg ~ /.*_t_p$/ ||
821 arg ~ /.*_pointer_t$/)
822 printf("\t\tuarg[%d] = (intptr_t) SCARG(p, %s).i32; /* %s */\n", \
823 i - 1, \
824 argname[i], arg) > systrace
825 else if (index(arg, "*") > 0 || arg == "caddr_t" ||
826 arg ~ /.*_handler_t$/)
827 printf("\t\tuarg[%d] = (intptr_t) SCARG(p, %s); /* %s */\n", \
828 i - 1, \
829 argname[i], arg) > systrace
830 else if (substr(arg, 1, 1) == "u" || arg == "size_t")
831 printf("\t\tuarg[%d] = SCARG(p, %s); /* %s */\n", \
832 i - 1, \
833 argname[i], arg) > systrace
834 else
835 printf("\t\tiarg[%d] = SCARG(p, %s); /* %s */\n", \
836 i - 1, \
837 argname[i], arg) > systrace
838 }
839 printf("\t\tdefault:\n\t\t\tbreak;\n\t\t};\n") > systracetmp
840
841 printf("\t\tif (ndx == 0 || ndx == 1)\n") > systraceret
842 printf("\t\t\tp = \"%s\";\n", returntype) > systraceret
843 printf("\t\tbreak;\n") > systraceret
844 }
845 printf("\t\t*n_args = %d;\n\t\tbreak;\n\t}\n", argc) > systrace
846 printf("\t\tbreak;\n") > systracetmp
847 }
848
849 function putent(type, compatwrap) {
850 # output syscall declaration for switch table.
851 if (compatwrap == "")
852 compatwrap_ = ""
853 else
854 compatwrap_ = compatwrap "_"
855 if (argc == 0)
856 arg_type = "void";
857 else {
858 arg_type = "struct " compatwrap_ funcname "_args";
859 }
860 putsystrace(type, compatwrap_)
861 proto = "int\t" compatwrap_ funcname "(struct lwp *, const " \
862 arg_type " *, register_t *);\n"
863 if (sysmap[proto] != 1) {
864 sysmap[proto] = 1;
865 print proto > sysprotos;
866 }
867
868 # output syscall switch entry
869 printf("\t{") > sysent
870 if (argc != 0) {
871 printf("\n\t\tns(struct %s%s_args),", compatwrap_, funcname) > sysent
872 }
873 if (modular) {
874 wfn = "sys_nomodule";
875 idx = int(syscall / 32);
876 bit = 2 ^ (syscall % 32);
877 nomodbits[ idx ] += bit;
878 } else if (compatwrap == "")
879 wfn = funcname;
880 else
881 wfn = compatwrap "(" funcname ")";
882 wfn_cast="(sy_call_t *)" wfn
883 if (sycall_flags != "0")
884 flags = "\n\t\t.sy_flags = " sycall_flags ","
885 else
886 flags = ""
887 printf("%s\n\t\t.sy_call = %s\n\t},", flags, wfn_cast) > sysent
888 printf("\t\t/* %d = %s%s */\n", syscall, compatwrap_, funcalias) > sysent
889
890 # output syscall name for names table
891 printf("\t/* %3d */\t\"%s%s\",\n", syscall, compatwrap_, funcalias) \
892 > sysnamesbottom
893 if (compatwrap_ != "" || fbase == funcalias)
894 printf("\t/* %3d */\tNULL, /* %s%s */\n", syscall, \
895 compatwrap_, funcalias) > sysnamesfriendly
896 else
897 printf("\t/* %3d */\t\"%s%s\",\n", syscall, compatwrap_, \
898 fbase) > sysnamesfriendly
899
900 # output syscall number of header, if appropriate
901 if (type == "STD" || type == "NOARGS" || type == "INDIR" || \
902 type == "NOERR") {
903 # output a prototype, to be used to generate lint stubs in
904 # libc.
905 printproto("")
906 } else if (type == "COMPAT" || type == "EXTERN") {
907 # Just define the syscall number with a comment. These
908 # may be used by compatibility stubs in libc.
909 printproto(compatwrap_)
910 }
911
912 # output syscall argument structure, if it has arguments
913 if (argc != 0) {
914 printf("\n") > sysarghdr
915 if (haverumpcalls && !rumpable)
916 printf("#ifndef RUMP_CLIENT\n") > sysarghdr
917 printf("struct %s%s_args", compatwrap_, funcname) > sysarghdr
918 if (type != "NOARGS") {
919 print " {" >sysarghdr;
920 for (i = 1; i <= argc; i++)
921 printf("\tsyscallarg(%s) %s;\n", argtype[i],
922 argname[i]) > sysarghdr
923 printf "}" >sysarghdr;
924 }
925 printf(";\n") > sysarghdr
926 if (type != "NOARGS" && type != "INDIR") {
927 printf("check_syscall_args(%s%s)\n", compatwrap_,
928 funcname) >sysarghdr
929 }
930 if (haverumpcalls && !rumpable)
931 printf("#endif /* !RUMP_CLIENT */\n") > sysarghdr
932 }
933
934 if (!rumpable) {
935 if (funcname == "sys_pipe" && rumphaspipe == 1) {
936 insysent = 1
937 printrumpsysmap(syscall,
938 funcname, funcalias, "rump_sys_pipe")
939 } else {
940 insysent = 0
941 }
942 } else {
943 insysent = 1
944 }
945 printrumpsysent(insysent, compatwrap)
946
947 # output rump marshalling code if necessary
948 if (!rumpable) {
949 return
950 }
951
952 printrumpsysmap(syscall, wfn, funcalias, "rump___sysimpl_" rumpfname)
953
954 printf("\n") > rumpcalls
955
956 if (compatwrap)
957 printf("#ifdef RUMP_SYS_COMPAT\n") > rumpcalls
958
959 # need a local prototype, we export the re-re-named one in .h
960 printf("%s rump___sysimpl_%s(", returntype, rumpfname) \
961 > rumpcalls
962 for (i = 1; i < argc; i++) {
963 if (argname[i] != "PAD")
964 printf("%s, ", uncompattype(argtype[i])) > rumpcalls
965 }
966 printf("%s);", uncompattype(argtype[argc])) > rumpcalls
967
968 printf("\n%s\nrump___sysimpl_%s(", returntype, rumpfname) > rumpcalls
969 for (i = 1; i < argc; i++) {
970 if (argname[i] != "PAD")
971 printf("%s %s, ", uncompattype(argtype[i]), \
972 argname[i]) > rumpcalls
973 }
974 printf("%s %s)\n", uncompattype(argtype[argc]), argname[argc]) \
975 > rumpcalls
976 printf("{\n\tregister_t retval[2];\n") > rumpcalls
977 if (returntype != "void") {
978 if (type != "NOERR") {
979 printf("\tint error = 0;\n") > rumpcalls
980 }
981 # assume rumpcalls return only integral types
982 printf("\t%s rv = -1;\n", returntype) > rumpcalls
983 }
984
985 argarg = "NULL"
986 argsize = 0;
987 if (argc) {
988 argarg = "&callarg"
989 argsize = "sizeof(callarg)"
990 printf("\tstruct %s%s_args callarg;\n\n",compatwrap_,funcname) \
991 > rumpcalls
992 printf "\tmemset(&callarg, 0, sizeof(callarg));\n" > rumpcalls
993 for (i = 1; i <= argc; i++) {
994 if (argname[i] == "PAD") {
995 printf("\tSPARG(&callarg, %s) = 0;\n", \
996 argname[i]) > rumpcalls
997 } else {
998 if (iscompattype(argtype[i])) {
999 printf("\tSPARG(&callarg, %s) = " \
1000 "(%s)%s;\n", argname[i], argtype[i], \
1001 argname[i]) > rumpcalls
1002 } else {
1003 printf("\tSPARG(&callarg, %s) = %s;\n",\
1004 argname[i], argname[i]) > rumpcalls
1005 }
1006 }
1007 }
1008 printf("\n") > rumpcalls
1009 } else {
1010 printf("\n") > rumpcalls
1011 }
1012 printf("\t") > rumpcalls
1013 if (returntype != "void" && type != "NOERR")
1014 printf("error = ") > rumpcalls
1015 else if (returntype != "void")
1016 printf("(void)") > rumpcalls
1017 printf("rsys_syscall(%s%s%s, " \
1018 "%s, %s, retval);\n", constprefix, compatwrap_, funcalias, \
1019 argarg, argsize) > rumpcalls
1020 if (type != "NOERR") {
1021 printf("\trsys_seterrno(error);\n") > rumpcalls
1022 printf("\tif (error == 0) {\n") > rumpcalls
1023 indent="\t\t"
1024 ending="\t}\n"
1025 } else {
1026 indent="\t"
1027 ending=""
1028 }
1029 if (returntype != "void") {
1030 printf("%sif (sizeof(%s) > sizeof(register_t))\n", \
1031 indent, returntype) > rumpcalls
1032 printf("%s\trv = *(%s *)retval;\n", \
1033 indent, returntype) > rumpcalls
1034 printf("%selse\n", indent, indent) > rumpcalls
1035 printf("%s\trv = *retval;\n", indent, returntype) > rumpcalls
1036 printf("%s", ending) > rumpcalls
1037 printf("\treturn rv;\n") > rumpcalls
1038 }
1039 printf("}\n") > rumpcalls
1040
1041 printf("#ifdef RUMP_KERNEL_IS_LIBC\n") > rumpcalls
1042
1043 # create the bog-standard, non-renamed public name.
1044 # this way we get e.g. select instead of just __select50
1045 if (fcompat)
1046 printf("__weak_alias(%s,rump___sysimpl_%s);\n", \
1047 fbase, rumpfname) > rumpcalls
1048
1049 printf("__weak_alias(%s,rump___sysimpl_%s);\n", \
1050 funcalias, rumpfname) > rumpcalls
1051 printf("__weak_alias(_%s,rump___sysimpl_%s);\n", \
1052 funcalias, rumpfname) > rumpcalls
1053 printf("__strong_alias(_sys_%s,rump___sysimpl_%s);\n", \
1054 funcalias, rumpfname) >rumpcalls
1055
1056 printf("#endif /* RUMP_KERNEL_IS_LIBC */\n") > rumpcalls
1057
1058 if (compatwrap)
1059 printf("#endif /* RUMP_SYS_COMPAT */\n") > rumpcalls
1060
1061 }
1062 $2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "INDIR" \
1063 || $2 == "NOERR" {
1064 parseline()
1065 putent($2, "")
1066 syscall++
1067 next
1068 }
1069 $2 == "OBSOL" || $2 == "UNIMPL" || $2 == "EXCL" || $2 == "IGNORED" {
1070 if ($2 == "OBSOL")
1071 comment="obsolete"
1072 else if ($2 == "EXCL")
1073 comment="excluded"
1074 else if ($2 == "IGNORED")
1075 comment="ignored"
1076 else
1077 comment="unimplemented"
1078 for (i = 3; i <= NF; i++)
1079 comment=comment " " $i
1080
1081 if ($2 == "IGNORED")
1082 sys_stub = "(sy_call_t *)nullop";
1083 else
1084 sys_stub = sys_nosys;
1085
1086 print fillerpsysent(syscall, "", sys_stub, comment) > sysent
1087 print fillerpsysent(syscall, rumpnoflags, rumpnosys, comment) > rumpsysent
1088 printf("\t/* %3d */\t\"#%d (%s)\",\n", syscall, syscall, comment) \
1089 > sysnamesbottom
1090 printf("\t/* %3d */\tNULL, /* %s */\n", syscall, comment) \
1091 > sysnamesfriendly
1092 if ($2 != "UNIMPL")
1093 printf("\t\t\t\t/* %d is %s */\n", syscall, comment) > sysnumhdr
1094 syscall++
1095 next
1096 }
1097 $2 == "EXTERN" {
1098 parseline()
1099 putent("EXTERN", "")
1100 syscall++
1101 next
1102 }
1103 {
1104 for (i = 1; i <= ncompat; i++) {
1105 if ($2 == compat_upper[i]) {
1106 parseline();
1107 putent("COMPAT", compat[i])
1108 syscall++
1109 next
1110 }
1111 }
1112 printf("%s: line %d: unrecognized keyword %s\n", infile, NR, $2)
1113 exit 1
1114 }
1115 END {
1116 # output pipe() syscall with its special retval[2] handling
1117 if (rumphaspipe) {
1118 printf("int rump_sys_pipe(int *);\n") > rumpprotos
1119 printf("\nint rump_sys_pipe(int *);\n") > rumpcalls
1120 printf("int\nrump_sys_pipe(int *fd)\n{\n") > rumpcalls
1121 printf("\tregister_t retval[2];\n") > rumpcalls
1122 printf("\tint error = 0;\n") > rumpcalls
1123 printf("\n\terror = rsys_syscall(SYS_pipe, ") > rumpcalls
1124 printf("NULL, 0, retval);\n") > rumpcalls
1125 printf("\tif (error) {\n") > rumpcalls
1126 printf("\t\trsys_seterrno(error);\n") > rumpcalls
1127 printf("\t} else {\n\t\tfd[0] = retval[0];\n") > rumpcalls
1128 printf("\t\tfd[1] = retval[1];\n\t}\n") > rumpcalls
1129 printf("\treturn error ? -1 : 0;\n}\n") > rumpcalls
1130 printf("#ifdef RUMP_KERNEL_IS_LIBC\n") > rumpcalls
1131 printf("__weak_alias(pipe,rump_sys_pipe);\n") > rumpcalls
1132 printf("__weak_alias(_pipe,rump_sys_pipe);\n") > rumpcalls
1133 printf("__strong_alias(_sys_pipe,rump_sys_pipe);\n") > rumpcalls
1134 printf("#endif\n") > rumpcalls
1135 }
1136
1137 # print default rump syscall interfaces
1138 for (var in funcseen) {
1139 printf("#ifndef RUMP_SYS_RENAME_%s\n", \
1140 toupper(var)) > rumpcallshdr
1141 printf("#define RUMP_SYS_RENAME_%s rump___sysimpl_%s\n", \
1142 toupper(var), funcseen[var]) > rumpcallshdr
1143 printf("#endif\n\n") > rumpcallshdr
1144 }
1145
1146 maxsyscall = syscall
1147
1148 if (nsysent) {
1149 if (syscall > nsysent) {
1150 printf("%s: line %d: too many syscalls [%d > %d]\n", infile, NR, syscall, nsysent)
1151 exit 1
1152 }
1153 while (syscall < nsysent) {
1154 print fillerpsysent(syscall, "", sys_nosys, "filler") > sysent
1155 print fillerpsysent(syscall, rumpnoflags, rumpnosys, "filler") > rumpsysent
1156 printf("\t/* %3d */\t\"# filler\",\n", syscall) \
1157 > sysnamesbottom
1158 printf("\t/* %3d */\tNULL, /* filler */\n", syscall) \
1159 > sysnamesfriendly
1160 syscall++
1161 }
1162 }
1163 printf("};\n") > sysent
1164 printf("\nconst uint32_t %s_nomodbits[] = {\n", switchname) > sysent
1165 printf("};\n") > rumpsysent
1166 printf("\nconst uint32_t rump_sysent_nomodbits[] = {\n") > rumpsysent
1167 for (i = 0; i < syscall / 32; i++) {
1168 printf("\t0x%08x,\t/* syscalls %3d-%3d */\n",
1169 nomodbits[i], i * 32, i * 32 + 31) > sysent
1170 printf("\t0x%08x,\t/* syscalls %3d-%3d */\n",
1171 nomodbits[i], i * 32, i * 32 + 31) > rumpsysent
1172 }
1173 printf("};\n") > sysent
1174 printf("};\n") > rumpsysent
1175 printf("CTASSERT(__arraycount(rump_sysent) == SYS_NSYSENT);\n") > rumpsysent
1176 printf("__strong_alias(rumpns_sysent,rump_sysent);\n") > rumpsysent
1177 printf("#endif /* RUMP_CLIENT */\n") > rumpsysent
1178 if (haverumpcalls)
1179 printf("#endif /* !RUMP_CLIENT */\n") > sysprotos
1180 printf("};\n") > sysnamesbottom
1181 printf("};\n") > sysnamesfriendly
1182 printf("#define\t%sMAXSYSCALL\t%d\n", constprefix, maxsyscall) > sysnumhdr
1183 if (nsysent)
1184 printf("#define\t%sNSYSENT\t%d\n", constprefix, nsysent) > sysnumhdr
1185 printf "\tdefault:\n\t\t*n_args = 0;\n\t\tbreak;\n\t};\n}\n" > systrace
1186 printf "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n" > systracetmp
1187 printf "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n" > systraceret
1188 } '
1189
1190 cat $sysprotos >> $sysarghdr
1191 echo "#endif /* _${constprefix}SYSCALL_H_ */" >> $sysnumhdr
1192 echo "#endif /* _${constprefix}SYSCALLARGS_H_ */" >> $sysarghdr
1193 printf "\t { 0, NULL }\n" >> $sysautoload
1194 echo "};" >> $sysautoload
1195 printf "\n#endif /* _RUMP_RUMP_SYSCALLS_H_ */\n" >> $rumpprotos
1196 cat $sysdcl $sysent > $syssw
1197 cat $sysnamesbottom >> $sysnames
1198 cat $sysnamesfriendly >> $sysnames
1199 cat $rumpsysent >> $rumpcalls
1200
1201 touch $rumptypes
1202 cat $rumptypes >> $rumpcallshdr
1203 echo >> $rumpcallshdr
1204 cat $rumpprotos >> $rumpcallshdr
1205
1206 #chmod 444 $sysnames $sysnumhdr $syssw
1207
1208 cat $systracetmp >> $systrace
1209 cat $systraceret >> $systrace
1210
1211 echo Generated following files:
1212 echo $sysarghdr $sysnumhdr $syssw $sysnames $sysautoload $systrace $rumpcalls $rumpcallshdr $rumpsysmap
1213