[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:
@@ -19,4 +19,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return (uint)BitOperations.TrailingZeroCount(type.GetFlag());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,18 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
enum CapabilityType : uint
|
||||
{
|
||||
CorePriority = (1u << 3) - 1,
|
||||
SyscallMask = (1u << 4) - 1,
|
||||
MapRange = (1u << 6) - 1,
|
||||
MapIoPage = (1u << 7) - 1,
|
||||
MapRegion = (1u << 10) - 1,
|
||||
CorePriority = (1u << 3) - 1,
|
||||
SyscallMask = (1u << 4) - 1,
|
||||
MapRange = (1u << 6) - 1,
|
||||
MapIoPage = (1u << 7) - 1,
|
||||
MapRegion = (1u << 10) - 1,
|
||||
InterruptPair = (1u << 11) - 1,
|
||||
ProgramType = (1u << 13) - 1,
|
||||
ProgramType = (1u << 13) - 1,
|
||||
KernelVersion = (1u << 14) - 1,
|
||||
HandleTable = (1u << 15) - 1,
|
||||
DebugFlags = (1u << 16) - 1,
|
||||
HandleTable = (1u << 15) - 1,
|
||||
DebugFlags = (1u << 16) - 1,
|
||||
|
||||
Invalid = 0u,
|
||||
Padding = ~0u
|
||||
Invalid = 0u,
|
||||
Padding = ~0u,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
private const int Mod0 = 'M' << 0 | 'O' << 8 | 'D' << 16 | '0' << 24;
|
||||
|
||||
private KProcess _owner;
|
||||
private readonly KProcess _owner;
|
||||
|
||||
private class Image
|
||||
{
|
||||
@@ -27,12 +27,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
public Image(ulong baseAddress, ulong size, ElfSymbol[] symbols)
|
||||
{
|
||||
BaseAddress = baseAddress;
|
||||
Size = size;
|
||||
Symbols = symbols;
|
||||
Size = size;
|
||||
Symbols = symbols;
|
||||
}
|
||||
}
|
||||
|
||||
private List<Image> _images;
|
||||
private readonly List<Image> _images;
|
||||
|
||||
private int _loaded;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
var context = thread.Context;
|
||||
|
||||
StringBuilder trace = new StringBuilder();
|
||||
StringBuilder trace = new();
|
||||
|
||||
trace.AppendLine($"Process: {_owner.Name}, PID: {_owner.Pid}");
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
var context = thread.Context;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder sb = new();
|
||||
|
||||
string GetReg(int x)
|
||||
{
|
||||
@@ -145,11 +145,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private bool TryGetSubName(Image image, ulong address, out ElfSymbol symbol)
|
||||
private static bool TryGetSubName(Image image, ulong address, out ElfSymbol symbol)
|
||||
{
|
||||
address -= image.BaseAddress;
|
||||
|
||||
int left = 0;
|
||||
int left = 0;
|
||||
int right = image.Symbols.Length - 1;
|
||||
|
||||
while (left <= right)
|
||||
@@ -190,9 +190,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
public ulong Offset;
|
||||
public ulong SubOffset;
|
||||
|
||||
public string ImageDisplay => $"{ImageName}:0x{Offset:x4}";
|
||||
public string SubDisplay => SubOffset == 0 ? SubName : $"{SubName}:0x{SubOffset:x4}";
|
||||
public string SpDisplay => SubOffset == 0 ? "SP" : $"SP:-0x{SubOffset:x4}";
|
||||
public readonly string ImageDisplay => $"{ImageName}:0x{Offset:x4}";
|
||||
public readonly string SubDisplay => SubOffset == 0 ? SubName : $"{SubName}:0x{SubOffset:x4}";
|
||||
public readonly string SpDisplay => SubOffset == 0 ? "SP" : $"SP:-0x{SubOffset:x4}";
|
||||
}
|
||||
|
||||
private bool AnalyzePointer(out PointerInfo info, ulong address, KThread thread)
|
||||
@@ -324,7 +324,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
private void ScanMemoryForTextSegments()
|
||||
{
|
||||
ulong oldAddress = 0;
|
||||
ulong address = 0;
|
||||
ulong address = 0;
|
||||
|
||||
while (address >= oldAddress)
|
||||
{
|
||||
@@ -355,7 +355,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return;
|
||||
}
|
||||
|
||||
Dictionary<ElfDynamicTag, ulong> dynamic = new Dictionary<ElfDynamicTag, ulong>();
|
||||
Dictionary<ElfDynamicTag, ulong> dynamic = new();
|
||||
|
||||
int mod0Magic = memory.Read<int>(mod0Offset + 0x0);
|
||||
|
||||
@@ -364,12 +364,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return;
|
||||
}
|
||||
|
||||
ulong dynamicOffset = memory.Read<uint>(mod0Offset + 0x4) + mod0Offset;
|
||||
ulong bssStartOffset = memory.Read<uint>(mod0Offset + 0x8) + mod0Offset;
|
||||
ulong bssEndOffset = memory.Read<uint>(mod0Offset + 0xc) + mod0Offset;
|
||||
ulong dynamicOffset = memory.Read<uint>(mod0Offset + 0x4) + mod0Offset;
|
||||
ulong bssStartOffset = memory.Read<uint>(mod0Offset + 0x8) + mod0Offset;
|
||||
ulong bssEndOffset = memory.Read<uint>(mod0Offset + 0xc) + mod0Offset;
|
||||
ulong ehHdrStartOffset = memory.Read<uint>(mod0Offset + 0x10) + mod0Offset;
|
||||
ulong ehHdrEndOffset = memory.Read<uint>(mod0Offset + 0x14) + mod0Offset;
|
||||
ulong modObjOffset = memory.Read<uint>(mod0Offset + 0x18) + mod0Offset;
|
||||
ulong ehHdrEndOffset = memory.Read<uint>(mod0Offset + 0x14) + mod0Offset;
|
||||
ulong modObjOffset = memory.Read<uint>(mod0Offset + 0x18) + mod0Offset;
|
||||
|
||||
bool isAArch32 = memory.Read<ulong>(dynamicOffset) > 0xFFFFFFFF || memory.Read<ulong>(dynamicOffset + 0x10) > 0xFFFFFFFF;
|
||||
|
||||
@@ -381,14 +381,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
if (isAArch32)
|
||||
{
|
||||
tagVal = memory.Read<uint>(dynamicOffset + 0);
|
||||
value = memory.Read<uint>(dynamicOffset + 4);
|
||||
value = memory.Read<uint>(dynamicOffset + 4);
|
||||
|
||||
dynamicOffset += 0x8;
|
||||
}
|
||||
else
|
||||
{
|
||||
tagVal = memory.Read<ulong>(dynamicOffset + 0);
|
||||
value = memory.Read<ulong>(dynamicOffset + 8);
|
||||
value = memory.Read<ulong>(dynamicOffset + 8);
|
||||
|
||||
dynamicOffset += 0x10;
|
||||
}
|
||||
@@ -413,7 +413,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
ulong strTblAddr = textOffset + strTab;
|
||||
ulong symTblAddr = textOffset + symTab;
|
||||
|
||||
List<ElfSymbol> symbols = new List<ElfSymbol>();
|
||||
List<ElfSymbol> symbols = new();
|
||||
|
||||
while (symTblAddr < strTblAddr)
|
||||
{
|
||||
@@ -430,7 +430,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
}
|
||||
}
|
||||
|
||||
private ElfSymbol GetSymbol64(IVirtualMemoryManager memory, ulong address, ulong strTblAddr)
|
||||
private static ElfSymbol GetSymbol64(IVirtualMemoryManager memory, ulong address, ulong strTblAddr)
|
||||
{
|
||||
ElfSymbol64 sym = memory.Read<ElfSymbol64>(address);
|
||||
|
||||
@@ -446,7 +446,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return new ElfSymbol(name, sym.Info, sym.Other, sym.SectionIndex, sym.ValueAddress, sym.Size);
|
||||
}
|
||||
|
||||
private ElfSymbol GetSymbol32(IVirtualMemoryManager memory, ulong address, ulong strTblAddr)
|
||||
private static ElfSymbol GetSymbol32(IVirtualMemoryManager memory, ulong address, ulong strTblAddr)
|
||||
{
|
||||
ElfSymbol32 sym = memory.Read<ElfSymbol32>(address);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
private const int IdMasksCount = 8;
|
||||
|
||||
private int[] _idMasks;
|
||||
private readonly int[] _idMasks;
|
||||
|
||||
private int _nextFreeBitHint;
|
||||
|
||||
@@ -67,17 +67,17 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
private bool TestBit(int bit)
|
||||
{
|
||||
return (_idMasks[_nextFreeBitHint / 32] & (1 << (_nextFreeBitHint & 31))) != 0;
|
||||
return (_idMasks[bit / 32] & (1 << (bit & 31))) != 0;
|
||||
}
|
||||
|
||||
private void SetBit(int bit)
|
||||
{
|
||||
_idMasks[_nextFreeBitHint / 32] |= (1 << (_nextFreeBitHint & 31));
|
||||
_idMasks[bit / 32] |= (1 << (bit & 31));
|
||||
}
|
||||
|
||||
private void ClearBit(int bit)
|
||||
{
|
||||
_idMasks[_nextFreeBitHint / 32] &= ~(1 << (_nextFreeBitHint & 31));
|
||||
_idMasks[bit / 32] &= ~(1 << (bit & 31));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
public int Index { get; private set; }
|
||||
|
||||
public ushort HandleId { get; set; }
|
||||
public KAutoObject Obj { get; set; }
|
||||
public ushort HandleId { get; set; }
|
||||
public KAutoObject Obj { get; set; }
|
||||
|
||||
public KHandleEntry(int index)
|
||||
{
|
||||
Index = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
class KHandleTable
|
||||
{
|
||||
public const int SelfThreadHandle = (0x1ffff << 15) | 0;
|
||||
public const int SelfThreadHandle = (0x1ffff << 15) | 0;
|
||||
public const int SelfProcessHandle = (0x1ffff << 15) | 1;
|
||||
|
||||
private readonly KernelContext _context;
|
||||
|
||||
private KHandleEntry[] _table;
|
||||
|
||||
private KHandleEntry _tableHead;
|
||||
@@ -23,11 +21,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
private ushort _idCounter;
|
||||
|
||||
public KHandleTable(KernelContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public Result Initialize(uint size)
|
||||
{
|
||||
if (size > 1024)
|
||||
@@ -81,7 +74,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
_nextFreeEntry = entry.Next;
|
||||
|
||||
entry.Obj = obj;
|
||||
entry.Obj = obj;
|
||||
entry.HandleId = _idCounter;
|
||||
|
||||
_activeSlotsCount++;
|
||||
@@ -143,7 +136,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
KHandleEntry entry = _table[index];
|
||||
|
||||
entry.Obj = null;
|
||||
entry.Obj = null;
|
||||
entry.Next = _nextFreeEntry;
|
||||
|
||||
_nextFreeEntry = entry;
|
||||
@@ -154,14 +147,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
public void SetReservedHandleObj(int handle, KAutoObject obj)
|
||||
{
|
||||
int index = (handle >> 0) & 0x7fff;
|
||||
int index = (handle >> 0) & 0x7fff;
|
||||
int handleId = (handle >> 15);
|
||||
|
||||
lock (_table)
|
||||
{
|
||||
KHandleEntry entry = _table[index];
|
||||
|
||||
entry.Obj = obj;
|
||||
entry.Obj = obj;
|
||||
entry.HandleId = (ushort)handleId;
|
||||
|
||||
obj.IncrementReferenceCount();
|
||||
@@ -177,7 +170,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return false;
|
||||
}
|
||||
|
||||
int index = (handle >> 0) & 0x7fff;
|
||||
int index = (handle >> 0) & 0x7fff;
|
||||
int handleId = (handle >> 15);
|
||||
|
||||
KAutoObject obj = null;
|
||||
@@ -192,7 +185,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
if ((obj = entry.Obj) != null && entry.HandleId == handleId)
|
||||
{
|
||||
entry.Obj = null;
|
||||
entry.Obj = null;
|
||||
entry.Next = _nextFreeEntry;
|
||||
|
||||
_nextFreeEntry = entry;
|
||||
@@ -214,7 +207,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
public T GetObject<T>(int handle) where T : KAutoObject
|
||||
{
|
||||
int index = (handle >> 0) & 0x7fff;
|
||||
int index = (handle >> 0) & 0x7fff;
|
||||
int handleId = (handle >> 15);
|
||||
|
||||
lock (_table)
|
||||
@@ -273,7 +266,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
}
|
||||
|
||||
entry.Obj.DecrementReferenceCount();
|
||||
entry.Obj = null;
|
||||
entry.Obj = null;
|
||||
entry.Next = _nextFreeEntry;
|
||||
|
||||
_nextFreeEntry = entry;
|
||||
@@ -282,4 +275,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
public KPageTableBase MemoryManager { get; private set; }
|
||||
|
||||
private SortedDictionary<ulong, KTlsPageInfo> _fullTlsPages;
|
||||
private SortedDictionary<ulong, KTlsPageInfo> _freeTlsPages;
|
||||
private readonly SortedDictionary<ulong, KTlsPageInfo> _fullTlsPages;
|
||||
private readonly SortedDictionary<ulong, KTlsPageInfo> _freeTlsPages;
|
||||
|
||||
public int DefaultCpuCore { get; set; }
|
||||
|
||||
@@ -66,19 +66,17 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
public bool IsApplication { get; private set; }
|
||||
public ulong Pid { get; private set; }
|
||||
|
||||
private long _creationTimestamp;
|
||||
private ulong _entrypoint;
|
||||
private ThreadStart _customThreadStart;
|
||||
private ulong _imageSize;
|
||||
private ulong _mainThreadStackSize;
|
||||
private ulong _memoryUsageCapacity;
|
||||
private int _version;
|
||||
|
||||
public KHandleTable HandleTable { get; private set; }
|
||||
|
||||
public ulong UserExceptionContextAddress { get; private set; }
|
||||
|
||||
private LinkedList<KThread> _threads;
|
||||
private readonly LinkedList<KThread> _threads;
|
||||
|
||||
public bool IsPaused { get; private set; }
|
||||
|
||||
@@ -107,7 +105,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
PinnedThreads = new KThread[KScheduler.CpuCoresCount];
|
||||
|
||||
// TODO: Remove once we no longer need to initialize it externally.
|
||||
HandleTable = new KHandleTable(context);
|
||||
HandleTable = new KHandleTable();
|
||||
|
||||
_threads = new LinkedList<KThread>();
|
||||
|
||||
@@ -347,10 +345,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
State = ProcessState.Created;
|
||||
|
||||
_creationTimestamp = PerformanceCounter.ElapsedMilliseconds;
|
||||
|
||||
Flags = creationInfo.Flags;
|
||||
_version = creationInfo.Version;
|
||||
TitleId = creationInfo.TitleId;
|
||||
_entrypoint = creationInfo.CodeAddress;
|
||||
_imageSize = (ulong)creationInfo.CodePagesCount * KPageTableBase.PageSize;
|
||||
@@ -370,8 +365,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
MemoryManager.AliasRegionEnd -
|
||||
MemoryManager.AliasRegionStart;
|
||||
break;
|
||||
|
||||
default: throw new InvalidOperationException($"Invalid MMU flags value 0x{Flags:x2}.");
|
||||
default:
|
||||
throw new InvalidOperationException($"Invalid MMU flags value 0x{Flags:x2}.");
|
||||
}
|
||||
|
||||
GenerateRandomEntropy();
|
||||
@@ -476,9 +471,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
Result result = Result.Success;
|
||||
|
||||
KTlsPageInfo pageInfo;
|
||||
|
||||
if (_fullTlsPages.TryGetValue(tlsPageAddr, out pageInfo))
|
||||
if (_fullTlsPages.TryGetValue(tlsPageAddr, out KTlsPageInfo pageInfo))
|
||||
{
|
||||
// TLS page was full, free slot and move to free pages tree.
|
||||
_fullTlsPages.Remove(tlsPageAddr);
|
||||
@@ -525,10 +519,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
private void GenerateRandomEntropy()
|
||||
{
|
||||
// TODO.
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
public Result Start(int mainThreadPriority, ulong stackSize)
|
||||
{
|
||||
@@ -549,7 +545,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
if (_mainThreadStackSize != 0)
|
||||
{
|
||||
throw new InvalidOperationException("Trying to start a process with a invalid state!");
|
||||
throw new InvalidOperationException("Trying to start a process with an invalid state!");
|
||||
}
|
||||
|
||||
ulong stackSizeRounded = BitUtils.AlignUp<ulong>(stackSize, KPageTableBase.PageSize);
|
||||
@@ -648,7 +644,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return result;
|
||||
}
|
||||
|
||||
HandleTable = new KHandleTable(KernelContext);
|
||||
HandleTable = new KHandleTable();
|
||||
|
||||
result = HandleTable.Initialize(Capabilities.HandleTableSize);
|
||||
|
||||
@@ -1018,22 +1014,19 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
}
|
||||
}
|
||||
|
||||
private void SignalExitToDebugTerminated()
|
||||
private static void SignalExitToDebugTerminated()
|
||||
{
|
||||
// TODO: Debug events.
|
||||
}
|
||||
|
||||
private void SignalExitToDebugExited()
|
||||
private static void SignalExitToDebugExited()
|
||||
{
|
||||
// TODO: Debug events.
|
||||
}
|
||||
|
||||
private void SignalExit()
|
||||
{
|
||||
if (ResourceLimit != null)
|
||||
{
|
||||
ResourceLimit.Release(LimitableResource.Memory, GetMemoryUsage());
|
||||
}
|
||||
ResourceLimit?.Release(LimitableResource.Memory, GetMemoryUsage());
|
||||
|
||||
KernelContext.CriticalSection.Enter();
|
||||
|
||||
@@ -1075,7 +1068,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
ProcessCreationFlags.AddressSpace64BitDeprecated => 36,
|
||||
ProcessCreationFlags.AddressSpace32BitWithoutAlias => 32,
|
||||
ProcessCreationFlags.AddressSpace64Bit => 39,
|
||||
_ => 39
|
||||
_ => 39,
|
||||
};
|
||||
|
||||
bool for64Bit = flags.HasFlag(ProcessCreationFlags.Is64Bit);
|
||||
@@ -1184,10 +1177,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExceptionUserThread(KThread thread)
|
||||
public static bool IsExceptionUserThread(KThread thread)
|
||||
{
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
public byte[] SvcAccessMask { get; }
|
||||
public byte[] IrqAccessMask { get; }
|
||||
|
||||
public ulong AllowedCpuCoresMask { get; private set; }
|
||||
public ulong AllowedCpuCoresMask { get; private set; }
|
||||
public ulong AllowedThreadPriosMask { get; private set; }
|
||||
|
||||
public uint DebuggingFlags { get; private set; }
|
||||
public uint HandleTableSize { get; private set; }
|
||||
public uint DebuggingFlags { get; private set; }
|
||||
public uint HandleTableSize { get; private set; }
|
||||
public uint KernelReleaseVersion { get; private set; }
|
||||
public uint ApplicationType { get; private set; }
|
||||
public uint ApplicationType { get; private set; }
|
||||
|
||||
public KProcessCapabilities()
|
||||
{
|
||||
@@ -28,10 +28,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
public Result InitializeForKernel(ReadOnlySpan<uint> capabilities, KPageTableBase memoryManager)
|
||||
{
|
||||
AllowedCpuCoresMask = 0xf;
|
||||
AllowedCpuCoresMask = 0xf;
|
||||
AllowedThreadPriosMask = ulong.MaxValue;
|
||||
DebuggingFlags &= ~3u;
|
||||
KernelReleaseVersion = KProcess.KernelVersionPacked;
|
||||
DebuggingFlags &= ~3u;
|
||||
KernelReleaseVersion = KProcess.KernelVersionPacked;
|
||||
|
||||
return Parse(capabilities, memoryManager);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
}
|
||||
|
||||
long address = ((long)prevCap << 5) & 0xffffff000;
|
||||
long size = ((long)cap << 5) & 0xfffff000;
|
||||
long size = ((long)cap << 5) & 0xfffff000;
|
||||
|
||||
if (((ulong)(address + size - 1) >> 36) != 0)
|
||||
{
|
||||
@@ -101,11 +101,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
if ((cap >> 31) != 0)
|
||||
{
|
||||
result = memoryManager.MapNormalMemory(address, size, perm);
|
||||
result = KPageTableBase.MapNormalMemory(address, size, perm);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = memoryManager.MapIoMemory(address, size, perm);
|
||||
result = KPageTableBase.MapIoMemory(address, size, perm);
|
||||
}
|
||||
|
||||
if (result != Result.Success)
|
||||
@@ -144,168 +144,168 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
switch (code)
|
||||
{
|
||||
case CapabilityType.CorePriority:
|
||||
{
|
||||
if (AllowedCpuCoresMask != 0 || AllowedThreadPriosMask != 0)
|
||||
{
|
||||
return KernelResult.InvalidCapability;
|
||||
if (AllowedCpuCoresMask != 0 || AllowedThreadPriosMask != 0)
|
||||
{
|
||||
return KernelResult.InvalidCapability;
|
||||
}
|
||||
|
||||
uint lowestCpuCore = (cap >> 16) & 0xff;
|
||||
uint highestCpuCore = (cap >> 24) & 0xff;
|
||||
|
||||
if (lowestCpuCore > highestCpuCore)
|
||||
{
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
uint highestThreadPrio = (cap >> 4) & 0x3f;
|
||||
uint lowestThreadPrio = (cap >> 10) & 0x3f;
|
||||
|
||||
if (lowestThreadPrio > highestThreadPrio)
|
||||
{
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
if (highestCpuCore >= KScheduler.CpuCoresCount)
|
||||
{
|
||||
return KernelResult.InvalidCpuCore;
|
||||
}
|
||||
|
||||
AllowedCpuCoresMask = GetMaskFromMinMax(lowestCpuCore, highestCpuCore);
|
||||
AllowedThreadPriosMask = GetMaskFromMinMax(lowestThreadPrio, highestThreadPrio);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
uint lowestCpuCore = (cap >> 16) & 0xff;
|
||||
uint highestCpuCore = (cap >> 24) & 0xff;
|
||||
|
||||
if (lowestCpuCore > highestCpuCore)
|
||||
{
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
uint highestThreadPrio = (cap >> 4) & 0x3f;
|
||||
uint lowestThreadPrio = (cap >> 10) & 0x3f;
|
||||
|
||||
if (lowestThreadPrio > highestThreadPrio)
|
||||
{
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
if (highestCpuCore >= KScheduler.CpuCoresCount)
|
||||
{
|
||||
return KernelResult.InvalidCpuCore;
|
||||
}
|
||||
|
||||
AllowedCpuCoresMask = GetMaskFromMinMax(lowestCpuCore, highestCpuCore);
|
||||
AllowedThreadPriosMask = GetMaskFromMinMax(lowestThreadPrio, highestThreadPrio);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CapabilityType.SyscallMask:
|
||||
{
|
||||
int slot = ((int)cap >> 29) & 7;
|
||||
|
||||
int svcSlotMask = 1 << slot;
|
||||
|
||||
if ((mask1 & svcSlotMask) != 0)
|
||||
{
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
int slot = ((int)cap >> 29) & 7;
|
||||
|
||||
mask1 |= svcSlotMask;
|
||||
int svcSlotMask = 1 << slot;
|
||||
|
||||
uint svcMask = (cap >> 5) & 0xffffff;
|
||||
|
||||
int baseSvc = slot * 24;
|
||||
|
||||
for (int index = 0; index < 24; index++)
|
||||
{
|
||||
if (((svcMask >> index) & 1) == 0)
|
||||
if ((mask1 & svcSlotMask) != 0)
|
||||
{
|
||||
continue;
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
int svcId = baseSvc + index;
|
||||
mask1 |= svcSlotMask;
|
||||
|
||||
if (svcId >= KernelConstants.SupervisorCallCount)
|
||||
uint svcMask = (cap >> 5) & 0xffffff;
|
||||
|
||||
int baseSvc = slot * 24;
|
||||
|
||||
for (int index = 0; index < 24; index++)
|
||||
{
|
||||
return KernelResult.MaximumExceeded;
|
||||
if (((svcMask >> index) & 1) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int svcId = baseSvc + index;
|
||||
|
||||
if (svcId >= KernelConstants.SupervisorCallCount)
|
||||
{
|
||||
return KernelResult.MaximumExceeded;
|
||||
}
|
||||
|
||||
SvcAccessMask[svcId / 8] |= (byte)(1 << (svcId & 7));
|
||||
}
|
||||
|
||||
SvcAccessMask[svcId / 8] |= (byte)(1 << (svcId & 7));
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CapabilityType.MapIoPage:
|
||||
{
|
||||
long address = ((long)cap << 4) & 0xffffff000;
|
||||
{
|
||||
long address = ((long)cap << 4) & 0xffffff000;
|
||||
|
||||
memoryManager.MapIoMemory(address, KPageTableBase.PageSize, KMemoryPermission.ReadAndWrite);
|
||||
KPageTableBase.MapIoMemory(address, KPageTableBase.PageSize, KMemoryPermission.ReadAndWrite);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CapabilityType.MapRegion:
|
||||
{
|
||||
// TODO: Implement capabilities for MapRegion
|
||||
{
|
||||
// TODO: Implement capabilities for MapRegion
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CapabilityType.InterruptPair:
|
||||
{
|
||||
// TODO: GIC distributor check.
|
||||
int irq0 = ((int)cap >> 12) & 0x3ff;
|
||||
int irq1 = ((int)cap >> 22) & 0x3ff;
|
||||
|
||||
if (irq0 != 0x3ff)
|
||||
{
|
||||
IrqAccessMask[irq0 / 8] |= (byte)(1 << (irq0 & 7));
|
||||
}
|
||||
// TODO: GIC distributor check.
|
||||
int irq0 = ((int)cap >> 12) & 0x3ff;
|
||||
int irq1 = ((int)cap >> 22) & 0x3ff;
|
||||
|
||||
if (irq1 != 0x3ff)
|
||||
{
|
||||
IrqAccessMask[irq1 / 8] |= (byte)(1 << (irq1 & 7));
|
||||
}
|
||||
if (irq0 != 0x3ff)
|
||||
{
|
||||
IrqAccessMask[irq0 / 8] |= (byte)(1 << (irq0 & 7));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
if (irq1 != 0x3ff)
|
||||
{
|
||||
IrqAccessMask[irq1 / 8] |= (byte)(1 << (irq1 & 7));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CapabilityType.ProgramType:
|
||||
{
|
||||
uint applicationType = (cap >> 14);
|
||||
|
||||
if (applicationType > 7)
|
||||
{
|
||||
return KernelResult.ReservedValue;
|
||||
uint applicationType = (cap >> 14);
|
||||
|
||||
if (applicationType > 7)
|
||||
{
|
||||
return KernelResult.ReservedValue;
|
||||
}
|
||||
|
||||
ApplicationType = applicationType;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
ApplicationType = applicationType;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CapabilityType.KernelVersion:
|
||||
{
|
||||
// Note: This check is bugged on kernel too, we are just replicating the bug here.
|
||||
if ((KernelReleaseVersion >> 17) != 0 || cap < 0x80000)
|
||||
{
|
||||
return KernelResult.ReservedValue;
|
||||
// Note: This check is bugged on kernel too, we are just replicating the bug here.
|
||||
if ((KernelReleaseVersion >> 17) != 0 || cap < 0x80000)
|
||||
{
|
||||
return KernelResult.ReservedValue;
|
||||
}
|
||||
|
||||
KernelReleaseVersion = cap;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
KernelReleaseVersion = cap;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CapabilityType.HandleTable:
|
||||
{
|
||||
uint handleTableSize = cap >> 26;
|
||||
|
||||
if (handleTableSize > 0x3ff)
|
||||
{
|
||||
return KernelResult.ReservedValue;
|
||||
uint handleTableSize = cap >> 26;
|
||||
|
||||
if (handleTableSize > 0x3ff)
|
||||
{
|
||||
return KernelResult.ReservedValue;
|
||||
}
|
||||
|
||||
HandleTableSize = handleTableSize;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
HandleTableSize = handleTableSize;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CapabilityType.DebugFlags:
|
||||
{
|
||||
uint debuggingFlags = cap >> 19;
|
||||
|
||||
if (debuggingFlags > 3)
|
||||
{
|
||||
return KernelResult.ReservedValue;
|
||||
uint debuggingFlags = cap >> 19;
|
||||
|
||||
if (debuggingFlags > 3)
|
||||
{
|
||||
return KernelResult.ReservedValue;
|
||||
}
|
||||
|
||||
DebuggingFlags &= ~3u;
|
||||
DebuggingFlags |= debuggingFlags;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
DebuggingFlags &= ~3u;
|
||||
DebuggingFlags |= debuggingFlags;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default: return KernelResult.InvalidCapability;
|
||||
default:
|
||||
return KernelResult.InvalidCapability;
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
@@ -325,4 +325,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return mask << (int)min;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,4 +74,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
_isSlotFree[(address - PageVirtualAddress) / TlsEntrySize] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
private const int TlsEntrySize = 0x200;
|
||||
|
||||
private long _pagePosition;
|
||||
private readonly long _pagePosition;
|
||||
|
||||
private int _usedSlots;
|
||||
|
||||
private bool[] _slots;
|
||||
private readonly bool[] _slots;
|
||||
|
||||
public bool IsEmpty => _usedSlots == 0;
|
||||
public bool IsFull => _usedSlots == _slots.Length;
|
||||
public bool IsFull => _usedSlots == _slots.Length;
|
||||
|
||||
public KTlsPageManager(long pagePosition)
|
||||
{
|
||||
@@ -58,4 +58,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
_usedSlots--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
[Flags]
|
||||
[SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
|
||||
enum ProcessCreationFlags
|
||||
{
|
||||
Is64Bit = 1 << 0,
|
||||
@@ -36,6 +38,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
IsApplication |
|
||||
DeprecatedUseSecureMemory |
|
||||
PoolPartitionMask |
|
||||
OptimizeMemoryAllocation
|
||||
OptimizeMemoryAllocation,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,4 +34,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
SystemResourcePagesCount = systemResourcePagesCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
public ulong Pc => 0UL;
|
||||
|
||||
public ulong CntfrqEl0 { get; set; }
|
||||
public ulong CntpctEl0 => 0UL;
|
||||
|
||||
public long TpidrEl0 { get; set; }
|
||||
public long TpidrroEl0 { get; set; }
|
||||
|
||||
@@ -43,4 +40,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
enum ProcessState : byte
|
||||
{
|
||||
Created = 0,
|
||||
Created = 0,
|
||||
CreatedAttached = 1,
|
||||
Started = 2,
|
||||
Crashed = 3,
|
||||
Attached = 4,
|
||||
Exiting = 5,
|
||||
Exited = 6,
|
||||
DebugSuspended = 7
|
||||
Started = 2,
|
||||
Crashed = 3,
|
||||
Attached = 4,
|
||||
Exiting = 5,
|
||||
Exited = 6,
|
||||
DebugSuspended = 7,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
public ProcessTamperInfo(KProcess process, IEnumerable<string> buildIds, IEnumerable<ulong> codeAddresses, ulong heapAddress, ulong aliasAddress, ulong aslrAddress)
|
||||
{
|
||||
Process = process;
|
||||
BuildIds = buildIds;
|
||||
Process = process;
|
||||
BuildIds = buildIds;
|
||||
CodeAddresses = codeAddresses;
|
||||
HeapAddress = heapAddress;
|
||||
AliasAddress = aliasAddress;
|
||||
AslrAddress = aslrAddress;
|
||||
HeapAddress = heapAddress;
|
||||
AliasAddress = aliasAddress;
|
||||
AslrAddress = aslrAddress;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user