vi: rewrite IApplicationRootService, IManagerRootService, ISystemRootService
This commit is contained in:
parent
2e8c0e9247
commit
c448001d47
@ -969,6 +969,8 @@ add_library(core STATIC
|
||||
hle/service/vi/manager_display_service.h
|
||||
hle/service/vi/manager_root_service.cpp
|
||||
hle/service/vi/manager_root_service.h
|
||||
hle/service/vi/service_creator.cpp
|
||||
hle/service/vi/service_creator.h
|
||||
hle/service/vi/system_display_service.cpp
|
||||
hle/service/vi/system_display_service.h
|
||||
hle/service/vi/system_root_service.cpp
|
||||
|
@ -1,19 +1,22 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/vi/application_display_service.h"
|
||||
#include "core/hle/service/vi/application_root_service.h"
|
||||
#include "core/hle/service/vi/service_creator.h"
|
||||
#include "core/hle/service/vi/vi.h"
|
||||
#include "core/hle/service/vi/vi_types.h"
|
||||
|
||||
namespace Service::VI {
|
||||
|
||||
IApplicationRootService::IApplicationRootService(
|
||||
Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_)
|
||||
: ServiceFramework{system_, "vi:u"}, nv_flinger{nv_flinger_},
|
||||
hos_binder_driver_server{hos_binder_driver_server_} {
|
||||
Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server)
|
||||
: ServiceFramework{system_, "vi:u"}, m_nvnflinger{nvnflinger}, m_hos_binder_driver_server{
|
||||
hos_binder_driver_server} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IApplicationRootService::GetDisplayService, "GetDisplayService"},
|
||||
{0, C<&IApplicationRootService::GetDisplayService>, "GetDisplayService"},
|
||||
{1, nullptr, "GetDisplayServiceWithProxyNameExchange"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
@ -21,11 +24,11 @@ IApplicationRootService::IApplicationRootService(
|
||||
|
||||
IApplicationRootService::~IApplicationRootService() = default;
|
||||
|
||||
void IApplicationRootService::GetDisplayService(HLERequestContext& ctx) {
|
||||
Result IApplicationRootService::GetDisplayService(
|
||||
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
|
||||
LOG_DEBUG(Service_VI, "called");
|
||||
|
||||
detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server,
|
||||
Permission::User);
|
||||
R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_nvnflinger,
|
||||
m_hos_binder_driver_server, Permission::User, policy));
|
||||
}
|
||||
|
||||
} // namespace Service::VI
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
@ -16,17 +17,23 @@ class Nvnflinger;
|
||||
|
||||
namespace Service::VI {
|
||||
|
||||
class IApplicationDisplayService;
|
||||
enum class Policy : u32;
|
||||
|
||||
class IApplicationRootService final : public ServiceFramework<IApplicationRootService> {
|
||||
public:
|
||||
explicit IApplicationRootService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_);
|
||||
explicit IApplicationRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
|
||||
~IApplicationRootService() override;
|
||||
|
||||
private:
|
||||
void GetDisplayService(HLERequestContext& ctx);
|
||||
Result GetDisplayService(
|
||||
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service,
|
||||
Policy policy);
|
||||
|
||||
Nvnflinger::Nvnflinger& nv_flinger;
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server;
|
||||
private:
|
||||
Nvnflinger::Nvnflinger& m_nvnflinger;
|
||||
Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server;
|
||||
};
|
||||
|
||||
} // namespace Service::VI
|
||||
|
@ -1,19 +1,22 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/vi/application_display_service.h"
|
||||
#include "core/hle/service/vi/manager_root_service.h"
|
||||
#include "core/hle/service/vi/service_creator.h"
|
||||
#include "core/hle/service/vi/vi.h"
|
||||
#include "core/hle/service/vi/vi_types.h"
|
||||
|
||||
namespace Service::VI {
|
||||
|
||||
IManagerRootService::IManagerRootService(
|
||||
Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_)
|
||||
: ServiceFramework{system_, "vi:m"}, nv_flinger{nv_flinger_},
|
||||
hos_binder_driver_server{hos_binder_driver_server_} {
|
||||
Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server)
|
||||
: ServiceFramework{system_, "vi:m"}, m_nvnflinger{nvnflinger}, m_hos_binder_driver_server{
|
||||
hos_binder_driver_server} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{2, &IManagerRootService::GetDisplayService, "GetDisplayService"},
|
||||
{2, C<&IManagerRootService::GetDisplayService>, "GetDisplayService"},
|
||||
{3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
|
||||
{100, nullptr, "PrepareFatal"},
|
||||
{101, nullptr, "ShowFatal"},
|
||||
@ -25,11 +28,11 @@ IManagerRootService::IManagerRootService(
|
||||
|
||||
IManagerRootService::~IManagerRootService() = default;
|
||||
|
||||
void IManagerRootService::GetDisplayService(HLERequestContext& ctx) {
|
||||
Result IManagerRootService::GetDisplayService(
|
||||
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
|
||||
LOG_DEBUG(Service_VI, "called");
|
||||
|
||||
detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server,
|
||||
Permission::Manager);
|
||||
R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_nvnflinger,
|
||||
m_hos_binder_driver_server, Permission::Manager, policy));
|
||||
}
|
||||
|
||||
} // namespace Service::VI
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
@ -16,17 +17,22 @@ class Nvnflinger;
|
||||
|
||||
namespace Service::VI {
|
||||
|
||||
class IApplicationDisplayService;
|
||||
enum class Policy : u32;
|
||||
|
||||
class IManagerRootService final : public ServiceFramework<IManagerRootService> {
|
||||
public:
|
||||
explicit IManagerRootService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_);
|
||||
explicit IManagerRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
|
||||
~IManagerRootService() override;
|
||||
|
||||
private:
|
||||
void GetDisplayService(HLERequestContext& ctx);
|
||||
Result GetDisplayService(
|
||||
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service,
|
||||
Policy policy);
|
||||
|
||||
Nvnflinger::Nvnflinger& nv_flinger;
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server;
|
||||
Nvnflinger::Nvnflinger& m_nvnflinger;
|
||||
Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server;
|
||||
};
|
||||
|
||||
} // namespace Service::VI
|
||||
|
39
src/core/hle/service/vi/service_creator.cpp
Normal file
39
src/core/hle/service/vi/service_creator.cpp
Normal file
@ -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
|
33
src/core/hle/service/vi/service_creator.h
Normal file
33
src/core/hle/service/vi/service_creator.h
Normal file
@ -0,0 +1,33 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::Nvnflinger {
|
||||
class HosBinderDriverServer;
|
||||
class Nvnflinger;
|
||||
} // namespace Service::Nvnflinger
|
||||
|
||||
union Result;
|
||||
|
||||
namespace Service::VI {
|
||||
|
||||
class IApplicationDisplayService;
|
||||
enum class Permission;
|
||||
enum class Policy : u32;
|
||||
|
||||
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);
|
||||
|
||||
} // namespace Service::VI
|
@ -1,18 +1,21 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/vi/application_display_service.h"
|
||||
#include "core/hle/service/vi/service_creator.h"
|
||||
#include "core/hle/service/vi/system_root_service.h"
|
||||
#include "core/hle/service/vi/vi.h"
|
||||
#include "core/hle/service/vi/vi_types.h"
|
||||
|
||||
namespace Service::VI {
|
||||
|
||||
ISystemRootService::ISystemRootService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_)
|
||||
: ServiceFramework{system_, "vi:s"}, nv_flinger{nv_flinger_},
|
||||
hos_binder_driver_server{hos_binder_driver_server_} {
|
||||
ISystemRootService::ISystemRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server)
|
||||
: ServiceFramework{system_, "vi:s"}, m_nvnflinger{nvnflinger}, m_hos_binder_driver_server{
|
||||
hos_binder_driver_server} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{1, &ISystemRootService::GetDisplayService, "GetDisplayService"},
|
||||
{1, C<&ISystemRootService::GetDisplayService>, "GetDisplayService"},
|
||||
{3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
@ -20,11 +23,11 @@ ISystemRootService::ISystemRootService(Core::System& system_, Nvnflinger::Nvnfli
|
||||
|
||||
ISystemRootService::~ISystemRootService() = default;
|
||||
|
||||
void ISystemRootService::GetDisplayService(HLERequestContext& ctx) {
|
||||
Result ISystemRootService::GetDisplayService(
|
||||
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
|
||||
LOG_DEBUG(Service_VI, "called");
|
||||
|
||||
detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server,
|
||||
Permission::System);
|
||||
R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_nvnflinger,
|
||||
m_hos_binder_driver_server, Permission::System, policy));
|
||||
}
|
||||
|
||||
} // namespace Service::VI
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
@ -16,17 +17,22 @@ class Nvnflinger;
|
||||
|
||||
namespace Service::VI {
|
||||
|
||||
class IApplicationDisplayService;
|
||||
enum class Policy : u32;
|
||||
|
||||
class ISystemRootService final : public ServiceFramework<ISystemRootService> {
|
||||
public:
|
||||
explicit ISystemRootService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_);
|
||||
explicit ISystemRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
|
||||
~ISystemRootService() override;
|
||||
|
||||
private:
|
||||
void GetDisplayService(HLERequestContext& ctx);
|
||||
Result GetDisplayService(
|
||||
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service,
|
||||
Policy policy);
|
||||
|
||||
Nvnflinger::Nvnflinger& nv_flinger;
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server;
|
||||
Nvnflinger::Nvnflinger& m_nvnflinger;
|
||||
Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server;
|
||||
};
|
||||
|
||||
} // namespace Service::VI
|
||||
|
@ -1,49 +1,15 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/server_manager.h"
|
||||
#include "core/hle/service/vi/application_display_service.h"
|
||||
#include "core/hle/service/vi/application_root_service.h"
|
||||
#include "core/hle/service/vi/manager_root_service.h"
|
||||
#include "core/hle/service/vi/system_root_service.h"
|
||||
#include "core/hle/service/vi/vi.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;
|
||||
}
|
||||
|
||||
void detail::GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system,
|
||||
Nvnflinger::Nvnflinger& nvnflinger,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server,
|
||||
Permission permission) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto policy = rp.PopEnum<Policy>();
|
||||
|
||||
if (!IsValidServiceAccess(permission, policy)) {
|
||||
LOG_ERROR(Service_VI, "Permission denied for policy {}", policy);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultPermissionDenied);
|
||||
return;
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<IApplicationDisplayService>(system, nvnflinger, hos_binder_driver_server);
|
||||
}
|
||||
|
||||
void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) {
|
||||
auto server_manager = std::make_unique<ServerManager>(system);
|
||||
|
@ -7,10 +7,6 @@ namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service {
|
||||
class HLERequestContext;
|
||||
}
|
||||
|
||||
namespace Service::Nvnflinger {
|
||||
class HosBinderDriverServer;
|
||||
class Nvnflinger;
|
||||
@ -18,15 +14,6 @@ class Nvnflinger;
|
||||
|
||||
namespace Service::VI {
|
||||
|
||||
enum class Permission;
|
||||
|
||||
namespace detail {
|
||||
void GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system,
|
||||
Nvnflinger::Nvnflinger& nv_flinger,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server,
|
||||
Permission permission);
|
||||
} // namespace detail
|
||||
|
||||
void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
|
||||
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
|
||||
|
||||
|
@ -23,7 +23,7 @@ enum class Permission {
|
||||
|
||||
/// A policy type that may be requested via GetDisplayService and
|
||||
/// GetDisplayServiceWithProxyNameExchange
|
||||
enum class Policy {
|
||||
enum class Policy : u32 {
|
||||
User,
|
||||
Compositor,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user