[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:
TSRBerry 2023-07-01 12:42:10 +02:00 committed by GitHub
parent 801b71a128
commit 02b5c7ea89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
105 changed files with 617 additions and 637 deletions

View File

@ -1,5 +1,4 @@
using Ryujinx.Horizon.Bcat.Ipc;
using Ryujinx.Horizon.Bcat.Types;
using Ryujinx.Horizon.Bcat.Types;
using Ryujinx.Horizon.Sdk.Sf.Hipc;
using Ryujinx.Horizon.Sdk.Sm;
@ -29,10 +28,12 @@ namespace Ryujinx.Horizon.Bcat
_serverManager = new BcatServerManager(allocator, _sm, MaxPortsCount, _bcatManagerOptions, BcatTotalMaxSessionsCount);
#pragma warning disable IDE0055 // Disable formatting
_serverManager.RegisterServer((int)BcatPortIndex.Admin, ServiceName.Encode("bcat:a"), BcatMaxSessionsCount);
_serverManager.RegisterServer((int)BcatPortIndex.Manager, ServiceName.Encode("bcat:m"), BcatMaxSessionsCount);
_serverManager.RegisterServer((int)BcatPortIndex.User, ServiceName.Encode("bcat:u"), BcatMaxSessionsCount);
_serverManager.RegisterServer((int)BcatPortIndex.System, ServiceName.Encode("bcat:s"), BcatMaxSessionsCount);
#pragma warning restore IDE0055
}
public void ServiceRequests()

View File

