Preliminary BSD user emulator support

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5544 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
blueswir1 2008-10-26 20:33:16 +00:00
parent 46f42f2940
commit 84778508d7
24 changed files with 5943 additions and 1 deletions

View File

@ -469,6 +469,111 @@ $(QEMU_PROG): $(OBJS)
endif #CONFIG_DARWIN_USER endif #CONFIG_DARWIN_USER
#########################################################
# BSD user emulator target
ifdef CONFIG_BSD_USER
VPATH+=:$(SRC_PATH)/bsd-user
CPPFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH)
ifdef CONFIG_STATIC
LDFLAGS+=-static
endif
ifeq ($(ARCH),i386)
ifdef TARGET_GPROF
USE_I386_LD=y
endif
ifdef CONFIG_STATIC
USE_I386_LD=y
endif
ifdef USE_I386_LD
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
else
# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
# that the kernel ELF loader considers as an executable. I think this
# is the simplest way to make it self virtualizable!
LDFLAGS+=-Wl,-shared
endif
endif
ifeq ($(ARCH),x86_64)
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
endif
ifeq ($(ARCH),ppc)
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
endif
ifeq ($(ARCH),ppc64)
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
endif
ifeq ($(ARCH),s390)
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
endif
ifeq ($(ARCH),sparc)
# -static is used to avoid g1/g3 usage by the dynamic linker
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld -static
endif
ifeq ($(ARCH),sparc64)
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
endif
ifeq ($(ARCH),alpha)
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
endif
ifeq ($(ARCH),ia64)
LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/$(ARCH).ld
endif
ifeq ($(ARCH),arm)
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
endif
ifeq ($(ARCH),m68k)
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
endif
ifeq ($(ARCH),mips)
ifeq ($(WORDS_BIGENDIAN),yes)
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
else
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
endif
endif
ifeq ($(ARCH),mips64)
ifeq ($(WORDS_BIGENDIAN),yes)
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
else
LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
endif
endif
OBJS= main.o bsdload.o elfload.o mmap.o path.o signal.o strace.o syscall.o
OBJS+= uaccess.o
OBJS+= libqemu.a
ifdef CONFIG_GDBSTUB
OBJS+=gdbstub.o
endif
# Note: this is a workaround. The real fix is to avoid compiling
# cpu_signal_handler() in cpu-exec.c.
signal.o: signal.c
$(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(QEMU_PROG): $(OBJS) ../libqemu_user.a
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
endif #CONFIG_BSD_USER
######################################################### #########################################################
# System emulator target # System emulator target
ifndef CONFIG_USER_ONLY ifndef CONFIG_USER_ONLY

204
bsd-user/bsdload.c Normal file
View File

@ -0,0 +1,204 @@
/* Code for loading BSD executables. Mostly linux kernel code. */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "qemu.h"
#define NGROUPS 32
/* ??? This should really be somewhere else. */
abi_long memcpy_to_target(abi_ulong dest, const void *src,
unsigned long len)
{
void *host_ptr;
host_ptr = lock_user(VERIFY_WRITE, dest, len, 0);
if (!host_ptr)
return -TARGET_EFAULT;
memcpy(host_ptr, src, len);
unlock_user(host_ptr, dest, 1);
return 0;
}
static int in_group_p(gid_t g)
{
/* return TRUE if we're in the specified group, FALSE otherwise */
int ngroup;
int i;
gid_t grouplist[NGROUPS];
ngroup = getgroups(NGROUPS, grouplist);
for(i = 0; i < ngroup; i++) {
if(grouplist[i] == g) {
return 1;
}
}
return 0;
}
static int count(char ** vec)
{
int i;
for(i = 0; *vec; i++) {
vec++;
}
return(i);
}
static int prepare_binprm(struct linux_binprm *bprm)
{
struct stat st;
int mode;
int retval, id_change;
if(fstat(bprm->fd, &st) < 0) {
return(-errno);
}
mode = st.st_mode;
if(!S_ISREG(mode)) { /* Must be regular file */
return(-EACCES);
}
if(!(mode & 0111)) { /* Must have at least one execute bit set */
return(-EACCES);
}
bprm->e_uid = geteuid();
bprm->e_gid = getegid();
id_change = 0;
/* Set-uid? */
if(mode & S_ISUID) {
bprm->e_uid = st.st_uid;
if(bprm->e_uid != geteuid()) {
id_change = 1;
}
}
/* Set-gid? */
/*
* If setgid is set but no group execute bit then this
* is a candidate for mandatory locking, not a setgid
* executable.
*/
if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
bprm->e_gid = st.st_gid;
if (!in_group_p(bprm->e_gid)) {
id_change = 1;
}
}
memset(bprm->buf, 0, sizeof(bprm->buf));
retval = lseek(bprm->fd, 0L, SEEK_SET);
if(retval >= 0) {
retval = read(bprm->fd, bprm->buf, 128);
}
if(retval < 0) {
perror("prepare_binprm");
exit(-1);
/* return(-errno); */
}
else {
return(retval);
}
}
/* Construct the envp and argv tables on the target stack. */
abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
abi_ulong stringp, int push_ptr)
{
int n = sizeof(abi_ulong);
abi_ulong envp;
abi_ulong argv;
sp -= (envc + 1) * n;
envp = sp;
sp -= (argc + 1) * n;
argv = sp;
if (push_ptr) {
/* FIXME - handle put_user() failures */
sp -= n;
put_user_ual(envp, sp);
sp -= n;
put_user_ual(argv, sp);
}
sp -= n;
/* FIXME - handle put_user() failures */
put_user_ual(argc, sp);
while (argc-- > 0) {
/* FIXME - handle put_user() failures */
put_user_ual(stringp, argv);
argv += n;
stringp += target_strlen(stringp) + 1;
}
/* FIXME - handle put_user() failures */
put_user_ual(0, argv);
while (envc-- > 0) {
/* FIXME - handle put_user() failures */
put_user_ual(stringp, envp);
envp += n;
stringp += target_strlen(stringp) + 1;
}
/* FIXME - handle put_user() failures */
put_user_ual(0, envp);
return sp;
}
int loader_exec(const char * filename, char ** argv, char ** envp,
struct target_pt_regs * regs, struct image_info *infop)
{
struct linux_binprm bprm;
int retval;
int i;
bprm.p = TARGET_PAGE_SIZE*MAX_ARG_PAGES-sizeof(unsigned int);
for (i=0 ; i<MAX_ARG_PAGES ; i++) /* clear page-table */
bprm.page[i] = 0;
retval = open(filename, O_RDONLY);
if (retval < 0)
return retval;
bprm.fd = retval;
bprm.filename = (char *)filename;
bprm.argc = count(argv);
bprm.argv = argv;
bprm.envc = count(envp);
bprm.envp = envp;
retval = prepare_binprm(&bprm);
infop->host_argv = argv;
if(retval>=0) {
if (bprm.buf[0] == 0x7f
&& bprm.buf[1] == 'E'
&& bprm.buf[2] == 'L'
&& bprm.buf[3] == 'F') {
retval = load_elf_binary(&bprm,regs,infop);
} else {
fprintf(stderr, "Unknown binary format\n");
return -1;
}
}
if(retval>=0) {
/* success. Initialize important registers */
do_init_thread(regs, infop);
return retval;
}
/* Something went wrong, return the inode and free the argument pages*/
for (i=0 ; i<MAX_ARG_PAGES ; i++) {
free(bprm.page[i]);
}
return(retval);
}

1523
bsd-user/elfload.c Normal file

File diff suppressed because it is too large Load Diff

149
bsd-user/errno_defs.h Normal file
View File

@ -0,0 +1,149 @@
/* $OpenBSD: errno.h,v 1.20 2007/09/03 14:37:52 millert Exp $ */
/* $NetBSD: errno.h,v 1.10 1996/01/20 01:33:53 jtc Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)errno.h 8.5 (Berkeley) 1/21/94
*/
#define TARGET_EPERM 1 /* Operation not permitted */
#define TARGET_ENOENT 2 /* No such file or directory */
#define TARGET_ESRCH 3 /* No such process */
#define TARGET_EINTR 4 /* Interrupted system call */
#define TARGET_EIO 5 /* Input/output error */
#define TARGET_ENXIO 6 /* Device not configured */
#define TARGET_E2BIG 7 /* Argument list too long */
#define TARGET_ENOEXEC 8 /* Exec format error */
#define TARGET_EBADF 9 /* Bad file descriptor */
#define TARGET_ECHILD 10 /* No child processes */
#define TARGET_EDEADLK 11 /* Resource deadlock avoided */
/* 11 was EAGAIN */
#define TARGET_ENOMEM 12 /* Cannot allocate memory */
#define TARGET_EACCES 13 /* Permission denied */
#define TARGET_EFAULT 14 /* Bad address */
#define TARGET_ENOTBLK 15 /* Block device required */
#define TARGET_EBUSY 16 /* Device busy */
#define TARGET_EEXIST 17 /* File exists */
#define TARGET_EXDEV 18 /* Cross-device link */
#define TARGET_ENODEV 19 /* Operation not supported by device */
#define TARGET_ENOTDIR 20 /* Not a directory */
#define TARGET_EISDIR 21 /* Is a directory */
#define TARGET_EINVAL 22 /* Invalid argument */
#define TARGET_ENFILE 23 /* Too many open files in system */
#define TARGET_EMFILE 24 /* Too many open files */
#define TARGET_ENOTTY 25 /* Inappropriate ioctl for device */
#define TARGET_ETXTBSY 26 /* Text file busy */
#define TARGET_EFBIG 27 /* File too large */
#define TARGET_ENOSPC 28 /* No space left on device */
#define TARGET_ESPIPE 29 /* Illegal seek */
#define TARGET_EROFS 30 /* Read-only file system */
#define TARGET_EMLINK 31 /* Too many links */
#define TARGET_EPIPE 32 /* Broken pipe */
/* math software */
#define TARGET_EDOM 33 /* Numerical argument out of domain */
#define TARGET_ERANGE 34 /* Result too large */
/* non-blocking and interrupt i/o */
#define TARGET_EAGAIN 35 /* Resource temporarily unavailable */
#define TARGET_EWOULDBLOCK EAGAIN /* Operation would block */
#define TARGET_EINPROGRESS 36 /* Operation now in progress */
#define TARGET_EALREADY 37 /* Operation already in progress */
/* ipc/network software -- argument errors */
#define TARGET_ENOTSOCK 38 /* Socket operation on non-socket */
#define TARGET_EDESTADDRREQ 39 /* Destination address required */
#define TARGET_EMSGSIZE 40 /* Message too long */
#define TARGET_EPROTOTYPE 41 /* Protocol wrong type for socket */
#define TARGET_ENOPROTOOPT 42 /* Protocol not available */
#define TARGET_EPROTONOSUPPORT 43 /* Protocol not supported */
#define TARGET_ESOCKTNOSUPPORT 44 /* Socket type not supported */
#define TARGET_EOPNOTSUPP 45 /* Operation not supported */
#define TARGET_EPFNOSUPPORT 46 /* Protocol family not supported */
#define TARGET_EAFNOSUPPORT 47 /* Address family not supported by protocol family */
#define TARGET_EADDRINUSE 48 /* Address already in use */
#define TARGET_EADDRNOTAVAIL 49 /* Can't assign requested address */
/* ipc/network software -- operational errors */
#define TARGET_ENETDOWN 50 /* Network is down */
#define TARGET_ENETUNREACH 51 /* Network is unreachable */
#define TARGET_ENETRESET 52 /* Network dropped connection on reset */
#define TARGET_ECONNABORTED 53 /* Software caused connection abort */
#define TARGET_ECONNRESET 54 /* Connection reset by peer */
#define TARGET_ENOBUFS 55 /* No buffer space available */
#define TARGET_EISCONN 56 /* Socket is already connected */
#define TARGET_ENOTCONN 57 /* Socket is not connected */
#define TARGET_ESHUTDOWN 58 /* Can't send after socket shutdown */
#define TARGET_ETOOMANYREFS 59 /* Too many references: can't splice */
#define TARGET_ETIMEDOUT 60 /* Operation timed out */
#define TARGET_ECONNREFUSED 61 /* Connection refused */
#define TARGET_ELOOP 62 /* Too many levels of symbolic links */
#define TARGET_ENAMETOOLONG 63 /* File name too long */
/* should be rearranged */
#define TARGET_EHOSTDOWN 64 /* Host is down */
#define TARGET_EHOSTUNREACH 65 /* No route to host */
#define TARGET_ENOTEMPTY 66 /* Directory not empty */
/* quotas & mush */
#define TARGET_EPROCLIM 67 /* Too many processes */
#define TARGET_EUSERS 68 /* Too many users */
#define TARGET_EDQUOT 69 /* Disk quota exceeded */
/* Network File System */
#define TARGET_ESTALE 70 /* Stale NFS file handle */
#define TARGET_EREMOTE 71 /* Too many levels of remote in path */
#define TARGET_EBADRPC 72 /* RPC struct is bad */
#define TARGET_ERPCMISMATCH 73 /* RPC version wrong */
#define TARGET_EPROGUNAVAIL 74 /* RPC prog. not avail */
#define TARGET_EPROGMISMATCH 75 /* Program version wrong */
#define TARGET_EPROCUNAVAIL 76 /* Bad procedure for program */
#define TARGET_ENOLCK 77 /* No locks available */
#define TARGET_ENOSYS 78 /* Function not implemented */
#define TARGET_EFTYPE 79 /* Inappropriate file type or format */
#define TARGET_EAUTH 80 /* Authentication error */
#define TARGET_ENEEDAUTH 81 /* Need authenticator */
#define TARGET_EIPSEC 82 /* IPsec processing failure */
#define TARGET_ENOATTR 83 /* Attribute not found */
#define TARGET_EILSEQ 84 /* Illegal byte sequence */
#define TARGET_ENOMEDIUM 85 /* No medium found */
#define TARGET_EMEDIUMTYPE 86 /* Wrong Medium Type */
#define TARGET_EOVERFLOW 87 /* Conversion overflow */
#define TARGET_ECANCELED 88 /* Operation canceled */
#define TARGET_EIDRM 89 /* Identifier removed */
#define TARGET_ENOMSG 90 /* No message of desired type */
#define TARGET_ELAST 90 /* Must be equal largest errno */

View File

