2018-10-21 06:01:22 +00:00
|
|
|
|
using Ryujinx.Common.Logging;
|
|
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
2018-12-18 05:33:36 +00:00
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Common;
|
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Psm
|
|
|
|
|
{
|
|
|
|
|
class IPsmSession : IpcService
|
|
|
|
|
{
|
2018-12-06 11:16:24 +00:00
|
|
|
|
private KEvent _stateChangeEvent;
|
|
|
|
|
private int _stateChangeEventHandle;
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2018-12-06 11:16:24 +00:00
|
|
|
|
public IPsmSession(Horizon system)
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
2018-12-06 11:16:24 +00:00
|
|
|
|
_stateChangeEvent = new KEvent(system);
|
|
|
|
|
_stateChangeEventHandle = -1;
|
2018-10-21 06:01:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-12 01:13:43 +00:00
|
|
|
|
[Command(0)]
|
2018-10-21 06:01:22 +00:00
|
|
|
|
// BindStateChangeEvent() -> KObject
|
2019-07-14 19:04:38 +00:00
|
|
|
|
public ResultCode BindStateChangeEvent(ServiceCtx context)
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
2018-12-06 11:16:24 +00:00
|
|
|
|
if (_stateChangeEventHandle == -1)
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
2019-01-18 22:26:39 +00:00
|
|
|
|
KernelResult resultCode = context.Process.HandleTable.GenerateHandle(_stateChangeEvent.ReadableEvent, out int stateChangeEventHandle);
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2018-12-06 11:16:24 +00:00
|
|
|
|
if (resultCode != KernelResult.Success)
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
2019-07-14 19:04:38 +00:00
|
|
|
|
return (ResultCode)resultCode;
|
2018-10-21 06:01:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-06 11:16:24 +00:00
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_stateChangeEventHandle);
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2019-01-11 00:11:46 +00:00
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm);
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2019-07-14 19:04:38 +00:00
|
|
|
|
return ResultCode.Success;
|
2018-10-21 06:01:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-12 01:13:43 +00:00
|
|
|
|
[Command(1)]
|
2018-10-21 06:01:22 +00:00
|
|
|
|
// UnbindStateChangeEvent()
|
2019-07-14 19:04:38 +00:00
|
|
|
|
public ResultCode UnbindStateChangeEvent(ServiceCtx context)
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
2018-12-06 11:16:24 +00:00
|
|
|
|
if (_stateChangeEventHandle != -1)
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
2018-12-06 11:16:24 +00:00
|
|
|
|
context.Process.HandleTable.CloseHandle(_stateChangeEventHandle);
|
|
|
|
|
_stateChangeEventHandle = -1;
|
2018-10-21 06:01:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 00:11:46 +00:00
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm);
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2019-07-14 19:04:38 +00:00
|
|
|
|
return ResultCode.Success;
|
2018-10-21 06:01:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-12 01:13:43 +00:00
|
|
|
|
[Command(2)]
|
2018-10-21 06:01:22 +00:00
|
|
|
|
// SetChargerTypeChangeEventEnabled(u8)
|
2019-07-14 19:04:38 +00:00
|
|
|
|
public ResultCode SetChargerTypeChangeEventEnabled(ServiceCtx context)
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
2018-12-06 11:16:24 +00:00
|
|
|
|
bool chargerTypeChangeEventEnabled = context.RequestData.ReadBoolean();
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2019-01-11 00:11:46 +00:00
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm, new { chargerTypeChangeEventEnabled });
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2019-07-14 19:04:38 +00:00
|
|
|
|
return ResultCode.Success;
|
2018-10-21 06:01:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-12 01:13:43 +00:00
|
|
|
|
[Command(3)]
|
2018-10-21 06:01:22 +00:00
|
|
|
|
// SetPowerSupplyChangeEventEnabled(u8)
|
2019-07-14 19:04:38 +00:00
|
|
|
|
public ResultCode SetPowerSupplyChangeEventEnabled(ServiceCtx context)
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
2018-12-06 11:16:24 +00:00
|
|
|
|
bool powerSupplyChangeEventEnabled = context.RequestData.ReadBoolean();
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2019-01-11 00:11:46 +00:00
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm, new { powerSupplyChangeEventEnabled });
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2019-07-14 19:04:38 +00:00
|
|
|
|
return ResultCode.Success;
|
2018-10-21 06:01:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-12 01:13:43 +00:00
|
|
|
|
[Command(4)]
|
2018-10-21 06:01:22 +00:00
|
|
|
|
// SetBatteryVoltageStateChangeEventEnabled(u8)
|
2019-07-14 19:04:38 +00:00
|
|
|
|
public ResultCode SetBatteryVoltageStateChangeEventEnabled(ServiceCtx context)
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
2018-12-06 11:16:24 +00:00
|
|
|
|
bool batteryVoltageStateChangeEventEnabled = context.RequestData.ReadBoolean();
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2019-01-11 00:11:46 +00:00
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm, new { batteryVoltageStateChangeEventEnabled });
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2019-07-14 19:04:38 +00:00
|
|
|
|
return ResultCode.Success;
|
2018-10-21 06:01:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|