Add support for PermissionLocked attribute added on firmware 17.0.0 (#6072)

* Update MemoryState enum and add new flags

* Add support for new PermissionLocked attribute added on firmware 17.0.0

* Format whitespace
This commit is contained in:
gdkchan 2024-01-03 20:05:14 -03:00 committed by GitHub
parent f11d663df7
commit 6f50b9bdb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 172 additions and 35 deletions

View file

@ -675,7 +675,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
KMemoryPermission.None,
MemoryAttribute.Mask,
MemoryAttribute.None,
MemoryAttribute.IpcAndDeviceMapped,
MemoryAttribute.IpcAndDeviceMapped | MemoryAttribute.PermissionLocked,
out MemoryState state,
out _,
out _);
@ -687,7 +687,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
state,
KMemoryPermission.None,
KMemoryPermission.None,
MemoryAttribute.Mask,
MemoryAttribute.Mask & ~MemoryAttribute.PermissionLocked,
MemoryAttribute.None);
if (success)
@ -913,19 +913,27 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
return Result.Success;
}
public Result SetMemoryAttribute(
ulong address,
ulong size,
MemoryAttribute attributeMask,
MemoryAttribute attributeValue)
public Result SetMemoryAttribute(ulong address, ulong size, MemoryAttribute attributeMask, MemoryAttribute attributeValue)
{
lock (_blockManager)
{
MemoryState stateCheckMask = 0;
if (attributeMask.HasFlag(MemoryAttribute.Uncached))
{
stateCheckMask = MemoryState.AttributeChangeAllowed;
}
if (attributeMask.HasFlag(MemoryAttribute.PermissionLocked))
{
stateCheckMask |= MemoryState.PermissionLockAllowed;
}
if (CheckRange(
address,
size,
MemoryState.AttributeChangeAllowed,
MemoryState.AttributeChangeAllowed,
stateCheckMask,
stateCheckMask,
KMemoryPermission.None,
KMemoryPermission.None,
MemoryAttribute.BorrowedAndIpcMapped,