Merge remote-tracking branch 'remotes/philmd/tags/mips-20210502' into staging
[qemu/ar7.git] / linux-user / sparc / target_cpu.h
blob1fa1011775a1ea95b108ce97e15710a9bd2fa78f
1 /*
2 * SPARC specific CPU ABI and functions for linux-user
4 * Copyright (C) 2003 Thomas M. Ogrisegg <tom@fnord.at>
5 * Copyright (C) 2003-2005 Fabrice Bellard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef SPARC_TARGET_CPU_H
21 #define SPARC_TARGET_CPU_H
23 static inline void cpu_clone_regs_child(CPUSPARCState *env, target_ulong newsp,
24 unsigned flags)
27 * After cpu_copy, env->regwptr is pointing into the old env.
28 * Update the new cpu to use its own register window.
30 env->regwptr = env->regbase + (env->cwp * 16);
32 if (newsp) {
33 /* When changing stacks, do it with clean register windows. */
34 #ifdef TARGET_SPARC64
35 env->cansave = env->nwindows - 2;
36 env->cleanwin = env->nwindows - 2;
37 env->canrestore = 0;
38 #else
39 env->wim = 1 << env->cwp;
40 #endif
41 /* ??? The kernel appears to copy one stack frame to the new stack. */
42 /* ??? The kernel force aligns the new stack. */
43 env->regwptr[WREG_SP] = newsp;
46 if (flags & CLONE_VM) {
48 * Syscall return for clone child: %o0 = 0 and clear CF since this
49 * counts as a success return value. Advance the PC past the syscall.
50 * For fork child, all of this happens in cpu_loop, and we must not
51 * do the pc advance twice.
53 env->regwptr[WREG_O0] = 0;
54 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
55 env->xcc &= ~PSR_CARRY;
56 #else
57 env->psr &= ~PSR_CARRY;
58 #endif
59 env->pc = env->npc;
60 env->npc = env->npc + 4;
63 /* Set the second return value for the child: %o1 = 1. */
64 env->regwptr[WREG_O1] = 1;
67 static inline void cpu_clone_regs_parent(CPUSPARCState *env, unsigned flags)
69 /* Set the second return value for the parent: %o1 = 0. */
70 env->regwptr[WREG_O1] = 0;
73 static inline void cpu_set_tls(CPUSPARCState *env, target_ulong newtls)
75 env->gregs[7] = newtls;
78 static inline abi_ulong get_sp_from_cpustate(CPUSPARCState *state)
80 return state->regwptr[WREG_SP];
83 #endif