@ -0,0 +1,170 @@
{ TARGET_FREEBSD_NR___getcwd, "__getcwd", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR___semctl, "__semctl", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR___syscall, "__syscall", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR___sysctl, "__sysctl", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_accept, "accept", "%s(%d,%#x,%#x)", NULL, NULL },
{ TARGET_FREEBSD_NR_access, "access", "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_FREEBSD_NR_acct, "acct", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_adjtime, "adjtime", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_bind, "bind", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_break, "break", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_chdir, "chdir", "%s(\"%s\")", NULL, NULL },
{ TARGET_FREEBSD_NR_chflags, "chflags", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_chmod, "chmod", "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_FREEBSD_NR_chown, "chown", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_chroot, "chroot", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_clock_getres, "clock_getres", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_clock_gettime, "clock_gettime", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_clock_settime, "clock_settime", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_close, "close", "%s(%d)", NULL, NULL },
{ TARGET_FREEBSD_NR_connect, "connect", "%s(%d,%#x,%d)", NULL, NULL },
{ TARGET_FREEBSD_NR_dup, "dup", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_dup2, "dup2", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_execve, "execve", NULL, print_execve, NULL },
{ TARGET_FREEBSD_NR_exit, "exit", "%s(%d)\n", NULL, NULL },
{ TARGET_FREEBSD_NR_fchdir, "fchdir", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_fchflags, "fchflags", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_fchmod, "fchmod", "%s(%d,%#o)", NULL, NULL },
{ TARGET_FREEBSD_NR_fchown, "fchown", "%s(\"%s\",%d,%d)", NULL, NULL },
{ TARGET_FREEBSD_NR_fcntl, "fcntl", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_fhopen, "fhopen", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_fhstat, "fhstat", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_fhstatfs, "fhstatfs", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_flock, "flock", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_fork, "fork", "%s()", NULL, NULL },
{ TARGET_FREEBSD_NR_fpathconf, "fpathconf", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_fstat, "fstat", "%s(%d,%p)", NULL, NULL },
{ TARGET_FREEBSD_NR_fstatfs, "fstatfs", "%s(%d,%p)", NULL, NULL },
{ TARGET_FREEBSD_NR_fsync, "fsync", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_ftruncate, "ftruncate", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_futimes, "futimes", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getdirentries, "getdirentries", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getegid, "getegid", "%s()", NULL, NULL },
{ TARGET_FREEBSD_NR_geteuid, "geteuid", "%s()", NULL, NULL },
{ TARGET_FREEBSD_NR_getfh, "getfh", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getfsstat, "getfsstat", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getgid, "getgid", "%s()", NULL, NULL },
{ TARGET_FREEBSD_NR_getgroups, "getgroups", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getitimer, "getitimer", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getlogin, "getlogin", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getpeername, "getpeername", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getpgid, "getpgid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getpgrp, "getpgrp", "%s()", NULL, NULL },
{ TARGET_FREEBSD_NR_getpid, "getpid", "%s()", NULL, NULL },
{ TARGET_FREEBSD_NR_getppid, "getppid", "%s()", NULL, NULL },
{ TARGET_FREEBSD_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL },
{ TARGET_FREEBSD_NR_getresgid, "getresgid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getresuid, "getresuid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getrlimit, "getrlimit", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getrusage, "getrusage", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getsid, "getsid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getsockname, "getsockname", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getsockopt, "getsockopt", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_gettimeofday, "gettimeofday", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getuid, "getuid", "%s()", NULL, NULL },
{ TARGET_FREEBSD_NR_ioctl, "ioctl", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_issetugid, "issetugid", "%s()", NULL, NULL },
{ TARGET_FREEBSD_NR_kevent, "kevent", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_kill, "kill", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_kqueue, "kqueue", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_ktrace, "ktrace", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_lchown, "lchown", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_link, "link", "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_FREEBSD_NR_listen, "listen", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_lseek, "lseek", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_lstat, "lstat", "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_FREEBSD_NR_madvise, "madvise", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_mincore, "mincore", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_minherit, "minherit", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_mkdir, "mkdir", "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_FREEBSD_NR_mkfifo, "mkfifo", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_mknod, "mknod", "%s(\"%s\",%#o,%#x)", NULL, NULL },
{ TARGET_FREEBSD_NR_mlock, "mlock", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_mlockall, "mlockall", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_mmap, "mmap", NULL, NULL, print_syscall_ret_addr },
{ TARGET_FREEBSD_NR_mount, "mount", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_mprotect, "mprotect", "%s(%#x,%#x,%d)", NULL, NULL },
{ TARGET_FREEBSD_NR_msgctl, "msgctl", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_msgget, "msgget", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_msgrcv, "msgrcv", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_msgsnd, "msgsnd", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_msync, "msync", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_munlock, "munlock", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_munlockall, "munlockall", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_munmap, "munmap", "%s(%p,%d)", NULL, NULL },
{ TARGET_FREEBSD_NR_nanosleep, "nanosleep", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_nfssvc, "nfssvc", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_open, "open", "%s(\"%s\",%#x,%#o)", NULL, NULL },
{ TARGET_FREEBSD_NR_pathconf, "pathconf", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_pipe, "pipe", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_poll, "poll", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_pread, "pread", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_preadv, "preadv", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_profil, "profil", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_ptrace, "ptrace", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_pwrite, "pwrite", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_pwritev, "pwritev", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_quotactl, "quotactl", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_read, "read", "%s(%d,%#x,%d)", NULL, NULL },
{ TARGET_FREEBSD_NR_readlink, "readlink", "%s(\"%s\",%p,%d)", NULL, NULL },
{ TARGET_FREEBSD_NR_readv, "readv", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_reboot, "reboot", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_recvfrom, "recvfrom", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_recvmsg, "recvmsg", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_rename, "rename", "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_FREEBSD_NR_revoke, "revoke", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_rfork, "rfork", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_rmdir, "rmdir", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sbrk, "sbrk", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sched_yield, "sched_yield", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_select, "select", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_semget, "semget", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_semop, "semop", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sendmsg, "sendmsg", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sendto, "sendto", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setegid, "setegid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_seteuid, "seteuid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setgid, "setgid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setgroups, "setgroups", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setitimer, "setitimer", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setlogin, "setlogin", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setpgid, "setpgid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setpriority, "setpriority", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setregid, "setregid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setresgid, "setresgid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setresuid, "setresuid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setreuid, "setreuid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setrlimit, "setrlimit", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setsid, "setsid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setsockopt, "setsockopt", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_settimeofday, "settimeofday", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setuid, "setuid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_shmat, "shmat", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_shmctl, "shmctl", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_shmdt, "shmdt", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_shmget, "shmget", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_shutdown, "shutdown", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sigaction, "sigaction", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sigaltstack, "sigaltstack", "%s(%p,%p)", NULL, NULL },
{ TARGET_FREEBSD_NR_sigpending, "sigpending", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sigprocmask, "sigprocmask", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sigreturn, "sigreturn", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sigsuspend, "sigsuspend", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_socket, "socket", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_socketpair, "socketpair", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sstk, "sstk", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_stat, "stat", "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_FREEBSD_NR_statfs, "statfs", "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_FREEBSD_NR_symlink, "symlink", "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_FREEBSD_NR_sync, "sync", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sysarch, "sysarch", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_syscall, "syscall", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_truncate, "truncate", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_umask, "umask", "%s(%#o)", NULL, NULL },
{ TARGET_FREEBSD_NR_unlink, "unlink", "%s(\"%s\")", NULL, NULL },
{ TARGET_FREEBSD_NR_unmount, "unmount", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_utimes, "utimes", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_vfork, "vfork", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_wait4, "wait4", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_write, "write", "%s(%d,%#x,%d)", NULL, NULL },
{ TARGET_FREEBSD_NR_writev, "writev", "%s(%d,%p,%#x)", NULL, NULL },

View File

@ -0,0 +1,373 @@
/*
* System call numbers.
*
* $FreeBSD: src/sys/sys/syscall.h,v 1.224 2008/08/24 21:23:08 rwatson Exp $
* created from FreeBSD: head/sys/kern/syscalls.master 182123 2008-08-24 21:20:35Z rwatson
*/
#define TARGET_FREEBSD_NR_syscall 0
#define TARGET_FREEBSD_NR_exit 1
#define TARGET_FREEBSD_NR_fork 2
#define TARGET_FREEBSD_NR_read 3
#define TARGET_FREEBSD_NR_write 4
#define TARGET_FREEBSD_NR_open 5
#define TARGET_FREEBSD_NR_close 6
#define TARGET_FREEBSD_NR_wait4 7
#define TARGET_FREEBSD_NR_link 9
#define TARGET_FREEBSD_NR_unlink 10
#define TARGET_FREEBSD_NR_chdir 12
#define TARGET_FREEBSD_NR_fchdir 13
#define TARGET_FREEBSD_NR_mknod 14
#define TARGET_FREEBSD_NR_chmod 15
#define TARGET_FREEBSD_NR_chown 16
#define TARGET_FREEBSD_NR_break 17
#define TARGET_FREEBSD_NR_freebsd4_getfsstat 18
#define TARGET_FREEBSD_NR_getpid 20
#define TARGET_FREEBSD_NR_mount 21
#define TARGET_FREEBSD_NR_unmount 22
#define TARGET_FREEBSD_NR_setuid 23
#define TARGET_FREEBSD_NR_getuid 24
#define TARGET_FREEBSD_NR_geteuid 25
#define TARGET_FREEBSD_NR_ptrace 26
#define TARGET_FREEBSD_NR_recvmsg 27
#define TARGET_FREEBSD_NR_sendmsg 28
#define TARGET_FREEBSD_NR_recvfrom 29
#define TARGET_FREEBSD_NR_accept 30
#define TARGET_FREEBSD_NR_getpeername 31
#define TARGET_FREEBSD_NR_getsockname 32
#define TARGET_FREEBSD_NR_access 33
#define TARGET_FREEBSD_NR_chflags 34
#define TARGET_FREEBSD_NR_fchflags 35
#define TARGET_FREEBSD_NR_sync 36
#define TARGET_FREEBSD_NR_kill 37
#define TARGET_FREEBSD_NR_getppid 39
#define TARGET_FREEBSD_NR_dup 41
#define TARGET_FREEBSD_NR_pipe 42
#define TARGET_FREEBSD_NR_getegid 43
#define TARGET_FREEBSD_NR_profil 44
#define TARGET_FREEBSD_NR_ktrace 45
#define TARGET_FREEBSD_NR_getgid 47
#define TARGET_FREEBSD_NR_getlogin 49
#define TARGET_FREEBSD_NR_setlogin 50
#define TARGET_FREEBSD_NR_acct 51
#define TARGET_FREEBSD_NR_sigaltstack 53
#define TARGET_FREEBSD_NR_ioctl 54
#define TARGET_FREEBSD_NR_reboot 55
#define TARGET_FREEBSD_NR_revoke 56
#define TARGET_FREEBSD_NR_symlink 57
#define TARGET_FREEBSD_NR_readlink 58
#define TARGET_FREEBSD_NR_execve 59
#define TARGET_FREEBSD_NR_umask 60
#define TARGET_FREEBSD_NR_chroot 61
#define TARGET_FREEBSD_NR_msync 65
#define TARGET_FREEBSD_NR_vfork 66
#define TARGET_FREEBSD_NR_sbrk 69
#define TARGET_FREEBSD_NR_sstk 70
#define TARGET_FREEBSD_NR_vadvise 72
#define TARGET_FREEBSD_NR_munmap 73
#define TARGET_FREEBSD_NR_mprotect 74
#define TARGET_FREEBSD_NR_madvise 75
#define TARGET_FREEBSD_NR_mincore 78
#define TARGET_FREEBSD_NR_getgroups 79
#define TARGET_FREEBSD_NR_setgroups 80
#define TARGET_FREEBSD_NR_getpgrp 81
#define TARGET_FREEBSD_NR_setpgid 82
#define TARGET_FREEBSD_NR_setitimer 83
#define TARGET_FREEBSD_NR_swapon 85
#define TARGET_FREEBSD_NR_getitimer 86
#define TARGET_FREEBSD_NR_getdtablesize 89
#define TARGET_FREEBSD_NR_dup2 90
#define TARGET_FREEBSD_NR_fcntl 92
#define TARGET_FREEBSD_NR_select 93
#define TARGET_FREEBSD_NR_fsync 95
#define TARGET_FREEBSD_NR_setpriority 96
#define TARGET_FREEBSD_NR_socket 97
#define TARGET_FREEBSD_NR_connect 98
#define TARGET_FREEBSD_NR_getpriority 100
#define TARGET_FREEBSD_NR_bind 104
#define TARGET_FREEBSD_NR_setsockopt 105
#define TARGET_FREEBSD_NR_listen 106
#define TARGET_FREEBSD_NR_gettimeofday 116
#define TARGET_FREEBSD_NR_getrusage 117
#define TARGET_FREEBSD_NR_getsockopt 118
#define TARGET_FREEBSD_NR_readv 120
#define TARGET_FREEBSD_NR_writev 121
#define TARGET_FREEBSD_NR_settimeofday 122
#define TARGET_FREEBSD_NR_fchown 123
#define TARGET_FREEBSD_NR_fchmod 124
#define TARGET_FREEBSD_NR_setreuid 126
#define TARGET_FREEBSD_NR_setregid 127
#define TARGET_FREEBSD_NR_rename 128
#define TARGET_FREEBSD_NR_flock 131
#define TARGET_FREEBSD_NR_mkfifo 132
#define TARGET_FREEBSD_NR_sendto 133
#define TARGET_FREEBSD_NR_shutdown 134
#define TARGET_FREEBSD_NR_socketpair 135
#define TARGET_FREEBSD_NR_mkdir 136
#define TARGET_FREEBSD_NR_rmdir 137
#define TARGET_FREEBSD_NR_utimes 138
#define TARGET_FREEBSD_NR_adjtime 140
#define TARGET_FREEBSD_NR_setsid 147
#define TARGET_FREEBSD_NR_quotactl 148
#define TARGET_FREEBSD_NR_nlm_syscall 154
#define TARGET_FREEBSD_NR_nfssvc 155
#define TARGET_FREEBSD_NR_freebsd4_statfs 157
#define TARGET_FREEBSD_NR_freebsd4_fstatfs 158
#define TARGET_FREEBSD_NR_lgetfh 160
#define TARGET_FREEBSD_NR_getfh 161
#define TARGET_FREEBSD_NR_getdomainname 162
#define TARGET_FREEBSD_NR_setdomainname 163
#define TARGET_FREEBSD_NR_uname 164
#define TARGET_FREEBSD_NR_sysarch 165
#define TARGET_FREEBSD_NR_rtprio 166
#define TARGET_FREEBSD_NR_semsys 169
#define TARGET_FREEBSD_NR_msgsys 170
#define TARGET_FREEBSD_NR_shmsys 171
#define TARGET_FREEBSD_NR_freebsd6_pread 173
#define TARGET_FREEBSD_NR_freebsd6_pwrite 174
#define TARGET_FREEBSD_NR_setfib 175
#define TARGET_FREEBSD_NR_ntp_adjtime 176
#define TARGET_FREEBSD_NR_setgid 181
#define TARGET_FREEBSD_NR_setegid 182
#define TARGET_FREEBSD_NR_seteuid 183
#define TARGET_FREEBSD_NR_stat 188
#define TARGET_FREEBSD_NR_fstat 189
#define TARGET_FREEBSD_NR_lstat 190
#define TARGET_FREEBSD_NR_pathconf 191
#define TARGET_FREEBSD_NR_fpathconf 192
#define TARGET_FREEBSD_NR_getrlimit 194
#define TARGET_FREEBSD_NR_setrlimit 195
#define TARGET_FREEBSD_NR_getdirentries 196
#define TARGET_FREEBSD_NR_freebsd6_mmap 197
#define TARGET_FREEBSD_NR___syscall 198
#define TARGET_FREEBSD_NR_freebsd6_lseek 199
#define TARGET_FREEBSD_NR_freebsd6_truncate 200
#define TARGET_FREEBSD_NR_freebsd6_ftruncate 201
#define TARGET_FREEBSD_NR___sysctl 202
#define TARGET_FREEBSD_NR_mlock 203
#define TARGET_FREEBSD_NR_munlock 204
#define TARGET_FREEBSD_NR_undelete 205
#define TARGET_FREEBSD_NR_futimes 206
#define TARGET_FREEBSD_NR_getpgid 207
#define TARGET_FREEBSD_NR_poll 209
#define TARGET_FREEBSD_NR___semctl 220
#define TARGET_FREEBSD_NR_semget 221
#define TARGET_FREEBSD_NR_semop 222
#define TARGET_FREEBSD_NR_msgctl 224
#define TARGET_FREEBSD_NR_msgget 225
#define TARGET_FREEBSD_NR_msgsnd 226
#define TARGET_FREEBSD_NR_msgrcv 227
#define TARGET_FREEBSD_NR_shmat 228
#define TARGET_FREEBSD_NR_shmctl 229
#define TARGET_FREEBSD_NR_shmdt 230
#define TARGET_FREEBSD_NR_shmget 231
#define TARGET_FREEBSD_NR_clock_gettime 232
#define TARGET_FREEBSD_NR_clock_settime 233
#define TARGET_FREEBSD_NR_clock_getres 234
#define TARGET_FREEBSD_NR_ktimer_create 235
#define TARGET_FREEBSD_NR_ktimer_delete 236
#define TARGET_FREEBSD_NR_ktimer_settime 237
#define TARGET_FREEBSD_NR_ktimer_gettime 238
#define TARGET_FREEBSD_NR_ktimer_getoverrun 239
#define TARGET_FREEBSD_NR_nanosleep 240
#define TARGET_FREEBSD_NR_ntp_gettime 248
#define TARGET_FREEBSD_NR_minherit 250
#define TARGET_FREEBSD_NR_rfork 251
#define TARGET_FREEBSD_NR_openbsd_poll 252
#define TARGET_FREEBSD_NR_issetugid 253
#define TARGET_FREEBSD_NR_lchown 254
#define TARGET_FREEBSD_NR_aio_read 255
#define TARGET_FREEBSD_NR_aio_write 256
#define TARGET_FREEBSD_NR_lio_listio 257
#define TARGET_FREEBSD_NR_getdents 272
#define TARGET_FREEBSD_NR_lchmod 274
#define TARGET_FREEBSD_NR_netbsd_lchown 275
#define TARGET_FREEBSD_NR_lutimes 276
#define TARGET_FREEBSD_NR_netbsd_msync 277
#define TARGET_FREEBSD_NR_nstat 278
#define TARGET_FREEBSD_NR_nfstat 279
#define TARGET_FREEBSD_NR_nlstat 280
#define TARGET_FREEBSD_NR_preadv 289
#define TARGET_FREEBSD_NR_pwritev 290
#define TARGET_FREEBSD_NR_freebsd4_fhstatfs 297
#define TARGET_FREEBSD_NR_fhopen 298
#define TARGET_FREEBSD_NR_fhstat 299
#define TARGET_FREEBSD_NR_modnext 300
#define TARGET_FREEBSD_NR_modstat 301
#define TARGET_FREEBSD_NR_modfnext 302
#define TARGET_FREEBSD_NR_modfind 303
#define TARGET_FREEBSD_NR_kldload 304
#define TARGET_FREEBSD_NR_kldunload 305
#define TARGET_FREEBSD_NR_kldfind 306
#define TARGET_FREEBSD_NR_kldnext 307
#define TARGET_FREEBSD_NR_kldstat 308
#define TARGET_FREEBSD_NR_kldfirstmod 309
#define TARGET_FREEBSD_NR_getsid 310
#define TARGET_FREEBSD_NR_setresuid 311
#define TARGET_FREEBSD_NR_setresgid 312
#define TARGET_FREEBSD_NR_aio_return 314
#define TARGET_FREEBSD_NR_aio_suspend 315
#define TARGET_FREEBSD_NR_aio_cancel 316
#define TARGET_FREEBSD_NR_aio_error 317
#define TARGET_FREEBSD_NR_oaio_read 318
#define TARGET_FREEBSD_NR_oaio_write 319
#define TARGET_FREEBSD_NR_olio_listio 320
#define TARGET_FREEBSD_NR_yield 321
#define TARGET_FREEBSD_NR_mlockall 324
#define TARGET_FREEBSD_NR_munlockall 325
#define TARGET_FREEBSD_NR___getcwd 326
#define TARGET_FREEBSD_NR_sched_setparam 327
#define TARGET_FREEBSD_NR_sched_getparam 328
#define TARGET_FREEBSD_NR_sched_setscheduler 329
#define TARGET_FREEBSD_NR_sched_getscheduler 330
#define TARGET_FREEBSD_NR_sched_yield 331
#define TARGET_FREEBSD_NR_sched_get_priority_max 332
#define TARGET_FREEBSD_NR_sched_get_priority_min 333
#define TARGET_FREEBSD_NR_sched_rr_get_interval 334
#define TARGET_FREEBSD_NR_utrace 335
#define TARGET_FREEBSD_NR_freebsd4_sendfile 336
#define TARGET_FREEBSD_NR_kldsym 337
#define TARGET_FREEBSD_NR_jail 338
#define TARGET_FREEBSD_NR_sigprocmask 340
#define TARGET_FREEBSD_NR_sigsuspend 341
#define TARGET_FREEBSD_NR_freebsd4_sigaction 342
#define TARGET_FREEBSD_NR_sigpending 343
#define TARGET_FREEBSD_NR_freebsd4_sigreturn 344
#define TARGET_FREEBSD_NR_sigtimedwait 345
#define TARGET_FREEBSD_NR_sigwaitinfo 346
#define TARGET_FREEBSD_NR___acl_get_file 347
#define TARGET_FREEBSD_NR___acl_set_file 348
#define TARGET_FREEBSD_NR___acl_get_fd 349
#define TARGET_FREEBSD_NR___acl_set_fd 350
#define TARGET_FREEBSD_NR___acl_delete_file 351
#define TARGET_FREEBSD_NR___acl_delete_fd 352
#define TARGET_FREEBSD_NR___acl_aclcheck_file 353
#define TARGET_FREEBSD_NR___acl_aclcheck_fd 354
#define TARGET_FREEBSD_NR_extattrctl 355
#define TARGET_FREEBSD_NR_extattr_set_file 356
#define TARGET_FREEBSD_NR_extattr_get_file 357
#define TARGET_FREEBSD_NR_extattr_delete_file 358
#define TARGET_FREEBSD_NR_aio_waitcomplete 359
#define TARGET_FREEBSD_NR_getresuid 360
#define TARGET_FREEBSD_NR_getresgid 361
#define TARGET_FREEBSD_NR_kqueue 362
#define TARGET_FREEBSD_NR_kevent 363
#define TARGET_FREEBSD_NR_extattr_set_fd 371
#define TARGET_FREEBSD_NR_extattr_get_fd 372
#define TARGET_FREEBSD_NR_extattr_delete_fd 373
#define TARGET_FREEBSD_NR___setugid 374
#define TARGET_FREEBSD_NR_nfsclnt 375
#define TARGET_FREEBSD_NR_eaccess 376
#define TARGET_FREEBSD_NR_nmount 378
#define TARGET_FREEBSD_NR___mac_get_proc 384
#define TARGET_FREEBSD_NR___mac_set_proc 385
#define TARGET_FREEBSD_NR___mac_get_fd 386
#define TARGET_FREEBSD_NR___mac_get_file 387
#define TARGET_FREEBSD_NR___mac_set_fd 388
#define TARGET_FREEBSD_NR___mac_set_file 389
#define TARGET_FREEBSD_NR_kenv 390
#define TARGET_FREEBSD_NR_lchflags 391
#define TARGET_FREEBSD_NR_uuidgen 392
#define TARGET_FREEBSD_NR_sendfile 393
#define TARGET_FREEBSD_NR_mac_syscall 394
#define TARGET_FREEBSD_NR_getfsstat 395
#define TARGET_FREEBSD_NR_statfs 396
#define TARGET_FREEBSD_NR_fstatfs 397
#define TARGET_FREEBSD_NR_fhstatfs 398
#define TARGET_FREEBSD_NR_ksem_close 400
#define TARGET_FREEBSD_NR_ksem_post 401
#define TARGET_FREEBSD_NR_ksem_wait 402
#define TARGET_FREEBSD_NR_ksem_trywait 403
#define TARGET_FREEBSD_NR_ksem_init 404
#define TARGET_FREEBSD_NR_ksem_open 405
#define TARGET_FREEBSD_NR_ksem_unlink 406
#define TARGET_FREEBSD_NR_ksem_getvalue 407
#define TARGET_FREEBSD_NR_ksem_destroy 408
#define TARGET_FREEBSD_NR___mac_get_pid 409
#define TARGET_FREEBSD_NR___mac_get_link 410
#define TARGET_FREEBSD_NR___mac_set_link 411
#define TARGET_FREEBSD_NR_extattr_set_link 412
#define TARGET_FREEBSD_NR_extattr_get_link 413
#define TARGET_FREEBSD_NR_extattr_delete_link 414
#define TARGET_FREEBSD_NR___mac_execve 415
#define TARGET_FREEBSD_NR_sigaction 416
#define TARGET_FREEBSD_NR_sigreturn 417
#define TARGET_FREEBSD_NR_getcontext 421
#define TARGET_FREEBSD_NR_setcontext 422
#define TARGET_FREEBSD_NR_swapcontext 423
#define TARGET_FREEBSD_NR_swapoff 424
#define TARGET_FREEBSD_NR___acl_get_link 425
#define TARGET_FREEBSD_NR___acl_set_link 426
#define TARGET_FREEBSD_NR___acl_delete_link 427
#define TARGET_FREEBSD_NR___acl_aclcheck_link 428
#define TARGET_FREEBSD_NR_sigwait 429
#define TARGET_FREEBSD_NR_thr_create 430
#define TARGET_FREEBSD_NR_thr_exit 431
#define TARGET_FREEBSD_NR_thr_self 432
#define TARGET_FREEBSD_NR_thr_kill 433
#define TARGET_FREEBSD_NR__umtx_lock 434
#define TARGET_FREEBSD_NR__umtx_unlock 435
#define TARGET_FREEBSD_NR_jail_attach 436
#define TARGET_FREEBSD_NR_extattr_list_fd 437
#define TARGET_FREEBSD_NR_extattr_list_file 438
#define TARGET_FREEBSD_NR_extattr_list_link 439
#define TARGET_FREEBSD_NR_ksem_timedwait 441
#define TARGET_FREEBSD_NR_thr_suspend 442
#define TARGET_FREEBSD_NR_thr_wake 443
#define TARGET_FREEBSD_NR_kldunloadf 444
#define TARGET_FREEBSD_NR_audit 445
#define TARGET_FREEBSD_NR_auditon 446
#define TARGET_FREEBSD_NR_getauid 447
#define TARGET_FREEBSD_NR_setauid 448
#define TARGET_FREEBSD_NR_getaudit 449
#define TARGET_FREEBSD_NR_setaudit 450
#define TARGET_FREEBSD_NR_getaudit_addr 451
#define TARGET_FREEBSD_NR_setaudit_addr 452
#define TARGET_FREEBSD_NR_auditctl 453
#define TARGET_FREEBSD_NR__umtx_op 454
#define TARGET_FREEBSD_NR_thr_new 455
#define TARGET_FREEBSD_NR_sigqueue 456
#define TARGET_FREEBSD_NR_kmq_open 457
#define TARGET_FREEBSD_NR_kmq_setattr 458
#define TARGET_FREEBSD_NR_kmq_timedreceive 459
#define TARGET_FREEBSD_NR_kmq_timedsend 460
#define TARGET_FREEBSD_NR_kmq_notify 461
#define TARGET_FREEBSD_NR_kmq_unlink 462
#define TARGET_FREEBSD_NR_abort2 463
#define TARGET_FREEBSD_NR_thr_set_name 464
#define TARGET_FREEBSD_NR_aio_fsync 465
#define TARGET_FREEBSD_NR_rtprio_thread 466
#define TARGET_FREEBSD_NR_sctp_peeloff 471
#define TARGET_FREEBSD_NR_sctp_generic_sendmsg 472
#define TARGET_FREEBSD_NR_sctp_generic_sendmsg_iov 473
#define TARGET_FREEBSD_NR_sctp_generic_recvmsg 474
#define TARGET_FREEBSD_NR_pread 475
#define TARGET_FREEBSD_NR_pwrite 476
#define TARGET_FREEBSD_NR_mmap 477
#define TARGET_FREEBSD_NR_lseek 478
#define TARGET_FREEBSD_NR_truncate 479
#define TARGET_FREEBSD_NR_ftruncate 480
#define TARGET_FREEBSD_NR_thr_kill2 481
#define TARGET_FREEBSD_NR_shm_open 482
#define TARGET_FREEBSD_NR_shm_unlink 483
#define TARGET_FREEBSD_NR_cpuset 484
#define TARGET_FREEBSD_NR_cpuset_setid 485
#define TARGET_FREEBSD_NR_cpuset_getid 486
#define TARGET_FREEBSD_NR_cpuset_getaffinity 487
#define TARGET_FREEBSD_NR_cpuset_setaffinity 488
#define TARGET_FREEBSD_NR_faccessat 489
#define TARGET_FREEBSD_NR_fchmodat 490
#define TARGET_FREEBSD_NR_fchownat 491
#define TARGET_FREEBSD_NR_fexecve 492
#define TARGET_FREEBSD_NR_fstatat 493
#define TARGET_FREEBSD_NR_futimesat 494
#define TARGET_FREEBSD_NR_linkat 495
#define TARGET_FREEBSD_NR_mkdirat 496
#define TARGET_FREEBSD_NR_mkfifoat 497
#define TARGET_FREEBSD_NR_mknodat 498
#define TARGET_FREEBSD_NR_openat 499
#define TARGET_FREEBSD_NR_readlinkat 500
#define TARGET_FREEBSD_NR_renameat 501
#define TARGET_FREEBSD_NR_symlinkat 502
#define TARGET_FREEBSD_NR_unlinkat 503
#define TARGET_FREEBSD_NR_posix_openpt 504

576
bsd-user/main.c Normal file
View File

@ -0,0 +1,576 @@
/*
* qemu user main
*
* Copyright (c) 2003-2008 Fabrice Bellard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <machine/trap.h>
#include "qemu.h"
#include "qemu-common.h"
/* For tb_lock */
#include "exec-all.h"
#define DEBUG_LOGFILE "/tmp/qemu.log"
static const char *interp_prefix = CONFIG_QEMU_PREFIX;
const char *qemu_uname_release = CONFIG_UNAME_RELEASE;
extern char **environ;
/* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so
we allocate a bigger stack. Need a better solution, for example
by remapping the process stack directly at the right place */
unsigned long x86_stack_size = 512 * 1024;
void gemu_log(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
}
#ifdef TARGET_SPARC
#define SPARC64_STACK_BIAS 2047
//#define DEBUG_WIN
/* WARNING: dealing with register windows _is_ complicated. More info
can be found at http://www.sics.se/~psm/sparcstack.html */
static inline int get_reg_index(CPUSPARCState *env, int cwp, int index)
{
index = (index + cwp * 16) % (16 * env->nwindows);
/* wrap handling : if cwp is on the last window, then we use the
registers 'after' the end */
if (index < 8 && env->cwp == env->nwindows - 1)
index += 16 * env->nwindows;
return index;
}
/* save the register window 'cwp1' */
static inline void save_window_offset(CPUSPARCState *env, int cwp1)
{
unsigned int i;
abi_ulong sp_ptr;
sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)];
#ifdef TARGET_SPARC64
if (sp_ptr & 3)
sp_ptr += SPARC64_STACK_BIAS;
#endif
#if defined(DEBUG_WIN)
printf("win_overflow: sp_ptr=0x" TARGET_ABI_FMT_lx " save_cwp=%d\n",
sp_ptr, cwp1);
#endif
for(i = 0; i < 16; i++) {
/* FIXME - what to do if put_user() fails? */
put_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr);
sp_ptr += sizeof(abi_ulong);
}
}
static void save_window(CPUSPARCState *env)
{
#ifndef TARGET_SPARC64
unsigned int new_wim;
new_wim = ((env->wim >> 1) | (env->wim << (env->nwindows - 1))) &
((1LL << env->nwindows) - 1);
save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
env->wim = new_wim;
#else
save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
env->cansave++;
env->canrestore--;
#endif
}
static void restore_window(CPUSPARCState *env)
{
#ifndef TARGET_SPARC64
unsigned int new_wim;
#endif
unsigned int i, cwp1;
abi_ulong sp_ptr;
#ifndef TARGET_SPARC64
new_wim = ((env->wim << 1) | (env->wim >> (env->nwindows - 1))) &
((1LL << env->nwindows) - 1);
#endif
/* restore the invalid window */
cwp1 = cpu_cwp_inc(env, env->cwp + 1);
sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)];
#ifdef TARGET_SPARC64
if (sp_ptr & 3)
sp_ptr += SPARC64_STACK_BIAS;
#endif
#if defined(DEBUG_WIN)
printf("win_underflow: sp_ptr=0x" TARGET_ABI_FMT_lx " load_cwp=%d\n",
sp_ptr, cwp1);
#endif
for(i = 0; i < 16; i++) {
/* FIXME - what to do if get_user() fails? */
get_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr);
sp_ptr += sizeof(abi_ulong);
}
#ifdef TARGET_SPARC64
env->canrestore++;
if (env->cleanwin < env->nwindows - 1)
env->cleanwin++;
env->cansave--;
#else
env->wim = new_wim;
#endif
}
static void flush_windows(CPUSPARCState *env)
{
int offset, cwp1;
offset = 1;
for(;;) {
/* if restore would invoke restore_window(), then we can stop */
cwp1 = cpu_cwp_inc(env, env->cwp + offset);
#ifndef TARGET_SPARC64
if (env->wim & (1 << cwp1))
break;
#else
if (env->canrestore == 0)
break;
env->cansave++;
env->canrestore--;
#endif
save_window_offset(env, cwp1);
offset++;
}
cwp1 = cpu_cwp_inc(env, env->cwp + 1);
#ifndef TARGET_SPARC64
/* set wim so that restore will reload the registers */
env->wim = 1 << cwp1;
#endif
#if defined(DEBUG_WIN)
printf("flush_windows: nb=%d\n", offset - 1);
#endif
}
void cpu_loop(CPUSPARCState *env, enum BSDType bsd_type)
{
int trapnr, ret, syscall_nr;
//target_siginfo_t info;
while (1) {
trapnr = cpu_sparc_exec (env);
switch (trapnr) {
case 0x100:
syscall_nr = env->gregs[1];
#if defined(TARGET_SPARC)
syscall_nr &= ~(SYSCALL_G7RFLAG | SYSCALL_G2RFLAG);
#endif
if (bsd_type == target_freebsd)
ret = do_freebsd_syscall(env, syscall_nr,
env->regwptr[0], env->regwptr[1],
env->regwptr[2], env->regwptr[3],
env->regwptr[4], env->regwptr[5]);
else if (bsd_type == target_netbsd)
ret = do_netbsd_syscall(env, syscall_nr,
env->regwptr[0], env->regwptr[1],
env->regwptr[2], env->regwptr[3],
env->regwptr[4], env->regwptr[5]);
else //if (bsd_type == target_openbsd)
ret = do_openbsd_syscall(env, syscall_nr,
env->regwptr[0], env->regwptr[1],
env->regwptr[2], env->regwptr[3],
env->regwptr[4], env->regwptr[5]);
if ((unsigned int)ret >= (unsigned int)(-515)) {
#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
env->xcc |= PSR_CARRY;
#else
env->psr |= PSR_CARRY;
#endif
} else {
#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
env->xcc &= ~PSR_CARRY;
#else
env->psr &= ~PSR_CARRY;
#endif
}
env->regwptr[0] = ret;
/* next instruction */
#if defined(TARGET_SPARC)
if (env->gregs[1] & SYSCALL_G2RFLAG) {
env->pc = env->gregs[2];
env->npc = env->pc + 4;
} else if (env->gregs[1] & SYSCALL_G7RFLAG) {
env->pc = env->gregs[7];
env->npc = env->pc + 4;
} else {
env->pc = env->npc;
env->npc = env->npc + 4;
}
#else
env->pc = env->npc;
env->npc = env->npc + 4;
#endif
break;
case 0x83: /* flush windows */
#ifdef TARGET_ABI32
case 0x103:
#endif
flush_windows(env);
/* next instruction */
env->pc = env->npc;
env->npc = env->npc + 4;
break;
#ifndef TARGET_SPARC64
case TT_WIN_OVF: /* window overflow */
save_window(env);
break;
case TT_WIN_UNF: /* window underflow */
restore_window(env);
break;
case TT_TFAULT:
case TT_DFAULT:
#if 0
{
info.si_signo = SIGSEGV;
info.si_errno = 0;
/* XXX: check env->error_code */
info.si_code = TARGET_SEGV_MAPERR;
info._sifields._sigfault._addr = env->mmuregs[4];
queue_signal(env, info.si_signo, &info);
}
#endif
break;
#else
case TT_SPILL: /* window overflow */
save_window(env);
break;
case TT_FILL: /* window underflow */
restore_window(env);
break;
case TT_TFAULT:
case TT_DFAULT:
#if 0
{
info.si_signo = SIGSEGV;
info.si_errno = 0;
/* XXX: check env->error_code */
info.si_code = TARGET_SEGV_MAPERR;
if (trapnr == TT_DFAULT)
info._sifields._sigfault._addr = env->dmmuregs[4];
else
info._sifields._sigfault._addr = env->tsptr->tpc;
//queue_signal(env, info.si_signo, &info);
}
#endif
break;
#endif
case EXCP_INTERRUPT:
/* just indicate that signals should be handled asap */
break;
case EXCP_DEBUG:
{
int sig;
sig = gdb_handlesig (env, TARGET_SIGTRAP);
#if 0
if (sig)
{
info.si_signo = sig;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
//queue_signal(env, info.si_signo, &info);
}
#endif
}
break;
default:
printf ("Unhandled trap: 0x%x\n", trapnr);
cpu_dump_state(env, stderr, fprintf, 0);
exit (1);
}
process_pending_signals (env);
}
}
#endif
static void usage(void)
{
printf("qemu-" TARGET_ARCH " version " QEMU_VERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n"
"usage: qemu-" TARGET_ARCH " [options] program [arguments...]\n"
"BSD CPU emulator (compiled for %s emulation)\n"
"\n"
"Standard options:\n"
"-h print this help\n"
"-g port wait gdb connection to port\n"
"-L path set the elf interpreter prefix (default=%s)\n"
"-s size set the stack size in bytes (default=%ld)\n"
"-cpu model select CPU (-cpu ? for list)\n"
"-drop-ld-preload drop LD_PRELOAD for target process\n"
"-bsd type select emulated BSD type FreeBSD/NetBSD/OpenBSD (default)\n"
"\n"
"Debug options:\n"
"-d options activate log (logfile=%s)\n"
"-p pagesize set the host page size to 'pagesize'\n"
"-strace log system calls\n"
"\n"
"Environment variables:\n"
"QEMU_STRACE Print system calls and arguments similar to the\n"
" 'strace' program. Enable by setting to any value.\n"
,
TARGET_ARCH,
interp_prefix,
x86_stack_size,
DEBUG_LOGFILE);
_exit(1);
}
THREAD CPUState *thread_env;
/* Assumes contents are already zeroed. */
void init_task_state(TaskState *ts)
{
int i;
ts->used = 1;
ts->first_free = ts->sigqueue_table;
for (i = 0; i < MAX_SIGQUEUE_SIZE - 1; i++) {
ts->sigqueue_table[i].next = &ts->sigqueue_table[i + 1];
}
ts->sigqueue_table[i].next = NULL;
}
int main(int argc, char **argv)
{
const char *filename;
const char *cpu_model;
struct target_pt_regs regs1, *regs = &regs1;
struct image_info info1, *info = &info1;
TaskState ts1, *ts = &ts1;
CPUState *env;
int optind;
const char *r;
int gdbstub_port = 0;
int drop_ld_preload = 0, environ_count = 0;
char **target_environ, **wrk, **dst;
enum BSDType bsd_type = target_openbsd;
if (argc <= 1)
usage();
/* init debug */
cpu_set_log_filename(DEBUG_LOGFILE);
cpu_model = NULL;
optind = 1;
for(;;) {
if (optind >= argc)
break;
r = argv[optind];
if (r[0] != '-')
break;
optind++;
r++;
if (!strcmp(r, "-")) {
break;
} else if (!strcmp(r, "d")) {
int mask;
const CPULogItem *item;
if (optind >= argc)
break;
r = argv[optind++];
mask = cpu_str_to_log_mask(r);
if (!mask) {
printf("Log items (comma separated):\n");
for(item = cpu_log_items; item->mask != 0; item++) {
printf("%-10s %s\n", item->name, item->help);
}
exit(1);
}
cpu_set_log(mask);
} else if (!strcmp(r, "s")) {
r = argv[optind++];
x86_stack_size = strtol(r, (char **)&r, 0);
if (x86_stack_size <= 0)
usage();
if (*r == 'M')
x86_stack_size *= 1024 * 1024;
else if (*r == 'k' || *r == 'K')
x86_stack_size *= 1024;
} else if (!strcmp(r, "L")) {
interp_prefix = argv[optind++];
} else if (!strcmp(r, "p")) {
qemu_host_page_size = atoi(argv[optind++]);
if (qemu_host_page_size == 0 ||
(qemu_host_page_size & (qemu_host_page_size - 1)) != 0) {
fprintf(stderr, "page size must be a power of two\n");
exit(1);
}
} else if (!strcmp(r, "g")) {
gdbstub_port = atoi(argv[optind++]);
} else if (!strcmp(r, "r")) {
qemu_uname_release = argv[optind++];
} else if (!strcmp(r, "cpu")) {
cpu_model = argv[optind++];
if (strcmp(cpu_model, "?") == 0) {
/* XXX: implement xxx_cpu_list for targets that still miss it */
#if defined(cpu_list)
cpu_list(stdout, &fprintf);
#endif
_exit(1);
}
} else if (!strcmp(r, "drop-ld-preload")) {
drop_ld_preload = 1;
} else if (!strcmp(r, "bsd")) {
if (!strcasecmp(argv[optind], "freebsd")) {
bsd_type = target_freebsd;
} else if (!strcasecmp(argv[optind], "netbsd")) {
bsd_type = target_netbsd;
} else if (!strcasecmp(argv[optind], "openbsd")) {
bsd_type = target_openbsd;
} else {
usage();
}
optind++;
} else if (!strcmp(r, "strace")) {
do_strace = 1;
} else
{
usage();
}
}
if (optind >= argc)
usage();
filename = argv[optind];
/* Zero out regs */
memset(regs, 0, sizeof(struct target_pt_regs));
/* Zero out image_info */
memset(info, 0, sizeof(struct image_info));
/* Scan interp_prefix dir for replacement files. */
init_paths(interp_prefix);
if (cpu_model == NULL) {
#if defined(TARGET_SPARC)
#ifdef TARGET_SPARC64
cpu_model = "TI UltraSparc II";
#else
cpu_model = "Fujitsu MB86904";
#endif
#else
cpu_model = "any";
#endif
}
cpu_exec_init_all(0);
/* NOTE: we need to init the CPU at this stage to get
qemu_host_page_size */
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
thread_env = env;
if (getenv("QEMU_STRACE")) {
do_strace = 1;
}
wrk = environ;
while (*(wrk++))
environ_count++;
target_environ = malloc((environ_count + 1) * sizeof(char *));
if (!target_environ)
abort();
for (wrk = environ, dst = target_environ; *wrk; wrk++) {
if (drop_ld_preload && !strncmp(*wrk, "LD_PRELOAD=", 11))
continue;
*(dst++) = strdup(*wrk);
}
*dst = NULL; /* NULL terminate target_environ */
if (loader_exec(filename, argv+optind, target_environ, regs, info) != 0) {
printf("Error loading %s\n", filename);
_exit(1);
}
for (wrk = target_environ; *wrk; wrk++) {
free(*wrk);
}
free(target_environ);
if (loglevel) {
page_dump(logfile);
fprintf(logfile, "start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
fprintf(logfile, "end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code);
fprintf(logfile, "start_code 0x" TARGET_ABI_FMT_lx "\n",
info->start_code);
fprintf(logfile, "start_data 0x" TARGET_ABI_FMT_lx "\n",
info->start_data);
fprintf(logfile, "end_data 0x" TARGET_ABI_FMT_lx "\n", info->end_data);
fprintf(logfile, "start_stack 0x" TARGET_ABI_FMT_lx "\n",
info->start_stack);
fprintf(logfile, "brk 0x" TARGET_ABI_FMT_lx "\n", info->brk);
fprintf(logfile, "entry 0x" TARGET_ABI_FMT_lx "\n", info->entry);
}
target_set_brk(info->brk);
syscall_init();
signal_init();
/* build Task State */
memset(ts, 0, sizeof(TaskState));
init_task_state(ts);
ts->info = info;
env->opaque = ts;
env->user_mode_only = 1;
#if defined(TARGET_SPARC)
{
int i;
env->pc = regs->pc;
env->npc = regs->npc;
env->y = regs->y;
for(i = 0; i < 8; i++)
env->gregs[i] = regs->u_regs[i];
for(i = 0; i < 8; i++)
env->regwptr[i] = regs->u_regs[i + 8];
}
#else
#error unsupported target CPU
#endif
if (gdbstub_port) {
gdbserver_start (gdbstub_port);
gdb_handlesig(env, 0);
}
cpu_loop(env, bsd_type);
/* never exits */
return 0;
}

545
bsd-user/mmap.c Normal file
View File

@ -0,0 +1,545 @@
/*
* mmap support for qemu
*
* Copyright (c) 2003 - 2008 Fabrice Bellard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/mman.h>
#include "qemu.h"
#include "qemu-common.h"
//#define DEBUG_MMAP
#if defined(USE_NPTL)
pthread_mutex_t mmap_mutex;
static int __thread mmap_lock_count;
void mmap_lock(void)
{
if (mmap_lock_count++ == 0) {
pthread_mutex_lock(&mmap_mutex);
}
}
void mmap_unlock(void)
{
if (--mmap_lock_count == 0) {
pthread_mutex_unlock(&mmap_mutex);
}
}
/* Grab lock to make sure things are in a consistent state after fork(). */
void mmap_fork_start(void)
{
if (mmap_lock_count)
abort();
pthread_mutex_lock(&mmap_mutex);
}
void mmap_fork_end(int child)
{
if (child)
pthread_mutex_init(&mmap_mutex, NULL);
else
pthread_mutex_unlock(&mmap_mutex);
}
#else
/* We aren't threadsafe to start with, so no need to worry about locking. */
void mmap_lock(void)
{
}
void mmap_unlock(void)
{
}
#endif
void *qemu_vmalloc(size_t size)
{
void *p;
unsigned long addr;
mmap_lock();
/* Use map and mark the pages as used. */
p = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
addr = (unsigned long)p;
if (addr == (target_ulong) addr) {
/* Allocated region overlaps guest address space.
This may recurse. */
page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size),
PAGE_RESERVED);
}
mmap_unlock();
return p;
}
void *qemu_malloc(size_t size)
{
char * p;
size += 16;
p = qemu_vmalloc(size);
*(size_t *)p = size;
return p + 16;
}
/* We use map, which is always zero initialized. */
void * qemu_mallocz(size_t size)
{
return qemu_malloc(size);
}
void qemu_free(void *ptr)
{
/* FIXME: We should unmark the reserved pages here. However this gets
complicated when one target page spans multiple host pages, so we
don't bother. */
size_t *p;
p = (size_t *)((char *)ptr - 16);
munmap(p, *p);
}
/* NOTE: all the constants are the HOST ones, but addresses are target. */
int target_mprotect(abi_ulong start, abi_ulong len, int prot)
{
abi_ulong end, host_start, host_end, addr;
int prot1, ret;
#ifdef DEBUG_MMAP
printf("mprotect: start=0x" TARGET_FMT_lx
" len=0x" TARGET_FMT_lx " prot=%c%c%c\n", start, len,
prot & PROT_READ ? 'r' : '-',
prot & PROT_WRITE ? 'w' : '-',
prot & PROT_EXEC ? 'x' : '-');
#endif
if ((start & ~TARGET_PAGE_MASK) != 0)
return -EINVAL;
len = TARGET_PAGE_ALIGN(len);
end = start + len;
if (end < start)
return -EINVAL;
prot &= PROT_READ | PROT_WRITE | PROT_EXEC;
if (len == 0)
return 0;
mmap_lock();
host_start = start & qemu_host_page_mask;
host_end = HOST_PAGE_ALIGN(end);
if (start > host_start) {
/* handle host page containing start */
prot1 = prot;
for(addr = host_start; addr < start; addr += TARGET_PAGE_SIZE) {
prot1 |= page_get_flags(addr);
}
if (host_end == host_start + qemu_host_page_size) {
for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {
prot1 |= page_get_flags(addr);
}
end = host_end;
}
ret = mprotect(g2h(host_start), qemu_host_page_size, prot1 & PAGE_BITS);
if (ret != 0)
goto error;
host_start += qemu_host_page_size;
}
if (end < host_end) {
prot1 = prot;
for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {
prot1 |= page_get_flags(addr);
}
ret = mprotect(g2h(host_end - qemu_host_page_size), qemu_host_page_size,
prot1 & PAGE_BITS);
if (ret != 0)
goto error;
host_end -= qemu_host_page_size;
}
/* handle the pages in the middle */
if (host_start < host_end) {
ret = mprotect(g2h(host_start), host_end - host_start, prot);
if (ret != 0)
goto error;
}
page_set_flags(start, start + len, prot | PAGE_VALID);
mmap_unlock();
return 0;
error:
mmap_unlock();
return ret;
}
/* map an incomplete host page */
static int mmap_frag(abi_ulong real_start,
abi_ulong start, abi_ulong end,
int prot, int flags, int fd, abi_ulong offset)
{
abi_ulong real_end, addr;
void *host_start;
int prot1, prot_new;
real_end = real_start + qemu_host_page_size;
host_start = g2h(real_start);
/* get the protection of the target pages outside the mapping */
prot1 = 0;
for(addr = real_start; addr < real_end; addr++) {
if (addr < start || addr >= end)
prot1 |= page_get_flags(addr);
}
if (prot1 == 0) {
/* no page was there, so we allocate one */
void *p = mmap(host_start, qemu_host_page_size, prot,
flags | MAP_ANON, -1, 0);
if (p == MAP_FAILED)
return -1;
prot1 = prot;
}
prot1 &= PAGE_BITS;
prot_new = prot | prot1;
if (!(flags & MAP_ANON)) {
/* msync() won't work here, so we return an error if write is
possible while it is a shared mapping */
if ((flags & MAP_FLAGMASK) == MAP_SHARED &&
(prot & PROT_WRITE))
return -EINVAL;
/* adjust protection to be able to read */
if (!(prot1 & PROT_WRITE))
mprotect(host_start, qemu_host_page_size, prot1 | PROT_WRITE);
/* read the corresponding file data */
pread(fd, g2h(start), end - start, offset);
/* put final protection */
if (prot_new != (prot1 | PROT_WRITE))
mprotect(host_start, qemu_host_page_size, prot_new);
} else {
/* just update the protection */
if (prot_new != prot1) {
mprotect(host_start, qemu_host_page_size, prot_new);
}
}
return 0;
}
#if defined(__CYGWIN__)
/* Cygwin doesn't have a whole lot of address space. */
static abi_ulong mmap_next_start = 0x18000000;
#else
static abi_ulong mmap_next_start = 0x40000000;
#endif
unsigned long last_brk;
/* find a free memory area of size 'size'. The search starts at
'start'. If 'start' == 0, then a default start address is used.
Return -1 if error.
*/
/* page_init() marks pages used by the host as reserved to be sure not
to use them. */
static abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
{
abi_ulong addr, addr1, addr_start;
int prot;
unsigned long new_brk;
new_brk = (unsigned long)sbrk(0);
if (last_brk && last_brk < new_brk && last_brk == (target_ulong)last_brk) {
/* This is a hack to catch the host allocating memory with brk().
If it uses mmap then we loose.
FIXME: We really want to avoid the host allocating memory in
the first place, and maybe leave some slack to avoid switching
to mmap. */
page_set_flags(last_brk & TARGET_PAGE_MASK,
TARGET_PAGE_ALIGN(new_brk),
PAGE_RESERVED);
}
last_brk = new_brk;
size = HOST_PAGE_ALIGN(size);
start = start & qemu_host_page_mask;
addr = start;
if (addr == 0)
addr = mmap_next_start;
addr_start = addr;
for(;;) {
prot = 0;
for(addr1 = addr; addr1 < (addr + size); addr1 += TARGET_PAGE_SIZE) {
prot |= page_get_flags(addr1);
}
if (prot == 0)
break;
addr += qemu_host_page_size;
/* we found nothing */
if (addr == addr_start)
return (abi_ulong)-1;
}
if (start == 0)
mmap_next_start = addr + size;
return addr;
}
/* NOTE: all the constants are the HOST ones */
abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
int flags, int fd, abi_ulong offset)
{
abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len;
unsigned long host_start;
mmap_lock();
#ifdef DEBUG_MMAP
{
printf("mmap: start=0x" TARGET_FMT_lx
" len=0x" TARGET_FMT_lx " prot=%c%c%c flags=",
start, len,
prot & PROT_READ ? 'r' : '-',
prot & PROT_WRITE ? 'w' : '-',
prot & PROT_EXEC ? 'x' : '-');
if (flags & MAP_FIXED)
printf("MAP_FIXED ");
if (flags & MAP_ANON)
printf("MAP_ANON ");
switch(flags & MAP_FLAGMASK) {
case MAP_PRIVATE:
printf("MAP_PRIVATE ");
break;
case MAP_SHARED:
printf("MAP_SHARED ");
break;
default:
printf("[MAP_FLAGMASK=0x%x] ", flags & MAP_FLAGMASK);
break;
}
printf("fd=%d offset=" TARGET_FMT_lx "\n", fd, offset);
}
#endif
if (offset & ~TARGET_PAGE_MASK) {
errno = EINVAL;
goto fail;
}
len = TARGET_PAGE_ALIGN(len);
if (len == 0)
goto the_end;
real_start = start & qemu_host_page_mask;
if (!(flags & MAP_FIXED)) {
abi_ulong mmap_start;
void *p;
host_offset = offset & qemu_host_page_mask;
host_len = len + offset - host_offset;
host_len = HOST_PAGE_ALIGN(host_len);
mmap_start = mmap_find_vma(real_start, host_len);
if (mmap_start == (abi_ulong)-1) {
errno = ENOMEM;
goto fail;
}
/* Note: we prefer to control the mapping address. It is
especially important if qemu_host_page_size >
qemu_real_host_page_size */
p = mmap(g2h(mmap_start),
host_len, prot, flags | MAP_FIXED, fd, host_offset);
if (p == MAP_FAILED)
goto fail;
/* update start so that it points to the file position at 'offset' */
host_start = (unsigned long)p;
if (!(flags & MAP_ANON))
host_start += offset - host_offset;
start = h2g(host_start);
} else {
int flg;
target_ulong addr;
if (start & ~TARGET_PAGE_MASK) {
errno = EINVAL;
goto fail;
}
end = start + len;
real_end = HOST_PAGE_ALIGN(end);
for(addr = real_start; addr < real_end; addr += TARGET_PAGE_SIZE) {
flg = page_get_flags(addr);
if (flg & PAGE_RESERVED) {
errno = ENXIO;
goto fail;
}
}
/* worst case: we cannot map the file because the offset is not
aligned, so we read it */
if (!(flags & MAP_ANON) &&
(offset & ~qemu_host_page_mask) != (start & ~qemu_host_page_mask)) {
/* msync() won't work here, so we return an error if write is
possible while it is a shared mapping */
if ((flags & MAP_FLAGMASK) == MAP_SHARED &&
(prot & PROT_WRITE)) {
errno = EINVAL;
goto fail;
}
retaddr = target_mmap(start, len, prot | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE | MAP_ANON,
-1, 0);
if (retaddr == -1)
goto fail;
pread(fd, g2h(start), len, offset);
if (!(prot & PROT_WRITE)) {
ret = target_mprotect(start, len, prot);
if (ret != 0) {
start = ret;
goto the_end;
}
}
goto the_end;
}
/* handle the start of the mapping */
if (start > real_start) {
if (real_end == real_start + qemu_host_page_size) {
/* one single host page */
ret = mmap_frag(real_start, start, end,
prot, flags, fd, offset);
if (ret == -1)
goto fail;
goto the_end1;
}
ret = mmap_frag(real_start, start, real_start + qemu_host_page_size,
prot, flags, fd, offset);
if (ret == -1)
goto fail;
real_start += qemu_host_page_size;
}
/* handle the end of the mapping */
if (end < real_end) {
ret = mmap_frag(real_end - qemu_host_page_size,
real_end - qemu_host_page_size, real_end,
prot, flags, fd,
offset + real_end - qemu_host_page_size - start);
if (ret == -1)
goto fail;
real_end -= qemu_host_page_size;
}
/* map the middle (easier) */
if (real_start < real_end) {
void *p;
unsigned long offset1;
if (flags & MAP_ANON)
offset1 = 0;
else
offset1 = offset + real_start - start;
p = mmap(g2h(real_start), real_end - real_start,
prot, flags, fd, offset1);
if (p == MAP_FAILED)
goto fail;
}
}
the_end1:
page_set_flags(start, start + len, prot | PAGE_VALID);
the_end:
#ifdef DEBUG_MMAP
printf("ret=0x" TARGET_FMT_lx "\n", start);
page_dump(stdout);
printf("\n");
#endif
mmap_unlock();
return start;
fail:
mmap_unlock();
return -1;
}
int target_munmap(abi_ulong start, abi_ulong len)
{
abi_ulong end, real_start, real_end, addr;
int prot, ret;
#ifdef DEBUG_MMAP
printf("munmap: start=0x%lx len=0x%lx\n", start, len);
#endif
if (start & ~TARGET_PAGE_MASK)
return -EINVAL;
len = TARGET_PAGE_ALIGN(len);
if (len == 0)
return -EINVAL;
mmap_lock();
end = start + len;
real_start = start & qemu_host_page_mask;
real_end = HOST_PAGE_ALIGN(end);
if (start > real_start) {
/* handle host page containing start */
prot = 0;
for(addr = real_start; addr < start; addr += TARGET_PAGE_SIZE) {
prot |= page_get_flags(addr);
}
if (real_end == real_start + qemu_host_page_size) {
for(addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) {
prot |= page_get_flags(addr);
}
end = real_end;
}
if (prot != 0)
real_start += qemu_host_page_size;
}
if (end < real_end) {
prot = 0;
for(addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) {
prot |= page_get_flags(addr);
}
if (prot != 0)
real_end -= qemu_host_page_size;
}
ret = 0;
/* unmap what we can */
if (real_start < real_end) {
ret = munmap(g2h(real_start), real_end - real_start);
}
if (ret == 0)
page_set_flags(start, start + len, 0);
mmap_unlock();
return ret;
}
int target_msync(abi_ulong start, abi_ulong len, int flags)
{
abi_ulong end;
if (start & ~TARGET_PAGE_MASK)
return -EINVAL;
len = TARGET_PAGE_ALIGN(len);
end = start + len;
if (end < start)
return -EINVAL;
if (end == start)
return 0;
start &= qemu_host_page_mask;
return msync(g2h(start), end - start, flags);
}

145
bsd-user/netbsd/strace.list Normal file
View File

@ -0,0 +1,145 @@
{ TARGET_NETBSD_NR___getcwd, "__getcwd", NULL, NULL, NULL },
{ TARGET_NETBSD_NR___syscall, "__syscall", NULL, NULL, NULL },
{ TARGET_NETBSD_NR___sysctl, "__sysctl", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_accept, "accept", "%s(%d,%#x,%#x)", NULL, NULL },
{ TARGET_NETBSD_NR_access, "access", "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_NETBSD_NR_acct, "acct", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_adjtime, "adjtime", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_bind, "bind", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_break, "break", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_chdir, "chdir", "%s(\"%s\")", NULL, NULL },
{ TARGET_NETBSD_NR_chflags, "chflags", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_chmod, "chmod", "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_NETBSD_NR_chown, "chown", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_chroot, "chroot", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_clock_getres, "clock_getres", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_clock_gettime, "clock_gettime", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_clock_settime, "clock_settime", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_close, "close", "%s(%d)", NULL, NULL },
{ TARGET_NETBSD_NR_connect, "connect", "%s(%d,%#x,%d)", NULL, NULL },
{ TARGET_NETBSD_NR_dup, "dup", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_dup2, "dup2", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_execve, "execve", NULL, print_execve, NULL },
{ TARGET_NETBSD_NR_exit, "exit", "%s(%d)\n", NULL, NULL },
{ TARGET_NETBSD_NR_fchdir, "fchdir", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_fchflags, "fchflags", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_fchmod, "fchmod", "%s(%d,%#o)", NULL, NULL },
{ TARGET_NETBSD_NR_fchown, "fchown", "%s(\"%s\",%d,%d)", NULL, NULL },
{ TARGET_NETBSD_NR_fcntl, "fcntl", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_flock, "flock", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_fork, "fork", "%s()", NULL, NULL },
{ TARGET_NETBSD_NR_fpathconf, "fpathconf", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_fsync, "fsync", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_ftruncate, "ftruncate", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_futimes, "futimes", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_getegid, "getegid", "%s()", NULL, NULL },
{ TARGET_NETBSD_NR_geteuid, "geteuid", "%s()", NULL, NULL },
{ TARGET_NETBSD_NR_getgid, "getgid", "%s()", NULL, NULL },
{ TARGET_NETBSD_NR_getgroups, "getgroups", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_getitimer, "getitimer", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_getpeername, "getpeername", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_getpgid, "getpgid", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_getpgrp, "getpgrp", "%s()", NULL, NULL },
{ TARGET_NETBSD_NR_getpid, "getpid", "%s()", NULL, NULL },
{ TARGET_NETBSD_NR_getppid, "getppid", "%s()", NULL, NULL },
{ TARGET_NETBSD_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL },
{ TARGET_NETBSD_NR_getrlimit, "getrlimit", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_getrusage, "getrusage", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_getsid, "getsid", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_getsockname, "getsockname", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_getsockopt, "getsockopt", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_gettimeofday, "gettimeofday", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_getuid, "getuid", "%s()", NULL, NULL },
{ TARGET_NETBSD_NR_ioctl, "ioctl", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_issetugid, "issetugid", "%s()", NULL, NULL },
{ TARGET_NETBSD_NR_kevent, "kevent", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_kill, "kill", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_kqueue, "kqueue", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_ktrace, "ktrace", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_lchown, "lchown", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_lfs_bmapv, "lfs_bmapv", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_lfs_markv, "lfs_markv", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_lfs_segclean, "lfs_segclean", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_lfs_segwait, "lfs_segwait", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_link, "link", "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_NETBSD_NR_listen, "listen", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_lseek, "lseek", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_madvise, "madvise", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_mincore, "mincore", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_minherit, "minherit", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_mkdir, "mkdir", "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_NETBSD_NR_mkfifo, "mkfifo", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_mknod, "mknod", "%s(\"%s\",%#o,%#x)", NULL, NULL },
{ TARGET_NETBSD_NR_mlock, "mlock", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_mlockall, "mlockall", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_mmap, "mmap", NULL, NULL, print_syscall_ret_addr },
{ TARGET_NETBSD_NR_mprotect, "mprotect", "%s(%#x,%#x,%d)", NULL, NULL },
{ TARGET_NETBSD_NR_msgget, "msgget", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_msgrcv, "msgrcv", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_msgsnd, "msgsnd", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_munlock, "munlock", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_munlockall, "munlockall", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_munmap, "munmap", "%s(%p,%d)", NULL, NULL },
{ TARGET_NETBSD_NR_nanosleep, "nanosleep", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_nfssvc, "nfssvc", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_open, "open", "%s(\"%s\",%#x,%#o)", NULL, NULL },
{ TARGET_NETBSD_NR_pathconf, "pathconf", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_pipe, "pipe", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_poll, "poll", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_pread, "pread", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_preadv, "preadv", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_profil, "profil", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_ptrace, "ptrace", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_pwrite, "pwrite", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_pwritev, "pwritev", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_quotactl, "quotactl", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_read, "read", "%s(%d,%#x,%d)", NULL, NULL },
{ TARGET_NETBSD_NR_readlink, "readlink", "%s(\"%s\",%p,%d)", NULL, NULL },
{ TARGET_NETBSD_NR_readv, "readv", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_reboot, "reboot", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_recvfrom, "recvfrom", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_recvmsg, "recvmsg", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_rename, "rename", "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_NETBSD_NR_revoke, "revoke", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_rmdir, "rmdir", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_sbrk, "sbrk", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_sched_yield, "sched_yield", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_select, "select", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_semget, "semget", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_semop, "semop", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_sendmsg, "sendmsg", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_sendto, "sendto", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_setegid, "setegid", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_seteuid, "seteuid", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_setgid, "setgid", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_setgroups, "setgroups", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_setitimer, "setitimer", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_setpgid, "setpgid", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_setpriority, "setpriority", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_setregid, "setregid", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_setreuid, "setreuid", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_setrlimit, "setrlimit", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_setsid, "setsid", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_setsockopt, "setsockopt", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_settimeofday, "settimeofday", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_setuid, "setuid", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_shmat, "shmat", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_shmdt, "shmdt", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_shmget, "shmget", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_shutdown, "shutdown", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_socketpair, "socketpair", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_sstk, "sstk", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_swapctl, "swapctl", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_symlink, "symlink", "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_NETBSD_NR_sync, "sync", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_sysarch, "sysarch", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_syscall, "syscall", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_truncate, "truncate", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_umask, "umask", "%s(%#o)", NULL, NULL },
{ TARGET_NETBSD_NR_unlink, "unlink", "%s(\"%s\")", NULL, NULL },
{ TARGET_NETBSD_NR_unmount, "unmount", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_utimes, "utimes", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_vfork, "vfork", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_wait4, "wait4", NULL, NULL, NULL },
{ TARGET_NETBSD_NR_write, "write", "%s(%d,%#x,%d)", NULL, NULL },
{ TARGET_NETBSD_NR_writev, "writev", "%s(%d,%p,%#x)", NULL, NULL },

View File

@ -0,0 +1,373 @@
/* $NetBSD: syscall.h,v 1.215 2008/06/17 16:07:57 tsutsui Exp $ */
/*
* System call numbers.
*
* created from NetBSD: syscalls.master,v 1.204 2008/06/17 16:05:23 tsutsui Exp
*/
#define TARGET_NETBSD_NR_syscall 0
#define TARGET_NETBSD_NR_exit 1
#define TARGET_NETBSD_NR_fork 2
#define TARGET_NETBSD_NR_read 3
#define TARGET_NETBSD_NR_write 4
#define TARGET_NETBSD_NR_open 5
#define TARGET_NETBSD_NR_close 6
#define TARGET_NETBSD_NR_wait4 7
#define TARGET_NETBSD_NR_compat_43_ocreat 8
#define TARGET_NETBSD_NR_link 9
#define TARGET_NETBSD_NR_unlink 10
#define TARGET_NETBSD_NR_chdir 12
#define TARGET_NETBSD_NR_fchdir 13
#define TARGET_NETBSD_NR_mknod 14
#define TARGET_NETBSD_NR_chmod 15
#define TARGET_NETBSD_NR_chown 16
#define TARGET_NETBSD_NR_break 17
#define TARGET_NETBSD_NR_compat_20_getfsstat 18
#define TARGET_NETBSD_NR_compat_43_olseek 19
#define TARGET_NETBSD_NR_getpid 20
#define TARGET_NETBSD_NR_getpid 20
#define TARGET_NETBSD_NR_compat_40_mount 21
#define TARGET_NETBSD_NR_unmount 22
#define TARGET_NETBSD_NR_setuid 23
#define TARGET_NETBSD_NR_getuid 24
#define TARGET_NETBSD_NR_getuid 24
#define TARGET_NETBSD_NR_geteuid 25
#define TARGET_NETBSD_NR_ptrace 26
#define TARGET_NETBSD_NR_recvmsg 27
#define TARGET_NETBSD_NR_sendmsg 28
#define TARGET_NETBSD_NR_recvfrom 29
#define TARGET_NETBSD_NR_accept 30
#define TARGET_NETBSD_NR_getpeername 31
#define TARGET_NETBSD_NR_getsockname 32
#define TARGET_NETBSD_NR_access 33
#define TARGET_NETBSD_NR_chflags 34
#define TARGET_NETBSD_NR_fchflags 35
#define TARGET_NETBSD_NR_sync 36
#define TARGET_NETBSD_NR_kill 37
#define TARGET_NETBSD_NR_compat_43_stat43 38
#define TARGET_NETBSD_NR_getppid 39
#define TARGET_NETBSD_NR_compat_43_lstat43 40
#define TARGET_NETBSD_NR_dup 41
#define TARGET_NETBSD_NR_pipe 42
#define TARGET_NETBSD_NR_getegid 43
#define TARGET_NETBSD_NR_profil 44
#define TARGET_NETBSD_NR_ktrace 45
#define TARGET_NETBSD_NR_compat_13_sigaction13 46
#define TARGET_NETBSD_NR_getgid 47
#define TARGET_NETBSD_NR_getgid 47
#define TARGET_NETBSD_NR_compat_13_sigprocmask13 48
#define TARGET_NETBSD_NR___getlogin 49
#define TARGET_NETBSD_NR___setlogin 50
#define TARGET_NETBSD_NR_acct 51
#define TARGET_NETBSD_NR_compat_13_sigpending13 52
#define TARGET_NETBSD_NR_compat_13_sigaltstack13 53
#define TARGET_NETBSD_NR_ioctl 54
#define TARGET_NETBSD_NR_compat_12_oreboot 55
#define TARGET_NETBSD_NR_revoke 56
#define TARGET_NETBSD_NR_symlink 57
#define TARGET_NETBSD_NR_readlink 58
#define TARGET_NETBSD_NR_execve 59
#define TARGET_NETBSD_NR_umask 60
#define TARGET_NETBSD_NR_chroot 61
#define TARGET_NETBSD_NR_compat_43_fstat43 62
#define TARGET_NETBSD_NR_compat_43_ogetkerninfo 63
#define TARGET_NETBSD_NR_compat_43_ogetpagesize 64
#define TARGET_NETBSD_NR_compat_12_msync 65
#define TARGET_NETBSD_NR_vfork 66
#define TARGET_NETBSD_NR_sbrk 69
#define TARGET_NETBSD_NR_sstk 70
#define TARGET_NETBSD_NR_compat_43_ommap 71
#define TARGET_NETBSD_NR_vadvise 72
#define TARGET_NETBSD_NR_munmap 73
#define TARGET_NETBSD_NR_mprotect 74
#define TARGET_NETBSD_NR_madvise 75
#define TARGET_NETBSD_NR_mincore 78
#define TARGET_NETBSD_NR_getgroups 79
#define TARGET_NETBSD_NR_setgroups 80
#define TARGET_NETBSD_NR_getpgrp 81
#define TARGET_NETBSD_NR_setpgid 82
#define TARGET_NETBSD_NR_setitimer 83
#define TARGET_NETBSD_NR_compat_43_owait 84
#define TARGET_NETBSD_NR_compat_12_oswapon 85
#define TARGET_NETBSD_NR_getitimer 86
#define TARGET_NETBSD_NR_compat_43_ogethostname 87
#define TARGET_NETBSD_NR_compat_43_osethostname 88
#define TARGET_NETBSD_NR_compat_43_ogetdtablesize 89
#define TARGET_NETBSD_NR_dup2 90
#define TARGET_NETBSD_NR_fcntl 92
#define TARGET_NETBSD_NR_select 93
#define TARGET_NETBSD_NR_fsync 95
#define TARGET_NETBSD_NR_setpriority 96
#define TARGET_NETBSD_NR_compat_30_socket 97
#define TARGET_NETBSD_NR_connect 98
#define TARGET_NETBSD_NR_compat_43_oaccept 99
#define TARGET_NETBSD_NR_getpriority 100
#define TARGET_NETBSD_NR_compat_43_osend 101
#define TARGET_NETBSD_NR_compat_43_orecv 102
#define TARGET_NETBSD_NR_compat_13_sigreturn13 103
#define TARGET_NETBSD_NR_bind 104
#define TARGET_NETBSD_NR_setsockopt 105
#define TARGET_NETBSD_NR_listen 106
#define TARGET_NETBSD_NR_compat_43_osigvec 108
#define TARGET_NETBSD_NR_compat_43_osigblock 109
#define TARGET_NETBSD_NR_compat_43_osigsetmask 110
#define TARGET_NETBSD_NR_compat_13_sigsuspend13 111
#define TARGET_NETBSD_NR_compat_43_osigstack 112
#define TARGET_NETBSD_NR_compat_43_orecvmsg 113
#define TARGET_NETBSD_NR_compat_43_osendmsg 114
#define TARGET_NETBSD_NR_gettimeofday 116
#define TARGET_NETBSD_NR_getrusage 117
#define TARGET_NETBSD_NR_getsockopt 118
#define TARGET_NETBSD_NR_readv 120
#define TARGET_NETBSD_NR_writev 121
#define TARGET_NETBSD_NR_settimeofday 122
#define TARGET_NETBSD_NR_fchown 123
#define TARGET_NETBSD_NR_fchmod 124
#define TARGET_NETBSD_NR_compat_43_orecvfrom 125
#define TARGET_NETBSD_NR_setreuid 126
#define TARGET_NETBSD_NR_setregid 127
#define TARGET_NETBSD_NR_rename 128
#define TARGET_NETBSD_NR_compat_43_otruncate 129
#define TARGET_NETBSD_NR_compat_43_oftruncate 130
#define TARGET_NETBSD_NR_flock 131
#define TARGET_NETBSD_NR_mkfifo 132
#define TARGET_NETBSD_NR_sendto 133
#define TARGET_NETBSD_NR_shutdown 134
#define TARGET_NETBSD_NR_socketpair 135
#define TARGET_NETBSD_NR_mkdir 136
#define TARGET_NETBSD_NR_rmdir 137
#define TARGET_NETBSD_NR_utimes 138
#define TARGET_NETBSD_NR_adjtime 140
#define TARGET_NETBSD_NR_compat_43_ogetpeername 141
#define TARGET_NETBSD_NR_compat_43_ogethostid 142
#define TARGET_NETBSD_NR_compat_43_osethostid 143
#define TARGET_NETBSD_NR_compat_43_ogetrlimit 144
#define TARGET_NETBSD_NR_compat_43_osetrlimit 145
#define TARGET_NETBSD_NR_compat_43_okillpg 146
#define TARGET_NETBSD_NR_setsid 147
#define TARGET_NETBSD_NR_quotactl 148
#define TARGET_NETBSD_NR_compat_43_oquota 149
#define TARGET_NETBSD_NR_compat_43_ogetsockname 150
#define TARGET_NETBSD_NR_nfssvc 155
#define TARGET_NETBSD_NR_compat_43_ogetdirentries 156
#define TARGET_NETBSD_NR_compat_20_statfs 157
#define TARGET_NETBSD_NR_compat_20_fstatfs 158
#define TARGET_NETBSD_NR_compat_30_getfh 161
#define TARGET_NETBSD_NR_compat_09_ogetdomainname 162
#define TARGET_NETBSD_NR_compat_09_osetdomainname 163
#define TARGET_NETBSD_NR_compat_09_ouname 164
#define TARGET_NETBSD_NR_sysarch 165
#define TARGET_NETBSD_NR_compat_10_osemsys 169
#define TARGET_NETBSD_NR_compat_10_omsgsys 170
#define TARGET_NETBSD_NR_compat_10_oshmsys 171
#define TARGET_NETBSD_NR_pread 173
#define TARGET_NETBSD_NR_pwrite 174
#define TARGET_NETBSD_NR_compat_30_ntp_gettime 175
#define TARGET_NETBSD_NR_ntp_adjtime 176
#define TARGET_NETBSD_NR_setgid 181
#define TARGET_NETBSD_NR_setegid 182
#define TARGET_NETBSD_NR_seteuid 183
#define TARGET_NETBSD_NR_lfs_bmapv 184
#define TARGET_NETBSD_NR_lfs_markv 185
#define TARGET_NETBSD_NR_lfs_segclean 186
#define TARGET_NETBSD_NR_lfs_segwait 187
#define TARGET_NETBSD_NR_compat_12_stat12 188
#define TARGET_NETBSD_NR_compat_12_fstat12 189
#define TARGET_NETBSD_NR_compat_12_lstat12 190
#define TARGET_NETBSD_NR_pathconf 191
#define TARGET_NETBSD_NR_fpathconf 192
#define TARGET_NETBSD_NR_getrlimit 194
#define TARGET_NETBSD_NR_setrlimit 195
#define TARGET_NETBSD_NR_compat_12_getdirentries 196
#define TARGET_NETBSD_NR_mmap 197
#define TARGET_NETBSD_NR___syscall 198
#define TARGET_NETBSD_NR_lseek 199
#define TARGET_NETBSD_NR_truncate 200
#define TARGET_NETBSD_NR_ftruncate 201
#define TARGET_NETBSD_NR___sysctl 202
#define TARGET_NETBSD_NR_mlock 203
#define TARGET_NETBSD_NR_munlock 204
#define TARGET_NETBSD_NR_undelete 205
#define TARGET_NETBSD_NR_futimes 206
#define TARGET_NETBSD_NR_getpgid 207
#define TARGET_NETBSD_NR_reboot 208
#define TARGET_NETBSD_NR_poll 209
#define TARGET_NETBSD_NR_compat_14___semctl 220
#define TARGET_NETBSD_NR_semget 221
#define TARGET_NETBSD_NR_semop 222
#define TARGET_NETBSD_NR_semconfig 223
#define TARGET_NETBSD_NR_compat_14_msgctl 224
#define TARGET_NETBSD_NR_msgget 225
#define TARGET_NETBSD_NR_msgsnd 226
#define TARGET_NETBSD_NR_msgrcv 227
#define TARGET_NETBSD_NR_shmat 228
#define TARGET_NETBSD_NR_compat_14_shmctl 229
#define TARGET_NETBSD_NR_shmdt 230
#define TARGET_NETBSD_NR_shmget 231
#define TARGET_NETBSD_NR_clock_gettime 232
#define TARGET_NETBSD_NR_clock_settime 233
#define TARGET_NETBSD_NR_clock_getres 234
#define TARGET_NETBSD_NR_timer_create 235
#define TARGET_NETBSD_NR_timer_delete 236
#define TARGET_NETBSD_NR_timer_settime 237
#define TARGET_NETBSD_NR_timer_gettime 238
#define TARGET_NETBSD_NR_timer_getoverrun 239
#define TARGET_NETBSD_NR_nanosleep 240
#define TARGET_NETBSD_NR_fdatasync 241
#define TARGET_NETBSD_NR_mlockall 242
#define TARGET_NETBSD_NR_munlockall 243
#define TARGET_NETBSD_NR___sigtimedwait 244
#define TARGET_NETBSD_NR_modctl 246
#define TARGET_NETBSD_NR__ksem_init 247
#define TARGET_NETBSD_NR__ksem_open 248
#define TARGET_NETBSD_NR__ksem_unlink 249
#define TARGET_NETBSD_NR__ksem_close 250
#define TARGET_NETBSD_NR__ksem_post 251
#define TARGET_NETBSD_NR__ksem_wait 252
#define TARGET_NETBSD_NR__ksem_trywait 253
#define TARGET_NETBSD_NR__ksem_getvalue 254
#define TARGET_NETBSD_NR__ksem_destroy 255
#define TARGET_NETBSD_NR_mq_open 257
#define TARGET_NETBSD_NR_mq_close 258
#define TARGET_NETBSD_NR_mq_unlink 259
#define TARGET_NETBSD_NR_mq_getattr 260
#define TARGET_NETBSD_NR_mq_setattr 261
#define TARGET_NETBSD_NR_mq_notify 262
#define TARGET_NETBSD_NR_mq_send 263
#define TARGET_NETBSD_NR_mq_receive 264
#define TARGET_NETBSD_NR_mq_timedsend 265
#define TARGET_NETBSD_NR_mq_timedreceive 266
#define TARGET_NETBSD_NR___posix_rename 270
#define TARGET_NETBSD_NR_swapctl 271
#define TARGET_NETBSD_NR_compat_30_getdents 272
#define TARGET_NETBSD_NR_minherit 273
#define TARGET_NETBSD_NR_lchmod 274
#define TARGET_NETBSD_NR_lchown 275
#define TARGET_NETBSD_NR_lutimes 276
#define TARGET_NETBSD_NR___msync13 277
#define TARGET_NETBSD_NR_compat_30___stat13 278
#define TARGET_NETBSD_NR_compat_30___fstat13 279
#define TARGET_NETBSD_NR_compat_30___lstat13 280
#define TARGET_NETBSD_NR___sigaltstack14 281
#define TARGET_NETBSD_NR___vfork14 282
#define TARGET_NETBSD_NR___posix_chown 283
#define TARGET_NETBSD_NR___posix_fchown 284
#define TARGET_NETBSD_NR___posix_lchown 285
#define TARGET_NETBSD_NR_getsid 286
#define TARGET_NETBSD_NR___clone 287
#define TARGET_NETBSD_NR_fktrace 288
#define TARGET_NETBSD_NR_preadv 289
#define TARGET_NETBSD_NR_pwritev 290
#define TARGET_NETBSD_NR_compat_16___sigaction14 291
#define TARGET_NETBSD_NR___sigpending14 292
#define TARGET_NETBSD_NR___sigprocmask14 293
#define TARGET_NETBSD_NR___sigsuspend14 294
#define TARGET_NETBSD_NR_compat_16___sigreturn14 295
#define TARGET_NETBSD_NR___getcwd 296
#define TARGET_NETBSD_NR_fchroot 297
#define TARGET_NETBSD_NR_compat_30_fhopen 298
#define TARGET_NETBSD_NR_compat_30_fhstat 299
#define TARGET_NETBSD_NR_compat_20_fhstatfs 300
#define TARGET_NETBSD_NR_____semctl13 301
#define TARGET_NETBSD_NR___msgctl13 302
#define TARGET_NETBSD_NR___shmctl13 303
#define TARGET_NETBSD_NR_lchflags 304
#define TARGET_NETBSD_NR_issetugid 305
#define TARGET_NETBSD_NR_utrace 306
#define TARGET_NETBSD_NR_getcontext 307
#define TARGET_NETBSD_NR_setcontext 308
#define TARGET_NETBSD_NR__lwp_create 309
#define TARGET_NETBSD_NR__lwp_exit 310
#define TARGET_NETBSD_NR__lwp_self 311
#define TARGET_NETBSD_NR__lwp_wait 312
#define TARGET_NETBSD_NR__lwp_suspend 313
#define TARGET_NETBSD_NR__lwp_continue 314
#define TARGET_NETBSD_NR__lwp_wakeup 315
#define TARGET_NETBSD_NR__lwp_getprivate 316
#define TARGET_NETBSD_NR__lwp_setprivate 317
#define TARGET_NETBSD_NR__lwp_kill 318
#define TARGET_NETBSD_NR__lwp_detach 319
#define TARGET_NETBSD_NR__lwp_park 320
#define TARGET_NETBSD_NR__lwp_unpark 321
#define TARGET_NETBSD_NR__lwp_unpark_all 322
#define TARGET_NETBSD_NR__lwp_setname 323
#define TARGET_NETBSD_NR__lwp_getname 324
#define TARGET_NETBSD_NR__lwp_ctl 325
#define TARGET_NETBSD_NR_sa_register 330
#define TARGET_NETBSD_NR_sa_stacks 331
#define TARGET_NETBSD_NR_sa_enable 332
#define TARGET_NETBSD_NR_sa_setconcurrency 333
#define TARGET_NETBSD_NR_sa_yield 334
#define TARGET_NETBSD_NR_sa_preempt 335
#define TARGET_NETBSD_NR_sa_unblockyield 336
#define TARGET_NETBSD_NR___sigaction_sigtramp 340
#define TARGET_NETBSD_NR_pmc_get_info 341
#define TARGET_NETBSD_NR_pmc_control 342
#define TARGET_NETBSD_NR_rasctl 343
#define TARGET_NETBSD_NR_kqueue 344
#define TARGET_NETBSD_NR_kevent 345
#define TARGET_NETBSD_NR__sched_setparam 346
#define TARGET_NETBSD_NR__sched_getparam 347
#define TARGET_NETBSD_NR__sched_setaffinity 348
#define TARGET_NETBSD_NR__sched_getaffinity 349
#define TARGET_NETBSD_NR_sched_yield 350
#define TARGET_NETBSD_NR_fsync_range 354
#define TARGET_NETBSD_NR_uuidgen 355
#define TARGET_NETBSD_NR_getvfsstat 356
#define TARGET_NETBSD_NR_statvfs1 357
#define TARGET_NETBSD_NR_fstatvfs1 358
#define TARGET_NETBSD_NR_compat_30_fhstatvfs1 359
#define TARGET_NETBSD_NR_extattrctl 360
#define TARGET_NETBSD_NR_extattr_set_file 361
#define TARGET_NETBSD_NR_extattr_get_file 362
#define TARGET_NETBSD_NR_extattr_delete_file 363
#define TARGET_NETBSD_NR_extattr_set_fd 364
#define TARGET_NETBSD_NR_extattr_get_fd 365
#define TARGET_NETBSD_NR_extattr_delete_fd 366
#define TARGET_NETBSD_NR_extattr_set_link 367
#define TARGET_NETBSD_NR_extattr_get_link 368
#define TARGET_NETBSD_NR_extattr_delete_link 369
#define TARGET_NETBSD_NR_extattr_list_fd 370
#define TARGET_NETBSD_NR_extattr_list_file 371
#define TARGET_NETBSD_NR_extattr_list_link 372
#define TARGET_NETBSD_NR_pselect 373
#define TARGET_NETBSD_NR_pollts 374
#define TARGET_NETBSD_NR_setxattr 375
#define TARGET_NETBSD_NR_lsetxattr 376
#define TARGET_NETBSD_NR_fsetxattr 377
#define TARGET_NETBSD_NR_getxattr 378
#define TARGET_NETBSD_NR_lgetxattr 379
#define TARGET_NETBSD_NR_fgetxattr 380
#define TARGET_NETBSD_NR_listxattr 381
#define TARGET_NETBSD_NR_llistxattr 382
#define TARGET_NETBSD_NR_flistxattr 383
#define TARGET_NETBSD_NR_removexattr 384
#define TARGET_NETBSD_NR_lremovexattr 385
#define TARGET_NETBSD_NR_fremovexattr 386
#define TARGET_NETBSD_NR___stat30 387
#define TARGET_NETBSD_NR___fstat30 388
#define TARGET_NETBSD_NR___lstat30 389
#define TARGET_NETBSD_NR___getdents30 390
#define TARGET_NETBSD_NR_compat_30___fhstat30 392
#define TARGET_NETBSD_NR___ntp_gettime30 393
#define TARGET_NETBSD_NR___socket30 394
#define TARGET_NETBSD_NR___getfh30 395
#define TARGET_NETBSD_NR___fhopen40 396
#define TARGET_NETBSD_NR___fhstatvfs140 397
#define TARGET_NETBSD_NR___fhstat40 398
#define TARGET_NETBSD_NR_aio_cancel 399
#define TARGET_NETBSD_NR_aio_error 400
#define TARGET_NETBSD_NR_aio_fsync 401
#define TARGET_NETBSD_NR_aio_read 402
#define TARGET_NETBSD_NR_aio_return 403
#define TARGET_NETBSD_NR_aio_suspend 404
#define TARGET_NETBSD_NR_aio_write 405
#define TARGET_NETBSD_NR_lio_listio 406
#define TARGET_NETBSD_NR___mount50 410
#define TARGET_NETBSD_NR_mremap 411
#define TARGET_NETBSD_NR_pset_create 412
#define TARGET_NETBSD_NR_pset_destroy 413
#define TARGET_NETBSD_NR_pset_assign 414
#define TARGET_NETBSD_NR__pset_bind 415
#define TARGET_NETBSD_NR___posix_fadvise50 416

View File

@ -0,0 +1,187 @@
{ TARGET_OPENBSD_NR___getcwd, "__getcwd", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR___semctl, "__semctl", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR___syscall, "__syscall", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR___sysctl, "__sysctl", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_accept, "accept", "%s(%d,%#x,%#x)", NULL, NULL },
{ TARGET_OPENBSD_NR_access, "access", "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_OPENBSD_NR_acct, "acct", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_adjfreq, "adjfreq", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_adjtime, "adjtime", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_bind, "bind", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_break, "break", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_chdir, "chdir", "%s(\"%s\")", NULL, NULL },
{ TARGET_OPENBSD_NR_chflags, "chflags", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_chmod, "chmod", "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_OPENBSD_NR_chown, "chown", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_chroot, "chroot", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_clock_getres, "clock_getres", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_clock_gettime, "clock_gettime", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_clock_settime, "clock_settime", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_close, "close", "%s(%d)", NULL, NULL },
{ TARGET_OPENBSD_NR_closefrom, "closefrom", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_connect, "connect", "%s(%d,%#x,%d)", NULL, NULL },
{ TARGET_OPENBSD_NR_dup, "dup", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_dup2, "dup2", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_execve, "execve", NULL, print_execve, NULL },
{ TARGET_OPENBSD_NR_exit, "exit", "%s(%d)\n", NULL, NULL },
{ TARGET_OPENBSD_NR_fchdir, "fchdir", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_fchflags, "fchflags", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_fchmod, "fchmod", "%s(%d,%#o)", NULL, NULL },
{ TARGET_OPENBSD_NR_fchown, "fchown", "%s(\"%s\",%d,%d)", NULL, NULL },
{ TARGET_OPENBSD_NR_fcntl, "fcntl", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_fhopen, "fhopen", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_fhstat, "fhstat", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_fhstatfs, "fhstatfs", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_flock, "flock", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_fork, "fork", "%s()", NULL, NULL },
{ TARGET_OPENBSD_NR_fpathconf, "fpathconf", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_fstat, "fstat", "%s(%d,%p)", NULL, NULL },
{ TARGET_OPENBSD_NR_fstatfs, "fstatfs", "%s(%d,%p)", NULL, NULL },
{ TARGET_OPENBSD_NR_fsync, "fsync", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_ftruncate, "ftruncate", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_futimes, "futimes", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getdirentries, "getdirentries", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getegid, "getegid", "%s()", NULL, NULL },
{ TARGET_OPENBSD_NR_geteuid, "geteuid", "%s()", NULL, NULL },
{ TARGET_OPENBSD_NR_getfh, "getfh", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getfsstat, "getfsstat", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getgid, "getgid", "%s()", NULL, NULL },
{ TARGET_OPENBSD_NR_getgroups, "getgroups", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getitimer, "getitimer", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getlogin, "getlogin", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getpeereid, "getpeereid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getpeername, "getpeername", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getpgid, "getpgid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getpgrp, "getpgrp", "%s()", NULL, NULL },
{ TARGET_OPENBSD_NR_getpid, "getpid", "%s()", NULL, NULL },
{ TARGET_OPENBSD_NR_getppid, "getppid", "%s()", NULL, NULL },
{ TARGET_OPENBSD_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL },
{ TARGET_OPENBSD_NR_getresgid, "getresgid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getresuid, "getresuid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getrlimit, "getrlimit", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getrusage, "getrusage", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getsid, "getsid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getsockname, "getsockname", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getsockopt, "getsockopt", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getthrid, "getthrid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_gettimeofday, "gettimeofday", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_getuid, "getuid", "%s()", NULL, NULL },
{ TARGET_OPENBSD_NR_ioctl, "ioctl", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_issetugid, "issetugid", "%s()", NULL, NULL },
{ TARGET_OPENBSD_NR_kevent, "kevent", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_kill, "kill", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_kqueue, "kqueue", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_ktrace, "ktrace", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_lchown, "lchown", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_lfs_bmapv, "lfs_bmapv", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_lfs_markv, "lfs_markv", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_lfs_segclean, "lfs_segclean", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_lfs_segwait, "lfs_segwait", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_link, "link", "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_OPENBSD_NR_listen, "listen", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_lseek, "lseek", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_lstat, "lstat", "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_OPENBSD_NR_madvise, "madvise", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_mincore, "mincore", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_minherit, "minherit", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_mkdir, "mkdir", "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_OPENBSD_NR_mkfifo, "mkfifo", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_mknod, "mknod", "%s(\"%s\",%#o,%#x)", NULL, NULL },
{ TARGET_OPENBSD_NR_mlock, "mlock", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_mlockall, "mlockall", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_mmap, "mmap", NULL, NULL, print_syscall_ret_addr },
{ TARGET_OPENBSD_NR_mount, "mount", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_mprotect, "mprotect", "%s(%#x,%#x,%d)", NULL, NULL },
{ TARGET_OPENBSD_NR_mquery, "mquery", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_msgctl, "msgctl", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_msgget, "msgget", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_msgrcv, "msgrcv", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_msgsnd, "msgsnd", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_msync, "msync", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_munlock, "munlock", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_munlockall, "munlockall", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_munmap, "munmap", "%s(%p,%d)", NULL, NULL },
{ TARGET_OPENBSD_NR_nanosleep, "nanosleep", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_nfssvc, "nfssvc", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_open, "open", "%s(\"%s\",%#x,%#o)", NULL, NULL },
{ TARGET_OPENBSD_NR_opipe, "opipe", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_osigaltstack, "osigaltstack", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_pathconf, "pathconf", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_pipe, "pipe", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_poll, "poll", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_pread, "pread", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_preadv, "preadv", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_profil, "profil", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_ptrace, "ptrace", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_pwrite, "pwrite", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_pwritev, "pwritev", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_quotactl, "quotactl", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_read, "read", "%s(%d,%#x,%d)", NULL, NULL },
{ TARGET_OPENBSD_NR_readlink, "readlink", "%s(\"%s\",%p,%d)", NULL, NULL },
{ TARGET_OPENBSD_NR_readv, "readv", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_reboot, "reboot", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_recvfrom, "recvfrom", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_recvmsg, "recvmsg", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_rename, "rename", "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_OPENBSD_NR_revoke, "revoke", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_rfork, "rfork", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_rmdir, "rmdir", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_sbrk, "sbrk", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_sched_yield, "sched_yield", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_select, "select", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_semget, "semget", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_semop, "semop", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_sendmsg, "sendmsg", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_sendto, "sendto", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setegid, "setegid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_seteuid, "seteuid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setgid, "setgid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setgroups, "setgroups", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setitimer, "setitimer", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setlogin, "setlogin", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setpgid, "setpgid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setpriority, "setpriority", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setregid, "setregid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setresgid, "setresgid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setresuid, "setresuid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setreuid, "setreuid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setrlimit, "setrlimit", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setsid, "setsid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setsockopt, "setsockopt", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_settimeofday, "settimeofday", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_setuid, "setuid", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_shmat, "shmat", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_shmctl, "shmctl", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_shmdt, "shmdt", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_shmget, "shmget", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_shutdown, "shutdown", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_sigaction, "sigaction", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_sigaltstack, "sigaltstack", "%s(%p,%p)", NULL, NULL },
{ TARGET_OPENBSD_NR_sigpending, "sigpending", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_sigprocmask, "sigprocmask", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_sigreturn, "sigreturn", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_sigsuspend, "sigsuspend", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_socket, "socket", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_socketpair, "socketpair", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_sstk, "sstk", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_stat, "stat", "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_OPENBSD_NR_statfs, "statfs", "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_OPENBSD_NR_swapctl, "swapctl", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_symlink, "symlink", "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_OPENBSD_NR_sync, "sync", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_sysarch, "sysarch", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_syscall, "syscall", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_threxit, "threxit", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_thrsigdivert, "thrsigdivert", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_thrsleep, "thrsleep", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_thrwakeup, "thrwakeup", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_truncate, "truncate", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_umask, "umask", "%s(%#o)", NULL, NULL },
{ TARGET_OPENBSD_NR_unlink, "unlink", "%s(\"%s\")", NULL, NULL },
{ TARGET_OPENBSD_NR_unmount, "unmount", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_utimes, "utimes", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_vfork, "vfork", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_wait4, "wait4", NULL, NULL, NULL },
{ TARGET_OPENBSD_NR_write, "write", "%s(%d,%#x,%d)", NULL, NULL },
{ TARGET_OPENBSD_NR_writev, "writev", "%s(%d,%p,%#x)", NULL, NULL },
{ TARGET_OPENBSD_NR_xfspioctl, "xfspioctl", NULL, NULL, NULL },

View File

@ -0,0 +1,195 @@
/* $OpenBSD: syscall.h,v 1.101 2008/03/16 19:43:41 otto Exp $ */
/*
* System call numbers.
*
* created from; OpenBSD: syscalls.master,v 1.90 2008/03/16 19:42:57 otto Exp
*/
#define TARGET_OPENBSD_NR_syscall 0
#define TARGET_OPENBSD_NR_exit 1
#define TARGET_OPENBSD_NR_fork 2
#define TARGET_OPENBSD_NR_read 3
#define TARGET_OPENBSD_NR_write 4
#define TARGET_OPENBSD_NR_open 5
#define TARGET_OPENBSD_NR_close 6
#define TARGET_OPENBSD_NR_wait4 7
#define TARGET_OPENBSD_NR_link 9
#define TARGET_OPENBSD_NR_unlink 10
#define TARGET_OPENBSD_NR_chdir 12
#define TARGET_OPENBSD_NR_fchdir 13
#define TARGET_OPENBSD_NR_mknod 14
#define TARGET_OPENBSD_NR_chmod 15
#define TARGET_OPENBSD_NR_chown 16
#define TARGET_OPENBSD_NR_break 17
#define TARGET_OPENBSD_NR_getpid 20
#define TARGET_OPENBSD_NR_mount 21
#define TARGET_OPENBSD_NR_unmount 22
#define TARGET_OPENBSD_NR_setuid 23
#define TARGET_OPENBSD_NR_getuid 24
#define TARGET_OPENBSD_NR_geteuid 25
#define TARGET_OPENBSD_NR_ptrace 26
#define TARGET_OPENBSD_NR_recvmsg 27
#define TARGET_OPENBSD_NR_sendmsg 28
#define TARGET_OPENBSD_NR_recvfrom 29
#define TARGET_OPENBSD_NR_accept 30
#define TARGET_OPENBSD_NR_getpeername 31
#define TARGET_OPENBSD_NR_getsockname 32
#define TARGET_OPENBSD_NR_access 33
#define TARGET_OPENBSD_NR_chflags 34
#define TARGET_OPENBSD_NR_fchflags 35
#define TARGET_OPENBSD_NR_sync 36
#define TARGET_OPENBSD_NR_kill 37
#define TARGET_OPENBSD_NR_getppid 39
#define TARGET_OPENBSD_NR_dup 41
#define TARGET_OPENBSD_NR_opipe 42
#define TARGET_OPENBSD_NR_getegid 43
#define TARGET_OPENBSD_NR_profil 44
#define TARGET_OPENBSD_NR_ktrace 45
#define TARGET_OPENBSD_NR_sigaction 46
#define TARGET_OPENBSD_NR_getgid 47
#define TARGET_OPENBSD_NR_sigprocmask 48
#define TARGET_OPENBSD_NR_getlogin 49
#define TARGET_OPENBSD_NR_setlogin 50
#define TARGET_OPENBSD_NR_acct 51
#define TARGET_OPENBSD_NR_sigpending 52
#define TARGET_OPENBSD_NR_osigaltstack 53
#define TARGET_OPENBSD_NR_ioctl 54
#define TARGET_OPENBSD_NR_reboot 55
#define TARGET_OPENBSD_NR_revoke 56
#define TARGET_OPENBSD_NR_symlink 57
#define TARGET_OPENBSD_NR_readlink 58
#define TARGET_OPENBSD_NR_execve 59
#define TARGET_OPENBSD_NR_umask 60
#define TARGET_OPENBSD_NR_chroot 61
#define TARGET_OPENBSD_NR_vfork 66
#define TARGET_OPENBSD_NR_sbrk 69
#define TARGET_OPENBSD_NR_sstk 70
#define TARGET_OPENBSD_NR_munmap 73
#define TARGET_OPENBSD_NR_mprotect 74
#define TARGET_OPENBSD_NR_madvise 75
#define TARGET_OPENBSD_NR_mincore 78
#define TARGET_OPENBSD_NR_getgroups 79
#define TARGET_OPENBSD_NR_setgroups 80
#define TARGET_OPENBSD_NR_getpgrp 81
#define TARGET_OPENBSD_NR_setpgid 82
#define TARGET_OPENBSD_NR_setitimer 83
#define TARGET_OPENBSD_NR_getitimer 86
#define TARGET_OPENBSD_NR_dup2 90
#define TARGET_OPENBSD_NR_fcntl 92
#define TARGET_OPENBSD_NR_select 93
#define TARGET_OPENBSD_NR_fsync 95
#define TARGET_OPENBSD_NR_setpriority 96
#define TARGET_OPENBSD_NR_socket 97
#define TARGET_OPENBSD_NR_connect 98
#define TARGET_OPENBSD_NR_getpriority 100
#define TARGET_OPENBSD_NR_sigreturn 103
#define TARGET_OPENBSD_NR_bind 104
#define TARGET_OPENBSD_NR_setsockopt 105
#define TARGET_OPENBSD_NR_listen 106
#define TARGET_OPENBSD_NR_sigsuspend 111
#define TARGET_OPENBSD_NR_gettimeofday 116
#define TARGET_OPENBSD_NR_getrusage 117
#define TARGET_OPENBSD_NR_getsockopt 118
#define TARGET_OPENBSD_NR_readv 120
#define TARGET_OPENBSD_NR_writev 121
#define TARGET_OPENBSD_NR_settimeofday 122
#define TARGET_OPENBSD_NR_fchown 123
#define TARGET_OPENBSD_NR_fchmod 124
#define TARGET_OPENBSD_NR_setreuid 126
#define TARGET_OPENBSD_NR_setregid 127
#define TARGET_OPENBSD_NR_rename 128
#define TARGET_OPENBSD_NR_flock 131
#define TARGET_OPENBSD_NR_mkfifo 132
#define TARGET_OPENBSD_NR_sendto 133
#define TARGET_OPENBSD_NR_shutdown 134
#define TARGET_OPENBSD_NR_socketpair 135
#define TARGET_OPENBSD_NR_mkdir 136
#define TARGET_OPENBSD_NR_rmdir 137
#define TARGET_OPENBSD_NR_utimes 138
#define TARGET_OPENBSD_NR_adjtime 140
#define TARGET_OPENBSD_NR_setsid 147
#define TARGET_OPENBSD_NR_quotactl 148
#define TARGET_OPENBSD_NR_nfssvc 155
#define TARGET_OPENBSD_NR_getfh 161
#define TARGET_OPENBSD_NR_sysarch 165
#define TARGET_OPENBSD_NR_pread 173
#define TARGET_OPENBSD_NR_pwrite 174
#define TARGET_OPENBSD_NR_setgid 181
#define TARGET_OPENBSD_NR_setegid 182
#define TARGET_OPENBSD_NR_seteuid 183
#define TARGET_OPENBSD_NR_lfs_bmapv 184
#define TARGET_OPENBSD_NR_lfs_markv 185
#define TARGET_OPENBSD_NR_lfs_segclean 186
#define TARGET_OPENBSD_NR_lfs_segwait 187
#define TARGET_OPENBSD_NR_pathconf 191
#define TARGET_OPENBSD_NR_fpathconf 192
#define TARGET_OPENBSD_NR_swapctl 193
#define TARGET_OPENBSD_NR_getrlimit 194
#define TARGET_OPENBSD_NR_setrlimit 195
#define TARGET_OPENBSD_NR_getdirentries 196
#define TARGET_OPENBSD_NR_mmap 197
#define TARGET_OPENBSD_NR___syscall 198
#define TARGET_OPENBSD_NR_lseek 199
#define TARGET_OPENBSD_NR_truncate 200
#define TARGET_OPENBSD_NR_ftruncate 201
#define TARGET_OPENBSD_NR___sysctl 202
#define TARGET_OPENBSD_NR_mlock 203
#define TARGET_OPENBSD_NR_munlock 204
#define TARGET_OPENBSD_NR_futimes 206
#define TARGET_OPENBSD_NR_getpgid 207
#define TARGET_OPENBSD_NR_xfspioctl 208
#define TARGET_OPENBSD_NR_semget 221
#define TARGET_OPENBSD_NR_msgget 225
#define TARGET_OPENBSD_NR_msgsnd 226
#define TARGET_OPENBSD_NR_msgrcv 227
#define TARGET_OPENBSD_NR_shmat 228
#define TARGET_OPENBSD_NR_shmdt 230
#define TARGET_OPENBSD_NR_clock_gettime 232
#define TARGET_OPENBSD_NR_clock_settime 233
#define TARGET_OPENBSD_NR_clock_getres 234
#define TARGET_OPENBSD_NR_nanosleep 240
#define TARGET_OPENBSD_NR_minherit 250
#define TARGET_OPENBSD_NR_rfork 251
#define TARGET_OPENBSD_NR_poll 252
#define TARGET_OPENBSD_NR_issetugid 253
#define TARGET_OPENBSD_NR_lchown 254
#define TARGET_OPENBSD_NR_getsid 255
#define TARGET_OPENBSD_NR_msync 256
#define TARGET_OPENBSD_NR_pipe 263
#define TARGET_OPENBSD_NR_fhopen 264
#define TARGET_OPENBSD_NR_preadv 267
#define TARGET_OPENBSD_NR_pwritev 268
#define TARGET_OPENBSD_NR_kqueue 269
#define TARGET_OPENBSD_NR_kevent 270
#define TARGET_OPENBSD_NR_mlockall 271
#define TARGET_OPENBSD_NR_munlockall 272
#define TARGET_OPENBSD_NR_getpeereid 273
#define TARGET_OPENBSD_NR_getresuid 281
#define TARGET_OPENBSD_NR_setresuid 282
#define TARGET_OPENBSD_NR_getresgid 283
#define TARGET_OPENBSD_NR_setresgid 284
#define TARGET_OPENBSD_NR_mquery 286
#define TARGET_OPENBSD_NR_closefrom 287
#define TARGET_OPENBSD_NR_sigaltstack 288
#define TARGET_OPENBSD_NR_shmget 289
#define TARGET_OPENBSD_NR_semop 290
#define TARGET_OPENBSD_NR_stat 291
#define TARGET_OPENBSD_NR_fstat 292
#define TARGET_OPENBSD_NR_lstat 293
#define TARGET_OPENBSD_NR_fhstat 294
#define TARGET_OPENBSD_NR___semctl 295
#define TARGET_OPENBSD_NR_shmctl 296
#define TARGET_OPENBSD_NR_msgctl 297
#define TARGET_OPENBSD_NR_sched_yield 298
#define TARGET_OPENBSD_NR_getthrid 299
#define TARGET_OPENBSD_NR_thrsleep 300
#define TARGET_OPENBSD_NR_thrwakeup 301
#define TARGET_OPENBSD_NR_threxit 302
#define TARGET_OPENBSD_NR_thrsigdivert 303
#define TARGET_OPENBSD_NR___getcwd 304
#define TARGET_OPENBSD_NR_adjfreq 305
#define TARGET_OPENBSD_NR_getfsstat 306
#define TARGET_OPENBSD_NR_statfs 307
#define TARGET_OPENBSD_NR_fstatfs 308
#define TARGET_OPENBSD_NR_fhstatfs 309

163
bsd-user/path.c Normal file
View File

@ -0,0 +1,163 @@
/* Code to mangle pathnames into those matching a given prefix.
eg. open("/lib/foo.so") => open("/usr/gnemul/i386-linux/lib/foo.so");
The assumption is that this area does not change.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <dirent.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include "qemu.h"
#include "qemu-common.h"
struct pathelem
{
/* Name of this, eg. lib */
char *name;
/* Full path name, eg. /usr/gnemul/x86-linux/lib. */
char *pathname;
struct pathelem *parent;
/* Children */
unsigned int num_entries;
struct pathelem *entries[0];
};
static struct pathelem *base;
/* First N chars of S1 match S2, and S2 is N chars long. */
static int strneq(const char *s1, unsigned int n, const char *s2)
{
unsigned int i;
for (i = 0; i < n; i++)
if (s1[i] != s2[i])
return 0;
return s2[i] == 0;
}
static struct pathelem *add_entry(struct pathelem *root, const char *name);
static struct pathelem *new_entry(const char *root,
struct pathelem *parent,
const char *name)
{
struct pathelem *new = malloc(sizeof(*new));
new->name = strdup(name);
asprintf(&new->pathname, "%s/%s", root, name);
new->num_entries = 0;
return new;
}
#define streq(a,b) (strcmp((a), (b)) == 0)
static struct pathelem *add_dir_maybe(struct pathelem *path)
{
DIR *dir;
if ((dir = opendir(path->pathname)) != NULL) {
struct dirent *dirent;
while ((dirent = readdir(dir)) != NULL) {
if (!streq(dirent->d_name,".") && !streq(dirent->d_name,"..")){
path = add_entry(path, dirent->d_name);
}
}
closedir(dir);
}
return path;
}
static struct pathelem *add_entry(struct pathelem *root, const char *name)
{
root->num_entries++;
root = realloc(root, sizeof(*root)
+ sizeof(root->entries[0])*root->num_entries);
root->entries[root->num_entries-1] = new_entry(root->pathname, root, name);
root->entries[root->num_entries-1]
= add_dir_maybe(root->entries[root->num_entries-1]);
return root;
}
/* This needs to be done after tree is stabilized (ie. no more reallocs!). */
static void set_parents(struct pathelem *child, struct pathelem *parent)
{
unsigned int i;
child->parent = parent;
for (i = 0; i < child->num_entries; i++)
set_parents(child->entries[i], child);
}
/* FIXME: Doesn't handle DIR/.. where DIR is not in emulated dir. */
static const char *
follow_path(const struct pathelem *cursor, const char *name)
{
unsigned int i, namelen;
name += strspn(name, "/");
namelen = strcspn(name, "/");
if (namelen == 0)
return cursor->pathname;
if (strneq(name, namelen, ".."))
return follow_path(cursor->parent, name + namelen);
if (strneq(name, namelen, "."))
return follow_path(cursor, name + namelen);
for (i = 0; i < cursor->num_entries; i++)
if (strneq(name, namelen, cursor->entries[i]->name))
return follow_path(cursor->entries[i], name + namelen);
/* Not found */
return NULL;
}
void init_paths(const char *prefix)
{
char pref_buf[PATH_MAX];
if (prefix[0] == '\0' ||
!strcmp(prefix, "/"))
return;
if (prefix[0] != '/') {
char *cwd = getcwd(NULL, 0);
size_t pref_buf_len = sizeof(pref_buf);
if (!cwd)
abort();
pstrcpy(pref_buf, sizeof(pref_buf), cwd);
pstrcat(pref_buf, pref_buf_len, "/");
pstrcat(pref_buf, pref_buf_len, prefix);
free(cwd);
} else
pstrcpy(pref_buf, sizeof(pref_buf), prefix + 1);
base = new_entry("", NULL, pref_buf);
base = add_dir_maybe(base);
if (base->num_entries == 0) {
free (base);
base = NULL;
} else {
set_parents(base, base);
}
}
/* Look for path in emulation dir, otherwise return name. */
const char *path(const char *name)
{
/* Only do absolute paths: quick and dirty, but should mostly be OK.
Could do relative by tracking cwd. */
if (!base || name[0] != '/')
return name;
return follow_path(base, name) ?: name;
}

405
bsd-user/qemu.h Normal file
View File

@ -0,0 +1,405 @@
#ifndef QEMU_H
#define QEMU_H
#include <signal.h>
#include <string.h>
#include "cpu.h"
#undef DEBUG_REMAP
#ifdef DEBUG_REMAP
#include <stdlib.h>
#endif /* DEBUG_REMAP */
#ifdef TARGET_ABI32
typedef uint32_t abi_ulong;
typedef int32_t abi_long;
#define TARGET_ABI_FMT_lx "%08x"
#define TARGET_ABI_FMT_ld "%d"
#define TARGET_ABI_FMT_lu "%u"
#define TARGET_ABI_BITS 32
#else
typedef target_ulong abi_ulong;
typedef target_long abi_long;
#define TARGET_ABI_FMT_lx TARGET_FMT_lx
#define TARGET_ABI_FMT_ld TARGET_FMT_ld
#define TARGET_ABI_FMT_lu TARGET_FMT_lu
#define TARGET_ABI_BITS TARGET_LONG_BITS
/* for consistency, define ABI32 too */
#if TARGET_ABI_BITS == 32
#define TARGET_ABI32 1
#endif
#endif
enum BSDType {
target_freebsd,
target_netbsd,
target_openbsd,
};
#include "syscall_defs.h"
#include "syscall.h"
#include "target_signal.h"
#include "gdbstub.h"
#if defined(USE_NPTL)
#define THREAD __thread
#else
#define THREAD
#endif
/* This struct is used to hold certain information about the image.
* Basically, it replicates in user space what would be certain
* task_struct fields in the kernel
*/
struct image_info {
abi_ulong load_addr;
abi_ulong start_code;
abi_ulong end_code;
abi_ulong start_data;
abi_ulong end_data;
abi_ulong start_brk;
abi_ulong brk;
abi_ulong start_mmap;
abi_ulong mmap;
abi_ulong rss;
abi_ulong start_stack;
abi_ulong entry;
abi_ulong code_offset;
abi_ulong data_offset;
char **host_argv;
int personality;
};
#define MAX_SIGQUEUE_SIZE 1024
struct sigqueue {
struct sigqueue *next;
//target_siginfo_t info;
};
struct emulated_sigtable {
int pending; /* true if signal is pending */
struct sigqueue *first;
struct sigqueue info; /* in order to always have memory for the
first signal, we put it here */
};
/* NOTE: we force a big alignment so that the stack stored after is
aligned too */
typedef struct TaskState {
struct TaskState *next;
int used; /* non zero if used */
struct image_info *info;
struct emulated_sigtable sigtab[TARGET_NSIG];
struct sigqueue sigqueue_table[MAX_SIGQUEUE_SIZE]; /* siginfo queue */
struct sigqueue *first_free; /* first free siginfo queue entry */
int signal_pending; /* non zero if a signal may be pending */
uint8_t stack[0];
} __attribute__((aligned(16))) TaskState;
void init_task_state(TaskState *ts);
extern const char *qemu_uname_release;
/* ??? See if we can avoid exposing so much of the loader internals. */
/*
* MAX_ARG_PAGES defines the number of pages allocated for arguments
* and envelope for the new program. 32 should suffice, this gives
* a maximum env+arg of 128kB w/4KB pages!
*/
#define MAX_ARG_PAGES 32
/*
* This structure is used to hold the arguments that are
* used when loading binaries.
*/
struct linux_binprm {
char buf[128];
void *page[MAX_ARG_PAGES];
abi_ulong p;
int fd;
int e_uid, e_gid;
int argc, envc;
char **argv;
char **envp;
char * filename; /* Name of binary */
};
void do_init_thread(struct target_pt_regs *regs, struct image_info *infop);
abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
abi_ulong stringp, int push_ptr);
int loader_exec(const char * filename, char ** argv, char ** envp,
struct target_pt_regs * regs, struct image_info *infop);
int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
struct image_info * info);
int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
struct image_info * info);
abi_long memcpy_to_target(abi_ulong dest, const void *src,
unsigned long len);
void target_set_brk(abi_ulong new_brk);
abi_long do_brk(abi_ulong new_brk);
void syscall_init(void);
abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6);
abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6);
abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6);
void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2)));
extern THREAD CPUState *thread_env;
void cpu_loop(CPUState *env, enum BSDType bsd_type);
void init_paths(const char *prefix);
const char *path(const char *pathname);
char *target_strerror(int err);
int get_osversion(void);
void fork_start(void);
void fork_end(int child);
#include "qemu-log.h"
/* strace.c */
void
print_freebsd_syscall(int num,
abi_long arg1, abi_long arg2, abi_long arg3,
abi_long arg4, abi_long arg5, abi_long arg6);
void print_freebsd_syscall_ret(int num, abi_long ret);
void
print_netbsd_syscall(int num,
abi_long arg1, abi_long arg2, abi_long arg3,
abi_long arg4, abi_long arg5, abi_long arg6);
void print_netbsd_syscall_ret(int num, abi_long ret);
void
print_openbsd_syscall(int num,
abi_long arg1, abi_long arg2, abi_long arg3,
abi_long arg4, abi_long arg5, abi_long arg6);
void print_openbsd_syscall_ret(int num, abi_long ret);
extern int do_strace;
/* signal.c */
void process_pending_signals(CPUState *cpu_env);
void signal_init(void);
//int queue_signal(CPUState *env, int sig, target_siginfo_t *info);
//void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info);
//void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo);
long do_sigreturn(CPUState *env);
long do_rt_sigreturn(CPUState *env);
abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp);
/* mmap.c */
int target_mprotect(abi_ulong start, abi_ulong len, int prot);
abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
int flags, int fd, abi_ulong offset);
int target_munmap(abi_ulong start, abi_ulong len);
abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
abi_ulong new_size, unsigned long flags,
abi_ulong new_addr);
int target_msync(abi_ulong start, abi_ulong len, int flags);
extern unsigned long last_brk;
void mmap_lock(void);
void mmap_unlock(void);
#if defined(USE_NPTL)
void mmap_fork_start(void);
void mmap_fork_end(int child);
#endif
/* user access */
#define VERIFY_READ 0
#define VERIFY_WRITE 1 /* implies read access */
static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
{
return page_check_range((target_ulong)addr, size,
(type == VERIFY_READ) ? PAGE_READ : (PAGE_READ | PAGE_WRITE)) == 0;
}
/* NOTE __get_user and __put_user use host pointers and don't check access. */
/* These are usually used to access struct data members once the
* struct has been locked - usually with lock_user_struct().
*/
#define __put_user(x, hptr)\
({\
int size = sizeof(*hptr);\
switch(size) {\
case 1:\
*(uint8_t *)(hptr) = (uint8_t)(typeof(*hptr))(x);\
break;\
case 2:\
*(uint16_t *)(hptr) = tswap16((typeof(*hptr))(x));\
break;\
case 4:\
*(uint32_t *)(hptr) = tswap32((typeof(*hptr))(x));\
break;\
case 8:\
*(uint64_t *)(hptr) = tswap64((typeof(*hptr))(x));\
break;\
default:\
abort();\
}\
0;\
})
#define __get_user(x, hptr) \
({\
int size = sizeof(*hptr);\
switch(size) {\
case 1:\
x = (typeof(*hptr))*(uint8_t *)(hptr);\
break;\
case 2:\
x = (typeof(*hptr))tswap16(*(uint16_t *)(hptr));\
break;\
case 4:\
x = (typeof(*hptr))tswap32(*(uint32_t *)(hptr));\
break;\
case 8:\
x = (typeof(*hptr))tswap64(*(uint64_t *)(hptr));\
break;\
default:\
/* avoid warning */\
x = 0;\
abort();\
}\
0;\
})
/* put_user()/get_user() take a guest address and check access */
/* These are usually used to access an atomic data type, such as an int,
* that has been passed by address. These internally perform locking
* and unlocking on the data type.
*/
#define put_user(x, gaddr, target_type) \
({ \
abi_ulong __gaddr = (gaddr); \
target_type *__hptr; \
abi_long __ret; \
if ((__hptr = lock_user(VERIFY_WRITE, __gaddr, sizeof(target_type), 0))) { \
__ret = __put_user((x), __hptr); \
unlock_user(__hptr, __gaddr, sizeof(target_type)); \
} else \
__ret = -TARGET_EFAULT; \
__ret; \
})
#define get_user(x, gaddr, target_type) \
({ \
abi_ulong __gaddr = (gaddr); \
target_type *__hptr; \
abi_long __ret; \
if ((__hptr = lock_user(VERIFY_READ, __gaddr, sizeof(target_type), 1))) { \
__ret = __get_user((x), __hptr); \
unlock_user(__hptr, __gaddr, 0); \
} else { \
/* avoid warning */ \
(x) = 0; \
__ret = -TARGET_EFAULT; \
} \
__ret; \
})
#define put_user_ual(x, gaddr) put_user((x), (gaddr), abi_ulong)
#define put_user_sal(x, gaddr) put_user((x), (gaddr), abi_long)
#define put_user_u64(x, gaddr) put_user((x), (gaddr), uint64_t)
#define put_user_s64(x, gaddr) put_user((x), (gaddr), int64_t)
#define put_user_u32(x, gaddr) put_user((x), (gaddr), uint32_t)
#define put_user_s32(x, gaddr) put_user((x), (gaddr), int32_t)
#define put_user_u16(x, gaddr) put_user((x), (gaddr), uint16_t)
#define put_user_s16(x, gaddr) put_user((x), (gaddr), int16_t)
#define put_user_u8(x, gaddr) put_user((x), (gaddr), uint8_t)
#define put_user_s8(x, gaddr) put_user((x), (gaddr), int8_t)
#define get_user_ual(x, gaddr) get_user((x), (gaddr), abi_ulong)
#define get_user_sal(x, gaddr) get_user((x), (gaddr), abi_long)
#define get_user_u64(x, gaddr) get_user((x), (gaddr), uint64_t)
#define get_user_s64(x, gaddr) get_user((x), (gaddr), int64_t)
#define get_user_u32(x, gaddr) get_user((x), (gaddr), uint32_t)
#define get_user_s32(x, gaddr) get_user((x), (gaddr), int32_t)
#define get_user_u16(x, gaddr) get_user((x), (gaddr), uint16_t)
#define get_user_s16(x, gaddr) get_user((x), (gaddr), int16_t)
#define get_user_u8(x, gaddr) get_user((x), (gaddr), uint8_t)
#define get_user_s8(x, gaddr) get_user((x), (gaddr), int8_t)
/* copy_from_user() and copy_to_user() are usually used to copy data
* buffers between the target and host. These internally perform
* locking/unlocking of the memory.
*/
abi_long copy_from_user(void *hptr, abi_ulong gaddr, size_t len);
abi_long copy_to_user(abi_ulong gaddr, void *hptr, size_t len);
/* Functions for accessing guest memory. The tget and tput functions
read/write single values, byteswapping as neccessary. The lock_user
gets a pointer to a contiguous area of guest memory, but does not perform
and byteswapping. lock_user may return either a pointer to the guest
memory, or a temporary buffer. */
/* Lock an area of guest memory into the host. If copy is true then the
host area will have the same contents as the guest. */
static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy)
{
if (!access_ok(type, guest_addr, len))
return NULL;
#ifdef DEBUG_REMAP
{
void *addr;
addr = malloc(len);
if (copy)
memcpy(addr, g2h(guest_addr), len);
else
memset(addr, 0, len);
return addr;
}
#else
return g2h(guest_addr);
#endif
}
/* Unlock an area of guest memory. The first LEN bytes must be
flushed back to guest memory. host_ptr = NULL is explicitly
allowed and does nothing. */
static inline void unlock_user(void *host_ptr, abi_ulong guest_addr,
long len)
{
#ifdef DEBUG_REMAP
if (!host_ptr)
return;
if (host_ptr == g2h(guest_addr))
return;
if (len > 0)
memcpy(g2h(guest_addr), host_ptr, len);
free(host_ptr);
#endif
}
/* Return the length of a string in target memory or -TARGET_EFAULT if
access error. */
abi_long target_strlen(abi_ulong gaddr);
/* Like lock_user but for null terminated strings. */
static inline void *lock_user_string(abi_ulong guest_addr)
{
abi_long len;
len = target_strlen(guest_addr);
if (len < 0)
return NULL;
return lock_user(VERIFY_READ, guest_addr, (long)(len + 1), 1);
}
/* Helper macros for locking/ulocking a target struct. */
#define lock_user_struct(type, host_ptr, guest_addr, copy) \
(host_ptr = lock_user(type, guest_addr, sizeof(*host_ptr), copy))
#define unlock_user_struct(host_ptr, guest_addr, copy) \
unlock_user(host_ptr, guest_addr, (copy) ? sizeof(*host_ptr) : 0)
#if defined(USE_NPTL)
#include <pthread.h>
#endif
#endif /* QEMU_H */

