2023-03-04 08:43:08 -05:00
|
|
|
|
using Ryujinx.Horizon.Prepo;
|
|
|
|
|
using Ryujinx.Horizon.Prepo.Types;
|
2023-01-08 07:13:39 -05:00
|
|
|
|
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
2023-01-04 17:15:45 -05:00
|
|
|
|
using Ryujinx.Horizon.Sdk.Sm;
|
|
|
|
|
using Ryujinx.Horizon.Sm.Impl;
|
2023-01-08 07:13:39 -05:00
|
|
|
|
using Ryujinx.Horizon.Sm.Types;
|
2023-01-04 17:15:45 -05:00
|
|
|
|
|
|
|
|
|
namespace Ryujinx.Horizon.Sm
|
|
|
|
|
{
|
|
|
|
|
public class SmMain
|
|
|
|
|
{
|
2023-01-08 07:13:39 -05:00
|
|
|
|
private const int SmMaxSessionsCount = 64;
|
|
|
|
|
private const int SmmMaxSessionsCount = 1;
|
|
|
|
|
private const int SmTotalMaxSessionsCount = SmMaxSessionsCount + SmmMaxSessionsCount;
|
2023-01-04 17:15:45 -05:00
|
|
|
|
|
|
|
|
|
private const int MaxPortsCount = 2;
|
|
|
|
|
|
2023-01-08 07:13:39 -05:00
|
|
|
|
private SmServerManager _serverManager;
|
|
|
|
|
|
|
|
|
|
private readonly ServiceManager _serviceManager = new();
|
2023-01-04 17:15:45 -05:00
|
|
|
|
|
|
|
|
|
public void Main()
|
|
|
|
|
{
|
2023-01-08 07:13:39 -05:00
|
|
|
|
HorizonStatic.Syscall.ManageNamedPort(out int smHandle, "sm:", SmMaxSessionsCount).AbortOnFailure();
|
|
|
|
|
|
|
|
|
|
_serverManager = new SmServerManager(_serviceManager, null, null, MaxPortsCount, ManagerOptions.Default, SmTotalMaxSessionsCount);
|
2023-01-04 17:15:45 -05:00
|
|
|
|
|
2023-01-08 07:13:39 -05:00
|
|
|
|
_serverManager.RegisterServer((int)SmPortIndex.User, smHandle);
|
|
|
|
|
_serviceManager.RegisterServiceForSelf(out int smmHandle, ServiceName.Encode("sm:m"), SmmMaxSessionsCount).AbortOnFailure();
|
|
|
|
|
_serverManager.RegisterServer((int)SmPortIndex.Manager, smmHandle);
|
2023-01-04 17:15:45 -05:00
|
|
|
|
_serverManager.ServiceRequests();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-08 07:13:39 -05:00
|
|
|
|
}
|