11d854765SPaolo Bonzini /*
21d854765SPaolo Bonzini * ARM load/store instructions for code (armeb-user support)
31d854765SPaolo Bonzini *
41d854765SPaolo Bonzini * Copyright (c) 2012 CodeSourcery, LLC
51d854765SPaolo Bonzini *
61d854765SPaolo Bonzini * This library is free software; you can redistribute it and/or
71d854765SPaolo Bonzini * modify it under the terms of the GNU Lesser General Public
81d854765SPaolo Bonzini * License as published by the Free Software Foundation; either
950f57e09SChetan Pant * version 2.1 of the License, or (at your option) any later version.
101d854765SPaolo Bonzini *
111d854765SPaolo Bonzini * This library is distributed in the hope that it will be useful,
121d854765SPaolo Bonzini * but WITHOUT ANY WARRANTY; without even the implied warranty of
131d854765SPaolo Bonzini * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
141d854765SPaolo Bonzini * Lesser General Public License for more details.
151d854765SPaolo Bonzini *
161d854765SPaolo Bonzini * You should have received a copy of the GNU Lesser General Public
171d854765SPaolo Bonzini * License along with this library; if not, see <http://www.gnu.org/licenses/>.
181d854765SPaolo Bonzini */
191d854765SPaolo Bonzini
201d854765SPaolo Bonzini #ifndef ARM_LDST_H
211d854765SPaolo Bonzini #define ARM_LDST_H
221d854765SPaolo Bonzini
23ae82adc8SEmilio G. Cota #include "exec/translator.h"
241d854765SPaolo Bonzini #include "qemu/bswap.h"
251d854765SPaolo Bonzini
261d854765SPaolo Bonzini /* 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)274e116893SIlya Leoshkevich static inline uint32_t arm_ldl_code(CPUARMState *env, DisasContextBase *s,
284e116893SIlya Leoshkevich target_ulong addr, bool sctlr_b)
291d854765SPaolo Bonzini {
304e116893SIlya Leoshkevich return translator_ldl_swap(env, s, addr, bswap_code(sctlr_b));
311d854765SPaolo Bonzini }
321d854765SPaolo Bonzini
331d854765SPaolo Bonzini /* Ditto, for a halfword (Thumb) instruction */
arm_lduw_code(CPUARMState * env,DisasContextBase * s,target_ulong addr,bool sctlr_b)344e116893SIlya Leoshkevich static inline uint16_t arm_lduw_code(CPUARMState *env, DisasContextBase* s,
354e116893SIlya Leoshkevich target_ulong addr, bool sctlr_b)
361d854765SPaolo Bonzini {
37f7478a92SJulian Brown #ifndef CONFIG_USER_ONLY
38f7478a92SJulian Brown /* In big-endian (BE32) mode, adjacent Thumb instructions have been swapped
39f7478a92SJulian Brown within each word. Undo that now. */
40f7478a92SJulian Brown if (sctlr_b) {
41f7478a92SJulian Brown addr ^= 2;
42f7478a92SJulian Brown }
43f7478a92SJulian Brown #endif
444e116893SIlya Leoshkevich return translator_lduw_swap(env, s, addr, bswap_code(sctlr_b));
451d854765SPaolo Bonzini }
461d854765SPaolo Bonzini
471d854765SPaolo Bonzini #endif
48