diff --git a/sys/kern/makesyscalls.sh b/sys/kern/makesyscalls.sh index 89fe62a0ed54..4526f92a0e97 100644 --- a/sys/kern/makesyscalls.sh +++ b/sys/kern/makesyscalls.sh @@ -1,5 +1,5 @@ #! /bin/sh - -# $NetBSD: makesyscalls.sh,v 1.82 2009/02/14 16:21:23 pooka Exp $ +# $NetBSD: makesyscalls.sh,v 1.83 2009/02/20 17:56:36 pooka Exp $ # # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou # All rights reserved. @@ -64,6 +64,7 @@ sys_nosys="sys_nosys" # default is sys_nosys(), if not specified otherwise maxsysargs=8 # default limit is 8 (32bit) arguments rumpcalls="/dev/null" rumpcallshdr="/dev/null" +rumpsysent="rumpsysent.tmp" . ./$1 # tmp files: @@ -73,7 +74,7 @@ syscompat_pref="sysent." sysent="sysent.switch" sysnamesbottom="sysnames.bottom" -trap "rm $sysdcl $sysprotos $sysent $sysnamesbottom" 0 +trap "rm $sysdcl $sysprotos $sysent $sysnamesbottom $rumpsysent" 0 # Awk program (must support nawk extensions) # Use "awk" at Berkeley, "nawk" or "gawk" elsewhere. @@ -135,6 +136,7 @@ BEGIN { sysarghdr = \"$sysarghdr\" rumpcalls = \"$rumpcalls\" rumpcallshdr = \"$rumpcallshdr\" + rumpsysent = \"$rumpsysent\" switchname = \"$switchname\" namesname = \"$namesname\" constprefix = \"$constprefix\" @@ -192,7 +194,7 @@ BEGIN { printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysarghdr printf "/* %s */\n\n", tag > rumpcalls - printf "/*\n * System call marshalling for rump.\n *\n" > rumpcalls + printf "/*\n * System call vector and marshalling for rump.\n *\n" > rumpcalls printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcalls printf "/* %s */\n\n", tag > rumpcallshdr @@ -212,6 +214,7 @@ NR == 1 { printf "#include \n" > rumpcalls printf "#include \n" > rumpcalls printf "#include \n" > rumpcalls + printf "#include \n" > rumpcalls printf "#include \n" > rumpcalls printf "#include \n" > rumpcalls printf "#include \"rump_private.h\"\n\n" > rumpcalls @@ -223,6 +226,11 @@ NR == 1 { printf "int rump_enosys(void);\n" > rumpcalls printf "int\nrump_enosys()\n{\n\n\treturn ENOSYS;\n}\n" > rumpcalls + printf "\n#define\ts(type)\tsizeof(type)\n" > rumpsysent + printf "#define\tn(type)\t(sizeof(type)/sizeof (%s))\n", registertype > rumpsysent + printf "#define\tns(type)\tn(type), s(type)\n\n", registertype > rumpsysent + printf "struct sysent rump_sysent[] = {\n" > rumpsysent + # System call names are included by userland (kdump(1)), so # hide the include files from it. printf "#if defined(_KERNEL_OPT)\n" > sysnames @@ -315,6 +323,11 @@ $1 ~ /^#/ && intable { print > sysnumhdr print > sysprotos print > sysnamesbottom + + # XXX: technically we do not want to have conditionals in rump, + # but it is easier to just let the cpp handle them than try to + # figure out what we want here in this script + print > rumpsysent next } syscall != $1 { @@ -580,8 +593,11 @@ function putent(type, compatwrap) { } # output rump marshalling code if necessary - if (!rumpable) + if (!rumpable) { + printf("\t{ 0, 0, 0,\n\t %s },\t\t\t/* %d = unrumped */\n", \ + "(sy_call_t *)rump_enosys", syscall) > rumpsysent return + } # need a local prototype, we export the re-re-named one in .h printf("\n%s rump_%s(", returntype, funcname) > rumpcalls @@ -598,9 +614,11 @@ function putent(type, compatwrap) { printf("{\n\tregister_t retval = 0;\n\tint error = 0;\n") > rumpcalls argarg = "NULL" + argsize = 0; if (argc) { argarg = "&arg" - printf("\tstruct %s%s_args arg;\n\n", funcname, compatwrap_) \ + argsize = "sizeof(arg)" + printf("\tstruct %s%s_args arg;\n\n", compatwrap_, funcname) \ > rumpcalls for (i = 1; i <= argc; i++) { printf("\tSPARG(&arg, %s) = %s;\n", \ @@ -610,8 +628,9 @@ function putent(type, compatwrap) { } else { printf("\n") > rumpcalls } - printf("\terror = %s(curlwp, %s, &retval);\n", funcname, argarg) \ - > rumpcalls + printf("\terror = rump_sysproxy(%s%s, rump_sysproxy_arg,\n\t" \ + " (uint8_t *)%s, %s, &retval);\n", constprefix, funcalias, \ + argarg, argsize) > rumpcalls printf("\tif (error) {\n\t\tretval = -1;\n") > rumpcalls if (returntype != "void") { printf("\t\trumpuser_seterrno(error);\n\t}\n") > rumpcalls @@ -621,6 +640,18 @@ function putent(type, compatwrap) { } printf("}\n") > rumpcalls printf("__weak_alias(%s,rump_enosys);\n", funcname) > rumpcalls + + # rumpsysent + printf("\t{ ") > rumpsysent + if (argc == 0) { + printf("0, 0, ") > rumpsysent + } else { + printf("ns(struct %s%s_args), ", compatwrap_, funcname) > rumpsysent + } + printf("0,\n\t %s },", wfn) > rumpsysent + for (i = 0; i < (41 - length(wfn)) / 8; i++) + printf("\t") > rumpsysent + printf("/* %d = %s%s */\n", syscall, compatwrap_, funcalias) > rumpsysent } $2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "INDIR" { parseline() @@ -647,6 +678,8 @@ $2 == "OBSOL" || $2 == "UNIMPL" || $2 == "EXCL" || $2 == "IGNORED" { printf("\t{ 0, 0, 0,\n\t %s },\t\t\t/* %d = %s */\n", \ sys_stub, syscall, comment) > sysent + printf("\t{ 0, 0, 0,\n\t %s },\t\t\t/* %d = %s */\n", \ + "(sy_call_t *)rump_enosys", syscall, comment) > rumpsysent printf("\t/* %3d */\t\"#%d (%s)\",\n", syscall, syscall, comment) \ > sysnamesbottom if ($2 != "UNIMPL") @@ -676,10 +709,14 @@ END { while (syscall < nsysent) { printf("\t{ 0, 0, 0,\n\t %s },\t\t\t/* %d = filler */\n", \ sys_nosys, syscall) > sysent + printf("\t{ 0, 0, 0,\n\t %s },\t\t\t/* %d = filler */\n", \ + "(sy_call_t *)rump_enosys", syscall) > rumpsysent syscall++ } } printf("};\n") > sysent + printf("};\n") > rumpsysent + printf("CTASSERT(__arraycount(rump_sysent) == SYS_NSYSENT);\n") > rumpsysent printf("};\n") > sysnamesbottom printf("#define\t%sMAXSYSCALL\t%d\n", constprefix, maxsyscall) > sysnumhdr if (nsysent) @@ -691,5 +728,6 @@ echo "#endif /* _${constprefix}SYSCALL_H_ */" >> $sysnumhdr echo "#endif /* _${constprefix}SYSCALLARGS_H_ */" >> $sysarghdr cat $sysdcl $sysent > $syssw cat $sysnamesbottom >> $sysnames +cat $rumpsysent >> $rumpcalls #chmod 444 $sysnames $sysnumhdr $syssw