mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-27 21:07:26 +02:00
[Ryujinx.Horizon] Address dotnet-format issues (#5381)
* 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 dotnet format CA1822 warnings * 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 * Revert formatting changes for while and for-loops * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Add comments to disabled warnings * Remove a few unused parameters * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Address IDE0251 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 * Add trailing commas and fix formatting issues * Convert if-else chain to switch block * Address review feedback
This commit is contained in:
parent
801b71a128
commit
02b5c7ea89
105 changed files with 617 additions and 637 deletions
|
@ -41,10 +41,8 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
{
|
||||
return HorizonStatic.Syscall.ReplyAndReceive(out _, handles, 0, -1L);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static Result Reply(int sessionHandle, ReadOnlySpan<byte> messageBuffer)
|
||||
|
@ -64,10 +62,8 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
{
|
||||
return HorizonStatic.Syscall.ReplyAndReceive(out _, ReadOnlySpan<int>.Empty, sessionHandle, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static Result CreateSession(out int serverHandle, out int clientHandle)
|
||||
|
@ -82,4 +78,4 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,55 +10,55 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
|
||||
public CommandType Type
|
||||
{
|
||||
get => (CommandType)_word0.Extract(0, 16);
|
||||
readonly get => (CommandType)_word0.Extract(0, 16);
|
||||
set => _word0 = _word0.Insert(0, 16, (uint)value);
|
||||
}
|
||||
|
||||
public int SendStaticsCount
|
||||
{
|
||||
get => (int)_word0.Extract(16, 4);
|
||||
readonly get => (int)_word0.Extract(16, 4);
|
||||
set => _word0 = _word0.Insert(16, 4, (uint)value);
|
||||
}
|
||||
|
||||
public int SendBuffersCount
|
||||
{
|
||||
get => (int)_word0.Extract(20, 4);
|
||||
readonly get => (int)_word0.Extract(20, 4);
|
||||
set => _word0 = _word0.Insert(20, 4, (uint)value);
|
||||
}
|
||||
|
||||
public int ReceiveBuffersCount
|
||||
{
|
||||
get => (int)_word0.Extract(24, 4);
|
||||
readonly get => (int)_word0.Extract(24, 4);
|
||||
set => _word0 = _word0.Insert(24, 4, (uint)value);
|
||||
}
|
||||
|
||||
public int ExchangeBuffersCount
|
||||
{
|
||||
get => (int)_word0.Extract(28, 4);
|
||||
readonly get => (int)_word0.Extract(28, 4);
|
||||
set => _word0 = _word0.Insert(28, 4, (uint)value);
|
||||
}
|
||||
|
||||
public int DataWordsCount
|
||||
{
|
||||
get => (int)_word1.Extract(0, 10);
|
||||
readonly get => (int)_word1.Extract(0, 10);
|
||||
set => _word1 = _word1.Insert(0, 10, (uint)value);
|
||||
}
|
||||
|
||||
public int ReceiveStaticMode
|
||||
{
|
||||
get => (int)_word1.Extract(10, 4);
|
||||
readonly get => (int)_word1.Extract(10, 4);
|
||||
set => _word1 = _word1.Insert(10, 4, (uint)value);
|
||||
}
|
||||
|
||||
public int ReceiveListOffset
|
||||
{
|
||||
get => (int)_word1.Extract(20, 11);
|
||||
readonly get => (int)_word1.Extract(20, 11);
|
||||
set => _word1 = _word1.Insert(20, 11, (uint)value);
|
||||
}
|
||||
|
||||
public bool HasSpecialHeader
|
||||
{
|
||||
get => _word1.Extract(31);
|
||||
readonly get => _word1.Extract(31);
|
||||
set => _word1 = _word1.Insert(31, value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
||||
{
|
||||
struct HipcBufferDescriptor
|
||||
readonly struct HipcBufferDescriptor
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
private uint _sizeLow;
|
||||
private uint _addressLow;
|
||||
private uint _word2;
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
private readonly uint _sizeLow;
|
||||
private readonly uint _addressLow;
|
||||
private readonly uint _word2;
|
||||
#pragma warning restore CS0649
|
||||
|
||||
public ulong Address => _addressLow | (((ulong)_word2 << 4) & 0xf00000000UL) | (((ulong)_word2 << 34) & 0x7000000000UL);
|
||||
|
|
|
@ -5,13 +5,13 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
[Flags]
|
||||
enum HipcBufferFlags : byte
|
||||
{
|
||||
In = 1 << 0,
|
||||
Out = 1 << 1,
|
||||
MapAlias = 1 << 2,
|
||||
Pointer = 1 << 3,
|
||||
FixedSize = 1 << 4,
|
||||
AutoSelect = 1 << 5,
|
||||
In = 1 << 0,
|
||||
Out = 1 << 1,
|
||||
MapAlias = 1 << 2,
|
||||
Pointer = 1 << 3,
|
||||
FixedSize = 1 << 4,
|
||||
AutoSelect = 1 << 5,
|
||||
MapTransferAllowsNonSecure = 1 << 6,
|
||||
MapTransferAllowsNonDevice = 1 << 7
|
||||
MapTransferAllowsNonDevice = 1 << 7,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
{
|
||||
enum HipcBufferMode
|
||||
{
|
||||
Normal = 0,
|
||||
Normal = 0,
|
||||
NonSecure = 1,
|
||||
Invalid = 2,
|
||||
NonDevice = 3
|
||||
Invalid = 2,
|
||||
NonDevice = 3,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,4 +112,4 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
return Result.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
{
|
||||
public const int AutoReceiveStatic = byte.MaxValue;
|
||||
|
||||
public HipcMetadata Meta;
|
||||
public HipcMetadata Meta;
|
||||
public HipcMessageData Data;
|
||||
public ulong Pid;
|
||||
public ulong Pid;
|
||||
|
||||
public HipcMessage(Span<byte> data)
|
||||
{
|
||||
|
@ -22,8 +22,8 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
|
||||
data = data[Unsafe.SizeOf<Header>()..];
|
||||
|
||||
int receiveStaticsCount = 0;
|
||||
ulong pid = 0;
|
||||
int receiveStaticsCount = 0;
|
||||
ulong pid = 0;
|
||||
|
||||
if (header.ReceiveStaticMode != 0)
|
||||
{
|
||||
|
@ -42,75 +42,75 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
if (header.HasSpecialHeader)
|
||||
{
|
||||
specialHeader = MemoryMarshal.Cast<byte, SpecialHeader>(data)[0];
|
||||
data = data[Unsafe.SizeOf<SpecialHeader>()..];
|
||||
data = data[Unsafe.SizeOf<SpecialHeader>()..];
|
||||
|
||||
if (specialHeader.SendPid)
|
||||
{
|
||||
pid = MemoryMarshal.Cast<byte, ulong>(data)[0];
|
||||
pid = MemoryMarshal.Cast<byte, ulong>(data)[0];
|
||||
data = data[sizeof(ulong)..];
|
||||
}
|
||||
}
|
||||
|
||||
Meta = new HipcMetadata()
|
||||
Meta = new HipcMetadata
|
||||
{
|
||||
Type = (int)header.Type,
|
||||
SendStaticsCount = header.SendStaticsCount,
|
||||
SendBuffersCount = header.SendBuffersCount,
|
||||
ReceiveBuffersCount = header.ReceiveBuffersCount,
|
||||
Type = (int)header.Type,
|
||||
SendStaticsCount = header.SendStaticsCount,
|
||||
SendBuffersCount = header.SendBuffersCount,
|
||||
ReceiveBuffersCount = header.ReceiveBuffersCount,
|
||||
ExchangeBuffersCount = header.ExchangeBuffersCount,
|
||||
DataWordsCount = header.DataWordsCount,
|
||||
ReceiveStaticsCount = receiveStaticsCount,
|
||||
SendPid = specialHeader.SendPid,
|
||||
CopyHandlesCount = specialHeader.CopyHandlesCount,
|
||||
MoveHandlesCount = specialHeader.MoveHandlesCount
|
||||
DataWordsCount = header.DataWordsCount,
|
||||
ReceiveStaticsCount = receiveStaticsCount,
|
||||
SendPid = specialHeader.SendPid,
|
||||
CopyHandlesCount = specialHeader.CopyHandlesCount,
|
||||
MoveHandlesCount = specialHeader.MoveHandlesCount,
|
||||
};
|
||||
|
||||
Data = CreateMessageData(Meta, data, initialLength);
|
||||
Pid = pid;
|
||||
Pid = pid;
|
||||
}
|
||||
|
||||
public static HipcMessageData WriteResponse(
|
||||
Span<byte> destination,
|
||||
int sendStaticCount,
|
||||
int dataWordsCount,
|
||||
int copyHandlesCount,
|
||||
int moveHandlesCount)
|
||||
int sendStaticCount,
|
||||
int dataWordsCount,
|
||||
int copyHandlesCount,
|
||||
int moveHandlesCount)
|
||||
{
|
||||
return WriteMessage(destination, new HipcMetadata()
|
||||
return WriteMessage(destination, new HipcMetadata
|
||||
{
|
||||
SendStaticsCount = sendStaticCount,
|
||||
DataWordsCount = dataWordsCount,
|
||||
DataWordsCount = dataWordsCount,
|
||||
CopyHandlesCount = copyHandlesCount,
|
||||
MoveHandlesCount = moveHandlesCount
|
||||
MoveHandlesCount = moveHandlesCount,
|
||||
});
|
||||
}
|
||||
|
||||
public static HipcMessageData WriteMessage(Span<byte> destination, HipcMetadata meta)
|
||||
{
|
||||
int initialLength = destination.Length;
|
||||
int initialLength = destination.Length;
|
||||
bool hasSpecialHeader = meta.SendPid || meta.CopyHandlesCount != 0 || meta.MoveHandlesCount != 0;
|
||||
|
||||
MemoryMarshal.Cast<byte, Header>(destination)[0] = new Header()
|
||||
MemoryMarshal.Cast<byte, Header>(destination)[0] = new Header
|
||||
{
|
||||
Type = (CommandType)meta.Type,
|
||||
SendStaticsCount = meta.SendStaticsCount,
|
||||
SendBuffersCount = meta.SendBuffersCount,
|
||||
ReceiveBuffersCount = meta.ReceiveBuffersCount,
|
||||
Type = (CommandType)meta.Type,
|
||||
SendStaticsCount = meta.SendStaticsCount,
|
||||
SendBuffersCount = meta.SendBuffersCount,
|
||||
ReceiveBuffersCount = meta.ReceiveBuffersCount,
|
||||
ExchangeBuffersCount = meta.ExchangeBuffersCount,
|
||||
DataWordsCount = meta.DataWordsCount,
|
||||
ReceiveStaticMode = meta.ReceiveStaticsCount != 0 ? (meta.ReceiveStaticsCount != AutoReceiveStatic ? meta.ReceiveStaticsCount + 2 : 2) : 0,
|
||||
HasSpecialHeader = hasSpecialHeader
|
||||
DataWordsCount = meta.DataWordsCount,
|
||||
ReceiveStaticMode = meta.ReceiveStaticsCount != 0 ? (meta.ReceiveStaticsCount != AutoReceiveStatic ? meta.ReceiveStaticsCount + 2 : 2) : 0,
|
||||
HasSpecialHeader = hasSpecialHeader,
|
||||
};
|
||||
|
||||
destination = destination[Unsafe.SizeOf<Header>()..];
|
||||
|
||||
if (hasSpecialHeader)
|
||||
{
|
||||
MemoryMarshal.Cast<byte, SpecialHeader>(destination)[0] = new SpecialHeader()
|
||||
MemoryMarshal.Cast<byte, SpecialHeader>(destination)[0] = new SpecialHeader
|
||||
{
|
||||
SendPid = meta.SendPid,
|
||||
SendPid = meta.SendPid,
|
||||
CopyHandlesCount = meta.CopyHandlesCount,
|
||||
MoveHandlesCount = meta.MoveHandlesCount
|
||||
MoveHandlesCount = meta.MoveHandlesCount,
|
||||
};
|
||||
|
||||
destination = destination[Unsafe.SizeOf<SpecialHeader>()..];
|
||||
|
@ -184,9 +184,9 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
|
||||
if (meta.DataWordsCount != 0)
|
||||
{
|
||||
int dataOffset = initialLength - data.Length;
|
||||
int dataOffset = initialLength - data.Length;
|
||||
int dataOffsetAligned = BitUtils.AlignUp(dataOffset, 0x10);
|
||||
int padding = (dataOffsetAligned - dataOffset) / sizeof(uint);
|
||||
int padding = (dataOffsetAligned - dataOffset) / sizeof(uint);
|
||||
|
||||
dataWords = MemoryMarshal.Cast<byte, uint>(data)[padding..meta.DataWordsCount];
|
||||
|
||||
|
@ -202,16 +202,16 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
receiveList = MemoryMarshal.Cast<byte, HipcReceiveListEntry>(data)[..receiveListSize];
|
||||
}
|
||||
|
||||
return new HipcMessageData()
|
||||
return new HipcMessageData
|
||||
{
|
||||
SendStatics = sendStatics,
|
||||
SendBuffers = sendBuffers,
|
||||
ReceiveBuffers = receiveBuffers,
|
||||
SendStatics = sendStatics,
|
||||
SendBuffers = sendBuffers,
|
||||
ReceiveBuffers = receiveBuffers,
|
||||
ExchangeBuffers = exchangeBuffers,
|
||||
DataWords = dataWords,
|
||||
ReceiveList = receiveList,
|
||||
CopyHandles = copyHandles,
|
||||
MoveHandles = moveHandles
|
||||
DataWords = dataWords,
|
||||
ReceiveList = receiveList,
|
||||
CopyHandles = copyHandles,
|
||||
MoveHandles = moveHandles,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
public Span<HipcBufferDescriptor> SendBuffers;
|
||||
public Span<HipcBufferDescriptor> ReceiveBuffers;
|
||||
public Span<HipcBufferDescriptor> ExchangeBuffers;
|
||||
public Span<uint> DataWords;
|
||||
public Span<uint> DataWords;
|
||||
public Span<HipcReceiveListEntry> ReceiveList;
|
||||
public Span<int> CopyHandles;
|
||||
public Span<int> MoveHandles;
|
||||
public Span<int> CopyHandles;
|
||||
public Span<int> MoveHandles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
{
|
||||
struct HipcMetadata
|
||||
{
|
||||
public int Type;
|
||||
public int SendStaticsCount;
|
||||
public int SendBuffersCount;
|
||||
public int ReceiveBuffersCount;
|
||||
public int ExchangeBuffersCount;
|
||||
public int DataWordsCount;
|
||||
public int ReceiveStaticsCount;
|
||||
public int Type;
|
||||
public int SendStaticsCount;
|
||||
public int SendBuffersCount;
|
||||
public int ReceiveBuffersCount;
|
||||
public int ExchangeBuffersCount;
|
||||
public int DataWordsCount;
|
||||
public int ReceiveStaticsCount;
|
||||
public bool SendPid;
|
||||
public int CopyHandlesCount;
|
||||
public int MoveHandlesCount;
|
||||
public int CopyHandlesCount;
|
||||
public int MoveHandlesCount;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
||||
{
|
||||
struct HipcReceiveListEntry
|
||||
readonly struct HipcReceiveListEntry
|
||||
{
|
||||
private uint _addressLow;
|
||||
private uint _word1;
|
||||
#pragma warning disable IDE0052 // Remove unread private member
|
||||
private readonly uint _addressLow;
|
||||
private readonly uint _word1;
|
||||
#pragma warning restore IDE0052
|
||||
|
||||
public HipcReceiveListEntry(ulong address, ulong size)
|
||||
{
|
||||
_addressLow = (uint)address;
|
||||
_word1 = (ushort)(address >> 32) | (uint)(size << 16);
|
||||
_word1 = (ushort)(address >> 32) | (uint)(size << 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
{
|
||||
public const int ModuleId = 11;
|
||||
|
||||
#pragma warning disable IDE0055 // Disable formatting
|
||||
public static Result OutOfSessionMemory => new(ModuleId, 102);
|
||||
public static Result OutOfSessions => new(ModuleId, 131);
|
||||
public static Result PointerBufferTooSmall => new(ModuleId, 141);
|
||||
|
@ -15,5 +16,6 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
public static Result InvalidCmifRequest => new(ModuleId, 420);
|
||||
public static Result TargetNotDomain => new(ModuleId, 491);
|
||||
public static Result DomainObjectNotFound => new(ModuleId, 492);
|
||||
#pragma warning restore IDE0055
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
||||
{
|
||||
struct HipcStaticDescriptor
|
||||
readonly struct HipcStaticDescriptor
|
||||
{
|
||||
private readonly ulong _data;
|
||||
|
||||
public ulong Address => ((((_data >> 2) & 0x70) | ((_data >> 12) & 0xf)) << 32) | (_data >> 32);
|
||||
public ushort Size => (ushort)(_data >> 16);
|
||||
public int ReceiveIndex => (int)(_data & 0xf);
|
||||
public ulong Address => ((((_data >> 2) & 0x70) | ((_data >> 12) & 0xf)) << 32) | (_data >> 32);
|
||||
public ushort Size => (ushort)(_data >> 16);
|
||||
public int ReceiveIndex => (int)(_data & 0xf);
|
||||
|
||||
public HipcStaticDescriptor(ulong address, ushort size, int receiveIndex)
|
||||
{
|
||||
|
@ -19,4 +19,4 @@
|
|||
_data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
||||
{
|
||||
struct ManagerOptions
|
||||
readonly struct ManagerOptions
|
||||
{
|
||||
public static ManagerOptions Default => new(0, 0, 0, false);
|
||||
|
||||
public int PointerBufferSize { get; }
|
||||
public int MaxDomains { get; }
|
||||
public int MaxDomainObjects { get; }
|
||||
public int PointerBufferSize { get; }
|
||||
public int MaxDomains { get; }
|
||||
public int MaxDomainObjects { get; }
|
||||
public bool CanDeferInvokeRequest { get; }
|
||||
|
||||
public ManagerOptions(int pointerBufferSize, int maxDomains, int maxDomainObjects, bool canDeferInvokeRequest)
|
||||
{
|
||||
PointerBufferSize = pointerBufferSize;
|
||||
MaxDomains = maxDomains;
|
||||
MaxDomainObjects = maxDomainObjects;
|
||||
PointerBufferSize = pointerBufferSize;
|
||||
MaxDomains = maxDomains;
|
||||
MaxDomainObjects = maxDomainObjects;
|
||||
CanDeferInvokeRequest = canDeferInvokeRequest;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
{
|
||||
Success,
|
||||
Closed,
|
||||
NeedsRetry
|
||||
NeedsRetry,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,22 +6,22 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
{
|
||||
class Server : MultiWaitHolderOfHandle
|
||||
{
|
||||
public int PortIndex { get; }
|
||||
public int PortHandle { get; }
|
||||
public ServiceName Name { get; }
|
||||
public bool Managed { get; }
|
||||
public int PortIndex { get; }
|
||||
public int PortHandle { get; }
|
||||
public ServiceName Name { get; }
|
||||
public bool Managed { get; }
|
||||
public ServiceObjectHolder StaticObject { get; }
|
||||
|
||||
public Server(
|
||||
int portIndex,
|
||||
int portHandle,
|
||||
ServiceName name,
|
||||
bool managed,
|
||||
int portIndex,
|
||||
int portHandle,
|
||||
ServiceName name,
|
||||
bool managed,
|
||||
ServiceObjectHolder staticHoder) : base(portHandle)
|
||||
{
|
||||
PortHandle = portHandle;
|
||||
Name = name;
|
||||
Managed = managed;
|
||||
Name = name;
|
||||
Managed = managed;
|
||||
|
||||
if (staticHoder != null)
|
||||
{
|
||||
|
|
|
@ -14,8 +14,8 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
private readonly bool _canDeferInvokeRequest;
|
||||
private readonly int _maxSessions;
|
||||
|
||||
private ulong _pointerBuffersBaseAddress;
|
||||
private ulong _savedMessagesBaseAddress;
|
||||
private readonly ulong _pointerBuffersBaseAddress;
|
||||
private readonly ulong _savedMessagesBaseAddress;
|
||||
|
||||
private readonly object _resourceLock;
|
||||
private readonly ulong[] _sessionAllocationBitmap;
|
||||
|
@ -35,7 +35,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
|
||||
if (options.CanDeferInvokeRequest)
|
||||
{
|
||||
_savedMessagesBaseAddress = allocator.Allocate((ulong)maxSessions * (ulong)Api.TlsMessageBufferSize);
|
||||
_savedMessagesBaseAddress = allocator.Allocate((ulong)maxSessions * Api.TlsMessageBufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
_servers = new HashSet<Server>();
|
||||
}
|
||||
|
||||
private PointerAndSize GetObjectBySessionIndex(ServerSession session, ulong baseAddress, ulong size)
|
||||
private static PointerAndSize GetObjectBySessionIndex(ServerSession session, ulong baseAddress, ulong size)
|
||||
{
|
||||
return new PointerAndSize(baseAddress + (ulong)session.SessionIndex * size, size);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i <_sessionAllocationBitmap.Length; i++)
|
||||
for (int i = 0; i < _sessionAllocationBitmap.Length; i++)
|
||||
{
|
||||
ref ulong mask = ref _sessionAllocationBitmap[i];
|
||||
|
||||
|
@ -145,10 +145,8 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
{
|
||||
return GetObjectBySessionIndex(session, _pointerBuffersBaseAddress, (ulong)_pointerBufferSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PointerAndSize.Empty;
|
||||
}
|
||||
|
||||
return PointerAndSize.Empty;
|
||||
}
|
||||
|
||||
protected override PointerAndSize GetSessionSavedMessageBuffer(ServerSession session)
|
||||
|
@ -157,10 +155,8 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
{
|
||||
return GetObjectBySessionIndex(session, _savedMessagesBaseAddress, Api.TlsMessageBufferSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PointerAndSize.Empty;
|
||||
}
|
||||
|
||||
return PointerAndSize.Empty;
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
{
|
||||
private readonly SmApi _sm;
|
||||
|
||||
private bool _canDeferInvokeRequest;
|
||||
private readonly bool _canDeferInvokeRequest;
|
||||
|
||||
private readonly MultiWait _multiWait;
|
||||
private readonly MultiWait _waitList;
|
||||
|
@ -26,8 +26,8 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
|
||||
private enum UserDataTag
|
||||
{
|
||||
Server = 1,
|
||||
Session = 2
|
||||
Server = 1,
|
||||
Session = 2,
|
||||
}
|
||||
|
||||
public ServerManagerBase(SmApi sm, ManagerOptions options) : base(options.MaxDomainObjects, options.MaxDomains)
|
||||
|
@ -36,13 +36,13 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
_canDeferInvokeRequest = options.CanDeferInvokeRequest;
|
||||
|
||||
_multiWait = new MultiWait();
|
||||
_waitList = new MultiWait();
|
||||
_waitList = new MultiWait();
|
||||
|
||||
_multiWaitSelectionLock = new object();
|
||||
_waitListLock = new object();
|
||||
_waitListLock = new object();
|
||||
|
||||
_requestStopEvent = new Event(EventClearMode.ManualClear);
|
||||
_notifyEvent = new Event(EventClearMode.ManualClear);
|
||||
_notifyEvent = new Event(EventClearMode.ManualClear);
|
||||
|
||||
_requestStopEventHolder = new MultiWaitHolderOfEvent(_requestStopEvent);
|
||||
_multiWait.LinkMultiWaitHolder(_requestStopEventHolder);
|
||||
|
@ -113,7 +113,9 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
|
||||
public void ServiceRequests()
|
||||
{
|
||||
while (WaitAndProcessRequestsImpl());
|
||||
while (WaitAndProcessRequestsImpl())
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void WaitAndProcessRequests()
|
||||
|
@ -183,7 +185,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
protected override void RegisterSessionToWaitList(ServerSession session)
|
||||
{
|
||||
session.HasReceived = false;
|
||||
session.UserData = UserDataTag.Session;
|
||||
session.UserData = UserDataTag.Session;
|
||||
|
||||
RegisterToWaitList(session);
|
||||
}
|
||||
|
@ -209,9 +211,9 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
{
|
||||
return (UserDataTag)holder.UserData switch
|
||||
{
|
||||
UserDataTag.Server => ProcessForServer(holder),
|
||||
UserDataTag.Server => ProcessForServer(holder),
|
||||
UserDataTag.Session => ProcessForSession(holder),
|
||||
_ => throw new NotImplementedException(((UserDataTag)holder.UserData).ToString())
|
||||
_ => throw new NotImplementedException(((UserDataTag)holder.UserData).ToString()),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -6,18 +6,18 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
class ServerSession : MultiWaitHolderOfHandle
|
||||
{
|
||||
public ServiceObjectHolder ServiceObjectHolder { get; set; }
|
||||
public PointerAndSize PointerBuffer { get; set; }
|
||||
public PointerAndSize SavedMessage { get; set; }
|
||||
public int SessionIndex { get; }
|
||||
public int SessionHandle { get; }
|
||||
public bool IsClosed { get; set; }
|
||||
public bool HasReceived { get; set; }
|
||||
public PointerAndSize PointerBuffer { get; set; }
|
||||
public PointerAndSize SavedMessage { get; set; }
|
||||
public int SessionIndex { get; }
|
||||
public int SessionHandle { get; }
|
||||
public bool IsClosed { get; set; }
|
||||
public bool HasReceived { get; set; }
|
||||
|
||||
public ServerSession(int index, int handle, ServiceObjectHolder obj) : base(handle)
|
||||
{
|
||||
ServiceObjectHolder = obj;
|
||||
SessionIndex = index;
|
||||
SessionHandle = handle;
|
||||
SessionIndex = index;
|
||||
SessionHandle = handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
}
|
||||
|
||||
session.PointerBuffer = GetSessionPointerBuffer(session);
|
||||
session.SavedMessage = GetSessionSavedMessageBuffer(session);
|
||||
session.SavedMessage = GetSessionSavedMessageBuffer(session);
|
||||
|
||||
RegisterSessionToWaitList(session);
|
||||
|
||||
|
@ -110,10 +110,10 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
}
|
||||
|
||||
protected virtual Server AllocateServer(
|
||||
int portIndex,
|
||||
int portHandle,
|
||||
ServiceName name,
|
||||
bool managed,
|
||||
int portIndex,
|
||||
int portHandle,
|
||||
ServiceName name,
|
||||
bool managed,
|
||||
ServiceObjectHolder staticHoder)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
|
@ -161,29 +161,25 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
|
||||
return Result.Success;
|
||||
}
|
||||
else
|
||||
|
||||
Result result = ProcessRequestImpl(session, message, message);
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
Result result = ProcessRequestImpl(session, message, message);
|
||||
RegisterSessionToWaitList(session);
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
RegisterSessionToWaitList(session);
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
else if (SfResult.RequestContextChanged(result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.KernelIpc, $"Request processing returned error {result}");
|
||||
|
||||
CloseSessionImpl(session);
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
return Result.Success;
|
||||
}
|
||||
else if (SfResult.RequestContextChanged(result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
Logger.Warning?.Print(LogClass.KernelIpc, $"Request processing returned error {result}");
|
||||
|
||||
CloseSessionImpl(session);
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
private Result ProcessRequestImpl(ServerSession session, Span<byte> inMessage, Span<byte> outMessage)
|
||||
|
@ -192,18 +188,13 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
|
||||
using var _ = new ScopedInlineContextChange(GetInlineContext(commandType, inMessage));
|
||||
|
||||
switch (commandType)
|
||||
return commandType switch
|
||||
{
|
||||
case CommandType.Request:
|
||||
case CommandType.RequestWithContext:
|
||||
return DispatchRequest(session.ServiceObjectHolder, session, inMessage, outMessage);
|
||||
case CommandType.Control:
|
||||
case CommandType.ControlWithContext:
|
||||
return DispatchManagerRequest(session, inMessage, outMessage);
|
||||
default:
|
||||
return HipcResult.UnknownCommandType;
|
||||
CommandType.Request or CommandType.RequestWithContext => DispatchRequest(session.ServiceObjectHolder, session, inMessage, outMessage),
|
||||
CommandType.Control or CommandType.ControlWithContext => DispatchManagerRequest(session, inMessage, outMessage),
|
||||
_ => HipcResult.UnknownCommandType,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetInlineContext(CommandType commandType, ReadOnlySpan<byte> inMessage)
|
||||
{
|
||||
|
@ -221,12 +212,12 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
return 0;
|
||||
}
|
||||
|
||||
protected Result ReceiveRequest(ServerSession session, Span<byte> message)
|
||||
protected static Result ReceiveRequest(ServerSession session, Span<byte> message)
|
||||
{
|
||||
return ReceiveRequestImpl(session, message);
|
||||
}
|
||||
|
||||
private Result ReceiveRequestImpl(ServerSession session, Span<byte> message)
|
||||
private static Result ReceiveRequestImpl(ServerSession session, Span<byte> message)
|
||||
{
|
||||
PointerAndSize pointerBuffer = session.PointerBuffer;
|
||||
|
||||
|
@ -234,19 +225,19 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
{
|
||||
if (pointerBuffer.Address != 0)
|
||||
{
|
||||
HipcMessageData messageData = HipcMessage.WriteMessage(message, new HipcMetadata()
|
||||
HipcMessageData messageData = HipcMessage.WriteMessage(message, new HipcMetadata
|
||||
{
|
||||
Type = (int)CommandType.Invalid,
|
||||
ReceiveStaticsCount = HipcMessage.AutoReceiveStatic
|
||||
Type = (int)CommandType.Invalid,
|
||||
ReceiveStaticsCount = HipcMessage.AutoReceiveStatic,
|
||||
});
|
||||
|
||||
messageData.ReceiveList[0] = new HipcReceiveListEntry(pointerBuffer.Address, pointerBuffer.Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
MemoryMarshal.Cast<byte, Header>(message)[0] = new Header()
|
||||
MemoryMarshal.Cast<byte, Header>(message)[0] = new Header
|
||||
{
|
||||
Type = CommandType.Invalid
|
||||
Type = CommandType.Invalid,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -276,9 +267,9 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
|
||||
protected virtual Result DispatchRequest(
|
||||
ServiceObjectHolder objectHolder,
|
||||
ServerSession session,
|
||||
Span<byte> inMessage,
|
||||
Span<byte> outMessage)
|
||||
ServerSession session,
|
||||
Span<byte> inMessage,
|
||||
Span<byte> outMessage)
|
||||
{
|
||||
HipcMessage request;
|
||||
|
||||
|
@ -291,16 +282,16 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
return HipcResult.InvalidRequestSize;
|
||||
}
|
||||
|
||||
var dispatchCtx = new ServiceDispatchContext()
|
||||
var dispatchCtx = new ServiceDispatchContext
|
||||
{
|
||||
ServiceObject = objectHolder.ServiceObject,
|
||||
Manager = this,
|
||||
Session = session,
|
||||
HandlesToClose = new HandlesToClose(),
|
||||
PointerBuffer = session.PointerBuffer,
|
||||
InMessageBuffer = inMessage,
|
||||
ServiceObject = objectHolder.ServiceObject,
|
||||
Manager = this,
|
||||
Session = session,
|
||||
HandlesToClose = new HandlesToClose(),
|
||||
PointerBuffer = session.PointerBuffer,
|
||||
InMessageBuffer = inMessage,
|
||||
OutMessageBuffer = outMessage,
|
||||
Request = request
|
||||
Request = request,
|
||||
};
|
||||
|
||||
ReadOnlySpan<byte> inRawData = MemoryMarshal.Cast<uint, byte>(dispatchCtx.Request.Data.DataWords);
|
||||
|
@ -337,4 +328,4 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,19 +8,19 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
|
|||
|
||||
public bool SendPid
|
||||
{
|
||||
get => _word.Extract(0);
|
||||
readonly get => _word.Extract(0);
|
||||
set => _word = _word.Insert(0, value);
|
||||
}
|
||||
|
||||
public int CopyHandlesCount
|
||||
{
|
||||
get => (int)_word.Extract(1, 4);
|
||||
readonly get => (int)_word.Extract(1, 4);
|
||||
set => _word = _word.Insert(1, 4, (uint)value);
|
||||
}
|
||||
|
||||
public int MoveHandlesCount
|
||||
{
|
||||
get => (int)_word.Extract(5, 4);
|
||||
readonly get => (int)_word.Extract(5, 4);
|
||||
set => _word = _word.Insert(5, 4, (uint)value);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue