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
This commit is contained in:
Ac_K 2020-11-08 21:00:54 +01:00 committed by GitHub
parent 8d168574eb
commit eda6b78894
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 282 additions and 37 deletions

View file

@ -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<copy>
@ -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);
}
}
}