mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-23 11:41:22 -08:00
Implement IIrSensorServer GetIrsensorSharedMemoryHandle (#664)
* Implement IIrSensorServer GetIrsensorSharedMemoryHandle Resolves #620 * Set _irsSharedMem
This commit is contained in:
parent
bea73895f5
commit
9e923b1473
@ -30,6 +30,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
internal const int HidSize = 0x40000;
|
||||
internal const int FontSize = 0x1100000;
|
||||
internal const int IirsSize = 0x8000;
|
||||
|
||||
private const int MemoryBlockAllocatorSize = 0x2710;
|
||||
|
||||
@ -81,6 +82,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
internal KSharedMemory HidSharedMem { get; private set; }
|
||||
internal KSharedMemory FontSharedMem { get; private set; }
|
||||
internal KSharedMemory IirsSharedMem { get; private set; }
|
||||
|
||||
internal SharedFontManager Font { get; private set; }
|
||||
|
||||
@ -151,17 +153,21 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
ulong hidPa = region.Address;
|
||||
ulong fontPa = region.Address + HidSize;
|
||||
ulong iirsPa = region.Address + HidSize + FontSize;
|
||||
|
||||
HidBaseAddress = (long)(hidPa - DramMemoryMap.DramBase);
|
||||
|
||||
KPageList hidPageList = new KPageList();
|
||||
KPageList fontPageList = new KPageList();
|
||||
KPageList iirsPageList = new KPageList();
|
||||
|
||||
hidPageList .AddRange(hidPa, HidSize / KMemoryManager.PageSize);
|
||||
fontPageList.AddRange(fontPa, FontSize / KMemoryManager.PageSize);
|
||||
iirsPageList.AddRange(iirsPa, IirsSize / KMemoryManager.PageSize);
|
||||
|
||||
HidSharedMem = new KSharedMemory(this, hidPageList, 0, 0, MemoryPermission.Read);
|
||||
FontSharedMem = new KSharedMemory(this, fontPageList, 0, 0, MemoryPermission.Read);
|
||||
IirsSharedMem = new KSharedMemory(this, iirsPageList, 0, 0, MemoryPermission.Read);
|
||||
|
||||
AppletState = new AppletStateMgr(this);
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.Exceptions;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@ -12,14 +14,19 @@ namespace Ryujinx.HLE.HOS.Services.Irs
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||
|
||||
public IIrSensorServer()
|
||||
private KSharedMemory _irsSharedMem;
|
||||
|
||||
public IIrSensorServer(KSharedMemory irsSharedMem)
|
||||
{
|
||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||
{
|
||||
{ 302, ActivateIrsensor },
|
||||
{ 303, DeactivateIrsensor },
|
||||
{ 304, GetIrsensorSharedMemoryHandle },
|
||||
{ 311, GetNpadIrCameraHandle }
|
||||
};
|
||||
|
||||
_irsSharedMem = irsSharedMem;
|
||||
}
|
||||
|
||||
// ActivateIrsensor(nn::applet::AppletResourceUserId, pid)
|
||||
@ -42,6 +49,21 @@ namespace Ryujinx.HLE.HOS.Services.Irs
|
||||
return 0;
|
||||
}
|
||||
|
||||
// GetIrsensorSharedMemoryHandle(nn::applet::AppletResourceUserId, pid) -> handle<copy>
|
||||
public long GetIrsensorSharedMemoryHandle(ServiceCtx context)
|
||||
{
|
||||
var handleTable = context.Process.HandleTable;
|
||||
|
||||
if (handleTable.GenerateHandle(_irsSharedMem, out int handle) != KernelResult.Success)
|
||||
{
|
||||
throw new InvalidOperationException("Out of handles!");
|
||||
}
|
||||
|
||||
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// GetNpadIrCameraHandle(u32) -> nn::irsensor::IrCameraHandle
|
||||
public long GetNpadIrCameraHandle(ServiceCtx context)
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
return new IHidServer(system);
|
||||
|
||||
case "irs":
|
||||
return new IIrSensorServer();
|
||||
return new IIrSensorServer(system.IirsSharedMem);
|
||||
|
||||
case "ldr:ro":
|
||||
return new IRoInterface();
|
||||
|
Loading…
Reference in New Issue
Block a user