summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2019-02-26 17:49:32 -0500
committerGravatar Lioncash2019-02-26 20:16:23 -0500
commit92ea1c32d608cd258c3fc077f5aaf953536d7f45 (patch)
treea5a8bfa8c071f01f4c8cee5c9a2983a097c93f6d /src
parentcore/ipc_helper: Allow popping all signed value types with RequestParser (diff)
downloadyuzu-92ea1c32d608cd258c3fc077f5aaf953536d7f45.tar.gz
yuzu-92ea1c32d608cd258c3fc077f5aaf953536d7f45.tar.xz
yuzu-92ea1c32d608cd258c3fc077f5aaf953536d7f45.zip
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).
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/vi/vi.cpp25
-rw-r--r--src/core/hle/service/vi/vi.h23
-rw-r--r--src/core/hle/service/vi/vi_m.cpp4
-rw-r--r--src/core/hle/service/vi/vi_s.cpp4
-rw-r--r--src/core/hle/service/vi/vi_u.cpp4
5 files changed, 49 insertions, 11 deletions
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 @@
34namespace Service::VI { 34namespace Service::VI {
35 35
36constexpr ResultCode ERR_OPERATION_FAILED{ErrorModule::VI, 1}; 36constexpr ResultCode ERR_OPERATION_FAILED{ErrorModule::VI, 1};
37constexpr ResultCode ERR_PERMISSION_DENIED{ErrorModule::VI, 5};
37constexpr ResultCode ERR_UNSUPPORTED{ErrorModule::VI, 6}; 38constexpr ResultCode ERR_UNSUPPORTED{ErrorModule::VI, 6};
38constexpr ResultCode ERR_NOT_FOUND{ErrorModule::VI, 7}; 39constexpr ResultCode ERR_NOT_FOUND{ErrorModule::VI, 7};
39 40
@@ -1203,8 +1204,30 @@ IApplicationDisplayService::IApplicationDisplayService(
1203 RegisterHandlers(functions); 1204 RegisterHandlers(functions);
1204} 1205}
1205 1206
1207static bool IsValidServiceAccess(Permission permission, Policy policy) {
1208 if (permission == Permission::User) {
1209 return policy == Policy::User;
1210 }
1211
1212 if (permission == Permission::System || permission == Permission::Manager) {
1213 return policy == Policy::User || policy == Policy::Compositor;
1214 }
1215
1216 return false;
1217}
1218
1206void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, 1219void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx,
1207 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) { 1220 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger,
1221 Permission permission) {
1222 IPC::RequestParser rp{ctx};
1223 const auto policy = rp.PopEnum<Policy>();
1224
1225 if (!IsValidServiceAccess(permission, policy)) {
1226 IPC::ResponseBuilder rb{ctx, 2};
1227 rb.Push(ERR_PERMISSION_DENIED);
1228 return;
1229 }
1230
1208 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 1231 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
1209 rb.Push(RESULT_SUCCESS); 1232 rb.Push(RESULT_SUCCESS);
1210 rb.PushIpcInterface<IApplicationDisplayService>(std::move(nv_flinger)); 1233 rb.PushIpcInterface<IApplicationDisplayService>(std::move(nv_flinger));
diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h
index c5682accc..6b66f8b81 100644
--- a/src/core/hle/service/vi/vi.h
+++ b/src/core/hle/service/vi/vi.h
@@ -20,10 +20,6 @@ class ServiceManager;
20} 20}
21 21
22namespace Service::VI { 22namespace Service::VI {
23namespace detail {
24void GetDisplayServiceImpl(Kernel::HLERequestContext& ctx,
25 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
26}
27 23
28enum class DisplayResolution : u32 { 24enum class DisplayResolution : u32 {
29 DockedWidth = 1920, 25 DockedWidth = 1920,
@@ -32,6 +28,25 @@ enum class DisplayResolution : u32 {
32 UndockedHeight = 720, 28 UndockedHeight = 720,
33}; 29};
34 30
31/// Permission level for a particular VI service instance
32enum class Permission {
33 User,
34 System,
35 Manager,
36};
37
38/// A policy type that may be requested via GetDisplayService and
39/// GetDisplayServiceWithProxyNameExchange
40enum class Policy {
41 User,
42 Compositor,
43};
44
45namespace detail {
46void GetDisplayServiceImpl(Kernel::HLERequestContext& ctx,
47 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger, Permission permission);
48} // namespace detail
49
35/// Registers all VI services with the specified service manager. 50/// Registers all VI services with the specified service manager.
36void InstallInterfaces(SM::ServiceManager& service_manager, 51void InstallInterfaces(SM::ServiceManager& service_manager,
37 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger); 52 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
diff --git a/src/core/hle/service/vi/vi_m.cpp b/src/core/hle/service/vi/vi_m.cpp
index 6e3e0bd8f..06070087f 100644
--- a/src/core/hle/service/vi/vi_m.cpp
+++ b/src/core/hle/service/vi/vi_m.cpp
@@ -20,9 +20,9 @@ VI_M::VI_M(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger)
20VI_M::~VI_M() = default; 20VI_M::~VI_M() = default;
21 21
22void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) { 22void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) {
23 LOG_WARNING(Service_VI, "(STUBBED) called"); 23 LOG_DEBUG(Service_VI, "called");
24 24
25 detail::GetDisplayServiceImpl(ctx, nv_flinger); 25 detail::GetDisplayServiceImpl(ctx, nv_flinger, Permission::Manager);
26} 26}
27 27
28} // namespace Service::VI 28} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi_s.cpp b/src/core/hle/service/vi/vi_s.cpp
index 6dd700eae..57c596cc4 100644
--- a/src/core/hle/service/vi/vi_s.cpp
+++ b/src/core/hle/service/vi/vi_s.cpp
@@ -20,9 +20,9 @@ VI_S::VI_S(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger)
20VI_S::~VI_S() = default; 20VI_S::~VI_S() = default;
21 21
22void VI_S::GetDisplayService(Kernel::HLERequestContext& ctx) { 22void VI_S::GetDisplayService(Kernel::HLERequestContext& ctx) {
23 LOG_WARNING(Service_VI, "(STUBBED) called"); 23 LOG_DEBUG(Service_VI, "called");
24 24
25 detail::GetDisplayServiceImpl(ctx, nv_flinger); 25 detail::GetDisplayServiceImpl(ctx, nv_flinger, Permission::System);
26} 26}
27 27
28} // namespace Service::VI 28} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi_u.cpp b/src/core/hle/service/vi/vi_u.cpp
index ef09a5df5..9d5ceb608 100644
--- a/src/core/hle/service/vi/vi_u.cpp
+++ b/src/core/hle/service/vi/vi_u.cpp
@@ -19,9 +19,9 @@ VI_U::VI_U(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger)
19VI_U::~VI_U() = default; 19VI_U::~VI_U() = default;
20 20
21void VI_U::GetDisplayService(Kernel::HLERequestContext& ctx) { 21void VI_U::GetDisplayService(Kernel::HLERequestContext& ctx) {
22 LOG_WARNING(Service_VI, "(STUBBED) called"); 22 LOG_DEBUG(Service_VI, "called");
23 23
24 detail::GetDisplayServiceImpl(ctx, nv_flinger); 24 detail::GetDisplayServiceImpl(ctx, nv_flinger, Permission::User);
25} 25}
26 26
27} // namespace Service::VI 27} // namespace Service::VI