bsd-user/sysarch: Move to using do_freebsd_arch_sysarch interface
do_freebsd_arch_sysarch() exists in $ARCH/target_arch_sysarch.h for x86. Call it from do_freebsd_sysarch() and remove the mostly duplicate version in syscall.c. Future changes will move it to os-sys.c and support other architectures. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
This commit is contained in:
parent
653ccec26d
commit
da07e6944f
3
bsd-user/freebsd/meson.build
Normal file
3
bsd-user/freebsd/meson.build
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
bsd_user_ss.add(files(
|
||||||
|
'os-sys.c',
|
||||||
|
))
|
27
bsd-user/freebsd/os-sys.c
Normal file
27
bsd-user/freebsd/os-sys.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* FreeBSD sysctl() and sysarch() system call emulation
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-15 Stacey D. Son
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qemu.h"
|
||||||
|
#include "target_arch_sysarch.h"
|
||||||
|
|
||||||
|
/* sysarch() is architecture dependent. */
|
||||||
|
abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2)
|
||||||
|
{
|
||||||
|
return do_freebsd_arch_sysarch(cpu_env, arg1, arg2);
|
||||||
|
}
|
@ -12,3 +12,6 @@ bsd_user_ss.add(files(
|
|||||||
'syscall.c',
|
'syscall.c',
|
||||||
'uaccess.c',
|
'uaccess.c',
|
||||||
))
|
))
|
||||||
|
|
||||||
|
# Pull in the OS-specific build glue, if any
|
||||||
|
subdir(targetos)
|
||||||
|
@ -239,6 +239,9 @@ extern unsigned long target_sgrowsiz;
|
|||||||
abi_long get_errno(abi_long ret);
|
abi_long get_errno(abi_long ret);
|
||||||
bool is_error(abi_long ret);
|
bool is_error(abi_long ret);
|
||||||
|
|
||||||
|
/* os-sys.c */
|
||||||
|
abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2);
|
||||||
|
|
||||||
/* user access */
|
/* user access */
|
||||||
|
|
||||||
#define VERIFY_READ PAGE_READ
|
#define VERIFY_READ PAGE_READ
|
||||||
|
@ -88,56 +88,6 @@ static abi_long do_obreak(abi_ulong new_brk)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TARGET_I386)
|
|
||||||
static abi_long do_freebsd_sysarch(CPUX86State *env, int op, abi_ulong parms)
|
|
||||||
{
|
|
||||||
abi_long ret = 0;
|
|
||||||
abi_ulong val;
|
|
||||||
int idx;
|
|
||||||
|
|
||||||
switch (op) {
|
|
||||||
#ifdef TARGET_ABI32
|
|
||||||
case TARGET_FREEBSD_I386_SET_GSBASE:
|
|
||||||
case TARGET_FREEBSD_I386_SET_FSBASE:
|
|
||||||
if (op == TARGET_FREEBSD_I386_SET_GSBASE)
|
|
||||||
#else
|
|
||||||
case TARGET_FREEBSD_AMD64_SET_GSBASE:
|
|
||||||
case TARGET_FREEBSD_AMD64_SET_FSBASE:
|
|
||||||
if (op == TARGET_FREEBSD_AMD64_SET_GSBASE)
|
|
||||||
#endif
|
|
||||||
idx = R_GS;
|
|
||||||
else
|
|
||||||
idx = R_FS;
|
|
||||||
if (get_user(val, parms, abi_ulong))
|
|
||||||
return -TARGET_EFAULT;
|
|
||||||
cpu_x86_load_seg(env, idx, 0);
|
|
||||||
env->segs[idx].base = val;
|
|
||||||
break;
|
|
||||||
#ifdef TARGET_ABI32
|
|
||||||
case TARGET_FREEBSD_I386_GET_GSBASE:
|
|
||||||
case TARGET_FREEBSD_I386_GET_FSBASE:
|
|
||||||
if (op == TARGET_FREEBSD_I386_GET_GSBASE)
|
|
||||||
#else
|
|
||||||
case TARGET_FREEBSD_AMD64_GET_GSBASE:
|
|
||||||
case TARGET_FREEBSD_AMD64_GET_FSBASE:
|
|
||||||
if (op == TARGET_FREEBSD_AMD64_GET_GSBASE)
|
|
||||||
#endif
|
|
||||||
idx = R_GS;
|
|
||||||
else
|
|
||||||
idx = R_FS;
|
|
||||||
val = env->segs[idx].base;
|
|
||||||
if (put_user(val, parms, abi_ulong))
|
|
||||||
return -TARGET_EFAULT;
|
|
||||||
break;
|
|
||||||
/* XXX handle the others... */
|
|
||||||
default:
|
|
||||||
ret = -TARGET_EINVAL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
/*
|
/*
|
||||||
* XXX this uses the undocumented oidfmt interface to find the kind of
|
* XXX this uses the undocumented oidfmt interface to find the kind of
|
||||||
|
Loading…
Reference in New Issue
Block a user