mirror of
https://git.743378673.xyz/MeloNX/MeloNX.git
synced 2025-07-07 15:56:27 +02:00
Remove address space mirror and tweak address space layout when host has small adress space
This commit is contained in:
parent
f2a0031f26
commit
c3dcfce739
8 changed files with 1046 additions and 1595 deletions
|
@ -181,26 +181,44 @@ namespace Ryujinx.Cpu
|
|||
|
||||
const MemoryAllocationFlags AsFlags = MemoryAllocationFlags.Reserve | MemoryAllocationFlags.ViewCompatible;
|
||||
|
||||
MemoryBlock baseMemory = null;
|
||||
MemoryBlock mirrorMemory = null;
|
||||
|
||||
try
|
||||
{
|
||||
baseMemory = new MemoryBlock(asSize, asFlags);
|
||||
mirrorMemory = new MemoryBlock(asSize, asFlags);
|
||||
addressSpace = new AddressSpace(backingMemory, baseMemory, mirrorMemory, asSize, supports4KBPages);
|
||||
}
|
||||
catch (SystemException)
|
||||
{
|
||||
baseMemory?.Dispose();
|
||||
mirrorMemory?.Dispose();
|
||||
}
|
||||
|
||||
return addressSpace != null;
|
||||
}
|
||||
|
||||
public static bool TryCreateWithoutMirror(ulong asSize, out MemoryBlock addressSpace)
|
||||
{
|
||||
addressSpace = null;
|
||||
|
||||
MemoryAllocationFlags asFlags = MemoryAllocationFlags.Reserve | MemoryAllocationFlags.ViewCompatible;
|
||||
|
||||
ulong minAddressSpaceSize = Math.Min(asSize, 1UL << 36);
|
||||
|
||||
// Attempt to create the address space with expected size or try to reduce it until it succeed.
|
||||
for (ulong addressSpaceSize = asSize; addressSpaceSize >= minAddressSpaceSize; addressSpaceSize >>= 1)
|
||||
for (ulong addressSpaceSize = asSize; addressSpaceSize >= minAddressSpaceSize; addressSpaceSize -= 0x100000000UL)
|
||||
{
|
||||
MemoryBlock baseMemory = null;
|
||||
MemoryBlock mirrorMemory = null;
|
||||
|
||||
try
|
||||
{
|
||||
baseMemory = new MemoryBlock(addressSpaceSize, AsFlags);
|
||||
mirrorMemory = new MemoryBlock(addressSpaceSize, AsFlags);
|
||||
addressSpace = new AddressSpace(backingMemory, baseMemory, mirrorMemory, addressSpaceSize, supports4KBPages);
|
||||
MemoryBlock baseMemory = new MemoryBlock(addressSpaceSize, AsFlags);
|
||||
addressSpace = baseMemory;
|
||||
|
||||
break;
|
||||
}
|
||||
catch (SystemException)
|
||||
{
|
||||
baseMemory?.Dispose();
|
||||
mirrorMemory?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue