xref: /openbmc/qemu/linux-user/i386/target_cpu.h (revision cb5ed407a1ddadf788fd373fed41c87c9e81e5b0)
16291ad77SPeter Maydell /*
26291ad77SPeter Maydell  * i386 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
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  */
196291ad77SPeter Maydell 
2055c5063cSMarkus Armbruster #ifndef I386_TARGET_CPU_H
2155c5063cSMarkus Armbruster #define I386_TARGET_CPU_H
226291ad77SPeter Maydell 
cpu_clone_regs_child(CPUX86State * env,target_ulong newsp,unsigned flags)23608999d1SRichard Henderson static inline void cpu_clone_regs_child(CPUX86State *env, target_ulong newsp,
24608999d1SRichard Henderson                                         unsigned flags)
256291ad77SPeter Maydell {
266291ad77SPeter Maydell     if (newsp) {
276291ad77SPeter Maydell         env->regs[R_ESP] = newsp;
286291ad77SPeter Maydell     }
296291ad77SPeter Maydell     env->regs[R_EAX] = 0;
306291ad77SPeter Maydell }
316291ad77SPeter Maydell 
cpu_clone_regs_parent(CPUX86State * env,unsigned flags)3207a6ecf4SRichard Henderson static inline void cpu_clone_regs_parent(CPUX86State *env, unsigned flags)
3307a6ecf4SRichard Henderson {
3407a6ecf4SRichard Henderson }
3507a6ecf4SRichard Henderson 
369d12f79dSLaurent Vivier abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr);
379d12f79dSLaurent Vivier 
38bc22eb44SAlexander Graf #if defined(TARGET_ABI32)
39bc22eb44SAlexander Graf abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr);
406291ad77SPeter Maydell 
cpu_set_tls(CPUX86State * env,target_ulong newtls)41bc22eb44SAlexander Graf static inline void cpu_set_tls(CPUX86State *env, target_ulong newtls)
42bc22eb44SAlexander Graf {
43bc22eb44SAlexander Graf     do_set_thread_area(env, newtls);
44bc22eb44SAlexander Graf     cpu_x86_load_seg(env, R_GS, env->segs[R_GS].selector);
45bc22eb44SAlexander Graf }
462667e71cSPeter Maydell #else
cpu_set_tls(CPUX86State * env,target_ulong newtls)472667e71cSPeter Maydell static inline void cpu_set_tls(CPUX86State *env, target_ulong newtls)
482667e71cSPeter Maydell {
492667e71cSPeter Maydell     do_arch_prctl(env, TARGET_ARCH_SET_FS, newtls);
502667e71cSPeter Maydell }
51bc22eb44SAlexander Graf #endif /* defined(TARGET_ABI32) */
52bc22eb44SAlexander Graf 
get_sp_from_cpustate(CPUX86State * state)539850f9f6SLaurent Vivier static inline abi_ulong get_sp_from_cpustate(CPUX86State *state)
549850f9f6SLaurent Vivier {
559850f9f6SLaurent Vivier     return state->regs[R_ESP];
569850f9f6SLaurent Vivier }
5755c5063cSMarkus Armbruster #endif /* I386_TARGET_CPU_H */
58