mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-25 14:55:49 +00:00
cf6cd71488
* IPC refactor part 2: Use ReplyAndReceive on HLE services and remove special handling from kernel * Fix for applet transfer memory + some nits * Keep handles if possible to avoid server handle table exhaustion * Fix IPC ZeroFill bug * am: Correctly implement CreateManagedDisplayLayer and implement CreateManagedDisplaySeparableLayer CreateManagedDisplaySeparableLayer is requires since 10.x+ when appletResourceUserId != 0 * Make it exit properly * Make ServiceNotImplementedException show the full message again * Allow yielding execution to avoid starving other threads * Only wait if active * Merge IVirtualMemoryManager and IAddressSpaceManager * Fix Ro loading data from the wrong process Co-authored-by: Thog <me@thog.eu>
85 lines
No EOL
2.5 KiB
C#
85 lines
No EOL
2.5 KiB
C#
using Ryujinx.HLE.HOS.Kernel.Common;
|
|
using Ryujinx.HLE.HOS.Kernel.Process;
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
|
using Ryujinx.HLE.HOS.Services;
|
|
using System;
|
|
|
|
namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|
{
|
|
class KClientSession : KSynchronizationObject
|
|
{
|
|
public KProcess CreatorProcess { get; }
|
|
|
|
private KSession _parent;
|
|
|
|
public ChannelState State { get; set; }
|
|
|
|
public KClientPort ParentPort { get; }
|
|
|
|
public KClientSession(KernelContext context, KSession parent, KClientPort parentPort) : base(context)
|
|
{
|
|
_parent = parent;
|
|
ParentPort = parentPort;
|
|
|
|
parentPort?.IncrementReferenceCount();
|
|
|
|
State = ChannelState.Open;
|
|
|
|
CreatorProcess = context.Scheduler.GetCurrentProcess();
|
|
CreatorProcess.IncrementReferenceCount();
|
|
}
|
|
|
|
public KernelResult SendSyncRequest(ulong customCmdBuffAddr = 0, ulong customCmdBuffSize = 0)
|
|
{
|
|
KThread currentThread = KernelContext.Scheduler.GetCurrentThread();
|
|
|
|
KSessionRequest request = new KSessionRequest(currentThread, customCmdBuffAddr, customCmdBuffSize);
|
|
|
|
KernelContext.CriticalSection.Enter();
|
|
|
|
currentThread.SignaledObj = null;
|
|
currentThread.ObjSyncResult = KernelResult.Success;
|
|
|
|
KernelResult result = _parent.ServerSession.EnqueueRequest(request);
|
|
|
|
KernelContext.CriticalSection.Leave();
|
|
|
|
if (result == KernelResult.Success)
|
|
{
|
|
result = currentThread.ObjSyncResult;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public KernelResult SendAsyncRequest(KWritableEvent asyncEvent, ulong customCmdBuffAddr = 0, ulong customCmdBuffSize = 0)
|
|
{
|
|
KThread currentThread = KernelContext.Scheduler.GetCurrentThread();
|
|
|
|
KSessionRequest request = new KSessionRequest(currentThread, customCmdBuffAddr, customCmdBuffSize, asyncEvent);
|
|
|
|
KernelContext.CriticalSection.Enter();
|
|
|
|
KernelResult result = _parent.ServerSession.EnqueueRequest(request);
|
|
|
|
KernelContext.CriticalSection.Leave();
|
|
|
|
return result;
|
|
}
|
|
|
|
public void DisconnectFromPort()
|
|
{
|
|
if (ParentPort != null)
|
|
{
|
|
ParentPort.Disconnect();
|
|
ParentPort.DecrementReferenceCount();
|
|
}
|
|
}
|
|
|
|
protected override void Destroy()
|
|
{
|
|
_parent.DisconnectClient();
|
|
_parent.DecrementReferenceCount();
|
|
}
|
|
}
|
|
} |