1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
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
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
private KEvent StateChangeEvent;
private int StateChangeEventHandle;
public IPsmSession(Horizon System)
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, BindStateChangeEvent },
{ 1, UnbindStateChangeEvent },
{ 2, SetChargerTypeChangeEventEnabled },
{ 3, SetPowerSupplyChangeEventEnabled },
{ 4, SetBatteryVoltageStateChangeEventEnabled }
};
StateChangeEvent = new KEvent(System);
StateChangeEventHandle = -1;
}
// BindStateChangeEvent() -> KObject
public long BindStateChangeEvent(ServiceCtx Context)
{
if (StateChangeEventHandle == -1)
{
KernelResult ResultCode = Context.Process.HandleTable.GenerateHandle(StateChangeEvent, out int StateChangeEventHandle);
if (ResultCode != KernelResult.Success)
{
return (long)ResultCode;
}
}
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(StateChangeEventHandle);
Logger.PrintStub(LogClass.ServicePsm, "Stubbed.");
return 0;
}
// UnbindStateChangeEvent()
public long UnbindStateChangeEvent(ServiceCtx Context)
{
if (StateChangeEventHandle != -1)
{
Context.Process.HandleTable.CloseHandle(StateChangeEventHandle);
StateChangeEventHandle = -1;
}
Logger.PrintStub(LogClass.ServicePsm, "Stubbed.");
return 0;
}
// SetChargerTypeChangeEventEnabled(u8)
public long SetChargerTypeChangeEventEnabled(ServiceCtx Context)
{
bool ChargerTypeChangeEventEnabled = Context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargerTypeChangeEventEnabled: {ChargerTypeChangeEventEnabled}");
return 0;
}
// SetPowerSupplyChangeEventEnabled(u8)
public long SetPowerSupplyChangeEventEnabled(ServiceCtx Context)
{
bool PowerSupplyChangeEventEnabled = Context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. PowerSupplyChangeEventEnabled: {PowerSupplyChangeEventEnabled}");
return 0;
}
// SetBatteryVoltageStateChangeEventEnabled(u8)
public long SetBatteryVoltageStateChangeEventEnabled(ServiceCtx Context)
{
bool BatteryVoltageStateChangeEventEnabled = Context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. BatteryVoltageStateChangeEventEnabled: {BatteryVoltageStateChangeEventEnabled}");
return 0;
}
}
}
|