2016-06-09 19:31:47 +02:00
|
|
|
/*
|
|
|
|
* Helper functions for guest memory tracing
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Lluís Vilanova <vilanova@ac.upc.edu>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TRACE__MEM_INTERNAL_H
|
|
|
|
#define TRACE__MEM_INTERNAL_H
|
|
|
|
|
2017-11-22 03:03:15 +01:00
|
|
|
#define TRACE_MEM_SZ_SHIFT_MASK 0xf /* size shift mask */
|
|
|
|
#define TRACE_MEM_SE (1ULL << 4) /* sign extended (y/n) */
|
|
|
|
#define TRACE_MEM_BE (1ULL << 5) /* big endian (y/n) */
|
|
|
|
#define TRACE_MEM_ST (1ULL << 6) /* store (y/n) */
|
2019-06-28 21:54:11 +02:00
|
|
|
#define TRACE_MEM_MMU_SHIFT 8 /* mmu idx */
|
2018-05-23 00:26:49 +02:00
|
|
|
|
2019-06-28 21:54:11 +02:00
|
|
|
static inline uint16_t trace_mem_build_info(
|
|
|
|
int size_shift, bool sign_extend, MemOp endianness,
|
|
|
|
bool store, unsigned int mmu_idx)
|
2016-06-09 19:31:47 +02:00
|
|
|
{
|
2019-06-28 21:54:11 +02:00
|
|
|
uint16_t res;
|
2016-06-09 19:31:47 +02:00
|
|
|
|
2018-05-23 00:26:49 +02:00
|
|
|
res = size_shift & TRACE_MEM_SZ_SHIFT_MASK;
|
|
|
|
if (sign_extend) {
|
|
|
|
res |= TRACE_MEM_SE;
|
|
|
|
}
|
|
|
|
if (endianness == MO_BE) {
|
|
|
|
res |= TRACE_MEM_BE;
|
2016-06-09 19:31:47 +02:00
|
|
|
}
|
|
|
|
if (store) {
|
2018-05-23 00:26:49 +02:00
|
|
|
res |= TRACE_MEM_ST;
|
2016-06-09 19:31:47 +02:00
|
|
|
}
|
2019-06-28 21:54:11 +02:00
|
|
|
#ifdef CONFIG_SOFTMMU
|
|
|
|
res |= mmu_idx << TRACE_MEM_MMU_SHIFT;
|
|
|
|
#endif
|
2016-06-09 19:31:47 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2019-06-28 21:54:11 +02:00
|
|
|
static inline uint16_t trace_mem_get_info(MemOp op,
|
|
|
|
unsigned int mmu_idx,
|
|
|
|
bool store)
|
2016-06-09 19:31:47 +02:00
|
|
|
{
|
2018-05-23 00:26:49 +02:00
|
|
|
return trace_mem_build_info(op & MO_SIZE, !!(op & MO_SIGN),
|
2019-06-28 21:54:11 +02:00
|
|
|
op & MO_BSWAP, store,
|
|
|
|
mmu_idx);
|
2016-06-09 19:31:47 +02:00
|
|
|
}
|
|
|
|
|
2016-06-29 15:29:06 +02:00
|
|
|
#endif /* TRACE__MEM_INTERNAL_H */
|