1ea1ab4cfSStacey Son /* 2ea1ab4cfSStacey Son * x86_64 sysarch() syscall emulation 3ea1ab4cfSStacey Son * 4ea1ab4cfSStacey Son * 5ea1ab4cfSStacey Son * This program is free software; you can redistribute it and/or modify 6ea1ab4cfSStacey Son * it under the terms of the GNU General Public License as published by 7ea1ab4cfSStacey Son * the Free Software Foundation; either version 2 of the License, or 8ea1ab4cfSStacey Son * (at your option) any later version. 9ea1ab4cfSStacey Son * 10ea1ab4cfSStacey Son * This program is distributed in the hope that it will be useful, 11ea1ab4cfSStacey Son * but WITHOUT ANY WARRANTY; without even the implied warranty of 12ea1ab4cfSStacey Son * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13ea1ab4cfSStacey Son * GNU General Public License for more details. 14ea1ab4cfSStacey Son * 15ea1ab4cfSStacey Son * You should have received a copy of the GNU General Public License 16ea1ab4cfSStacey Son * along with this program; if not, see <http://www.gnu.org/licenses/>. 17ea1ab4cfSStacey Son */ 18ea1ab4cfSStacey Son 19*52581c71SMarkus Armbruster #ifndef TARGET_ARCH_SYSARCH_H 20*52581c71SMarkus Armbruster #define TARGET_ARCH_SYSARCH_H 21ea1ab4cfSStacey Son 22ea1ab4cfSStacey Son #include "target_syscall.h" 23ea1ab4cfSStacey Son 24ea1ab4cfSStacey Son static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op, 25ea1ab4cfSStacey Son abi_ulong parms) 26ea1ab4cfSStacey Son { 27ea1ab4cfSStacey Son abi_long ret = 0; 28ea1ab4cfSStacey Son abi_ulong val; 29ea1ab4cfSStacey Son int idx; 30ea1ab4cfSStacey Son 31ea1ab4cfSStacey Son switch (op) { 32ea1ab4cfSStacey Son case TARGET_FREEBSD_AMD64_SET_GSBASE: 33ea1ab4cfSStacey Son case TARGET_FREEBSD_AMD64_SET_FSBASE: 34ea1ab4cfSStacey Son if (op == TARGET_FREEBSD_AMD64_SET_GSBASE) { 35ea1ab4cfSStacey Son idx = R_GS; 36ea1ab4cfSStacey Son } else { 37ea1ab4cfSStacey Son idx = R_FS; 38ea1ab4cfSStacey Son } 39ea1ab4cfSStacey Son if (get_user(val, parms, abi_ulong)) { 40ea1ab4cfSStacey Son return -TARGET_EFAULT; 41ea1ab4cfSStacey Son } 42ea1ab4cfSStacey Son cpu_x86_load_seg(env, idx, 0); 43ea1ab4cfSStacey Son env->segs[idx].base = val; 44ea1ab4cfSStacey Son break; 45ea1ab4cfSStacey Son 46ea1ab4cfSStacey Son case TARGET_FREEBSD_AMD64_GET_GSBASE: 47ea1ab4cfSStacey Son case TARGET_FREEBSD_AMD64_GET_FSBASE: 48ea1ab4cfSStacey Son if (op == TARGET_FREEBSD_AMD64_GET_GSBASE) { 49ea1ab4cfSStacey Son idx = R_GS; 50ea1ab4cfSStacey Son } else { 51ea1ab4cfSStacey Son idx = R_FS; 52ea1ab4cfSStacey Son } 53ea1ab4cfSStacey Son val = env->segs[idx].base; 54ea1ab4cfSStacey Son if (put_user(val, parms, abi_ulong)) { 55ea1ab4cfSStacey Son return -TARGET_EFAULT; 56ea1ab4cfSStacey Son } 57ea1ab4cfSStacey Son break; 58ea1ab4cfSStacey Son 59ea1ab4cfSStacey Son /* XXX handle the others... */ 60ea1ab4cfSStacey Son default: 61ea1ab4cfSStacey Son ret = -TARGET_EINVAL; 62ea1ab4cfSStacey Son break; 63ea1ab4cfSStacey Son } 64ea1ab4cfSStacey Son return ret; 65ea1ab4cfSStacey Son } 66ea1ab4cfSStacey Son 67ea1ab4cfSStacey Son static inline void do_freebsd_arch_print_sysarch( 68ea1ab4cfSStacey Son const struct syscallname *name, abi_long arg1, abi_long arg2, 69ea1ab4cfSStacey Son abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) 70ea1ab4cfSStacey Son { 71ea1ab4cfSStacey Son 72ea1ab4cfSStacey Son gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", " 73ea1ab4cfSStacey Son TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4); 74ea1ab4cfSStacey Son } 75ea1ab4cfSStacey Son 76*52581c71SMarkus Armbruster #endif /* TARGET_ARCH_SYSARCH_H */ 77