mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-06-11 23:09:17 +00:00
Memory changes 3 (ryubing/ryujinx!202)
See merge request ryubing/ryujinx!202
This commit is contained in:
@@ -998,7 +998,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
}
|
||||
else
|
||||
{
|
||||
return new KMemoryInfo(
|
||||
return KMemoryInfo.Pool.Allocate().Set(
|
||||
AddrSpaceEnd,
|
||||
~AddrSpaceEnd + 1,
|
||||
MemoryState.Reserved,
|
||||
@@ -2544,10 +2544,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
KMemoryPermission firstPermission = info.Permission;
|
||||
MemoryAttribute firstAttribute = info.Attribute;
|
||||
|
||||
do
|
||||
info = currBlock.GetInfo(info);
|
||||
|
||||
while (info.Address + info.Size - 1 < endAddr - 1 && (currBlock = currBlock.Successor) != null)
|
||||
{
|
||||
info = currBlock.GetInfo();
|
||||
|
||||
// Check if the block state matches what we expect.
|
||||
if (firstState != info.State ||
|
||||
firstPermission != info.Permission ||
|
||||
@@ -2559,11 +2559,16 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
outState = MemoryState.Unmapped;
|
||||
outPermission = KMemoryPermission.None;
|
||||
outAttribute = MemoryAttribute.None;
|
||||
|
||||
KMemoryInfo.Pool.Release(info);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
info = currBlock.GetInfo(info);
|
||||
}
|
||||
while (info.Address + info.Size - 1 < endAddr - 1 && (currBlock = currBlock.Successor) != null);
|
||||
|
||||
KMemoryInfo.Pool.Release(info);
|
||||
|
||||
outState = firstState;
|
||||
outPermission = firstPermission;
|
||||
@@ -2582,16 +2587,26 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
MemoryAttribute attributeMask,
|
||||
MemoryAttribute attributeExpected)
|
||||
{
|
||||
foreach (KMemoryInfo info in IterateOverRange(address, address + size))
|
||||
KMemoryBlock currBlock = _blockManager.FindBlock(address);
|
||||
|
||||
KMemoryInfo info = currBlock.GetInfo();
|
||||
|
||||
while (info.Address + info.Size - 1 < address + size - 1 && (currBlock = currBlock.Successor) != null)
|
||||
{
|
||||
// Check if the block state matches what we expect.
|
||||
if ((info.State & stateMask) != stateExpected ||
|
||||
(info.Permission & permissionMask) != permissionExpected ||
|
||||
(info.Attribute & attributeMask) != attributeExpected)
|
||||
{
|
||||
KMemoryInfo.Pool.Release(info);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
info = currBlock.GetInfo(info);
|
||||
}
|
||||
|
||||
KMemoryInfo.Pool.Release(info);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2641,6 +2656,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
ulong currBaseAddr = info.Address + reservedPagesCount * PageSize;
|
||||
ulong currEndAddr = info.Address + info.Size;
|
||||
|
||||
KMemoryInfo.Pool.Release(info);
|
||||
|
||||
if (aslrAddress >= regionStart &&
|
||||
aslrAddress >= currBaseAddr &&
|
||||
@@ -2721,6 +2738,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
allocationEndAddr <= regionEndAddr &&
|
||||
allocationEndAddr <= currEndAddr)
|
||||
{
|
||||
KMemoryInfo.Pool.Release(info);
|
||||
return address;
|
||||
}
|
||||
}
|
||||
@@ -2731,9 +2749,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
info = currBlock.GetInfo();
|
||||
|
||||
info = currBlock.GetInfo(info);
|
||||
}
|
||||
|
||||
KMemoryInfo.Pool.Release(info);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user