2018-10-21 02:01:22 -04:00
|
|
|
|
using Ryujinx.Common.Logging;
|
|
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
2018-12-18 00:33:36 -05:00
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
2023-01-04 17:15:45 -05:00
|
|
|
|
using Ryujinx.Horizon.Common;
|
2018-10-21 02:01:22 -04:00
|
|
|
|
|
2019-09-18 20:45:11 -04:00
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Ptm.Psm
|
2018-10-21 02:01:22 -04:00
|
|
|
|
{
|
|
|
|
|
class IPsmSession : IpcService
|
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
private KEvent _stateChangeEvent;
|
|
|
|
|
private int _stateChangeEventHandle;
|
2018-10-21 02:01:22 -04:00
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
|
public IPsmSession(Horizon system)
|
2018-10-21 02:01:22 -04:00
|
|
|
|
{
|
2020-05-03 23:41:29 -04:00
|
|
|
|
_stateChangeEvent = new KEvent(system.KernelContext);
|
2018-12-06 06:16:24 -05:00
|
|
|
|
_stateChangeEventHandle = -1;
|
2018-10-21 02:01:22 -04:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 19:00:34 -04:00
|
|
|
|
[CommandCmif(0)]
|
2018-10-21 02:01:22 -04:00
|
|
|
|
// BindStateChangeEvent() -> KObject
|
2019-07-14 15:04:38 -04:00
|
|
|
|
public ResultCode BindStateChangeEvent(ServiceCtx context)
|
2018-10-21 02:01:22 -04:00
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
if (_stateChangeEventHandle == -1)
|
2018-10-21 02:01:22 -04:00
|
|
|
|
{
|
2023-01-04 17:15:45 -05:00
|
|
|
|
Result resultCode = context.Process.HandleTable.GenerateHandle(_stateChangeEvent.ReadableEvent, out _stateChangeEventHandle);
|
2018-10-21 02:01:22 -04:00
|
|
|
|
|
2023-01-04 17:15:45 -05:00
|
|
|
|
if (resultCode != Result.Success)
|
2018-10-21 02:01:22 -04:00
|
|
|
|
{
|
2023-01-04 17:15:45 -05:00
|
|
|
|
return (ResultCode)resultCode.ErrorCode;
|
2018-10-21 02:01:22 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_stateChangeEventHandle);
|
2018-10-21 02:01:22 -04:00
|
|
|
|
|
2020-08-03 19:32:53 -04:00
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServicePsm);
|
2018-10-21 02:01:22 -04:00
|
|
|
|
|
2019-07-14 15:04:38 -04:00
|
|
|
|
return ResultCode.Success;
|
2018-10-21 02:01:22 -04:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 19:00:34 -04:00
|
|
|
|
[CommandCmif(1)]
|
2018-10-21 02:01:22 -04:00
|
|
|
|
// UnbindStateChangeEvent()
|
2019-07-14 15:04:38 -04:00
|
|
|
|
public ResultCode UnbindStateChangeEvent(ServiceCtx context)
|
2018-10-21 02:01:22 -04:00
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
if (_stateChangeEventHandle != -1)
|
2018-10-21 02:01:22 -04:00
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
context.Process.HandleTable.CloseHandle(_stateChangeEventHandle);
|
|
|
|
|
_stateChangeEventHandle = -1;
|
2018-10-21 02:01:22 -04:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-03 19:32:53 -04:00
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServicePsm);
|
2018-10-21 02:01:22 -04:00
|
|
|
|
|
2019-07-14 15:04:38 -04:00
|
|
|
|
return ResultCode.Success;
|
2018-10-21 02:01:22 -04:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 19:00:34 -04:00
|
|
|
|
[CommandCmif(2)]
|
2018-10-21 02:01:22 -04:00
|
|
|
|
// SetChargerTypeChangeEventEnabled(u8)
|
2019-07-14 15:04:38 -04:00
|
|
|
|
public ResultCode SetChargerTypeChangeEventEnabled(ServiceCtx context)
|
2018-10-21 02:01:22 -04:00
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
bool chargerTypeChangeEventEnabled = context.RequestData.ReadBoolean();
|
2018-10-21 02:01:22 -04:00
|
|
|
|
|
2020-08-03 19:32:53 -04:00
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServicePsm, new { chargerTypeChangeEventEnabled });
|
2018-10-21 02:01:22 -04:00
|
|
|
|
|
2019-07-14 15:04:38 -04:00
|
|
|
|
return ResultCode.Success;
|
2018-10-21 02:01:22 -04:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 19:00:34 -04:00
|
|
|
|
[CommandCmif(3)]
|
2018-10-21 02:01:22 -04:00
|
|
|
|
// SetPowerSupplyChangeEventEnabled(u8)
|
2019-07-14 15:04:38 -04:00
|
|
|
|
public ResultCode SetPowerSupplyChangeEventEnabled(ServiceCtx context)
|
2018-10-21 02:01:22 -04:00
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
bool powerSupplyChangeEventEnabled = context.RequestData.ReadBoolean();
|
2018-10-21 02:01:22 -04:00
|
|
|
|
|
2020-08-03 19:32:53 -04:00
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServicePsm, new { powerSupplyChangeEventEnabled });
|
2018-10-21 02:01:22 -04:00
|
|
|
|
|
2019-07-14 15:04:38 -04:00
|
|
|
|
return ResultCode.Success;
|
2018-10-21 02:01:22 -04:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 19:00:34 -04:00
|
|
|
|
[CommandCmif(4)]
|
2018-10-21 02:01:22 -04:00
|
|
|
|
// SetBatteryVoltageStateChangeEventEnabled(u8)
|
2019-07-14 15:04:38 -04:00
|
|
|
|
public ResultCode SetBatteryVoltageStateChangeEventEnabled(ServiceCtx context)
|
2018-10-21 02:01:22 -04:00
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
bool batteryVoltageStateChangeEventEnabled = context.RequestData.ReadBoolean();
|
2018-10-21 02:01:22 -04:00
|
|
|
|
|
2020-08-03 19:32:53 -04:00
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServicePsm, new { batteryVoltageStateChangeEventEnabled });
|
2018-10-21 02:01:22 -04:00
|
|
|
|
|
2019-07-14 15:04:38 -04:00
|
|
|
|
return ResultCode.Success;
|
2018-10-21 02:01:22 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|