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
This commit is contained in:
parent
76d95dee05
commit
c393cdf8e3
64 changed files with 3289 additions and 1852 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue