2016-06-10 01:31:47 +08: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
|
|
|
|
|
2018-05-23 06:26:50 +08:00
|
|
|
#define TRACE_MEM_SZ_SHIFT_MASK 0x7 /* size shift mask */
|
|
|
|
#define TRACE_MEM_SE (1ULL << 3) /* sign extended (y/n) */
|
|
|
|
#define TRACE_MEM_BE (1ULL << 4) /* big endian (y/n) */
|
|
|
|
#define TRACE_MEM_ST (1ULL << 5) /* store (y/n) */
|
2018-05-23 06:26:49 +08:00
|
|
|
|
|
|
|
static inline uint8_t trace_mem_build_info(
|
2019-08-24 02:10:58 +08:00
|
|
|
int size_shift, bool sign_extend, MemOp endianness, bool store)
|
2016-06-10 01:31:47 +08:00
|
|
|
{
|
2018-05-23 06:26:49 +08:00
|
|
|
uint8_t res;
|
2016-06-10 01:31:47 +08:00
|
|
|
|
2018-05-23 06:26:49 +08: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-10 01:31:47 +08:00
|
|
|
}
|
|
|
|
if (store) {
|
2018-05-23 06:26:49 +08:00
|
|
|
res |= TRACE_MEM_ST;
|
2016-06-10 01:31:47 +08:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2019-08-24 02:10:58 +08:00
|
|
|
static inline uint8_t trace_mem_get_info(MemOp op, bool store)
|
2016-06-10 01:31:47 +08:00
|
|
|
{
|
2018-05-23 06:26:49 +08:00
|
|
|
return trace_mem_build_info(op & MO_SIZE, !!(op & MO_SIGN),
|
|
|
|
op & MO_BSWAP, store);
|
2016-06-10 01:31:47 +08:00
|
|
|
}
|
|
|
|
|
2018-05-23 06:26:51 +08:00
|
|
|
static inline
|
|
|
|
uint8_t trace_mem_build_info_no_se_be(int size_shift, bool store)
|
|
|
|
{
|
|
|
|
return trace_mem_build_info(size_shift, false, MO_BE, store);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
uint8_t trace_mem_build_info_no_se_le(int size_shift, bool store)
|
|
|
|
{
|
|
|
|
return trace_mem_build_info(size_shift, false, MO_LE, store);
|
|
|
|
}
|
|
|
|
|
2016-06-29 21:29:06 +08:00
|
|
|
#endif /* TRACE__MEM_INTERNAL_H */
|