diff options
| author | TSR Berry <20988865+TSRBerry@users.noreply.github.com> | 2023-04-08 01:22:00 +0200 |
|---|---|---|
| committer | Mary <thog@protonmail.com> | 2023-04-27 23:51:14 +0200 |
| commit | cee712105850ac3385cd0091a923438167433f9f (patch) | |
| tree | 4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /src/Ryujinx.HLE/HOS/Services/Ptm | |
| parent | cd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff) | |
Move solution and projects to src
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Services/Ptm')
10 files changed, 231 insertions, 0 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Fan/IManager.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Fan/IManager.cs new file mode 100644 index 00000000..e2fe2235 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Fan/IManager.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Ptm.Fan +{ + [Service("fan")] + class IManager : IpcService + { + public IManager(ServiceCtx context) { } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/IDebugger.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/IDebugger.cs new file mode 100644 index 00000000..a93f5283 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/IDebugger.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Ptm.Fgm +{ + [Service("fgm:dbg")] // 9.0.0+ + class IDebugger : IpcService + { + public IDebugger(ServiceCtx context) { } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/ISession.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/ISession.cs new file mode 100644 index 00000000..0e3f965b --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/ISession.cs @@ -0,0 +1,10 @@ +namespace Ryujinx.HLE.HOS.Services.Ptm.Fgm +{ + [Service("fgm")] // 9.0.0+ + [Service("fgm:0")] // 9.0.0+ + [Service("fgm:9")] // 9.0.0+ + class ISession : IpcService + { + public ISession(ServiceCtx context) { } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Pcm/IManager.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Pcm/IManager.cs new file mode 100644 index 00000000..0bec45fa --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Pcm/IManager.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Ptm.Pcm +{ + [Service("pcm")] + class IManager : IpcService + { + public IManager(ServiceCtx context) { } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmServer.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmServer.cs new file mode 100644 index 00000000..4e3d3e8e --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmServer.cs @@ -0,0 +1,45 @@ +using Ryujinx.Common.Logging; + +namespace Ryujinx.HLE.HOS.Services.Ptm.Psm +{ + [Service("psm")] + class IPsmServer : IpcService + { + public IPsmServer(ServiceCtx context) { } + + [CommandCmif(0)] + // GetBatteryChargePercentage() -> u32 + public static ResultCode GetBatteryChargePercentage(ServiceCtx context) + { + int chargePercentage = 100; + + context.ResponseData.Write(chargePercentage); + + Logger.Stub?.PrintStub(LogClass.ServicePsm, new { chargePercentage }); + + return ResultCode.Success; + } + + [CommandCmif(1)] + // GetChargerType() -> u32 + public static ResultCode GetChargerType(ServiceCtx context) + { + ChargerType chargerType = ChargerType.ChargerOrDock; + + context.ResponseData.Write((int)chargerType); + + Logger.Stub?.PrintStub(LogClass.ServicePsm, new { chargerType }); + + return ResultCode.Success; + } + + [CommandCmif(7)] + // OpenSession() -> IPsmSession + public ResultCode OpenSession(ServiceCtx context) + { + MakeObject(context, new IPsmSession(context.Device.System)); + + return ResultCode.Success; + } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmSession.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmSession.cs new file mode 100644 index 00000000..5d11f227 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmSession.cs @@ -0,0 +1,88 @@ +using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Ipc; +using Ryujinx.HLE.HOS.Kernel.Threading; +using Ryujinx.Horizon.Common; + +namespace Ryujinx.HLE.HOS.Services.Ptm.Psm +{ + class IPsmSession : IpcService + { + private KEvent _stateChangeEvent; + private int _stateChangeEventHandle; + + public IPsmSession(Horizon system) + { + _stateChangeEvent = new KEvent(system.KernelContext); + _stateChangeEventHandle = -1; + } + + [CommandCmif(0)] + // BindStateChangeEvent() -> KObject + public ResultCode BindStateChangeEvent(ServiceCtx context) + { + if (_stateChangeEventHandle == -1) + { + Result resultCode = context.Process.HandleTable.GenerateHandle(_stateChangeEvent.ReadableEvent, out _stateChangeEventHandle); + + if (resultCode != Result.Success) + { + return (ResultCode)resultCode.ErrorCode; + } + } + + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_stateChangeEventHandle); + + Logger.Stub?.PrintStub(LogClass.ServicePsm); + + return ResultCode.Success; + } + + [CommandCmif(1)] + // UnbindStateChangeEvent() + public ResultCode UnbindStateChangeEvent(ServiceCtx context) + { + if (_stateChangeEventHandle != -1) + { + context.Process.HandleTable.CloseHandle(_stateChangeEventHandle); + _stateChangeEventHandle = -1; + } + + Logger.Stub?.PrintStub(LogClass.ServicePsm); + + return ResultCode.Success; + } + + [CommandCmif(2)] + // SetChargerTypeChangeEventEnabled(u8) + public ResultCode SetChargerTypeChangeEventEnabled(ServiceCtx context) + { + bool chargerTypeChangeEventEnabled = context.RequestData.ReadBoolean(); + + Logger.Stub?.PrintStub(LogClass.ServicePsm, new { chargerTypeChangeEventEnabled }); + + return ResultCode.Success; + } + + [CommandCmif(3)] + // SetPowerSupplyChangeEventEnabled(u8) + public ResultCode SetPowerSupplyChangeEventEnabled(ServiceCtx context) + { + bool powerSupplyChangeEventEnabled = context.RequestData.ReadBoolean(); + + Logger.Stub?.PrintStub(LogClass.ServicePsm, new { powerSupplyChangeEventEnabled }); + + return ResultCode.Success; + } + + [CommandCmif(4)] + // SetBatteryVoltageStateChangeEventEnabled(u8) + public ResultCode SetBatteryVoltageStateChangeEventEnabled(ServiceCtx context) + { + bool batteryVoltageStateChangeEventEnabled = context.RequestData.ReadBoolean(); + + Logger.Stub?.PrintStub(LogClass.ServicePsm, new { batteryVoltageStateChangeEventEnabled }); + + return ResultCode.Success; + } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/Types/ChargerType.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/Types/ChargerType.cs new file mode 100644 index 00000000..3e239711 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/Types/ChargerType.cs @@ -0,0 +1,9 @@ +namespace Ryujinx.HLE.HOS.Services.Ptm.Psm +{ + enum ChargerType + { + None, + ChargerOrDock, + UsbC + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Tc/IManager.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Tc/IManager.cs new file mode 100644 index 00000000..1daa4f5e --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Tc/IManager.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Ptm.Tc +{ + [Service("tc")] + class IManager : IpcService + { + public IManager(ServiceCtx context) { } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/IMeasurementServer.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/IMeasurementServer.cs new file mode 100644 index 00000000..6ddc0aef --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/IMeasurementServer.cs @@ -0,0 +1,39 @@ +using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Services.Ptm.Ts.Types; + +namespace Ryujinx.HLE.HOS.Services.Ptm.Ts +{ + [Service("ts")] + class IMeasurementServer : IpcService + { + private const uint DefaultTemperature = 42u; + + public IMeasurementServer(ServiceCtx context) { } + + [CommandCmif(1)] + // GetTemperature(Location location) -> u32 + public ResultCode GetTemperature(ServiceCtx context) + { + Location location = (Location)context.RequestData.ReadByte(); + + Logger.Stub?.PrintStub(LogClass.ServicePtm, new { location }); + + context.ResponseData.Write(DefaultTemperature); + + return ResultCode.Success; + } + + [CommandCmif(3)] + // GetTemperatureMilliC(Location location) -> u32 + public ResultCode GetTemperatureMilliC(ServiceCtx context) + { + Location location = (Location)context.RequestData.ReadByte(); + + Logger.Stub?.PrintStub(LogClass.ServicePtm, new { location }); + + context.ResponseData.Write(DefaultTemperature * 1000); + + return ResultCode.Success; + } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/Types/Location.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/Types/Location.cs new file mode 100644 index 00000000..e72491d5 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/Types/Location.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Ptm.Ts.Types +{ + enum Location : byte + { + Internal, + External + } +} |