39
bsd-user/signal.c Normal file
View File

@ -0,0 +1,39 @@
/*
* Emulation of BSD signals
*
* Copyright (c) 2003 - 2008 Fabrice Bellard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include "qemu.h"
#include "target_signal.h"
//#define DEBUG_SIGNAL
void signal_init(void)
{
}
void process_pending_signals(CPUState *cpu_env)
{
}

View File

@ -0,0 +1,10 @@
struct target_pt_regs {
abi_ulong u_regs[16];
abi_ulong tstate;
abi_ulong pc;
abi_ulong npc;
abi_ulong y;
abi_ulong fprs;
};
#define UNAME_MACHINE "sun4u"

View File

@ -0,0 +1,27 @@
#ifndef TARGET_SIGNAL_H
#define TARGET_SIGNAL_H
#include "cpu.h"
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_ulong ss_sp;
abi_long ss_flags;
abi_ulong ss_size;
} target_stack_t;
#ifndef UREG_I6
#define UREG_I6 6
#endif
#ifndef UREG_FP
#define UREG_FP UREG_I6
#endif
static inline abi_ulong get_sp_from_cpustate(CPUSPARCState *state)
{
return state->regwptr[UREG_FP];
}
#endif /* TARGET_SIGNAL_H */

191
bsd-user/strace.c Normal file
View File

