1 /* 2 * cpu_mmu_index() 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * SPDX-License-Identifier: LGPL-2.1-or-later 7 */ 8 9 #ifndef ACCEL_TCG_CPU_MMU_INDEX_H 10 #define ACCEL_TCG_CPU_MMU_INDEX_H 11 12 #include "hw/core/cpu.h" 13 #include "accel/tcg/cpu-ops.h" 14 #include "tcg/debug-assert.h" 15 #ifdef COMPILING_PER_TARGET 16 # ifdef CONFIG_USER_ONLY 17 # include "cpu.h" 18 # endif 19 #endif 20 21 /** 22 * cpu_mmu_index: 23 * @env: The cpu environment 24 * @ifetch: True for code access, false for data access. 25 * 26 * Return the core mmu index for the current translation regime. 27 * This function is used by generic TCG code paths. 28 */ cpu_mmu_index(CPUState * cs,bool ifetch)29static inline int cpu_mmu_index(CPUState *cs, bool ifetch) 30 { 31 #ifdef COMPILING_PER_TARGET 32 # ifdef CONFIG_USER_ONLY 33 return MMU_USER_IDX; 34 # endif 35 #endif 36 37 int ret = cs->cc->tcg_ops->mmu_index(cs, ifetch); 38 tcg_debug_assert(ret >= 0 && ret < NB_MMU_MODES); 39 return ret; 40 } 41 42 #endif /* ACCEL_TCG_CPU_MMU_INDEX_H */ 43