From: "Alex Bennée" <alex.bennee@linaro.org>
To: Stacey Son <sson@FreeBSD.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 04/18] bsd-user: move target arch and host OSdependent code out of main.cc
Date: Wed, 16 Oct 2013 16:38:12 +0100 [thread overview]
Message-ID: <p138o1jkez.fsf@linaro.org> (raw)
In-Reply-To: <1381934232-55158-5-git-send-email-sson@FreeBSD.org>
sson@FreeBSD.org writes:
> This change moves the cpu initialization and main loop code from
> main.c to the OS and arch dependent directories. This eliminates
> many of the #ifdef's in main.c. The cpu initialization and loop
> code is now located in the arch directory along with target arch
> support code.
>
> Signed-off-by: Stacey Son <sson@FreeBSD.org>
<snip>
> +#if 0
> + TaskState *ts = env->opaque;
> + uint32_t opcode;
> + int rc;
> +
> + /* we handle the FPU emulation here, as Linux */
> + /* we get the opcode */
> + /* FIXME - what to do if get_user() fails? */
> + get_user_u32(opcode, env->regs[15]);
> +
> + rc = EmulateAll(opcode, &ts->fpa, env);
> + if (rc == 0) { /* illegal instruction */
> + info.si_signo = SIGILL;
> + info.si_errno = 0;
> + info.si_code = TARGET_ILL_ILLOPN;
> + info._sifields._sigfault._addr = env->regs[15];
> + queue_signal(env, info.si_signo, &info);
> +
> + } else if (rc < 0) { /* FP exception */
> + int arm_fpe = 0;
> +
> + /* translate softfloat flags to FPSR flags */
> + if (-rc & float_flag_invalid) {
> + arm_fpe |= BIT_IOC;
> + }
> + if (-rc & float_flag_divbyzero) {
> + arm_fpe |= BIT_DZC;
> + }
> + if (-rc & float_flag_overflow) {
> + arm_fpe |= BIT_OFC;
> + }
> + if (-rc & float_flag_underflow) {
> + arm_fpe |= BIT_UFC;
> + }
> + if (-rc & float_flag_inexact) {
> + arm_fpe |= BIT_IXC;
> + }
> +
> + FPSR fpsr = ts->fpa.fpsr;
> + /* printf("fpsr 0x%x, arm_fpe 0x%x\n",fpsr,arm_fpe); */
> +
> + if (fpsr & (arm_fpe << 16)) { /* exception enabled? */
> + info.si_signo = SIGFPE;
> + info.si_errno = 0;
> +
> + /* ordered by priority, least first */
> + if (arm_fpe & BIT_IXC) {
> + info.si_code = TARGET_FPE_FLTRES;
> + }
> + if (arm_fpe & BIT_UFC) {
> + info.si_code = TARGET_FPE_FLTUND;
> + }
> + if (arm_fpe & BIT_OFC) {
> + info.si_code = TARGET_FPE_FLTOVF;
> + }
> + if (arm_fpe & BIT_DZC) {
> + info.si_code = TARGET_FPE_FLTDIV;
> + }
> + if (arm_fpe & BIT_IOC) {
> + info.si_code = TARGET_FPE_FLTINV;
> + }
> + info._sifields._sigfault._addr = env->regs[15];
> + queue_signal(env, info.si_signo, &info);
> + } else {
> + env->regs[15] += 4;
> + }
> +
> + /* accumulate unenabled exceptions */
> + if ((!(fpsr & BIT_IXE)) && (arm_fpe & BIT_IXC)) {
> + fpsr |= BIT_IXC;
> + }
> + if ((!(fpsr & BIT_UFE)) && (arm_fpe & BIT_UFC)) {
> + fpsr |= BIT_UFC;
> + }
> + if ((!(fpsr & BIT_OFE)) && (arm_fpe & BIT_OFC)) {
> + fpsr |= BIT_OFC;
> + }
> + if ((!(fpsr & BIT_DZE)) && (arm_fpe & BIT_DZC)) {
> + fpsr |= BIT_DZC;
> + }
> + if ((!(fpsr & BIT_IOE)) && (arm_fpe & BIT_IOC)) {
> + fpsr |= BIT_IOC;
> + }
> + ts->fpa.fpsr = fpsr;
> + } else { /* everything OK */
> + /* increment PC */
> + env->regs[15] += 4;
> + }
> + }
> +#endif
I'm fairly sure that should either be deleted or re-instated. We have
SCMs for a reason ;-)
> + break;
> + case EXCP_SWI:
> + case EXCP_BKPT:
> + {
> + env->eabi = 1;
> + /* system call */
> + if (trapnr == EXCP_BKPT) {
> + if (env->thumb) {
> + /* FIXME - what to do if get_user() fails? */
> +#ifdef FREEBSD_ARM_OABI
> + get_user_u16(insn, env->regs[15]);
> + n = insn & 0xff;
> +#else
> + n = env->regs[7];
> +#endif
> + env->regs[15] += 2;
> + } else {
> + /* FIXME - what to do if get_user() fails? */
> +#ifdef FREEBSD_ARM_OABI
> + get_user_u32(insn, env->regs[15]);
> + n = (insn & 0xf) | ((insn >> 4) & 0xff0);
> +#else
> + n = env->regs[7];
> +#endif
> + env->regs[15] += 4;
> + }
> + } else {
> + if (env->thumb) {
> +#ifdef FREEBSD_ARM_OABI
> + /* FIXME - what to do if get_user() fails? */
> + get_user_u16(insn, env->regs[15] - 2);
> + n = insn & 0xff;
> +#else
> + n = env->regs[7];
> +#endif
> + } else {
> +#ifdef FREEBSD_ARM_OABI
> + /* FIXME - what to do if get_user() fails? */
> + get_user_u32(insn, env->regs[15] - 4);
> + n = insn & 0xffffff;
> +#else
> + n = env->regs[7];
> +#endif
> + }
> + }
> +
> +#ifdef DEBUG_ARM
> + printf("AVANT CALL %d\n", n);
> +#endif
I think debug statements (rather than user visible logging) should
generally be wrapped up in a macro.
> + if (bsd_type == target_freebsd) {
> + int ret;
> + abi_ulong params = get_sp_from_cpustate(env);
> + int32_t syscall_nr = n;
> + int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8;
> +
Another #if 0, there are several more in the patch.
> +#if 0 /* XXX FIXME */
<snip>
> +static inline abi_ulong get_sp_from_cpustate(CPUARMState *state)
> +{
> + return state->regs[13]; /* sp */
> +}
> +
> +static inline void set_second_rval(CPUARMState *state, abi_ulong retval2)
> +{
> + state->regs[1] = retval2;
> +}
It's a shame ARM hasn't got some un-ambigious #define's for registers
<snip>
More #if 0's
> +#if 0
> + case EXCP0B_NOSEG:
> + case EXCP0C_STACK:
<snip>
--
Alex Bennée
next prev parent reply other threads:[~2013-10-16 15:38 UTC|newest]
Thread overview: 95+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-16 14:36 [Qemu-devel] [PATCH 00/18] bsd-user: Add system call and mips/arm support Stacey Son
2013-10-16 14:36 ` [Qemu-devel] [PATCH 01/18] bsd-user: refresh freebsd system call numbers Stacey Son
2013-10-24 1:22 ` Ed Maste
2013-10-16 14:36 ` [Qemu-devel] [PATCH 02/18] bsd-user: add HOST_ABI_DIR for the various *BSD dependent code Stacey Son
2013-10-16 14:36 ` [Qemu-devel] [PATCH 03/18] bsd-user: move OS/arch dependent code for strace into separate directories Stacey Son
2013-10-16 14:36 ` [Qemu-devel] [PATCH 04/18] bsd-user: move target arch and host OS dependent code out of main.c Stacey Son
2013-10-16 15:38 ` Alex Bennée [this message]
2013-10-16 15:46 ` [Qemu-devel] [PATCH 04/18] bsd-user: move target arch and host OSdependent code out of main.cc Stacey Son
2013-10-16 16:32 ` Peter Maydell
2013-10-17 19:07 ` Stacey Son
2013-10-16 14:36 ` [Qemu-devel] [PATCH 05/18] bsd-user: move target arch and host OS dependent code out of syscall.c Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 06/18] bsd-user: add support for freebsd time related system calls Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 07/18] bsd-user: add support for freebsd signal " Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 08/18] bsd-user: move target arch and host OS dependent code out of elfload.c Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 09/18] bsd-user: add support for freebsd process related system calls Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 10/18] bsd-user: add support for file system " Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 11/18] bsd-user: add support for stat, directory, and file control " Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 12/18] bsd-user: add support for memory management " Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 13/18] bsd-user: add support for socket " Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 14/18] bsd-user: add support for thread " Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 15/18] bsd-user: add support for the ioctl system call Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 16/18] bsd-user: add support for extended attribute and ACL related syscalls Stacey Son
2014-01-27 20:11 ` Peter Maydell
2013-10-16 14:37 ` [Qemu-devel] [PATCH 17/18] bsd-user: add support for miscellaneous system calls Stacey Son
2013-10-16 14:37 ` [Qemu-devel] [PATCH 18/18] bsd-user: add arm, mips and mips64 options to configure target-list Stacey Son
2013-10-16 15:22 ` [Qemu-devel] [PATCH 18/18] bsd-user: add arm, mips and mips64 options to configure target-listt Alex Bennée
2013-10-16 16:12 ` Stacey Son
2013-10-16 16:31 ` Peter Maydell
2013-10-16 16:26 ` [Qemu-devel] [PATCH 18/18] bsd-user: add arm, mips and mips64 options to configure target-list Peter Maydell
2013-10-16 15:27 ` [Qemu-devel] [PATCH 00/18] bsd-user: Add system call and mips/armsupport Alex Bennée
2013-10-16 15:40 ` Stacey Son
2013-10-16 16:29 ` [Qemu-devel] [PATCH 00/18] bsd-user: Add system call and mips/arm support Peter Maydell
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 00/19] " Stacey Son
2013-11-26 21:01 ` Ed Maste
2013-11-27 11:29 ` Paolo Bonzini
2013-12-12 19:57 ` Ed Maste
2013-12-12 20:15 ` Stacey Son
2013-12-13 12:44 ` Paolo Bonzini
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 " Stacey Son
2014-01-27 19:15 ` Peter Maydell
2014-01-27 19:27 ` Stacey Son
2014-01-27 20:18 ` Peter Maydell
2014-05-08 14:59 ` Peter Maydell
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 01/19] bsd-user: refresh freebsd system call numbers Stacey Son
2014-01-27 19:30 ` Peter Maydell
2014-02-01 12:11 ` Ed Maste
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 02/19] bsd-user: add HOST_VARIANT_DIR for various *BSD dependent code Stacey Son
2014-01-27 19:31 ` Peter Maydell
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 03/19] bsd-user: move strace OS/arch dependent code to host/arch dirs Stacey Son
2014-01-27 19:46 ` Peter Maydell
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 04/19] bsd-user: move arch/OS dependent code out of main.c Stacey Son
2014-01-27 19:50 ` Peter Maydell
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 05/19] bsd-user: move arch/OS dependent code out of syscall.c Stacey Son
2014-01-27 19:52 ` Peter Maydell
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 06/19] bsd-user: add support for freebsd time related system calls Stacey Son
2014-01-27 19:58 ` Peter Maydell
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 07/19] bsd-user: add support for freebsd signal " Stacey Son
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 08/19] bsd-user: move arch/OS dependent code out of elfload.c Stacey Son
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 09/19] bsd-user: add support for freebsd process related system calls Stacey Son
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 10/19] bsd-user: add support for file system " Stacey Son
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 11/19] bsd-user: add support for stat, dir, and fcntl related syscalls Stacey Son
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 12/19] bsd-user: add support for memory management " Stacey Son
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 13/19] bsd-user: add support for socket related system calls Stacey Son
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 14/19] bsd-user: add support for thread " Stacey Son
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 15/19] bsd-user: add support for the ioctl system call Stacey Son
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 16/19] bsd-user: add support for extattr and ACL related syscalls Stacey Son
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 17/19] bsd-user: add support for miscellaneous system calls Stacey Son
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 18/19] bsd-user: add arm, mips and mips64 options to configure target-list Stacey Son
2014-01-27 20:03 ` Peter Maydell
2013-12-17 11:52 ` [Qemu-devel] [PATCH v3 19/19] bsd-user: fix linking conflicts with FreeBSD libcrypto Stacey Son
2014-01-27 20:07 ` Peter Maydell
2014-01-27 20:15 ` Stacey Son
2014-01-28 10:17 ` Paolo Bonzini
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 01/19] bsd-user: refresh freebsd system call numbers Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 02/19] bsd-user: add HOST_ABI_DIR for the various *BSD dependent code Stacey Son
2013-11-27 11:27 ` Paolo Bonzini
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 03/19] bsd-user: move OS/arch dependent code for strace into separate directories Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 04/19] bsd-user: move target arch and host OS dependent code out of main.c Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 05/19] bsd-user: move target arch and host OS dependent code out of syscall.c Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 06/19] bsd-user: add support for freebsd time related system calls Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 07/19] bsd-user: add support for freebsd signal " Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 08/19] bsd-user: move target arch and host OS dependent code out of elfload.c Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 09/19] bsd-user: add support for freebsd process related system calls Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 10/19] bsd-user: add support for file system " Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 11/19] bsd-user: add support for stat, directory, and file control " Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 12/19] bsd-user: add support for memory management " Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 13/19] bsd-user: add support for socket " Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 14/19] bsd-user: add support for thread " Stacey Son
2013-11-27 11:28 ` Paolo Bonzini
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 15/19] bsd-user: add support for the ioctl system call Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 16/19] bsd-user: add support for extended attribute and ACL related syscalls Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 17/19] bsd-user: add support for miscellaneous system calls Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 18/19] bsd-user: add arm, mips and mips64 options to configure target-list Stacey Son
2013-11-08 16:33 ` [Qemu-devel] [PATCH v2 19/19] bsd-user: fix linking conflicts with FreeBSD libcrypto Stacey Son
2013-11-27 11:23 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=p138o1jkez.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=sson@FreeBSD.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.