diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-08-15 15:59:51 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-15 15:59:51 -0300 |
| commit | c393cdf8e3775bc95850e4d8c8e4c446b286d3b4 (patch) | |
| tree | 25035a244741d2daf3f7d6be8b23153ff061ea15 /ChocolArm64/Memory/AMemoryHelper.cs | |
| parent | 76d95dee05e3c51c18e1799f54cc407e0f633b4e (diff) | |
More flexible memory manager (#307)
* Keep track mapped buffers with fixed offsets
* Started rewriting the memory manager
* Initial support for MapPhysicalMemory and UnmapPhysicalMemory, other tweaks
* MapPhysicalMemory/UnmapPhysicalMemory support, other tweaks
* Rebased
* Optimize the map/unmap physical memory svcs
* Integrate shared font support
* Fix address space reserve alignment
* Some fixes related to gpu memory mapping
* Some cleanup
* Only try uploading const buffers that are really used
* Check if memory region is contiguous
* Rebased
* Add missing count increment on IsRegionModified
* Check for reads/writes outside of the address space, optimize translation with a tail call
Diffstat (limited to 'ChocolArm64/Memory/AMemoryHelper.cs')
| -rw-r--r-- | ChocolArm64/Memory/AMemoryHelper.cs | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/ChocolArm64/Memory/AMemoryHelper.cs b/ChocolArm64/Memory/AMemoryHelper.cs index 0a23a2f8..ea877834 100644 --- a/ChocolArm64/Memory/AMemoryHelper.cs +++ b/ChocolArm64/Memory/AMemoryHelper.cs @@ -26,12 +26,9 @@ namespace ChocolArm64.Memory { long Size = Marshal.SizeOf<T>(); - if ((ulong)(Position + Size) > AMemoryMgr.AddrSize) - { - throw new ArgumentOutOfRangeException(nameof(Position)); - } + Memory.EnsureRangeIsValid(Position, Size); - IntPtr Ptr = new IntPtr((byte*)Memory.Ram + Position); + IntPtr Ptr = (IntPtr)Memory.Translate(Position); return Marshal.PtrToStructure<T>(Ptr); } @@ -40,12 +37,9 @@ namespace ChocolArm64.Memory { long Size = Marshal.SizeOf<T>(); - if ((ulong)(Position + Size) > AMemoryMgr.AddrSize) - { - throw new ArgumentOutOfRangeException(nameof(Position)); - } + Memory.EnsureRangeIsValid(Position, Size); - IntPtr Ptr = new IntPtr((byte*)Memory.Ram + Position); + IntPtr Ptr = (IntPtr)Memory.TranslateWrite(Position); Marshal.StructureToPtr<T>(Value, Ptr, false); } @@ -69,15 +63,5 @@ namespace ChocolArm64.Memory return Encoding.ASCII.GetString(MS.ToArray()); } } - - public static long PageRoundUp(long Value) - { - return (Value + AMemoryMgr.PageMask) & ~AMemoryMgr.PageMask; - } - - public static long PageRoundDown(long Value) - { - return Value & ~AMemoryMgr.PageMask; - } } }
\ No newline at end of file |
