Skip to content

Commit da07e69

Browse files
committed
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 <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Reviewed-by: Kyle Evans <[email protected]>
1 parent 653ccec commit da07e69

File tree

5 files changed

+36
-50
lines changed

5 files changed

+36
-50
lines changed

bsd-user/freebsd/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bsd_user_ss.add(files(
2+
'os-sys.c',
3+
))

bsd-user/freebsd/os-sys.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* FreeBSD sysctl() and sysarch() system call emulation
3+
*
4+
* Copyright (c) 2013-15 Stacey D. Son
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include "qemu.h"
21+
#include "target_arch_sysarch.h"
22+
23+
/* sysarch() is architecture dependent. */
24+
abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2)
25+
{
26+
return do_freebsd_arch_sysarch(cpu_env, arg1, arg2);
27+
}

bsd-user/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ bsd_user_ss.add(files(
1212
'syscall.c',
1313
'uaccess.c',
1414
))
15+
16+
# Pull in the OS-specific build glue, if any
17+
subdir(targetos)

bsd-user/qemu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ extern unsigned long target_sgrowsiz;
239239
abi_long get_errno(abi_long ret);
240240
bool is_error(abi_long ret);
241241

242+
/* os-sys.c */
243+
abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2);
244+
242245
/* user access */
243246

244247
#define VERIFY_READ PAGE_READ

bsd-user/syscall.c

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -88,56 +88,6 @@ static abi_long do_obreak(abi_ulong new_brk)
8888
return 0;
8989
}
9090

91-
#if defined(TARGET_I386)
92-
static abi_long do_freebsd_sysarch(CPUX86State *env, int op, abi_ulong parms)
93-
{
94-
abi_long ret = 0;
95-
abi_ulong val;
96-
int idx;
97-
98-
switch (op) {
99-
#ifdef TARGET_ABI32
100-
case TARGET_FREEBSD_I386_SET_GSBASE:
101-
case TARGET_FREEBSD_I386_SET_FSBASE:
102-
if (op == TARGET_FREEBSD_I386_SET_GSBASE)
103-
#else
104-
case TARGET_FREEBSD_AMD64_SET_GSBASE:
105-
case TARGET_FREEBSD_AMD64_SET_FSBASE:
106-
if (op == TARGET_FREEBSD_AMD64_SET_GSBASE)
107-
#endif
108-
idx = R_GS;
109-
else
110-
idx = R_FS;
111-
if (get_user(val, parms, abi_ulong))
112-
return -TARGET_EFAULT;
113-
cpu_x86_load_seg(env, idx, 0);
114-
env->segs[idx].base = val;
115-
break;
116-
#ifdef TARGET_ABI32
117-
case TARGET_FREEBSD_I386_GET_GSBASE:
118-
case TARGET_FREEBSD_I386_GET_FSBASE:
119-
if (op == TARGET_FREEBSD_I386_GET_GSBASE)
120-
#else
121-
case TARGET_FREEBSD_AMD64_GET_GSBASE:
122-
case TARGET_FREEBSD_AMD64_GET_FSBASE:
123-
if (op == TARGET_FREEBSD_AMD64_GET_GSBASE)
124-
#endif
125-
idx = R_GS;
126-
else
127-
idx = R_FS;
128-
val = env->segs[idx].base;
129-
if (put_user(val, parms, abi_ulong))
130-
return -TARGET_EFAULT;
131-
break;
132-
/* XXX handle the others... */
133-
default:
134-
ret = -TARGET_EINVAL;
135-
break;
136-
}
137-
return ret;
138-
}
139-
#endif
140-
14191
#ifdef __FreeBSD__
14292
/*
14393
* XXX this uses the undocumented oidfmt interface to find the kind of

0 commit comments

Comments
 (0)