diff options
author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2023-07-16 19:31:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-16 19:31:14 +0200 |
commit | 326749498bed4360e5a4b11fc67d5ec7cb9a3076 (patch) | |
tree | ae21fb26f99b401ca4e9efaab72b679a81c22369 /src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs | |
parent | fec8291c17fa106c28f58b56419e90d49a41a1ea (diff) |
[Ryujinx.HLE] Address dotnet-format issues (#5380)1.1.962
* 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>
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs')
-rw-r--r-- | src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs | 147 |
1 files changed, 74 insertions, 73 deletions
diff --git a/src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs b/src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs index 86469c03..7e41a3f3 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs @@ -10,19 +10,18 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc { class KServerSession : KSynchronizationObject { - private static readonly MemoryState[] IpcMemoryStates = new MemoryState[] - { + private static readonly MemoryState[] _ipcMemoryStates = { MemoryState.IpcBuffer3, MemoryState.IpcBuffer0, MemoryState.IpcBuffer1, - (MemoryState)0xfffce5d4 //This is invalid, shouldn't be accessed. + (MemoryState)0xfffce5d4, //This is invalid, shouldn't be accessed. }; private readonly struct Message { - public ulong Address { get; } - public ulong Size { get; } - public bool IsCustom { get; } + public ulong Address { get; } + public ulong Size { get; } + public bool IsCustom { get; } public Message(KThread thread, ulong customCmdBuffAddress, ulong customCmdBuffSize) { @@ -31,19 +30,20 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc if (IsCustom) { Address = customCmdBuffAddress; - Size = customCmdBuffSize; + Size = customCmdBuffSize; } else { Address = thread.TlsAddress; - Size = 0x100; + Size = 0x100; } } public Message(KSessionRequest request) : this( request.ClientThread, request.CustomCmdBuffAddr, - request.CustomCmdBuffSize) { } + request.CustomCmdBuffSize) + { } } private readonly struct MessageHeader @@ -52,18 +52,18 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc public uint Word1 { get; } public uint Word2 { get; } - public uint PointerBuffersCount { get; } - public uint SendBuffersCount { get; } - public uint ReceiveBuffersCount { get; } + public uint PointerBuffersCount { get; } + public uint SendBuffersCount { get; } + public uint ReceiveBuffersCount { get; } public uint ExchangeBuffersCount { get; } public uint RawDataSizeInWords { get; } public uint ReceiveListType { get; } - public uint MessageSizeInWords { get; } + public uint MessageSizeInWords { get; } public uint ReceiveListOffsetInWords { get; } - public uint ReceiveListOffset { get; } + public uint ReceiveListOffset { get; } public bool HasHandles { get; } @@ -101,14 +101,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc MoveHandlesCount = 0; } - PointerBuffersCount = (word0 >> 16) & 0xf; - SendBuffersCount = (word0 >> 20) & 0xf; - ReceiveBuffersCount = (word0 >> 24) & 0xf; - ExchangeBuffersCount = word0 >> 28; + PointerBuffersCount = (word0 >> 16) & 0xf; + SendBuffersCount = (word0 >> 20) & 0xf; + ReceiveBuffersCount = (word0 >> 24) & 0xf; + ExchangeBuffersCount = word0 >> 28; - uint pointerDescSizeInWords = PointerBuffersCount * 2; - uint sendDescSizeInWords = SendBuffersCount * 3; - uint receiveDescSizeInWords = ReceiveBuffersCount * 3; + uint pointerDescSizeInWords = PointerBuffersCount * 2; + uint sendDescSizeInWords = SendBuffersCount * 3; + uint receiveDescSizeInWords = ReceiveBuffersCount * 3; uint exchangeDescSizeInWords = ExchangeBuffersCount * 3; RawDataSizeInWords = word1 & 0x3ff; @@ -119,12 +119,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc uint paddingSizeInWords = HasHandles ? 3u : 2u; - MessageSizeInWords = pointerDescSizeInWords + - sendDescSizeInWords + - receiveDescSizeInWords + + MessageSizeInWords = pointerDescSizeInWords + + sendDescSizeInWords + + receiveDescSizeInWords + exchangeDescSizeInWords + - RawDataSizeInWords + - paddingSizeInWords + + RawDataSizeInWords + + paddingSizeInWords + handleDescSizeInWords; if (ReceiveListOffsetInWords == 0) @@ -140,25 +140,25 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc { public uint ReceiveIndex { get; } - public uint BufferSize { get; } + public uint BufferSize { get; } public ulong BufferAddress { get; set; } public PointerBufferDesc(ulong dword) { ReceiveIndex = (uint)dword & 0xf; - BufferSize = (uint)dword >> 16; + BufferSize = (uint)dword >> 16; - BufferAddress = (dword >> 2) & 0x70; + BufferAddress = (dword >> 2) & 0x70; BufferAddress |= (dword >> 12) & 0xf; BufferAddress = (BufferAddress << 32) | (dword >> 32); } - public ulong Pack() + public readonly ulong Pack() { ulong dword = (ReceiveIndex & 0xf) | ((BufferSize & 0xffff) << 16); - dword |= BufferAddress << 32; + dword |= BufferAddress << 32; dword |= (BufferAddress >> 20) & 0xf000; dword |= (BufferAddress >> 30) & 0xffc0; @@ -166,9 +166,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc } } - private KSession _parent; + private readonly KSession _parent; - private LinkedList<KSessionRequest> _requests; + private readonly LinkedList<KSessionRequest> _requests; private KSessionRequest _activeRequest; @@ -208,7 +208,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc public Result Receive(ulong customCmdBuffAddr = 0, ulong customCmdBuffSize = 0) { - KThread serverThread = KernelStatic.GetCurrentThread(); + KThread serverThread = KernelStatic.GetCurrentThread(); KProcess serverProcess = serverThread.Owner; KernelContext.CriticalSection.Enter(); @@ -234,7 +234,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc return KernelResult.PortRemoteClosed; } - KThread clientThread = request.ClientThread; + KThread clientThread = request.ClientThread; KProcess clientProcess = clientThread.Owner; KernelContext.CriticalSection.Leave(); @@ -243,8 +243,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc request.ServerProcess = serverProcess; - Message clientMsg = new Message(request); - Message serverMsg = new Message(serverThread, customCmdBuffAddr, customCmdBuffSize); + Message clientMsg = new(request); + Message serverMsg = new(serverThread, customCmdBuffAddr, customCmdBuffSize); MessageHeader clientHeader = GetClientMessageHeader(clientProcess, clientMsg); MessageHeader serverHeader = GetServerMessageHeader(serverMsg); @@ -399,7 +399,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc { ulong pointerDesc = clientProcess.CpuMemory.Read<ulong>(clientMsg.Address + offset * 4); - PointerBufferDesc descriptor = new PointerBufferDesc(pointerDesc); + PointerBufferDesc descriptor = new(pointerDesc); if (descriptor.BufferSize != 0) { @@ -409,7 +409,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc serverHeader.ReceiveListType, clientHeader.MessageSizeInWords, receiveList, - ref recvListDstOffset, + ref recvListDstOffset, out ulong recvListBufferAddress); if (clientResult != Result.Success) @@ -450,7 +450,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc // Copy send, receive and exchange buffers. uint totalBuffersCount = - clientHeader.SendBuffersCount + + clientHeader.SendBuffersCount + clientHeader.ReceiveBuffersCount + clientHeader.ExchangeBuffersCount; @@ -462,11 +462,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc uint descWord1 = clientProcess.CpuMemory.Read<uint>(clientDescAddress + 4); uint descWord2 = clientProcess.CpuMemory.Read<uint>(clientDescAddress + 8); - bool isSendDesc = index < clientHeader.SendBuffersCount; + bool isSendDesc = index < clientHeader.SendBuffersCount; bool isExchangeDesc = index >= clientHeader.SendBuffersCount + clientHeader.ReceiveBuffersCount; bool notReceiveDesc = isSendDesc || isExchangeDesc; - bool isReceiveDesc = !notReceiveDesc; + bool isReceiveDesc = !notReceiveDesc; KMemoryPermission permission = index >= clientHeader.SendBuffersCount ? KMemoryPermission.ReadAndWrite @@ -482,12 +482,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc { ulong bufferAddress; - bufferAddress = descWord2 >> 28; + bufferAddress = descWord2 >> 28; bufferAddress |= ((descWord2 >> 2) & 7) << 4; bufferAddress = (bufferAddress << 32) | descWord1; - MemoryState state = IpcMemoryStates[(descWord2 + 1) & 3]; + MemoryState state = _ipcMemoryStates[(descWord2 + 1) & 3]; clientResult = serverProcess.MemoryManager.MapBufferFromClientProcess( bufferSize, @@ -533,7 +533,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc descWord2 |= sizeHigh4 << 24; descWord2 |= (uint)(dstAddress >> 34) & 0x3ffffffc; - descWord2 |= (uint)(dstAddress >> 4) & 0xf0000000; + descWord2 |= (uint)(dstAddress >> 4) & 0xf0000000; ulong serverDescAddress = serverMsg.Address + offset * 4; @@ -586,7 +586,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc public Result Reply(ulong customCmdBuffAddr = 0, ulong customCmdBuffSize = 0) { - KThread serverThread = KernelStatic.GetCurrentThread(); + KThread serverThread = KernelStatic.GetCurrentThread(); KProcess serverProcess = serverThread.Owner; KernelContext.CriticalSection.Enter(); @@ -609,11 +609,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc KernelContext.CriticalSection.Leave(); - KThread clientThread = request.ClientThread; + KThread clientThread = request.ClientThread; KProcess clientProcess = clientThread.Owner; - Message clientMsg = new Message(request); - Message serverMsg = new Message(serverThread, customCmdBuffAddr, customCmdBuffSize); + Message clientMsg = new(request); + Message serverMsg = new(serverThread, customCmdBuffAddr, customCmdBuffSize); MessageHeader clientHeader = GetClientMessageHeader(clientProcess, clientMsg); MessageHeader serverHeader = GetServerMessageHeader(serverMsg); @@ -664,8 +664,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc return KernelResult.CmdBufferTooSmall; } - if (serverHeader.SendBuffersCount != 0 || - serverHeader.ReceiveBuffersCount != 0 || + if (serverHeader.SendBuffersCount != 0 || + serverHeader.ReceiveBuffersCount != 0 || serverHeader.ExchangeBuffersCount != 0) { CleanUpForError(); @@ -761,7 +761,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc { ulong pointerDesc = serverProcess.CpuMemory.Read<ulong>(serverMsg.Address + offset * 4); - PointerBufferDesc descriptor = new PointerBufferDesc(pointerDesc); + PointerBufferDesc descriptor = new(pointerDesc); ulong recvListBufferAddress = 0; @@ -817,7 +817,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc // Set send, receive and exchange buffer descriptors to zero. uint totalBuffersCount = - serverHeader.SendBuffersCount + + serverHeader.SendBuffersCount + serverHeader.ReceiveBuffersCount + serverHeader.ExchangeBuffersCount; @@ -868,7 +868,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc return serverResult; } - private MessageHeader GetClientMessageHeader(KProcess clientProcess, Message clientMsg) + private static MessageHeader GetClientMessageHeader(KProcess clientProcess, Message clientMsg) { uint word0 = clientProcess.CpuMemory.Read<uint>(clientMsg.Address + 0); uint word1 = clientProcess.CpuMemory.Read<uint>(clientMsg.Address + 4); @@ -877,7 +877,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc return new MessageHeader(word0, word1, word2); } - private MessageHeader GetServerMessageHeader(Message serverMsg) + private static MessageHeader GetServerMessageHeader(Message serverMsg) { KProcess currentProcess = KernelStatic.GetCurrentProcess(); @@ -888,7 +888,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc return new MessageHeader(word0, word1, word2); } - private Result GetCopyObjectHandle(KThread srcThread, KProcess dstProcess, int srcHandle, out int dstHandle) + private static Result GetCopyObjectHandle(KThread srcThread, KProcess dstProcess, int srcHandle, out int dstHandle) { dstHandle = 0; @@ -919,7 +919,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc } } - private Result GetMoveObjectHandle(KProcess srcProcess, KProcess dstProcess, int srcHandle, out int dstHandle) + private static Result GetMoveObjectHandle(KProcess srcProcess, KProcess dstProcess, int srcHandle, out int dstHandle) { dstHandle = 0; @@ -939,7 +939,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc } } - private ulong[] GetReceiveList(KProcess ownerProcess, Message message, uint recvListType, uint recvListOffset) + private static ulong[] GetReceiveList(KProcess ownerProcess, Message message, uint recvListType, uint recvListOffset) { int recvListSize = 0; @@ -964,16 +964,17 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc return receiveList; } - private Result GetReceiveListAddress( + private static Result GetReceiveListAddress( PointerBufferDesc descriptor, - Message message, - uint recvListType, - uint messageSizeInWords, - ulong[] receiveList, - ref uint dstOffset, - out ulong address) + Message message, + uint recvListType, + uint messageSizeInWords, + ulong[] receiveList, + ref uint dstOffset, + out ulong address) { - ulong recvListBufferAddress = address = 0; + ulong recvListBufferAddress; + address = 0; if (recvListType == 0) { @@ -987,7 +988,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc if (recvListType == 1) { recvListBaseAddr = message.Address + messageSizeInWords * 4; - recvListEndAddr = message.Address + message.Size; + recvListEndAddr = message.Address + message.Size; } else /* if (recvListType == 2) */ { @@ -1012,7 +1013,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc dstOffset = (uint)endAddress - (uint)recvListBaseAddr; if (recvListBufferAddress + descriptor.BufferSize <= recvListBufferAddress || - recvListBufferAddress + descriptor.BufferSize > recvListEndAddr) + recvListBufferAddress + descriptor.BufferSize > recvListEndAddr) { return KernelResult.OutOfResource; } @@ -1041,7 +1042,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc return Result.Success; } - private void CloseAllHandles(Message message, MessageHeader header, KProcess process) + private static void CloseAllHandles(Message message, MessageHeader header, KProcess process) { if (header.HasHandles) { @@ -1202,7 +1203,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc } } - private void SendResultToAsyncRequestClient(KSessionRequest request, Result result) + private static void SendResultToAsyncRequestClient(KSessionRequest request, Result result) { KProcess clientProcess = request.ClientThread.Owner; @@ -1232,15 +1233,15 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc KernelContext.CriticalSection.Leave(); } - private void WakeAndSetResult(KThread thread, Result result, KSynchronizationObject signaledObj = null) + private static void WakeAndSetResult(KThread thread, Result result, KSynchronizationObject signaledObj = null) { if ((thread.SchedFlags & ThreadSchedState.LowMask) == ThreadSchedState.Paused) { - thread.SignaledObj = signaledObj; + thread.SignaledObj = signaledObj; thread.ObjSyncResult = result; thread.Reschedule(ThreadSchedState.Running); } } } -}
\ No newline at end of file +} |