mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-09 01:18:35 +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>
71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using Ryujinx.Common;
|
|
using Ryujinx.HLE.HOS.Kernel.Common;
|
|
using Ryujinx.HLE.HOS.Kernel.Process;
|
|
|
|
namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|
{
|
|
class KSharedMemory : KAutoObject
|
|
{
|
|
private readonly KPageList _pageList;
|
|
|
|
private readonly long _ownerPid;
|
|
|
|
private readonly KMemoryPermission _ownerPermission;
|
|
private readonly KMemoryPermission _userPermission;
|
|
|
|
public KSharedMemory(
|
|
KernelContext context,
|
|
KPageList pageList,
|
|
long ownerPid,
|
|
KMemoryPermission ownerPermission,
|
|
KMemoryPermission userPermission) : base(context)
|
|
{
|
|
_pageList = pageList;
|
|
_ownerPid = ownerPid;
|
|
_ownerPermission = ownerPermission;
|
|
_userPermission = userPermission;
|
|
}
|
|
|
|
public KernelResult MapIntoProcess(
|
|
KMemoryManager memoryManager,
|
|
ulong address,
|
|
ulong size,
|
|
KProcess process,
|
|
KMemoryPermission permission)
|
|
{
|
|
ulong pagesCountRounded = BitUtils.DivRoundUp(size, KMemoryManager.PageSize);
|
|
|
|
if (_pageList.GetPagesCount() != pagesCountRounded)
|
|
{
|
|
return KernelResult.InvalidSize;
|
|
}
|
|
|
|
KMemoryPermission expectedPermission = process.Pid == _ownerPid
|
|
? _ownerPermission
|
|
: _userPermission;
|
|
|
|
if (permission != expectedPermission)
|
|
{
|
|
return KernelResult.InvalidPermission;
|
|
}
|
|
|
|
return memoryManager.MapPages(address, _pageList, MemoryState.SharedMemory, permission);
|
|
}
|
|
|
|
public KernelResult UnmapFromProcess(
|
|
KMemoryManager memoryManager,
|
|
ulong address,
|
|
ulong size,
|
|
KProcess process)
|
|
{
|
|
ulong pagesCountRounded = BitUtils.DivRoundUp(size, KMemoryManager.PageSize);
|
|
|
|
if (_pageList.GetPagesCount() != pagesCountRounded)
|
|
{
|
|
return KernelResult.InvalidSize;
|
|
}
|
|
|
|
return memoryManager.UnmapPages(address, _pageList, MemoryState.SharedMemory);
|
|
}
|
|
}
|
|
} |