@ -1,11 +1,4 @@
using Ryujinx.Horizon.LogManager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ryujinx.Horizon.Bcat
namespace Ryujinx.Horizon.Bcat
{
internal class BcatMain : IService
{

View File

@ -7,12 +7,7 @@ namespace Ryujinx.Horizon.Bcat.Ipc
{
partial class BcatService : IBcatService
{
private readonly BcatServicePermissionLevel _permissionLevel;
public BcatService(BcatServicePermissionLevel permissionLevel)
{
_permissionLevel = permissionLevel;
}
public BcatService(BcatServicePermissionLevel permissionLevel) { }
[CmifCommand(10100)]
public Result RequestSyncDeliveryCache(out IDeliveryCacheProgressService deliveryCacheProgressService)

View File

@ -26,7 +26,7 @@ namespace Ryujinx.Horizon.Bcat.Ipc
}
[CmifCommand(1)]
public Result Read(out int entriesRead, [Buffer(Sdk.Sf.Hipc.HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<DeliveryCacheDirectoryEntry> entriesBuffer)
public Result Read(out int entriesRead, [Buffer(HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<DeliveryCacheDirectoryEntry> entriesBuffer)
{
return _libHacService.Get.Read(out entriesRead, entriesBuffer).ToHorizonResult();
}

View File

@ -39,7 +39,7 @@ namespace Ryujinx.Horizon.Bcat.Ipc
deliveryCacheProgressImpl = new DeliveryCacheProgressImpl
{
State = DeliveryCacheProgressImpl.Status.Done,
Result = 0
Result = 0,
};
Logger.Stub?.PrintStub(LogClass.ServiceBcat);

View File

@ -8,7 +8,7 @@ namespace Ryujinx.Horizon.Bcat.Ipc.Types
public enum Status
{
// TODO: determine other values
Done = 9
Done = 9,
}
public Status State;

View File

@ -5,6 +5,6 @@
Admin,
Manager,
User,
System
System,
}
}

View File

@ -5,6 +5,6 @@
Admin = -1,
User = 1,
System = 2,
Manager = 6
Manager = 6,
}
}

View File

@ -9,7 +9,7 @@ namespace Ryujinx.Horizon
{
private const ulong InvalidAddress = ulong.MaxValue;
private struct Range : IComparable<Range>
private readonly struct Range : IComparable<Range>
{
public ulong Offset { get; }
public ulong Size { get; }

View File

@ -2,7 +2,7 @@ using LibHac;
namespace Ryujinx.Horizon
{
public struct HorizonOptions
public readonly struct HorizonOptions
{
public bool IgnoreMissingServices { get; }
public bool ThrowOnInvalidCommandIds { get; }

View File

@ -95,38 +95,18 @@ namespace Ryujinx.Horizon.LogManager.Ipc
LogDataChunkKey key = (LogDataChunkKey)type;
if (key == LogDataChunkKey.Start)
switch (key)
{
case LogDataChunkKey.Start:
reader.Skip(size);
continue;
}
else if (key == LogDataChunkKey.Stop)
{
case LogDataChunkKey.Stop:
break;
}
else if (key == LogDataChunkKey.Line)
{
if (!reader.TryRead<int>(out _logPacket.Line))
{
case LogDataChunkKey.Line when !reader.TryRead(out _logPacket.Line):
case LogDataChunkKey.DropCount when !reader.TryRead(out _logPacket.DropCount):
case LogDataChunkKey.Time when !reader.TryRead(out _logPacket.Time):
return true;
}
}
else if (key == LogDataChunkKey.DropCount)
{
if (!reader.TryRead<long>(out _logPacket.DropCount))
{
return true;
}
}
else if (key == LogDataChunkKey.Time)
{
if (!reader.TryRead<long>(out _logPacket.Time))
{
return true;
}
}
else if (key == LogDataChunkKey.Message)
case LogDataChunkKey.Message:
{
string text = Encoding.UTF8.GetString(reader.GetSpanSafe(size)).TrimEnd();
@ -143,26 +123,24 @@ namespace Ryujinx.Horizon.LogManager.Ipc
isTailPacket = true;
}
}
break;
}
else if (key == LogDataChunkKey.Filename)
{
case LogDataChunkKey.Filename:
_logPacket.Filename = Encoding.UTF8.GetString(reader.GetSpanSafe(size)).TrimEnd();
}
else if (key == LogDataChunkKey.Function)
{
break;
case LogDataChunkKey.Function:
_logPacket.Function = Encoding.UTF8.GetString(reader.GetSpanSafe(size)).TrimEnd();
}
else if (key == LogDataChunkKey.Module)
{
break;
case LogDataChunkKey.Module:
_logPacket.Module = Encoding.UTF8.GetString(reader.GetSpanSafe(size)).TrimEnd();
}
else if (key == LogDataChunkKey.Thread)
{
break;
case LogDataChunkKey.Thread:
_logPacket.Thread = Encoding.UTF8.GetString(reader.GetSpanSafe(size)).TrimEnd();
}
else if (key == LogDataChunkKey.ProgramName)
{
break;
case LogDataChunkKey.ProgramName:
_logPacket.ProgramName = Encoding.UTF8.GetString(reader.GetSpanSafe(size)).TrimEnd();
break;
}
}
@ -177,7 +155,7 @@ namespace Ryujinx.Horizon.LogManager.Ipc
do
{
if (!reader.TryRead<byte>(out encoded))
if (!reader.TryRead(out encoded))
{
return false;
}

View File

@ -10,6 +10,7 @@ using Ryujinx.Horizon.Sdk.Sf;
using Ryujinx.Horizon.Sdk.Sf.Hipc;
using System;
using System.Text;
using ApplicationId = Ryujinx.Horizon.Sdk.Ncm.ApplicationId;
namespace Ryujinx.Horizon.Prepo.Ipc
{
@ -18,13 +19,13 @@ namespace Ryujinx.Horizon.Prepo.Ipc
enum PlayReportKind
{
Normal,
System
System,
}
private readonly PrepoServicePermissionLevel _permissionLevel;
private ulong _systemSessionId;
private bool _immediateTransmissionEnabled = false;
private bool _immediateTransmissionEnabled;
private bool _userAgreementCheckEnabled = true;
public PrepoService(PrepoServicePermissionLevel permissionLevel)
@ -107,7 +108,7 @@ namespace Ryujinx.Horizon.Prepo.Ipc
}
[CmifCommand(20100)]
public Result SaveSystemReport([Buffer(HipcBufferFlags.In | HipcBufferFlags.Pointer)] ReadOnlySpan<byte> gameRoomBuffer, Sdk.Ncm.ApplicationId applicationId, [Buffer(HipcBufferFlags.In | HipcBufferFlags.MapAlias)] ReadOnlySpan<byte> reportBuffer)
public Result SaveSystemReport([Buffer(HipcBufferFlags.In | HipcBufferFlags.Pointer)] ReadOnlySpan<byte> gameRoomBuffer, ApplicationId applicationId, [Buffer(HipcBufferFlags.In | HipcBufferFlags.MapAlias)] ReadOnlySpan<byte> reportBuffer)
{
if ((_permissionLevel & PrepoServicePermissionLevel.System) != 0)
{
@ -118,7 +119,7 @@ namespace Ryujinx.Horizon.Prepo.Ipc
}
[CmifCommand(20101)]
public Result SaveSystemReportWithUser(Uid userId, [Buffer(HipcBufferFlags.In | HipcBufferFlags.Pointer)] ReadOnlySpan<byte> gameRoomBuffer, Sdk.Ncm.ApplicationId applicationId, [Buffer(HipcBufferFlags.In | HipcBufferFlags.MapAlias)] ReadOnlySpan<byte> reportBuffer)
public Result SaveSystemReportWithUser(Uid userId, [Buffer(HipcBufferFlags.In | HipcBufferFlags.Pointer)] ReadOnlySpan<byte> gameRoomBuffer, ApplicationId applicationId, [Buffer(HipcBufferFlags.In | HipcBufferFlags.MapAlias)] ReadOnlySpan<byte> reportBuffer)
{
if ((_permissionLevel & PrepoServicePermissionLevel.System) != 0)
{
@ -164,7 +165,7 @@ namespace Ryujinx.Horizon.Prepo.Ipc
return PrepoResult.PermissionDenied;
}
private static Result ProcessPlayReport(PlayReportKind playReportKind, ReadOnlySpan<byte> gameRoomBuffer, ReadOnlySpan<byte> reportBuffer, ulong pid, Uid userId, bool withUserId = false, Sdk.Ncm.ApplicationId applicationId = default)
private static Result ProcessPlayReport(PlayReportKind playReportKind, ReadOnlySpan<byte> gameRoomBuffer, ReadOnlySpan<byte> reportBuffer, ulong pid, Uid userId, bool withUserId = false, ApplicationId applicationId = default)
{
if (withUserId)
{

View File

@ -28,12 +28,14 @@ namespace Ryujinx.Horizon.Prepo
_serverManager = new PrepoServerManager(allocator, _sm, MaxPortsCount, _prepoManagerOptions, PrepoTotalMaxSessionsCount);
#pragma warning disable IDE0055 // Disable formatting
_serverManager.RegisterServer((int)PrepoPortIndex.Admin, ServiceName.Encode("prepo:a"), PrepoMaxSessionsCount); // 1.0.0-5.1.0
_serverManager.RegisterServer((int)PrepoPortIndex.Admin2, ServiceName.Encode("prepo:a2"), PrepoMaxSessionsCount); // 6.0.0+
_serverManager.RegisterServer((int)PrepoPortIndex.Manager, ServiceName.Encode("prepo:m"), PrepoMaxSessionsCount);
_serverManager.RegisterServer((int)PrepoPortIndex.User, ServiceName.Encode("prepo:u"), PrepoMaxSessionsCount);
_serverManager.RegisterServer((int)PrepoPortIndex.System, ServiceName.Encode("prepo:s"), PrepoMaxSessionsCount);
_serverManager.RegisterServer((int)PrepoPortIndex.Debug, ServiceName.Encode("prepo:d"), PrepoMaxSessionsCount); // 1.0.0
#pragma warning restore IDE0055
}
public void ServiceRequests()

View File

@ -6,10 +6,12 @@ namespace Ryujinx.Horizon.Prepo
{
private const int ModuleId = 129;
#pragma warning disable IDE0055 // Disable formatting
public static Result InvalidArgument => new(ModuleId, 1);
public static Result InvalidState => new(ModuleId, 5);
public static Result InvalidBufferSize => new(ModuleId, 9);
public static Result PermissionDenied => new(ModuleId, 90);
public static Result InvalidPid => new(ModuleId, 101);
#pragma warning restore IDE0055
}
}

View File

@ -17,6 +17,7 @@ namespace Ryujinx.Horizon.Prepo
{
return (PrepoPortIndex)portIndex switch
{
#pragma warning disable IDE0055 // Disable formatting
PrepoPortIndex.Admin => AcceptImpl(server, new PrepoService(PrepoServicePermissionLevel.Admin)),
PrepoPortIndex.Admin2 => AcceptImpl(server, new PrepoService(PrepoServicePermissionLevel.Admin)),
PrepoPortIndex.Manager => AcceptImpl(server, new PrepoService(PrepoServicePermissionLevel.Manager)),
@ -24,6 +25,7 @@ namespace Ryujinx.Horizon.Prepo
PrepoPortIndex.System => AcceptImpl(server, new PrepoService(PrepoServicePermissionLevel.System)),
PrepoPortIndex.Debug => AcceptImpl(server, new PrepoService(PrepoServicePermissionLevel.Debug)),
_ => throw new ArgumentOutOfRangeException(nameof(portIndex)),
#pragma warning restore IDE0055
};
}
}

View File

@ -7,6 +7,6 @@
Manager,
User,
System,
Debug
Debug,
}
}

View File

@ -6,6 +6,6 @@
User = 1,
System = 2,
Manager = 6,
Debug = unchecked((int)0x80000006)
Debug = unchecked((int)0x80000006),
}
}

View File

@ -1,4 +1,5 @@
using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Sdk.Ncm;
using Ryujinx.Horizon.Sdk.Sf;
namespace Ryujinx.Horizon.Sdk.Bcat
@ -7,6 +8,6 @@ namespace Ryujinx.Horizon.Sdk.Bcat
{
Result CreateBcatService(out IBcatService service, ulong pid);
Result CreateDeliveryCacheStorageService(out IDeliveryCacheStorageService service, ulong pid);
Result CreateDeliveryCacheStorageServiceWithApplicationId(out IDeliveryCacheStorageService service, Ncm.ApplicationId applicationId);
Result CreateDeliveryCacheStorageServiceWithApplicationId(out IDeliveryCacheStorageService service, ApplicationId applicationId);
}
}

View File

@ -6,6 +6,6 @@ namespace Ryujinx.Horizon.Sdk.Diag
Info = 1,
Warn = 2,
Error = 3,
Fatal = 4
Fatal = 4,
}
}

