2
0

mem-internal.h 1023 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef TRACE__MEM_INTERNAL_H
  10. #define TRACE__MEM_INTERNAL_H
  11. static inline uint8_t trace_mem_get_info(TCGMemOp op, bool store)
  12. {
  13. uint8_t res = op;
  14. bool be = (op & MO_BSWAP) == MO_BE;
  15. /* remove untraced fields */
  16. res &= (1ULL << 4) - 1;
  17. /* make endianness absolute */
  18. res &= ~MO_BSWAP;
  19. if (be) {
  20. res |= 1ULL << 3;
  21. }
  22. /* add fields */
  23. if (store) {
  24. res |= 1ULL << 4;
  25. }
  26. return res;
  27. }
  28. static inline uint8_t trace_mem_build_info(
  29. TCGMemOp size, bool sign_extend, TCGMemOp endianness, bool store)
  30. {
  31. uint8_t res = 0;
  32. res |= size;
  33. res |= (sign_extend << 2);
  34. if (endianness == MO_BE) {
  35. res |= (1ULL << 3);
  36. }
  37. res |= (store << 4);
  38. return res;
  39. }
  40. #endif /* TRACE__MEM_INTERNAL_H */