applet_ae.cpp 9.7 KB

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