View File

@ -14,6 +14,6 @@ namespace Ryujinx.Horizon.Sdk.Lm
Time = 9,
ProgramName = 10,
Count
Count,
}
}

View File

@ -9,6 +9,6 @@ namespace Ryujinx.Horizon.Sdk.Lm
Uart = 1 << 1,
UartIfSleep = 1 << 2,
All = 0xffff
All = 0xffff,
}
}

View File

@ -7,6 +7,6 @@ namespace Ryujinx.Horizon.Sdk.Lm
{
IsHead = 1 << 0,
IsTail = 1 << 1,
IsLittleEndian = 1 << 2
IsLittleEndian = 1 << 2,
}
}

View File

@ -3,6 +3,6 @@
enum EventClearMode
{
ManualClear,
AutoClear
AutoClear,
}
}

View File

@ -63,10 +63,7 @@ namespace Ryujinx.Horizon.Sdk.OsTypes.Impl
}
}
if (result == null)
{
result = WaitAnyHandleImpl(infinite, timeout);
}
result ??= WaitAnyHandleImpl(infinite, timeout);
UnlinkHoldersFromObjectsList();
_waitingThreadHandle = 0;
@ -98,7 +95,7 @@ namespace Ryujinx.Horizon.Sdk.OsTypes.Impl
}
else
{
index = WaitSynchronization(objectHandles.Slice(0, count), minTimeout);
index = WaitSynchronization(objectHandles[..count], minTimeout);
DebugUtil.Assert(index != WaitInvalid);
}
@ -200,10 +197,8 @@ namespace Ryujinx.Horizon.Sdk.OsTypes.Impl
{
return WaitCancelled;
}
else
{
result.AbortOnFailure();
}
return index;
}