@ -0,0 +1,191 @@
#include <stdio.h>
#include <errno.h>
#include <sys/select.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/syscall.h>
#include "qemu.h"
int do_strace=0;
struct syscallname {
int nr;
const char *name;
const char *format;
void (*call)(const struct syscallname *,
abi_long, abi_long, abi_long,
abi_long, abi_long, abi_long);
void (*result)(const struct syscallname *, abi_long);
};
/*
* Utility functions
*/
static void
print_execve(const struct syscallname *name,
abi_long arg1, abi_long arg2, abi_long arg3,
abi_long arg4, abi_long arg5, abi_long arg6)
{
abi_ulong arg_ptr_addr;
char *s;
if (!(s = lock_user_string(arg1)))
return;
gemu_log("%s(\"%s\",{", name->name, s);
unlock_user(s, arg1, 0);
for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) {
abi_ulong *arg_ptr, arg_addr, s_addr;
arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
if (!arg_ptr)
return;
arg_addr = tswapl(*arg_ptr);
unlock_user(arg_ptr, arg_ptr_addr, 0);
if (!arg_addr)
break;
if ((s = lock_user_string(arg_addr))) {
gemu_log("\"%s\",", s);
unlock_user(s, s_addr, 0);
}
}
gemu_log("NULL})");
}
/*
* Variants for the return value output function
*/
static void
print_syscall_ret_addr(const struct syscallname *name, abi_long ret)
{
if( ret == -1 ) {
gemu_log(" = -1 errno=%d (%s)\n", errno, strerror(errno));
} else {
gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
}
}
#if 0 /* currently unused */
static void
print_syscall_ret_raw(struct syscallname *name, abi_long ret)
{
gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
}
#endif
/*
* An array of all of the syscalls we know about
*/
static const struct syscallname freebsd_scnames[] = {
#include "freebsd/strace.list"
};
static const struct syscallname netbsd_scnames[] = {
#include "netbsd/strace.list"
};
static const struct syscallname openbsd_scnames[] = {
#include "openbsd/strace.list"
};
static void
print_syscall(int num, const struct syscallname *scnames, unsigned int nscnames,
abi_long arg1, abi_long arg2, abi_long arg3,
abi_long arg4, abi_long arg5, abi_long arg6)
{
unsigned int i;
const char *format="%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ","
TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ","
TARGET_ABI_FMT_ld ")";
gemu_log("%d ", getpid() );
for (i = 0; i < nscnames; i++)
if (scnames[i].nr == num) {
if (scnames[i].call != NULL) {
scnames[i].call(&scnames[i], arg1, arg2, arg3, arg4, arg5,
arg6);
} else {
/* XXX: this format system is broken because it uses
host types and host pointers for strings */
if (scnames[i].format != NULL)
format = scnames[i].format;
gemu_log(format, scnames[i].name, arg1, arg2, arg3, arg4,
arg5, arg6);
}
return;
}
gemu_log("Unknown syscall %d\n", num);
}
static void
print_syscall_ret(int num, abi_long ret, const struct syscallname *scnames,
unsigned int nscnames)
{
unsigned int i;
for (i = 0; i < nscnames; i++)
if (scnames[i].nr == num) {
if (scnames[i].result != NULL) {
scnames[i].result(&scnames[i], ret);
} else {
if( ret < 0 ) {
gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", -ret,
strerror(-ret));
} else {
gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret);
}
}
break;
}
}
/*
* The public interface to this module.
*/
void
print_freebsd_syscall(int num,
abi_long arg1, abi_long arg2, abi_long arg3,
abi_long arg4, abi_long arg5, abi_long arg6)
{
print_syscall(num, freebsd_scnames, ARRAY_SIZE(freebsd_scnames),
arg1, arg2, arg3, arg4, arg5, arg6);
}
void
print_freebsd_syscall_ret(int num, abi_long ret)
{
print_syscall_ret(num, ret, freebsd_scnames, ARRAY_SIZE(freebsd_scnames));
}
void
print_netbsd_syscall(int num,
abi_long arg1, abi_long arg2, abi_long arg3,
abi_long arg4, abi_long arg5, abi_long arg6)
{
print_syscall(num, netbsd_scnames, ARRAY_SIZE(netbsd_scnames),
arg1, arg2, arg3, arg4, arg5, arg6);
}
void
print_netbsd_syscall_ret(int num, abi_long ret)
{
print_syscall_ret(num, ret, netbsd_scnames, ARRAY_SIZE(netbsd_scnames));
}
void
print_openbsd_syscall(int num,
abi_long arg1, abi_long arg2, abi_long arg3,
abi_long arg4, abi_long arg5, abi_long arg6)
{
print_syscall(num, openbsd_scnames, ARRAY_SIZE(openbsd_scnames),
arg1, arg2, arg3, arg4, arg5, arg6);
}
void
print_openbsd_syscall_ret(int num, abi_long ret)
{
print_syscall_ret(num, ret, openbsd_scnames, ARRAY_SIZE(openbsd_scnames));
}

