master
h 56 lines 1.01 KB
Raw
1 /*
2 * Combine the MemOp and mmu_idx parameters into a single value.
3 *
4 * Authors:
5 * Richard Henderson <rth@twiddle.net>
6 *
7 * This work is licensed under the terms of the GNU GPL, version 2 or later.
8 * See the COPYING file in the top-level directory.
9 */
10
11 #ifndef EXEC_MEMOPIDX_H
12 #define EXEC_MEMOPIDX_H
13
14 #include "exec/memop.h"
15
16 typedef uint32_t MemOpIdx;
17
18 /**
19 * make_memop_idx
20 * @op: memory operation
21 * @idx: mmu index
22 *
23 * Encode these values into a single parameter.
24 */
25 static inline MemOpIdx make_memop_idx(MemOp op, unsigned idx)
26 {
27 #ifdef CONFIG_DEBUG_TCG
28 assert(idx <= 31);
29 assert(clz32(op) >= 5);
30 #endif
31 return (op << 5) | idx;
32 }
33
34 /**
35 * get_memop
36 * @oi: combined op/idx parameter
37 *
38 * Extract the memory operation from the combined value.
39 */
40 static inline MemOp get_memop(MemOpIdx oi)
41 {
42 return oi >> 5;
43 }
44
45 /**
46 * get_mmuidx
47 * @oi: combined op/idx parameter
48 *
49 * Extract the mmu index from the combined value.
50 */
51 static inline unsigned get_mmuidx(MemOpIdx oi)
52 {
53 return oi & 31;
54 }
55
56 #endif