aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Kernel/Memory/KMemoryPermission.cs
blob: 32734574ec310826a2ef36197655b28af56738d2 (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
37
38
39
40
41
42
43
44
45
46
using Ryujinx.Memory;
using System;

namespace Ryujinx.HLE.HOS.Kernel.Memory
{
    [Flags]
    enum KMemoryPermission : uint
    {
        None = 0,
        UserMask = Read | Write | Execute,
        Mask = uint.MaxValue,

        Read = 1 << 0,
        Write = 1 << 1,
        Execute = 1 << 2,
        DontCare = 1 << 28,

        ReadAndWrite = Read | Write,
        ReadAndExecute = Read | Execute,
    }

    static class KMemoryPermissionExtensions
    {
        public static MemoryPermission Convert(this KMemoryPermission permission)
        {
            MemoryPermission output = MemoryPermission.None;

            if (permission.HasFlag(KMemoryPermission.Read))
            {
                output = MemoryPermission.Read;
            }

            if (permission.HasFlag(KMemoryPermission.Write))
            {
                output |= MemoryPermission.Write;
            }

            if (permission.HasFlag(KMemoryPermission.Execute))
            {
                output |= MemoryPermission.Execute;
            }

            return output;
        }
    }
}