Add time shared memory, some ISelfController stuff and clean up ServiceFactory
This commit is contained in:
parent
9e923b1473
commit
efac6c4743
5 changed files with 80 additions and 53 deletions
|
@ -31,6 +31,7 @@ namespace Ryujinx.HLE.HOS
|
||||||
internal const int HidSize = 0x40000;
|
internal const int HidSize = 0x40000;
|
||||||
internal const int FontSize = 0x1100000;
|
internal const int FontSize = 0x1100000;
|
||||||
internal const int IirsSize = 0x8000;
|
internal const int IirsSize = 0x8000;
|
||||||
|
internal const int TimeSize = 0x1000;
|
||||||
|
|
||||||
private const int MemoryBlockAllocatorSize = 0x2710;
|
private const int MemoryBlockAllocatorSize = 0x2710;
|
||||||
|
|
||||||
|
@ -83,6 +84,7 @@ namespace Ryujinx.HLE.HOS
|
||||||
internal KSharedMemory HidSharedMem { get; private set; }
|
internal KSharedMemory HidSharedMem { get; private set; }
|
||||||
internal KSharedMemory FontSharedMem { get; private set; }
|
internal KSharedMemory FontSharedMem { get; private set; }
|
||||||
internal KSharedMemory IirsSharedMem { get; private set; }
|
internal KSharedMemory IirsSharedMem { get; private set; }
|
||||||
|
internal KSharedMemory TimeSharedMem { get; private set; }
|
||||||
|
|
||||||
internal SharedFontManager Font { get; private set; }
|
internal SharedFontManager Font { get; private set; }
|
||||||
|
|
||||||
|
@ -154,20 +156,24 @@ namespace Ryujinx.HLE.HOS
|
||||||
ulong hidPa = region.Address;
|
ulong hidPa = region.Address;
|
||||||
ulong fontPa = region.Address + HidSize;
|
ulong fontPa = region.Address + HidSize;
|
||||||
ulong iirsPa = region.Address + HidSize + FontSize;
|
ulong iirsPa = region.Address + HidSize + FontSize;
|
||||||
|
ulong timePa = region.Address + HidSize + FontSize + IirsSize;
|
||||||
|
|
||||||
HidBaseAddress = (long)(hidPa - DramMemoryMap.DramBase);
|
HidBaseAddress = (long)(hidPa - DramMemoryMap.DramBase);
|
||||||
|
|
||||||
KPageList hidPageList = new KPageList();
|
KPageList hidPageList = new KPageList();
|
||||||
KPageList fontPageList = new KPageList();
|
KPageList fontPageList = new KPageList();
|
||||||
KPageList iirsPageList = new KPageList();
|
KPageList iirsPageList = new KPageList();
|
||||||
|
KPageList timePageList = new KPageList();
|
||||||
|
|
||||||
hidPageList .AddRange(hidPa, HidSize / KMemoryManager.PageSize);
|
hidPageList .AddRange(hidPa, HidSize / KMemoryManager.PageSize);
|
||||||
fontPageList.AddRange(fontPa, FontSize / KMemoryManager.PageSize);
|
fontPageList.AddRange(fontPa, FontSize / KMemoryManager.PageSize);
|
||||||
iirsPageList.AddRange(iirsPa, IirsSize / KMemoryManager.PageSize);
|
iirsPageList.AddRange(iirsPa, IirsSize / KMemoryManager.PageSize);
|
||||||
|
timePageList.AddRange(timePa, TimeSize / KMemoryManager.PageSize);
|
||||||
|
|
||||||
HidSharedMem = new KSharedMemory(this, hidPageList, 0, 0, MemoryPermission.Read);
|
HidSharedMem = new KSharedMemory(this, hidPageList, 0, 0, MemoryPermission.Read);
|
||||||
FontSharedMem = new KSharedMemory(this, fontPageList, 0, 0, MemoryPermission.Read);
|
FontSharedMem = new KSharedMemory(this, fontPageList, 0, 0, MemoryPermission.Read);
|
||||||
IirsSharedMem = new KSharedMemory(this, iirsPageList, 0, 0, MemoryPermission.Read);
|
IirsSharedMem = new KSharedMemory(this, iirsPageList, 0, 0, MemoryPermission.Read);
|
||||||
|
TimeSharedMem = new KSharedMemory(this, timePageList, 0, 0, MemoryPermission.Read);
|
||||||
|
|
||||||
AppletState = new AppletStateMgr(this);
|
AppletState = new AppletStateMgr(this);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@ namespace Ryujinx.HLE.HOS.Services.Am
|
||||||
|
|
||||||
private int _idleTimeDetectionExtension;
|
private int _idleTimeDetectionExtension;
|
||||||
|
|
||||||
|
private int _suspendedTickValue;
|
||||||
|
private KEvent _suspendedTickChangedEvent;
|
||||||
|
|
||||||
public ISelfController(Horizon system)
|
public ISelfController(Horizon system)
|
||||||
{
|
{
|
||||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||||
|
@ -34,10 +37,13 @@ namespace Ryujinx.HLE.HOS.Services.Am
|
||||||
{ 19, SetScreenShotImageOrientation },
|
{ 19, SetScreenShotImageOrientation },
|
||||||
{ 50, SetHandlesRequestToDisplay },
|
{ 50, SetHandlesRequestToDisplay },
|
||||||
{ 62, SetIdleTimeDetectionExtension },
|
{ 62, SetIdleTimeDetectionExtension },
|
||||||
{ 63, GetIdleTimeDetectionExtension }
|
{ 63, GetIdleTimeDetectionExtension },
|
||||||
|
{ 90, GetAccumulatedSuspendedTickValue },
|
||||||
|
{ 91, GetAccumulatedSuspendedTickChangedEvent }
|
||||||
};
|
};
|
||||||
|
|
||||||
_launchableEvent = new KEvent(system);
|
_launchableEvent = new KEvent(system);
|
||||||
|
_suspendedTickChangedEvent = new KEvent(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long Exit(ServiceCtx context)
|
public long Exit(ServiceCtx context)
|
||||||
|
@ -170,5 +176,30 @@ namespace Ryujinx.HLE.HOS.Services.Am
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long GetAccumulatedSuspendedTickValue(ServiceCtx context)
|
||||||
|
{
|
||||||
|
context.ResponseData.Write(_suspendedTickValue);
|
||||||
|
|
||||||
|
Logger.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long GetAccumulatedSuspendedTickChangedEvent(ServiceCtx context)
|
||||||
|
{
|
||||||
|
_suspendedTickChangedEvent.ReadableEvent.Signal();
|
||||||
|
|
||||||
|
if (context.Process.HandleTable.GenerateHandle(_suspendedTickChangedEvent.ReadableEvent, out int handle) != KernelResult.Success)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Out of handles!");
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
|
||||||
|
|
||||||
|
Logger.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.HLE.Exceptions;
|
|
||||||
using Ryujinx.HLE.HOS.Ipc;
|
using Ryujinx.HLE.HOS.Ipc;
|
||||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||||
using Ryujinx.HLE.HOS.Kernel.Memory;
|
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||||
|
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
@ -14,9 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Irs
|
||||||
|
|
||||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||||
|
|
||||||
private KSharedMemory _irsSharedMem;
|
public IIrSensorServer()
|
||||||
|
|
||||||
public IIrSensorServer(KSharedMemory irsSharedMem)
|
|
||||||
{
|
{
|
||||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||||
{
|
{
|
||||||
|
@ -25,8 +23,6 @@ namespace Ryujinx.HLE.HOS.Services.Irs
|
||||||
{ 304, GetIrsensorSharedMemoryHandle },
|
{ 304, GetIrsensorSharedMemoryHandle },
|
||||||
{ 311, GetNpadIrCameraHandle }
|
{ 311, GetNpadIrCameraHandle }
|
||||||
};
|
};
|
||||||
|
|
||||||
_irsSharedMem = irsSharedMem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActivateIrsensor(nn::applet::AppletResourceUserId, pid)
|
// ActivateIrsensor(nn::applet::AppletResourceUserId, pid)
|
||||||
|
@ -52,9 +48,7 @@ namespace Ryujinx.HLE.HOS.Services.Irs
|
||||||
// GetIrsensorSharedMemoryHandle(nn::applet::AppletResourceUserId, pid) -> handle<copy>
|
// GetIrsensorSharedMemoryHandle(nn::applet::AppletResourceUserId, pid) -> handle<copy>
|
||||||
public long GetIrsensorSharedMemoryHandle(ServiceCtx context)
|
public long GetIrsensorSharedMemoryHandle(ServiceCtx context)
|
||||||
{
|
{
|
||||||
var handleTable = context.Process.HandleTable;
|
if (context.Process.HandleTable.GenerateHandle(context.Device.System.IirsSharedMem, out int handle) != KernelResult.Success)
|
||||||
|
|
||||||
if (handleTable.GenerateHandle(_irsSharedMem, out int handle) != KernelResult.Success)
|
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Out of handles!");
|
throw new InvalidOperationException("Out of handles!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,6 @@ namespace Ryujinx.HLE.HOS.Services
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case "acc:u0":
|
case "acc:u0":
|
||||||
return new IAccountService();
|
|
||||||
|
|
||||||
case "acc:u1":
|
case "acc:u1":
|
||||||
return new IAccountService();
|
return new IAccountService();
|
||||||
|
|
||||||
|
@ -52,8 +50,6 @@ namespace Ryujinx.HLE.HOS.Services
|
||||||
return new IAddOnContentManager();
|
return new IAddOnContentManager();
|
||||||
|
|
||||||
case "apm":
|
case "apm":
|
||||||
return new IManager();
|
|
||||||
|
|
||||||
case "apm:p":
|
case "apm:p":
|
||||||
return new IManager();
|
return new IManager();
|
||||||
|
|
||||||
|
@ -70,14 +66,8 @@ namespace Ryujinx.HLE.HOS.Services
|
||||||
return new IAudioRendererManager();
|
return new IAudioRendererManager();
|
||||||
|
|
||||||
case "bcat:a":
|
case "bcat:a":
|
||||||
return new Bcat.IServiceCreator();
|
|
||||||
|
|
||||||
case "bcat:m":
|
case "bcat:m":
|
||||||
return new Bcat.IServiceCreator();
|
|
||||||
|
|
||||||
case "bcat:u":
|
case "bcat:u":
|
||||||
return new Bcat.IServiceCreator();
|
|
||||||
|
|
||||||
case "bcat:s":
|
case "bcat:s":
|
||||||
return new Bcat.IServiceCreator();
|
return new Bcat.IServiceCreator();
|
||||||
|
|
||||||
|
@ -100,8 +90,6 @@ namespace Ryujinx.HLE.HOS.Services
|
||||||
return new IeTicketService();
|
return new IeTicketService();
|
||||||
|
|
||||||
case "friend:a":
|
case "friend:a":
|
||||||
return new Friend.IServiceCreator();
|
|
||||||
|
|
||||||
case "friend:u":
|
case "friend:u":
|
||||||
return new Friend.IServiceCreator();
|
return new Friend.IServiceCreator();
|
||||||
|
|
||||||
|
@ -112,7 +100,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||||
return new IHidServer(system);
|
return new IHidServer(system);
|
||||||
|
|
||||||
case "irs":
|
case "irs":
|
||||||
return new IIrSensorServer(system.IirsSharedMem);
|
return new IIrSensorServer();
|
||||||
|
|
||||||
case "ldr:ro":
|
case "ldr:ro":
|
||||||
return new IRoInterface();
|
return new IRoInterface();
|
||||||
|
@ -149,20 +137,12 @@ namespace Ryujinx.HLE.HOS.Services
|
||||||
return new IVulnerabilityManagerInterface();
|
return new IVulnerabilityManagerInterface();
|
||||||
|
|
||||||
case "nvdrv":
|
case "nvdrv":
|
||||||
return new INvDrvServices(system);
|
|
||||||
|
|
||||||
case "nvdrv:a":
|
case "nvdrv:a":
|
||||||
return new INvDrvServices(system);
|
return new INvDrvServices(system);
|
||||||
|
|
||||||
case "pctl:s":
|
case "pctl:s":
|
||||||
return new IParentalControlServiceFactory();
|
|
||||||
|
|
||||||
case "pctl:r":
|
case "pctl:r":
|
||||||
return new IParentalControlServiceFactory();
|
|
||||||
|
|
||||||
case "pctl:a":
|
case "pctl:a":
|
||||||
return new IParentalControlServiceFactory();
|
|
||||||
|
|
||||||
case "pctl":
|
case "pctl":
|
||||||
return new IParentalControlServiceFactory();
|
return new IParentalControlServiceFactory();
|
||||||
|
|
||||||
|
@ -173,8 +153,6 @@ namespace Ryujinx.HLE.HOS.Services
|
||||||
return new IShellInterface();
|
return new IShellInterface();
|
||||||
|
|
||||||
case "prepo:a":
|
case "prepo:a":
|
||||||
return new IPrepoService();
|
|
||||||
|
|
||||||
case "prepo:u":
|
case "prepo:u":
|
||||||
return new IPrepoService();
|
return new IPrepoService();
|
||||||
|
|
||||||
|
@ -197,13 +175,9 @@ namespace Ryujinx.HLE.HOS.Services
|
||||||
return new ISslService();
|
return new ISslService();
|
||||||
|
|
||||||
case "time:a":
|
case "time:a":
|
||||||
return new Time.IStaticService();
|
|
||||||
|
|
||||||
case "time:s":
|
case "time:s":
|
||||||
return new Time.IStaticService();
|
|
||||||
|
|
||||||
case "time:u":
|
case "time:u":
|
||||||
return new Time.IStaticService();
|
return new Time.IStaticService(system.TimeSharedMem);
|
||||||
|
|
||||||
case "vi:m":
|
case "vi:m":
|
||||||
return new IManagerRootService();
|
return new IManagerRootService();
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
using Ryujinx.HLE.HOS.Ipc;
|
using Ryujinx.HLE.HOS.Ipc;
|
||||||
|
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||||
|
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||||
|
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
@ -12,7 +15,9 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
||||||
|
|
||||||
private static readonly DateTime StartupDate = DateTime.UtcNow;
|
private static readonly DateTime StartupDate = DateTime.UtcNow;
|
||||||
|
|
||||||
public IStaticService()
|
private KSharedMemory _timeSharedMem;
|
||||||
|
|
||||||
|
public IStaticService(KSharedMemory timeSharedMem)
|
||||||
{
|
{
|
||||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||||
{
|
{
|
||||||
|
@ -21,8 +26,11 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
||||||
{ 2, GetStandardSteadyClock },
|
{ 2, GetStandardSteadyClock },
|
||||||
{ 3, GetTimeZoneService },
|
{ 3, GetTimeZoneService },
|
||||||
{ 4, GetStandardLocalSystemClock },
|
{ 4, GetStandardLocalSystemClock },
|
||||||
|
{ 20, GetSharedMemoryNativeHandle },
|
||||||
{ 300, CalculateMonotonicSystemClockBaseTimePoint }
|
{ 300, CalculateMonotonicSystemClockBaseTimePoint }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_timeSharedMem = timeSharedMem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long GetStandardUserSystemClock(ServiceCtx context)
|
public long GetStandardUserSystemClock(ServiceCtx context)
|
||||||
|
@ -60,6 +68,20 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long GetSharedMemoryNativeHandle(ServiceCtx context)
|
||||||
|
{
|
||||||
|
KHandleTable handleTable = context.Process.HandleTable;
|
||||||
|
|
||||||
|
if (handleTable.GenerateHandle(_timeSharedMem, out int handle) != KernelResult.Success)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Out of handles!");
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public long CalculateMonotonicSystemClockBaseTimePoint(ServiceCtx context)
|
public long CalculateMonotonicSystemClockBaseTimePoint(ServiceCtx context)
|
||||||
{
|
{
|
||||||
long timeOffset = (long)(DateTime.UtcNow - StartupDate).TotalSeconds;
|
long timeOffset = (long)(DateTime.UtcNow - StartupDate).TotalSeconds;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue