]> git.proxmox.com Git - mirror_qemu.git/blob - trace/mem-internal.h
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2021-07-09-v2' into staging
[mirror_qemu.git] / trace / mem-internal.h
1 /*
2 * Helper functions for guest memory tracing
3 *
4 * Copyright (C) 2016 LluĂ­s Vilanova <vilanova@ac.upc.edu>
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
9
10 #ifndef TRACE__MEM_INTERNAL_H
11 #define TRACE__MEM_INTERNAL_H
12
13 #define TRACE_MEM_SZ_SHIFT_MASK 0xf /* size shift mask */
14 #define TRACE_MEM_SE (1ULL << 4) /* sign extended (y/n) */
15 #define TRACE_MEM_BE (1ULL << 5) /* big endian (y/n) */
16 #define TRACE_MEM_ST (1ULL << 6) /* store (y/n) */
17 #define TRACE_MEM_MMU_SHIFT 8 /* mmu idx */
18
19 static inline uint16_t trace_mem_build_info(
20 int size_shift, bool sign_extend, MemOp endianness,
21 bool store, unsigned int mmu_idx)
22 {
23 uint16_t res;
24
25 res = size_shift & TRACE_MEM_SZ_SHIFT_MASK;
26 if (sign_extend) {
27 res |= TRACE_MEM_SE;
28 }
29 if (endianness == MO_BE) {
30 res |= TRACE_MEM_BE;
31 }
32 if (store) {
33 res |= TRACE_MEM_ST;
34 }
35 #ifdef CONFIG_SOFTMMU
36 res |= mmu_idx << TRACE_MEM_MMU_SHIFT;
37 #endif
38 return res;
39 }
40
41 static inline uint16_t trace_mem_get_info(MemOp op,
42 unsigned int mmu_idx,
43 bool store)
44 {
45 return trace_mem_build_info(op & MO_SIZE, !!(op & MO_SIGN),
46 op & MO_BSWAP, store,
47 mmu_idx);
48 }
49
50 #endif /* TRACE__MEM_INTERNAL_H */