applet_ae.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "common/logging/log.h"
  4. #include "core/core.h"
  5. #include "core/hle/service/am/am.h"
  6. #include "core/hle/service/am/applet_ae.h"
  7. #include "core/hle/service/ipc_helpers.h"
  8. #include "core/hle/service/nvnflinger/nvnflinger.h"
  9. namespace Service::AM {
  10. class ILibraryAppletProxy final : public ServiceFramework<ILibraryAppletProxy> {
  11. public:
  12. explicit ILibraryAppletProxy(Nvnflinger::Nvnflinger& nvnflinger_,
  13. std::shared_ptr<AppletMessageQueue> msg_queue_,
  14. Core::System& system_)
  15. : ServiceFramework{system_, "ILibraryAppletProxy"},
  16. nvnflinger{nvnflinger_}, msg_queue{std::move(msg_queue_)} {
  17. // clang-format off
  18. static const FunctionInfo functions[] = {
  19. {0, &ILibraryAppletProxy::GetCommonStateGetter, "GetCommonStateGetter"},
  20. {1, &ILibraryAppletProxy::GetSelfController, "GetSelfController"},
  21. {2, &ILibraryAppletProxy::GetWindowController, "GetWindowController"},
  22. {3, &ILibraryAppletProxy::GetAudioController, "GetAudioController"},
  23. {4, &ILibraryAppletProxy::GetDisplayController, "GetDisplayController"},
  24. {10, &ILibraryAppletProxy::GetProcessWindingController, "GetProcessWindingController"},
  25. {11, &ILibraryAppletProxy::GetLibraryAppletCreator, "GetLibraryAppletCreator"},
  26. {20, &ILibraryAppletProxy::OpenLibraryAppletSelfAccessor, "OpenLibraryAppletSelfAccessor"},
  27. {21, &ILibraryAppletProxy::GetAppletCommonFunctions, "GetAppletCommonFunctions"},
  28. {22, &ILibraryAppletProxy::GetHomeMenuFunctions, "GetHomeMenuFunctions"},
  29. {23, &ILibraryAppletProxy::GetGlobalStateController, "GetGlobalStateController"},
  30. {1000, &ILibraryAppletProxy::GetDebugFunctions, "GetDebugFunctions"},
  31. };
  32. // clang-format on
  33. RegisterHandlers(functions);
  34. }
  35. private:
  36. void GetCommonStateGetter(HLERequestContext& ctx) {
  37. LOG_DEBUG(Service_AM, "called");
  38. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  39. rb.Push(ResultSuccess);
  40. rb.PushIpcInterface<ICommonStateGetter>(system, msg_queue);
  41. }
  42. void GetSelfController(HLERequestContext& ctx) {
  43. LOG_DEBUG(Service_AM, "called");
  44. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  45. rb.Push(ResultSuccess);
  46. rb.PushIpcInterface<ISelfController>(system, nvnflinger);
  47. }
  48. void GetWindowController(HLERequestContext& ctx) {
  49. LOG_DEBUG(Service_AM, "called");
  50. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  51. rb.Push(ResultSuccess);
  52. rb.PushIpcInterface<IWindowController>(system);
  53. }
  54. void GetAudioController(HLERequestContext& ctx) {
  55. LOG_DEBUG(Service_AM, "called");
  56. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  57. rb.Push(ResultSuccess);
  58. rb.PushIpcInterface<IAudioController>(system);
  59. }
  60. void GetDisplayController(HLERequestContext& ctx) {
  61. LOG_DEBUG(Service_AM, "called");
  62. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  63. rb.Push(ResultSuccess);
  64. rb.PushIpcInterface<IDisplayController>(system);
  65. }
  66. void GetProcessWindingController(HLERequestContext& ctx) {
  67. LOG_DEBUG(Service_AM, "called");
  68. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  69. rb.Push(ResultSuccess);
  70. rb.PushIpcInterface<IProcessWindingController>(system);
  71. }
  72. void GetLibraryAppletCreator(HLERequestContext& ctx) {
  73. LOG_DEBUG(Service_AM, "called");
  74. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  75. rb.Push(ResultSuccess);
  76. rb.PushIpcInterface<ILibraryAppletCreator>(system);
  77. }
  78. void OpenLibraryAppletSelfAccessor(HLERequestContext& ctx) {
  79. LOG_DEBUG(Service_AM, "called");
  80. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  81. rb.Push(ResultSuccess);
  82. rb.PushIpcInterface<ILibraryAppletSelfAccessor>(system);
  83. }
  84. void GetAppletCommonFunctions(HLERequestContext& ctx) {
  85. LOG_DEBUG(Service_AM, "called");
  86. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  87. rb.Push(ResultSuccess);
  88. rb.PushIpcInterface<IAppletCommonFunctions>(system);
  89. }
  90. void GetHomeMenuFunctions(HLERequestContext& ctx) {
  91. LOG_DEBUG(Service_AM, "called");
  92. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  93. rb.Push(ResultSuccess);
  94. rb.PushIpcInterface<IHomeMenuFunctions>(system);
  95. }
  96. void GetGlobalStateController(HLERequestContext& ctx) {
  97. LOG_DEBUG(Service_AM, "called");
  98. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  99. rb.Push(ResultSuccess);
  100. rb.PushIpcInterface<IGlobalStateController>(system);
  101. }
  102. void GetDebugFunctions(HLERequestContext& ctx) {
  103. LOG_DEBUG(Service_AM, "called");
  104. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  105. rb.Push(ResultSuccess);
  106. rb.PushIpcInterface<IDebugFunctions>(system);
  107. }
  108. Nvnflinger::Nvnflinger& nvnflinger;
  109. std::shared_ptr<AppletMessageQueue> msg_queue;
  110. };
  111. class ISystemAppletProxy final : public ServiceFramework<ISystemAppletProxy> {
  112. public:
  113. explicit ISystemAppletProxy(Nvnflinger::Nvnflinger& nvnflinger_,
  114. std::shared_ptr<AppletMessageQueue> msg_queue_,
  115. Core::System& system_)
  116. : ServiceFramework{system_, "ISystemAppletProxy"},
  117. nvnflinger{nvnflinger_}, msg_queue{std::move(msg_queue_)} {
  118. // clang-format off
  119. static const FunctionInfo functions[] = {
  120. {0, &ISystemAppletProxy::GetCommonStateGetter, "GetCommonStateGetter"},
  121. {1, &ISystemAppletProxy::GetSelfController, "GetSelfController"},
  122. {2, &ISystemAppletProxy::GetWindowController, "GetWindowController"},
  123. {3, &ISystemAppletProxy::GetAudioController, "GetAudioController"},
  124. {4, &ISystemAppletProxy::GetDisplayController, "GetDisplayController"},
  125. {10, nullptr, "GetProcessWindingController"},
  126. {11, &ISystemAppletProxy::GetLibraryAppletCreator, "GetLibraryAppletCreator"},
  127. {20, &ISystemAppletProxy::GetHomeMenuFunctions, "GetHomeMenuFunctions"},
  128. {21, &ISystemAppletProxy::GetGlobalStateController, "GetGlobalStateController"},
  129. {22, &ISystemAppletProxy::GetApplicationCreator, "GetApplicationCreator"},
  130. {23, &ISystemAppletProxy::GetAppletCommonFunctions, "GetAppletCommonFunctions"},
  131. {1000, &ISystemAppletProxy::GetDebugFunctions, "GetDebugFunctions"},
  132. };
  133. // clang-format on
  134. RegisterHandlers(functions);
  135. }
  136. private:
  137. void GetCommonStateGetter(HLERequestContext& ctx) {
  138. LOG_DEBUG(Service_AM, "called");
  139. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  140. rb.Push(ResultSuccess);
  141. rb.PushIpcInterface<ICommonStateGetter>(system, msg_queue);
  142. }
  143. void GetSelfController(HLERequestContext& ctx) {
  144. LOG_DEBUG(Service_AM, "called");
  145. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  146. rb.Push(ResultSuccess);
  147. rb.PushIpcInterface<ISelfController>(system, nvnflinger);
  148. }
  149. void GetWindowController(HLERequestContext& ctx) {
  150. LOG_DEBUG(Service_AM, "called");
  151. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  152. rb.Push(ResultSuccess);
  153. rb.PushIpcInterface<IWindowController>(system);
  154. }
  155. void GetAudioController(HLERequestContext& ctx) {
  156. LOG_DEBUG(Service_AM, "called");
  157. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  158. rb.Push(ResultSuccess);
  159. rb.PushIpcInterface<IAudioController>(system);
  160. }
  161. void GetDisplayController(HLERequestContext& ctx) {
  162. LOG_DEBUG(Service_AM, "called");
  163. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  164. rb.Push(ResultSuccess);
  165. rb.PushIpcInterface<IDisplayController>(system);
  166. }
  167. void GetLibraryAppletCreator(HLERequestContext& ctx) {
  168. LOG_DEBUG(Service_AM, "called");
  169. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  170. rb.Push(ResultSuccess);
  171. rb.PushIpcInterface<ILibraryAppletCreator>(system);
  172. }
  173. void GetHomeMenuFunctions(HLERequestContext& ctx) {
  174. LOG_DEBUG(Service_AM, "called");
  175. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  176. rb.Push(ResultSuccess);
  177. rb.PushIpcInterface<IHomeMenuFunctions>(system);
  178. }
  179. void GetGlobalStateController(HLERequestContext& ctx) {
  180. LOG_DEBUG(Service_AM, "called");
  181. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  182. rb.Push(ResultSuccess);
  183. rb.PushIpcInterface<IGlobalStateController>(system);
  184. }
  185. void GetApplicationCreator(HLERequestContext& ctx) {
  186. LOG_DEBUG(Service_AM, "called");
  187. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  188. rb.Push(ResultSuccess);
  189. rb.PushIpcInterface<IApplicationCreator>(system);
  190. }
  191. void GetAppletCommonFunctions(HLERequestContext& ctx) {
  192. LOG_DEBUG(Service_AM, "called");
  193. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  194. rb.Push(ResultSuccess);
  195. rb.PushIpcInterface<IAppletCommonFunctions>(system);
  196. }
  197. void GetDebugFunctions(HLERequestContext& ctx) {
  198. LOG_DEBUG(Service_AM, "called");
  199. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  200. rb.Push(ResultSuccess);
  201. rb.PushIpcInterface<IDebugFunctions>(system);
  202. }
  203. Nvnflinger::Nvnflinger& nvnflinger;
  204. std::shared_ptr<AppletMessageQueue> msg_queue;
  205. };
  206. void AppletAE::OpenSystemAppletProxy(HLERequestContext& ctx) {
  207. LOG_DEBUG(Service_AM, "called");
  208. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  209. rb.Push(ResultSuccess);
  210. rb.PushIpcInterface<ISystemAppletProxy>(nvnflinger, msg_queue, system);
  211. }
  212. void AppletAE::OpenLibraryAppletProxy(HLERequestContext& ctx) {
  213. LOG_DEBUG(Service_AM, "called");
  214. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  215. rb.Push(ResultSuccess);
  216. rb.PushIpcInterface<ILibraryAppletProxy>(nvnflinger, msg_queue, system);
  217. }
  218. void AppletAE::OpenLibraryAppletProxyOld(HLERequestContext& ctx) {
  219. LOG_DEBUG(Service_AM, "called");
  220. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  221. rb.Push(ResultSuccess);
  222. rb.PushIpcInterface<ILibraryAppletProxy>(nvnflinger, msg_queue, system);
  223. }
  224. AppletAE::AppletAE(Nvnflinger::Nvnflinger& nvnflinger_,
  225. std::shared_ptr<AppletMessageQueue> msg_queue_, Core::System& system_)
  226. : ServiceFramework{system_, "appletAE"}, nvnflinger{nvnflinger_}, msg_queue{
  227. std::move(msg_queue_)} {
  228. // clang-format off
  229. static const FunctionInfo functions[] = {
  230. {100, &AppletAE::OpenSystemAppletProxy, "OpenSystemAppletProxy"},
  231. {200, &AppletAE::OpenLibraryAppletProxyOld, "OpenLibraryAppletProxyOld"},
  232. {201, &AppletAE::OpenLibraryAppletProxy, "OpenLibraryAppletProxy"},
  233. {300, nullptr, "OpenOverlayAppletProxy"},
  234. {350, nullptr, "OpenSystemApplicationProxy"},
  235. {400, nullptr, "CreateSelfLibraryAppletCreatorForDevelop"},
  236. {410, nullptr, "GetSystemAppletControllerForDebug"},
  237. {1000, nullptr, "GetDebugFunctions"},
  238. };
  239. // clang-format on
  240. RegisterHandlers(functions);
  241. }
  242. AppletAE::~AppletAE() = default;
  243. const std::shared_ptr<AppletMessageQueue>& AppletAE::GetMessageQueue() const {
  244. return msg_queue;
  245. }
  246. } // namespace Service::AM