From eda6b78894eef3d9dc1e8ea6984e2f5bd319d68e Mon Sep 17 00:00:00 2001 From: Ac_K Date: Sun, 8 Nov 2020 21:00:54 +0100 Subject: apm/am: Refactoring/Unstub services (#1662) * apm: Refactoring/Unstub service This PR implement some IPC calls of apm service: - nn::apm::IManager is fully implemented. - nn::apm::ISession is fully implemented (close #1633). - nn::apm::ISystemManager is partially implemented. nn::appletAE::ICommonStateGetter have some calls which are just a layer of apm IPC calls. What we did in some calls was wrong, it's fixed now! Everything is checked with RE. * abstract Apm *Server as Thog requested * abstract ISession and fix other classes * Address gdkchan feedback * Fix class * Fix Logging --- .../SystemAppletProxy/ICommonStateGetter.cs | 35 ++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy') diff --git a/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs b/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs index a2113163..82e18922 100644 --- a/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs +++ b/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs @@ -2,17 +2,22 @@ using Ryujinx.Common.Logging; using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.HOS.Kernel.Common; using Ryujinx.HLE.HOS.Kernel.Threading; -using Ryujinx.HLE.HOS.Services.Apm; using System; namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy { class ICommonStateGetter : IpcService { - private CpuBoostMode _cpuBoostMode = CpuBoostMode.Disabled; - private bool _vrModeEnabled = false; + private Apm.ManagerServer apmManagerServer; + private Apm.SystemManagerServer apmSystemManagerServer; - public ICommonStateGetter() { } + private bool _vrModeEnabled = false; + + public ICommonStateGetter(ServiceCtx context) + { + apmManagerServer = new Apm.ManagerServer(context); + apmSystemManagerServer = new Apm.SystemManagerServer(context); + } [Command(0)] // GetEventHandle() -> handle @@ -58,16 +63,10 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys } [Command(6)] - // GetPerformanceMode() -> u32 + // GetPerformanceMode() -> nn::apm::PerformanceMode public ResultCode GetPerformanceMode(ServiceCtx context) { - PerformanceMode mode = context.Device.System.State.DockedMode - ? PerformanceMode.Docked - : PerformanceMode.Handheld; - - context.ResponseData.Write((int)mode); - - return ResultCode.Success; + return (ResultCode)apmManagerServer.GetPerformanceMode(context); } [Command(8)] @@ -136,12 +135,18 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys return ResultCode.InvalidParameters; } - _cpuBoostMode = (CpuBoostMode)cpuBoostMode; + apmSystemManagerServer.SetCpuBoostMode((Apm.CpuBoostMode)cpuBoostMode); - // NOTE: There is a condition variable after the assignment, probably waiting something with apm:sys service (SetCpuBoostMode call?). - // Since we will probably never support CPU boost things, it's not needed to implement more. + // TODO: It signals an internal event of ICommonStateGetter. We have to determine where this event is used. return ResultCode.Success; } + + [Command(91)] // 7.0.0+ + // GetCurrentPerformanceConfiguration() -> nn::apm::PerformanceConfiguration + public ResultCode GetCurrentPerformanceConfiguration(ServiceCtx context) + { + return (ResultCode)apmSystemManagerServer.GetCurrentPerformanceConfiguration(context); + } } } \ No newline at end of file -- cgit v1.2.3