IRequest.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Ipc;
  3. using Ryujinx.HLE.HOS.Kernel.Common;
  4. using Ryujinx.HLE.HOS.Kernel.Threading;
  5. using System;
  6. namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
  7. {
  8. class IRequest : IpcService
  9. {
  10. private KEvent _event0;
  11. private KEvent _event1;
  12. private uint _version;
  13. public IRequest(Horizon system, uint version)
  14. {
  15. _event0 = new KEvent(system.KernelContext);
  16. _event1 = new KEvent(system.KernelContext);
  17. _version = version;
  18. }
  19. [Command(0)]
  20. // GetRequestState() -> u32
  21. public ResultCode GetRequestState(ServiceCtx context)
  22. {
  23. context.ResponseData.Write(1);
  24. Logger.Stub?.PrintStub(LogClass.ServiceNifm);
  25. return ResultCode.Success;
  26. }
  27. [Command(1)]
  28. // GetResult()
  29. public ResultCode GetResult(ServiceCtx context)
  30. {
  31. Logger.Stub?.PrintStub(LogClass.ServiceNifm);
  32. return GetResultImpl();
  33. }
  34. private ResultCode GetResultImpl()
  35. {
  36. return ResultCode.Success;
  37. }
  38. [Command(2)]
  39. // GetSystemEventReadableHandles() -> (handle<copy>, handle<copy>)
  40. public ResultCode GetSystemEventReadableHandles(ServiceCtx context)
  41. {
  42. if (context.Process.HandleTable.GenerateHandle(_event0.ReadableEvent, out int handle0) != KernelResult.Success)
  43. {
  44. throw new InvalidOperationException("Out of handles!");
  45. }
  46. if (context.Process.HandleTable.GenerateHandle(_event1.ReadableEvent, out int handle1) != KernelResult.Success)
  47. {
  48. throw new InvalidOperationException("Out of handles!");
  49. }
  50. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle0, handle1);
  51. return ResultCode.Success;
  52. }
  53. [Command(3)]
  54. // Cancel()
  55. public ResultCode Cancel(ServiceCtx context)
  56. {
  57. Logger.Stub?.PrintStub(LogClass.ServiceNifm);
  58. return ResultCode.Success;
  59. }
  60. [Command(4)]
  61. // Submit()
  62. public ResultCode Submit(ServiceCtx context)
  63. {
  64. Logger.Stub?.PrintStub(LogClass.ServiceNifm);
  65. return ResultCode.Success;
  66. }
  67. [Command(11)]
  68. // SetConnectionConfirmationOption(i8)
  69. public ResultCode SetConnectionConfirmationOption(ServiceCtx context)
  70. {
  71. Logger.Stub?.PrintStub(LogClass.ServiceNifm);
  72. return ResultCode.Success;
  73. }
  74. [Command(21)]
  75. // GetAppletInfo(u32) -> (u32, u32, u32, buffer<bytes, 6>)
  76. public ResultCode GetAppletInfo(ServiceCtx context)
  77. {
  78. uint themeColor = context.RequestData.ReadUInt32();
  79. Logger.Stub?.PrintStub(LogClass.ServiceNifm);
  80. ResultCode result = GetResultImpl();
  81. if (result == ResultCode.Success || (ResultCode)((int)result & 0x3fffff) == ResultCode.Unknown112)
  82. {
  83. return ResultCode.Unknown180;
  84. }
  85. // Returns appletId, libraryAppletMode, outSize and a buffer.
  86. // Returned applet ids- (0x19, 0xf, 0xe)
  87. // libraryAppletMode seems to be 0 for all applets supported.
  88. // TODO: check order
  89. context.ResponseData.Write(0xe); // Use error applet as default for now
  90. context.ResponseData.Write(0); // libraryAppletMode
  91. context.ResponseData.Write(0); // outSize
  92. return ResultCode.Success;
  93. }
  94. }
  95. }