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> m_Commands;
  11. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  12. private KEvent Event0;
  13. private KEvent Event1;
  14. public IRequest(Horizon System)
  15. {
  16. m_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. }