1 /* Copyright (C) 2007-2009 The Android Open Source Project 2 ** 3 ** This software is licensed under the terms of the GNU General Public 4 ** License version 2, as published by the Free Software Foundation, and 5 ** may be copied, distributed, and modified under those terms. 6 ** 7 ** This program is distributed in the hope that it will be useful, 8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 ** GNU General Public License for more details. 11 */ 12 13 /* 14 * Contains SOFTMMU macros expansion for ldx_user and stx_user routines used 15 * outside of JIT. The issue is that regular implementation of these routines 16 * assumes that pointer to CPU environment is stored in ebp register, which 17 * is true for calls made inside JIT, but is not necessarily true for calls 18 * made outside of JIT. The way SOFTMMU macros are expanded in this header 19 * enforces ldx/stx routines to use CPU environment stored in cpu_single_env 20 * variable. 21 */ 22 #ifndef QEMU_SOFTMMU_OUTSIDE_JIT_H 23 #define QEMU_SOFTMMU_OUTSIDE_JIT_H 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 //////////////////////////////////////////////////////////////////////////////// 30 // Declares routines implemented in softmmu_outside_jit.c, that are used in 31 // this macros expansion. Note that MMUSUFFIX _outside_jit is enforced in 32 // softmmu_header.h by defining OUTSIDE_JIT macro. 33 //////////////////////////////////////////////////////////////////////////////// 34 35 uint8_t REGPARM __ldb_outside_jit(target_ulong addr, int mmu_idx); 36 void REGPARM __stb_outside_jit(target_ulong addr, uint8_t val, int mmu_idx); 37 uint16_t REGPARM __ldw_outside_jit(target_ulong addr, int mmu_idx); 38 void REGPARM __stw_outside_jit(target_ulong addr, uint16_t val, int mmu_idx); 39 uint32_t REGPARM __ldl_outside_jit(target_ulong addr, int mmu_idx); 40 void REGPARM __stl_outside_jit(target_ulong addr, uint32_t val, int mmu_idx); 41 uint64_t REGPARM __ldq_outside_jit(target_ulong addr, int mmu_idx); 42 void REGPARM __stq_outside_jit(target_ulong addr, uint64_t val, int mmu_idx); 43 44 // Enforces MMUSUFFIX to be set to _outside_jit in softmmu_header.h 45 #define OUTSIDE_JIT 46 // Enforces use of cpu_single_env for CPU environment. 47 #define env cpu_single_env 48 49 // ============================================================================= 50 // Generate ld/stx_user 51 // ============================================================================= 52 #if defined(TARGET_MIPS) 53 #define MEMSUFFIX MMU_MODE2_SUFFIX 54 #else 55 #define MEMSUFFIX MMU_MODE1_SUFFIX 56 #endif 57 #define ACCESS_TYPE 1 58 59 #define DATA_SIZE 1 60 #include "softmmu_header.h" 61 62 #define DATA_SIZE 2 63 #include "softmmu_header.h" 64 65 #define DATA_SIZE 4 66 #include "softmmu_header.h" 67 68 #define DATA_SIZE 8 69 #include "softmmu_header.h" 70 71 #undef MEMSUFFIX 72 #undef ACCESS_TYPE 73 74 // ============================================================================= 75 // Generate ld/stx_kernel 76 // ============================================================================= 77 #define MEMSUFFIX MMU_MODE0_SUFFIX 78 #define ACCESS_TYPE 0 79 80 #define DATA_SIZE 1 81 #include "softmmu_header.h" 82 83 #define DATA_SIZE 2 84 #include "softmmu_header.h" 85 86 #define DATA_SIZE 4 87 #include "softmmu_header.h" 88 89 #define DATA_SIZE 8 90 #include "softmmu_header.h" 91 92 #undef MEMSUFFIX 93 #undef ACCESS_TYPE 94 95 #undef env 96 #undef OUTSIDE_JIT 97 98 #ifdef __cplusplus 99 }; /* end of extern "C" */ 100 #endif 101 102 #endif // QEMU_SOFTMMU_OUTSIDE_JIT_H 103