Merge tag 'v9.0.0-rc3'
[qemu/ar7.git] / bsd-user / x86_64 / target_arch_sysarch.h
blob152cb8bcb86f15a7fd34184e5ae6724aa7811215
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 TARGET_ARCH_SYSARCH_H
20 #define TARGET_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 /* TARGET_ARCH_SYSARCH_H */