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
|
@ -1,7 +1,7 @@
|
|||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
@ -11,9 +11,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
{
|
||||
private const int FlagNotFreedYet = 1;
|
||||
|
||||
private static ConcurrentDictionary<KProcess, IdDictionary> _maps = new ConcurrentDictionary<KProcess, IdDictionary>();
|
||||
private static ConcurrentDictionary<long, IdDictionary> _maps = new ConcurrentDictionary<long, IdDictionary>();
|
||||
|
||||
public NvMapDeviceFile(ServiceCtx context) : base(context)
|
||||
public NvMapDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, long owner) : base(context, owner)
|
||||
{
|
||||
IdDictionary dict = _maps.GetOrAdd(Owner, (key) => new IdDictionary());
|
||||
|
||||
|
@ -244,9 +244,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
return dict.Add(map);
|
||||
}
|
||||
|
||||
private static bool DeleteMapWithHandle(KProcess process, int handle)
|
||||
private static bool DeleteMapWithHandle(long pid, int handle)
|
||||
{
|
||||
if (_maps.TryGetValue(process, out IdDictionary dict))
|
||||
if (_maps.TryGetValue(pid, out IdDictionary dict))
|
||||
{
|
||||
return dict.Delete(handle) != null;
|
||||
}
|
||||
|
@ -254,14 +254,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void IncrementMapRefCount(KProcess process, int handle, bool allowHandleZero = false)
|
||||
public static void IncrementMapRefCount(long pid, int handle, bool allowHandleZero = false)
|
||||
{
|
||||
GetMapFromHandle(process, handle, allowHandleZero)?.IncrementRefCount();
|
||||
GetMapFromHandle(pid, handle, allowHandleZero)?.IncrementRefCount();
|
||||
}
|
||||
|
||||
public static bool DecrementMapRefCount(KProcess process, int handle)
|
||||
public static bool DecrementMapRefCount(long pid, int handle)
|
||||
{
|
||||
NvMapHandle map = GetMapFromHandle(process, handle, false);
|
||||
NvMapHandle map = GetMapFromHandle(pid, handle, false);
|
||||
|
||||
if (map == null)
|
||||
{
|
||||
|
@ -270,7 +270,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
|
||||
if (map.DecrementRefCount() <= 0)
|
||||
{
|
||||
DeleteMapWithHandle(process, handle);
|
||||
DeleteMapWithHandle(pid, handle);
|
||||
|
||||
Logger.Info?.Print(LogClass.ServiceNv, $"Deleted map {handle}!");
|
||||
|
||||
|
@ -282,9 +282,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
}
|
||||
}
|
||||
|
||||
public static NvMapHandle GetMapFromHandle(KProcess process, int handle, bool allowHandleZero = false)
|
||||
public static NvMapHandle GetMapFromHandle(long pid, int handle, bool allowHandleZero = false)
|
||||
{
|
||||
if ((allowHandleZero || handle != 0) && _maps.TryGetValue(process, out IdDictionary dict))
|
||||
if ((allowHandleZero || handle != 0) && _maps.TryGetValue(pid, out IdDictionary dict))
|
||||
{
|
||||
return dict.GetData<NvMapHandle>(handle);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue