IClkrstSession.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Services.Pcv.Types;
  3. using System.Linq;
  4. namespace Ryujinx.HLE.HOS.Services.Pcv.Clkrst.ClkrstManager
  5. {
  6. class IClkrstSession : IpcService
  7. {
  8. private DeviceCode _deviceCode;
  9. private uint _unknown;
  10. private uint _clockRate;
  11. private DeviceCode[] allowedDeviceCodeTable = new DeviceCode[]
  12. {
  13. DeviceCode.Cpu, DeviceCode.Gpu, DeviceCode.Disp1, DeviceCode.Disp2,
  14. DeviceCode.Tsec, DeviceCode.Mselect, DeviceCode.Sor1, DeviceCode.Host1x,
  15. DeviceCode.Vic, DeviceCode.Nvenc, DeviceCode.Nvjpg, DeviceCode.Nvdec,
  16. DeviceCode.Ape, DeviceCode.AudioDsp, DeviceCode.Emc, DeviceCode.Dsi,
  17. DeviceCode.SysBus, DeviceCode.XusbSs, DeviceCode.XusbHost, DeviceCode.XusbDevice,
  18. DeviceCode.Gpuaux, DeviceCode.Pcie, DeviceCode.Apbdma, DeviceCode.Sdmmc1,
  19. DeviceCode.Sdmmc2, DeviceCode.Sdmmc4
  20. };
  21. public IClkrstSession(DeviceCode deviceCode, uint unknown)
  22. {
  23. _deviceCode = deviceCode;
  24. _unknown = unknown;
  25. }
  26. [CommandHipc(7)]
  27. // SetClockRate(u32 hz)
  28. public ResultCode SetClockRate(ServiceCtx context)
  29. {
  30. if (!allowedDeviceCodeTable.Contains(_deviceCode))
  31. {
  32. return ResultCode.InvalidArgument;
  33. }
  34. _clockRate = context.RequestData.ReadUInt32();
  35. Logger.Stub?.PrintStub(LogClass.ServicePcv, new { _clockRate });
  36. return ResultCode.Success;
  37. }
  38. [CommandHipc(8)]
  39. // GetClockRate() -> u32 hz
  40. public ResultCode GetClockRate(ServiceCtx context)
  41. {
  42. if (!allowedDeviceCodeTable.Contains(_deviceCode))
  43. {
  44. return ResultCode.InvalidArgument;
  45. }
  46. context.ResponseData.Write(_clockRate);
  47. Logger.Stub?.PrintStub(LogClass.ServicePcv, new { _clockRate });
  48. return ResultCode.Success;
  49. }
  50. }
  51. }