Merge tag 'pull-aspeed-20240709' of https://github.com/legoater/qemu into staging
[qemu/ar7.git] / bsd-user / i386 / target_arch_sysarch.h
blobdb8fee6380a42ad0b38f359e42ef66298460bf13
1 /*
2 * i386 sysarch system call emulation
4 * Copyright (c) 2013 Stacey D. Son
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef TARGET_ARCH_SYSARCH_H
21 #define TARGET_ARCH_SYSARCH_H
23 #include "target_syscall.h"
25 static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op,
26 abi_ulong parms)
28 abi_long ret = 0;
29 abi_ulong val;
30 int idx;
32 switch (op) {
33 case TARGET_FREEBSD_I386_SET_GSBASE:
34 case TARGET_FREEBSD_I386_SET_FSBASE:
35 if (op == TARGET_FREEBSD_I386_SET_GSBASE) {
36 idx = R_GS;
37 } else {
38 idx = R_FS;
40 if (get_user(val, parms, abi_ulong)) {
41 return -TARGET_EFAULT;
43 cpu_x86_load_seg(env, idx, 0);
44 env->segs[idx].base = val;
45 break;
47 case TARGET_FREEBSD_I386_GET_GSBASE:
48 case TARGET_FREEBSD_I386_GET_FSBASE:
49 if (op == TARGET_FREEBSD_I386_GET_GSBASE) {
50 idx = R_GS;
51 } else {
52 idx = R_FS;
54 val = env->segs[idx].base;
55 if (put_user(val, parms, abi_ulong)) {
56 return -TARGET_EFAULT;
58 break;
60 /* XXX handle the others... */
61 default:
62 ret = -TARGET_EINVAL;
63 break;
65 return ret;
68 static inline void do_freebsd_arch_print_sysarch(
69 const struct syscallname *name, abi_long arg1, abi_long arg2,
70 abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
73 gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
74 TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
77 #endif /* TARGET_ARCH_SYSARCH_H */