View File

@ -3,6 +3,6 @@ namespace Ryujinx.Horizon.Sdk.OsTypes
enum InitializationState : byte
{
NotInitialized,
Initialized
Initialized,
}
}

View File

@ -4,7 +4,7 @@ namespace Ryujinx.Horizon.Sdk.OsTypes
{
class MultiWaitHolderOfEvent : MultiWaitHolder
{
private Event _event;
private readonly Event _event;
private LinkedListNode<MultiWaitHolderBase> _node;
public override TriBool Signaled

View File

@ -2,7 +2,7 @@
{
class MultiWaitHolderOfHandle : MultiWaitHolder
{
private int _handle;
private readonly int _handle;
public override int Handle => _handle;

View File

@ -15,7 +15,7 @@ namespace Ryujinx.Horizon.Sdk.OsTypes
InitiallySignaled = signaled,
ClearMode = clearMode,
State = InitializationState.Initialized,
Lock = new object()
Lock = new object(),
};
}

View File

@ -6,6 +6,6 @@ namespace Ryujinx.Horizon.Sdk.OsTypes
{
private const int ModuleId = 3;
public static Result OutOfResource => new Result(ModuleId, 9);
public static Result OutOfResource => new(ModuleId, 9);
}
}

View File

@ -6,12 +6,12 @@
{
NotInitialized,
InitializedAsEvent,
InitializedAsInterProcess
InitializedAsInterProcess,
}
public InterProcessEventType InterProcessEvent;
public InitializationState State;
public bool NotInitialized => State == InitializationState.NotInitialized;
public readonly bool NotInitialized => State == InitializationState.NotInitialized;
}
}

View File

@ -4,6 +4,6 @@
{
False,
True,
Undefined
Undefined,
}
}

View File

@ -2,6 +2,7 @@
using Ryujinx.Horizon.Sdk.Account;
using Ryujinx.Horizon.Sdk.Sf;
using System;
using ApplicationId = Ryujinx.Horizon.Sdk.Ncm.ApplicationId;
namespace Ryujinx.Horizon.Sdk.Prepo
{
@ -12,8 +13,8 @@ namespace Ryujinx.Horizon.Sdk.Prepo
Result RequestImmediateTransmission();
Result GetTransmissionStatus(out int status);
Result GetSystemSessionId(out ulong systemSessionId);
Result SaveSystemReport(ReadOnlySpan<byte> gameRoomBuffer, Ncm.ApplicationId applicationId, ReadOnlySpan<byte> reportBuffer);
Result SaveSystemReportWithUser(Uid userId, ReadOnlySpan<byte> gameRoomBuffer, Ncm.ApplicationId applicationId, ReadOnlySpan<byte> reportBuffer);
Result SaveSystemReport(ReadOnlySpan<byte> gameRoomBuffer, ApplicationId applicationId, ReadOnlySpan<byte> reportBuffer);
Result SaveSystemReportWithUser(Uid userId, ReadOnlySpan<byte> gameRoomBuffer, ApplicationId applicationId, ReadOnlySpan<byte> reportBuffer);
Result IsUserAgreementCheckEnabled(out bool enabled);
Result SetUserAgreementCheckEnabled(bool enabled);
}

View File

