python/aqmp-tui: relicense as LGPLv2+
[qemu/armbru.git] / bsd-user / x86_64 / target_arch_sysarch.h
blob5c36fc0752061e0ade532a4424aa4023eacd23ab
1 /*
2 * x86_64 sysarch() syscall emulation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 #ifndef BSD_USER_ARCH_SYSARCH_H_
20 #define BSD_USER_ARCH_SYSARCH_H_
22 #include "target_syscall.h"
24 static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op,
25 abi_ulong parms)
27 abi_long ret = 0;
28 abi_ulong val;
29 int idx;
31 switch (op) {
32 case TARGET_FREEBSD_AMD64_SET_GSBASE:
33 case TARGET_FREEBSD_AMD64_SET_FSBASE:
34 if (op == TARGET_FREEBSD_AMD64_SET_GSBASE) {
35 idx = R_GS;
36 } else {
37 idx = R_FS;
39 if (get_user(val, parms, abi_ulong)) {
40 return -TARGET_EFAULT;
42 cpu_x86_load_seg(env, idx, 0);
43 env->segs[idx].base = val;
44 break;
46 case TARGET_FREEBSD_AMD64_GET_GSBASE:
47 case TARGET_FREEBSD_AMD64_GET_FSBASE:
48 if (op == TARGET_FREEBSD_AMD64_GET_GSBASE) {
49 idx = R_GS;
50 } else {
51 idx = R_FS;
53 val = env->segs[idx].base;
54 if (put_user(val, parms, abi_ulong)) {
55 return -TARGET_EFAULT;
57 break;
59 /* XXX handle the others... */
60 default:
61 ret = -TARGET_EINVAL;
62 break;
64 return ret;
67 static inline void do_freebsd_arch_print_sysarch(
68 const struct syscallname *name, abi_long arg1, abi_long arg2,
69 abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
72 gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
73 TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
76 #endif /*! BSD_USER_ARCH_SYSARCH_H_ */