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