applet_ae.cpp 10.0 KB

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