IClkrstManager.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using Ryujinx.HLE.HOS.Ipc;
  2. using Ryujinx.HLE.HOS.Kernel.Common;
  3. using Ryujinx.HLE.HOS.Services.Pcv.Clkrst.ClkrstManager;
  4. using Ryujinx.HLE.HOS.Services.Pcv.Types;
  5. using System;
  6. namespace Ryujinx.HLE.HOS.Services.Pcv.Clkrst
  7. {
  8. [Service("clkrst")] // 8.0.0+
  9. [Service("clkrst:i")] // 8.0.0+
  10. class IClkrstManager : IpcService
  11. {
  12. private int _moduleStateTableEventHandle = 0;
  13. public IClkrstManager(ServiceCtx context) { }
  14. [CommandHipc(0)]
  15. // OpenSession(u32 device_code, u32 unk) -> object<nn::clkrst::IClkrstSession>
  16. public ResultCode OpenSession(ServiceCtx context)
  17. {
  18. DeviceCode deviceCode = (DeviceCode)context.RequestData.ReadUInt32();
  19. uint unknown = context.RequestData.ReadUInt32();
  20. // TODO: Service checks the deviceCode and the unk value.
  21. MakeObject(context, new IClkrstSession(deviceCode, unknown));
  22. return ResultCode.Success;
  23. }
  24. [CommandHipc(4)]
  25. // GetModuleStateTableEvent() -> handle<copy>
  26. public ResultCode GetModuleStateTableEvent(ServiceCtx context)
  27. {
  28. if (_moduleStateTableEventHandle == 0)
  29. {
  30. if (context.Process.HandleTable.GenerateHandle(context.Device.System.IirsSharedMem, out _moduleStateTableEventHandle) != KernelResult.Success)
  31. {
  32. throw new InvalidOperationException("Out of handles!");
  33. }
  34. }
  35. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_moduleStateTableEventHandle);
  36. return ResultCode.Success;
  37. }
  38. [CommandHipc(5)]
  39. // GetModuleStateTableMaxCount() -> u32 max_count
  40. public ResultCode GetModuleStateTableMaxCount(ServiceCtx context)
  41. {
  42. context.ResponseData.Write(26u);
  43. return ResultCode.Success;
  44. }
  45. }
  46. }