memopidx.h 1003 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Combine the MemOp and mmu_idx parameters into a single value.
  3. *
  4. * Authors:
  5. * Richard Henderson <rth@twiddle.net>
  6. *
  7. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  8. * See the COPYING file in the top-level directory.
  9. */
  10. #ifndef EXEC_MEMOPIDX_H
  11. #define EXEC_MEMOPIDX_H
  12. #include "exec/memop.h"
  13. typedef uint32_t MemOpIdx;
  14. /**
  15. * make_memop_idx
  16. * @op: memory operation
  17. * @idx: mmu index
  18. *
  19. * Encode these values into a single parameter.
  20. */
  21. static inline MemOpIdx make_memop_idx(MemOp op, unsigned idx)
  22. {
  23. #ifdef CONFIG_DEBUG_TCG
  24. assert(idx <= 15);
  25. #endif
  26. return (op << 4) | idx;
  27. }
  28. /**
  29. * get_memop
  30. * @oi: combined op/idx parameter
  31. *
  32. * Extract the memory operation from the combined value.
  33. */
  34. static inline MemOp get_memop(MemOpIdx oi)
  35. {
  36. return oi >> 4;
  37. }
  38. /**
  39. * get_mmuidx
  40. * @oi: combined op/idx parameter
  41. *
  42. * Extract the mmu index from the combined value.
  43. */
  44. static inline unsigned get_mmuidx(MemOpIdx oi)
  45. {
  46. return oi & 15;
  47. }
  48. #endif