identity.hh 823 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef API_IDENTITY_HH
  2. #define API_IDENTITY_HH
  3. #include "kvmxx.hh"
  4. #include "memmap.hh"
  5. #include <functional>
  6. #include <memory>
  7. #include <vector>
  8. namespace identity {
  9. struct hole {
  10. hole();
  11. hole(void* address, size_t size);
  12. void* address;
  13. size_t size;
  14. };
  15. class vm {
  16. public:
  17. vm(kvm::vm& vm, mem_map& mmap, hole address_space_hole = hole());
  18. ~vm();
  19. private:
  20. void *tss;
  21. typedef std::shared_ptr<mem_slot> mem_slot_ptr;
  22. std::vector<mem_slot_ptr> _slots;
  23. };
  24. class vcpu {
  25. public:
  26. vcpu(kvm::vcpu& vcpu, std::function<void ()> guest_func,
  27. unsigned long stack_size = 256 * 1024);
  28. private:
  29. static void thunk(vcpu* vcpu);
  30. void setup_regs();
  31. void setup_sregs();
  32. private:
  33. kvm::vcpu& _vcpu;
  34. std::function<void ()> _guest_func;
  35. std::vector<char> _stack;
  36. };
  37. }
  38. #endif