summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/core.cpp9
-rw-r--r--src/core/hle/service/am/am.cpp17
-rw-r--r--src/core/hle/service/am/am.h9
-rw-r--r--src/core/hle/service/am/applet_ae.cpp21
-rw-r--r--src/core/hle/service/am/applet_ae.h4
-rw-r--r--src/core/hle/service/am/applet_oe.cpp14
-rw-r--r--src/core/hle/service/am/applet_oe.h4
-rw-r--r--src/core/hle/service/service.cpp20
-rw-r--r--src/core/hle/service/service.h21
-rw-r--r--src/core/hle/service/vi/vi.cpp57
-rw-r--r--src/core/hle/service/vi/vi.h7
-rw-r--r--src/core/hle/service/vi/vi_m.cpp3
-rw-r--r--src/core/hle/service/vi/vi_m.h4
-rw-r--r--src/core/hle/service/vi/vi_s.cpp3
-rw-r--r--src/core/hle/service/vi/vi_s.h4
-rw-r--r--src/core/hle/service/vi/vi_u.cpp3
-rw-r--r--src/core/hle/service/vi/vi_u.h4
17 files changed, 104 insertions, 100 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 5accdc783..1aa477a29 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -187,7 +187,7 @@ struct System::Impl {
187 187
188 service_manager = std::make_shared<Service::SM::ServiceManager>(kernel); 188 service_manager = std::make_shared<Service::SM::ServiceManager>(kernel);
189 189
190 Service::Init(service_manager, system); 190 services = std::make_unique<Service::Services>(service_manager, system);
191 GDBStub::DeferStart(); 191 GDBStub::DeferStart();
192 192
193 interrupt_manager = std::make_unique<Core::Hardware::InterruptManager>(system); 193 interrupt_manager = std::make_unique<Core::Hardware::InterruptManager>(system);
@@ -296,7 +296,7 @@ struct System::Impl {
296 296
297 // Shutdown emulation session 297 // Shutdown emulation session
298 GDBStub::Shutdown(); 298 GDBStub::Shutdown();
299 Service::Shutdown(); 299 services.reset();
300 service_manager.reset(); 300 service_manager.reset();
301 cheat_engine.reset(); 301 cheat_engine.reset();
302 telemetry_session.reset(); 302 telemetry_session.reset();
@@ -306,8 +306,8 @@ struct System::Impl {
306 cpu_manager.Shutdown(); 306 cpu_manager.Shutdown();
307 307
308 // Shutdown kernel and core timing 308 // Shutdown kernel and core timing
309 kernel.Shutdown();
310 core_timing.Shutdown(); 309 core_timing.Shutdown();
310 kernel.Shutdown();
311 311
312 // Close app loader 312 // Close app loader
313 app_loader.reset(); 313 app_loader.reset();
@@ -398,6 +398,9 @@ struct System::Impl {
398 /// Service manager 398 /// Service manager
399 std::shared_ptr<Service::SM::ServiceManager> service_manager; 399 std::shared_ptr<Service::SM::ServiceManager> service_manager;
400 400
401 /// Services
402 std::unique_ptr<Service::Services> services;
403
401 /// Telemetry session for this emulation session 404 /// Telemetry session for this emulation session
402 std::unique_ptr<Core::TelemetrySession> telemetry_session; 405 std::unique_ptr<Core::TelemetrySession> telemetry_session;
403 406
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 63421b963..55e428456 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -246,9 +246,8 @@ IDebugFunctions::IDebugFunctions() : ServiceFramework{"IDebugFunctions"} {
246 246
247IDebugFunctions::~IDebugFunctions() = default; 247IDebugFunctions::~IDebugFunctions() = default;
248 248
249ISelfController::ISelfController(Core::System& system, 249ISelfController::ISelfController(Core::System& system, NVFlinger::NVFlinger& nvflinger)
250 std::shared_ptr<NVFlinger::NVFlinger> nvflinger) 250 : ServiceFramework("ISelfController"), system(system), nvflinger(nvflinger) {
251 : ServiceFramework("ISelfController"), system(system), nvflinger(std::move(nvflinger)) {
252 // clang-format off 251 // clang-format off
253 static const FunctionInfo functions[] = { 252 static const FunctionInfo functions[] = {
254 {0, &ISelfController::Exit, "Exit"}, 253 {0, &ISelfController::Exit, "Exit"},
@@ -458,8 +457,8 @@ void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx)
458 457
459 // TODO(Subv): Find out how AM determines the display to use, for now just 458 // TODO(Subv): Find out how AM determines the display to use, for now just
460 // create the layer in the Default display. 459 // create the layer in the Default display.
461 const auto display_id = nvflinger->OpenDisplay("Default"); 460 const auto display_id = nvflinger.OpenDisplay("Default");
462 const auto layer_id = nvflinger->CreateLayer(*display_id); 461 const auto layer_id = nvflinger.CreateLayer(*display_id);
463 462
464 IPC::ResponseBuilder rb{ctx, 4}; 463 IPC::ResponseBuilder rb{ctx, 4};
465 rb.Push(RESULT_SUCCESS); 464 rb.Push(RESULT_SUCCESS);
@@ -476,8 +475,8 @@ void ISelfController::CreateManagedDisplaySeparableLayer(Kernel::HLERequestConte
476 // Outputting 1 layer id instead of the expected 2 has not been observed to cause any adverse 475 // Outputting 1 layer id instead of the expected 2 has not been observed to cause any adverse
477 // side effects. 476 // side effects.
478 // TODO: Support multiple layers 477 // TODO: Support multiple layers
479 const auto display_id = nvflinger->OpenDisplay("Default"); 478 const auto display_id = nvflinger.OpenDisplay("Default");
480 const auto layer_id = nvflinger->CreateLayer(*display_id); 479 const auto layer_id = nvflinger.CreateLayer(*display_id);
481 480
482 IPC::ResponseBuilder rb{ctx, 4}; 481 IPC::ResponseBuilder rb{ctx, 4};
483 rb.Push(RESULT_SUCCESS); 482 rb.Push(RESULT_SUCCESS);
@@ -1586,8 +1585,8 @@ void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERe
1586 rb.PushCopyObjects(friend_invitation_storage_channel_event.readable); 1585 rb.PushCopyObjects(friend_invitation_storage_channel_event.readable);
1587} 1586}
1588 1587
1589void InstallInterfaces(SM::ServiceManager& service_manager, 1588void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger,
1590 std::shared_ptr<NVFlinger::NVFlinger> nvflinger, Core::System& system) { 1589 Core::System& system) {
1591 auto message_queue = std::make_shared<AppletMessageQueue>(system.Kernel()); 1590 auto message_queue = std::make_shared<AppletMessageQueue>(system.Kernel());
1592 // Needed on game boot 1591 // Needed on game boot
1593 message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged); 1592 message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h
index bcc06affe..09c2d05bc 100644
--- a/src/core/hle/service/am/am.h
+++ b/src/core/hle/service/am/am.h
@@ -121,8 +121,7 @@ public:
121 121
122class ISelfController final : public ServiceFramework<ISelfController> { 122class ISelfController final : public ServiceFramework<ISelfController> {
123public: 123public:
124 explicit ISelfController(Core::System& system_, 124 explicit ISelfController(Core::System& system_, NVFlinger::NVFlinger& nvflinger_);
125 std::shared_ptr<NVFlinger::NVFlinger> nvflinger_);
126 ~ISelfController() override; 125 ~ISelfController() override;
127 126
128private: 127private:
@@ -156,7 +155,7 @@ private:
156 }; 155 };
157 156
158 Core::System& system; 157 Core::System& system;
159 std::shared_ptr<NVFlinger::NVFlinger> nvflinger; 158 NVFlinger::NVFlinger& nvflinger;
160 Kernel::EventPair launchable_event; 159 Kernel::EventPair launchable_event;
161 Kernel::EventPair accumulated_suspended_tick_changed_event; 160 Kernel::EventPair accumulated_suspended_tick_changed_event;
162 161
@@ -332,7 +331,7 @@ public:
332}; 331};
333 332
334/// Registers all AM services with the specified service manager. 333/// Registers all AM services with the specified service manager.
335void InstallInterfaces(SM::ServiceManager& service_manager, 334void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger,
336 std::shared_ptr<NVFlinger::NVFlinger> nvflinger, Core::System& system); 335 Core::System& system);
337 336
338} // namespace Service::AM 337} // namespace Service::AM
diff --git a/src/core/hle/service/am/applet_ae.cpp b/src/core/hle/service/am/applet_ae.cpp
index be23ca747..7de506b70 100644
--- a/src/core/hle/service/am/applet_ae.cpp
+++ b/src/core/hle/service/am/applet_ae.cpp
@@ -13,10 +13,10 @@ namespace Service::AM {
13 13
14class ILibraryAppletProxy final : public ServiceFramework<ILibraryAppletProxy> { 14class ILibraryAppletProxy final : public ServiceFramework<ILibraryAppletProxy> {
15public: 15public:
16 explicit ILibraryAppletProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, 16 explicit ILibraryAppletProxy(NVFlinger::NVFlinger& nvflinger,
17 std::shared_ptr<AppletMessageQueue> msg_queue, 17 std::shared_ptr<AppletMessageQueue> msg_queue,
18 Core::System& system) 18 Core::System& system)
19 : ServiceFramework("ILibraryAppletProxy"), nvflinger(std::move(nvflinger)), 19 : ServiceFramework("ILibraryAppletProxy"), nvflinger(nvflinger),
20 msg_queue(std::move(msg_queue)), system(system) { 20 msg_queue(std::move(msg_queue)), system(system) {
21 // clang-format off 21 // clang-format off
22 static const FunctionInfo functions[] = { 22 static const FunctionInfo functions[] = {
@@ -109,16 +109,16 @@ private:
109 rb.PushIpcInterface<IApplicationFunctions>(system); 109 rb.PushIpcInterface<IApplicationFunctions>(system);
110 } 110 }
111 111
112 std::shared_ptr<NVFlinger::NVFlinger> nvflinger; 112 NVFlinger::NVFlinger& nvflinger;
113 std::shared_ptr<AppletMessageQueue> msg_queue; 113 std::shared_ptr<AppletMessageQueue> msg_queue;
114 Core::System& system; 114 Core::System& system;
115}; 115};
116 116
117class ISystemAppletProxy final : public ServiceFramework<ISystemAppletProxy> { 117class ISystemAppletProxy final : public ServiceFramework<ISystemAppletProxy> {
118public: 118public:
119 explicit ISystemAppletProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, 119 explicit ISystemAppletProxy(NVFlinger::NVFlinger& nvflinger,
120 std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system) 120 std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system)
121 : ServiceFramework("ISystemAppletProxy"), nvflinger(std::move(nvflinger)), 121 : ServiceFramework("ISystemAppletProxy"), nvflinger(nvflinger),
122 msg_queue(std::move(msg_queue)), system(system) { 122 msg_queue(std::move(msg_queue)), system(system) {
123 // clang-format off 123 // clang-format off
124 static const FunctionInfo functions[] = { 124 static const FunctionInfo functions[] = {
@@ -220,7 +220,8 @@ private:
220 rb.Push(RESULT_SUCCESS); 220 rb.Push(RESULT_SUCCESS);
221 rb.PushIpcInterface<IApplicationCreator>(); 221 rb.PushIpcInterface<IApplicationCreator>();
222 } 222 }
223 std::shared_ptr<NVFlinger::NVFlinger> nvflinger; 223
224 NVFlinger::NVFlinger& nvflinger;
224 std::shared_ptr<AppletMessageQueue> msg_queue; 225 std::shared_ptr<AppletMessageQueue> msg_queue;
225 Core::System& system; 226 Core::System& system;
226}; 227};
@@ -249,10 +250,10 @@ void AppletAE::OpenLibraryAppletProxyOld(Kernel::HLERequestContext& ctx) {
249 rb.PushIpcInterface<ILibraryAppletProxy>(nvflinger, msg_queue, system); 250 rb.PushIpcInterface<ILibraryAppletProxy>(nvflinger, msg_queue, system);
250} 251}
251 252
252AppletAE::AppletAE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, 253AppletAE::AppletAE(NVFlinger::NVFlinger& nvflinger, std::shared_ptr<AppletMessageQueue> msg_queue,
253 std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system) 254 Core::System& system)
254 : ServiceFramework("appletAE"), nvflinger(std::move(nvflinger)), 255 : ServiceFramework("appletAE"), nvflinger(nvflinger), msg_queue(std::move(msg_queue)),
255 msg_queue(std::move(msg_queue)), system(system) { 256 system(system) {
256 // clang-format off 257 // clang-format off
257 static const FunctionInfo functions[] = { 258 static const FunctionInfo functions[] = {
258 {100, &AppletAE::OpenSystemAppletProxy, "OpenSystemAppletProxy"}, 259 {100, &AppletAE::OpenSystemAppletProxy, "OpenSystemAppletProxy"},
diff --git a/src/core/hle/service/am/applet_ae.h b/src/core/hle/service/am/applet_ae.h
index 2e3e45915..761844a1f 100644
--- a/src/core/hle/service/am/applet_ae.h
+++ b/src/core/hle/service/am/applet_ae.h
@@ -23,7 +23,7 @@ class AppletMessageQueue;
23 23
24class AppletAE final : public ServiceFramework<AppletAE> { 24class AppletAE final : public ServiceFramework<AppletAE> {
25public: 25public:
26 explicit AppletAE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, 26 explicit AppletAE(NVFlinger::NVFlinger& nvflinger,
27 std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system); 27 std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system);
28 ~AppletAE() override; 28 ~AppletAE() override;
29 29
@@ -34,7 +34,7 @@ private:
34 void OpenLibraryAppletProxy(Kernel::HLERequestContext& ctx); 34 void OpenLibraryAppletProxy(Kernel::HLERequestContext& ctx);
35 void OpenLibraryAppletProxyOld(Kernel::HLERequestContext& ctx); 35 void OpenLibraryAppletProxyOld(Kernel::HLERequestContext& ctx);
36 36
37 std::shared_ptr<NVFlinger::NVFlinger> nvflinger; 37 NVFlinger::NVFlinger& nvflinger;
38 std::shared_ptr<AppletMessageQueue> msg_queue; 38 std::shared_ptr<AppletMessageQueue> msg_queue;
39 Core::System& system; 39 Core::System& system;
40}; 40};
diff --git a/src/core/hle/service/am/applet_oe.cpp b/src/core/hle/service/am/applet_oe.cpp
index a2ffaa440..7bed86ec4 100644
--- a/src/core/hle/service/am/applet_oe.cpp
+++ b/src/core/hle/service/am/applet_oe.cpp
@@ -12,9 +12,9 @@ namespace Service::AM {
12 12
13class IApplicationProxy final : public ServiceFramework<IApplicationProxy> { 13class IApplicationProxy final : public ServiceFramework<IApplicationProxy> {
14public: 14public:
15 explicit IApplicationProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, 15 explicit IApplicationProxy(NVFlinger::NVFlinger& nvflinger,
16 std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system) 16 std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system)
17 : ServiceFramework("IApplicationProxy"), nvflinger(std::move(nvflinger)), 17 : ServiceFramework("IApplicationProxy"), nvflinger(nvflinger),
18 msg_queue(std::move(msg_queue)), system(system) { 18 msg_queue(std::move(msg_queue)), system(system) {
19 // clang-format off 19 // clang-format off
20 static const FunctionInfo functions[] = { 20 static const FunctionInfo functions[] = {
@@ -98,7 +98,7 @@ private:
98 rb.PushIpcInterface<IApplicationFunctions>(system); 98 rb.PushIpcInterface<IApplicationFunctions>(system);
99 } 99 }
100 100
101 std::shared_ptr<NVFlinger::NVFlinger> nvflinger; 101 NVFlinger::NVFlinger& nvflinger;
102 std::shared_ptr<AppletMessageQueue> msg_queue; 102 std::shared_ptr<AppletMessageQueue> msg_queue;
103 Core::System& system; 103 Core::System& system;
104}; 104};
@@ -111,10 +111,10 @@ void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) {
111 rb.PushIpcInterface<IApplicationProxy>(nvflinger, msg_queue, system); 111 rb.PushIpcInterface<IApplicationProxy>(nvflinger, msg_queue, system);
112} 112}
113 113
114AppletOE::AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, 114AppletOE::AppletOE(NVFlinger::NVFlinger& nvflinger, std::shared_ptr<AppletMessageQueue> msg_queue,
115 std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system) 115 Core::System& system)
116 : ServiceFramework("appletOE"), nvflinger(std::move(nvflinger)), 116 : ServiceFramework("appletOE"), nvflinger(nvflinger), msg_queue(std::move(msg_queue)),
117 msg_queue(std::move(msg_queue)), system(system) { 117 system(system) {
118 static const FunctionInfo functions[] = { 118 static const FunctionInfo functions[] = {
119 {0, &AppletOE::OpenApplicationProxy, "OpenApplicationProxy"}, 119 {0, &AppletOE::OpenApplicationProxy, "OpenApplicationProxy"},
120 }; 120 };
diff --git a/src/core/hle/service/am/applet_oe.h b/src/core/hle/service/am/applet_oe.h
index 758da792d..88906d354 100644
--- a/src/core/hle/service/am/applet_oe.h
+++ b/src/core/hle/service/am/applet_oe.h
@@ -23,7 +23,7 @@ class AppletMessageQueue;
23 23
24class AppletOE final : public ServiceFramework<AppletOE> { 24class AppletOE final : public ServiceFramework<AppletOE> {
25public: 25public:
26 explicit AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, 26 explicit AppletOE(NVFlinger::NVFlinger& nvflinger,
27 std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system); 27 std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system);
28 ~AppletOE() override; 28 ~AppletOE() override;
29 29
@@ -32,7 +32,7 @@ public:
32private: 32private:
33 void OpenApplicationProxy(Kernel::HLERequestContext& ctx); 33 void OpenApplicationProxy(Kernel::HLERequestContext& ctx);
34 34
35 std::shared_ptr<NVFlinger::NVFlinger> nvflinger; 35 NVFlinger::NVFlinger& nvflinger;
36 std::shared_ptr<AppletMessageQueue> msg_queue; 36 std::shared_ptr<AppletMessageQueue> msg_queue;
37 Core::System& system; 37 Core::System& system;
38}; 38};
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index fbfda2d5b..fb4979af2 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -188,17 +188,19 @@ ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& co
188 return RESULT_SUCCESS; 188 return RESULT_SUCCESS;
189} 189}
190 190
191/// Initialize ServiceManager 191/// Initialize Services
192void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) { 192Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system)
193 : nv_flinger{std::make_unique<NVFlinger::NVFlinger>(system)} {
194
193 // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it 195 // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it
194 // here and pass it into the respective InstallInterfaces functions. 196 // here and pass it into the respective InstallInterfaces functions.
195 auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(system); 197
196 system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false); 198 system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false);
197 199
198 SM::ServiceManager::InstallInterfaces(sm, system.Kernel()); 200 SM::ServiceManager::InstallInterfaces(sm, system.Kernel());
199 201
200 Account::InstallInterfaces(system); 202 Account::InstallInterfaces(system);
201 AM::InstallInterfaces(*sm, nv_flinger, system); 203 AM::InstallInterfaces(*sm, *nv_flinger, system);
202 AOC::InstallInterfaces(*sm, system); 204 AOC::InstallInterfaces(*sm, system);
203 APM::InstallInterfaces(system); 205 APM::InstallInterfaces(system);
204 Audio::InstallInterfaces(*sm, system); 206 Audio::InstallInterfaces(*sm, system);
@@ -246,14 +248,10 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) {
246 SSL::InstallInterfaces(*sm); 248 SSL::InstallInterfaces(*sm);
247 Time::InstallInterfaces(system); 249 Time::InstallInterfaces(system);
248 USB::InstallInterfaces(*sm); 250 USB::InstallInterfaces(*sm);
249 VI::InstallInterfaces(*sm, nv_flinger); 251 VI::InstallInterfaces(*sm, *nv_flinger);
250 WLAN::InstallInterfaces(*sm); 252 WLAN::InstallInterfaces(*sm);
251
252 LOG_DEBUG(Service, "initialized OK");
253} 253}
254 254
255/// Shutdown ServiceManager 255Services::~Services() = default;
256void Shutdown() { 256
257 LOG_DEBUG(Service, "shutdown OK");
258}
259} // namespace Service 257} // namespace Service
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index a01ef3353..ed4792289 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -29,7 +29,11 @@ namespace Service {
29 29
30namespace FileSystem { 30namespace FileSystem {
31class FileSystemController; 31class FileSystemController;
32} // namespace FileSystem 32}
33
34namespace NVFlinger {
35class NVFlinger;
36}
33 37
34namespace SM { 38namespace SM {
35class ServiceManager; 39class ServiceManager;
@@ -181,10 +185,17 @@ private:
181 } 185 }
182}; 186};
183 187
184/// Initialize ServiceManager 188/**
185void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system); 189 * The purpose of this class is to own any objects that need to be shared across the other service
190 * implementations. Will be torn down when the global system instance is shutdown.
191 */
192class Services final {
193public:
194 explicit Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system);
195 ~Services();
186 196
187/// Shutdown ServiceManager 197private:
188void Shutdown(); 198 std::unique_ptr<NVFlinger::NVFlinger> nv_flinger;
199};
189 200
190} // namespace Service 201} // namespace Service
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 55e00dd93..86bd604f4 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -492,8 +492,8 @@ private:
492 492
493class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> { 493class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> {
494public: 494public:
495 explicit IHOSBinderDriver(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) 495 explicit IHOSBinderDriver(NVFlinger::NVFlinger& nv_flinger)
496 : ServiceFramework("IHOSBinderDriver"), nv_flinger(std::move(nv_flinger)) { 496 : ServiceFramework("IHOSBinderDriver"), nv_flinger(nv_flinger) {
497 static const FunctionInfo functions[] = { 497 static const FunctionInfo functions[] = {
498 {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, 498 {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"},
499 {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"}, 499 {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"},
@@ -530,8 +530,8 @@ private:
530 LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id, 530 LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id,
531 static_cast<u32>(transaction), flags); 531 static_cast<u32>(transaction), flags);
532 532
533 const auto guard = nv_flinger->Lock(); 533 const auto guard = nv_flinger.Lock();
534 auto& buffer_queue = nv_flinger->FindBufferQueue(id); 534 auto& buffer_queue = nv_flinger.FindBufferQueue(id);
535 535
536 switch (transaction) { 536 switch (transaction) {
537 case TransactionId::Connect: { 537 case TransactionId::Connect: {
@@ -570,8 +570,8 @@ private:
570 [=, this](std::shared_ptr<Kernel::Thread> thread, 570 [=, this](std::shared_ptr<Kernel::Thread> thread,
571 Kernel::HLERequestContext& ctx, Kernel::ThreadWakeupReason reason) { 571 Kernel::HLERequestContext& ctx, Kernel::ThreadWakeupReason reason) {
572 // Repeat TransactParcel DequeueBuffer when a buffer is available 572 // Repeat TransactParcel DequeueBuffer when a buffer is available
573 const auto guard = nv_flinger->Lock(); 573 const auto guard = nv_flinger.Lock();
574 auto& buffer_queue = nv_flinger->FindBufferQueue(id); 574 auto& buffer_queue = nv_flinger.FindBufferQueue(id);
575 auto result = buffer_queue.DequeueBuffer(width, height); 575 auto result = buffer_queue.DequeueBuffer(width, height);
576 ASSERT_MSG(result != std::nullopt, "Could not dequeue buffer."); 576 ASSERT_MSG(result != std::nullopt, "Could not dequeue buffer.");
577 577
@@ -676,7 +676,7 @@ private:
676 676
677 LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown); 677 LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown);
678 678
679 const auto& buffer_queue = nv_flinger->FindBufferQueue(id); 679 const auto& buffer_queue = nv_flinger.FindBufferQueue(id);
680 680
681 // TODO(Subv): Find out what this actually is. 681 // TODO(Subv): Find out what this actually is.
682 IPC::ResponseBuilder rb{ctx, 2, 1}; 682 IPC::ResponseBuilder rb{ctx, 2, 1};
@@ -684,8 +684,8 @@ private:
684 rb.PushCopyObjects(buffer_queue.GetBufferWaitEvent()); 684 rb.PushCopyObjects(buffer_queue.GetBufferWaitEvent());
685 } 685 }
686 686
687 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger; 687 NVFlinger::NVFlinger& nv_flinger;
688}; // namespace VI 688};
689 689
690class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> { 690class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> {
691public: 691public:
@@ -790,8 +790,8 @@ private:
790 790
791class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> { 791class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> {
792public: 792public:
793 explicit IManagerDisplayService(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) 793 explicit IManagerDisplayService(NVFlinger::NVFlinger& nv_flinger)
794 : ServiceFramework("IManagerDisplayService"), nv_flinger(std::move(nv_flinger)) { 794 : ServiceFramework("IManagerDisplayService"), nv_flinger(nv_flinger) {
795 // clang-format off 795 // clang-format off
796 static const FunctionInfo functions[] = { 796 static const FunctionInfo functions[] = {
797 {200, nullptr, "AllocateProcessHeapBlock"}, 797 {200, nullptr, "AllocateProcessHeapBlock"},
@@ -893,7 +893,7 @@ private:
893 "(STUBBED) called. unknown=0x{:08X}, display=0x{:016X}, aruid=0x{:016X}", 893 "(STUBBED) called. unknown=0x{:08X}, display=0x{:016X}, aruid=0x{:016X}",
894 unknown, display, aruid); 894 unknown, display, aruid);
895 895
896 const auto layer_id = nv_flinger->CreateLayer(display); 896 const auto layer_id = nv_flinger.CreateLayer(display);
897 if (!layer_id) { 897 if (!layer_id) {
898 LOG_ERROR(Service_VI, "Layer not found! display=0x{:016X}", display); 898 LOG_ERROR(Service_VI, "Layer not found! display=0x{:016X}", display);
899 IPC::ResponseBuilder rb{ctx, 2}; 899 IPC::ResponseBuilder rb{ctx, 2};
@@ -930,12 +930,12 @@ private:
930 rb.Push(RESULT_SUCCESS); 930 rb.Push(RESULT_SUCCESS);
931 } 931 }
932 932
933 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger; 933 NVFlinger::NVFlinger& nv_flinger;
934}; 934};
935 935
936class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> { 936class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> {
937public: 937public:
938 explicit IApplicationDisplayService(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger); 938 explicit IApplicationDisplayService(NVFlinger::NVFlinger& nv_flinger);
939 939
940private: 940private:
941 enum class ConvertedScaleMode : u64 { 941 enum class ConvertedScaleMode : u64 {
@@ -1010,7 +1010,7 @@ private:
1010 1010
1011 ASSERT_MSG(name == "Default", "Non-default displays aren't supported yet"); 1011 ASSERT_MSG(name == "Default", "Non-default displays aren't supported yet");
1012 1012
1013 const auto display_id = nv_flinger->OpenDisplay(name); 1013 const auto display_id = nv_flinger.OpenDisplay(name);
1014 if (!display_id) { 1014 if (!display_id) {
1015 LOG_ERROR(Service_VI, "Display not found! display_name={}", name); 1015 LOG_ERROR(Service_VI, "Display not found! display_name={}", name);
1016 IPC::ResponseBuilder rb{ctx, 2}; 1016 IPC::ResponseBuilder rb{ctx, 2};
@@ -1110,7 +1110,7 @@ private:
1110 1110
1111 LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}, aruid=0x{:016X}", layer_id, aruid); 1111 LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}, aruid=0x{:016X}", layer_id, aruid);
1112 1112
1113 const auto display_id = nv_flinger->OpenDisplay(display_name); 1113 const auto display_id = nv_flinger.OpenDisplay(display_name);
1114 if (!display_id) { 1114 if (!display_id) {
1115 LOG_ERROR(Service_VI, "Layer not found! layer_id={}", layer_id); 1115 LOG_ERROR(Service_VI, "Layer not found! layer_id={}", layer_id);
1116 IPC::ResponseBuilder rb{ctx, 2}; 1116 IPC::ResponseBuilder rb{ctx, 2};
@@ -1118,7 +1118,7 @@ private:
1118 return; 1118 return;
1119 } 1119 }
1120 1120
1121 const auto buffer_queue_id = nv_flinger->FindBufferQueueId(*display_id, layer_id); 1121 const auto buffer_queue_id = nv_flinger.FindBufferQueueId(*display_id, layer_id);
1122 if (!buffer_queue_id) { 1122 if (!buffer_queue_id) {
1123 LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", *display_id); 1123 LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", *display_id);
1124 IPC::ResponseBuilder rb{ctx, 2}; 1124 IPC::ResponseBuilder rb{ctx, 2};
@@ -1138,7 +1138,7 @@ private:
1138 1138
1139 LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}", layer_id); 1139 LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}", layer_id);
1140 1140
1141 nv_flinger->CloseLayer(layer_id); 1141 nv_flinger.CloseLayer(layer_id);
1142 1142
1143 IPC::ResponseBuilder rb{ctx, 2}; 1143 IPC::ResponseBuilder rb{ctx, 2};
1144 rb.Push(RESULT_SUCCESS); 1144 rb.Push(RESULT_SUCCESS);
@@ -1154,7 +1154,7 @@ private:
1154 1154
1155 // TODO(Subv): What's the difference between a Stray and a Managed layer? 1155 // TODO(Subv): What's the difference between a Stray and a Managed layer?
1156 1156
1157 const auto layer_id = nv_flinger->CreateLayer(display_id); 1157 const auto layer_id = nv_flinger.CreateLayer(display_id);
1158 if (!layer_id) { 1158 if (!layer_id) {
1159 LOG_ERROR(Service_VI, "Layer not found! layer_id={}", *layer_id); 1159 LOG_ERROR(Service_VI, "Layer not found! layer_id={}", *layer_id);
1160 IPC::ResponseBuilder rb{ctx, 2}; 1160 IPC::ResponseBuilder rb{ctx, 2};
@@ -1162,7 +1162,7 @@ private:
1162 return; 1162 return;
1163 } 1163 }
1164 1164
1165 const auto buffer_queue_id = nv_flinger->FindBufferQueueId(display_id, *layer_id); 1165 const auto buffer_queue_id = nv_flinger.FindBufferQueueId(display_id, *layer_id);
1166 if (!buffer_queue_id) { 1166 if (!buffer_queue_id) {
1167 LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", display_id); 1167 LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", display_id);
1168 IPC::ResponseBuilder rb{ctx, 2}; 1168 IPC::ResponseBuilder rb{ctx, 2};
@@ -1193,7 +1193,7 @@ private:
1193 1193
1194 LOG_WARNING(Service_VI, "(STUBBED) called. display_id=0x{:016X}", display_id); 1194 LOG_WARNING(Service_VI, "(STUBBED) called. display_id=0x{:016X}", display_id);
1195 1195
1196 const auto vsync_event = nv_flinger->FindVsyncEvent(display_id); 1196 const auto vsync_event = nv_flinger.FindVsyncEvent(display_id);
1197 if (!vsync_event) { 1197 if (!vsync_event) {
1198 LOG_ERROR(Service_VI, "Vsync event was not found for display_id={}", display_id); 1198 LOG_ERROR(Service_VI, "Vsync event was not found for display_id={}", display_id);
1199 IPC::ResponseBuilder rb{ctx, 2}; 1199 IPC::ResponseBuilder rb{ctx, 2};
@@ -1258,12 +1258,11 @@ private:
1258 } 1258 }
1259 } 1259 }
1260 1260
1261 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger; 1261 NVFlinger::NVFlinger& nv_flinger;
1262}; 1262};
1263 1263
1264IApplicationDisplayService::IApplicationDisplayService( 1264IApplicationDisplayService::IApplicationDisplayService(NVFlinger::NVFlinger& nv_flinger)
1265 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) 1265 : ServiceFramework("IApplicationDisplayService"), nv_flinger(nv_flinger) {
1266 : ServiceFramework("IApplicationDisplayService"), nv_flinger(std::move(nv_flinger)) {
1267 static const FunctionInfo functions[] = { 1266 static const FunctionInfo functions[] = {
1268 {100, &IApplicationDisplayService::GetRelayService, "GetRelayService"}, 1267 {100, &IApplicationDisplayService::GetRelayService, "GetRelayService"},
1269 {101, &IApplicationDisplayService::GetSystemDisplayService, "GetSystemDisplayService"}, 1268 {101, &IApplicationDisplayService::GetSystemDisplayService, "GetSystemDisplayService"},
@@ -1304,8 +1303,7 @@ static bool IsValidServiceAccess(Permission permission, Policy policy) {
1304 return false; 1303 return false;
1305} 1304}
1306 1305
1307void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, 1306void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, NVFlinger::NVFlinger& nv_flinger,
1308 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger,
1309 Permission permission) { 1307 Permission permission) {
1310 IPC::RequestParser rp{ctx}; 1308 IPC::RequestParser rp{ctx};
1311 const auto policy = rp.PopEnum<Policy>(); 1309 const auto policy = rp.PopEnum<Policy>();
@@ -1319,11 +1317,10 @@ void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx,
1319 1317
1320 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 1318 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
1321 rb.Push(RESULT_SUCCESS); 1319 rb.Push(RESULT_SUCCESS);
1322 rb.PushIpcInterface<IApplicationDisplayService>(std::move(nv_flinger)); 1320 rb.PushIpcInterface<IApplicationDisplayService>(nv_flinger);
1323} 1321}
1324 1322
1325void InstallInterfaces(SM::ServiceManager& service_manager, 1323void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nv_flinger) {
1326 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) {
1327 std::make_shared<VI_M>(nv_flinger)->InstallAsService(service_manager); 1324 std::make_shared<VI_M>(nv_flinger)->InstallAsService(service_manager);
1328 std::make_shared<VI_S>(nv_flinger)->InstallAsService(service_manager); 1325 std::make_shared<VI_S>(nv_flinger)->InstallAsService(service_manager);
1329 std::make_shared<VI_U>(nv_flinger)->InstallAsService(service_manager); 1326 std::make_shared<VI_U>(nv_flinger)->InstallAsService(service_manager);
diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h
index 6b66f8b81..5229fa753 100644
--- a/src/core/hle/service/vi/vi.h
+++ b/src/core/hle/service/vi/vi.h
@@ -43,12 +43,11 @@ enum class Policy {
43}; 43};
44 44
45namespace detail { 45namespace detail {
46void GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, 46void GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, NVFlinger::NVFlinger& nv_flinger,
47 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger, Permission permission); 47 Permission permission);
48} // namespace detail 48} // namespace detail
49 49
50/// Registers all VI services with the specified service manager. 50/// Registers all VI services with the specified service manager.
51void InstallInterfaces(SM::ServiceManager& service_manager, 51void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nv_flinger);
52 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
53 52
54} // namespace Service::VI 53} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi_m.cpp b/src/core/hle/service/vi/vi_m.cpp
index 06070087f..41da3ee93 100644
--- a/src/core/hle/service/vi/vi_m.cpp
+++ b/src/core/hle/service/vi/vi_m.cpp
@@ -8,8 +8,7 @@
8 8
9namespace Service::VI { 9namespace Service::VI {
10 10
11VI_M::VI_M(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) 11VI_M::VI_M(NVFlinger::NVFlinger& nv_flinger) : ServiceFramework{"vi:m"}, nv_flinger{nv_flinger} {
12 : ServiceFramework{"vi:m"}, nv_flinger{std::move(nv_flinger)} {
13 static const FunctionInfo functions[] = { 12 static const FunctionInfo functions[] = {
14 {2, &VI_M::GetDisplayService, "GetDisplayService"}, 13 {2, &VI_M::GetDisplayService, "GetDisplayService"},
15 {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, 14 {3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
diff --git a/src/core/hle/service/vi/vi_m.h b/src/core/hle/service/vi/vi_m.h
index 290e06689..ee2489874 100644
--- a/src/core/hle/service/vi/vi_m.h
+++ b/src/core/hle/service/vi/vi_m.h
@@ -18,13 +18,13 @@ namespace Service::VI {
18 18
19class VI_M final : public ServiceFramework<VI_M> { 19class VI_M final : public ServiceFramework<VI_M> {
20public: 20public:
21 explicit VI_M(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger); 21 explicit VI_M(NVFlinger::NVFlinger& nv_flinger);
22 ~VI_M() override; 22 ~VI_M() override;
23 23
24private: 24private:
25 void GetDisplayService(Kernel::HLERequestContext& ctx); 25 void GetDisplayService(Kernel::HLERequestContext& ctx);
26 26
27 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger; 27 NVFlinger::NVFlinger& nv_flinger;
28}; 28};
29 29
30} // namespace Service::VI 30} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi_s.cpp b/src/core/hle/service/vi/vi_s.cpp
index 57c596cc4..6acb51e2a 100644
--- a/src/core/hle/service/vi/vi_s.cpp
+++ b/src/core/hle/service/vi/vi_s.cpp
@@ -8,8 +8,7 @@
8 8
9namespace Service::VI { 9namespace Service::VI {
10 10
11VI_S::VI_S(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) 11VI_S::VI_S(NVFlinger::NVFlinger& nv_flinger) : ServiceFramework{"vi:s"}, nv_flinger{nv_flinger} {
12 : ServiceFramework{"vi:s"}, nv_flinger{std::move(nv_flinger)} {
13 static const FunctionInfo functions[] = { 12 static const FunctionInfo functions[] = {
14 {1, &VI_S::GetDisplayService, "GetDisplayService"}, 13 {1, &VI_S::GetDisplayService, "GetDisplayService"},
15 {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, 14 {3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
diff --git a/src/core/hle/service/vi/vi_s.h b/src/core/hle/service/vi/vi_s.h
index 47804dc0b..6790673ab 100644
--- a/src/core/hle/service/vi/vi_s.h
+++ b/src/core/hle/service/vi/vi_s.h
@@ -18,13 +18,13 @@ namespace Service::VI {
18 18
19class VI_S final : public ServiceFramework<VI_S> { 19class VI_S final : public ServiceFramework<VI_S> {
20public: 20public:
21 explicit VI_S(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger); 21 explicit VI_S(NVFlinger::NVFlinger& nv_flinger);
22 ~VI_S() override; 22 ~VI_S() override;
23 23
24private: 24private:
25 void GetDisplayService(Kernel::HLERequestContext& ctx); 25 void GetDisplayService(Kernel::HLERequestContext& ctx);
26 26
27 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger; 27 NVFlinger::NVFlinger& nv_flinger;
28}; 28};
29 29
30} // namespace Service::VI 30} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi_u.cpp b/src/core/hle/service/vi/vi_u.cpp
index 6b7329345..44e00a4f6 100644
--- a/src/core/hle/service/vi/vi_u.cpp
+++ b/src/core/hle/service/vi/vi_u.cpp
@@ -8,8 +8,7 @@
8 8
9namespace Service::VI { 9namespace Service::VI {
10 10
11VI_U::VI_U(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) 11VI_U::VI_U(NVFlinger::NVFlinger& nv_flinger) : ServiceFramework{"vi:u"}, nv_flinger{nv_flinger} {
12 : ServiceFramework{"vi:u"}, nv_flinger{std::move(nv_flinger)} {
13 static const FunctionInfo functions[] = { 12 static const FunctionInfo functions[] = {
14 {0, &VI_U::GetDisplayService, "GetDisplayService"}, 13 {0, &VI_U::GetDisplayService, "GetDisplayService"},
15 {1, nullptr, "GetDisplayServiceWithProxyNameExchange"}, 14 {1, nullptr, "GetDisplayServiceWithProxyNameExchange"},
diff --git a/src/core/hle/service/vi/vi_u.h b/src/core/hle/service/vi/vi_u.h
index 19bdb73b0..b59f986f0 100644
--- a/src/core/hle/service/vi/vi_u.h
+++ b/src/core/hle/service/vi/vi_u.h
@@ -18,13 +18,13 @@ namespace Service::VI {
18 18
19class VI_U final : public ServiceFramework<VI_U> { 19class VI_U final : public ServiceFramework<VI_U> {
20public: 20public:
21 explicit VI_U(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger); 21 explicit VI_U(NVFlinger::NVFlinger& nv_flinger);
22 ~VI_U() override; 22 ~VI_U() override;
23 23
24private: 24private:
25 void GetDisplayService(Kernel::HLERequestContext& ctx); 25 void GetDisplayService(Kernel::HLERequestContext& ctx);
26 26
27 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger; 27 NVFlinger::NVFlinger& nv_flinger;
28}; 28};
29 29
30} // namespace Service::VI 30} // namespace Service::VI