aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Cpu/AppleHv/HvMemoryBlockAllocation.cs
blob: 855d313c5723c8aa644de2147ece293dcc2b639c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Ryujinx.Memory;
using System;
using System.Runtime.Versioning;

namespace Ryujinx.Cpu.AppleHv
{
    [SupportedOSPlatform("macos")]
    readonly struct HvMemoryBlockAllocation : IDisposable
    {
        private readonly HvMemoryBlockAllocator _owner;
        private readonly HvMemoryBlockAllocator.Block _block;

        public bool IsValid => _owner != null;
        public MemoryBlock Memory => _block.Memory;
        public ulong Ipa => _block.Ipa;
        public ulong Offset { get; }
        public ulong Size { get; }

        public HvMemoryBlockAllocation(
            HvMemoryBlockAllocator owner,
            HvMemoryBlockAllocator.Block block,
            ulong offset,
            ulong size)
        {
            _owner = owner;
            _block = block;
            Offset = offset;
            Size = size;
        }

        public void Dispose()
        {
            _owner.Free(_block, Offset, Size);
        }
    }
}