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 "tcg/debug-assert.h" 14 #ifdef COMPILING_PER_TARGET 15 # ifdef CONFIG_USER_ONLY 16 # include "cpu.h" 17 # endif 18 #endif 19 20 /** 21 * cpu_mmu_index: 22 * @env: The cpu environment 23 * @ifetch: True for code access, false for data access. 24 * 25 * Return the core mmu index for the current translation regime. 26 * This function is used by generic TCG code paths. 27 */ 28 static inline int cpu_mmu_index(CPUState *cs, bool ifetch) 29 { 30 #ifdef COMPILING_PER_TARGET 31 # ifdef CONFIG_USER_ONLY 32 return MMU_USER_IDX; 33 # endif 34 #endif 35 36 int ret = cs->cc->mmu_index(cs, ifetch); 37 tcg_debug_assert(ret >= 0 && ret < NB_MMU_MODES); 38 return ret; 39 } 40 41 #endif /* ACCEL_TCG_CPU_MMU_INDEX_H */ 42