IRequest.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Ipc;
  3. using Ryujinx.HLE.HOS.Kernel;
  4. using System;
  5. using System.Collections.Generic;
  6. namespace Ryujinx.HLE.HOS.Services.Nifm
  7. {
  8. class IRequest : IpcService
  9. {
  10. private Dictionary<int, ServiceProcessRequest> _commands;
  11. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
  12. private KEvent _event0;
  13. private KEvent _event1;
  14. public IRequest(Horizon system)
  15. {
  16. _commands = new Dictionary<int, ServiceProcessRequest>
  17. {
  18. { 0, GetRequestState },
  19. { 1, GetResult },
  20. { 2, GetSystemEventReadableHandles },
  21. { 3, Cancel },
  22. { 4, Submit },
  23. { 11, SetConnectionConfirmationOption }
  24. };
  25. _event0 = new KEvent(system);
  26. _event1 = new KEvent(system);
  27. }
  28. public long GetRequestState(ServiceCtx context)
  29. {
  30. context.ResponseData.Write(1);
  31. Logger.PrintStub(LogClass.ServiceNifm, "Stubbed.");
  32. return 0;
  33. }
  34. public long GetResult(ServiceCtx context)
  35. {
  36. Logger.PrintStub(LogClass.ServiceNifm, "Stubbed.");
  37. return 0;
  38. }
  39. public long GetSystemEventReadableHandles(ServiceCtx context)
  40. {
  41. if (context.Process.HandleTable.GenerateHandle(_event0.ReadableEvent, out int handle0) != KernelResult.Success)
  42. {
  43. throw new InvalidOperationException("Out of handles!");
  44. }
  45. if (context.Process.HandleTable.GenerateHandle(_event1.ReadableEvent, out int handle1) != KernelResult.Success)
  46. {
  47. throw new InvalidOperationException("Out of handles!");
  48. }
  49. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle0, handle1);
  50. return 0;
  51. }
  52. public long Cancel(ServiceCtx context)
  53. {
  54. Logger.PrintStub(LogClass.ServiceNifm, "Stubbed.");
  55. return 0;
  56. }
  57. public long Submit(ServiceCtx context)
  58. {
  59. Logger.PrintStub(LogClass.ServiceNifm, "Stubbed.");
  60. return 0;
  61. }
  62. public long SetConnectionConfirmationOption(ServiceCtx context)
  63. {
  64. Logger.PrintStub(LogClass.ServiceNifm, "Stubbed.");
  65. return 0;
  66. }
  67. }
  68. }