mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-23 03:42:01 +00:00
08831eecf7
* IPC refactor part 3 + 4: New server HIPC message processor with source generator based serialization * Make types match on calls to AlignUp/AlignDown * Formatting * Address some PR feedback * Move BitfieldExtensions to Ryujinx.Common.Utilities and consolidate implementations * Rename Reader/Writer to SpanReader/SpanWriter and move to Ryujinx.Common.Memory * Implement EventType * Address more PR feedback * Log request processing errors since they are not normal * Rename waitable to multiwait and add missing lock * PR feedback * Ac_K PR feedback
84 lines
No EOL
2.4 KiB
C#
84 lines
No EOL
2.4 KiB
C#
using Ryujinx.HLE.HOS.Kernel.Common;
|
|
using Ryujinx.HLE.HOS.Kernel.Process;
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
|
using Ryujinx.Horizon.Common;
|
|
|
|
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 = KernelStatic.GetCurrentProcess();
|
|
CreatorProcess.IncrementReferenceCount();
|
|
}
|
|
|
|
public Result SendSyncRequest(ulong customCmdBuffAddr = 0, ulong customCmdBuffSize = 0)
|
|
{
|
|
KThread currentThread = KernelStatic.GetCurrentThread();
|
|
|
|
KSessionRequest request = new KSessionRequest(currentThread, customCmdBuffAddr, customCmdBuffSize);
|
|
|
|
KernelContext.CriticalSection.Enter();
|
|
|
|
currentThread.SignaledObj = null;
|
|
currentThread.ObjSyncResult = Result.Success;
|
|
|
|
Result result = _parent.ServerSession.EnqueueRequest(request);
|
|
|
|
KernelContext.CriticalSection.Leave();
|
|
|
|
if (result == Result.Success)
|
|
{
|
|
result = currentThread.ObjSyncResult;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public Result SendAsyncRequest(KWritableEvent asyncEvent, ulong customCmdBuffAddr = 0, ulong customCmdBuffSize = 0)
|
|
{
|
|
KThread currentThread = KernelStatic.GetCurrentThread();
|
|
|
|
KSessionRequest request = new KSessionRequest(currentThread, customCmdBuffAddr, customCmdBuffSize, asyncEvent);
|
|
|
|
KernelContext.CriticalSection.Enter();
|
|
|
|
Result 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();
|
|
}
|
|
}
|
|
} |