diff options
author | Liam <byteslice@airmail.cc> | 2024-02-14 05:53:56 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2024-02-14 18:03:32 +0100 |
commit | c448001d4766a4959b4c1468b5a9de6dfe3d9bc4 (patch) | |
tree | e0c35c83cda5b104faa7c8f3757fbe28fe8b3f36 /src/core/hle/service/vi/service_creator.cpp | |
parent | vi: split into implementation files (diff) | |
download | yuzu-c448001d4766a4959b4c1468b5a9de6dfe3d9bc4.tar yuzu-c448001d4766a4959b4c1468b5a9de6dfe3d9bc4.tar.gz yuzu-c448001d4766a4959b4c1468b5a9de6dfe3d9bc4.tar.bz2 yuzu-c448001d4766a4959b4c1468b5a9de6dfe3d9bc4.tar.lz yuzu-c448001d4766a4959b4c1468b5a9de6dfe3d9bc4.tar.xz yuzu-c448001d4766a4959b4c1468b5a9de6dfe3d9bc4.tar.zst yuzu-c448001d4766a4959b4c1468b5a9de6dfe3d9bc4.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/vi/service_creator.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
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 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/vi/application_display_service.h" +#include "core/hle/service/vi/service_creator.h" +#include "core/hle/service/vi/vi_results.h" +#include "core/hle/service/vi/vi_types.h" + +namespace Service::VI { + +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; +} + +Result GetApplicationDisplayService( + std::shared_ptr<IApplicationDisplayService>* out_application_display_service, + Core::System& system, Nvnflinger::Nvnflinger& nvnflinger, + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server, Permission permission, + Policy policy) { + + if (!IsValidServiceAccess(permission, policy)) { + LOG_ERROR(Service_VI, "Permission denied for policy {}", policy); + R_THROW(ResultPermissionDenied); + } + + *out_application_display_service = + std::make_shared<IApplicationDisplayService>(system, nvnflinger, hos_binder_driver_server); + R_SUCCEED(); +} + +} // namespace Service::VI |