[Ryujinx.HLE] Address dotnet-format issues (#5380)
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Address or silence dotnet format IDE1006 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA2208 warnings * Address or silence dotnet format CA1806 and a few CA1854 warnings * Address dotnet format CA2211 warnings * Address dotnet format CA1822 warnings * Address or silence dotnet format CA1069 warnings * Make dotnet format succeed in style mode * Address or silence dotnet format CA2211 warnings * Address review comments * Address dotnet format CA2208 warnings properly * Make ProcessResult readonly * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Add previously silenced warnings back I have no clue how these disappeared * Revert formatting changes for while and for-loops * Format if-blocks correctly * Run dotnet format style after rebase * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format analyzers after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Fix a few disabled warnings * Fix naming rule violation, Convert shader properties to auto-property and convert values to const * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Fix and silence a few dotnet-format warnings again * Run dotnet format after rebase * Use using declaration instead of block syntax * Address IDE0251 warnings * Address a few disabled IDE0060 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Fix naming rule violations * Fix typo * Add trailing commas, use targeted new and use array initializer * Fix build issues * Fix remaining build issues * Remove SuppressMessage for CA1069 where possible * Address dotnet format issues * Address formatting issues Co-authored-by: Ac_K <acoustik666@gmail.com> * Add GetHashCode implementation for RenderingSurfaceInfo * Explicitly silence CA1822 for every affected method in Syscall * Address formatting issues in Demangler.cs * Address review feedback Co-authored-by: Ac_K <acoustik666@gmail.com> * Revert marking service methods as static * Next dotnet format pass * Address review feedback --------- Co-authored-by: Ac_K <acoustik666@gmail.com>
This commit is contained in:
parent
fec8291c17
commit
326749498b
1015 changed files with 8173 additions and 7615 deletions
|
@ -2,9 +2,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
enum AddressSpaceType
|
||||
{
|
||||
Addr32Bits = 0,
|
||||
Addr36Bits = 1,
|
||||
Addr32Bits = 0,
|
||||
Addr36Bits = 1,
|
||||
Addr32BitsNoMap = 2,
|
||||
Addr39Bits = 3
|
||||
Addr39Bits = 3,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
public const ulong SlabHeapBase = KernelReserveBase + 0x85000;
|
||||
public const ulong SlapHeapSize = 0xa21000;
|
||||
public const ulong SlabHeapEnd = SlabHeapBase + SlapHeapSize;
|
||||
public const ulong SlabHeapEnd = SlabHeapBase + SlapHeapSize;
|
||||
|
||||
public static bool IsHeapPhysicalAddress(ulong address)
|
||||
{
|
||||
return address >= SlabHeapEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,4 +166,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
Owner.DecrementReferenceCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,4 +153,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
class KMemoryBlockSlabManager
|
||||
{
|
||||
private ulong _capacityElements;
|
||||
private readonly ulong _capacityElements;
|
||||
|
||||
public int Count { get; set; }
|
||||
|
||||
|
@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
return (ulong)(Count + count) <= _capacityElements;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,34 +3,34 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
class KMemoryInfo
|
||||
{
|
||||
public ulong Address { get; }
|
||||
public ulong Size { get; }
|
||||
public ulong Size { get; }
|
||||
|
||||
public MemoryState State { get; }
|
||||
public KMemoryPermission Permission { get; }
|
||||
public MemoryAttribute Attribute { get; }
|
||||
public MemoryState State { get; }
|
||||
public KMemoryPermission Permission { get; }
|
||||
public MemoryAttribute Attribute { get; }
|
||||
public KMemoryPermission SourcePermission { get; }
|
||||
|
||||
public int IpcRefCount { get; }
|
||||
public int IpcRefCount { get; }
|
||||
public int DeviceRefCount { get; }
|
||||
|
||||
public KMemoryInfo(
|
||||
ulong address,
|
||||
ulong size,
|
||||
MemoryState state,
|
||||
ulong address,
|
||||
ulong size,
|
||||
MemoryState state,
|
||||
KMemoryPermission permission,
|
||||
MemoryAttribute attribute,
|
||||
MemoryAttribute attribute,
|
||||
KMemoryPermission sourcePermission,
|
||||
int ipcRefCount,
|
||||
int deviceRefCount)
|
||||
int ipcRefCount,
|
||||
int deviceRefCount)
|
||||
{
|
||||
Address = address;
|
||||
Size = size;
|
||||
State = state;
|
||||
Permission = permission;
|
||||
Attribute = attribute;
|
||||
Address = address;
|
||||
Size = size;
|
||||
State = state;
|
||||
Permission = permission;
|
||||
Attribute = attribute;
|
||||
SourcePermission = sourcePermission;
|
||||
IpcRefCount = ipcRefCount;
|
||||
DeviceRefCount = deviceRefCount;
|
||||
IpcRefCount = ipcRefCount;
|
||||
DeviceRefCount = deviceRefCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,4 +239,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
return (EndAddr - address) / KPageTableBase.PageSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
while (depth >= 0)
|
||||
{
|
||||
int ind = (int)(offset / UInt64BitSize);
|
||||
int ind = (int)(offset / UInt64BitSize);
|
||||
int which = (int)(offset % UInt64BitSize);
|
||||
|
||||
ulong mask = 1UL << which;
|
||||
|
@ -247,7 +247,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
while (depth >= 0)
|
||||
{
|
||||
int ind = (int)(offset / UInt64BitSize);
|
||||
int ind = (int)(offset / UInt64BitSize);
|
||||
int which = (int)(offset % UInt64BitSize);
|
||||
|
||||
ulong mask = 1UL << which;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
private class Block
|
||||
{
|
||||
private KPageBitmap _bitmap = new KPageBitmap();
|
||||
private readonly KPageBitmap _bitmap = new();
|
||||
private ulong _heapAddress;
|
||||
private ulong _endOffset;
|
||||
|
||||
|
@ -29,8 +29,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
? 1UL << nextBlockShift
|
||||
: 1UL << blockShift;
|
||||
|
||||
address = BitUtils.AlignDown(address, align);
|
||||
endAddress = BitUtils.AlignUp (endAddress, align);
|
||||
address = BitUtils.AlignDown(address, align);
|
||||
endAddress = BitUtils.AlignUp(endAddress, align);
|
||||
|
||||
_heapAddress = address;
|
||||
_endOffset = (endAddress - address) / (1UL << blockShift);
|
||||
|
@ -84,11 +84,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
}
|
||||
}
|
||||
|
||||
private static readonly int[] _memoryBlockPageShifts = new int[] { 12, 16, 21, 22, 25, 29, 30 };
|
||||
private static readonly int[] _memoryBlockPageShifts = { 12, 16, 21, 22, 25, 29, 30 };
|
||||
|
||||
#pragma warning disable IDE0052 // Remove unread private member
|
||||
private readonly ulong _heapAddress;
|
||||
private readonly ulong _heapSize;
|
||||
private ulong _usedSize;
|
||||
#pragma warning restore IDE0052
|
||||
private readonly int _blocksCount;
|
||||
private readonly Block[] _blocks;
|
||||
|
||||
|
@ -175,19 +177,19 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
int bigIndex = _blocksCount - 1;
|
||||
|
||||
ulong start = address;
|
||||
ulong end = address + pagesCount * KPageTableBase.PageSize;
|
||||
ulong start = address;
|
||||
ulong end = address + pagesCount * KPageTableBase.PageSize;
|
||||
ulong beforeStart = start;
|
||||
ulong beforeEnd = start;
|
||||
ulong afterStart = end;
|
||||
ulong afterEnd = end;
|
||||
ulong beforeEnd = start;
|
||||
ulong afterStart = end;
|
||||
ulong afterEnd = end;
|
||||
|
||||
while (bigIndex >= 0)
|
||||
{
|
||||
ulong blockSize = _blocks[bigIndex].Size;
|
||||
|
||||
ulong bigStart = BitUtils.AlignUp (start, blockSize);
|
||||
ulong bigEnd = BitUtils.AlignDown(end, blockSize);
|
||||
ulong bigStart = BitUtils.AlignUp(start, blockSize);
|
||||
ulong bigEnd = BitUtils.AlignDown(end, blockSize);
|
||||
|
||||
if (bigStart < bigEnd)
|
||||
{
|
||||
|
@ -196,7 +198,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
FreeBlock(block, bigIndex);
|
||||
}
|
||||
|
||||
beforeEnd = bigStart;
|
||||
beforeEnd = bigStart;
|
||||
afterStart = bigEnd;
|
||||
|
||||
break;
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
if (lastNode.Address + lastNode.PagesCount * KPageTableBase.PageSize == address)
|
||||
{
|
||||
address = lastNode.Address;
|
||||
address = lastNode.Address;
|
||||
pagesCount += lastNode.PagesCount;
|
||||
|
||||
Nodes.RemoveLast();
|
||||
|
@ -50,18 +50,18 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
public bool IsEqual(KPageList other)
|
||||
{
|
||||
LinkedListNode<KPageNode> thisNode = Nodes.First;
|
||||
LinkedListNode<KPageNode> thisNode = Nodes.First;
|
||||
LinkedListNode<KPageNode> otherNode = other.Nodes.First;
|
||||
|
||||
while (thisNode != null && otherNode != null)
|
||||
{
|
||||
if (thisNode.Value.Address != otherNode.Value.Address ||
|
||||
if (thisNode.Value.Address != otherNode.Value.Address ||
|
||||
thisNode.Value.PagesCount != otherNode.Value.PagesCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
thisNode = thisNode.Next;
|
||||
thisNode = thisNode.Next;
|
||||
otherNode = otherNode.Next;
|
||||
}
|
||||
|
||||
|
@ -94,4 +94,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
public KPageNode(ulong address, ulong pagesCount)
|
||||
{
|
||||
Address = address;
|
||||
Address = address;
|
||||
PagesCount = pagesCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
/// <inheritdoc/>
|
||||
protected override Result MapMemory(ulong src, ulong dst, ulong pagesCount, KMemoryPermission oldSrcPermission, KMemoryPermission newDstPermission)
|
||||
{
|
||||
KPageList pageList = new KPageList();
|
||||
KPageList pageList = new();
|
||||
GetPhysicalRegions(src, pagesCount * PageSize, pageList);
|
||||
|
||||
Result result = Reprotect(src, pagesCount, KMemoryPermission.None);
|
||||
|
@ -69,8 +69,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
ulong size = pagesCount * PageSize;
|
||||
|
||||
KPageList srcPageList = new KPageList();
|
||||
KPageList dstPageList = new KPageList();
|
||||
KPageList srcPageList = new();
|
||||
KPageList dstPageList = new();
|
||||
|
||||
GetPhysicalRegions(src, size, srcPageList);
|
||||
GetPhysicalRegions(dst, size, dstPageList);
|
||||
|
@ -180,7 +180,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
/// <inheritdoc/>
|
||||
protected override Result Unmap(ulong address, ulong pagesCount)
|
||||
{
|
||||
KPageList pagesToClose = new KPageList();
|
||||
KPageList pagesToClose = new();
|
||||
|
||||
var regions = _cpuMemory.GetPhysicalRegions(address, pagesCount * PageSize);
|
||||
|
||||
|
@ -226,4 +226,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
_cpuMemory.Write(va, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,14 +12,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
abstract class KPageTableBase
|
||||
{
|
||||
private static readonly int[] MappingUnitSizes = new int[]
|
||||
{
|
||||
private static readonly int[] _mappingUnitSizes = {
|
||||
0x1000,
|
||||
0x10000,
|
||||
0x200000,
|
||||
0x400000,
|
||||
0x2000000,
|
||||
0x40000000
|
||||
0x40000000,
|
||||
};
|
||||
|
||||
private const ulong RegionAlignment = 0x200000;
|
||||
|
@ -58,7 +57,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
public ulong AslrRegionStart { get; private set; }
|
||||
public ulong AslrRegionEnd { get; private set; }
|
||||
|
||||
#pragma warning disable IDE0052 // Remove unread private member
|
||||
private ulong _heapCapacity;
|
||||
#pragma warning restore IDE0052
|
||||
|
||||
public ulong PhysicalMemoryUsage { get; private set; }
|
||||
|
||||
|
@ -67,7 +68,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
private MemoryRegion _memRegion;
|
||||
|
||||
private bool _allocateFromBack;
|
||||
private bool _isKernel;
|
||||
private readonly bool _isKernel;
|
||||
|
||||
private bool _aslrEnabled;
|
||||
|
||||
|
@ -77,10 +78,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
private MersenneTwister _randomNumberGenerator;
|
||||
|
||||
private MemoryFillValue _heapFillValue;
|
||||
private MemoryFillValue _ipcFillValue;
|
||||
private readonly MemoryFillValue _heapFillValue;
|
||||
private readonly MemoryFillValue _ipcFillValue;
|
||||
|
||||
private ulong _reservedAddressSpaceSize;
|
||||
private readonly ulong _reservedAddressSpaceSize;
|
||||
|
||||
public KPageTableBase(KernelContext context, ulong reservedAddressSpaceSize)
|
||||
{
|
||||
|
@ -96,7 +97,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
_reservedAddressSpaceSize = reservedAddressSpaceSize;
|
||||
}
|
||||
|
||||
private static readonly int[] AddrSpaceSizes = new int[] { 32, 36, 32, 39 };
|
||||
private static readonly int[] _addrSpaceSizes = { 32, 36, 32, 39 };
|
||||
|
||||
public Result InitializeForProcess(
|
||||
AddressSpaceType addrSpaceType,
|
||||
|
@ -109,13 +110,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
if ((uint)addrSpaceType > (uint)AddressSpaceType.Addr39Bits)
|
||||
{
|
||||
throw new ArgumentException(nameof(addrSpaceType));
|
||||
throw new ArgumentException($"AddressSpaceType bigger than {(uint)AddressSpaceType.Addr39Bits}: {(uint)addrSpaceType}", nameof(addrSpaceType));
|
||||
}
|
||||
|
||||
_contextId = Context.ContextIdManager.GetId();
|
||||
|
||||
ulong addrSpaceBase = 0;
|
||||
ulong addrSpaceSize = 1UL << AddrSpaceSizes[(int)addrSpaceType];
|
||||
ulong addrSpaceSize = 1UL << _addrSpaceSizes[(int)addrSpaceType];
|
||||
|
||||
Result result = CreateUserAddressSpace(
|
||||
addrSpaceType,
|
||||
|
@ -157,10 +158,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
ulong endAddr = address + size;
|
||||
|
||||
Region aliasRegion = new Region();
|
||||
Region heapRegion = new Region();
|
||||
Region stackRegion = new Region();
|
||||
Region tlsIoRegion = new Region();
|
||||
Region aliasRegion = new();
|
||||
Region heapRegion = new();
|
||||
Region stackRegion = new();
|
||||
Region tlsIoRegion = new();
|
||||
|
||||
ulong codeRegionSize;
|
||||
ulong stackAndTlsIoStart;
|
||||
|
@ -238,8 +239,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
stackAndTlsIoEnd = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default: throw new ArgumentException(nameof(addrSpaceType));
|
||||
default:
|
||||
throw new ArgumentException($"AddressSpaceType bigger than {(uint)AddressSpaceType.Addr39Bits}: {(uint)addrSpaceType}", nameof(addrSpaceType));
|
||||
}
|
||||
|
||||
CodeRegionEnd = CodeRegionStart + codeRegionSize;
|
||||
|
@ -374,10 +375,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
private long GetRandomValue(long min, long max)
|
||||
{
|
||||
if (_randomNumberGenerator == null)
|
||||
{
|
||||
_randomNumberGenerator = new MersenneTwister(0);
|
||||
}
|
||||
_randomNumberGenerator ??= new MersenneTwister(0);
|
||||
|
||||
return _randomNumberGenerator.GenRandomNumber(min, max);
|
||||
}
|
||||
|
@ -442,7 +440,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
lock (_blockManager)
|
||||
{
|
||||
KPageList currentPageList = new KPageList();
|
||||
KPageList currentPageList = new();
|
||||
|
||||
GetPhysicalRegions(address, size, currentPageList);
|
||||
|
||||
|
@ -486,13 +484,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
}
|
||||
}
|
||||
|
||||
public Result MapNormalMemory(long address, long size, KMemoryPermission permission)
|
||||
public static Result MapNormalMemory(long address, long size, KMemoryPermission permission)
|
||||
{
|
||||
// TODO.
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public Result MapIoMemory(long address, long size, KMemoryPermission permission)
|
||||
public static Result MapIoMemory(long address, long size, KMemoryPermission permission)
|
||||
{
|
||||
// TODO.
|
||||
return Result.Success;
|
||||
|
@ -1174,8 +1172,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
return KernelResult.InvalidMemState;
|
||||
}
|
||||
|
||||
KPageList srcPageList = new KPageList();
|
||||
KPageList dstPageList = new KPageList();
|
||||
KPageList srcPageList = new();
|
||||
KPageList dstPageList = new();
|
||||
|
||||
srcPageTable.GetPhysicalRegions(src, size, srcPageList);
|
||||
GetPhysicalRegions(dst, size, dstPageList);
|
||||
|
@ -1681,11 +1679,17 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
switch (state)
|
||||
{
|
||||
case MemoryState.IpcBuffer0: stateMask = MemoryState.IpcSendAllowedType0; break;
|
||||
case MemoryState.IpcBuffer1: stateMask = MemoryState.IpcSendAllowedType1; break;
|
||||
case MemoryState.IpcBuffer3: stateMask = MemoryState.IpcSendAllowedType3; break;
|
||||
|
||||
default: return KernelResult.InvalidCombination;
|
||||
case MemoryState.IpcBuffer0:
|
||||
stateMask = MemoryState.IpcSendAllowedType0;
|
||||
break;
|
||||
case MemoryState.IpcBuffer1:
|
||||
stateMask = MemoryState.IpcSendAllowedType1;
|
||||
break;
|
||||
case MemoryState.IpcBuffer3:
|
||||
stateMask = MemoryState.IpcSendAllowedType3;
|
||||
break;
|
||||
default:
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
KMemoryPermission permissionMask = permission == KMemoryPermission.ReadAndWrite
|
||||
|
@ -1822,9 +1826,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
ulong va = 0;
|
||||
|
||||
for (int unit = MappingUnitSizes.Length - 1; unit >= 0 && va == 0; unit--)
|
||||
for (int unit = _mappingUnitSizes.Length - 1; unit >= 0 && va == 0; unit--)
|
||||
{
|
||||
int alignment = MappingUnitSizes[unit];
|
||||
int alignment = _mappingUnitSizes[unit];
|
||||
|
||||
va = AllocateVa(AliasRegionStart, regionPagesCount, neededPagesCount, alignment);
|
||||
}
|
||||
|
@ -1937,7 +1941,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
if (srcPageTable.Supports4KBPages)
|
||||
{
|
||||
KPageList pageList = new KPageList();
|
||||
KPageList pageList = new();
|
||||
srcPageTable.GetPhysicalRegions(addressRounded, alignedSize, pageList);
|
||||
|
||||
result = MapPages(currentVa, pageList, permission, MemoryMapFlags.None);
|
||||
|
@ -2075,11 +2079,17 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
switch (state)
|
||||
{
|
||||
case MemoryState.IpcBuffer0: stateMask = MemoryState.IpcSendAllowedType0; break;
|
||||
case MemoryState.IpcBuffer1: stateMask = MemoryState.IpcSendAllowedType1; break;
|
||||
case MemoryState.IpcBuffer3: stateMask = MemoryState.IpcSendAllowedType3; break;
|
||||
|
||||
default: return KernelResult.InvalidCombination;
|
||||
case MemoryState.IpcBuffer0:
|
||||
stateMask = MemoryState.IpcSendAllowedType0;
|
||||
break;
|
||||
case MemoryState.IpcBuffer1:
|
||||
stateMask = MemoryState.IpcSendAllowedType1;
|
||||
break;
|
||||
case MemoryState.IpcBuffer3:
|
||||
stateMask = MemoryState.IpcSendAllowedType3;
|
||||
break;
|
||||
default:
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
MemoryAttribute attributeMask =
|
||||
|
@ -2392,7 +2402,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
if (pageList != null)
|
||||
{
|
||||
KPageList currentPageList = new KPageList();
|
||||
KPageList currentPageList = new();
|
||||
|
||||
GetPhysicalRegions(address, pagesCount * PageSize, currentPageList);
|
||||
|
||||
|
@ -3050,4 +3060,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
/// <exception cref="Ryujinx.Memory.InvalidMemoryRegionException">Throw for unhandled invalid or unmapped memory accesses</exception>
|
||||
protected abstract void Write(ulong va, ReadOnlySpan<byte> data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
_pageList = null;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
public readonly void Dispose()
|
||||
{
|
||||
_pageList?.DecrementPagesReferenceCount(_manager);
|
||||
}
|
||||
|
|
|
@ -72,4 +72,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
return memoryManager.UnmapPages(address, _pageList, MemoryState.SharedMemory);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
class KSlabHeap
|
||||
{
|
||||
private LinkedList<ulong> _items;
|
||||
private readonly LinkedList<ulong> _items;
|
||||
|
||||
public KSlabHeap(ulong pa, ulong itemSize, ulong size)
|
||||
{
|
||||
|
@ -47,4 +47,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,4 +127,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,20 +3,20 @@ using System;
|
|||
namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
{
|
||||
[Flags]
|
||||
enum MemoryAttribute : byte
|
||||
enum MemoryAttribute : byte
|
||||
{
|
||||
None = 0,
|
||||
Mask = 0xff,
|
||||
|
||||
Borrowed = 1 << 0,
|
||||
IpcMapped = 1 << 1,
|
||||
Borrowed = 1 << 0,
|
||||
IpcMapped = 1 << 1,
|
||||
DeviceMapped = 1 << 2,
|
||||
Uncached = 1 << 3,
|
||||
Uncached = 1 << 3,
|
||||
|
||||
IpcAndDeviceMapped = IpcMapped | DeviceMapped,
|
||||
|
||||
BorrowedAndIpcMapped = Borrowed | IpcMapped,
|
||||
|
||||
DeviceMappedAndUncached = DeviceMapped | Uncached
|
||||
DeviceMappedAndUncached = DeviceMapped | Uncached,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,16 +5,16 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
[Flags]
|
||||
enum KMemoryPermission : uint
|
||||
{
|
||||
None = 0,
|
||||
None = 0,
|
||||
UserMask = Read | Write | Execute,
|
||||
Mask = uint.MaxValue,
|
||||
Mask = uint.MaxValue,
|
||||
|
||||
Read = 1 << 0,
|
||||
Write = 1 << 1,
|
||||
Execute = 1 << 2,
|
||||
Read = 1 << 0,
|
||||
Write = 1 << 1,
|
||||
Execute = 1 << 2,
|
||||
DontCare = 1 << 28,
|
||||
|
||||
ReadAndWrite = Read | Write,
|
||||
ReadAndExecute = Read | Execute
|
||||
ReadAndWrite = Read | Write,
|
||||
ReadAndExecute = Read | Execute,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
enum MemoryRegion
|
||||
{
|
||||
Application = 0,
|
||||
Applet = 1,
|
||||
Service = 2,
|
||||
NvServices = 3
|
||||
Applet = 1,
|
||||
Service = 2,
|
||||
NvServices = 3,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,46 +5,46 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
[Flags]
|
||||
enum MemoryState : uint
|
||||
{
|
||||
Unmapped = 0x00000000,
|
||||
Io = 0x00002001,
|
||||
Normal = 0x00042002,
|
||||
CodeStatic = 0x00DC7E03,
|
||||
CodeMutable = 0x03FEBD04,
|
||||
Heap = 0x037EBD05,
|
||||
SharedMemory = 0x00402006,
|
||||
ModCodeStatic = 0x00DD7E08,
|
||||
ModCodeMutable = 0x03FFBD09,
|
||||
IpcBuffer0 = 0x005C3C0A,
|
||||
Stack = 0x005C3C0B,
|
||||
ThreadLocal = 0x0040200C,
|
||||
Unmapped = 0x00000000,
|
||||
Io = 0x00002001,
|
||||
Normal = 0x00042002,
|
||||
CodeStatic = 0x00DC7E03,
|
||||
CodeMutable = 0x03FEBD04,
|
||||
Heap = 0x037EBD05,
|
||||
SharedMemory = 0x00402006,
|
||||
ModCodeStatic = 0x00DD7E08,
|
||||
ModCodeMutable = 0x03FFBD09,
|
||||
IpcBuffer0 = 0x005C3C0A,
|
||||
Stack = 0x005C3C0B,
|
||||
ThreadLocal = 0x0040200C,
|
||||
TransferMemoryIsolated = 0x015C3C0D,
|
||||
TransferMemory = 0x005C380E,
|
||||
ProcessMemory = 0x0040380F,
|
||||
Reserved = 0x00000010,
|
||||
IpcBuffer1 = 0x005C3811,
|
||||
IpcBuffer3 = 0x004C2812,
|
||||
KernelStack = 0x00002013,
|
||||
CodeReadOnly = 0x00402214,
|
||||
CodeWritable = 0x00402015,
|
||||
UserMask = 0xff,
|
||||
Mask = 0xffffffff,
|
||||
TransferMemory = 0x005C380E,
|
||||
ProcessMemory = 0x0040380F,
|
||||
Reserved = 0x00000010,
|
||||
IpcBuffer1 = 0x005C3811,
|
||||
IpcBuffer3 = 0x004C2812,
|
||||
KernelStack = 0x00002013,
|
||||
CodeReadOnly = 0x00402214,
|
||||
CodeWritable = 0x00402015,
|
||||
UserMask = 0xff,
|
||||
Mask = 0xffffffff,
|
||||
|
||||
PermissionChangeAllowed = 1 << 8,
|
||||
PermissionChangeAllowed = 1 << 8,
|
||||
ForceReadWritableByDebugSyscalls = 1 << 9,
|
||||
IpcSendAllowedType0 = 1 << 10,
|
||||
IpcSendAllowedType3 = 1 << 11,
|
||||
IpcSendAllowedType1 = 1 << 12,
|
||||
ProcessPermissionChangeAllowed = 1 << 14,
|
||||
MapAllowed = 1 << 15,
|
||||
UnmapProcessCodeMemoryAllowed = 1 << 16,
|
||||
TransferMemoryAllowed = 1 << 17,
|
||||
QueryPhysicalAddressAllowed = 1 << 18,
|
||||
MapDeviceAllowed = 1 << 19,
|
||||
MapDeviceAlignedAllowed = 1 << 20,
|
||||
IpcBufferAllowed = 1 << 21,
|
||||
IsPoolAllocated = 1 << 22,
|
||||
MapProcessAllowed = 1 << 23,
|
||||
AttributeChangeAllowed = 1 << 24,
|
||||
CodeMemoryAllowed = 1 << 25
|
||||
IpcSendAllowedType0 = 1 << 10,
|
||||
IpcSendAllowedType3 = 1 << 11,
|
||||
IpcSendAllowedType1 = 1 << 12,
|
||||
ProcessPermissionChangeAllowed = 1 << 14,
|
||||
MapAllowed = 1 << 15,
|
||||
UnmapProcessCodeMemoryAllowed = 1 << 16,
|
||||
TransferMemoryAllowed = 1 << 17,
|
||||
QueryPhysicalAddressAllowed = 1 << 18,
|
||||
MapDeviceAllowed = 1 << 19,
|
||||
MapDeviceAlignedAllowed = 1 << 20,
|
||||
IpcBufferAllowed = 1 << 21,
|
||||
IsPoolAllocated = 1 << 22,
|
||||
MapProcessAllowed = 1 << 23,
|
||||
AttributeChangeAllowed = 1 << 24,
|
||||
CodeMemoryAllowed = 1 << 25,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue