2018-12-18 06:33:36 +01:00
|
|
|
using Ryujinx.HLE.HOS.Kernel.Common;
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
2018-11-28 23:18:09 +01:00
|
|
|
{
|
|
|
|
class KPort : KAutoObject
|
|
|
|
{
|
2019-01-18 23:26:39 +01:00
|
|
|
public KServerPort ServerPort { get; }
|
|
|
|
public KClientPort ClientPort { get; }
|
2018-11-28 23:18:09 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private long _nameAddress;
|
2018-11-28 23:18:09 +01:00
|
|
|
|
2019-01-18 23:26:39 +01:00
|
|
|
private ChannelState _state;
|
|
|
|
|
|
|
|
public bool IsLight { get; private set; }
|
|
|
|
|
|
|
|
public KPort(Horizon system, int maxSessions, bool isLight, long nameAddress) : base(system)
|
2018-11-28 23:18:09 +01:00
|
|
|
{
|
2019-01-18 23:26:39 +01:00
|
|
|
ServerPort = new KServerPort(system, this);
|
|
|
|
ClientPort = new KClientPort(system, this, maxSessions);
|
|
|
|
|
|
|
|
IsLight = isLight;
|
|
|
|
_nameAddress = nameAddress;
|
|
|
|
|
|
|
|
_state = ChannelState.Open;
|
2018-11-28 23:18:09 +01:00
|
|
|
}
|
|
|
|
|
2019-01-18 23:26:39 +01:00
|
|
|
public KernelResult EnqueueIncomingSession(KServerSession session)
|
2018-11-28 23:18:09 +01:00
|
|
|
{
|
2019-01-18 23:26:39 +01:00
|
|
|
KernelResult result;
|
2018-11-28 23:18:09 +01:00
|
|
|
|
2019-01-18 23:26:39 +01:00
|
|
|
System.CriticalSection.Enter();
|
|
|
|
|
|
|
|
if (_state == ChannelState.Open)
|
|
|
|
{
|
|
|
|
ServerPort.EnqueueIncomingSession(session);
|
|
|
|
|
|
|
|
result = KernelResult.Success;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = KernelResult.PortClosed;
|
|
|
|
}
|
|
|
|
|
|
|
|
System.CriticalSection.Leave();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public KernelResult EnqueueIncomingLightSession(KLightServerSession session)
|
|
|
|
{
|
|
|
|
KernelResult result;
|
|
|
|
|
|
|
|
System.CriticalSection.Enter();
|
|
|
|
|
|
|
|
if (_state == ChannelState.Open)
|
|
|
|
{
|
|
|
|
ServerPort.EnqueueIncomingLightSession(session);
|
|
|
|
|
|
|
|
result = KernelResult.Success;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = KernelResult.PortClosed;
|
|
|
|
}
|
|
|
|
|
|
|
|
System.CriticalSection.Leave();
|
|
|
|
|
|
|
|
return result;
|
2018-11-28 23:18:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|