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