aboutsummaryrefslogtreecommitdiff
path: root/trace/mem-internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'trace/mem-internal.h')
-rw-r--r--trace/mem-internal.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/trace/mem-internal.h b/trace/mem-internal.h
new file mode 100644
index 0000000000..a75e0ff732
--- /dev/null
+++ b/trace/mem-internal.h
@@ -0,0 +1,46 @@
+/*
+ * 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
+
+static inline uint8_t trace_mem_get_info(TCGMemOp op, bool store)
+{
+ uint8_t res = op;
+ bool be = (op & MO_BSWAP) == MO_BE;
+
+ /* remove untraced fields */
+ res &= (1ULL << 4) - 1;
+ /* make endianness absolute */
+ res &= ~MO_BSWAP;
+ if (be) {
+ res |= 1ULL << 3;
+ }
+ /* add fields */
+ if (store) {
+ res |= 1ULL << 4;
+ }
+
+ return res;
+}
+
+static inline uint8_t trace_mem_build_info(
+ TCGMemOp size, bool sign_extend, TCGMemOp endianness, bool store)
+{
+ uint8_t res = 0;
+ res |= size;
+ res |= (sign_extend << 2);
+ if (endianness == MO_BE) {
+ res |= (1ULL << 3);
+ }
+ res |= (store << 4);
+ return res;
+}
+
+#endif /* TRACE__MEM_INTERNAL_H */