IPC refactor part 2: Use ReplyAndReceive on HLE services and remove special handling from kernel (#1458)
* 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>
This commit is contained in:
parent
461c24092a
commit
cf6cd71488
115 changed files with 2356 additions and 1088 deletions
|
@ -99,7 +99,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
copySize,
|
||||
stateMask,
|
||||
stateMask,
|
||||
MemoryPermission.ReadAndWrite,
|
||||
KMemoryPermission.ReadAndWrite,
|
||||
attributeMask,
|
||||
MemoryAttribute.None,
|
||||
desc.ServerAddress);
|
||||
|
@ -125,7 +125,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
clientEndAddr - clientEndAddrTruncated,
|
||||
stateMask,
|
||||
stateMask,
|
||||
MemoryPermission.ReadAndWrite,
|
||||
KMemoryPermission.ReadAndWrite,
|
||||
attributeMask,
|
||||
MemoryAttribute.None,
|
||||
serverEndAddrTruncated);
|
||||
|
|
|
@ -14,10 +14,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
|
||||
public bool IsLight => _parent.IsLight;
|
||||
|
||||
// TODO: Remove that, we need it for now to allow HLE
|
||||
// SM implementation to work with the new IPC system.
|
||||
public IpcService Service { get; set; }
|
||||
|
||||
public KClientPort(KernelContext context, KPort parent, int maxSessions) : base(context)
|
||||
{
|
||||
_maxSessions = maxSessions;
|
||||
|
@ -45,11 +41,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
|
||||
KSession session = new KSession(KernelContext, this);
|
||||
|
||||
if (Service != null)
|
||||
{
|
||||
session.ClientSession.Service = Service;
|
||||
}
|
||||
|
||||
KernelResult result = _parent.EnqueueIncomingSession(session.ServerSession);
|
||||
|
||||
if (result != KernelResult.Success)
|
||||
|
|
|
@ -16,10 +16,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
|
||||
public KClientPort ParentPort { get; }
|
||||
|
||||
// TODO: Remove that, we need it for now to allow HLE
|
||||
// services implementation to work with the new IPC system.
|
||||
public IpcService Service { get; set; }
|
||||
|
||||
public KClientSession(KernelContext context, KSession parent, KClientPort parentPort) : base(context)
|
||||
{
|
||||
_parent = parent;
|
||||
|
@ -84,11 +80,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
{
|
||||
_parent.DisconnectClient();
|
||||
_parent.DecrementReferenceCount();
|
||||
|
||||
if (Service is IDisposable disposableObj)
|
||||
{
|
||||
disposableObj.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -430,7 +430,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
descriptor.BufferAddress,
|
||||
MemoryState.IsPoolAllocated,
|
||||
MemoryState.IsPoolAllocated,
|
||||
MemoryPermission.Read,
|
||||
KMemoryPermission.Read,
|
||||
MemoryAttribute.Uncached,
|
||||
MemoryAttribute.None);
|
||||
|
||||
|
@ -473,9 +473,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
bool notReceiveDesc = isSendDesc || isExchangeDesc;
|
||||
bool isReceiveDesc = !notReceiveDesc;
|
||||
|
||||
MemoryPermission permission = index >= clientHeader.SendBuffersCount
|
||||
? MemoryPermission.ReadAndWrite
|
||||
: MemoryPermission.Read;
|
||||
KMemoryPermission permission = index >= clientHeader.SendBuffersCount
|
||||
? KMemoryPermission.ReadAndWrite
|
||||
: KMemoryPermission.Read;
|
||||
|
||||
uint sizeHigh4 = (descWord2 >> 24) & 0xf;
|
||||
|
||||
|
@ -559,9 +559,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
|
||||
if (serverMsg.IsCustom || clientMsg.IsCustom)
|
||||
{
|
||||
MemoryPermission permission = clientMsg.IsCustom
|
||||
? MemoryPermission.None
|
||||
: MemoryPermission.Read;
|
||||
KMemoryPermission permission = clientMsg.IsCustom
|
||||
? KMemoryPermission.None
|
||||
: KMemoryPermission.Read;
|
||||
|
||||
clientResult = clientProcess.MemoryManager.CopyDataToCurrentProcess(
|
||||
copyDst,
|
||||
|
@ -795,7 +795,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
descriptor.BufferSize,
|
||||
MemoryState.IsPoolAllocated,
|
||||
MemoryState.IsPoolAllocated,
|
||||
MemoryPermission.Read,
|
||||
KMemoryPermission.Read,
|
||||
MemoryAttribute.Uncached,
|
||||
MemoryAttribute.None,
|
||||
descriptor.BufferAddress);
|
||||
|
@ -849,9 +849,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
|
||||
if (serverMsg.IsCustom || clientMsg.IsCustom)
|
||||
{
|
||||
MemoryPermission permission = clientMsg.IsCustom
|
||||
? MemoryPermission.None
|
||||
: MemoryPermission.Read;
|
||||
KMemoryPermission permission = clientMsg.IsCustom
|
||||
? KMemoryPermission.None
|
||||
: KMemoryPermission.Read;
|
||||
|
||||
clientResult = clientProcess.MemoryManager.CopyDataFromCurrentProcess(
|
||||
copyDst,
|
||||
|
@ -898,11 +898,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
return new MessageHeader(word0, word1, word2);
|
||||
}
|
||||
|
||||
private KernelResult GetCopyObjectHandle(
|
||||
KThread srcThread,
|
||||
KProcess dstProcess,
|
||||
int srcHandle,
|
||||
out int dstHandle)
|
||||
private KernelResult GetCopyObjectHandle(KThread srcThread, KProcess dstProcess, int srcHandle, out int dstHandle)
|
||||
{
|
||||
dstHandle = 0;
|
||||
|
||||
|
@ -933,11 +929,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
}
|
||||
}
|
||||
|
||||
private KernelResult GetMoveObjectHandle(
|
||||
KProcess srcProcess,
|
||||
KProcess dstProcess,
|
||||
int srcHandle,
|
||||
out int dstHandle)
|
||||
private KernelResult GetMoveObjectHandle(KProcess srcProcess, KProcess dstProcess, int srcHandle, out int dstHandle)
|
||||
{
|
||||
dstHandle = 0;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ using System;
|
|||
|
||||
namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
||||
{
|
||||
class KSession : KAutoObject, IDisposable
|
||||
class KSession : KAutoObject
|
||||
{
|
||||
public KServerSession ServerSession { get; }
|
||||
public KClientSession ClientSession { get; }
|
||||
|
@ -37,19 +37,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && ClientSession.Service is IDisposable disposableService)
|
||||
{
|
||||
disposableService.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Destroy()
|
||||
{
|
||||
if (_hasBeenInitialized)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue