Signed-off-by: Sean Bruno <sbr...@freebsd.org> Signed-off-by: Stacey Son <s...@freebsd.org> --- bsd-user/freebsd/os-strace.h | 35 +++++++++++++++ bsd-user/freebsd/strace.list | 2 +- bsd-user/i386/syscall.h | 21 +++++++++ bsd-user/i386/target_arch_sysarch.h | 78 ++++++++++++++++++++++++++++++++++ bsd-user/netbsd/os-strace.h | 37 ++++++++++++++++ bsd-user/openbsd/os-strace.h | 37 ++++++++++++++++ bsd-user/qemu.h | 3 ++ bsd-user/sparc/syscall.h | 27 +++++++++++- bsd-user/sparc/target_arch_sysarch.h | 52 +++++++++++++++++++++++ bsd-user/sparc64/syscall.h | 26 +++++++++++- bsd-user/sparc64/target_arch_sysarch.h | 52 +++++++++++++++++++++++ bsd-user/strace.c | 10 +++++ bsd-user/syscall.c | 63 +-------------------------- bsd-user/x86_64/syscall.h | 24 ++++++++++- bsd-user/x86_64/target_arch_sysarch.h | 76 +++++++++++++++++++++++++++++++++ 15 files changed, 477 insertions(+), 66 deletions(-) create mode 100644 bsd-user/freebsd/os-strace.h create mode 100644 bsd-user/i386/target_arch_sysarch.h create mode 100644 bsd-user/netbsd/os-strace.h create mode 100644 bsd-user/openbsd/os-strace.h create mode 100644 bsd-user/sparc/target_arch_sysarch.h create mode 100644 bsd-user/sparc64/target_arch_sysarch.h create mode 100644 bsd-user/x86_64/target_arch_sysarch.h
diff --git a/bsd-user/freebsd/os-strace.h b/bsd-user/freebsd/os-strace.h new file mode 100644 index 0000000..c856450 --- /dev/null +++ b/bsd-user/freebsd/os-strace.h @@ -0,0 +1,35 @@ +/* + * FreeBSD dependent strace print functions + * + * Copyright (c) 2013 Stacey D. Son + * + * 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, see <http://www.gnu.org/licenses/>. + */ + +#include "target_arch_sysarch.h" /* architecture dependent functions */ + + +static inline void do_os_print_sysarch(const struct syscallname *name, + abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6) +{ + /* This is arch dependent */ + do_freebsd_arch_print_sysarch(name, arg1, arg2, arg3, arg4, arg5, arg6); +} + +/* sysarch() is architecture dependent. */ +abi_long do_bsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2) +{ + return do_freebsd_arch_sysarch(cpu_env, arg1, arg2); +} diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list index 2800a2d..55f5ff8 100644 --- a/bsd-user/freebsd/strace.list +++ b/bsd-user/freebsd/strace.list @@ -209,7 +209,7 @@ { 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_sysarch, "sysarch", NULL, print_sysarch, NULL }, { TARGET_FREEBSD_NR_syscall, "syscall", NULL, NULL, NULL }, { TARGET_FREEBSD_NR_thr_create, "thr_create", "%s(%#x, %#x, %d)", NULL, NULL }, { TARGET_FREEBSD_NR_thr_exit, "thr_exit", "%s(%#x)", NULL, NULL }, diff --git a/bsd-user/i386/syscall.h b/bsd-user/i386/syscall.h index 9b34c61..8028fc8 100644 --- a/bsd-user/i386/syscall.h +++ b/bsd-user/i386/syscall.h @@ -1,3 +1,23 @@ +/* + * i386 system call definitions + * + * + * 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, see <http://www.gnu.org/licenses/>. + */ +#ifndef _I386_SYSCALL_H_ +#define _I386_SYSCALL_H_ + /* default linux values for the selectors */ #define __USER_CS (0x23) #define __USER_DS (0x2B) @@ -159,3 +179,4 @@ struct target_vm86plus_struct { #define UNAME_MACHINE "i386" +#endif /* ! _I386_SYSCALL_H_ */ diff --git a/bsd-user/i386/target_arch_sysarch.h b/bsd-user/i386/target_arch_sysarch.h new file mode 100644 index 0000000..4fa6698 --- /dev/null +++ b/bsd-user/i386/target_arch_sysarch.h @@ -0,0 +1,78 @@ +/* + * i386 sysarch system call emulation + * + * Copyright (c) 2013 Stacey D. Son + * + * 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __ARCH_SYSARCH_H_ +#define __ARCH_SYSARCH_H_ + +#include "syscall.h" + +static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op, + abi_ulong parms) +{ + abi_long ret = 0; + abi_ulong val; + int idx; + + switch (op) { + case TARGET_FREEBSD_I386_SET_GSBASE: + case TARGET_FREEBSD_I386_SET_FSBASE: + if (op == TARGET_FREEBSD_I386_SET_GSBASE) { + idx = R_GS; + } else { + idx = R_FS; + } + if (get_user(val, parms, abi_ulong)) { + return -TARGET_EFAULT; + } + cpu_x86_load_seg(env, idx, 0); + env->segs[idx].base = val; + break; + + case TARGET_FREEBSD_I386_GET_GSBASE: + case TARGET_FREEBSD_I386_GET_FSBASE: + if (op == TARGET_FREEBSD_I386_GET_GSBASE) { + idx = R_GS; + } else { + idx = R_FS; + } + val = env->segs[idx].base; + if (put_user(val, parms, abi_ulong)) { + return -TARGET_EFAULT; + } + break; + + /* XXX handle the others... */ + default: + ret = -TARGET_EINVAL; + break; + } + return ret; +} + +static inline void do_freebsd_arch_print_sysarch( + const struct syscallname *name, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) +{ + + gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", " + TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4); +} + +#endif /* !__ARCH_SYSARCH_H_ */ + diff --git a/bsd-user/netbsd/os-strace.h b/bsd-user/netbsd/os-strace.h new file mode 100644 index 0000000..20dfd4b --- /dev/null +++ b/bsd-user/netbsd/os-strace.h @@ -0,0 +1,37 @@ +/* + * NetBSD dependent strace print functions + * + * Copyright (c) 2014 Sean Bruno <sbr...@freebsd.org> + * + * 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, see <http://www.gnu.org/licenses/>. + */ + +#include "target_arch_sysarch.h" /* architecture dependent functions */ + + +static inline void do_os_print_sysarch(const struct syscallname *name, + abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6) +{ + qemu_log("qemu: Unsupported syscall %s\n", __func__); + return -TARGET_ENOSYS; +} + +/* sysarch() is architecture dependent. */ +abi_long do_bsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2) +{ + qemu_log("qemu: Unsupported syscall sysarch()\n"); + return -TARGET_ENOSYS; +} + diff --git a/bsd-user/openbsd/os-strace.h b/bsd-user/openbsd/os-strace.h new file mode 100644 index 0000000..277b96c --- /dev/null +++ b/bsd-user/openbsd/os-strace.h @@ -0,0 +1,37 @@ +/* + * OpenBSD dependent strace print functions + * + * Copyright (c) 2014 Sean Bruno <sbr...@freebsd.org> + * + * 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, see <http://www.gnu.org/licenses/>. + */ + +#include "target_arch_sysarch.h" /* architecture dependent functions */ + + +static inline void do_os_print_sysarch(const struct syscallname *name, + abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6) +{ + qemu_log("qemu: Unsupported syscall %s\n", __func__); + return -TARGET_ENOSYS; +} + +/* sysarch() is architecture dependent. */ +abi_long do_bsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2) +{ + + qemu_log("qemu: Unsupported syscall sysarch()\n"); + return -TARGET_ENOSYS; +} diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 5362297..658999b 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -225,6 +225,9 @@ void mmap_fork_end(int child); /* main.c */ extern unsigned long x86_stack_size; +/* os-strace.h */ +abi_long do_bsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2); + /* user access */ #define VERIFY_READ 0 diff --git a/bsd-user/sparc/syscall.h b/bsd-user/sparc/syscall.h index 5a9bb7e..7ed2152 100644 --- a/bsd-user/sparc/syscall.h +++ b/bsd-user/sparc/syscall.h @@ -1,3 +1,23 @@ +/* + * sparc dependent system call definitions + * + * + * 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, see <http://www.gnu.org/licenses/>. + */ +#ifndef _SPARC_SYSCALL_H_ +#define _SPARC_SYSCALL_H_ + struct target_pt_regs { abi_ulong psr; abi_ulong pc; @@ -6,4 +26,9 @@ struct target_pt_regs { abi_ulong u_regs[16]; }; -#define UNAME_MACHINE "sun4" +#define UNAME_MACHINE "sun4" + +#define TARGET_SPARC_UTRAP_INSTALL 1 +#define TARGET_SPARC_SIGTRAMP_INSTALL 2 + +#endif /* ! _SPARC_SYSCALL_H_ */ diff --git a/bsd-user/sparc/target_arch_sysarch.h b/bsd-user/sparc/target_arch_sysarch.h new file mode 100644 index 0000000..454c084 --- /dev/null +++ b/bsd-user/sparc/target_arch_sysarch.h @@ -0,0 +1,52 @@ +/* + * SPARC sysarch() system call emulation + * + * Copyright (c) 2013 Stacey D. Son + * + * 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __ARCH_SYSARCH_H_ +#define __ARCH_SYSARCH_H_ + +#include "syscall.h" + +static inline abi_long do_freebsd_arch_sysarch(void *env, int op, + abi_ulong parms) +{ + int ret = 0; + + switch (op) { + case TARGET_SPARC_SIGTRAMP_INSTALL: + /* XXX not currently handled */ + case TARGET_SPARC_UTRAP_INSTALL: + /* XXX not currently handled */ + default: + ret = -TARGET_EINVAL; + break; + } + + return ret; +} + +static inline void do_freebsd_arch_print_sysarch( + const struct syscallname *name, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) +{ + + gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", " + TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4); +} + +#endif /*!__ARCH_SYSARCH_H_ */ diff --git a/bsd-user/sparc64/syscall.h b/bsd-user/sparc64/syscall.h index 81a816d..8571092 100644 --- a/bsd-user/sparc64/syscall.h +++ b/bsd-user/sparc64/syscall.h @@ -1,3 +1,22 @@ +/* + * sparc64 dependent system call definitions + * + * + * 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, see <http://www.gnu.org/licenses/>. + */ +#ifndef _SPARC64_SYSCALL_H_ +#define _SPARC64_SYSCALL_H_ struct target_pt_regs { abi_ulong u_regs[16]; abi_ulong tstate; @@ -7,4 +26,9 @@ struct target_pt_regs { abi_ulong fprs; }; -#define UNAME_MACHINE "sun4u" +#define UNAME_MACHINE "sun4u" + +#define TARGET_SPARC_UTRAP_INSTALL 1 +#define TARGET_SPARC_SIGTRAMP_INSTALL 2 + +#endif /* !_SPARC64_SYSCALL_H_ */ diff --git a/bsd-user/sparc64/target_arch_sysarch.h b/bsd-user/sparc64/target_arch_sysarch.h new file mode 100644 index 0000000..84e1339 --- /dev/null +++ b/bsd-user/sparc64/target_arch_sysarch.h @@ -0,0 +1,52 @@ +/* + * SPARC64 sysarch() system call emulation + * + * Copyright (c) 2013 Stacey D. Son + * + * 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __ARCH_SYSARCH_H_ +#define __ARCH_SYSARCH_H_ + +#include "syscall.h" + +static inline abi_long do_freebsd_arch_sysarch(void *env, int op, + abi_ulong parms) +{ + int ret = 0; + + switch (op) { + case TARGET_SPARC_SIGTRAMP_INSTALL: + /* XXX not currently handled */ + case TARGET_SPARC_UTRAP_INSTALL: + /* XXX not currently handled */ + default: + ret = -TARGET_EINVAL; + break; + } + + return ret; +} + +static inline void do_freebsd_arch_print_sysarch( + const struct syscallname *name, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) +{ + + gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", " + TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4); +} + +#endif /*!__ARCH_SYSARCH_H_ */ diff --git a/bsd-user/strace.c b/bsd-user/strace.c index e33dd4d..60aabc3 100644 --- a/bsd-user/strace.c +++ b/bsd-user/strace.c @@ -27,6 +27,8 @@ #include "qemu.h" +#include "os-strace.h" /* OS dependent strace print functions */ + int do_strace; /* @@ -108,6 +110,14 @@ static void print_ioctl(const struct syscallname *name, arg3); } +static void print_sysarch(const struct syscallname *name, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, + abi_long arg6) +{ + /* This is os dependent. */ + do_os_print_sysarch(name, arg1, arg2, arg3, arg4, arg5, arg6); +} + /* * Variants for the return value output function */ diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c index a4d1583..b3efc3c 100644 --- a/bsd-user/syscall.c +++ b/bsd-user/syscall.c @@ -96,67 +96,6 @@ static abi_long do_obreak(abi_ulong new_brk) return 0; } -#if defined(TARGET_I386) -static abi_long do_freebsd_sysarch(CPUX86State *env, int op, abi_ulong parms) -{ - abi_long ret = 0; - abi_ulong val; - int idx; - - switch(op) { -#ifdef TARGET_ABI32 - case TARGET_FREEBSD_I386_SET_GSBASE: - case TARGET_FREEBSD_I386_SET_FSBASE: - if (op == TARGET_FREEBSD_I386_SET_GSBASE) -#else - case TARGET_FREEBSD_AMD64_SET_GSBASE: - case TARGET_FREEBSD_AMD64_SET_FSBASE: - if (op == TARGET_FREEBSD_AMD64_SET_GSBASE) -#endif - idx = R_GS; - else - idx = R_FS; - if (get_user(val, parms, abi_ulong)) - return -TARGET_EFAULT; - cpu_x86_load_seg(env, idx, 0); - env->segs[idx].base = val; - break; -#ifdef TARGET_ABI32 - case TARGET_FREEBSD_I386_GET_GSBASE: - case TARGET_FREEBSD_I386_GET_FSBASE: - if (op == TARGET_FREEBSD_I386_GET_GSBASE) -#else - case TARGET_FREEBSD_AMD64_GET_GSBASE: - case TARGET_FREEBSD_AMD64_GET_FSBASE: - if (op == TARGET_FREEBSD_AMD64_GET_GSBASE) -#endif - idx = R_GS; - else - idx = R_FS; - val = env->segs[idx].base; - if (put_user(val, parms, abi_ulong)) - return -TARGET_EFAULT; - break; - /* XXX handle the others... */ - default: - ret = -TARGET_EINVAL; - break; - } - return ret; -} -#endif - -#ifdef TARGET_SPARC -static abi_long do_freebsd_sysarch(void *env, int op, abi_ulong parms) -{ - /* XXX handle - * TARGET_FREEBSD_SPARC_UTRAP_INSTALL, - * TARGET_FREEBSD_SPARC_SIGTRAMP_INSTALL - */ - return -TARGET_EINVAL; -} -#endif - #ifdef __FreeBSD__ /* * XXX this uses the undocumented oidfmt interface to find the kind of @@ -393,7 +332,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1, break; #endif case TARGET_FREEBSD_NR_sysarch: - ret = do_freebsd_sysarch(cpu_env, arg1, arg2); + ret = do_bsd_sysarch(cpu_env, arg1, arg2); break; case TARGET_FREEBSD_NR_syscall: case TARGET_FREEBSD_NR___syscall: diff --git a/bsd-user/x86_64/syscall.h b/bsd-user/x86_64/syscall.h index 630514a..4e77235 100644 --- a/bsd-user/x86_64/syscall.h +++ b/bsd-user/x86_64/syscall.h @@ -1,3 +1,23 @@ +/* + * x86_64 system call definitions + * + * + * 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, see <http://www.gnu.org/licenses/>. + */ +#ifndef _X86_64_SYSCALL_H_ +#define _X86_64_SYSCALL_H_ + #define __USER_CS (0x33) #define __USER_DS (0x2B) @@ -108,9 +128,11 @@ struct target_msqid64_ds { #define TARGET_FREEBSD_AMD64_SET_GSBASE 131 -#define UNAME_MACHINE "x86_64" +#define UNAME_MACHINE "x86_64" #define TARGET_ARCH_SET_GS 0x1001 #define TARGET_ARCH_SET_FS 0x1002 #define TARGET_ARCH_GET_FS 0x1003 #define TARGET_ARCH_GET_GS 0x1004 + +#endif /* ! _X86_64_SYSCALL_H_ */ diff --git a/bsd-user/x86_64/target_arch_sysarch.h b/bsd-user/x86_64/target_arch_sysarch.h new file mode 100644 index 0000000..6d09d50 --- /dev/null +++ b/bsd-user/x86_64/target_arch_sysarch.h @@ -0,0 +1,76 @@ +/* + * x86_64 sysarch() syscall emulation + * + * + * 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __ARCH_SYSARCH_H_ +#define __ARCH_SYSARCH_H_ + +#include "syscall.h" + +static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op, + abi_ulong parms) +{ + abi_long ret = 0; + abi_ulong val; + int idx; + + switch (op) { + case TARGET_FREEBSD_AMD64_SET_GSBASE: + case TARGET_FREEBSD_AMD64_SET_FSBASE: + if (op == TARGET_FREEBSD_AMD64_SET_GSBASE) { + idx = R_GS; + } else { + idx = R_FS; + } + if (get_user(val, parms, abi_ulong)) { + return -TARGET_EFAULT; + } + cpu_x86_load_seg(env, idx, 0); + env->segs[idx].base = val; + break; + + case TARGET_FREEBSD_AMD64_GET_GSBASE: + case TARGET_FREEBSD_AMD64_GET_FSBASE: + if (op == TARGET_FREEBSD_AMD64_GET_GSBASE) { + idx = R_GS; + } else { + idx = R_FS; + } + val = env->segs[idx].base; + if (put_user(val, parms, abi_ulong)) { + return -TARGET_EFAULT; + } + break; + + /* XXX handle the others... */ + default: + ret = -TARGET_EINVAL; + break; + } + return ret; +} + +static inline void do_freebsd_arch_print_sysarch( + const struct syscallname *name, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) +{ + + gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", " + TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4); +} + +#endif /*! __ARCH_SYSARCH_H_ */ -- 2.0.0