IRequest.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. using System.Collections.Generic;
  7. namespace Ryujinx.HLE.HOS.Services.Nifm
  8. {
  9. class IRequest : IpcService
  10. {
  11. private Dictionary<int, ServiceProcessRequest> _commands;
  12. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
  13. private KEvent _event0;
  14. private KEvent _event1;
  15. public IRequest(Horizon system)
  16. {
  17. _commands = new Dictionary<int, ServiceProcessRequest>
  18. {
  19. { 0, GetRequestState },
  20. { 1, GetResult },
  21. { 2, GetSystemEventReadableHandles },
  22. { 3, Cancel },
  23. { 4, Submit },
  24. { 11, SetConnectionConfirmationOption }
  25. };
  26. _event0 = new KEvent(system);
  27. _event1 = new KEvent(system);
  28. }
  29. public long GetRequestState(ServiceCtx context)
  30. {
  31. context.ResponseData.Write(1);
  32. Logger.PrintStub(LogClass.ServiceNifm);
  33. return 0;
  34. }
  35. public long GetResult(ServiceCtx context)
  36. {
  37. Logger.PrintStub(LogClass.ServiceNifm);
  38. return 0;
  39. }
  40. public long 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 0;
  52. }
  53. public long Cancel(ServiceCtx context)
  54. {
  55. Logger.PrintStub(LogClass.ServiceNifm);
  56. return 0;
  57. }
  58. public long Submit(ServiceCtx context)
  59. {
  60. Logger.PrintStub(LogClass.ServiceNifm);
  61. return 0;
  62. }
  63. public long SetConnectionConfirmationOption(ServiceCtx context)
  64. {
  65. Logger.PrintStub(LogClass.ServiceNifm);
  66. return 0;
  67. }
  68. }
  69. }