blob: bc8ae26359808795ec523201949df7cd87bfa86d (
plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
namespace ARMeilleure.Memory
{
/// <summary>
/// Indicates the type of a memory manager and the method it uses for memory mapping
/// and address translation. This controls the code generated for memory accesses on the JIT.
/// </summary>
public enum MemoryManagerType
{
/// <summary>
/// Complete software MMU implementation, the read/write methods are always called,
/// without any attempt to perform faster memory access.
/// </summary>
SoftwareMmu,
/// <summary>
/// High level implementation using a software flat page table for address translation,
/// used to speed up address translation if possible without calling the read/write methods.
/// </summary>
SoftwarePageTable,
/// <summary>
/// High level implementation with mappings managed by the host OS, effectively using hardware
/// page tables. No address translation is performed in software and the memory is just accessed directly.
/// </summary>
HostMapped,
/// <summary>
/// Same as the host mapped memory manager type, but without masking the address within the address space.
/// Allows invalid access from JIT code to the rest of the program, but is faster.
/// </summary>
HostMappedUnsafe,
/// <summary>
/// High level implementation using a software flat page table for address translation
/// with no support for handling invalid or non-contiguous memory access.
/// </summary>
HostTracked,
/// <summary>
/// High level implementation using a software flat page table for address translation
/// without masking the address and no support for handling invalid or non-contiguous memory access.
/// </summary>
HostTrackedUnsafe,
}
public static class MemoryManagerTypeExtensions
{
public static bool IsHostMapped(this MemoryManagerType type)
{
return type == MemoryManagerType.HostMapped || type == MemoryManagerType.HostMappedUnsafe;
}
public static bool IsHostTracked(this MemoryManagerType type)
{
return type == MemoryManagerType.HostTracked || type == MemoryManagerType.HostTrackedUnsafe;
}
public static bool IsHostMappedOrTracked(this MemoryManagerType type)
{
return type.IsHostMapped() || type.IsHostTracked();
}
}
}
|