applet_oe.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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_oe.h"
  8. #include "core/hle/service/nvflinger/nvflinger.h"
  9. namespace Service::AM {
  10. class IApplicationProxy final : public ServiceFramework<IApplicationProxy> {
  11. public:
  12. explicit IApplicationProxy(NVFlinger::NVFlinger& nvflinger_,
  13. std::shared_ptr<AppletMessageQueue> msg_queue_,
  14. Core::System& system_)
  15. : ServiceFramework{system_, "IApplicationProxy"}, nvflinger{nvflinger_},
  16. msg_queue{std::move(msg_queue_)} {
  17. // clang-format off
  18. static const FunctionInfo functions[] = {
  19. {0, &IApplicationProxy::GetCommonStateGetter, "GetCommonStateGetter"},
  20. {1, &IApplicationProxy::GetSelfController, "GetSelfController"},
  21. {2, &IApplicationProxy::GetWindowController, "GetWindowController"},
  22. {3, &IApplicationProxy::GetAudioController, "GetAudioController"},
  23. {4, &IApplicationProxy::GetDisplayController, "GetDisplayController"},
  24. {10, nullptr, "GetProcessWindingController"},
  25. {11, &IApplicationProxy::GetLibraryAppletCreator, "GetLibraryAppletCreator"},
  26. {20, &IApplicationProxy::GetApplicationFunctions, "GetApplicationFunctions"},
  27. {1000, &IApplicationProxy::GetDebugFunctions, "GetDebugFunctions"},
  28. };
  29. // clang-format on
  30. RegisterHandlers(functions);
  31. }
  32. private:
  33. void GetAudioController(Kernel::HLERequestContext& ctx) {
  34. LOG_DEBUG(Service_AM, "called");
  35. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  36. rb.Push(ResultSuccess);
  37. rb.PushIpcInterface<IAudioController>(system);
  38. }
  39. void GetDisplayController(Kernel::HLERequestContext& ctx) {
  40. LOG_DEBUG(Service_AM, "called");
  41. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  42. rb.Push(ResultSuccess);
  43. rb.PushIpcInterface<IDisplayController>(system);
  44. }
  45. void GetDebugFunctions(Kernel::HLERequestContext& ctx) {
  46. LOG_DEBUG(Service_AM, "called");
  47. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  48. rb.Push(ResultSuccess);
  49. rb.PushIpcInterface<IDebugFunctions>(system);
  50. }
  51. void GetWindowController(Kernel::HLERequestContext& ctx) {
  52. LOG_DEBUG(Service_AM, "called");
  53. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  54. rb.Push(ResultSuccess);
  55. rb.PushIpcInterface<IWindowController>(system);
  56. }
  57. void GetSelfController(Kernel::HLERequestContext& ctx) {
  58. LOG_DEBUG(Service_AM, "called");
  59. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  60. rb.Push(ResultSuccess);
  61. rb.PushIpcInterface<ISelfController>(system, nvflinger);
  62. }
  63. void GetCommonStateGetter(Kernel::HLERequestContext& ctx) {
  64. LOG_DEBUG(Service_AM, "called");
  65. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  66. rb.Push(ResultSuccess);
  67. rb.PushIpcInterface<ICommonStateGetter>(system, msg_queue);
  68. }
  69. void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) {
  70. LOG_DEBUG(Service_AM, "called");
  71. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  72. rb.Push(ResultSuccess);
  73. rb.PushIpcInterface<ILibraryAppletCreator>(system);
  74. }
  75. void GetApplicationFunctions(Kernel::HLERequestContext& ctx) {
  76. LOG_DEBUG(Service_AM, "called");
  77. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  78. rb.Push(ResultSuccess);
  79. rb.PushIpcInterface<IApplicationFunctions>(system);
  80. }
  81. NVFlinger::NVFlinger& nvflinger;
  82. std::shared_ptr<AppletMessageQueue> msg_queue;
  83. };
  84. void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) {
  85. LOG_DEBUG(Service_AM, "called");
  86. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  87. rb.Push(ResultSuccess);
  88. rb.PushIpcInterface<IApplicationProxy>(nvflinger, msg_queue, system);
  89. }
  90. AppletOE::AppletOE(NVFlinger::NVFlinger& nvflinger_, std::shared_ptr<AppletMessageQueue> msg_queue_,
  91. Core::System& system_)
  92. : ServiceFramework{system_, "appletOE"}, nvflinger{nvflinger_}, msg_queue{
  93. std::move(msg_queue_)} {
  94. static const FunctionInfo functions[] = {
  95. {0, &AppletOE::OpenApplicationProxy, "OpenApplicationProxy"},
  96. };
  97. RegisterHandlers(functions);
  98. }
  99. AppletOE::~AppletOE() = default;
  100. const std::shared_ptr<AppletMessageQueue>& AppletOE::GetMessageQueue() const {
  101. return msg_queue;
  102. }
  103. } // namespace Service::AM