@ -14,11 +14,11 @@ namespace Ryujinx.Horizon.Sdk
using (var tlsRegion = HorizonStatic.AddressSpace.GetWritableRegion(tlsAddress, tlsSize))
{
CmifRequest request = CmifMessage.CreateRequest(tlsRegion.Memory.Span, new CmifRequestFormat()
CmifRequest request = CmifMessage.CreateRequest(tlsRegion.Memory.Span, new CmifRequestFormat
{
DataSize = data.Length,
RequestId = requestId,
SendPid = sendPid
SendPid = sendPid,
});
data.CopyTo(request.Data);

View File

@ -2,7 +2,7 @@
{
struct CmifDomainOutHeader
{
#pragma warning disable CS0649
#pragma warning disable CS0649 // Field is never assigned to
public uint ObjectsCount;
public uint Padding;
public uint Padding2;

View File

@ -4,6 +4,6 @@
{
Invalid = 0,
SendMessage = 1,
Close = 2
Close = 2,
}
}

View File

@ -32,7 +32,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
CmifRequest request = new()
{
Hipc = HipcMessage.WriteMessage(output, new HipcMetadata()
Hipc = HipcMessage.WriteMessage(output, new HipcMetadata
{
Type = format.Context != 0 ? (int)CommandType.RequestWithContext : (int)CommandType.Request,
SendStaticsCount = format.InAutoBuffersCount + format.InPointersCount,
@ -43,8 +43,8 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
ReceiveStaticsCount = outPointerSizeTableSize + format.OutFixedPointersCount,
SendPid = format.SendPid,
CopyHandlesCount = format.HandlesCount,
MoveHandlesCount = 0
})
MoveHandlesCount = 0,
}),
};
Span<uint> data = request.Hipc.DataWords;
@ -55,14 +55,14 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
int payloadSize = Unsafe.SizeOf<CmifInHeader>() + format.DataSize;
domainHeader = new CmifDomainInHeader()
domainHeader = new CmifDomainInHeader
{
Type = CmifDomainRequestType.SendMessage,
ObjectsCount = (byte)format.ObjectsCount,
DataSize = (ushort)payloadSize,
ObjectId = format.ObjectId,
Padding = 0,
Token = format.Context
Token = format.Context,
};
data = data[(Unsafe.SizeOf<CmifDomainInHeader>() / sizeof(uint))..];
@ -72,12 +72,12 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
ref CmifInHeader header = ref MemoryMarshal.Cast<uint, CmifInHeader>(data)[0];
header = new CmifInHeader()
header = new CmifInHeader
{
Magic = CmifInHeaderMagic,
Version = format.Context != 0 ? 1u : 0u,
CommandId = format.RequestId,
Token = format.ObjectId != 0 ? 0u : format.Context
Token = format.ObjectId != 0 ? 0u : format.Context,
};
request.Data = MemoryMarshal.Cast<uint, byte>(data)[Unsafe.SizeOf<CmifInHeader>()..];
@ -121,12 +121,12 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
return header.Result;
}
response = new CmifResponse()
response = new CmifResponse
{
Data = data[Unsafe.SizeOf<CmifOutHeader>()..],
Objects = objects,
CopyHandles = responseMessage.Data.CopyHandles,
MoveHandles = responseMessage.Data.MoveHandles
MoveHandles = responseMessage.Data.MoveHandles,
};
return Result.Success;

View File

@ -4,7 +4,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
{
struct CmifOutHeader
{
#pragma warning disable CS0649
#pragma warning disable CS0649 // Field is never assigned to
public uint Magic;
public uint Version;
public Result Result;

View File

@ -2,7 +2,7 @@
{
struct CmifRequestFormat
{
#pragma warning disable CS0649
#pragma warning disable CS0649 // Field is never assigned to
public int ObjectId;
public uint RequestId;
public uint Context;

View File

@ -9,6 +9,6 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
Request = 4,
Control = 5,
RequestWithContext = 6,
ControlWithContext = 7
ControlWithContext = 7,
}
}

View File

@ -12,7 +12,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
return ProcessMessageImpl(ref context, ((DomainServiceObject)context.ServiceObject).GetServerDomain(), inRawData);
}
private Result ProcessMessageImpl(ref ServiceDispatchContext context, ServerDomainBase domain, ReadOnlySpan<byte> inRawData)
private static Result ProcessMessageImpl(ref ServiceDispatchContext context, ServerDomainBase domain, ReadOnlySpan<byte> inRawData)
{
if (inRawData.Length < Unsafe.SizeOf<CmifDomainInHeader>())
{

View File

@ -19,7 +19,6 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
private int InObjectsCount => _inObjectIds.Length;
private int OutObjectsCount => _implMetadata.OutObjectsCount;
private int ImplOutHeadersSize => _implMetadata.OutHeadersSize;
private int ImplOutDataTotalSize => _implMetadata.OutDataSize + _implMetadata.OutHeadersSize;
public DomainServiceObjectProcessor(ServerDomainBase domain, int[] inObjectIds)

View File

@ -17,7 +17,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
public int this[int index]
{
get
readonly get
{
return index switch
{
@ -29,22 +29,39 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
5 => _handle5,
6 => _handle6,
7 => _handle7,
_ => throw new IndexOutOfRangeException()
_ => throw new IndexOutOfRangeException(),
};
}
set
{
switch (index)
{
case 0: _handle0 = value; break;
case 1: _handle1 = value; break;
case 2: _handle2 = value; break;
case 3: _handle3 = value; break;
case 4: _handle4 = value; break;
case 5: _handle5 = value; break;
case 6: _handle6 = value; break;
case 7: _handle7 = value; break;
default: throw new IndexOutOfRangeException();
case 0:
_handle0 = value;
break;
case 1:
_handle1 = value;
break;
case 2:
_handle2 = value;
break;
case 3:
_handle3 = value;
break;
case 4:
_handle4 = value;
break;
case 5:
_handle5 = value;
break;
case 6:
_handle6 = value;
break;
case 7:
_handle7 = value;
break;
default:
throw new IndexOutOfRangeException();
}
}
}

View File

@ -1,6 +1,6 @@
namespace Ryujinx.Horizon.Sdk.Sf.Cmif
{
struct PointerAndSize
readonly struct PointerAndSize
{
public static PointerAndSize Empty => new(0UL, 0UL);

View File

@ -2,7 +2,7 @@ using System;
namespace Ryujinx.Horizon.Sdk.Sf.Cmif
{
struct ScopedInlineContextChange : IDisposable
readonly struct ScopedInlineContextChange : IDisposable
{
private readonly int _previousContext;

View File

@ -211,7 +211,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
private readonly EntryManager _entryManager;
private readonly object _entryOwnerLock;
private readonly HashSet<Domain> _domains;
private int _maxDomains;
private readonly int _maxDomains;
public ServerDomainManager(int entryCount, int maxDomains)
{

View File

@ -1,6 +1,6 @@
namespace Ryujinx.Horizon.Sdk.Sf.Cmif
{
struct ServerMessageRuntimeMetadata
readonly struct ServerMessageRuntimeMetadata
{
public ushort InDataSize { get; }
public ushort OutDataSize { get; }

View File

@ -1,6 +1,6 @@
namespace Ryujinx.Horizon.Sdk.Sf.Cmif
{
struct ServiceDispatchMeta
readonly struct ServiceDispatchMeta
{
public ServiceDispatchTableBase DispatchTable { get; }

View File

@ -14,7 +14,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
public abstract Result ProcessMessage(ref ServiceDispatchContext context, ReadOnlySpan<byte> inRawData);
protected Result ProcessMessageImpl(ref ServiceDispatchContext context, ReadOnlySpan<byte> inRawData, IReadOnlyDictionary<int, CommandHandler> entries, string objectName)
protected static Result ProcessMessageImpl(ref ServiceDispatchContext context, ReadOnlySpan<byte> inRawData, IReadOnlyDictionary<int, CommandHandler> entries, string objectName)
{
if (inRawData.Length < Unsafe.SizeOf<CmifInHeader>())
{
@ -44,7 +44,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
// If ignore missing services is enabled, just pretend that everything is fine.
PrepareForStubReply(ref context, out Span<byte> outRawData);
CommandHandler.GetCmifOutHeaderPointer(ref outHeader, ref outRawData);
outHeader[0] = new CmifOutHeader() { Magic = CmifMessage.CmifOutHeaderMagic, Result = Result.Success };
outHeader[0] = new CmifOutHeader { Magic = CmifMessage.CmifOutHeaderMagic, Result = Result.Success };
Logger.Warning?.Print(LogClass.Service, $"Missing service {objectName} (command ID: {commandId}) ignored");
@ -80,7 +80,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
return commandResult;
}
outHeader[0] = new CmifOutHeader() { Magic = CmifMessage.CmifOutHeaderMagic, Result = commandResult };
outHeader[0] = new CmifOutHeader { Magic = CmifMessage.CmifOutHeaderMagic, Result = commandResult };
return Result.Success;
}

View File

@ -15,10 +15,10 @@ namespace Ryujinx.Horizon.Sdk.Sf
OutCopyHandle,
OutMoveHandle,
OutObject,
ProcessId
ProcessId,
}
struct CommandArg
readonly struct CommandArg
{
public CommandArgType Type { get; }
public HipcBufferFlags BufferFlags { get; }

View File

@ -41,11 +41,9 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
{
return HorizonStatic.Syscall.ReplyAndReceive(out _, handles, 0, -1L);
}
else
{
throw new NotImplementedException();
}
}
public static Result Reply(int sessionHandle, ReadOnlySpan<byte> messageBuffer)
{
@ -64,11 +62,9 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
{
return HorizonStatic.Syscall.ReplyAndReceive(out _, ReadOnlySpan<int>.Empty, sessionHandle, 0);
}
else
{
throw new NotImplementedException();
}
}
public static Result CreateSession(out int serverHandle, out int clientHandle)
{

View File

@ -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);
}
}

View File

@ -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);

View File

@ -12,6 +12,6 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
FixedSize = 1 << 4,
AutoSelect = 1 << 5,
MapTransferAllowsNonSecure = 1 << 6,
MapTransferAllowsNonDevice = 1 << 7
MapTransferAllowsNonDevice = 1 << 7,
}
}

View File

@ -5,6 +5,6 @@
Normal = 0,
NonSecure = 1,
Invalid = 2,
NonDevice = 3
NonDevice = 3,
}
}

View File

@ -51,7 +51,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
}
}
Meta = new HipcMetadata()
Meta = new HipcMetadata
{
Type = (int)header.Type,
SendStaticsCount = header.SendStaticsCount,
@ -62,7 +62,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
ReceiveStaticsCount = receiveStaticsCount,
SendPid = specialHeader.SendPid,
CopyHandlesCount = specialHeader.CopyHandlesCount,
MoveHandlesCount = specialHeader.MoveHandlesCount
MoveHandlesCount = specialHeader.MoveHandlesCount,
};
Data = CreateMessageData(Meta, data, initialLength);
@ -76,12 +76,12 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
int copyHandlesCount,
int moveHandlesCount)
{
return WriteMessage(destination, new HipcMetadata()
return WriteMessage(destination, new HipcMetadata
{
SendStaticsCount = sendStaticCount,
DataWordsCount = dataWordsCount,
CopyHandlesCount = copyHandlesCount,
MoveHandlesCount = moveHandlesCount
MoveHandlesCount = moveHandlesCount,
});
}
@ -90,7 +90,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
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,
@ -99,18 +99,18 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
ExchangeBuffersCount = meta.ExchangeBuffersCount,
DataWordsCount = meta.DataWordsCount,
ReceiveStaticMode = meta.ReceiveStaticsCount != 0 ? (meta.ReceiveStaticsCount != AutoReceiveStatic ? meta.ReceiveStaticsCount + 2 : 2) : 0,
HasSpecialHeader = hasSpecialHeader
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,
CopyHandlesCount = meta.CopyHandlesCount,
MoveHandlesCount = meta.MoveHandlesCount
MoveHandlesCount = meta.MoveHandlesCount,
};
destination = destination[Unsafe.SizeOf<SpecialHeader>()..];
@ -202,7 +202,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
receiveList = MemoryMarshal.Cast<byte, HipcReceiveListEntry>(data)[..receiveListSize];
}
return new HipcMessageData()
return new HipcMessageData
{
SendStatics = sendStatics,
SendBuffers = sendBuffers,
@ -211,7 +211,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
DataWords = dataWords,
ReceiveList = receiveList,
CopyHandles = copyHandles,
MoveHandles = moveHandles
MoveHandles = moveHandles,
};
}
}

