diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/service/vi/application_root_service.cpp | 21 | ||||
| -rw-r--r-- | src/core/hle/service/vi/application_root_service.h | 17 | ||||
| -rw-r--r-- | src/core/hle/service/vi/manager_root_service.cpp | 21 | ||||
| -rw-r--r-- | src/core/hle/service/vi/manager_root_service.h | 16 | ||||
| -rw-r--r-- | src/core/hle/service/vi/service_creator.cpp | 39 | ||||
| -rw-r--r-- | src/core/hle/service/vi/service_creator.h | 33 | ||||
| -rw-r--r-- | src/core/hle/service/vi/system_root_service.cpp | 21 | ||||
| -rw-r--r-- | src/core/hle/service/vi/system_root_service.h | 16 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi.cpp | 34 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi.h | 13 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi_types.h | 2 |
12 files changed, 145 insertions, 90 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index fa4a25156..7770dbeae 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -969,6 +969,8 @@ add_library(core STATIC | |||
| 969 | hle/service/vi/manager_display_service.h | 969 | hle/service/vi/manager_display_service.h |
| 970 | hle/service/vi/manager_root_service.cpp | 970 | hle/service/vi/manager_root_service.cpp |
| 971 | hle/service/vi/manager_root_service.h | 971 | hle/service/vi/manager_root_service.h |
| 972 | hle/service/vi/service_creator.cpp | ||
| 973 | hle/service/vi/service_creator.h | ||
| 972 | hle/service/vi/system_display_service.cpp | 974 | hle/service/vi/system_display_service.cpp |
| 973 | hle/service/vi/system_display_service.h | 975 | hle/service/vi/system_display_service.h |
| 974 | hle/service/vi/system_root_service.cpp | 976 | hle/service/vi/system_root_service.cpp |
diff --git a/src/core/hle/service/vi/application_root_service.cpp b/src/core/hle/service/vi/application_root_service.cpp index caba3d1d9..7af7f062c 100644 --- a/src/core/hle/service/vi/application_root_service.cpp +++ b/src/core/hle/service/vi/application_root_service.cpp | |||
| @@ -1,19 +1,22 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/cmif_serialization.h" | ||
| 5 | #include "core/hle/service/vi/application_display_service.h" | ||
| 4 | #include "core/hle/service/vi/application_root_service.h" | 6 | #include "core/hle/service/vi/application_root_service.h" |
| 7 | #include "core/hle/service/vi/service_creator.h" | ||
| 5 | #include "core/hle/service/vi/vi.h" | 8 | #include "core/hle/service/vi/vi.h" |
| 6 | #include "core/hle/service/vi/vi_types.h" | 9 | #include "core/hle/service/vi/vi_types.h" |
| 7 | 10 | ||
| 8 | namespace Service::VI { | 11 | namespace Service::VI { |
| 9 | 12 | ||
| 10 | IApplicationRootService::IApplicationRootService( | 13 | IApplicationRootService::IApplicationRootService( |
| 11 | Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, | 14 | Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger, |
| 12 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_) | 15 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) |
| 13 | : ServiceFramework{system_, "vi:u"}, nv_flinger{nv_flinger_}, | 16 | : ServiceFramework{system_, "vi:u"}, m_nvnflinger{nvnflinger}, m_hos_binder_driver_server{ |
| 14 | hos_binder_driver_server{hos_binder_driver_server_} { | 17 | hos_binder_driver_server} { |
| 15 | static const FunctionInfo functions[] = { | 18 | static const FunctionInfo functions[] = { |
| 16 | {0, &IApplicationRootService::GetDisplayService, "GetDisplayService"}, | 19 | {0, C<&IApplicationRootService::GetDisplayService>, "GetDisplayService"}, |
| 17 | {1, nullptr, "GetDisplayServiceWithProxyNameExchange"}, | 20 | {1, nullptr, "GetDisplayServiceWithProxyNameExchange"}, |
| 18 | }; | 21 | }; |
| 19 | RegisterHandlers(functions); | 22 | RegisterHandlers(functions); |
| @@ -21,11 +24,11 @@ IApplicationRootService::IApplicationRootService( | |||
| 21 | 24 | ||
| 22 | IApplicationRootService::~IApplicationRootService() = default; | 25 | IApplicationRootService::~IApplicationRootService() = default; |
| 23 | 26 | ||
| 24 | void IApplicationRootService::GetDisplayService(HLERequestContext& ctx) { | 27 | Result IApplicationRootService::GetDisplayService( |
| 28 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) { | ||
| 25 | LOG_DEBUG(Service_VI, "called"); | 29 | LOG_DEBUG(Service_VI, "called"); |
| 26 | 30 | R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_nvnflinger, | |
| 27 | detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server, | 31 | m_hos_binder_driver_server, Permission::User, policy)); |
| 28 | Permission::User); | ||
| 29 | } | 32 | } |
| 30 | 33 | ||
| 31 | } // namespace Service::VI | 34 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/application_root_service.h b/src/core/hle/service/vi/application_root_service.h index 231d26891..9dbf28cb4 100644 --- a/src/core/hle/service/vi/application_root_service.h +++ b/src/core/hle/service/vi/application_root_service.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 6 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 7 | 8 | ||
| 8 | namespace Core { | 9 | namespace Core { |
| @@ -16,17 +17,23 @@ class Nvnflinger; | |||
| 16 | 17 | ||
| 17 | namespace Service::VI { | 18 | namespace Service::VI { |
| 18 | 19 | ||
| 20 | class IApplicationDisplayService; | ||
| 21 | enum class Policy : u32; | ||
| 22 | |||
| 19 | class IApplicationRootService final : public ServiceFramework<IApplicationRootService> { | 23 | class IApplicationRootService final : public ServiceFramework<IApplicationRootService> { |
| 20 | public: | 24 | public: |
| 21 | explicit IApplicationRootService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, | 25 | explicit IApplicationRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger, |
| 22 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_); | 26 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server); |
| 23 | ~IApplicationRootService() override; | 27 | ~IApplicationRootService() override; |
| 24 | 28 | ||
| 25 | private: | 29 | private: |
| 26 | void GetDisplayService(HLERequestContext& ctx); | 30 | Result GetDisplayService( |
| 31 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, | ||
| 32 | Policy policy); | ||
| 27 | 33 | ||
| 28 | Nvnflinger::Nvnflinger& nv_flinger; | 34 | private: |
| 29 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server; | 35 | Nvnflinger::Nvnflinger& m_nvnflinger; |
| 36 | Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server; | ||
| 30 | }; | 37 | }; |
| 31 | 38 | ||
| 32 | } // namespace Service::VI | 39 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/manager_root_service.cpp b/src/core/hle/service/vi/manager_root_service.cpp index 3ab88111d..a7eee4f04 100644 --- a/src/core/hle/service/vi/manager_root_service.cpp +++ b/src/core/hle/service/vi/manager_root_service.cpp | |||
| @@ -1,19 +1,22 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/cmif_serialization.h" | ||
| 5 | #include "core/hle/service/vi/application_display_service.h" | ||
| 4 | #include "core/hle/service/vi/manager_root_service.h" | 6 | #include "core/hle/service/vi/manager_root_service.h" |
| 7 | #include "core/hle/service/vi/service_creator.h" | ||
| 5 | #include "core/hle/service/vi/vi.h" | 8 | #include "core/hle/service/vi/vi.h" |
| 6 | #include "core/hle/service/vi/vi_types.h" | 9 | #include "core/hle/service/vi/vi_types.h" |
| 7 | 10 | ||
| 8 | namespace Service::VI { | 11 | namespace Service::VI { |
| 9 | 12 | ||
| 10 | IManagerRootService::IManagerRootService( | 13 | IManagerRootService::IManagerRootService( |
| 11 | Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, | 14 | Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger, |
| 12 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_) | 15 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) |
| 13 | : ServiceFramework{system_, "vi:m"}, nv_flinger{nv_flinger_}, | 16 | : ServiceFramework{system_, "vi:m"}, m_nvnflinger{nvnflinger}, m_hos_binder_driver_server{ |
| 14 | hos_binder_driver_server{hos_binder_driver_server_} { | 17 | hos_binder_driver_server} { |
| 15 | static const FunctionInfo functions[] = { | 18 | static const FunctionInfo functions[] = { |
| 16 | {2, &IManagerRootService::GetDisplayService, "GetDisplayService"}, | 19 | {2, C<&IManagerRootService::GetDisplayService>, "GetDisplayService"}, |
| 17 | {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, | 20 | {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, |
| 18 | {100, nullptr, "PrepareFatal"}, | 21 | {100, nullptr, "PrepareFatal"}, |
| 19 | {101, nullptr, "ShowFatal"}, | 22 | {101, nullptr, "ShowFatal"}, |
| @@ -25,11 +28,11 @@ IManagerRootService::IManagerRootService( | |||
| 25 | 28 | ||
| 26 | IManagerRootService::~IManagerRootService() = default; | 29 | IManagerRootService::~IManagerRootService() = default; |
| 27 | 30 | ||
| 28 | void IManagerRootService::GetDisplayService(HLERequestContext& ctx) { | 31 | Result IManagerRootService::GetDisplayService( |
| 32 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) { | ||
| 29 | LOG_DEBUG(Service_VI, "called"); | 33 | LOG_DEBUG(Service_VI, "called"); |
| 30 | 34 | R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_nvnflinger, | |
| 31 | detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server, | 35 | m_hos_binder_driver_server, Permission::Manager, policy)); |
| 32 | Permission::Manager); | ||
| 33 | } | 36 | } |
| 34 | 37 | ||
| 35 | } // namespace Service::VI | 38 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/manager_root_service.h b/src/core/hle/service/vi/manager_root_service.h index 3776619ad..e6cb77aeb 100644 --- a/src/core/hle/service/vi/manager_root_service.h +++ b/src/core/hle/service/vi/manager_root_service.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 6 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 7 | 8 | ||
| 8 | namespace Core { | 9 | namespace Core { |
| @@ -16,17 +17,22 @@ class Nvnflinger; | |||
| 16 | 17 | ||
| 17 | namespace Service::VI { | 18 | namespace Service::VI { |
| 18 | 19 | ||
| 20 | class IApplicationDisplayService; | ||
| 21 | enum class Policy : u32; | ||
| 22 | |||
| 19 | class IManagerRootService final : public ServiceFramework<IManagerRootService> { | 23 | class IManagerRootService final : public ServiceFramework<IManagerRootService> { |
| 20 | public: | 24 | public: |
| 21 | explicit IManagerRootService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, | 25 | explicit IManagerRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger, |
| 22 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_); | 26 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server); |
| 23 | ~IManagerRootService() override; | 27 | ~IManagerRootService() override; |
| 24 | 28 | ||
| 25 | private: | 29 | private: |
| 26 | void GetDisplayService(HLERequestContext& ctx); | 30 | Result GetDisplayService( |
| 31 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, | ||
| 32 | Policy policy); | ||
| 27 | 33 | ||
| 28 | Nvnflinger::Nvnflinger& nv_flinger; | 34 | Nvnflinger::Nvnflinger& m_nvnflinger; |
| 29 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server; | 35 | Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server; |
| 30 | }; | 36 | }; |
| 31 | 37 | ||
| 32 | } // namespace Service::VI | 38 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/service_creator.cpp b/src/core/hle/service/vi/service_creator.cpp new file mode 100644 index 000000000..1de9d61a4 --- /dev/null +++ b/src/core/hle/service/vi/service_creator.cpp | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/service/vi/application_display_service.h" | ||
| 5 | #include "core/hle/service/vi/service_creator.h" | ||
| 6 | #include "core/hle/service/vi/vi_results.h" | ||
| 7 | #include "core/hle/service/vi/vi_types.h" | ||
| 8 | |||
| 9 | namespace Service::VI { | ||
| 10 | |||
| 11 | static bool IsValidServiceAccess(Permission permission, Policy policy) { | ||
| 12 | if (permission == Permission::User) { | ||
| 13 | return policy == Policy::User; | ||
| 14 | } | ||
| 15 | |||
| 16 | if (permission == Permission::System || permission == Permission::Manager) { | ||
| 17 | return policy == Policy::User || policy == Policy::Compositor; | ||
| 18 | } | ||
| 19 | |||
| 20 | return false; | ||
| 21 | } | ||
| 22 | |||
| 23 | Result GetApplicationDisplayService( | ||
| 24 | std::shared_ptr<IApplicationDisplayService>* out_application_display_service, | ||
| 25 | Core::System& system, Nvnflinger::Nvnflinger& nvnflinger, | ||
| 26 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server, Permission permission, | ||
| 27 | Policy policy) { | ||
| 28 | |||
| 29 | if (!IsValidServiceAccess(permission, policy)) { | ||
| 30 | LOG_ERROR(Service_VI, "Permission denied for policy {}", policy); | ||
| 31 | R_THROW(ResultPermissionDenied); | ||
| 32 | } | ||
| 33 | |||
| 34 | *out_application_display_service = | ||
| 35 | std::make_shared<IApplicationDisplayService>(system, nvnflinger, hos_binder_driver_server); | ||
| 36 | R_SUCCEED(); | ||
| 37 | } | ||
| 38 | |||
| 39 | } // namespace Service::VI | ||
diff --git a/src/core/hle/service/vi/service_creator.h b/src/core/hle/service/vi/service_creator.h new file mode 100644 index 000000000..8963bcd26 --- /dev/null +++ b/src/core/hle/service/vi/service_creator.h | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <memory> | ||
| 7 | |||
| 8 | #include "common/common_types.h" | ||
| 9 | |||
| 10 | namespace Core { | ||
| 11 | class System; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::Nvnflinger { | ||
| 15 | class HosBinderDriverServer; | ||
| 16 | class Nvnflinger; | ||
| 17 | } // namespace Service::Nvnflinger | ||
| 18 | |||
| 19 | union Result; | ||
| 20 | |||
| 21 | namespace Service::VI { | ||
| 22 | |||
| 23 | class IApplicationDisplayService; | ||
| 24 | enum class Permission; | ||
| 25 | enum class Policy : u32; | ||
| 26 | |||
| 27 | Result GetApplicationDisplayService( | ||
| 28 | std::shared_ptr<IApplicationDisplayService>* out_application_display_service, | ||
| 29 | Core::System& system, Nvnflinger::Nvnflinger& nvnflinger, | ||
| 30 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server, Permission permission, | ||
| 31 | Policy policy); | ||
| 32 | |||
| 33 | } // namespace Service::VI | ||
diff --git a/src/core/hle/service/vi/system_root_service.cpp b/src/core/hle/service/vi/system_root_service.cpp index c3228d73b..8789b4cfb 100644 --- a/src/core/hle/service/vi/system_root_service.cpp +++ b/src/core/hle/service/vi/system_root_service.cpp | |||
| @@ -1,18 +1,21 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/cmif_serialization.h" | ||
| 5 | #include "core/hle/service/vi/application_display_service.h" | ||
| 6 | #include "core/hle/service/vi/service_creator.h" | ||
| 4 | #include "core/hle/service/vi/system_root_service.h" | 7 | #include "core/hle/service/vi/system_root_service.h" |
| 5 | #include "core/hle/service/vi/vi.h" | 8 | #include "core/hle/service/vi/vi.h" |
| 6 | #include "core/hle/service/vi/vi_types.h" | 9 | #include "core/hle/service/vi/vi_types.h" |
| 7 | 10 | ||
| 8 | namespace Service::VI { | 11 | namespace Service::VI { |
| 9 | 12 | ||
| 10 | ISystemRootService::ISystemRootService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, | 13 | ISystemRootService::ISystemRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger, |
| 11 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_) | 14 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) |
| 12 | : ServiceFramework{system_, "vi:s"}, nv_flinger{nv_flinger_}, | 15 | : ServiceFramework{system_, "vi:s"}, m_nvnflinger{nvnflinger}, m_hos_binder_driver_server{ |
| 13 | hos_binder_driver_server{hos_binder_driver_server_} { | 16 | hos_binder_driver_server} { |
| 14 | static const FunctionInfo functions[] = { | 17 | static const FunctionInfo functions[] = { |
| 15 | {1, &ISystemRootService::GetDisplayService, "GetDisplayService"}, | 18 | {1, C<&ISystemRootService::GetDisplayService>, "GetDisplayService"}, |
| 16 | {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, | 19 | {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, |
| 17 | }; | 20 | }; |
| 18 | RegisterHandlers(functions); | 21 | RegisterHandlers(functions); |
| @@ -20,11 +23,11 @@ ISystemRootService::ISystemRootService(Core::System& system_, Nvnflinger::Nvnfli | |||
| 20 | 23 | ||
| 21 | ISystemRootService::~ISystemRootService() = default; | 24 | ISystemRootService::~ISystemRootService() = default; |
| 22 | 25 | ||
| 23 | void ISystemRootService::GetDisplayService(HLERequestContext& ctx) { | 26 | Result ISystemRootService::GetDisplayService( |
| 27 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) { | ||
| 24 | LOG_DEBUG(Service_VI, "called"); | 28 | LOG_DEBUG(Service_VI, "called"); |
| 25 | 29 | R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_nvnflinger, | |
| 26 | detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server, | 30 | m_hos_binder_driver_server, Permission::System, policy)); |
| 27 | Permission::System); | ||
| 28 | } | 31 | } |
| 29 | 32 | ||
| 30 | } // namespace Service::VI | 33 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/system_root_service.h b/src/core/hle/service/vi/system_root_service.h index 5a8ecfd1a..2c547faa5 100644 --- a/src/core/hle/service/vi/system_root_service.h +++ b/src/core/hle/service/vi/system_root_service.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 6 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 7 | 8 | ||
| 8 | namespace Core { | 9 | namespace Core { |
| @@ -16,17 +17,22 @@ class Nvnflinger; | |||
| 16 | 17 | ||
| 17 | namespace Service::VI { | 18 | namespace Service::VI { |
| 18 | 19 | ||
| 20 | class IApplicationDisplayService; | ||
| 21 | enum class Policy : u32; | ||
| 22 | |||
| 19 | class ISystemRootService final : public ServiceFramework<ISystemRootService> { | 23 | class ISystemRootService final : public ServiceFramework<ISystemRootService> { |
| 20 | public: | 24 | public: |
| 21 | explicit ISystemRootService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, | 25 | explicit ISystemRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger, |
| 22 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_); | 26 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server); |
| 23 | ~ISystemRootService() override; | 27 | ~ISystemRootService() override; |
| 24 | 28 | ||
| 25 | private: | 29 | private: |
| 26 | void GetDisplayService(HLERequestContext& ctx); | 30 | Result GetDisplayService( |
| 31 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, | ||
| 32 | Policy policy); | ||
| 27 | 33 | ||
| 28 | Nvnflinger::Nvnflinger& nv_flinger; | 34 | Nvnflinger::Nvnflinger& m_nvnflinger; |
| 29 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server; | 35 | Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server; |
| 30 | }; | 36 | }; |
| 31 | 37 | ||
| 32 | } // namespace Service::VI | 38 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index bb84d27b3..304e589b7 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -1,49 +1,15 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/ipc_helpers.h" | ||
| 5 | #include "core/hle/service/server_manager.h" | 4 | #include "core/hle/service/server_manager.h" |
| 6 | #include "core/hle/service/vi/application_display_service.h" | 5 | #include "core/hle/service/vi/application_display_service.h" |
| 7 | #include "core/hle/service/vi/application_root_service.h" | 6 | #include "core/hle/service/vi/application_root_service.h" |
| 8 | #include "core/hle/service/vi/manager_root_service.h" | 7 | #include "core/hle/service/vi/manager_root_service.h" |
| 9 | #include "core/hle/service/vi/system_root_service.h" | 8 | #include "core/hle/service/vi/system_root_service.h" |
| 10 | #include "core/hle/service/vi/vi.h" | 9 | #include "core/hle/service/vi/vi.h" |
| 11 | #include "core/hle/service/vi/vi_results.h" | ||
| 12 | #include "core/hle/service/vi/vi_types.h" | ||
| 13 | 10 | ||
| 14 | namespace Service::VI { | 11 | namespace Service::VI { |
| 15 | 12 | ||
| 16 | static bool IsValidServiceAccess(Permission permission, Policy policy) { | ||
| 17 | if (permission == Permission::User) { | ||
| 18 | return policy == Policy::User; | ||
| 19 | } | ||
| 20 | |||
| 21 | if (permission == Permission::System || permission == Permission::Manager) { | ||
| 22 | return policy == Policy::User || policy == Policy::Compositor; | ||
| 23 | } | ||
| 24 | |||
| 25 | return false; | ||
| 26 | } | ||
| 27 | |||
| 28 | void detail::GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system, | ||
| 29 | Nvnflinger::Nvnflinger& nvnflinger, | ||
| 30 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server, | ||
| 31 | Permission permission) { | ||
| 32 | IPC::RequestParser rp{ctx}; | ||
| 33 | const auto policy = rp.PopEnum<Policy>(); | ||
| 34 | |||
| 35 | if (!IsValidServiceAccess(permission, policy)) { | ||
| 36 | LOG_ERROR(Service_VI, "Permission denied for policy {}", policy); | ||
| 37 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 38 | rb.Push(ResultPermissionDenied); | ||
| 39 | return; | ||
| 40 | } | ||
| 41 | |||
| 42 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 43 | rb.Push(ResultSuccess); | ||
| 44 | rb.PushIpcInterface<IApplicationDisplayService>(system, nvnflinger, hos_binder_driver_server); | ||
| 45 | } | ||
| 46 | |||
| 47 | void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger, | 13 | void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger, |
| 48 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) { | 14 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) { |
| 49 | auto server_manager = std::make_unique<ServerManager>(system); | 15 | auto server_manager = std::make_unique<ServerManager>(system); |
diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h index 799def36d..8e681370d 100644 --- a/src/core/hle/service/vi/vi.h +++ b/src/core/hle/service/vi/vi.h | |||
| @@ -7,10 +7,6 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service { | ||
| 11 | class HLERequestContext; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::Nvnflinger { | 10 | namespace Service::Nvnflinger { |
| 15 | class HosBinderDriverServer; | 11 | class HosBinderDriverServer; |
| 16 | class Nvnflinger; | 12 | class Nvnflinger; |
| @@ -18,15 +14,6 @@ class Nvnflinger; | |||
| 18 | 14 | ||
| 19 | namespace Service::VI { | 15 | namespace Service::VI { |
| 20 | 16 | ||
| 21 | enum class Permission; | ||
| 22 | |||
| 23 | namespace detail { | ||
| 24 | void GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system, | ||
| 25 | Nvnflinger::Nvnflinger& nv_flinger, | ||
| 26 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server, | ||
| 27 | Permission permission); | ||
| 28 | } // namespace detail | ||
| 29 | |||
| 30 | void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger, | 17 | void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger, |
| 31 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server); | 18 | Nvnflinger::HosBinderDriverServer& hos_binder_driver_server); |
| 32 | 19 | ||
diff --git a/src/core/hle/service/vi/vi_types.h b/src/core/hle/service/vi/vi_types.h index 0297676af..47fe2d11c 100644 --- a/src/core/hle/service/vi/vi_types.h +++ b/src/core/hle/service/vi/vi_types.h | |||
| @@ -23,7 +23,7 @@ enum class Permission { | |||
| 23 | 23 | ||
| 24 | /// A policy type that may be requested via GetDisplayService and | 24 | /// A policy type that may be requested via GetDisplayService and |
| 25 | /// GetDisplayServiceWithProxyNameExchange | 25 | /// GetDisplayServiceWithProxyNameExchange |
| 26 | enum class Policy { | 26 | enum class Policy : u32 { |
| 27 | User, | 27 | User, |
| 28 | Compositor, | 28 | Compositor, |
| 29 | }; | 29 | }; |