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/AMemoryWin32.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/AMemoryWin32.cs')
| -rw-r--r-- | ChocolArm64/Memory/AMemoryWin32.cs | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/ChocolArm64/Memory/AMemoryWin32.cs b/ChocolArm64/Memory/AMemoryWin32.cs deleted file mode 100644 index 387ca32c..00000000 --- a/ChocolArm64/Memory/AMemoryWin32.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace ChocolArm64.Memory -{ - static class AMemoryWin32 - { - private const int MEM_COMMIT = 0x00001000; - private const int MEM_RESERVE = 0x00002000; - private const int MEM_WRITE_WATCH = 0x00200000; - - private const int PAGE_READWRITE = 0x04; - - private const int MEM_RELEASE = 0x8000; - - private const int WRITE_WATCH_FLAG_RESET = 1; - - [DllImport("kernel32.dll")] - private static extern IntPtr VirtualAlloc(IntPtr lpAddress, IntPtr dwSize, int flAllocationType, int flProtect); - - [DllImport("kernel32.dll")] - private static extern bool VirtualFree(IntPtr lpAddress, IntPtr dwSize, int dwFreeType); - - [DllImport("kernel32.dll")] - private unsafe static extern int GetWriteWatch( - int dwFlags, - IntPtr lpBaseAddress, - IntPtr dwRegionSize, - IntPtr[] lpAddresses, - long* lpdwCount, - long* lpdwGranularity); - - public static IntPtr Allocate(IntPtr Size) - { - const int Flags = MEM_COMMIT | MEM_RESERVE | MEM_WRITE_WATCH; - - IntPtr Address = VirtualAlloc(IntPtr.Zero, Size, Flags, PAGE_READWRITE); - - if (Address == IntPtr.Zero) - { - throw new InvalidOperationException(); - } - - return Address; - } - - public static void Free(IntPtr Address) - { - VirtualFree(Address, IntPtr.Zero, MEM_RELEASE); - } - - public unsafe static int GetPageSize(IntPtr Address, IntPtr Size) - { - IntPtr[] Addresses = new IntPtr[1]; - - long Count = Addresses.Length; - - long Granularity; - - GetWriteWatch( - 0, - Address, - Size, - Addresses, - &Count, - &Granularity); - - return (int)Granularity; - } - - public unsafe static void IsRegionModified( - IntPtr Address, - IntPtr Size, - IntPtr[] Addresses, - out int AddrCount) - { - long Count = Addresses.Length; - - long Granularity; - - GetWriteWatch( - WRITE_WATCH_FLAG_RESET, - Address, - Size, - Addresses, - &Count, - &Granularity); - - AddrCount = (int)Count; - } - } -}
\ No newline at end of file |
