1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef TARGET_ARCH_SYSARCH_H
20#define TARGET_ARCH_SYSARCH_H
21
22#include "target_syscall.h"
23
24static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op,
25 abi_ulong parms)
26{
27 abi_long ret = 0;
28 abi_ulong val;
29 int idx;
30
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;
38 }
39 if (get_user(val, parms, abi_ulong)) {
40 return -TARGET_EFAULT;
41 }
42 cpu_x86_load_seg(env, idx, 0);
43 env->segs[idx].base = val;
44 break;
45
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;
52 }
53 val = env->segs[idx].base;
54 if (put_user(val, parms, abi_ulong)) {
55 return -TARGET_EFAULT;
56 }
57 break;
58
59
60 default:
61 ret = -TARGET_EINVAL;
62 break;
63 }
64 return ret;
65}
66
67static 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)
70{
71
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);
74}
75
76#endif
77