273
bsd-user/syscall.c Normal file
View File

@ -0,0 +1,273 @@
/*
* BSD syscalls
*
* Copyright (c) 2003 - 2008 Fabrice Bellard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <signal.h>
#include <utime.h>
#include "qemu.h"
#include "qemu-common.h"
//#define DEBUG
static abi_ulong target_brk;
static abi_ulong target_original_brk;
#define get_errno(x) (x)
#define target_to_host_bitmask(x, tbl) (x)
void target_set_brk(abi_ulong new_brk)
{
target_original_brk = target_brk = HOST_PAGE_ALIGN(new_brk);
}
/* do_syscall() should always have a single exit point at the end so
that actions, such as logging of syscall results, can be performed.
All errnos that do_syscall() returns must be -TARGET_<errcode>. */
abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6)
{
abi_long ret;
void *p;
#ifdef DEBUG
gemu_log("freebsd syscall %d\n", num);
#endif
if(do_strace)
print_freebsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
switch(num) {
case TARGET_FREEBSD_NR_exit:
#ifdef HAVE_GPROF
_mcleanup();
#endif
gdb_exit(cpu_env, arg1);
/* XXX: should free thread stack and CPU env */
_exit(arg1);
ret = 0; /* avoid warning */
break;
case TARGET_FREEBSD_NR_read:
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(read(arg1, p, arg3));
unlock_user(p, arg2, ret);
break;
case TARGET_FREEBSD_NR_write:
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(write(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
case TARGET_FREEBSD_NR_open:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(open(path(p),
target_to_host_bitmask(arg2, fcntl_flags_tbl),
arg3));
unlock_user(p, arg1, 0);
break;
case TARGET_FREEBSD_NR_mmap:
ret = get_errno(target_mmap(arg1, arg2, arg3,
target_to_host_bitmask(arg4, mmap_flags_tbl),
arg5,
arg6));
break;
case TARGET_FREEBSD_NR_mprotect:
ret = get_errno(target_mprotect(arg1, arg2, arg3));
break;
case TARGET_FREEBSD_NR_syscall:
case TARGET_FREEBSD_NR___syscall:
ret = do_freebsd_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,0);
break;
default:
ret = syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
break;
}
fail:
#ifdef DEBUG
gemu_log(" = %ld\n", ret);
#endif
if (do_strace)
print_freebsd_syscall_ret(num, ret);
return ret;
efault:
ret = -TARGET_EFAULT;
goto fail;
}
abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6)
{
abi_long ret;
void *p;
#ifdef DEBUG
gemu_log("netbsd syscall %d\n", num);
#endif
if(do_strace)
print_netbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
switch(num) {
case TARGET_NETBSD_NR_exit:
#ifdef HAVE_GPROF
_mcleanup();
#endif
gdb_exit(cpu_env, arg1);
/* XXX: should free thread stack and CPU env */
_exit(arg1);
ret = 0; /* avoid warning */
break;
case TARGET_NETBSD_NR_read:
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(read(arg1, p, arg3));
unlock_user(p, arg2, ret);
break;
case TARGET_NETBSD_NR_write:
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(write(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
case TARGET_NETBSD_NR_open:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(open(path(p),
target_to_host_bitmask(arg2, fcntl_flags_tbl),
arg3));
unlock_user(p, arg1, 0);
break;
case TARGET_NETBSD_NR_mmap:
ret = get_errno(target_mmap(arg1, arg2, arg3,
target_to_host_bitmask(arg4, mmap_flags_tbl),
arg5,
arg6));
break;
case TARGET_NETBSD_NR_mprotect:
ret = get_errno(target_mprotect(arg1, arg2, arg3));
break;
case TARGET_NETBSD_NR_syscall:
case TARGET_NETBSD_NR___syscall:
ret = do_netbsd_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,0);
break;
default:
ret = syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
break;
}
fail:
#ifdef DEBUG
gemu_log(" = %ld\n", ret);
#endif
if (do_strace)
print_netbsd_syscall_ret(num, ret);
return ret;
efault:
ret = -TARGET_EFAULT;
goto fail;
}
abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6)
{
abi_long ret;
void *p;
#ifdef DEBUG
gemu_log("openbsd syscall %d\n", num);
#endif
if(do_strace)
print_openbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
switch(num) {
case TARGET_OPENBSD_NR_exit:
#ifdef HAVE_GPROF
_mcleanup();
#endif
gdb_exit(cpu_env, arg1);
/* XXX: should free thread stack and CPU env */
_exit(arg1);
ret = 0; /* avoid warning */
break;
case TARGET_OPENBSD_NR_read:
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(read(arg1, p, arg3));
unlock_user(p, arg2, ret);
break;
case TARGET_OPENBSD_NR_write:
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(write(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
case TARGET_OPENBSD_NR_open:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(open(path(p),
target_to_host_bitmask(arg2, fcntl_flags_tbl),
arg3));
unlock_user(p, arg1, 0);
break;
case TARGET_OPENBSD_NR_mmap:
ret = get_errno(target_mmap(arg1, arg2, arg3,
target_to_host_bitmask(arg4, mmap_flags_tbl),
arg5,
arg6));
break;
case TARGET_OPENBSD_NR_mprotect:
ret = get_errno(target_mprotect(arg1, arg2, arg3));
break;
case TARGET_OPENBSD_NR_syscall:
case TARGET_OPENBSD_NR___syscall:
ret = do_openbsd_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,0);
break;
default:
ret = syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
break;
}
fail:
#ifdef DEBUG
gemu_log(" = %ld\n", ret);
#endif
if (do_strace)
print_openbsd_syscall_ret(num, ret);
return ret;
efault:
ret = -TARGET_EFAULT;
goto fail;
}
void syscall_init(void)
{
}

108
bsd-user/syscall_defs.h Normal file
View File

@ -0,0 +1,108 @@
/* $OpenBSD: signal.h,v 1.19 2006/01/08 14:20:16 millert Exp $ */
/* $NetBSD: signal.h,v 1.21 1996/02/09 18:25:32 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)signal.h 8.2 (Berkeley) 1/21/94
*/
#define TARGET_NSIG 32 /* counting 0; could be 33 (mask is 1-32) */
#define TARGET_SIGHUP 1 /* hangup */
#define TARGET_SIGINT 2 /* interrupt */
#define TARGET_SIGQUIT 3 /* quit */
#define TARGET_SIGILL 4 /* illegal instruction (not reset when caught) */
#define TARGET_SIGTRAP 5 /* trace trap (not reset when caught) */
#define TARGET_SIGABRT 6 /* abort() */
#define TARGET_SIGIOT SIGABRT /* compatibility */
#define TARGET_SIGEMT 7 /* EMT instruction */
#define TARGET_SIGFPE 8 /* floating point exception */
#define TARGET_SIGKILL 9 /* kill (cannot be caught or ignored) */
#define TARGET_SIGBUS 10 /* bus error */
#define TARGET_SIGSEGV 11 /* segmentation violation */
#define TARGET_SIGSYS 12 /* bad argument to system call */
#define TARGET_SIGPIPE 13 /* write on a pipe with no one to read it */
#define TARGET_SIGALRM 14 /* alarm clock */
#define TARGET_SIGTERM 15 /* software termination signal from kill */
#define TARGET_SIGURG 16 /* urgent condition on IO channel */
#define TARGET_SIGSTOP 17 /* sendable stop signal not from tty */
#define TARGET_SIGTSTP 18 /* stop signal from tty */
#define TARGET_SIGCONT 19 /* continue a stopped process */
#define TARGET_SIGCHLD 20 /* to parent on child stop or exit */
#define TARGET_SIGTTIN 21 /* to readers pgrp upon background tty read */
#define TARGET_SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
#define TARGET_SIGIO 23 /* input/output possible signal */
#define TARGET_SIGXCPU 24 /* exceeded CPU time limit */
#define TARGET_SIGXFSZ 25 /* exceeded file size limit */
#define TARGET_SIGVTALRM 26 /* virtual time alarm */
#define TARGET_SIGPROF 27 /* profiling time alarm */
#define TARGET_SIGWINCH 28 /* window size changes */
#define TARGET_SIGINFO 29 /* information request */
#define TARGET_SIGUSR1 30 /* user defined signal 1 */
#define TARGET_SIGUSR2 31 /* user defined signal 2 */
/*
* Language spec says we must list exactly one parameter, even though we
* actually supply three. Ugh!
*/
#define TARGET_SIG_DFL (void (*)(int))0
#define TARGET_SIG_IGN (void (*)(int))1
#define TARGET_SIG_ERR (void (*)(int))-1
#define TARGET_SA_ONSTACK 0x0001 /* take signal on signal stack */
#define TARGET_SA_RESTART 0x0002 /* restart system on signal return */
#define TARGET_SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */
#define TARGET_SA_NODEFER 0x0010 /* don't mask the signal we're delivering */
#define TARGET_SA_NOCLDWAIT 0x0020 /* don't create zombies (assign to pid 1) */
#define TARGET_SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */
#define TARGET_SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
#define TARGET_SA_SIGINFO 0x0040 /* generate siginfo_t */
/*
* Flags for sigprocmask:
*/
#define TARGET_SIG_BLOCK 1 /* block specified signal set */
#define TARGET_SIG_UNBLOCK 2 /* unblock specified signal set */
#define TARGET_SIG_SETMASK 3 /* set specified signal set */
#define TARGET_BADSIG SIG_ERR
#define TARGET_SS_ONSTACK 0x0001 /* take signals on alternate stack */
#define TARGET_SS_DISABLE 0x0004 /* disable taking signals on alternate stack */
#include "errno_defs.h"
#include "freebsd/syscall_nr.h"
#include "netbsd/syscall_nr.h"
#include "openbsd/syscall_nr.h"

76
bsd-user/uaccess.c Normal file
View File

@ -0,0 +1,76 @@
/* User memory access */
#include <stdio.h>
#include <string.h>
#include "qemu.h"
/* copy_from_user() and copy_to_user() are usually used to copy data
* buffers between the target and host. These internally perform
* locking/unlocking of the memory.
*/
abi_long copy_from_user(void *hptr, abi_ulong gaddr, size_t len)
{
abi_long ret = 0;
void *ghptr;
if ((ghptr = lock_user(VERIFY_READ, gaddr, len, 1))) {
memcpy(hptr, ghptr, len);
unlock_user(ghptr, gaddr, 0);
} else
ret = -TARGET_EFAULT;
return ret;
}
abi_long copy_to_user(abi_ulong gaddr, void *hptr, size_t len)
{
abi_long ret = 0;
void *ghptr;
if ((ghptr = lock_user(VERIFY_WRITE, gaddr, len, 0))) {
memcpy(ghptr, hptr, len);
unlock_user(ghptr, gaddr, len);
} else
ret = -TARGET_EFAULT;
return ret;
}
/* XXX: use host strnlen if available ? */
static int qemu_strnlen(const char *s, int max_len)
{
int i;
for(i = 0; i < max_len; i++) {
if (s[i] == '\0')
break;
}
return i;
}
/* Return the length of a string in target memory or -TARGET_EFAULT if
access error */
abi_long target_strlen(abi_ulong guest_addr1)
{
uint8_t *ptr;
abi_ulong guest_addr;
int max_len, len;
guest_addr = guest_addr1;
for(;;) {
max_len = TARGET_PAGE_SIZE - (guest_addr & ~TARGET_PAGE_MASK);
ptr = lock_user(VERIFY_READ, guest_addr, max_len, 1);
if (!ptr)
return -TARGET_EFAULT;
len = qemu_strnlen(ptr, max_len);
unlock_user(ptr, guest_addr, 0);
guest_addr += len;
/* we don't allow wrapping or integer overflow */
if (guest_addr == 0 ||
(guest_addr - guest_addr1) > 0x7fffffff)
return -TARGET_EFAULT;
if (len != max_len)
break;
}
return guest_addr - guest_addr1;
}

26
configure vendored
View File

@ -106,6 +106,7 @@ check_gcc="yes"
softmmu="yes" softmmu="yes"
linux_user="no" linux_user="no"
darwin_user="no" darwin_user="no"
bsd_user="no"
build_docs="no" build_docs="no"
uname_release="" uname_release=""
curses="yes" curses="yes"
@ -218,6 +219,7 @@ if [ "$bsd" = "yes" ] ; then
if [ "$darwin" != "yes" ] ; then if [ "$darwin" != "yes" ] ; then
make="gmake" make="gmake"
fi fi
bsd_user="yes"
fi fi
# find source path # find source path
@ -323,6 +325,10 @@ for opt do
;; ;;
--enable-darwin-user) darwin_user="yes" --enable-darwin-user) darwin_user="yes"
;; ;;
--disable-bsd-user) bsd_user="no"
;;
--enable-bsd-user) bsd_user="yes"
;;
--enable-uname-release=*) uname_release="$optarg" --enable-uname-release=*) uname_release="$optarg"
;; ;;
--sparc_cpu=*) --sparc_cpu=*)
@ -446,6 +452,8 @@ echo " --enable-linux-user enable all linux usermode emulation targets"
echo " --disable-linux-user disable all linux usermode emulation targets" echo " --disable-linux-user disable all linux usermode emulation targets"
echo " --enable-darwin-user enable all darwin usermode emulation targets" echo " --enable-darwin-user enable all darwin usermode emulation targets"
echo " --disable-darwin-user disable all darwin usermode emulation targets" echo " --disable-darwin-user disable all darwin usermode emulation targets"
echo " --enable-bsd-user enable all BSD usermode emulation targets"
echo " --disable-bsd-user disable all BSD usermode emulation targets"
echo " --fmod-lib path to FMOD library" echo " --fmod-lib path to FMOD library"
echo " --fmod-inc path to FMOD includes" echo " --fmod-inc path to FMOD includes"
echo " --oss-lib path to OSS library" echo " --oss-lib path to OSS library"
@ -492,6 +500,7 @@ if test "$mingw32" = "yes" ; then
EXESUF=".exe" EXESUF=".exe"
oss="no" oss="no"
linux_user="no" linux_user="no"
bsd_user="no"
fi fi
if [ "$darwin" = "yes" -o "$mingw32" = "yes" ] ; then if [ "$darwin" = "yes" -o "$mingw32" = "yes" ] ; then
@ -629,6 +638,12 @@ sparc32plus-linux-user \
if [ "$darwin_user" = "yes" ] ; then if [ "$darwin_user" = "yes" ] ; then
target_list="$target_list i386-darwin-user ppc-darwin-user" target_list="$target_list i386-darwin-user ppc-darwin-user"
fi fi
# the following are BSD specific
if [ "$bsd_user" = "yes" ] ; then
target_list="${target_list}\
sparc64-bsd-user \
"
fi
else else
target_list=`echo "$target_list" | sed -e 's/,/ /g'` target_list=`echo "$target_list" | sed -e 's/,/ /g'`
fi fi
@ -1329,6 +1344,7 @@ target_softmmu="no"
target_user_only="no" target_user_only="no"
target_linux_user="no" target_linux_user="no"
target_darwin_user="no" target_darwin_user="no"
target_bsd_user="no"
case "$target" in case "$target" in
${target_cpu}-softmmu) ${target_cpu}-softmmu)
target_softmmu="yes" target_softmmu="yes"
@ -1341,6 +1357,10 @@ case "$target" in
target_user_only="yes" target_user_only="yes"
target_darwin_user="yes" target_darwin_user="yes"
;; ;;
${target_cpu}-bsd-user)
target_user_only="yes"
target_bsd_user="yes"
;;
*) *)
echo "ERROR: Target '$target' not recognised" echo "ERROR: Target '$target' not recognised"
exit 1 exit 1
@ -1363,7 +1383,7 @@ test -f $config_h && mv $config_h ${config_h}~
mkdir -p $target_dir mkdir -p $target_dir
mkdir -p $target_dir/fpu mkdir -p $target_dir/fpu
mkdir -p $target_dir/tcg mkdir -p $target_dir/tcg
if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" ; then if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
mkdir -p $target_dir/nwfpe mkdir -p $target_dir/nwfpe
fi fi
@ -1584,6 +1604,10 @@ if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
echo "TARGET_HAS_ELFLOAD32=yes" >> $config_mak echo "TARGET_HAS_ELFLOAD32=yes" >> $config_mak
echo "#define TARGET_HAS_ELFLOAD32 1" >> $config_h echo "#define TARGET_HAS_ELFLOAD32 1" >> $config_h
fi fi
if test "$target_bsd_user" = "yes" ; then
echo "CONFIG_BSD_USER=yes" >> $config_mak
echo "#define CONFIG_BSD_USER 1" >> $config_h
fi
test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h

