Generate syscalls entry points which can be called directly without
going through a syscall trap. These are currently useful for rumps. As all the standard syscalls are not compiled into librump, mark relevant ones with RUMP in syscalls.master. To do e.g. a mkdir "system call" from a rump, one would call rump_sys_mkdir("/dir", mode, &eval); where the last value represents something to store errno into.
This commit is contained in:
parent
aa717955e2
commit
f2976c3905
@ -1,5 +1,5 @@
|
||||
#! /bin/sh -
|
||||
# $NetBSD: makesyscalls.sh,v 1.65 2008/03/10 14:06:46 njoly Exp $
|
||||
# $NetBSD: makesyscalls.sh,v 1.66 2008/03/11 22:50:10 pooka Exp $
|
||||
#
|
||||
# Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou
|
||||
# All rights reserved.
|
||||
@ -124,6 +124,8 @@ BEGIN {
|
||||
sysprotos = \"$sysprotos\"
|
||||
sysnumhdr = \"$sysnumhdr\"
|
||||
sysarghdr = \"$sysarghdr\"
|
||||
rumpcalls = \"$rumpcalls\"
|
||||
rumpcallshdr = \"$rumpcallshdr\"
|
||||
switchname = \"$switchname\"
|
||||
namesname = \"$namesname\"
|
||||
constprefix = \"$constprefix\"
|
||||
@ -133,6 +135,13 @@ BEGIN {
|
||||
}
|
||||
nsysent = \"$nsysent\"
|
||||
|
||||
if (length(rumpcalls) == 0) {
|
||||
rumpcalls = "/dev/null"
|
||||
}
|
||||
if (length(rumpcallshdr) == 0) {
|
||||
rumpcallshdr = "/dev/null"
|
||||
}
|
||||
|
||||
sysdcl = \"$sysdcl\"
|
||||
syscompat_pref = \"$syscompat_pref\"
|
||||
sysent = \"$sysent\"
|
||||
@ -178,6 +187,14 @@ BEGIN {
|
||||
printf "/* \$NetBSD\$ */\n\n" > sysarghdr
|
||||
printf "/*\n * System call argument lists.\n *\n" > sysarghdr
|
||||
printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysarghdr
|
||||
|
||||
printf "/* \$NetBSD\$ */\n\n" > rumpcalls
|
||||
printf "/*\n * System call marshalling for rump.\n *\n" > rumpcalls
|
||||
printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcalls
|
||||
|
||||
printf "/* \$NetBSD\$ */\n\n" > rumpcallshdr
|
||||
printf "/*\n * System call protos in rump namespace.\n *\n" > rumpcallshdr
|
||||
printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcallshdr
|
||||
}
|
||||
NR == 1 {
|
||||
sub(/ $/, "")
|
||||
@ -187,6 +204,19 @@ NR == 1 {
|
||||
printf " * created from%s\n */\n\n", $0 > sysnames
|
||||
printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"\$NetBSD\$\");\n\n" > sysnames
|
||||
|
||||
printf " * created from%s\n */\n\n", $0 > rumpcalls
|
||||
printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"\$NetBSD\$\");\n\n" > rumpcalls
|
||||
printf "#include <sys/types.h>\n" > rumpcalls
|
||||
printf "#include <sys/param.h>\n" > rumpcalls
|
||||
printf "#include <sys/proc.h>\n" > rumpcalls
|
||||
printf "#include <sys/syscallargs.h>\n" > rumpcalls
|
||||
printf "#include \"rump_syscalls.h\"\n\n" > rumpcalls
|
||||
printf "#if\tBYTE_ORDER == BIG_ENDIAN\n" > rumpcalls
|
||||
printf "#define SPARG(p,k)\t((p)->k.be.datum)\n" > rumpcalls
|
||||
printf "#else /* LITTLE_ENDIAN, I hope dearly */\n" > rumpcalls
|
||||
printf "#define SPARG(p,k)\t((p)->k.le.datum)\n" > rumpcalls
|
||||
printf "#endif\n\n" > rumpcalls
|
||||
|
||||
# System call names are included by userland (kdump(1)), so
|
||||
# hide the include files from it.
|
||||
printf "#if defined(_KERNEL_OPT)\n" > sysnames
|
||||
@ -197,6 +227,9 @@ NR == 1 {
|
||||
printf " * created from%s\n */\n\n", $0 > sysnumhdr
|
||||
|
||||
printf " * created from%s\n */\n\n", $0 > sysarghdr
|
||||
|
||||
printf " * created from%s\n */\n\n", $0 > rumpcallshdr
|
||||
|
||||
printf "#ifndef _" constprefix "SYSCALL_H_\n" > sysnumhdr
|
||||
printf "#define _" constprefix "SYSCALL_H_\n\n" > sysnumhdr
|
||||
printf "#ifndef _" constprefix "SYSCALLARGS_H_\n" > sysarghdr
|
||||
@ -310,6 +343,12 @@ function parseline() {
|
||||
sycall_flags = "SYCALL_MPSAFE | " sycall_flags
|
||||
f++
|
||||
}
|
||||
if ($f == "RUMP") {
|
||||
rumpable = 1
|
||||
f++
|
||||
} else {
|
||||
rumpable = 0
|
||||
}
|
||||
if ($f ~ /^[a-z0-9_]*$/) { # allow syscall alias
|
||||
funcalias=$f
|
||||
f++
|
||||
@ -418,6 +457,17 @@ function printproto(wrap) {
|
||||
printf(" */\n") > sysnumhdr
|
||||
printf("#define\t%s%s%s\t%d\n\n", constprefix, wrap, funcalias,
|
||||
syscall) > sysnumhdr
|
||||
|
||||
# rumpalooza
|
||||
if (!rumpable)
|
||||
return
|
||||
|
||||
if (wrap == "")
|
||||
wrap = "sys"
|
||||
printf("%s rump_%s_%s(", returntype, wrap, funcalias) > rumpcallshdr
|
||||
for (i = 1; i <= argc; i++)
|
||||
printf("%s, ", argtype[i]) > rumpcallshdr
|
||||
printf("int *);\n") > rumpcallshdr
|
||||
}
|
||||
|
||||
function putent(type, compatwrap) {
|
||||
@ -485,6 +535,35 @@ function putent(type, compatwrap) {
|
||||
funcname) >sysarghdr
|
||||
}
|
||||
}
|
||||
|
||||
# output rump marshalling code if necessary
|
||||
if (!rumpable)
|
||||
return
|
||||
|
||||
printf("%s\nrump_%s(", returntype, funcname) > rumpcalls
|
||||
for (i = 1; i <= argc; i++) {
|
||||
printf("%s %s, ", argtype[i], argname[i]) > rumpcalls
|
||||
}
|
||||
printf("int *error)\n") > rumpcalls
|
||||
printf("{\n\tregister_t retval;\n") > rumpcalls
|
||||
argarg = "NULL"
|
||||
if (argc) {
|
||||
argarg = "&arg"
|
||||
printf("\tstruct %s%s_args arg;\n\n", funcname, compatwrap_) \
|
||||
> rumpcalls
|
||||
for (i = 1; i <= argc; i++) {
|
||||
printf("\tSPARG(&arg, %s) = %s;\n", \
|
||||
argname[i], argname[i]) > rumpcalls
|
||||
}
|
||||
printf("\n") > rumpcalls
|
||||
} else {
|
||||
printf("\n") > rumpcalls
|
||||
}
|
||||
printf("\t*error = %s(curlwp, %s, &retval);\n", funcname, argarg) \
|
||||
> rumpcalls
|
||||
if (returntype != "void")
|
||||
printf("\treturn retval;\n") > rumpcalls
|
||||
printf("}\n\n") > rumpcalls
|
||||
}
|
||||
$2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "INDIR" {
|
||||
parseline()
|
||||
|
@ -1,4 +1,4 @@
|
||||
$NetBSD: syscalls.master,v 1.190 2008/02/24 12:52:54 martin Exp $
|
||||
$NetBSD: syscalls.master,v 1.191 2008/03/11 22:50:10 pooka Exp $
|
||||
|
||||
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
|
||||
|
||||
@ -10,8 +10,10 @@
|
||||
; type one of STD, OBSOL, UNIMPL, IGNORED, NODEF, NOARGS, or one of
|
||||
; the compatibility options defined in syscalls.conf.
|
||||
;
|
||||
; An optional field, MPSAFE, after the type field, indicates that
|
||||
; the system call is MP-safe.
|
||||
; Optional fields are specified after the type field
|
||||
; (NOTE! they must be specified in this order):
|
||||
; MPSAFE: the system call is MP-safe.
|
||||
; RUMP: the system call can be called directly from rumps
|
||||
;
|
||||
; types:
|
||||
; STD always included
|
||||
@ -66,24 +68,24 @@
|
||||
... register_t args[SYS_MAXSYSARGS]); }
|
||||
1 STD MPSAFE { void sys_exit(int rval); }
|
||||
2 STD MPSAFE { int sys_fork(void); }
|
||||
3 STD MPSAFE { ssize_t sys_read(int fd, void *buf, size_t nbyte); }
|
||||
4 STD MPSAFE { ssize_t sys_write(int fd, const void *buf, \
|
||||
3 STD MPSAFE RUMP { ssize_t sys_read(int fd, void *buf, size_t nbyte); }
|
||||
4 STD MPSAFE RUMP { ssize_t sys_write(int fd, const void *buf, \
|
||||
size_t nbyte); }
|
||||
5 STD MPSAFE { int sys_open(const char *path, \
|
||||
5 STD MPSAFE RUMP { int sys_open(const char *path, \
|
||||
int flags, ... mode_t mode); }
|
||||
6 STD MPSAFE { int sys_close(int fd); }
|
||||
6 STD MPSAFE RUMP { int sys_close(int fd); }
|
||||
7 STD MPSAFE { int sys_wait4(int pid, int *status, int options, \
|
||||
struct rusage *rusage); }
|
||||
8 COMPAT_43 MPSAFE { int sys_creat(const char *path, mode_t mode); } ocreat
|
||||
9 STD MPSAFE { int sys_link(const char *path, const char *link); }
|
||||
10 STD MPSAFE { int sys_unlink(const char *path); }
|
||||
9 STD MPSAFE RUMP { int sys_link(const char *path, const char *link); }
|
||||
10 STD MPSAFE RUMP { int sys_unlink(const char *path); }
|
||||
11 OBSOL execv
|
||||
12 STD MPSAFE { int sys_chdir(const char *path); }
|
||||
13 STD MPSAFE { int sys_fchdir(int fd); }
|
||||
14 STD MPSAFE { int sys_mknod(const char *path, mode_t mode, \
|
||||
12 STD MPSAFE RUMP { int sys_chdir(const char *path); }
|
||||
13 STD MPSAFE RUMP { int sys_fchdir(int fd); }
|
||||
14 STD MPSAFE RUMP { int sys_mknod(const char *path, mode_t mode, \
|
||||
dev_t dev); }
|
||||
15 STD MPSAFE { int sys_chmod(const char *path, mode_t mode); }
|
||||
16 STD MPSAFE { int sys_chown(const char *path, uid_t uid, \
|
||||
15 STD MPSAFE RUMP { int sys_chmod(const char *path, mode_t mode); }
|
||||
16 STD MPSAFE RUMP { int sys_chown(const char *path, uid_t uid, \
|
||||
gid_t gid); }
|
||||
17 STD MPSAFE { int sys_obreak(char *nsize); } break
|
||||
18 COMPAT_20 MPSAFE { int sys_getfsstat(struct statfs12 *buf, \
|
||||
@ -97,7 +99,7 @@
|
||||
#endif
|
||||
21 COMPAT_40 MPSAFE { int sys_mount(const char *type, const char *path, \
|
||||
int flags, void *data); }
|
||||
22 STD MPSAFE { int sys_unmount(const char *path, int flags); }
|
||||
22 STD MPSAFE RUMP { int sys_unmount(const char *path, int flags); }
|
||||
23 STD MPSAFE { int sys_setuid(uid_t uid); }
|
||||
#ifdef COMPAT_43
|
||||
24 STD MPSAFE { uid_t sys_getuid_with_euid(void); } getuid
|
||||
@ -120,10 +122,10 @@
|
||||
unsigned int *alen); }
|
||||
32 STD { int sys_getsockname(int fdes, struct sockaddr *asa, \
|
||||
unsigned int *alen); }
|
||||
33 STD MPSAFE { int sys_access(const char *path, int flags); }
|
||||
34 STD MPSAFE { int sys_chflags(const char *path, u_long flags); }
|
||||
35 STD MPSAFE { int sys_fchflags(int fd, u_long flags); }
|
||||
36 STD MPSAFE { void sys_sync(void); }
|
||||
33 STD MPSAFE RUMP { int sys_access(const char *path, int flags); }
|
||||
34 STD MPSAFE RUMP { int sys_chflags(const char *path, u_long flags); }
|
||||
35 STD MPSAFE RUMP { int sys_fchflags(int fd, u_long flags); }
|
||||
36 STD MPSAFE RUMP { void sys_sync(void); }
|
||||
37 STD MPSAFE { int sys_kill(int pid, int signum); }
|
||||
38 COMPAT_43 MPSAFE { int sys_stat(const char *path, struct stat43 *ub); } \
|
||||
stat43
|
||||
@ -158,9 +160,9 @@
|
||||
u_long com, ... void *data); }
|
||||
55 COMPAT_12 { int sys_reboot(int opt); } oreboot
|
||||
56 STD MPSAFE { int sys_revoke(const char *path); }
|
||||
57 STD MPSAFE { int sys_symlink(const char *path, \
|
||||
57 STD MPSAFE RUMP { int sys_symlink(const char *path, \
|
||||
const char *link); }
|
||||
58 STD MPSAFE { ssize_t sys_readlink(const char *path, char *buf, \
|
||||
58 STD MPSAFE RUMP { ssize_t sys_readlink(const char *path, char *buf, \
|
||||
size_t count); }
|
||||
59 STD MPSAFE { int sys_execve(const char *path, \
|
||||
char * const *argp, char * const *envp); }
|
||||
@ -264,7 +266,7 @@
|
||||
orecvfrom
|
||||
126 STD MPSAFE { int sys_setreuid(uid_t ruid, uid_t euid); }
|
||||
127 STD MPSAFE { int sys_setregid(gid_t rgid, gid_t egid); }
|
||||
128 STD MPSAFE { int sys_rename(const char *from, const char *to); }
|
||||
128 STD MPSAFE RUMP { int sys_rename(const char *from, const char *to); }
|
||||
129 COMPAT_43 MPSAFE { int sys_truncate(const char *path, long length); } \
|
||||
otruncate
|
||||
130 COMPAT_43 MPSAFE { int sys_ftruncate(int fd, long length); } oftruncate
|
||||
@ -276,8 +278,8 @@
|
||||
134 STD { int sys_shutdown(int s, int how); }
|
||||
135 STD { int sys_socketpair(int domain, int type, \
|
||||
int protocol, int *rsv); }
|
||||
136 STD MPSAFE { int sys_mkdir(const char *path, mode_t mode); }
|
||||
137 STD MPSAFE { int sys_rmdir(const char *path); }
|
||||
136 STD MPSAFE RUMP { int sys_mkdir(const char *path, mode_t mode); }
|
||||
137 STD MPSAFE RUMP { int sys_rmdir(const char *path); }
|
||||
138 STD MPSAFE { int sys_utimes(const char *path, \
|
||||
const struct timeval *tptr); }
|
||||
139 OBSOL 4.2 sigreturn
|
||||
@ -406,7 +408,7 @@
|
||||
... register_t args[SYS_MAXSYSARGS]); }
|
||||
199 STD MPSAFE { off_t sys_lseek(int fd, int pad, off_t offset, \
|
||||
int whence); }
|
||||
200 STD MPSAFE { int sys_truncate(const char *path, int pad, \
|
||||
200 STD MPSAFE RUMP { int sys_truncate(const char *path, int pad, \
|
||||
off_t length); }
|
||||
201 STD MPSAFE { int sys_ftruncate(int fd, int pad, off_t length); }
|
||||
202 STD MPSAFE { int sys___sysctl(const int *name, u_int namelen, \
|
||||
@ -572,8 +574,8 @@
|
||||
272 COMPAT_30 MPSAFE { int sys_getdents(int fd, char *buf, size_t count); }
|
||||
273 STD MPSAFE { int sys_minherit(void *addr, size_t len, \
|
||||
int inherit); }
|
||||
274 STD MPSAFE { int sys_lchmod(const char *path, mode_t mode); }
|
||||
275 STD MPSAFE { int sys_lchown(const char *path, uid_t uid, \
|
||||
274 STD MPSAFE RUMP { int sys_lchmod(const char *path, mode_t mode); }
|
||||
275 STD MPSAFE RUMP { int sys_lchown(const char *path, uid_t uid, \
|
||||
gid_t gid); }
|
||||
276 STD MPSAFE { int sys_lutimes(const char *path, \
|
||||
const struct timeval *tptr); }
|
||||
|
Loading…
Reference in New Issue
Block a user