Skip to content

Commit

Permalink
linux-user: Move cpu_clone_regs() and cpu_set_tls() into linux-user
Browse files Browse the repository at this point in the history
The functions cpu_clone_regs() and cpu_set_tls() are not purely CPU
related -- they are specific to the TLS ABI for a a particular OS.
Move them into the linux-user/ tree where they belong.

target-lm32 had entirely unused implementations, since it has no
linux-user target; just drop them.

Signed-off-by: Peter Maydell <[email protected]>
Acked-by: Richard Henderson <[email protected]>
Signed-off-by: Andreas Färber <[email protected]>
  • Loading branch information
pm215 authored and afaerber committed Jul 9, 2013
1 parent aa48dd9 commit 6291ad7
Show file tree
Hide file tree
Showing 31 changed files with 460 additions and 188 deletions.
36 changes: 36 additions & 0 deletions linux-user/alpha/target_cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Alpha specific CPU ABI and functions for linux-user
*
* Copyright (c) 2007 Jocelyn Mayer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TARGET_CPU_H
#define TARGET_CPU_H

static inline void cpu_clone_regs(CPUAlphaState *env, target_ulong newsp)
{
if (newsp) {
env->ir[IR_SP] = newsp;
}
env->ir[IR_V0] = 0;
env->ir[IR_A3] = 0;
}

static inline void cpu_set_tls(CPUAlphaState *env, target_ulong newtls)
{
env->unique = newtls;
}

#endif
35 changes: 35 additions & 0 deletions linux-user/arm/target_cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* ARM specific CPU ABI and functions for linux-user
*
* Copyright (c) 2003 Fabrice Bellard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TARGET_CPU_H
#define TARGET_CPU_H

static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp)
{
if (newsp) {
env->regs[13] = newsp;
}
env->regs[0] = 0;
}

static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls)
{
env->cp15.c13_tls2 = newtls;
}

#endif
36 changes: 36 additions & 0 deletions linux-user/cris/target_cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* CRIS specific CPU ABI and functions for linux-user
*
* Copyright (c) 2007 AXIS Communications AB
* Written by Edgar E. Iglesias
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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 Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TARGET_CPU_H
#define TARGET_CPU_H

static inline void cpu_clone_regs(CPUCRISState *env, target_ulong newsp)
{
if (newsp) {
env->regs[14] = newsp;
}
env->regs[10] = 0;
}

static inline void cpu_set_tls(CPUCRISState *env, target_ulong newtls)
{
env->pregs[PR_PID] = (env->pregs[PR_PID] & 0xff) | newtls;
}

#endif
33 changes: 33 additions & 0 deletions linux-user/i386/target_cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* i386 specific CPU ABI and functions for linux-user
*
* Copyright (c) 2003 Fabrice Bellard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef TARGET_CPU_H
#define TARGET_CPU_H

static inline void cpu_clone_regs(CPUX86State *env, target_ulong newsp)
{
if (newsp) {
env->regs[R_ESP] = newsp;
}
env->regs[R_EAX] = 0;
}

/* TODO: need to implement cpu_set_tls() */

#endif
34 changes: 34 additions & 0 deletions linux-user/m68k/target_cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* m68k specific CPU ABI and functions for linux-user
*
* Copyright (c) 2005-2007 CodeSourcery
* Written by Paul Brook
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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 Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef TARGET_CPU_H
#define TARGET_CPU_H

static inline void cpu_clone_regs(CPUM68KState *env, target_ulong newsp)
{
if (newsp) {
env->aregs[7] = newsp;
}
env->dregs[0] = 0;
}

/* TODO: need to implement cpu_set_tls() */

#endif
35 changes: 35 additions & 0 deletions linux-user/microblaze/target_cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* MicroBlaze specific CPU ABI and functions for linux-user
*
* Copyright (c) 2009 Edgar E. Iglesias
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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 Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TARGET_CPU_H
#define TARGET_CPU_H

static inline void cpu_clone_regs(CPUMBState *env, target_ulong newsp)
{
if (newsp) {
env->regs[R_SP] = newsp;
}
env->regs[3] = 0;
}

static inline void cpu_set_tls(CPUMBState *env, target_ulong newtls)
{
env->regs[21] = newtls;
}

#endif
36 changes: 36 additions & 0 deletions linux-user/mips/target_cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* MIPS specific CPU ABI and functions for linux-user
*
* Copyright (c) 2004-2005 Jocelyn Mayer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TARGET_CPU_H
#define TARGET_CPU_H

static inline void cpu_clone_regs(CPUMIPSState *env, target_ulong newsp)
{
if (newsp) {
env->active_tc.gpr[29] = newsp;
}
env->active_tc.gpr[7] = 0;
env->active_tc.gpr[2] = 0;
}

static inline void cpu_set_tls(CPUMIPSState *env, target_ulong newtls)
{
env->tls_value = newtls;
}

#endif
1 change: 1 addition & 0 deletions linux-user/mips64/target_cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../mips/target_cpu.h"
33 changes: 33 additions & 0 deletions linux-user/openrisc/target_cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* OpenRISC specific CPU ABI and functions for linux-user
*
* Copyright (c) 2011-2012 Jia Liu <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef TARGET_CPU_H
#define TARGET_CPU_H

static inline void cpu_clone_regs(CPUOpenRISCState *env, target_ulong newsp)
{
if (newsp) {
env->gpr[1] = newsp;
}
env->gpr[2] = 0;
}

/* TODO: need to implement cpu_set_tls() */

#endif
41 changes: 41 additions & 0 deletions linux-user/ppc/target_cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* PowerPC specific CPU ABI and functions for linux-user
*
* Copyright (c) 2003-2007 Jocelyn Mayer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TARGET_CPU_H
#define TARGET_CPU_H

static inline void cpu_clone_regs(CPUPPCState *env, target_ulong newsp)
{
if (newsp) {
env->gpr[1] = newsp;
}
env->gpr[3] = 0;
}

static inline void cpu_set_tls(CPUPPCState *env, target_ulong newtls)
{
#if defined(TARGET_PPC64)
/* The kernel checks TIF_32BIT here; we don't support loading 32-bit
binaries on PPC64 yet. */
env->gpr[13] = newtls;
#else
env->gpr[2] = newtls;
#endif
}

#endif
1 change: 1 addition & 0 deletions linux-user/qemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "exec/user/thunk.h"
#include "syscall_defs.h"
#include "syscall.h"
#include "target_cpu.h"
#include "target_signal.h"
#include "exec/gdbstub.h"
#include "qemu/queue.h"
Expand Down
39 changes: 39 additions & 0 deletions linux-user/s390x/target_cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* S/390 specific CPU ABI and functions for linux-user
*
* Copyright (c) 2009 Ulrich Hecht
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* Contributions after 2012-10-29 are licensed under the terms of the
* GNU GPL, version 2 or (at your option) any later version.
*
* You should have received a copy of the GNU (Lesser) General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TARGET_CPU_H
#define TARGET_CPU_H

static inline void cpu_clone_regs(CPUS390XState *env, target_ulong newsp)
{
if (newsp) {
env->regs[15] = newsp;
}
env->regs[2] = 0;
}

static inline void cpu_set_tls(CPUS390XState *env, target_ulong newtls)
{
env->aregs[0] = newtls >> 32;
env->aregs[1] = newtls & 0xffffffffULL;
}

#endif
Loading

0 comments on commit 6291ad7

Please sign in to comment.