IApplicationFunctions.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using Ryujinx.HLE.Logging;
  2. using Ryujinx.HLE.OsHle.Ipc;
  3. using System.Collections.Generic;
  4. namespace Ryujinx.HLE.OsHle.Services.Am
  5. {
  6. class IApplicationFunctions : IpcService
  7. {
  8. private Dictionary<int, ServiceProcessRequest> m_Commands;
  9. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  10. public IApplicationFunctions()
  11. {
  12. m_Commands = new Dictionary<int, ServiceProcessRequest>()
  13. {
  14. { 1, PopLaunchParameter },
  15. { 20, EnsureSaveData },
  16. { 21, GetDesiredLanguage },
  17. { 22, SetTerminateResult },
  18. { 23, GetDisplayVersion },
  19. { 40, NotifyRunning },
  20. { 50, GetPseudoDeviceId },
  21. { 66, InitializeGamePlayRecording },
  22. { 67, SetGamePlayRecordingState }
  23. };
  24. }
  25. public long PopLaunchParameter(ServiceCtx Context)
  26. {
  27. //Only the first 0x18 bytes of the Data seems to be actually used.
  28. MakeObject(Context, new IStorage(StorageHelper.MakeLaunchParams()));
  29. return 0;
  30. }
  31. public long EnsureSaveData(ServiceCtx Context)
  32. {
  33. long UIdLow = Context.RequestData.ReadInt64();
  34. long UIdHigh = Context.RequestData.ReadInt64();
  35. Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  36. Context.ResponseData.Write(0L);
  37. return 0;
  38. }
  39. public long GetDesiredLanguage(ServiceCtx Context)
  40. {
  41. Context.ResponseData.Write(Context.Ns.Os.SystemState.DesiredLanguageCode);
  42. return 0;
  43. }
  44. public long SetTerminateResult(ServiceCtx Context)
  45. {
  46. int ErrorCode = Context.RequestData.ReadInt32();
  47. string Result = GetFormattedErrorCode(ErrorCode);
  48. Context.Ns.Log.PrintInfo(LogClass.ServiceAm, $"Result = 0x{ErrorCode:x8} ({Result}).");
  49. return 0;
  50. }
  51. private string GetFormattedErrorCode(int ErrorCode)
  52. {
  53. int Module = (ErrorCode >> 0) & 0x1ff;
  54. int Description = (ErrorCode >> 9) & 0x1fff;
  55. return $"{(2000 + Module):d4}-{Description:d4}";
  56. }
  57. public long GetDisplayVersion(ServiceCtx Context)
  58. {
  59. //FIXME: Need to check correct version on a switch.
  60. Context.ResponseData.Write(1L);
  61. Context.ResponseData.Write(0L);
  62. return 0;
  63. }
  64. public long NotifyRunning(ServiceCtx Context)
  65. {
  66. Context.ResponseData.Write(1);
  67. return 0;
  68. }
  69. public long GetPseudoDeviceId(ServiceCtx Context)
  70. {
  71. Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  72. Context.ResponseData.Write(0L);
  73. Context.ResponseData.Write(0L);
  74. return 0;
  75. }
  76. public long InitializeGamePlayRecording(ServiceCtx Context)
  77. {
  78. Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  79. return 0;
  80. }
  81. public long SetGamePlayRecordingState(ServiceCtx Context)
  82. {
  83. int State = Context.RequestData.ReadInt32();
  84. Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  85. return 0;
  86. }
  87. }
  88. }