xref: /openbmc/qemu/linux-user/arm/target_cpu.h (revision f00506aeca2f6d92318967693f8da8c713c163f3)
16291ad77SPeter Maydell /*
26291ad77SPeter Maydell  * ARM specific CPU ABI and functions for linux-user
36291ad77SPeter Maydell  *
46291ad77SPeter Maydell  * Copyright (c) 2003 Fabrice Bellard
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
91c79145fSChetan 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 ARM_TARGET_CPU_H
2055c5063cSMarkus Armbruster #define ARM_TARGET_CPU_H
216291ad77SPeter Maydell 
arm_max_reserved_va(CPUState * cs)220b689da3SRichard Henderson static inline unsigned long arm_max_reserved_va(CPUState *cs)
230b689da3SRichard Henderson {
240b689da3SRichard Henderson     ARMCPU *cpu = ARM_CPU(cs);
250b689da3SRichard Henderson 
260b689da3SRichard Henderson     if (arm_feature(&cpu->env, ARM_FEATURE_M)) {
270b689da3SRichard Henderson         /*
280b689da3SRichard Henderson          * There are magic return addresses above 0xfe000000,
290b689da3SRichard Henderson          * and in general a lot of M-profile system stuff in
300b689da3SRichard Henderson          * the high addresses.  Restrict linux-user to the
310b689da3SRichard Henderson          * cached write-back RAM in the system map.
320b689da3SRichard Henderson          */
33*95059f9cSRichard Henderson         return 0x7ffffffful;
340b689da3SRichard Henderson     } else {
350b689da3SRichard Henderson         /*
360b689da3SRichard Henderson          * We need to be able to map the commpage.
37fbd3c4cfSRichard Henderson          * See init_guest_commpage in linux-user/elfload.c.
380b689da3SRichard Henderson          */
39fbd3c4cfSRichard Henderson         return 0xfffffffful;
400b689da3SRichard Henderson     }
410b689da3SRichard Henderson }
420b689da3SRichard Henderson #define MAX_RESERVED_VA  arm_max_reserved_va
4318e80c55SRichard Henderson 
cpu_clone_regs_child(CPUARMState * env,target_ulong newsp,unsigned flags)44608999d1SRichard Henderson static inline void cpu_clone_regs_child(CPUARMState *env, target_ulong newsp,
45608999d1SRichard Henderson                                         unsigned flags)
466291ad77SPeter Maydell {
476291ad77SPeter Maydell     if (newsp) {
486291ad77SPeter Maydell         env->regs[13] = newsp;
496291ad77SPeter Maydell     }
506291ad77SPeter Maydell     env->regs[0] = 0;
516291ad77SPeter Maydell }
526291ad77SPeter Maydell 
cpu_clone_regs_parent(CPUARMState * env,unsigned flags)5307a6ecf4SRichard Henderson static inline void cpu_clone_regs_parent(CPUARMState *env, unsigned flags)
5407a6ecf4SRichard Henderson {
5507a6ecf4SRichard Henderson }
5607a6ecf4SRichard Henderson 
cpu_set_tls(CPUARMState * env,target_ulong newtls)576291ad77SPeter Maydell static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls)
586291ad77SPeter Maydell {
59b8d43285SMikhail Ilyin     if (access_secure_reg(env)) {
60b8d43285SMikhail Ilyin         env->cp15.tpidruro_s = newtls;
61b8d43285SMikhail Ilyin     } else {
6254bf36edSFabian Aggeler         env->cp15.tpidrro_el[0] = newtls;
636291ad77SPeter Maydell     }
64b8d43285SMikhail Ilyin }
65b8d43285SMikhail Ilyin 
cpu_get_tls(CPUARMState * env)66b8d43285SMikhail Ilyin static inline target_ulong cpu_get_tls(CPUARMState *env)
67b8d43285SMikhail Ilyin {
68b8d43285SMikhail Ilyin     if (access_secure_reg(env)) {
69b8d43285SMikhail Ilyin         return env->cp15.tpidruro_s;
70b8d43285SMikhail Ilyin     } else {
71b8d43285SMikhail Ilyin         return env->cp15.tpidrro_el[0];
72b8d43285SMikhail Ilyin     }
73b8d43285SMikhail Ilyin }
746291ad77SPeter Maydell 
get_sp_from_cpustate(CPUARMState * state)759850f9f6SLaurent Vivier static inline abi_ulong get_sp_from_cpustate(CPUARMState *state)
769850f9f6SLaurent Vivier {
779850f9f6SLaurent Vivier    return state->regs[13];
789850f9f6SLaurent Vivier }
796291ad77SPeter Maydell #endif
80