xref: /openbmc/qemu/target/arm/tcg/arm_ldst.h (revision c4601322)
1*c4601322SRichard Henderson /*
2*c4601322SRichard Henderson  * ARM load/store instructions for code (armeb-user support)
3*c4601322SRichard Henderson  *
4*c4601322SRichard Henderson  *  Copyright (c) 2012 CodeSourcery, LLC
5*c4601322SRichard Henderson  *
6*c4601322SRichard Henderson  * This library is free software; you can redistribute it and/or
7*c4601322SRichard Henderson  * modify it under the terms of the GNU Lesser General Public
8*c4601322SRichard Henderson  * License as published by the Free Software Foundation; either
9*c4601322SRichard Henderson  * version 2.1 of the License, or (at your option) any later version.
10*c4601322SRichard Henderson  *
11*c4601322SRichard Henderson  * This library is distributed in the hope that it will be useful,
12*c4601322SRichard Henderson  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13*c4601322SRichard Henderson  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14*c4601322SRichard Henderson  * Lesser General Public License for more details.
15*c4601322SRichard Henderson  *
16*c4601322SRichard Henderson  * You should have received a copy of the GNU Lesser General Public
17*c4601322SRichard Henderson  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18*c4601322SRichard Henderson  */
19*c4601322SRichard Henderson 
20*c4601322SRichard Henderson #ifndef ARM_LDST_H
21*c4601322SRichard Henderson #define ARM_LDST_H
22*c4601322SRichard Henderson 
23*c4601322SRichard Henderson #include "exec/translator.h"
24*c4601322SRichard Henderson #include "qemu/bswap.h"
25*c4601322SRichard Henderson 
26*c4601322SRichard Henderson /* Load an instruction and return it in the standard little-endian order */
arm_ldl_code(CPUARMState * env,DisasContextBase * s,target_ulong addr,bool sctlr_b)27*c4601322SRichard Henderson static inline uint32_t arm_ldl_code(CPUARMState *env, DisasContextBase *s,
28*c4601322SRichard Henderson                                     target_ulong addr, bool sctlr_b)
29*c4601322SRichard Henderson {
30*c4601322SRichard Henderson     return translator_ldl_swap(env, s, addr, bswap_code(sctlr_b));
31*c4601322SRichard Henderson }
32*c4601322SRichard Henderson 
33*c4601322SRichard Henderson /* Ditto, for a halfword (Thumb) instruction */
arm_lduw_code(CPUARMState * env,DisasContextBase * s,target_ulong addr,bool sctlr_b)34*c4601322SRichard Henderson static inline uint16_t arm_lduw_code(CPUARMState *env, DisasContextBase* s,
35*c4601322SRichard Henderson                                      target_ulong addr, bool sctlr_b)
36*c4601322SRichard Henderson {
37*c4601322SRichard Henderson #ifndef CONFIG_USER_ONLY
38*c4601322SRichard Henderson     /* In big-endian (BE32) mode, adjacent Thumb instructions have been swapped
39*c4601322SRichard Henderson        within each word.  Undo that now.  */
40*c4601322SRichard Henderson     if (sctlr_b) {
41*c4601322SRichard Henderson         addr ^= 2;
42*c4601322SRichard Henderson     }
43*c4601322SRichard Henderson #endif
44*c4601322SRichard Henderson     return translator_lduw_swap(env, s, addr, bswap_code(sctlr_b));
45*c4601322SRichard Henderson }
46*c4601322SRichard Henderson 
47*c4601322SRichard Henderson #endif
48