]> git.proxmox.com Git - mirror_qemu.git/blame - bsd-user/x86_64/target_arch_sysarch.h
bsd-user: Implement getrusage(2).
[mirror_qemu.git] / bsd-user / x86_64 / target_arch_sysarch.h
CommitLineData
ea1ab4cf
SS
1/*
2 * x86_64 sysarch() syscall emulation
3 *
4 *
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.
9 *
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.
14 *
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/>.
17 */
18
52581c71
MA
19#ifndef TARGET_ARCH_SYSARCH_H
20#define TARGET_ARCH_SYSARCH_H
ea1ab4cf
SS
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 /* XXX handle the others... */
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
52581c71 76#endif /* TARGET_ARCH_SYSARCH_H */