memmap.hh 821 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef MEMMAP_HH
  2. #define MEMMAP_HH
  3. #include "kvmxx.hh"
  4. #include <stdint.h>
  5. #include <vector>
  6. #include <stack>
  7. class mem_map;
  8. class mem_slot;
  9. class mem_slot {
  10. public:
  11. mem_slot(mem_map& map, uint64_t gpa, uint64_t size, void *hva);
  12. ~mem_slot();
  13. void set_dirty_logging(bool enabled);
  14. bool dirty_logging() const;
  15. int update_dirty_log();
  16. bool is_dirty(uint64_t gpa) const;
  17. private:
  18. void update();
  19. private:
  20. typedef unsigned long ulong;
  21. static const int bits_per_word = sizeof(ulong) * 8;
  22. mem_map& _map;
  23. int _slot;
  24. uint64_t _gpa;
  25. uint64_t _size;
  26. void *_hva;
  27. bool _dirty_log_enabled;
  28. std::vector<ulong> _log;
  29. };
  30. class mem_map {
  31. public:
  32. mem_map(kvm::vm& vm);
  33. private:
  34. kvm::vm& _vm;
  35. std::stack<int> _free_slots;
  36. friend class mem_slot;
  37. };
  38. #endif