View File

@ -1,9 +1,11 @@
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)
{

View File

@ -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
}
}

View File

@ -1,6 +1,6 @@
namespace Ryujinx.Horizon.Sdk.Sf.Hipc
{
struct HipcStaticDescriptor
readonly struct HipcStaticDescriptor
{
private readonly ulong _data;

View File

@ -1,6 +1,6 @@
namespace Ryujinx.Horizon.Sdk.Sf.Hipc
{
struct ManagerOptions
readonly struct ManagerOptions
{
public static ManagerOptions Default => new(0, 0, 0, false);

View File

@ -4,6 +4,6 @@
{
Success,
Closed,
NeedsRetry
NeedsRetry,
}
}

View File

@ -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,11 +145,9 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
{
return GetObjectBySessionIndex(session, _pointerBuffersBaseAddress, (ulong)_pointerBufferSize);
}
else
{
return PointerAndSize.Empty;
}
}
protected override PointerAndSize GetSessionSavedMessageBuffer(ServerSession session)
{
@ -157,11 +155,9 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
{
return GetObjectBySessionIndex(session, _savedMessagesBaseAddress, Api.TlsMessageBufferSize);
}
else
{
return PointerAndSize.Empty;
}
}
protected virtual void Dispose(bool disposing)
{

View File

@ -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;
@ -27,7 +27,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
private enum UserDataTag
{
Server = 1,
Session = 2
Session = 2,
}
public ServerManagerBase(SmApi sm, ManagerOptions options) : base(options.MaxDomainObjects, options.MaxDomains)
@ -113,7 +113,9 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
public void ServiceRequests()
{
while (WaitAndProcessRequestsImpl());
while (WaitAndProcessRequestsImpl())
{
}
}
public void WaitAndProcessRequests()
@ -211,7 +213,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
{
UserDataTag.Server => ProcessForServer(holder),
UserDataTag.Session => ProcessForSession(holder),
_ => throw new NotImplementedException(((UserDataTag)holder.UserData).ToString())
_ => throw new NotImplementedException(((UserDataTag)holder.UserData).ToString()),
};
}

View File

@ -161,8 +161,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
return Result.Success;
}
else
{
Result result = ProcessRequestImpl(session, message, message);
if (result.IsSuccess)
@ -175,16 +174,13 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
{
return result;
}
else
{
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,17 +188,12 @@ 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
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,
};
}
@ -291,7 +282,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
return HipcResult.InvalidRequestSize;
}
var dispatchCtx = new ServiceDispatchContext()
var dispatchCtx = new ServiceDispatchContext
{
ServiceObject = objectHolder.ServiceObject,
Manager = this,
@ -300,7 +291,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
PointerBuffer = session.PointerBuffer,
InMessageBuffer = inMessage,
OutMessageBuffer = outMessage,
Request = request
Request = request,
};
ReadOnlySpan<byte> inRawData = MemoryMarshal.Cast<uint, byte>(dispatchCtx.Request.Data.DataWords);

