From 86fd0643c26433362a25acceb4fa1fcee07dd0b2 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 17 Jan 2023 01:13:24 -0300 Subject: Implement support for page sizes > 4KB (#4252) * Implement support for page sizes > 4KB * Check and work around more alignment issues * Was not meant to change this * Use MemoryBlock.GetPageSize() value for signal handler code * Do not take the path for private allocations if host supports 4KB pages * Add Flags attribute on MemoryMapFlags * Fix dirty region size with 16kb pages Would accidentally report a size that was too high (generally 16k instead of 4k, uploading 4x as much data) Co-authored-by: riperiperi --- Ryujinx.Memory/IVirtualMemoryManager.cs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'Ryujinx.Memory/IVirtualMemoryManager.cs') diff --git a/Ryujinx.Memory/IVirtualMemoryManager.cs b/Ryujinx.Memory/IVirtualMemoryManager.cs index c8a74f66..390371ad 100644 --- a/Ryujinx.Memory/IVirtualMemoryManager.cs +++ b/Ryujinx.Memory/IVirtualMemoryManager.cs @@ -6,6 +6,12 @@ namespace Ryujinx.Memory { public interface IVirtualMemoryManager { + /// + /// Indicates whenever the memory manager supports aliasing pages at 4KB granularity. + /// + /// True if 4KB pages are supported by the memory manager, false otherwise + bool Supports4KBPages { get; } + /// /// Maps a virtual memory range into a physical memory range. /// @@ -15,7 +21,20 @@ namespace Ryujinx.Memory /// Virtual memory address /// Physical memory address where the region should be mapped to /// Size to be mapped - void Map(ulong va, ulong pa, ulong size); + /// Flags controlling memory mapping + void Map(ulong va, ulong pa, ulong size, MemoryMapFlags flags); + + /// + /// Maps a virtual memory range into an arbitrary host memory range. + /// + /// + /// Addresses and size must be page aligned. + /// Not all memory managers supports this feature. + /// + /// Virtual memory address + /// Host pointer where the virtual region should be mapped + /// Size to be mapped + void MapForeign(ulong va, nuint hostPointer, ulong size); /// /// Unmaps a previously mapped range of virtual memory. @@ -115,6 +134,15 @@ namespace Ryujinx.Memory /// Throw if the specified memory region is not contiguous in physical memory ref T GetRef(ulong va) where T : unmanaged; + /// + /// Gets the host regions that make up the given virtual address region. + /// If any part of the virtual region is unmapped, null is returned. + /// + /// Virtual address of the range + /// Size of the range + /// Array of host regions + IEnumerable GetHostRegions(ulong va, ulong size); + /// /// Gets the physical regions that make up the given virtual address region. /// If any part of the virtual region is unmapped, null is returned. -- cgit v1.2.3