2018-10-21 07:01:22 +01:00
|
|
|
|
using Ryujinx.Common.Logging;
|
|
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
|
|
|
|
using Ryujinx.HLE.HOS.Kernel;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Psm
|
|
|
|
|
{
|
|
|
|
|
class IPsmSession : IpcService
|
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
2018-10-21 07:01:22 +01:00
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
2018-10-21 07:01:22 +01:00
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
private KEvent StateChangeEvent;
|
|
|
|
|
private int StateChangeEventHandle;
|
2018-10-21 07:01:22 +01:00
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public IPsmSession(Horizon System)
|
2018-10-21 07:01:22 +01:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
2018-10-21 07:01:22 +01:00
|
|
|
|
{
|
|
|
|
|
{ 0, BindStateChangeEvent },
|
|
|
|
|
{ 1, UnbindStateChangeEvent },
|
|
|
|
|
{ 2, SetChargerTypeChangeEventEnabled },
|
|
|
|
|
{ 3, SetPowerSupplyChangeEventEnabled },
|
|
|
|
|
{ 4, SetBatteryVoltageStateChangeEventEnabled }
|
|
|
|
|
};
|
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
StateChangeEvent = new KEvent(System);
|
|
|
|
|
StateChangeEventHandle = -1;
|
2018-10-21 07:01:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BindStateChangeEvent() -> KObject
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public long BindStateChangeEvent(ServiceCtx Context)
|
2018-10-21 07:01:22 +01:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
if (StateChangeEventHandle == -1)
|
2018-10-21 07:01:22 +01:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
KernelResult ResultCode = Context.Process.HandleTable.GenerateHandle(StateChangeEvent, out int StateChangeEventHandle);
|
2018-10-21 07:01:22 +01:00
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
if (ResultCode != KernelResult.Success)
|
2018-10-21 07:01:22 +01:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
return (long)ResultCode;
|
2018-10-21 07:01:22 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(StateChangeEventHandle);
|
2018-10-21 07:01:22 +01:00
|
|
|
|
|
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm, "Stubbed.");
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UnbindStateChangeEvent()
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public long UnbindStateChangeEvent(ServiceCtx Context)
|
2018-10-21 07:01:22 +01:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
if (StateChangeEventHandle != -1)
|
2018-10-21 07:01:22 +01:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
Context.Process.HandleTable.CloseHandle(StateChangeEventHandle);
|
|
|
|
|
StateChangeEventHandle = -1;
|
2018-10-21 07:01:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm, "Stubbed.");
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetChargerTypeChangeEventEnabled(u8)
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public long SetChargerTypeChangeEventEnabled(ServiceCtx Context)
|
2018-10-21 07:01:22 +01:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
bool ChargerTypeChangeEventEnabled = Context.RequestData.ReadBoolean();
|
2018-10-21 07:01:22 +01:00
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargerTypeChangeEventEnabled: {ChargerTypeChangeEventEnabled}");
|
2018-10-21 07:01:22 +01:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetPowerSupplyChangeEventEnabled(u8)
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public long SetPowerSupplyChangeEventEnabled(ServiceCtx Context)
|
2018-10-21 07:01:22 +01:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
bool PowerSupplyChangeEventEnabled = Context.RequestData.ReadBoolean();
|
2018-10-21 07:01:22 +01:00
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. PowerSupplyChangeEventEnabled: {PowerSupplyChangeEventEnabled}");
|
2018-10-21 07:01:22 +01:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetBatteryVoltageStateChangeEventEnabled(u8)
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public long SetBatteryVoltageStateChangeEventEnabled(ServiceCtx Context)
|
2018-10-21 07:01:22 +01:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
bool BatteryVoltageStateChangeEventEnabled = Context.RequestData.ReadBoolean();
|
2018-10-21 07:01:22 +01:00
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. BatteryVoltageStateChangeEventEnabled: {BatteryVoltageStateChangeEventEnabled}");
|
2018-10-21 07:01:22 +01:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|