View File

@ -34,8 +34,10 @@
#undef EDI #undef EDI
#undef EIP #undef EIP
#include <signal.h> #include <signal.h>
#ifdef __linux__
#include <sys/ucontext.h> #include <sys/ucontext.h>
#endif #endif
#endif
#if defined(__sparc__) && !defined(HOST_SOLARIS) #if defined(__sparc__) && !defined(HOST_SOLARIS)
// Work around ugly bugs in glibc that mangle global register contents // Work around ugly bugs in glibc that mangle global register contents
@ -66,7 +68,11 @@ void cpu_loop_exit(void)
void cpu_resume_from_signal(CPUState *env1, void *puc) void cpu_resume_from_signal(CPUState *env1, void *puc)
{ {
#if !defined(CONFIG_SOFTMMU) #if !defined(CONFIG_SOFTMMU)
#ifdef __linux__
struct ucontext *uc = puc; struct ucontext *uc = puc;
#elif defined(__OpenBSD__)
struct sigcontext *uc = puc;
#endif
#endif #endif
env = env1; env = env1;
@ -76,7 +82,11 @@ void cpu_resume_from_signal(CPUState *env1, void *puc)
#if !defined(CONFIG_SOFTMMU) #if !defined(CONFIG_SOFTMMU)
if (puc) { if (puc) {
/* XXX: use siglongjmp ? */ /* XXX: use siglongjmp ? */
#ifdef __linux__
sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL);
#elif defined(__OpenBSD__)
sigprocmask(SIG_SETMASK, &uc->sc_mask, NULL);
#endif
} }
#endif #endif
longjmp(env->jmp_env, 1); longjmp(env->jmp_env, 1);
@ -1328,9 +1338,15 @@ int cpu_signal_handler(int host_signum, void *pinfo,
/* XXX: is there a standard glibc define ? */ /* XXX: is there a standard glibc define ? */
unsigned long pc = regs[1]; unsigned long pc = regs[1];
#else #else
#ifdef __linux__
struct sigcontext *sc = puc; struct sigcontext *sc = puc;
unsigned long pc = sc->sigc_regs.tpc; unsigned long pc = sc->sigc_regs.tpc;
void *sigmask = (void *)sc->sigc_mask; void *sigmask = (void *)sc->sigc_mask;
#elif defined(__OpenBSD__)
struct sigcontext *uc = puc;
unsigned long pc = uc->sc_pc;
void *sigmask = (void *)(long)uc->sc_mask;
#endif
#endif #endif
/* XXX: need kernel patch to get write flag faster */ /* XXX: need kernel patch to get write flag faster */

View File

@ -2759,6 +2759,7 @@ Two on-chip UARTs.
* Supported Operating Systems :: * Supported Operating Systems ::
* Linux User space emulator:: * Linux User space emulator::
* Mac OS X/Darwin User space emulator :: * Mac OS X/Darwin User space emulator ::
* BSD User space emulator ::
@end menu @end menu
@node Supported Operating Systems @node Supported Operating Systems
@ -2771,6 +2772,8 @@ The following OS are supported in user space emulation:
Linux (referred as qemu-linux-user) Linux (referred as qemu-linux-user)
@item @item
Mac OS X/Darwin (referred as qemu-darwin-user) Mac OS X/Darwin (referred as qemu-darwin-user)
@item
BSD (referred as qemu-bsd-user)
@end itemize @end itemize
@node Linux User space emulator @node Linux User space emulator
@ -3010,6 +3013,68 @@ Activate log (logfile=/tmp/qemu.log)
Act as if the host page size was 'pagesize' bytes Act as if the host page size was 'pagesize' bytes
@end table @end table
@node BSD User space emulator
@section BSD User space emulator
@menu
* BSD Status::
* BSD Quick Start::
* BSD Command line options::
@end menu
@node BSD Status
@subsection BSD Status
@itemize @minus
@item
target Sparc64 on Sparc64: Some trivial programs work.
@end itemize
@node BSD Quick Start
@subsection Quick Start
In order to launch a BSD process, QEMU needs the process executable
itself and all the target dynamic libraries used by it.
@itemize
@item On Sparc64, you can just try to launch any process by using the native
libraries:
@example
qemu-sparc64 /bin/ls
@end example
@end itemize
@node BSD Command line options
@subsection Command line options
@example
usage: qemu-sparc64 [-h] [-d] [-L path] [-s size] [-bsd type] program [arguments...]
@end example
@table @option
@item -h
Print the help
@item -L path
Set the library root path (default=/)
@item -s size
Set the stack size in bytes (default=524288)
@item -bsd type
Set the type of the emulated BSD Operating system. Valid values are
FreeBSD, NetBSD and OpenBSD (default).
@end table
Debug options:
@table @option
@item -d
Activate log (logfile=/tmp/qemu.log)
@item -p pagesize
Act as if the host page size was 'pagesize' bytes
@end table
@node compilation @node compilation
@chapter Compilation from the sources @chapter Compilation from the sources