]> git.proxmox.com Git - mirror_qemu.git/blob - include/exec/memopidx.h
Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into...
[mirror_qemu.git] / include / exec / memopidx.h
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 <= 15);
29 #endif
30 return (op << 4) | idx;
31 }
32
33 /**
34 * get_memop
35 * @oi: combined op/idx parameter
36 *
37 * Extract the memory operation from the combined value.
38 */
39 static inline MemOp get_memop(MemOpIdx oi)
40 {
41 return oi >> 4;
42 }
43
44 /**
45 * get_mmuidx
46 * @oi: combined op/idx parameter
47 *
48 * Extract the mmu index from the combined value.
49 */
50 static inline unsigned get_mmuidx(MemOpIdx oi)
51 {
52 return oi & 15;
53 }
54
55 #endif