]> git.proxmox.com Git - mirror_qemu.git/blame - linux-user/sparc/target_cpu.h
hw/riscv: spike: Remove misleading comments
[mirror_qemu.git] / linux-user / sparc / target_cpu.h
CommitLineData
6291ad77
PM
1/*
2 * SPARC specific CPU ABI and functions for linux-user
3 *
4 * Copyright (C) 2003 Thomas M. Ogrisegg <tom@fnord.at>
5 * Copyright (C) 2003-2005 Fabrice Bellard
6 *
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
1c79145f 10 * version 2.1 of the License, or (at your option) any later version.
6291ad77
PM
11 *
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.
16 *
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/>.
19 */
55c5063c
MA
20#ifndef SPARC_TARGET_CPU_H
21#define SPARC_TARGET_CPU_H
6291ad77 22
eb215f40
RH
23#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
24# define TARGET_STACK_BIAS 2047
25#else
26# define TARGET_STACK_BIAS 0
27#endif
28
608999d1
RH
29static inline void cpu_clone_regs_child(CPUSPARCState *env, target_ulong newsp,
30 unsigned flags)
6291ad77 31{
2ad983e0
RH
32 /*
33 * After cpu_copy, env->regwptr is pointing into the old env.
34 * Update the new cpu to use its own register window.
35 */
36 env->regwptr = env->regbase + (env->cwp * 16);
37
6291ad77 38 if (newsp) {
2ad983e0
RH
39 /* When changing stacks, do it with clean register windows. */
40#ifdef TARGET_SPARC64
41 env->cansave = env->nwindows - 2;
42 env->cleanwin = env->nwindows - 2;
43 env->canrestore = 0;
44#else
45 env->wim = 1 << env->cwp;
46#endif
47 /* ??? The kernel appears to copy one stack frame to the new stack. */
48 /* ??? The kernel force aligns the new stack. */
eb215f40 49 /* Userspace provides a biased stack pointer value. */
2ad983e0 50 env->regwptr[WREG_SP] = newsp;
6291ad77 51 }
2ad983e0
RH
52
53 if (flags & CLONE_VM) {
54 /*
55 * Syscall return for clone child: %o0 = 0 and clear CF since this
56 * counts as a success return value. Advance the PC past the syscall.
57 * For fork child, all of this happens in cpu_loop, and we must not
58 * do the pc advance twice.
59 */
60 env->regwptr[WREG_O0] = 0;
f5147c93 61#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
2ad983e0 62 env->xcc &= ~PSR_CARRY;
f5147c93 63#else
2ad983e0 64 env->psr &= ~PSR_CARRY;
f5147c93 65#endif
2ad983e0
RH
66 env->pc = env->npc;
67 env->npc = env->npc + 4;
68 }
69
70 /* Set the second return value for the child: %o1 = 1. */
71 env->regwptr[WREG_O1] = 1;
6291ad77
PM
72}
73
07a6ecf4
RH
74static inline void cpu_clone_regs_parent(CPUSPARCState *env, unsigned flags)
75{
2ad983e0
RH
76 /* Set the second return value for the parent: %o1 = 0. */
77 env->regwptr[WREG_O1] = 0;
07a6ecf4
RH
78}
79
f5147c93
PM
80static inline void cpu_set_tls(CPUSPARCState *env, target_ulong newtls)
81{
82 env->gregs[7] = newtls;
83}
6291ad77 84
9850f9f6
LV
85static inline abi_ulong get_sp_from_cpustate(CPUSPARCState *state)
86{
eb215f40 87 return state->regwptr[WREG_SP] + TARGET_STACK_BIAS;
9850f9f6 88}
083244d3 89
6291ad77 90#endif