mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-10 04:39:11 +00:00
Start new IPC
This commit is contained in:
parent
3924bd1a43
commit
e5c0dfa87e
10 changed files with 326 additions and 0 deletions
44
src/Ryujinx.Horizon/Am/AmIpcServer.cs
Normal file
44
src/Ryujinx.Horizon/Am/AmIpcServer.cs
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
||||||
|
using Ryujinx.Horizon.Sdk.Sm;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Am
|
||||||
|
{
|
||||||
|
internal class AmIpcServer
|
||||||
|
{
|
||||||
|
// TODO: Get actual values from RE
|
||||||
|
private const int MaxSessionsCount = 10;
|
||||||
|
private const int TotalMaxSessionsCount = MaxSessionsCount * 4;
|
||||||
|
|
||||||
|
private const int PointerBufferSize = 0;
|
||||||
|
private const int MaxDomains = 0;
|
||||||
|
private const int MaxDomainObjects = 64;
|
||||||
|
private const int MaxPortsCount = 4;
|
||||||
|
|
||||||
|
private static readonly ManagerOptions _options = new(PointerBufferSize, MaxDomains, MaxDomainObjects, false);
|
||||||
|
|
||||||
|
private SmApi _sm;
|
||||||
|
private ServerManager _serverManager;
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
HeapAllocator allocator = new();
|
||||||
|
|
||||||
|
_sm = new SmApi();
|
||||||
|
_sm.Initialize().AbortOnFailure();
|
||||||
|
|
||||||
|
_serverManager = new ServerManager(allocator, _sm, MaxPortsCount, _options, TotalMaxSessionsCount);
|
||||||
|
|
||||||
|
_serverManager.RegisterServer(0, ServiceName.Encode("appletAE"), MaxSessionsCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ServiceRequests()
|
||||||
|
{
|
||||||
|
_serverManager.ServiceRequests();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Shutdown()
|
||||||
|
{
|
||||||
|
_serverManager.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
src/Ryujinx.Horizon/Am/AmMain.cs
Normal file
17
src/Ryujinx.Horizon/Am/AmMain.cs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
namespace Ryujinx.Horizon.Am
|
||||||
|
{
|
||||||
|
class AmMain : IService
|
||||||
|
{
|
||||||
|
public static void Main(ServiceTable serviceTable)
|
||||||
|
{
|
||||||
|
AmIpcServer ipcServer = new();
|
||||||
|
|
||||||
|
ipcServer.Initialize();
|
||||||
|
|
||||||
|
serviceTable.SignalServiceReady();
|
||||||
|
|
||||||
|
ipcServer.ServiceRequests();
|
||||||
|
ipcServer.Shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
src/Ryujinx.Horizon/Am/Ipc/ProxiesService.cs
Normal file
75
src/Ryujinx.Horizon/Am/Ipc/ProxiesService.cs
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
using LibHac.Diag;
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.Horizon.Common;
|
||||||
|
using Ryujinx.Horizon.Sdk.Am;
|
||||||
|
using Ryujinx.Horizon.Sdk.Sf;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Am.Ipc
|
||||||
|
{
|
||||||
|
partial class ProxiesService : IAllSystemAppletProxiesService
|
||||||
|
{
|
||||||
|
[CmifCommand(100)]
|
||||||
|
public Result OpenSystemAppletProxy(out ISystemAppletProxy systemAppletProxy, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(200)]
|
||||||
|
public Result OpenLibraryAppletProxyOld(out ILibraryAppletProxy libraryAppletProxy, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(201)]
|
||||||
|
public Result OpenLibraryAppletProxy(out ILibraryAppletProxy libraryAppletProxy, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(300)]
|
||||||
|
public Result OpenOverlayAppletProxy(out IOverlayAppletProxy overlayAppletProxy, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(350)]
|
||||||
|
public Result OpenSystemApplicationProxy(out IApplicationProxy applicationProxy, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(400)]
|
||||||
|
public Result CreateSelfLibraryAppletCreatorForDevelop()
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(410)]
|
||||||
|
public Result GetSystemAppletControllerForDebug()
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(1000)]
|
||||||
|
public Result GetDebugFunctions()
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
src/Ryujinx.Horizon/Sdk/Am/IAllSystemAppletProxiesService.cs
Normal file
16
src/Ryujinx.Horizon/Sdk/Am/IAllSystemAppletProxiesService.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
using Ryujinx.Horizon.Common;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Sdk.Am
|
||||||
|
{
|
||||||
|
public interface IAllSystemAppletProxiesService
|
||||||
|
{
|
||||||
|
Result OpenSystemAppletProxy(out ISystemAppletProxy systemAppletProxy, ulong pid);
|
||||||
|
Result OpenLibraryAppletProxyOld(out ILibraryAppletProxy libraryAppletProxy, ulong pid);
|
||||||
|
Result OpenLibraryAppletProxy(out ILibraryAppletProxy libraryAppletProxy, ulong pid);
|
||||||
|
Result OpenOverlayAppletProxy(out IOverlayAppletProxy overlayAppletProxy, ulong pid);
|
||||||
|
Result OpenSystemApplicationProxy(out IApplicationProxy applicationProxy, ulong pid);
|
||||||
|
Result CreateSelfLibraryAppletCreatorForDevelop();
|
||||||
|
Result GetSystemAppletControllerForDebug();
|
||||||
|
Result GetDebugFunctions();
|
||||||
|
}
|
||||||
|
}
|
17
src/Ryujinx.Horizon/Sdk/Am/IApplicationProxy.cs
Normal file
17
src/Ryujinx.Horizon/Sdk/Am/IApplicationProxy.cs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
using Ryujinx.Horizon.Common;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Sdk.Am
|
||||||
|
{
|
||||||
|
public interface IApplicationProxy
|
||||||
|
{
|
||||||
|
Result GetCommonStateGetter();
|
||||||
|
Result GetSelfController();
|
||||||
|
Result GetWindowController();
|
||||||
|
Result GetAudioController();
|
||||||
|
Result GetDisplayController();
|
||||||
|
Result GetProcessWindingController();
|
||||||
|
Result GetLibraryAppletCreator();
|
||||||
|
Result GetApplicationFunctions();
|
||||||
|
Result GetDebugFunctions();
|
||||||
|
}
|
||||||
|
}
|
20
src/Ryujinx.Horizon/Sdk/Am/ILibraryAppletProxy.cs
Normal file
20
src/Ryujinx.Horizon/Sdk/Am/ILibraryAppletProxy.cs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
using Ryujinx.Horizon.Common;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Sdk.Am
|
||||||
|
{
|
||||||
|
public interface ILibraryAppletProxy
|
||||||
|
{
|
||||||
|
Result GetCommonStateGetter();
|
||||||
|
Result GetSelfController();
|
||||||
|
Result GetWindowController();
|
||||||
|
Result GetAudioController();
|
||||||
|
Result GetDisplayController();
|
||||||
|
Result GetProcessWindingController();
|
||||||
|
Result GetLibraryAppletCreator();
|
||||||
|
Result OpenLibraryAppletSelfAccessor();
|
||||||
|
Result GetAppletCommonFunctions();
|
||||||
|
Result GetHomeMenuFunctions();
|
||||||
|
Result GetGlobalStateController();
|
||||||
|
Result GetDebugFunctions();
|
||||||
|
}
|
||||||
|
}
|
19
src/Ryujinx.Horizon/Sdk/Am/IOverlayAppletProxy.cs
Normal file
19
src/Ryujinx.Horizon/Sdk/Am/IOverlayAppletProxy.cs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
using Ryujinx.Horizon.Common;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Sdk.Am
|
||||||
|
{
|
||||||
|
public interface IOverlayAppletProxy
|
||||||
|
{
|
||||||
|
Result GetCommonStateGetter();
|
||||||
|
Result GetSelfController();
|
||||||
|
Result GetWindowController();
|
||||||
|
Result GetAudioController();
|
||||||
|
Result GetDisplayController();
|
||||||
|
Result GetProcessWindingController();
|
||||||
|
Result GetLibraryAppletCreator();
|
||||||
|
Result GetOverlayFunctions();
|
||||||
|
Result GetAppletCommonFunctions();
|
||||||
|
Result GetGlobalStateController();
|
||||||
|
Result GetDebugFunctions();
|
||||||
|
}
|
||||||
|
}
|
20
src/Ryujinx.Horizon/Sdk/Am/ISystemAppletProxy.cs
Normal file
20
src/Ryujinx.Horizon/Sdk/Am/ISystemAppletProxy.cs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
using Ryujinx.Horizon.Common;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Sdk.Am
|
||||||
|
{
|
||||||
|
public interface ISystemAppletProxy
|
||||||
|
{
|
||||||
|
Result GetCommonStateGetter();
|
||||||
|
Result GetSelfController();
|
||||||
|
Result GetWindowController();
|
||||||
|
Result GetAudioController();
|
||||||
|
Result GetDisplayController();
|
||||||
|
Result GetProcessWindingController();
|
||||||
|
Result GetLibraryAppletCreator();
|
||||||
|
Result GetHomeMenuFunctions();
|
||||||
|
Result GetGlobalStateController();
|
||||||
|
Result GetApplicationCreator();
|
||||||
|
Result GetAppletCommonFunctions();
|
||||||
|
Result GetDebugFunctions();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
using Ryujinx.Horizon.Arp;
|
using Ryujinx.Horizon.Arp;
|
||||||
using Ryujinx.Horizon.Audio;
|
using Ryujinx.Horizon.Audio;
|
||||||
|
using Ryujinx.Horizon.Am;
|
||||||
using Ryujinx.Horizon.Bcat;
|
using Ryujinx.Horizon.Bcat;
|
||||||
using Ryujinx.Horizon.Friends;
|
using Ryujinx.Horizon.Friends;
|
||||||
using Ryujinx.Horizon.Hshl;
|
using Ryujinx.Horizon.Hshl;
|
||||||
|
@ -56,6 +57,7 @@ namespace Ryujinx.Horizon
|
||||||
RegisterService<SrepoMain>();
|
RegisterService<SrepoMain>();
|
||||||
RegisterService<UsbMain>();
|
RegisterService<UsbMain>();
|
||||||
RegisterService<WlanMain>();
|
RegisterService<WlanMain>();
|
||||||
|
RegisterService<AmMain>();
|
||||||
|
|
||||||
_totalServices = entries.Count;
|
_totalServices = entries.Count;
|
||||||
|
|
||||||
|
|
96
src/Ryujinx.Horizon/ServiceTable.cs.orig
Normal file
96
src/Ryujinx.Horizon/ServiceTable.cs.orig
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
<<<<<<< HEAD
|
||||||
|
using Ryujinx.Horizon.Arp;
|
||||||
|
using Ryujinx.Horizon.Audio;
|
||||||
|
=======
|
||||||
|
using Ryujinx.Horizon.Am;
|
||||||
|
>>>>>>> 8a4ff3542 (Start new IPC)
|
||||||
|
using Ryujinx.Horizon.Bcat;
|
||||||
|
using Ryujinx.Horizon.Friends;
|
||||||
|
using Ryujinx.Horizon.Hshl;
|
||||||
|
using Ryujinx.Horizon.Ins;
|
||||||
|
using Ryujinx.Horizon.Lbl;
|
||||||
|
using Ryujinx.Horizon.LogManager;
|
||||||
|
using Ryujinx.Horizon.MmNv;
|
||||||
|
using Ryujinx.Horizon.Ngc;
|
||||||
|
using Ryujinx.Horizon.Ovln;
|
||||||
|
using Ryujinx.Horizon.Prepo;
|
||||||
|
using Ryujinx.Horizon.Psc;
|
||||||
|
using Ryujinx.Horizon.Sdk.Arp;
|
||||||
|
using Ryujinx.Horizon.Srepo;
|
||||||
|
using Ryujinx.Horizon.Usb;
|
||||||
|
using Ryujinx.Horizon.Wlan;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon
|
||||||
|
{
|
||||||
|
public class ServiceTable
|
||||||
|
{
|
||||||
|
private int _readyServices;
|
||||||
|
private int _totalServices;
|
||||||
|
|
||||||
|
private readonly ManualResetEvent _servicesReadyEvent = new(false);
|
||||||
|
|
||||||
|
public IReader ArpReader { get; internal set; }
|
||||||
|
public IWriter ArpWriter { get; internal set; }
|
||||||
|
|
||||||
|
public IEnumerable<ServiceEntry> GetServices(HorizonOptions options)
|
||||||
|
{
|
||||||
|
List<ServiceEntry> entries = new();
|
||||||
|
|
||||||
|
void RegisterService<T>() where T : IService
|
||||||
|
{
|
||||||
|
entries.Add(new ServiceEntry(T.Main, this, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterService<ArpMain>();
|
||||||
|
RegisterService<AudioMain>();
|
||||||
|
RegisterService<BcatMain>();
|
||||||
|
RegisterService<FriendsMain>();
|
||||||
|
RegisterService<HshlMain>();
|
||||||
|
RegisterService<HwopusMain>(); // TODO: Merge with audio once we can start multiple threads.
|
||||||
|
RegisterService<InsMain>();
|
||||||
|
RegisterService<LblMain>();
|
||||||
|
RegisterService<LmMain>();
|
||||||
|
RegisterService<MmNvMain>();
|
||||||
|
RegisterService<NgcMain>();
|
||||||
|
RegisterService<OvlnMain>();
|
||||||
|
RegisterService<PrepoMain>();
|
||||||
|
RegisterService<PscMain>();
|
||||||
|
RegisterService<SrepoMain>();
|
||||||
|
RegisterService<UsbMain>();
|
||||||
|
RegisterService<WlanMain>();
|
||||||
|
RegisterService<AmMain>();
|
||||||
|
|
||||||
|
_totalServices = entries.Count;
|
||||||
|
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void SignalServiceReady()
|
||||||
|
{
|
||||||
|
if (Interlocked.Increment(ref _readyServices) == _totalServices)
|
||||||
|
{
|
||||||
|
_servicesReadyEvent.Set();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WaitServicesReady()
|
||||||
|
{
|
||||||
|
_servicesReadyEvent.WaitOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
_servicesReadyEvent.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue