From 1b2872eebc84ef3b35f8c0456ccb22519059d66a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 26 Feb 2019 17:20:02 -0500 Subject: service/vi: Remove use of a module class This didn't really provide much benefit here, especially since the subsequent change requires that the behavior for each service's GetDisplayService differs in a minor detail. This also arguably makes the services nicer to read, since it gets rid of an indirection in the class hierarchy. --- src/core/hle/service/vi/vi.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 7369a09ec..99340e2ed 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -24,6 +24,7 @@ #include "core/hle/service/nvdrv/nvdrv.h" #include "core/hle/service/nvflinger/buffer_queue.h" #include "core/hle/service/nvflinger/nvflinger.h" +#include "core/hle/service/service.h" #include "core/hle/service/vi/vi.h" #include "core/hle/service/vi/vi_m.h" #include "core/hle/service/vi/vi_s.h" @@ -1202,26 +1203,18 @@ IApplicationDisplayService::IApplicationDisplayService( RegisterHandlers(functions); } -Module::Interface::Interface(std::shared_ptr module, const char* name, - std::shared_ptr nv_flinger) - : ServiceFramework(name), module(std::move(module)), nv_flinger(std::move(nv_flinger)) {} - -Module::Interface::~Interface() = default; - -void Module::Interface::GetDisplayService(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_VI, "(STUBBED) called"); - +void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, + std::shared_ptr nv_flinger) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(nv_flinger); + rb.PushIpcInterface(std::move(nv_flinger)); } void InstallInterfaces(SM::ServiceManager& service_manager, std::shared_ptr nv_flinger) { - auto module = std::make_shared(); - std::make_shared(module, nv_flinger)->InstallAsService(service_manager); - std::make_shared(module, nv_flinger)->InstallAsService(service_manager); - std::make_shared(module, nv_flinger)->InstallAsService(service_manager); + std::make_shared(nv_flinger)->InstallAsService(service_manager); + std::make_shared(nv_flinger)->InstallAsService(service_manager); + std::make_shared(nv_flinger)->InstallAsService(service_manager); } } // namespace Service::VI -- cgit v1.2.3 From 92ea1c32d608cd258c3fc077f5aaf953536d7f45 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 26 Feb 2019 17:49:32 -0500 Subject: service/vi: Unstub GetDisplayService This function is also supposed to check its given policy type with the permission of the service itself. This implements the necessary machinery to unstub these functions. Policy::User seems to just be basic access (which is probably why vi:u is restricted to that policy), while the other policy seems to be for extended abilities regarding which displays can be managed and queried, so this is assumed to be for a background compositor (which I've named, appropriately, Policy::Compositor). --- src/core/hle/service/vi/vi.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 99340e2ed..a5ad66a13 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -34,6 +34,7 @@ namespace Service::VI { constexpr ResultCode ERR_OPERATION_FAILED{ErrorModule::VI, 1}; +constexpr ResultCode ERR_PERMISSION_DENIED{ErrorModule::VI, 5}; constexpr ResultCode ERR_UNSUPPORTED{ErrorModule::VI, 6}; constexpr ResultCode ERR_NOT_FOUND{ErrorModule::VI, 7}; @@ -1203,8 +1204,30 @@ IApplicationDisplayService::IApplicationDisplayService( RegisterHandlers(functions); } +static bool IsValidServiceAccess(Permission permission, Policy policy) { + if (permission == Permission::User) { + return policy == Policy::User; + } + + if (permission == Permission::System || permission == Permission::Manager) { + return policy == Policy::User || policy == Policy::Compositor; + } + + return false; +} + void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, - std::shared_ptr nv_flinger) { + std::shared_ptr nv_flinger, + Permission permission) { + IPC::RequestParser rp{ctx}; + const auto policy = rp.PopEnum(); + + if (!IsValidServiceAccess(permission, policy)) { + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ERR_PERMISSION_DENIED); + return; + } + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); rb.PushIpcInterface(std::move(nv_flinger)); -- cgit v1.2.3