HvMemoryBlockAllocation.cs 871 B

12345678910111213141516171819202122232425262728293031323334
  1. using Ryujinx.Memory;
  2. using System;
  3. namespace Ryujinx.Cpu.AppleHv
  4. {
  5. struct HvMemoryBlockAllocation : IDisposable
  6. {
  7. private readonly HvMemoryBlockAllocator _owner;
  8. private readonly HvMemoryBlockAllocator.Block _block;
  9. public bool IsValid => _owner != null;
  10. public MemoryBlock Memory => _block.Memory;
  11. public ulong Ipa => _block.Ipa;
  12. public ulong Offset { get; }
  13. public ulong Size { get; }
  14. public HvMemoryBlockAllocation(
  15. HvMemoryBlockAllocator owner,
  16. HvMemoryBlockAllocator.Block block,
  17. ulong offset,
  18. ulong size)
  19. {
  20. _owner = owner;
  21. _block = block;
  22. Offset = offset;
  23. Size = size;
  24. }
  25. public void Dispose()
  26. {
  27. _owner.Free(_block, Offset, Size);
  28. }
  29. }
  30. }