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