From 42859461f3d6db8ea64facdf388d4791f713c7b1 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 22 Jan 2018 13:40:02 -0500 Subject: Services: Vi shouldn't be responsible for creating nvflinger. It is now created during Service initialization and passed to all the services that need it. --- src/core/hle/service/service.cpp | 6 +++++- src/core/hle/service/vi/vi.cpp | 5 +++-- src/core/hle/service/vi/vi.h | 3 ++- src/core/hle/service/vi/vi_m.cpp | 4 ++-- src/core/hle/service/vi/vi_m.h | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 3f5ce56c6..403cce8e5 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -165,6 +165,10 @@ void AddNamedPort(std::string name, SharedPtr port) { /// Initialize ServiceManager void Init() { + // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it + // here and pass it into the respective InstallInterfaces functions. + auto nv_flinger = std::make_shared(); + SM::g_service_manager = std::make_shared(); SM::ServiceManager::InstallInterfaces(SM::g_service_manager); @@ -180,7 +184,7 @@ void Init() { PCTL::InstallInterfaces(*SM::g_service_manager); Sockets::InstallInterfaces(*SM::g_service_manager); Time::InstallInterfaces(*SM::g_service_manager); - VI::InstallInterfaces(*SM::g_service_manager); + VI::InstallInterfaces(*SM::g_service_manager, nv_flinger); Set::InstallInterfaces(*SM::g_service_manager); LOG_DEBUG(Service, "initialized OK"); diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index e0bfad290..6576f81db 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -753,8 +753,9 @@ IApplicationDisplayService::IApplicationDisplayService( RegisterHandlers(functions); } -void InstallInterfaces(SM::ServiceManager& service_manager) { - std::make_shared()->InstallAsService(service_manager); +void InstallInterfaces(SM::ServiceManager& service_manager, + std::shared_ptr nv_flinger) { + std::make_shared(nv_flinger)->InstallAsService(service_manager); } } // namespace VI diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h index 5e9b7e6cf..a6e084f87 100644 --- a/src/core/hle/service/vi/vi.h +++ b/src/core/hle/service/vi/vi.h @@ -39,7 +39,8 @@ private: }; /// Registers all VI services with the specified service manager. -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(SM::ServiceManager& service_manager, + std::shared_ptr nv_flinger); } // namespace VI } // namespace Service diff --git a/src/core/hle/service/vi/vi_m.cpp b/src/core/hle/service/vi/vi_m.cpp index 6deedf842..20b24658e 100644 --- a/src/core/hle/service/vi/vi_m.cpp +++ b/src/core/hle/service/vi/vi_m.cpp @@ -17,13 +17,13 @@ void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface(nv_flinger); } -VI_M::VI_M() : ServiceFramework("vi:m") { +VI_M::VI_M(std::shared_ptr nv_flinger) + : ServiceFramework("vi:m"), nv_flinger(std::move(nv_flinger)) { static const FunctionInfo functions[] = { {2, &VI_M::GetDisplayService, "GetDisplayService"}, {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, }; RegisterHandlers(functions); - nv_flinger = std::make_shared(); } } // namespace VI diff --git a/src/core/hle/service/vi/vi_m.h b/src/core/hle/service/vi/vi_m.h index ebe79d5c7..e5319b1e7 100644 --- a/src/core/hle/service/vi/vi_m.h +++ b/src/core/hle/service/vi/vi_m.h @@ -16,7 +16,7 @@ namespace VI { class VI_M final : public ServiceFramework { public: - VI_M(); + VI_M(std::shared_ptr nv_flinger); ~VI_M() = default; private: -- cgit v1.2.3 From eb58f852f8cd961853120e756e5cd91ad8c33bfd Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 22 Jan 2018 13:46:36 -0500 Subject: AppletOE: Make ISelfController keep a reference to nvflinger. It'll be needed when we implement CreateManagedDisplayLayer. --- src/core/hle/service/am/am.cpp | 5 +++-- src/core/hle/service/am/am.h | 8 +++++++- src/core/hle/service/am/applet_oe.cpp | 18 +++++++++++++----- src/core/hle/service/am/applet_oe.h | 9 ++++++++- src/core/hle/service/service.cpp | 2 +- 5 files changed, 32 insertions(+), 10 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index a761bea65..b6896852e 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -8,8 +8,9 @@ namespace Service { namespace AM { -void InstallInterfaces(SM::ServiceManager& service_manager) { - std::make_shared()->InstallAsService(service_manager); +void InstallInterfaces(SM::ServiceManager& service_manager, + std::shared_ptr nvflinger) { + std::make_shared(nvflinger)->InstallAsService(service_manager); } } // namespace AM diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 63d86cd41..3b8a06c1d 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -4,13 +4,19 @@ #pragma once +#include #include "core/hle/service/service.h" namespace Service { +namespace NVFlinger { +class NVFlinger; +} + namespace AM { /// Registers all AM services with the specified service manager. -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(SM::ServiceManager& service_manager, + std::shared_ptr nvflinger); } // namespace AM } // namespace Service diff --git a/src/core/hle/service/am/applet_oe.cpp b/src/core/hle/service/am/applet_oe.cpp index b4a6ad232..f593840b3 100644 --- a/src/core/hle/service/am/applet_oe.cpp +++ b/src/core/hle/service/am/applet_oe.cpp @@ -7,6 +7,7 @@ #include "core/hle/kernel/event.h" #include "core/hle/service/am/applet_oe.h" #include "core/hle/service/apm/apm.h" +#include "core/hle/service/nvflinger/nvflinger.h" namespace Service { namespace AM { @@ -53,7 +54,8 @@ public: class ISelfController final : public ServiceFramework { public: - ISelfController() : ServiceFramework("ISelfController") { + ISelfController(std::shared_ptr nvflinger) + : ServiceFramework("ISelfController"), nvflinger(std::move(nvflinger)) { static const FunctionInfo functions[] = { {1, &ISelfController::LockExit, "LockExit"}, {2, &ISelfController::UnlockExit, "UnlockExit"}, @@ -144,6 +146,8 @@ private: LOG_WARNING(Service, "(STUBBED) called"); } + + std::shared_ptr nvflinger; }; class ICommonStateGetter final : public ServiceFramework { @@ -367,7 +371,8 @@ public: class IApplicationProxy final : public ServiceFramework { public: - IApplicationProxy() : ServiceFramework("IApplicationProxy") { + IApplicationProxy(std::shared_ptr nvflinger) + : ServiceFramework("IApplicationProxy"), nvflinger(std::move(nvflinger)) { static const FunctionInfo functions[] = { {0, &IApplicationProxy::GetCommonStateGetter, "GetCommonStateGetter"}, {1, &IApplicationProxy::GetSelfController, "GetSelfController"}, @@ -413,7 +418,7 @@ private: void GetSelfController(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(nvflinger); LOG_DEBUG(Service, "called"); } @@ -437,16 +442,19 @@ private: rb.PushIpcInterface(); LOG_DEBUG(Service, "called"); } + + std::shared_ptr nvflinger; }; void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(nvflinger); LOG_DEBUG(Service, "called"); } -AppletOE::AppletOE() : ServiceFramework("appletOE") { +AppletOE::AppletOE(std::shared_ptr nvflinger) + : ServiceFramework("appletOE"), nvflinger(std::move(nvflinger)) { static const FunctionInfo functions[] = { {0x00000000, &AppletOE::OpenApplicationProxy, "OpenApplicationProxy"}, }; diff --git a/src/core/hle/service/am/applet_oe.h b/src/core/hle/service/am/applet_oe.h index 6ee5b0e9f..8083135c3 100644 --- a/src/core/hle/service/am/applet_oe.h +++ b/src/core/hle/service/am/applet_oe.h @@ -4,10 +4,15 @@ #pragma once +#include #include "core/hle/kernel/hle_ipc.h" #include "core/hle/service/service.h" namespace Service { +namespace NVFlinger { +class NVFlinger; +} + namespace AM { // TODO: Add more languages @@ -18,11 +23,13 @@ enum SystemLanguage { class AppletOE final : public ServiceFramework { public: - AppletOE(); + AppletOE(std::shared_ptr nvflinger); ~AppletOE() = default; private: void OpenApplicationProxy(Kernel::HLERequestContext& ctx); + + std::shared_ptr nvflinger; }; } // namespace AM diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 403cce8e5..1b8565351 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -173,7 +173,7 @@ void Init() { SM::ServiceManager::InstallInterfaces(SM::g_service_manager); Account::InstallInterfaces(*SM::g_service_manager); - AM::InstallInterfaces(*SM::g_service_manager); + AM::InstallInterfaces(*SM::g_service_manager, nv_flinger); AOC::InstallInterfaces(*SM::g_service_manager); APM::InstallInterfaces(*SM::g_service_manager); Audio::InstallInterfaces(*SM::g_service_manager); -- cgit v1.2.3 From 10c67bf39504aae36b06d4abe8055aaf6feeb2ad Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 22 Jan 2018 13:50:22 -0500 Subject: AppletOE: Stubbed CreateManagedDisplayLayer to create a new layer in the Default display. This function is used by libnx to obtain a new layer. --- src/core/hle/service/am/applet_oe.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/core/hle') diff --git a/src/core/hle/service/am/applet_oe.cpp b/src/core/hle/service/am/applet_oe.cpp index f593840b3..7d16b45f3 100644 --- a/src/core/hle/service/am/applet_oe.cpp +++ b/src/core/hle/service/am/applet_oe.cpp @@ -67,6 +67,7 @@ public: {14, &ISelfController::SetRestartMessageEnabled, "SetRestartMessageEnabled"}, {16, &ISelfController::SetOutOfFocusSuspendingEnabled, "SetOutOfFocusSuspendingEnabled"}, + {40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"}, }; RegisterHandlers(functions); } @@ -147,6 +148,19 @@ private: LOG_WARNING(Service, "(STUBBED) called"); } + void CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) { + // TODO(Subv): Find out how AM determines the display to use, for now just create the layer + // in the Default display. + u64 display_id = nvflinger->OpenDisplay("Default"); + u64 layer_id = nvflinger->CreateLayer(display_id); + + IPC::RequestBuilder rb{ctx, 4}; + rb.Push(RESULT_SUCCESS); + rb.Push(layer_id); + + LOG_WARNING(Service, "(STUBBED) called"); + } + std::shared_ptr nvflinger; }; -- cgit v1.2.3