View File

@ -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);
}
}

View File

@ -386,7 +386,9 @@ namespace Ryujinx.Horizon.Sdk.Sf
outRawData = MemoryMarshal.Cast<uint, byte>(response.DataWords);
}
#pragma warning disable CA1822 // Mark member as static
public void SetOutObjects(ref ServiceDispatchContext context, HipcMessageData response, Span<IServiceObject> objects)
#pragma warning restore CA1822
{
if (objects.Length == 0)
{
@ -411,7 +413,7 @@ namespace Ryujinx.Horizon.Sdk.Sf
}
}
private void SetOutObjectImpl(int index, HipcMessageData response, ServerSessionManager manager, ServiceObjectHolder obj)
private static void SetOutObjectImpl(int index, HipcMessageData response, ServerSessionManager manager, ServiceObjectHolder obj)
{
if (obj == null)
{

View File

@ -6,6 +6,7 @@ namespace Ryujinx.Horizon.Sdk.Sf
{
public const int ModuleId = 10;
#pragma warning disable IDE0055 // Disable formatting
public static Result NotSupported => new(ModuleId, 1);
public static Result InvalidHeaderSize => new(ModuleId, 202);
public static Result InvalidInHeader => new(ModuleId, 211);
@ -23,5 +24,6 @@ namespace Ryujinx.Horizon.Sdk.Sf
public static bool RequestContextChanged(Result result) => result.InRange(800, 899);
public static bool Invalidated(Result result) => result.InRange(801, 809);
public static bool RequestDeferred(Result result) => result.InRange(811, 819);
#pragma warning restore IDE0055
}
}

View File

@ -4,13 +4,13 @@ using System.Runtime.InteropServices;
namespace Ryujinx.Horizon.Sdk.Sm
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ServiceName
readonly struct ServiceName
{
public static ServiceName Invalid { get; } = new ServiceName(0);
public static ServiceName Invalid { get; } = new(0);
public bool IsValid => Packed != 0;
public int Length => sizeof(ulong);
public const int Length = sizeof(ulong);
public ulong Packed { get; }

View File

@ -4,7 +4,7 @@ using System;
namespace Ryujinx.Horizon
{
public struct ServiceEntry
public readonly struct ServiceEntry
{
private readonly Action<ServiceTable> _entrypoint;
private readonly ServiceTable _serviceTable;

View File

@ -40,7 +40,7 @@ namespace Ryujinx.Horizon.Sm.Impl
return result == KernelResult.SessionCountExceeded ? SmResult.OutOfSessions : result;
}
private Result GetServiceImpl(out int handle, ref ServiceInfo serviceInfo)
private static Result GetServiceImpl(out int handle, ref ServiceInfo serviceInfo)
{
return HorizonStatic.Syscall.ConnectToPort(out handle, serviceInfo.PortHandle);
}
@ -140,7 +140,7 @@ namespace Ryujinx.Horizon.Sm.Impl
int nameLength = 1;
for (; nameLength < name.Length; nameLength++)
for (; nameLength < ServiceName.Length; nameLength++)
{
if (name[nameLength] == 0)
{
@ -148,7 +148,7 @@ namespace Ryujinx.Horizon.Sm.Impl
}
}
while (nameLength < name.Length)
while (nameLength < ServiceName.Length)
{
if (name[nameLength++] != 0)
{

View File

@ -1,6 +1,4 @@
using Ryujinx.Horizon.Prepo;
using Ryujinx.Horizon.Prepo.Types;
using Ryujinx.Horizon.Sdk.Sf.Hipc;
using Ryujinx.Horizon.Sdk.Sf.Hipc;
using Ryujinx.Horizon.Sdk.Sm;
using Ryujinx.Horizon.Sm.Impl;
using Ryujinx.Horizon.Sm.Types;

View File

@ -6,6 +6,7 @@ namespace Ryujinx.Horizon.Sm
{
private const int ModuleId = 21;
#pragma warning disable IDE0055 // Disable formatting
public static Result OutOfProcess => new(ModuleId, 1);
public static Result InvalidClient => new(ModuleId, 2);
public static Result OutOfSessions => new(ModuleId, 3);
@ -15,5 +16,6 @@ namespace Ryujinx.Horizon.Sm
public static Result NotRegistered => new(ModuleId, 7);
public static Result NotAllowed => new(ModuleId, 8);
public static Result TooLargeAccessControl => new(ModuleId, 9);
#pragma warning restore IDE0055
}
}

View File

@ -3,6 +3,6 @@
enum SmPortIndex
{
User,
Manager
Manager,
}
}