applet_ae.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "core/hle/service/am/applet_ae.h"
  4. #include "core/hle/service/am/applet_manager.h"
  5. #include "core/hle/service/am/library_applet_proxy.h"
  6. #include "core/hle/service/am/system_applet_proxy.h"
  7. #include "core/hle/service/ipc_helpers.h"
  8. namespace Service::AM {
  9. AppletAE::AppletAE(Nvnflinger::Nvnflinger& nvnflinger_, Core::System& system_)
  10. : ServiceFramework{system_, "appletAE"}, nvnflinger{nvnflinger_} {
  11. // clang-format off
  12. static const FunctionInfo functions[] = {
  13. {100, &AppletAE::OpenSystemAppletProxy, "OpenSystemAppletProxy"},
  14. {200, &AppletAE::OpenLibraryAppletProxyOld, "OpenLibraryAppletProxyOld"},
  15. {201, &AppletAE::OpenLibraryAppletProxy, "OpenLibraryAppletProxy"},
  16. {300, nullptr, "OpenOverlayAppletProxy"},
  17. {350, nullptr, "OpenSystemApplicationProxy"},
  18. {400, nullptr, "CreateSelfLibraryAppletCreatorForDevelop"},
  19. {410, nullptr, "GetSystemAppletControllerForDebug"},
  20. {1000, nullptr, "GetDebugFunctions"},
  21. };
  22. // clang-format on
  23. RegisterHandlers(functions);
  24. }
  25. AppletAE::~AppletAE() = default;
  26. void AppletAE::OpenSystemAppletProxy(HLERequestContext& ctx) {
  27. LOG_DEBUG(Service_AM, "called");
  28. if (const auto applet = GetAppletFromContext(ctx)) {
  29. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  30. rb.Push(ResultSuccess);
  31. rb.PushIpcInterface<ISystemAppletProxy>(nvnflinger, applet, system);
  32. } else {
  33. UNIMPLEMENTED();
  34. IPC::ResponseBuilder rb{ctx, 2};
  35. rb.Push(ResultUnknown);
  36. }
  37. }
  38. void AppletAE::OpenLibraryAppletProxy(HLERequestContext& ctx) {
  39. LOG_DEBUG(Service_AM, "called");
  40. if (const auto applet = GetAppletFromContext(ctx)) {
  41. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  42. rb.Push(ResultSuccess);
  43. rb.PushIpcInterface<ILibraryAppletProxy>(nvnflinger, applet, system);
  44. } else {
  45. UNIMPLEMENTED();
  46. IPC::ResponseBuilder rb{ctx, 2};
  47. rb.Push(ResultUnknown);
  48. }
  49. }
  50. void AppletAE::OpenLibraryAppletProxyOld(HLERequestContext& ctx) {
  51. LOG_DEBUG(Service_AM, "called");
  52. return OpenLibraryAppletProxy(ctx);
  53. }
  54. std::shared_ptr<Applet> AppletAE::GetAppletFromContext(HLERequestContext& ctx) {
  55. const auto aruid = ctx.GetPID();
  56. return system.GetAppletManager().GetByAppletResourceUserId(aruid);
  57. }
  58. } // namespace Service::AM