16291ad77SPeter Maydell /*
26291ad77SPeter Maydell * PowerPC specific CPU ABI and functions for linux-user
36291ad77SPeter Maydell *
46291ad77SPeter Maydell * Copyright (c) 2003-2007 Jocelyn Mayer
56291ad77SPeter Maydell *
66291ad77SPeter Maydell * This library is free software; you can redistribute it and/or
76291ad77SPeter Maydell * modify it under the terms of the GNU Lesser General Public
86291ad77SPeter Maydell * License as published by the Free Software Foundation; either
9*1c79145fSChetan Pant * version 2.1 of the License, or (at your option) any later version.
106291ad77SPeter Maydell *
116291ad77SPeter Maydell * This library is distributed in the hope that it will be useful,
126291ad77SPeter Maydell * but WITHOUT ANY WARRANTY; without even the implied warranty of
136291ad77SPeter Maydell * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
146291ad77SPeter Maydell * Lesser General Public License for more details.
156291ad77SPeter Maydell *
166291ad77SPeter Maydell * You should have received a copy of the GNU Lesser General Public
176291ad77SPeter Maydell * License along with this library; if not, see <http://www.gnu.org/licenses/>.
186291ad77SPeter Maydell */
1955c5063cSMarkus Armbruster #ifndef PPC_TARGET_CPU_H
2055c5063cSMarkus Armbruster #define PPC_TARGET_CPU_H
216291ad77SPeter Maydell
cpu_clone_regs_child(CPUPPCState * env,target_ulong newsp,unsigned flags)22608999d1SRichard Henderson static inline void cpu_clone_regs_child(CPUPPCState *env, target_ulong newsp,
23608999d1SRichard Henderson unsigned flags)
246291ad77SPeter Maydell {
256291ad77SPeter Maydell if (newsp) {
266291ad77SPeter Maydell env->gpr[1] = newsp;
276291ad77SPeter Maydell }
286291ad77SPeter Maydell env->gpr[3] = 0;
296291ad77SPeter Maydell }
306291ad77SPeter Maydell
cpu_clone_regs_parent(CPUPPCState * env,unsigned flags)3107a6ecf4SRichard Henderson static inline void cpu_clone_regs_parent(CPUPPCState *env, unsigned flags)
3207a6ecf4SRichard Henderson {
3307a6ecf4SRichard Henderson }
3407a6ecf4SRichard Henderson
cpu_set_tls(CPUPPCState * env,target_ulong newtls)356291ad77SPeter Maydell static inline void cpu_set_tls(CPUPPCState *env, target_ulong newtls)
366291ad77SPeter Maydell {
376291ad77SPeter Maydell #if defined(TARGET_PPC64)
386291ad77SPeter Maydell /* The kernel checks TIF_32BIT here; we don't support loading 32-bit
396291ad77SPeter Maydell binaries on PPC64 yet. */
406291ad77SPeter Maydell env->gpr[13] = newtls;
416291ad77SPeter Maydell #else
426291ad77SPeter Maydell env->gpr[2] = newtls;
436291ad77SPeter Maydell #endif
446291ad77SPeter Maydell }
456291ad77SPeter Maydell
4667d6d829STom Musta #ifndef EF_PPC64_ABI
4767d6d829STom Musta #define EF_PPC64_ABI 0x3
4867d6d829STom Musta #endif
4967d6d829STom Musta
get_ppc64_abi(struct image_info * infop)5067d6d829STom Musta static inline uint32_t get_ppc64_abi(struct image_info *infop)
5167d6d829STom Musta {
5267d6d829STom Musta return infop->elf_flags & EF_PPC64_ABI;
5367d6d829STom Musta }
5467d6d829STom Musta
get_sp_from_cpustate(CPUPPCState * state)559850f9f6SLaurent Vivier static inline abi_ulong get_sp_from_cpustate(CPUPPCState *state)
569850f9f6SLaurent Vivier {
579850f9f6SLaurent Vivier return state->gpr[1];
589850f9f6SLaurent Vivier }
596291ad77SPeter Maydell #endif
60