summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-09-22 09:38:13 -0400
committerGravatar GitHub2019-09-22 09:38:13 -0400
commit4ace69de9c90eb7d4a758aa3c3616a9c0d55bc5b (patch)
treecbf3e722bf583a48f851744c8276a2caf0b2e8ef /src
parentMerge pull request #2870 from FernandoS27/multi-draw (diff)
parentremoved unneeded semicolon (diff)
downloadyuzu-4ace69de9c90eb7d4a758aa3c3616a9c0d55bc5b.tar.gz
yuzu-4ace69de9c90eb7d4a758aa3c3616a9c0d55bc5b.tar.xz
yuzu-4ace69de9c90eb7d4a758aa3c3616a9c0d55bc5b.zip
Merge pull request #2884 from ogniK5377/deglobal-sys-services
Remove usage of System::CurrentInterface() from most services
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/am/am.cpp2
-rw-r--r--src/core/hle/service/aoc/aoc_u.cpp19
-rw-r--r--src/core/hle/service/aoc/aoc_u.h5
-rw-r--r--src/core/hle/service/btdrv/btdrv.cpp8
-rw-r--r--src/core/hle/service/btdrv/btdrv.h6
-rw-r--r--src/core/hle/service/btm/btm.cpp14
-rw-r--r--src/core/hle/service/btm/btm.h6
-rw-r--r--src/core/hle/service/fatal/fatal.cpp29
-rw-r--r--src/core/hle/service/fatal/fatal.h9
-rw-r--r--src/core/hle/service/fatal/fatal_p.cpp4
-rw-r--r--src/core/hle/service/fatal/fatal_p.h2
-rw-r--r--src/core/hle/service/fatal/fatal_u.cpp3
-rw-r--r--src/core/hle/service/fatal/fatal_u.h2
-rw-r--r--src/core/hle/service/friend/friend.cpp31
-rw-r--r--src/core/hle/service/friend/friend.h9
-rw-r--r--src/core/hle/service/friend/interface.cpp4
-rw-r--r--src/core/hle/service/friend/interface.h2
-rw-r--r--src/core/hle/service/hid/controllers/controller_base.cpp2
-rw-r--r--src/core/hle/service/hid/controllers/controller_base.h8
-rw-r--r--src/core/hle/service/hid/controllers/debug_pad.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/debug_pad.h3
-rw-r--r--src/core/hle/service/hid/controllers/gesture.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/gesture.h3
-rw-r--r--src/core/hle/service/hid/controllers/keyboard.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/keyboard.h3
-rw-r--r--src/core/hle/service/hid/controllers/mouse.cpp2
-rw-r--r--src/core/hle/service/hid/controllers/mouse.h3
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp4
-rw-r--r--src/core/hle/service/hid/controllers/npad.h3
-rw-r--r--src/core/hle/service/hid/controllers/stubbed.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/stubbed.h3
-rw-r--r--src/core/hle/service/hid/controllers/touchscreen.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/touchscreen.h3
-rw-r--r--src/core/hle/service/hid/controllers/xpad.cpp2
-rw-r--r--src/core/hle/service/hid/controllers/xpad.h3
-rw-r--r--src/core/hle/service/hid/hid.cpp23
-rw-r--r--src/core/hle/service/hid/hid.h10
-rw-r--r--src/core/hle/service/hid/irs.cpp6
-rw-r--r--src/core/hle/service/hid/irs.h3
-rw-r--r--src/core/hle/service/ldr/ldr.cpp11
-rw-r--r--src/core/hle/service/ldr/ldr.h2
-rw-r--r--src/core/hle/service/nfp/nfp.cpp19
-rw-r--r--src/core/hle/service/nfp/nfp.h5
-rw-r--r--src/core/hle/service/nfp/nfp_user.cpp4
-rw-r--r--src/core/hle/service/nfp/nfp_user.h2
-rw-r--r--src/core/hle/service/nifm/nifm.cpp30
-rw-r--r--src/core/hle/service/nifm/nifm.h6
-rw-r--r--src/core/hle/service/nim/nim.cpp13
-rw-r--r--src/core/hle/service/nim/nim.h6
-rw-r--r--src/core/hle/service/ns/ns.cpp5
-rw-r--r--src/core/hle/service/ns/ns.h3
-rw-r--r--src/core/hle/service/ns/pl_u.cpp10
-rw-r--r--src/core/hle/service/ns/pl_u.h3
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp38
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.h5
-rw-r--r--src/core/hle/service/prepo/prepo.cpp14
-rw-r--r--src/core/hle/service/prepo/prepo.h6
-rw-r--r--src/core/hle/service/service.cpp26
-rw-r--r--src/core/hle/service/time/interface.cpp4
-rw-r--r--src/core/hle/service/time/interface.h2
-rw-r--r--src/core/hle/service/time/time.cpp25
-rw-r--r--src/core/hle/service/time/time.h4
-rw-r--r--src/core/hle/service/vi/display/vi_display.cpp4
-rw-r--r--src/core/hle/service/vi/display/vi_display.h2
64 files changed, 291 insertions, 212 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 6c594dcaf..3366fd8ce 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -1066,7 +1066,7 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_)
1066 1066
1067 RegisterHandlers(functions); 1067 RegisterHandlers(functions);
1068 1068
1069 auto& kernel = Core::System::GetInstance().Kernel(); 1069 auto& kernel = system.Kernel();
1070 gpu_error_detected_event = Kernel::WritableEvent::CreateEventPair( 1070 gpu_error_detected_event = Kernel::WritableEvent::CreateEventPair(
1071 kernel, Kernel::ResetType::Manual, "IApplicationFunctions:GpuErrorDetectedSystemEvent"); 1071 kernel, Kernel::ResetType::Manual, "IApplicationFunctions:GpuErrorDetectedSystemEvent");
1072} 1072}
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp
index d3e97776b..e9cf1e840 100644
--- a/src/core/hle/service/aoc/aoc_u.cpp
+++ b/src/core/hle/service/aoc/aoc_u.cpp
@@ -29,9 +29,9 @@ static bool CheckAOCTitleIDMatchesBase(u64 title_id, u64 base) {
29 return (title_id & DLC_BASE_TITLE_ID_MASK) == base; 29 return (title_id & DLC_BASE_TITLE_ID_MASK) == base;
30} 30}
31 31
32static std::vector<u64> AccumulateAOCTitleIDs() { 32static std::vector<u64> AccumulateAOCTitleIDs(Core::System& system) {
33 std::vector<u64> add_on_content; 33 std::vector<u64> add_on_content;
34 const auto& rcu = Core::System::GetInstance().GetContentProvider(); 34 const auto& rcu = system.GetContentProvider();
35 const auto list = 35 const auto list =
36 rcu.ListEntriesFilter(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data); 36 rcu.ListEntriesFilter(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
37 std::transform(list.begin(), list.end(), std::back_inserter(add_on_content), 37 std::transform(list.begin(), list.end(), std::back_inserter(add_on_content),
@@ -47,7 +47,8 @@ static std::vector<u64> AccumulateAOCTitleIDs() {
47 return add_on_content; 47 return add_on_content;
48} 48}
49 49
50AOC_U::AOC_U() : ServiceFramework("aoc:u"), add_on_content(AccumulateAOCTitleIDs()) { 50AOC_U::AOC_U(Core::System& system)
51 : ServiceFramework("aoc:u"), add_on_content(AccumulateAOCTitleIDs(system)), system(system) {
51 // clang-format off 52 // clang-format off
52 static const FunctionInfo functions[] = { 53 static const FunctionInfo functions[] = {
53 {0, nullptr, "CountAddOnContentByApplicationId"}, 54 {0, nullptr, "CountAddOnContentByApplicationId"},
@@ -65,7 +66,7 @@ AOC_U::AOC_U() : ServiceFramework("aoc:u"), add_on_content(AccumulateAOCTitleIDs
65 66
66 RegisterHandlers(functions); 67 RegisterHandlers(functions);
67 68
68 auto& kernel = Core::System::GetInstance().Kernel(); 69 auto& kernel = system.Kernel();
69 aoc_change_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual, 70 aoc_change_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual,
70 "GetAddOnContentListChanged:Event"); 71 "GetAddOnContentListChanged:Event");
71} 72}
@@ -86,7 +87,7 @@ void AOC_U::CountAddOnContent(Kernel::HLERequestContext& ctx) {
86 IPC::ResponseBuilder rb{ctx, 3}; 87 IPC::ResponseBuilder rb{ctx, 3};
87 rb.Push(RESULT_SUCCESS); 88 rb.Push(RESULT_SUCCESS);
88 89
89 const auto current = Core::System::GetInstance().CurrentProcess()->GetTitleID(); 90 const auto current = system.CurrentProcess()->GetTitleID();
90 91
91 const auto& disabled = Settings::values.disabled_addons[current]; 92 const auto& disabled = Settings::values.disabled_addons[current];
92 if (std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end()) { 93 if (std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end()) {
@@ -113,7 +114,7 @@ void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) {
113 LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count, 114 LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count,
114 process_id); 115 process_id);
115 116
116 const auto current = Core::System::GetInstance().CurrentProcess()->GetTitleID(); 117 const auto current = system.CurrentProcess()->GetTitleID();
117 118
118 std::vector<u32> out; 119 std::vector<u32> out;
119 const auto& disabled = Settings::values.disabled_addons[current]; 120 const auto& disabled = Settings::values.disabled_addons[current];
@@ -159,7 +160,7 @@ void AOC_U::GetAddOnContentBaseId(Kernel::HLERequestContext& ctx) {
159 IPC::ResponseBuilder rb{ctx, 4}; 160 IPC::ResponseBuilder rb{ctx, 4};
160 rb.Push(RESULT_SUCCESS); 161 rb.Push(RESULT_SUCCESS);
161 162
162 const auto title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); 163 const auto title_id = system.CurrentProcess()->GetTitleID();
163 FileSys::PatchManager pm{title_id}; 164 FileSys::PatchManager pm{title_id};
164 165
165 const auto res = pm.GetControlMetadata(); 166 const auto res = pm.GetControlMetadata();
@@ -196,8 +197,8 @@ void AOC_U::GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx) {
196 rb.PushCopyObjects(aoc_change_event.readable); 197 rb.PushCopyObjects(aoc_change_event.readable);
197} 198}
198 199
199void InstallInterfaces(SM::ServiceManager& service_manager) { 200void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
200 std::make_shared<AOC_U>()->InstallAsService(service_manager); 201 std::make_shared<AOC_U>(system)->InstallAsService(service_manager);
201} 202}
202 203
203} // namespace Service::AOC 204} // namespace Service::AOC
diff --git a/src/core/hle/service/aoc/aoc_u.h b/src/core/hle/service/aoc/aoc_u.h
index 5effea730..848b2f416 100644
--- a/src/core/hle/service/aoc/aoc_u.h
+++ b/src/core/hle/service/aoc/aoc_u.h
@@ -14,7 +14,7 @@ namespace Service::AOC {
14 14
15class AOC_U final : public ServiceFramework<AOC_U> { 15class AOC_U final : public ServiceFramework<AOC_U> {
16public: 16public:
17 AOC_U(); 17 explicit AOC_U(Core::System& system);
18 ~AOC_U() override; 18 ~AOC_U() override;
19 19
20private: 20private:
@@ -26,9 +26,10 @@ private:
26 26
27 std::vector<u64> add_on_content; 27 std::vector<u64> add_on_content;
28 Kernel::EventPair aoc_change_event; 28 Kernel::EventPair aoc_change_event;
29 Core::System& system;
29}; 30};
30 31
31/// Registers all AOC services with the specified service manager. 32/// Registers all AOC services with the specified service manager.
32void InstallInterfaces(SM::ServiceManager& service_manager); 33void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
33 34
34} // namespace Service::AOC 35} // namespace Service::AOC
diff --git a/src/core/hle/service/btdrv/btdrv.cpp b/src/core/hle/service/btdrv/btdrv.cpp
index 3c7ca2c44..afce581e5 100644
--- a/src/core/hle/service/btdrv/btdrv.cpp
+++ b/src/core/hle/service/btdrv/btdrv.cpp
@@ -16,7 +16,7 @@ namespace Service::BtDrv {
16 16
17class Bt final : public ServiceFramework<Bt> { 17class Bt final : public ServiceFramework<Bt> {
18public: 18public:
19 explicit Bt() : ServiceFramework{"bt"} { 19 explicit Bt(Core::System& system) : ServiceFramework{"bt"} {
20 // clang-format off 20 // clang-format off
21 static const FunctionInfo functions[] = { 21 static const FunctionInfo functions[] = {
22 {0, nullptr, "LeClientReadCharacteristic"}, 22 {0, nullptr, "LeClientReadCharacteristic"},
@@ -33,7 +33,7 @@ public:
33 // clang-format on 33 // clang-format on
34 RegisterHandlers(functions); 34 RegisterHandlers(functions);
35 35
36 auto& kernel = Core::System::GetInstance().Kernel(); 36 auto& kernel = system.Kernel();
37 register_event = Kernel::WritableEvent::CreateEventPair( 37 register_event = Kernel::WritableEvent::CreateEventPair(
38 kernel, Kernel::ResetType::Automatic, "BT:RegisterEvent"); 38 kernel, Kernel::ResetType::Automatic, "BT:RegisterEvent");
39 } 39 }
@@ -163,9 +163,9 @@ public:
163 } 163 }
164}; 164};
165 165
166void InstallInterfaces(SM::ServiceManager& sm) { 166void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
167 std::make_shared<BtDrv>()->InstallAsService(sm); 167 std::make_shared<BtDrv>()->InstallAsService(sm);
168 std::make_shared<Bt>()->InstallAsService(sm); 168 std::make_shared<Bt>(system)->InstallAsService(sm);
169} 169}
170 170
171} // namespace Service::BtDrv 171} // namespace Service::BtDrv
diff --git a/src/core/hle/service/btdrv/btdrv.h b/src/core/hle/service/btdrv/btdrv.h
index 164e56f43..191410dbc 100644
--- a/src/core/hle/service/btdrv/btdrv.h
+++ b/src/core/hle/service/btdrv/btdrv.h
@@ -8,9 +8,13 @@ namespace Service::SM {
8class ServiceManager; 8class ServiceManager;
9} 9}
10 10
11namespace Core {
12class System;
13}
14
11namespace Service::BtDrv { 15namespace Service::BtDrv {
12 16
13/// Registers all BtDrv services with the specified service manager. 17/// Registers all BtDrv services with the specified service manager.
14void InstallInterfaces(SM::ServiceManager& sm); 18void InstallInterfaces(SM::ServiceManager& sm, Core::System& system);
15 19
16} // namespace Service::BtDrv 20} // namespace Service::BtDrv
diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp
index b439ee7ec..920fc6ff7 100644
--- a/src/core/hle/service/btm/btm.cpp
+++ b/src/core/hle/service/btm/btm.cpp
@@ -17,7 +17,7 @@ namespace Service::BTM {
17 17
18class IBtmUserCore final : public ServiceFramework<IBtmUserCore> { 18class IBtmUserCore final : public ServiceFramework<IBtmUserCore> {
19public: 19public:
20 explicit IBtmUserCore() : ServiceFramework{"IBtmUserCore"} { 20 explicit IBtmUserCore(Core::System& system) : ServiceFramework{"IBtmUserCore"} {
21 // clang-format off 21 // clang-format off
22 static const FunctionInfo functions[] = { 22 static const FunctionInfo functions[] = {
23 {0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"}, 23 {0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"},
@@ -56,7 +56,7 @@ public:
56 // clang-format on 56 // clang-format on
57 RegisterHandlers(functions); 57 RegisterHandlers(functions);
58 58
59 auto& kernel = Core::System::GetInstance().Kernel(); 59 auto& kernel = system.Kernel();
60 scan_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic, 60 scan_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic,
61 "IBtmUserCore:ScanEvent"); 61 "IBtmUserCore:ScanEvent");
62 connection_event = Kernel::WritableEvent::CreateEventPair( 62 connection_event = Kernel::WritableEvent::CreateEventPair(
@@ -108,7 +108,7 @@ private:
108 108
109class BTM_USR final : public ServiceFramework<BTM_USR> { 109class BTM_USR final : public ServiceFramework<BTM_USR> {
110public: 110public:
111 explicit BTM_USR() : ServiceFramework{"btm:u"} { 111 explicit BTM_USR(Core::System& system) : ServiceFramework{"btm:u"}, system(system) {
112 // clang-format off 112 // clang-format off
113 static const FunctionInfo functions[] = { 113 static const FunctionInfo functions[] = {
114 {0, &BTM_USR::GetCore, "GetCore"}, 114 {0, &BTM_USR::GetCore, "GetCore"},
@@ -123,8 +123,10 @@ private:
123 123
124 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 124 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
125 rb.Push(RESULT_SUCCESS); 125 rb.Push(RESULT_SUCCESS);
126 rb.PushIpcInterface<IBtmUserCore>(); 126 rb.PushIpcInterface<IBtmUserCore>(system);
127 } 127 }
128
129 Core::System& system;
128}; 130};
129 131
130class BTM final : public ServiceFramework<BTM> { 132class BTM final : public ServiceFramework<BTM> {
@@ -268,11 +270,11 @@ private:
268 } 270 }
269}; 271};
270 272
271void InstallInterfaces(SM::ServiceManager& sm) { 273void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
272 std::make_shared<BTM>()->InstallAsService(sm); 274 std::make_shared<BTM>()->InstallAsService(sm);
273 std::make_shared<BTM_DBG>()->InstallAsService(sm); 275 std::make_shared<BTM_DBG>()->InstallAsService(sm);
274 std::make_shared<BTM_SYS>()->InstallAsService(sm); 276 std::make_shared<BTM_SYS>()->InstallAsService(sm);
275 std::make_shared<BTM_USR>()->InstallAsService(sm); 277 std::make_shared<BTM_USR>(system)->InstallAsService(sm);
276} 278}
277 279
278} // namespace Service::BTM 280} // namespace Service::BTM
diff --git a/src/core/hle/service/btm/btm.h b/src/core/hle/service/btm/btm.h
index e6425a7e3..c6b878043 100644
--- a/src/core/hle/service/btm/btm.h
+++ b/src/core/hle/service/btm/btm.h
@@ -8,8 +8,12 @@ namespace Service::SM {
8class ServiceManager; 8class ServiceManager;
9} 9}
10 10
11namespace Core {
12class System;
13};
14
11namespace Service::BTM { 15namespace Service::BTM {
12 16
13void InstallInterfaces(SM::ServiceManager& sm); 17void InstallInterfaces(SM::ServiceManager& sm, Core::System& system);
14 18
15} // namespace Service::BTM 19} // namespace Service::BTM
diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp
index 01fa06ad3..b2ebf6240 100644
--- a/src/core/hle/service/fatal/fatal.cpp
+++ b/src/core/hle/service/fatal/fatal.cpp
@@ -20,8 +20,8 @@
20 20
21namespace Service::Fatal { 21namespace Service::Fatal {
22 22
23Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) 23Module::Interface::Interface(std::shared_ptr<Module> module, Core::System& system, const char* name)
24 : ServiceFramework(name), module(std::move(module)) {} 24 : ServiceFramework(name), module(std::move(module)), system(system) {}
25 25
26Module::Interface::~Interface() = default; 26Module::Interface::~Interface() = default;
27 27
@@ -64,7 +64,8 @@ enum class FatalType : u32 {
64 ErrorScreen = 2, 64 ErrorScreen = 2,
65}; 65};
66 66
67static void GenerateErrorReport(ResultCode error_code, const FatalInfo& info) { 67static void GenerateErrorReport(Core::System& system, ResultCode error_code,
68 const FatalInfo& info) {
68 const auto title_id = Core::CurrentProcess()->GetTitleID(); 69 const auto title_id = Core::CurrentProcess()->GetTitleID();
69 std::string crash_report = fmt::format( 70 std::string crash_report = fmt::format(
70 "Yuzu {}-{} crash report\n" 71 "Yuzu {}-{} crash report\n"
@@ -101,18 +102,19 @@ static void GenerateErrorReport(ResultCode error_code, const FatalInfo& info) {
101 102
102 LOG_ERROR(Service_Fatal, "{}", crash_report); 103 LOG_ERROR(Service_Fatal, "{}", crash_report);
103 104
104 Core::System::GetInstance().GetReporter().SaveCrashReport( 105 system.GetReporter().SaveCrashReport(
105 title_id, error_code, info.set_flags, info.program_entry_point, info.sp, info.pc, 106 title_id, error_code, info.set_flags, info.program_entry_point, info.sp, info.pc,
106 info.pstate, info.afsr0, info.afsr1, info.esr, info.far, info.registers, info.backtrace, 107 info.pstate, info.afsr0, info.afsr1, info.esr, info.far, info.registers, info.backtrace,
107 info.backtrace_size, info.ArchAsString(), info.unk10); 108 info.backtrace_size, info.ArchAsString(), info.unk10);
108} 109}
109 110
110static void ThrowFatalError(ResultCode error_code, FatalType fatal_type, const FatalInfo& info) { 111static void ThrowFatalError(Core::System& system, ResultCode error_code, FatalType fatal_type,
112 const FatalInfo& info) {
111 LOG_ERROR(Service_Fatal, "Threw fatal error type {} with error code 0x{:X}", 113 LOG_ERROR(Service_Fatal, "Threw fatal error type {} with error code 0x{:X}",
112 static_cast<u32>(fatal_type), error_code.raw); 114 static_cast<u32>(fatal_type), error_code.raw);
113 switch (fatal_type) { 115 switch (fatal_type) {
114 case FatalType::ErrorReportAndScreen: 116 case FatalType::ErrorReportAndScreen:
115 GenerateErrorReport(error_code, info); 117 GenerateErrorReport(system, error_code, info);
116 [[fallthrough]]; 118 [[fallthrough]];
117 case FatalType::ErrorScreen: 119 case FatalType::ErrorScreen:
118 // Since we have no fatal:u error screen. We should just kill execution instead 120 // Since we have no fatal:u error screen. We should just kill execution instead
@@ -120,7 +122,7 @@ static void ThrowFatalError(ResultCode error_code, FatalType fatal_type, const F
120 break; 122 break;
121 // Should not throw a fatal screen but should generate an error report 123 // Should not throw a fatal screen but should generate an error report
122 case FatalType::ErrorReport: 124 case FatalType::ErrorReport:
123 GenerateErrorReport(error_code, info); 125 GenerateErrorReport(system, error_code, info);
124 break; 126 break;
125 } 127 }
126} 128}
@@ -130,7 +132,7 @@ void Module::Interface::ThrowFatal(Kernel::HLERequestContext& ctx) {
130 IPC::RequestParser rp{ctx}; 132 IPC::RequestParser rp{ctx};
131 const auto error_code = rp.Pop<ResultCode>(); 133 const auto error_code = rp.Pop<ResultCode>();
132 134
133 ThrowFatalError(error_code, FatalType::ErrorScreen, {}); 135 ThrowFatalError(system, error_code, FatalType::ErrorScreen, {});
134 IPC::ResponseBuilder rb{ctx, 2}; 136 IPC::ResponseBuilder rb{ctx, 2};
135 rb.Push(RESULT_SUCCESS); 137 rb.Push(RESULT_SUCCESS);
136} 138}
@@ -141,7 +143,8 @@ void Module::Interface::ThrowFatalWithPolicy(Kernel::HLERequestContext& ctx) {
141 const auto error_code = rp.Pop<ResultCode>(); 143 const auto error_code = rp.Pop<ResultCode>();
142 const auto fatal_type = rp.PopEnum<FatalType>(); 144 const auto fatal_type = rp.PopEnum<FatalType>();
143 145
144 ThrowFatalError(error_code, fatal_type, {}); // No info is passed with ThrowFatalWithPolicy 146 ThrowFatalError(system, error_code, fatal_type,
147 {}); // No info is passed with ThrowFatalWithPolicy
145 IPC::ResponseBuilder rb{ctx, 2}; 148 IPC::ResponseBuilder rb{ctx, 2};
146 rb.Push(RESULT_SUCCESS); 149 rb.Push(RESULT_SUCCESS);
147} 150}
@@ -157,15 +160,15 @@ void Module::Interface::ThrowFatalWithCpuContext(Kernel::HLERequestContext& ctx)
157 ASSERT_MSG(fatal_info.size() == sizeof(FatalInfo), "Invalid fatal info buffer size!"); 160 ASSERT_MSG(fatal_info.size() == sizeof(FatalInfo), "Invalid fatal info buffer size!");
158 std::memcpy(&info, fatal_info.data(), sizeof(FatalInfo)); 161 std::memcpy(&info, fatal_info.data(), sizeof(FatalInfo));
159 162
160 ThrowFatalError(error_code, fatal_type, info); 163 ThrowFatalError(system, error_code, fatal_type, info);
161 IPC::ResponseBuilder rb{ctx, 2}; 164 IPC::ResponseBuilder rb{ctx, 2};
162 rb.Push(RESULT_SUCCESS); 165 rb.Push(RESULT_SUCCESS);
163} 166}
164 167
165void InstallInterfaces(SM::ServiceManager& service_manager) { 168void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
166 auto module = std::make_shared<Module>(); 169 auto module = std::make_shared<Module>();
167 std::make_shared<Fatal_P>(module)->InstallAsService(service_manager); 170 std::make_shared<Fatal_P>(module, system)->InstallAsService(service_manager);
168 std::make_shared<Fatal_U>(module)->InstallAsService(service_manager); 171 std::make_shared<Fatal_U>(module, system)->InstallAsService(service_manager);
169} 172}
170 173
171} // namespace Service::Fatal 174} // namespace Service::Fatal
diff --git a/src/core/hle/service/fatal/fatal.h b/src/core/hle/service/fatal/fatal.h
index 09371ff7f..bd9339dfc 100644
--- a/src/core/hle/service/fatal/fatal.h
+++ b/src/core/hle/service/fatal/fatal.h
@@ -6,13 +6,17 @@
6 6
7#include "core/hle/service/service.h" 7#include "core/hle/service/service.h"
8 8
9namespace Core {
10class System;
11}
12
9namespace Service::Fatal { 13namespace Service::Fatal {
10 14
11class Module final { 15class Module final {
12public: 16public:
13 class Interface : public ServiceFramework<Interface> { 17 class Interface : public ServiceFramework<Interface> {
14 public: 18 public:
15 explicit Interface(std::shared_ptr<Module> module, const char* name); 19 explicit Interface(std::shared_ptr<Module> module, Core::System& system, const char* name);
16 ~Interface() override; 20 ~Interface() override;
17 21
18 void ThrowFatal(Kernel::HLERequestContext& ctx); 22 void ThrowFatal(Kernel::HLERequestContext& ctx);
@@ -21,9 +25,10 @@ public:
21 25
22 protected: 26 protected:
23 std::shared_ptr<Module> module; 27 std::shared_ptr<Module> module;
28 Core::System& system;
24 }; 29 };
25}; 30};
26 31
27void InstallInterfaces(SM::ServiceManager& service_manager); 32void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
28 33
29} // namespace Service::Fatal 34} // namespace Service::Fatal
diff --git a/src/core/hle/service/fatal/fatal_p.cpp b/src/core/hle/service/fatal/fatal_p.cpp
index 9e5f872ff..066ccf6b0 100644
--- a/src/core/hle/service/fatal/fatal_p.cpp
+++ b/src/core/hle/service/fatal/fatal_p.cpp
@@ -6,8 +6,8 @@
6 6
7namespace Service::Fatal { 7namespace Service::Fatal {
8 8
9Fatal_P::Fatal_P(std::shared_ptr<Module> module) 9Fatal_P::Fatal_P(std::shared_ptr<Module> module, Core::System& system)
10 : Module::Interface(std::move(module), "fatal:p") {} 10 : Module::Interface(std::move(module), system, "fatal:p") {}
11 11
12Fatal_P::~Fatal_P() = default; 12Fatal_P::~Fatal_P() = default;
13 13
diff --git a/src/core/hle/service/fatal/fatal_p.h b/src/core/hle/service/fatal/fatal_p.h
index 6e9c5979f..c6d953cb5 100644
--- a/src/core/hle/service/fatal/fatal_p.h
+++ b/src/core/hle/service/fatal/fatal_p.h
@@ -10,7 +10,7 @@ namespace Service::Fatal {
10 10
11class Fatal_P final : public Module::Interface { 11class Fatal_P final : public Module::Interface {
12public: 12public:
13 explicit Fatal_P(std::shared_ptr<Module> module); 13 explicit Fatal_P(std::shared_ptr<Module> module, Core::System& system);
14 ~Fatal_P() override; 14 ~Fatal_P() override;
15}; 15};
16 16
diff --git a/src/core/hle/service/fatal/fatal_u.cpp b/src/core/hle/service/fatal/fatal_u.cpp
index 1572a2051..8d72ed485 100644
--- a/src/core/hle/service/fatal/fatal_u.cpp
+++ b/src/core/hle/service/fatal/fatal_u.cpp
@@ -6,7 +6,8 @@
6 6
7namespace Service::Fatal { 7namespace Service::Fatal {
8 8
9Fatal_U::Fatal_U(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "fatal:u") { 9Fatal_U::Fatal_U(std::shared_ptr<Module> module, Core::System& system)
10 : Module::Interface(std::move(module), system, "fatal:u") {
10 static const FunctionInfo functions[] = { 11 static const FunctionInfo functions[] = {
11 {0, &Fatal_U::ThrowFatal, "ThrowFatal"}, 12 {0, &Fatal_U::ThrowFatal, "ThrowFatal"},
12 {1, &Fatal_U::ThrowFatalWithPolicy, "ThrowFatalWithPolicy"}, 13 {1, &Fatal_U::ThrowFatalWithPolicy, "ThrowFatalWithPolicy"},
diff --git a/src/core/hle/service/fatal/fatal_u.h b/src/core/hle/service/fatal/fatal_u.h
index 72cb6d076..34c5c7f95 100644
--- a/src/core/hle/service/fatal/fatal_u.h
+++ b/src/core/hle/service/fatal/fatal_u.h
@@ -10,7 +10,7 @@ namespace Service::Fatal {
10 10
11class Fatal_U final : public Module::Interface { 11class Fatal_U final : public Module::Interface {
12public: 12public:
13 explicit Fatal_U(std::shared_ptr<Module> module); 13 explicit Fatal_U(std::shared_ptr<Module> module, Core::System& system);
14 ~Fatal_U() override; 14 ~Fatal_U() override;
15}; 15};
16 16
diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp
index d1ec12ef9..42b4ee861 100644
--- a/src/core/hle/service/friend/friend.cpp
+++ b/src/core/hle/service/friend/friend.cpp
@@ -149,7 +149,8 @@ private:
149 149
150class INotificationService final : public ServiceFramework<INotificationService> { 150class INotificationService final : public ServiceFramework<INotificationService> {
151public: 151public:
152 INotificationService(Common::UUID uuid) : ServiceFramework("INotificationService"), uuid(uuid) { 152 INotificationService(Common::UUID uuid, Core::System& system)
153 : ServiceFramework("INotificationService"), uuid(uuid) {
153 // clang-format off 154 // clang-format off
154 static const FunctionInfo functions[] = { 155 static const FunctionInfo functions[] = {
155 {0, &INotificationService::GetEvent, "GetEvent"}, 156 {0, &INotificationService::GetEvent, "GetEvent"},
@@ -159,6 +160,9 @@ public:
159 // clang-format on 160 // clang-format on
160 161
161 RegisterHandlers(functions); 162 RegisterHandlers(functions);
163
164 notification_event = Kernel::WritableEvent::CreateEventPair(
165 system.Kernel(), Kernel::ResetType::Manual, "INotificationService:NotifyEvent");
162 } 166 }
163 167
164private: 168private:
@@ -167,13 +171,6 @@ private:
167 171
168 IPC::ResponseBuilder rb{ctx, 2, 1}; 172 IPC::ResponseBuilder rb{ctx, 2, 1};
169 rb.Push(RESULT_SUCCESS); 173 rb.Push(RESULT_SUCCESS);
170
171 if (!is_event_created) {
172 auto& kernel = Core::System::GetInstance().Kernel();
173 notification_event = Kernel::WritableEvent::CreateEventPair(
174 kernel, Kernel::ResetType::Manual, "INotificationService:NotifyEvent");
175 is_event_created = true;
176 }
177 rb.PushCopyObjects(notification_event.readable); 174 rb.PushCopyObjects(notification_event.readable);
178 } 175 }
179 176
@@ -261,21 +258,21 @@ void Module::Interface::CreateNotificationService(Kernel::HLERequestContext& ctx
261 258
262 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 259 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
263 rb.Push(RESULT_SUCCESS); 260 rb.Push(RESULT_SUCCESS);
264 rb.PushIpcInterface<INotificationService>(uuid); 261 rb.PushIpcInterface<INotificationService>(uuid, system);
265} 262}
266 263
267Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) 264Module::Interface::Interface(std::shared_ptr<Module> module, Core::System& system, const char* name)
268 : ServiceFramework(name), module(std::move(module)) {} 265 : ServiceFramework(name), module(std::move(module)), system(system) {}
269 266
270Module::Interface::~Interface() = default; 267Module::Interface::~Interface() = default;
271 268
272void InstallInterfaces(SM::ServiceManager& service_manager) { 269void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
273 auto module = std::make_shared<Module>(); 270 auto module = std::make_shared<Module>();
274 std::make_shared<Friend>(module, "friend:a")->InstallAsService(service_manager); 271 std::make_shared<Friend>(module, system, "friend:a")->InstallAsService(service_manager);
275 std::make_shared<Friend>(module, "friend:m")->InstallAsService(service_manager); 272 std::make_shared<Friend>(module, system, "friend:m")->InstallAsService(service_manager);
276 std::make_shared<Friend>(module, "friend:s")->InstallAsService(service_manager); 273 std::make_shared<Friend>(module, system, "friend:s")->InstallAsService(service_manager);
277 std::make_shared<Friend>(module, "friend:u")->InstallAsService(service_manager); 274 std::make_shared<Friend>(module, system, "friend:u")->InstallAsService(service_manager);
278 std::make_shared<Friend>(module, "friend:v")->InstallAsService(service_manager); 275 std::make_shared<Friend>(module, system, "friend:v")->InstallAsService(service_manager);
279} 276}
280 277
281} // namespace Service::Friend 278} // namespace Service::Friend
diff --git a/src/core/hle/service/friend/friend.h b/src/core/hle/service/friend/friend.h
index 38d05fa8e..24f3fc969 100644
--- a/src/core/hle/service/friend/friend.h
+++ b/src/core/hle/service/friend/friend.h
@@ -6,13 +6,17 @@
6 6
7#include "core/hle/service/service.h" 7#include "core/hle/service/service.h"
8 8
9namespace Core {
10class System;
11}
12
9namespace Service::Friend { 13namespace Service::Friend {
10 14
11class Module final { 15class Module final {
12public: 16public:
13 class Interface : public ServiceFramework<Interface> { 17 class Interface : public ServiceFramework<Interface> {
14 public: 18 public:
15 explicit Interface(std::shared_ptr<Module> module, const char* name); 19 explicit Interface(std::shared_ptr<Module> module, Core::System& system, const char* name);
16 ~Interface() override; 20 ~Interface() override;
17 21
18 void CreateFriendService(Kernel::HLERequestContext& ctx); 22 void CreateFriendService(Kernel::HLERequestContext& ctx);
@@ -20,10 +24,11 @@ public:
20 24
21 protected: 25 protected:
22 std::shared_ptr<Module> module; 26 std::shared_ptr<Module> module;
27 Core::System& system;
23 }; 28 };
24}; 29};
25 30
26/// Registers all Friend services with the specified service manager. 31/// Registers all Friend services with the specified service manager.
27void InstallInterfaces(SM::ServiceManager& service_manager); 32void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
28 33
29} // namespace Service::Friend 34} // namespace Service::Friend
diff --git a/src/core/hle/service/friend/interface.cpp b/src/core/hle/service/friend/interface.cpp
index 5b384f733..58155f652 100644
--- a/src/core/hle/service/friend/interface.cpp
+++ b/src/core/hle/service/friend/interface.cpp
@@ -6,8 +6,8 @@
6 6
7namespace Service::Friend { 7namespace Service::Friend {
8 8
9Friend::Friend(std::shared_ptr<Module> module, const char* name) 9Friend::Friend(std::shared_ptr<Module> module, Core::System& system, const char* name)
10 : Interface(std::move(module), name) { 10 : Interface(std::move(module), system, name) {
11 static const FunctionInfo functions[] = { 11 static const FunctionInfo functions[] = {
12 {0, &Friend::CreateFriendService, "CreateFriendService"}, 12 {0, &Friend::CreateFriendService, "CreateFriendService"},
13 {1, &Friend::CreateNotificationService, "CreateNotificationService"}, 13 {1, &Friend::CreateNotificationService, "CreateNotificationService"},
diff --git a/src/core/hle/service/friend/interface.h b/src/core/hle/service/friend/interface.h
index 1963def39..465a35770 100644
--- a/src/core/hle/service/friend/interface.h
+++ b/src/core/hle/service/friend/interface.h
@@ -10,7 +10,7 @@ namespace Service::Friend {
10 10
11class Friend final : public Module::Interface { 11class Friend final : public Module::Interface {
12public: 12public:
13 explicit Friend(std::shared_ptr<Module> module, const char* name); 13 explicit Friend(std::shared_ptr<Module> module, Core::System& system, const char* name);
14 ~Friend() override; 14 ~Friend() override;
15}; 15};
16 16
diff --git a/src/core/hle/service/hid/controllers/controller_base.cpp b/src/core/hle/service/hid/controllers/controller_base.cpp
index 0993a7815..8091db9d7 100644
--- a/src/core/hle/service/hid/controllers/controller_base.cpp
+++ b/src/core/hle/service/hid/controllers/controller_base.cpp
@@ -6,7 +6,7 @@
6 6
7namespace Service::HID { 7namespace Service::HID {
8 8
9ControllerBase::ControllerBase() = default; 9ControllerBase::ControllerBase(Core::System& system) : system(system) {}
10ControllerBase::~ControllerBase() = default; 10ControllerBase::~ControllerBase() = default;
11 11
12void ControllerBase::ActivateController() { 12void ControllerBase::ActivateController() {
diff --git a/src/core/hle/service/hid/controllers/controller_base.h b/src/core/hle/service/hid/controllers/controller_base.h
index 5e5097a03..8bc69c372 100644
--- a/src/core/hle/service/hid/controllers/controller_base.h
+++ b/src/core/hle/service/hid/controllers/controller_base.h
@@ -11,10 +11,14 @@ namespace Core::Timing {
11class CoreTiming; 11class CoreTiming;
12} 12}
13 13
14namespace Core {
15class System;
16}
17
14namespace Service::HID { 18namespace Service::HID {
15class ControllerBase { 19class ControllerBase {
16public: 20public:
17 ControllerBase(); 21 explicit ControllerBase(Core::System& system);
18 virtual ~ControllerBase(); 22 virtual ~ControllerBase();
19 23
20 // Called when the controller is initialized 24 // Called when the controller is initialized
@@ -46,5 +50,7 @@ protected:
46 s64_le entry_count; 50 s64_le entry_count;
47 }; 51 };
48 static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size"); 52 static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size");
53
54 Core::System& system;
49}; 55};
50} // namespace Service::HID 56} // namespace Service::HID
diff --git a/src/core/hle/service/hid/controllers/debug_pad.cpp b/src/core/hle/service/hid/controllers/debug_pad.cpp
index c5c2e032a..8e8263f5b 100644
--- a/src/core/hle/service/hid/controllers/debug_pad.cpp
+++ b/src/core/hle/service/hid/controllers/debug_pad.cpp
@@ -14,7 +14,8 @@ constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
14constexpr s32 HID_JOYSTICK_MIN = -0x7fff; 14constexpr s32 HID_JOYSTICK_MIN = -0x7fff;
15enum class JoystickId : std::size_t { Joystick_Left, Joystick_Right }; 15enum class JoystickId : std::size_t { Joystick_Left, Joystick_Right };
16 16
17Controller_DebugPad::Controller_DebugPad() = default; 17Controller_DebugPad::Controller_DebugPad(Core::System& system)
18 : ControllerBase(system), system(system) {}
18Controller_DebugPad::~Controller_DebugPad() = default; 19Controller_DebugPad::~Controller_DebugPad() = default;
19 20
20void Controller_DebugPad::OnInit() {} 21void Controller_DebugPad::OnInit() {}
diff --git a/src/core/hle/service/hid/controllers/debug_pad.h b/src/core/hle/service/hid/controllers/debug_pad.h
index e584b92ec..6c4de817e 100644
--- a/src/core/hle/service/hid/controllers/debug_pad.h
+++ b/src/core/hle/service/hid/controllers/debug_pad.h
@@ -16,7 +16,7 @@
16namespace Service::HID { 16namespace Service::HID {
17class Controller_DebugPad final : public ControllerBase { 17class Controller_DebugPad final : public ControllerBase {
18public: 18public:
19 Controller_DebugPad(); 19 explicit Controller_DebugPad(Core::System& system);
20 ~Controller_DebugPad() override; 20 ~Controller_DebugPad() override;
21 21
22 // Called when the controller is initialized 22 // Called when the controller is initialized
@@ -89,5 +89,6 @@ private:
89 buttons; 89 buttons;
90 std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID> 90 std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID>
91 analogs; 91 analogs;
92 Core::System& system;
92}; 93};
93} // namespace Service::HID 94} // namespace Service::HID
diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp
index a179252e3..80da0a0d3 100644
--- a/src/core/hle/service/hid/controllers/gesture.cpp
+++ b/src/core/hle/service/hid/controllers/gesture.cpp
@@ -10,7 +10,8 @@
10namespace Service::HID { 10namespace Service::HID {
11constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3BA00; 11constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3BA00;
12 12
13Controller_Gesture::Controller_Gesture() = default; 13Controller_Gesture::Controller_Gesture(Core::System& system)
14 : ControllerBase(system), system(system) {}
14Controller_Gesture::~Controller_Gesture() = default; 15Controller_Gesture::~Controller_Gesture() = default;
15 16
16void Controller_Gesture::OnInit() {} 17void Controller_Gesture::OnInit() {}
diff --git a/src/core/hle/service/hid/controllers/gesture.h b/src/core/hle/service/hid/controllers/gesture.h
index f305fe90f..396897527 100644
--- a/src/core/hle/service/hid/controllers/gesture.h
+++ b/src/core/hle/service/hid/controllers/gesture.h
@@ -12,7 +12,7 @@
12namespace Service::HID { 12namespace Service::HID {
13class Controller_Gesture final : public ControllerBase { 13class Controller_Gesture final : public ControllerBase {
14public: 14public:
15 Controller_Gesture(); 15 explicit Controller_Gesture(Core::System& system);
16 ~Controller_Gesture() override; 16 ~Controller_Gesture() override;
17 17
18 // Called when the controller is initialized 18 // Called when the controller is initialized
@@ -59,5 +59,6 @@ private:
59 std::array<GestureState, 17> gesture_states; 59 std::array<GestureState, 17> gesture_states;
60 }; 60 };
61 SharedMemory shared_memory{}; 61 SharedMemory shared_memory{};
62 Core::System& system;
62}; 63};
63} // namespace Service::HID 64} // namespace Service::HID
diff --git a/src/core/hle/service/hid/controllers/keyboard.cpp b/src/core/hle/service/hid/controllers/keyboard.cpp
index 92d7bfb52..e587b2e15 100644
--- a/src/core/hle/service/hid/controllers/keyboard.cpp
+++ b/src/core/hle/service/hid/controllers/keyboard.cpp
@@ -12,7 +12,8 @@ namespace Service::HID {
12constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800; 12constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800;
13constexpr u8 KEYS_PER_BYTE = 8; 13constexpr u8 KEYS_PER_BYTE = 8;
14 14
15Controller_Keyboard::Controller_Keyboard() = default; 15Controller_Keyboard::Controller_Keyboard(Core::System& system)
16 : ControllerBase(system), system(system) {}
16Controller_Keyboard::~Controller_Keyboard() = default; 17Controller_Keyboard::~Controller_Keyboard() = default;
17 18
18void Controller_Keyboard::OnInit() {} 19void Controller_Keyboard::OnInit() {}
diff --git a/src/core/hle/service/hid/controllers/keyboard.h b/src/core/hle/service/hid/controllers/keyboard.h
index 73cd2c7bb..ef586f7eb 100644
--- a/src/core/hle/service/hid/controllers/keyboard.h
+++ b/src/core/hle/service/hid/controllers/keyboard.h
@@ -15,7 +15,7 @@
15namespace Service::HID { 15namespace Service::HID {
16class Controller_Keyboard final : public ControllerBase { 16class Controller_Keyboard final : public ControllerBase {
17public: 17public:
18 Controller_Keyboard(); 18 explicit Controller_Keyboard(Core::System& system);
19 ~Controller_Keyboard() override; 19 ~Controller_Keyboard() override;
20 20
21 // Called when the controller is initialized 21 // Called when the controller is initialized
@@ -53,5 +53,6 @@ private:
53 keyboard_keys; 53 keyboard_keys;
54 std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeKeyboard::NumKeyboardMods> 54 std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeKeyboard::NumKeyboardMods>
55 keyboard_mods; 55 keyboard_mods;
56 Core::System& system;
56}; 57};
57} // namespace Service::HID 58} // namespace Service::HID
diff --git a/src/core/hle/service/hid/controllers/mouse.cpp b/src/core/hle/service/hid/controllers/mouse.cpp
index 11ab096d9..88f2ca4c1 100644
--- a/src/core/hle/service/hid/controllers/mouse.cpp
+++ b/src/core/hle/service/hid/controllers/mouse.cpp
@@ -11,7 +11,7 @@
11namespace Service::HID { 11namespace Service::HID {
12constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3400; 12constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3400;
13 13
14Controller_Mouse::Controller_Mouse() = default; 14Controller_Mouse::Controller_Mouse(Core::System& system) : ControllerBase(system), system(system) {}
15Controller_Mouse::~Controller_Mouse() = default; 15Controller_Mouse::~Controller_Mouse() = default;
16 16
17void Controller_Mouse::OnInit() {} 17void Controller_Mouse::OnInit() {}
diff --git a/src/core/hle/service/hid/controllers/mouse.h b/src/core/hle/service/hid/controllers/mouse.h
index 9d46eecbe..df2da6ae3 100644
--- a/src/core/hle/service/hid/controllers/mouse.h
+++ b/src/core/hle/service/hid/controllers/mouse.h
@@ -14,7 +14,7 @@
14namespace Service::HID { 14namespace Service::HID {
15class Controller_Mouse final : public ControllerBase { 15class Controller_Mouse final : public ControllerBase {
16public: 16public:
17 Controller_Mouse(); 17 explicit Controller_Mouse(Core::System& system);
18 ~Controller_Mouse() override; 18 ~Controller_Mouse() override;
19 19
20 // Called when the controller is initialized 20 // Called when the controller is initialized
@@ -53,5 +53,6 @@ private:
53 std::unique_ptr<Input::MouseDevice> mouse_device; 53 std::unique_ptr<Input::MouseDevice> mouse_device;
54 std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeMouseButton::NumMouseButtons> 54 std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeMouseButton::NumMouseButtons>
55 mouse_button_devices; 55 mouse_button_devices;
56 Core::System& system;
56}; 57};
57} // namespace Service::HID 58} // namespace Service::HID
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index e47fe8188..f7a0aa4ff 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -93,7 +93,7 @@ u32 Controller_NPad::IndexToNPad(std::size_t index) {
93 }; 93 };
94} 94}
95 95
96Controller_NPad::Controller_NPad() = default; 96Controller_NPad::Controller_NPad(Core::System& system) : ControllerBase(system), system(system) {}
97Controller_NPad::~Controller_NPad() = default; 97Controller_NPad::~Controller_NPad() = default;
98 98
99void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) { 99void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) {
@@ -168,7 +168,7 @@ void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) {
168} 168}
169 169
170void Controller_NPad::OnInit() { 170void Controller_NPad::OnInit() {
171 auto& kernel = Core::System::GetInstance().Kernel(); 171 auto& kernel = system.Kernel();
172 styleset_changed_event = Kernel::WritableEvent::CreateEventPair( 172 styleset_changed_event = Kernel::WritableEvent::CreateEventPair(
173 kernel, Kernel::ResetType::Automatic, "npad:NpadStyleSetChanged"); 173 kernel, Kernel::ResetType::Automatic, "npad:NpadStyleSetChanged");
174 174
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h
index f28b36806..f72a9900c 100644
--- a/src/core/hle/service/hid/controllers/npad.h
+++ b/src/core/hle/service/hid/controllers/npad.h
@@ -20,7 +20,7 @@ constexpr u32 NPAD_UNKNOWN = 16; // TODO(ogniK): What is this?
20 20
21class Controller_NPad final : public ControllerBase { 21class Controller_NPad final : public ControllerBase {
22public: 22public:
23 Controller_NPad(); 23 explicit Controller_NPad(Core::System& system);
24 ~Controller_NPad() override; 24 ~Controller_NPad() override;
25 25
26 // Called when the controller is initialized 26 // Called when the controller is initialized
@@ -327,5 +327,6 @@ private:
327 std::array<ControllerPad, 10> npad_pad_states{}; 327 std::array<ControllerPad, 10> npad_pad_states{};
328 bool IsControllerSupported(NPadControllerType controller); 328 bool IsControllerSupported(NPadControllerType controller);
329 bool is_in_lr_assignment_mode{false}; 329 bool is_in_lr_assignment_mode{false};
330 Core::System& system;
330}; 331};
331} // namespace Service::HID 332} // namespace Service::HID
diff --git a/src/core/hle/service/hid/controllers/stubbed.cpp b/src/core/hle/service/hid/controllers/stubbed.cpp
index 946948f5e..9b829341e 100644
--- a/src/core/hle/service/hid/controllers/stubbed.cpp
+++ b/src/core/hle/service/hid/controllers/stubbed.cpp
@@ -9,7 +9,8 @@
9 9
10namespace Service::HID { 10namespace Service::HID {
11 11
12Controller_Stubbed::Controller_Stubbed() = default; 12Controller_Stubbed::Controller_Stubbed(Core::System& system)
13 : ControllerBase(system), system(system) {}
13Controller_Stubbed::~Controller_Stubbed() = default; 14Controller_Stubbed::~Controller_Stubbed() = default;
14 15
15void Controller_Stubbed::OnInit() {} 16void Controller_Stubbed::OnInit() {}
diff --git a/src/core/hle/service/hid/controllers/stubbed.h b/src/core/hle/service/hid/controllers/stubbed.h
index 24469f03e..37d7d8538 100644
--- a/src/core/hle/service/hid/controllers/stubbed.h
+++ b/src/core/hle/service/hid/controllers/stubbed.h
@@ -10,7 +10,7 @@
10namespace Service::HID { 10namespace Service::HID {
11class Controller_Stubbed final : public ControllerBase { 11class Controller_Stubbed final : public ControllerBase {
12public: 12public:
13 Controller_Stubbed(); 13 explicit Controller_Stubbed(Core::System& system);
14 ~Controller_Stubbed() override; 14 ~Controller_Stubbed() override;
15 15
16 // Called when the controller is initialized 16 // Called when the controller is initialized
@@ -30,5 +30,6 @@ public:
30private: 30private:
31 bool smart_update{}; 31 bool smart_update{};
32 std::size_t common_offset{}; 32 std::size_t common_offset{};
33 Core::System& system;
33}; 34};
34} // namespace Service::HID 35} // namespace Service::HID
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp
index 1a8445a43..25912fd69 100644
--- a/src/core/hle/service/hid/controllers/touchscreen.cpp
+++ b/src/core/hle/service/hid/controllers/touchscreen.cpp
@@ -13,7 +13,8 @@
13namespace Service::HID { 13namespace Service::HID {
14constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400; 14constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400;
15 15
16Controller_Touchscreen::Controller_Touchscreen() = default; 16Controller_Touchscreen::Controller_Touchscreen(Core::System& system)
17 : ControllerBase(system), system(system) {}
17Controller_Touchscreen::~Controller_Touchscreen() = default; 18Controller_Touchscreen::~Controller_Touchscreen() = default;
18 19
19void Controller_Touchscreen::OnInit() {} 20void Controller_Touchscreen::OnInit() {}
diff --git a/src/core/hle/service/hid/controllers/touchscreen.h b/src/core/hle/service/hid/controllers/touchscreen.h
index 76fc340e9..3429c84db 100644
--- a/src/core/hle/service/hid/controllers/touchscreen.h
+++ b/src/core/hle/service/hid/controllers/touchscreen.h
@@ -14,7 +14,7 @@
14namespace Service::HID { 14namespace Service::HID {
15class Controller_Touchscreen final : public ControllerBase { 15class Controller_Touchscreen final : public ControllerBase {
16public: 16public:
17 Controller_Touchscreen(); 17 explicit Controller_Touchscreen(Core::System& system);
18 ~Controller_Touchscreen() override; 18 ~Controller_Touchscreen() override;
19 19
20 // Called when the controller is initialized 20 // Called when the controller is initialized
@@ -69,5 +69,6 @@ private:
69 TouchScreenSharedMemory shared_memory{}; 69 TouchScreenSharedMemory shared_memory{};
70 std::unique_ptr<Input::TouchDevice> touch_device; 70 std::unique_ptr<Input::TouchDevice> touch_device;
71 s64_le last_touch{}; 71 s64_le last_touch{};
72 Core::System& system;
72}; 73};
73} // namespace Service::HID 74} // namespace Service::HID
diff --git a/src/core/hle/service/hid/controllers/xpad.cpp b/src/core/hle/service/hid/controllers/xpad.cpp
index 1a9da9576..1bce044b4 100644
--- a/src/core/hle/service/hid/controllers/xpad.cpp
+++ b/src/core/hle/service/hid/controllers/xpad.cpp
@@ -10,7 +10,7 @@
10namespace Service::HID { 10namespace Service::HID {
11constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C00; 11constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C00;
12 12
13Controller_XPad::Controller_XPad() = default; 13Controller_XPad::Controller_XPad(Core::System& system) : ControllerBase(system), system(system) {}
14Controller_XPad::~Controller_XPad() = default; 14Controller_XPad::~Controller_XPad() = default;
15 15
16void Controller_XPad::OnInit() {} 16void Controller_XPad::OnInit() {}
diff --git a/src/core/hle/service/hid/controllers/xpad.h b/src/core/hle/service/hid/controllers/xpad.h
index 2864e6617..c445ebec0 100644
--- a/src/core/hle/service/hid/controllers/xpad.h
+++ b/src/core/hle/service/hid/controllers/xpad.h
@@ -12,7 +12,7 @@
12namespace Service::HID { 12namespace Service::HID {
13class Controller_XPad final : public ControllerBase { 13class Controller_XPad final : public ControllerBase {
14public: 14public:
15 Controller_XPad(); 15 explicit Controller_XPad(Core::System& system);
16 ~Controller_XPad() override; 16 ~Controller_XPad() override;
17 17
18 // Called when the controller is initialized 18 // Called when the controller is initialized
@@ -56,5 +56,6 @@ private:
56 }; 56 };
57 static_assert(sizeof(SharedMemory) == 0x1000, "SharedMemory is an invalid size"); 57 static_assert(sizeof(SharedMemory) == 0x1000, "SharedMemory is an invalid size");
58 SharedMemory shared_memory{}; 58 SharedMemory shared_memory{};
59 Core::System& system;
59}; 60};
60} // namespace Service::HID 61} // namespace Service::HID
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index f8b1ca816..33145b891 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -42,13 +42,14 @@ constexpr s64 accelerometer_update_ticks = static_cast<s64>(Core::Timing::BASE_C
42constexpr s64 gyroscope_update_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 100); 42constexpr s64 gyroscope_update_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 100);
43constexpr std::size_t SHARED_MEMORY_SIZE = 0x40000; 43constexpr std::size_t SHARED_MEMORY_SIZE = 0x40000;
44 44
45IAppletResource::IAppletResource() : ServiceFramework("IAppletResource") { 45IAppletResource::IAppletResource(Core::System& system)
46 : ServiceFramework("IAppletResource"), system(system) {
46 static const FunctionInfo functions[] = { 47 static const FunctionInfo functions[] = {
47 {0, &IAppletResource::GetSharedMemoryHandle, "GetSharedMemoryHandle"}, 48 {0, &IAppletResource::GetSharedMemoryHandle, "GetSharedMemoryHandle"},
48 }; 49 };
49 RegisterHandlers(functions); 50 RegisterHandlers(functions);
50 51
51 auto& kernel = Core::System::GetInstance().Kernel(); 52 auto& kernel = system.Kernel();
52 shared_mem = Kernel::SharedMemory::Create( 53 shared_mem = Kernel::SharedMemory::Create(
53 kernel, nullptr, SHARED_MEMORY_SIZE, Kernel::MemoryPermission::ReadWrite, 54 kernel, nullptr, SHARED_MEMORY_SIZE, Kernel::MemoryPermission::ReadWrite,
54 Kernel::MemoryPermission::Read, 0, Kernel::MemoryRegion::BASE, "HID:SharedMemory"); 55 Kernel::MemoryPermission::Read, 0, Kernel::MemoryRegion::BASE, "HID:SharedMemory");
@@ -74,7 +75,7 @@ IAppletResource::IAppletResource() : ServiceFramework("IAppletResource") {
74 GetController<Controller_Stubbed>(HidController::Unknown3).SetCommonHeaderOffset(0x5000); 75 GetController<Controller_Stubbed>(HidController::Unknown3).SetCommonHeaderOffset(0x5000);
75 76
76 // Register update callbacks 77 // Register update callbacks
77 auto& core_timing = Core::System::GetInstance().CoreTiming(); 78 auto& core_timing = system.CoreTiming();
78 pad_update_event = 79 pad_update_event =
79 core_timing.RegisterEvent("HID::UpdatePadCallback", [this](u64 userdata, s64 cycles_late) { 80 core_timing.RegisterEvent("HID::UpdatePadCallback", [this](u64 userdata, s64 cycles_late) {
80 UpdateControllers(userdata, cycles_late); 81 UpdateControllers(userdata, cycles_late);
@@ -96,7 +97,7 @@ void IAppletResource::DeactivateController(HidController controller) {
96} 97}
97 98
98IAppletResource ::~IAppletResource() { 99IAppletResource ::~IAppletResource() {
99 Core::System::GetInstance().CoreTiming().UnscheduleEvent(pad_update_event, 0); 100 system.CoreTiming().UnscheduleEvent(pad_update_event, 0);
100} 101}
101 102
102void IAppletResource::GetSharedMemoryHandle(Kernel::HLERequestContext& ctx) { 103void IAppletResource::GetSharedMemoryHandle(Kernel::HLERequestContext& ctx) {
@@ -108,7 +109,7 @@ void IAppletResource::GetSharedMemoryHandle(Kernel::HLERequestContext& ctx) {
108} 109}
109 110
110void IAppletResource::UpdateControllers(u64 userdata, s64 cycles_late) { 111void IAppletResource::UpdateControllers(u64 userdata, s64 cycles_late) {
111 auto& core_timing = Core::System::GetInstance().CoreTiming(); 112 auto& core_timing = system.CoreTiming();
112 113
113 const bool should_reload = Settings::values.is_device_reload_pending.exchange(false); 114 const bool should_reload = Settings::values.is_device_reload_pending.exchange(false);
114 for (const auto& controller : controllers) { 115 for (const auto& controller : controllers) {
@@ -141,13 +142,13 @@ private:
141 142
142std::shared_ptr<IAppletResource> Hid::GetAppletResource() { 143std::shared_ptr<IAppletResource> Hid::GetAppletResource() {
143 if (applet_resource == nullptr) { 144 if (applet_resource == nullptr) {
144 applet_resource = std::make_shared<IAppletResource>(); 145 applet_resource = std::make_shared<IAppletResource>(system);
145 } 146 }
146 147
147 return applet_resource; 148 return applet_resource;
148} 149}
149 150
150Hid::Hid() : ServiceFramework("hid") { 151Hid::Hid(Core::System& system) : ServiceFramework("hid"), system(system) {
151 // clang-format off 152 // clang-format off
152 static const FunctionInfo functions[] = { 153 static const FunctionInfo functions[] = {
153 {0, &Hid::CreateAppletResource, "CreateAppletResource"}, 154 {0, &Hid::CreateAppletResource, "CreateAppletResource"},
@@ -286,7 +287,7 @@ void Hid::CreateAppletResource(Kernel::HLERequestContext& ctx) {
286 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); 287 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
287 288
288 if (applet_resource == nullptr) { 289 if (applet_resource == nullptr) {
289 applet_resource = std::make_shared<IAppletResource>(); 290 applet_resource = std::make_shared<IAppletResource>(system);
290 } 291 }
291 292
292 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 293 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@@ -1053,14 +1054,14 @@ void ReloadInputDevices() {
1053 Settings::values.is_device_reload_pending.store(true); 1054 Settings::values.is_device_reload_pending.store(true);
1054} 1055}
1055 1056
1056void InstallInterfaces(SM::ServiceManager& service_manager) { 1057void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
1057 std::make_shared<Hid>()->InstallAsService(service_manager); 1058 std::make_shared<Hid>(system)->InstallAsService(service_manager);
1058 std::make_shared<HidBus>()->InstallAsService(service_manager); 1059 std::make_shared<HidBus>()->InstallAsService(service_manager);
1059 std::make_shared<HidDbg>()->InstallAsService(service_manager); 1060 std::make_shared<HidDbg>()->InstallAsService(service_manager);
1060 std::make_shared<HidSys>()->InstallAsService(service_manager); 1061 std::make_shared<HidSys>()->InstallAsService(service_manager);
1061 std::make_shared<HidTmp>()->InstallAsService(service_manager); 1062 std::make_shared<HidTmp>()->InstallAsService(service_manager);
1062 1063
1063 std::make_shared<IRS>()->InstallAsService(service_manager); 1064 std::make_shared<IRS>(system)->InstallAsService(service_manager);
1064 std::make_shared<IRS_SYS>()->InstallAsService(service_manager); 1065 std::make_shared<IRS_SYS>()->InstallAsService(service_manager);
1065 1066
1066 std::make_shared<XCD_SYS>()->InstallAsService(service_manager); 1067 std::make_shared<XCD_SYS>()->InstallAsService(service_manager);
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h
index 2fd6d9fc7..35b663679 100644
--- a/src/core/hle/service/hid/hid.h
+++ b/src/core/hle/service/hid/hid.h
@@ -42,7 +42,7 @@ enum class HidController : std::size_t {
42 42
43class IAppletResource final : public ServiceFramework<IAppletResource> { 43class IAppletResource final : public ServiceFramework<IAppletResource> {
44public: 44public:
45 IAppletResource(); 45 explicit IAppletResource(Core::System& system);
46 ~IAppletResource() override; 46 ~IAppletResource() override;
47 47
48 void ActivateController(HidController controller); 48 void ActivateController(HidController controller);
@@ -61,7 +61,7 @@ public:
61private: 61private:
62 template <typename T> 62 template <typename T>
63 void MakeController(HidController controller) { 63 void MakeController(HidController controller) {
64 controllers[static_cast<std::size_t>(controller)] = std::make_unique<T>(); 64 controllers[static_cast<std::size_t>(controller)] = std::make_unique<T>(system);
65 } 65 }
66 66
67 void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx); 67 void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx);
@@ -70,6 +70,7 @@ private:
70 Kernel::SharedPtr<Kernel::SharedMemory> shared_mem; 70 Kernel::SharedPtr<Kernel::SharedMemory> shared_mem;
71 71
72 Core::Timing::EventType* pad_update_event; 72 Core::Timing::EventType* pad_update_event;
73 Core::System& system;
73 74
74 std::array<std::unique_ptr<ControllerBase>, static_cast<size_t>(HidController::MaxControllers)> 75 std::array<std::unique_ptr<ControllerBase>, static_cast<size_t>(HidController::MaxControllers)>
75 controllers{}; 76 controllers{};
@@ -77,7 +78,7 @@ private:
77 78
78class Hid final : public ServiceFramework<Hid> { 79class Hid final : public ServiceFramework<Hid> {
79public: 80public:
80 Hid(); 81 explicit Hid(Core::System& system);
81 ~Hid() override; 82 ~Hid() override;
82 83
83 std::shared_ptr<IAppletResource> GetAppletResource(); 84 std::shared_ptr<IAppletResource> GetAppletResource();
@@ -126,12 +127,13 @@ private:
126 void SwapNpadAssignment(Kernel::HLERequestContext& ctx); 127 void SwapNpadAssignment(Kernel::HLERequestContext& ctx);
127 128
128 std::shared_ptr<IAppletResource> applet_resource; 129 std::shared_ptr<IAppletResource> applet_resource;
130 Core::System& system;
129}; 131};
130 132
131/// Reload input devices. Used when input configuration changed 133/// Reload input devices. Used when input configuration changed
132void ReloadInputDevices(); 134void ReloadInputDevices();
133 135
134/// Registers all HID services with the specified service manager. 136/// Registers all HID services with the specified service manager.
135void InstallInterfaces(SM::ServiceManager& service_manager); 137void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
136 138
137} // namespace Service::HID 139} // namespace Service::HID
diff --git a/src/core/hle/service/hid/irs.cpp b/src/core/hle/service/hid/irs.cpp
index 2c4625c99..5e79e2c1a 100644
--- a/src/core/hle/service/hid/irs.cpp
+++ b/src/core/hle/service/hid/irs.cpp
@@ -11,7 +11,7 @@
11 11
12namespace Service::HID { 12namespace Service::HID {
13 13
14IRS::IRS() : ServiceFramework{"irs"} { 14IRS::IRS(Core::System& system) : ServiceFramework{"irs"}, system(system) {
15 // clang-format off 15 // clang-format off
16 static const FunctionInfo functions[] = { 16 static const FunctionInfo functions[] = {
17 {302, &IRS::ActivateIrsensor, "ActivateIrsensor"}, 17 {302, &IRS::ActivateIrsensor, "ActivateIrsensor"},
@@ -37,7 +37,7 @@ IRS::IRS() : ServiceFramework{"irs"} {
37 37
38 RegisterHandlers(functions); 38 RegisterHandlers(functions);
39 39
40 auto& kernel = Core::System::GetInstance().Kernel(); 40 auto& kernel = system.Kernel();
41 shared_mem = Kernel::SharedMemory::Create( 41 shared_mem = Kernel::SharedMemory::Create(
42 kernel, nullptr, 0x8000, Kernel::MemoryPermission::ReadWrite, 42 kernel, nullptr, 0x8000, Kernel::MemoryPermission::ReadWrite,
43 Kernel::MemoryPermission::Read, 0, Kernel::MemoryRegion::BASE, "IRS:SharedMemory"); 43 Kernel::MemoryPermission::Read, 0, Kernel::MemoryRegion::BASE, "IRS:SharedMemory");
@@ -98,7 +98,7 @@ void IRS::GetImageTransferProcessorState(Kernel::HLERequestContext& ctx) {
98 98
99 IPC::ResponseBuilder rb{ctx, 5}; 99 IPC::ResponseBuilder rb{ctx, 5};
100 rb.Push(RESULT_SUCCESS); 100 rb.Push(RESULT_SUCCESS);
101 rb.PushRaw<u64>(Core::System::GetInstance().CoreTiming().GetTicks()); 101 rb.PushRaw<u64>(system.CoreTiming().GetTicks());
102 rb.PushRaw<u32>(0); 102 rb.PushRaw<u32>(0);
103} 103}
104 104
diff --git a/src/core/hle/service/hid/irs.h b/src/core/hle/service/hid/irs.h
index 12de6bfb3..eb4e898dd 100644
--- a/src/core/hle/service/hid/irs.h
+++ b/src/core/hle/service/hid/irs.h
@@ -15,7 +15,7 @@ namespace Service::HID {
15 15
16class IRS final : public ServiceFramework<IRS> { 16class IRS final : public ServiceFramework<IRS> {
17public: 17public:
18 explicit IRS(); 18 explicit IRS(Core::System& system);
19 ~IRS() override; 19 ~IRS() override;
20 20
21private: 21private:
@@ -39,6 +39,7 @@ private:
39 void ActivateIrsensorWithFunctionLevel(Kernel::HLERequestContext& ctx); 39 void ActivateIrsensorWithFunctionLevel(Kernel::HLERequestContext& ctx);
40 Kernel::SharedPtr<Kernel::SharedMemory> shared_mem; 40 Kernel::SharedPtr<Kernel::SharedMemory> shared_mem;
41 const u32 device_handle{0xABCD}; 41 const u32 device_handle{0xABCD};
42 Core::System& system;
42}; 43};
43 44
44class IRS_SYS final : public ServiceFramework<IRS_SYS> { 45class IRS_SYS final : public ServiceFramework<IRS_SYS> {
diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp
index 8ddad8682..3164ca26e 100644
--- a/src/core/hle/service/ldr/ldr.cpp
+++ b/src/core/hle/service/ldr/ldr.cpp
@@ -78,7 +78,7 @@ public:
78 78
79class RelocatableObject final : public ServiceFramework<RelocatableObject> { 79class RelocatableObject final : public ServiceFramework<RelocatableObject> {
80public: 80public:
81 explicit RelocatableObject() : ServiceFramework{"ldr:ro"} { 81 explicit RelocatableObject(Core::System& system) : ServiceFramework{"ldr:ro"}, system(system) {
82 // clang-format off 82 // clang-format off
83 static const FunctionInfo functions[] = { 83 static const FunctionInfo functions[] = {
84 {0, &RelocatableObject::LoadNro, "LoadNro"}, 84 {0, &RelocatableObject::LoadNro, "LoadNro"},
@@ -364,7 +364,7 @@ public:
364 vm_manager.ReprotectRange(*map_address + header.rw_offset, header.rw_size, 364 vm_manager.ReprotectRange(*map_address + header.rw_offset, header.rw_size,
365 Kernel::VMAPermission::ReadWrite); 365 Kernel::VMAPermission::ReadWrite);
366 366
367 Core::System::GetInstance().InvalidateCpuInstructionCaches(); 367 system.InvalidateCpuInstructionCaches();
368 368
369 nro.insert_or_assign(*map_address, 369 nro.insert_or_assign(*map_address,
370 NROInfo{hash, nro_address, nro_size, bss_address, bss_size}); 370 NROInfo{hash, nro_address, nro_size, bss_address, bss_size});
@@ -430,7 +430,7 @@ public:
430 .IsSuccess()); 430 .IsSuccess());
431 } 431 }
432 432
433 Core::System::GetInstance().InvalidateCpuInstructionCaches(); 433 system.InvalidateCpuInstructionCaches();
434 434
435 nro.erase(iter); 435 nro.erase(iter);
436 IPC::ResponseBuilder rb{ctx, 2}; 436 IPC::ResponseBuilder rb{ctx, 2};
@@ -516,13 +516,14 @@ private:
516 Common::Is4KBAligned(header.text_size) && Common::Is4KBAligned(header.ro_size) && 516 Common::Is4KBAligned(header.text_size) && Common::Is4KBAligned(header.ro_size) &&
517 Common::Is4KBAligned(header.rw_size); 517 Common::Is4KBAligned(header.rw_size);
518 } 518 }
519 Core::System& system;
519}; 520};
520 521
521void InstallInterfaces(SM::ServiceManager& sm) { 522void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
522 std::make_shared<DebugMonitor>()->InstallAsService(sm); 523 std::make_shared<DebugMonitor>()->InstallAsService(sm);
523 std::make_shared<ProcessManager>()->InstallAsService(sm); 524 std::make_shared<ProcessManager>()->InstallAsService(sm);
524 std::make_shared<Shell>()->InstallAsService(sm); 525 std::make_shared<Shell>()->InstallAsService(sm);
525 std::make_shared<RelocatableObject>()->InstallAsService(sm); 526 std::make_shared<RelocatableObject>(system)->InstallAsService(sm);
526} 527}
527 528
528} // namespace Service::LDR 529} // namespace Service::LDR
diff --git a/src/core/hle/service/ldr/ldr.h b/src/core/hle/service/ldr/ldr.h
index 412410c4f..7ac8c0b65 100644
--- a/src/core/hle/service/ldr/ldr.h
+++ b/src/core/hle/service/ldr/ldr.h
@@ -11,6 +11,6 @@ class ServiceManager;
11namespace Service::LDR { 11namespace Service::LDR {
12 12
13/// Registers all LDR services with the specified service manager. 13/// Registers all LDR services with the specified service manager.
14void InstallInterfaces(SM::ServiceManager& sm); 14void InstallInterfaces(SM::ServiceManager& sm, Core::System& system);
15 15
16} // namespace Service::LDR 16} // namespace Service::LDR
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp
index a5cb06f8a..a42c22d44 100644
--- a/src/core/hle/service/nfp/nfp.cpp
+++ b/src/core/hle/service/nfp/nfp.cpp
@@ -23,9 +23,9 @@ constexpr ResultCode ERR_TAG_FAILED(ErrorModule::NFP,
23constexpr ResultCode ERR_NO_APPLICATION_AREA(ErrorModule::NFP, 152); 23constexpr ResultCode ERR_NO_APPLICATION_AREA(ErrorModule::NFP, 152);
24} // namespace ErrCodes 24} // namespace ErrCodes
25 25
26Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) 26Module::Interface::Interface(std::shared_ptr<Module> module, Core::System& system, const char* name)
27 : ServiceFramework(name), module(std::move(module)) { 27 : ServiceFramework(name), module(std::move(module)), system(system) {
28 auto& kernel = Core::System::GetInstance().Kernel(); 28 auto& kernel = system.Kernel();
29 nfc_tag_load = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic, 29 nfc_tag_load = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic,
30 "IUser:NFCTagDetected"); 30 "IUser:NFCTagDetected");
31} 31}
@@ -34,8 +34,8 @@ Module::Interface::~Interface() = default;
34 34
35class IUser final : public ServiceFramework<IUser> { 35class IUser final : public ServiceFramework<IUser> {
36public: 36public:
37 IUser(Module::Interface& nfp_interface) 37 IUser(Module::Interface& nfp_interface, Core::System& system)
38 : ServiceFramework("NFP::IUser"), nfp_interface(nfp_interface) { 38 : ServiceFramework("NFP::IUser"), nfp_interface(nfp_interface), system(system) {
39 static const FunctionInfo functions[] = { 39 static const FunctionInfo functions[] = {
40 {0, &IUser::Initialize, "Initialize"}, 40 {0, &IUser::Initialize, "Initialize"},
41 {1, &IUser::Finalize, "Finalize"}, 41 {1, &IUser::Finalize, "Finalize"},
@@ -65,7 +65,7 @@ public:
65 }; 65 };
66 RegisterHandlers(functions); 66 RegisterHandlers(functions);
67 67
68 auto& kernel = Core::System::GetInstance().Kernel(); 68 auto& kernel = system.Kernel();
69 deactivate_event = Kernel::WritableEvent::CreateEventPair( 69 deactivate_event = Kernel::WritableEvent::CreateEventPair(
70 kernel, Kernel::ResetType::Automatic, "IUser:DeactivateEvent"); 70 kernel, Kernel::ResetType::Automatic, "IUser:DeactivateEvent");
71 availability_change_event = Kernel::WritableEvent::CreateEventPair( 71 availability_change_event = Kernel::WritableEvent::CreateEventPair(
@@ -324,6 +324,7 @@ private:
324 Kernel::EventPair deactivate_event; 324 Kernel::EventPair deactivate_event;
325 Kernel::EventPair availability_change_event; 325 Kernel::EventPair availability_change_event;
326 const Module::Interface& nfp_interface; 326 const Module::Interface& nfp_interface;
327 Core::System& system;
327}; 328};
328 329
329void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) { 330void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) {
@@ -331,7 +332,7 @@ void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) {
331 332
332 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 333 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
333 rb.Push(RESULT_SUCCESS); 334 rb.Push(RESULT_SUCCESS);
334 rb.PushIpcInterface<IUser>(*this); 335 rb.PushIpcInterface<IUser>(*this, system);
335} 336}
336 337
337bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) { 338bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) {
@@ -353,9 +354,9 @@ const Module::Interface::AmiiboFile& Module::Interface::GetAmiiboBuffer() const
353 return amiibo; 354 return amiibo;
354} 355}
355 356
356void InstallInterfaces(SM::ServiceManager& service_manager) { 357void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
357 auto module = std::make_shared<Module>(); 358 auto module = std::make_shared<Module>();
358 std::make_shared<NFP_User>(module)->InstallAsService(service_manager); 359 std::make_shared<NFP_User>(module, system)->InstallAsService(service_manager);
359} 360}
360 361
361} // namespace Service::NFP 362} // namespace Service::NFP
diff --git a/src/core/hle/service/nfp/nfp.h b/src/core/hle/service/nfp/nfp.h
index a1817e991..9718ef745 100644
--- a/src/core/hle/service/nfp/nfp.h
+++ b/src/core/hle/service/nfp/nfp.h
@@ -16,7 +16,7 @@ class Module final {
16public: 16public:
17 class Interface : public ServiceFramework<Interface> { 17 class Interface : public ServiceFramework<Interface> {
18 public: 18 public:
19 explicit Interface(std::shared_ptr<Module> module, const char* name); 19 explicit Interface(std::shared_ptr<Module> module, Core::System& system, const char* name);
20 ~Interface() override; 20 ~Interface() override;
21 21
22 struct ModelInfo { 22 struct ModelInfo {
@@ -43,9 +43,10 @@ public:
43 43
44 protected: 44 protected:
45 std::shared_ptr<Module> module; 45 std::shared_ptr<Module> module;
46 Core::System& system;
46 }; 47 };
47}; 48};
48 49
49void InstallInterfaces(SM::ServiceManager& service_manager); 50void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
50 51
51} // namespace Service::NFP 52} // namespace Service::NFP
diff --git a/src/core/hle/service/nfp/nfp_user.cpp b/src/core/hle/service/nfp/nfp_user.cpp
index 784a87c1b..298184f17 100644
--- a/src/core/hle/service/nfp/nfp_user.cpp
+++ b/src/core/hle/service/nfp/nfp_user.cpp
@@ -6,8 +6,8 @@
6 6
7namespace Service::NFP { 7namespace Service::NFP {
8 8
9NFP_User::NFP_User(std::shared_ptr<Module> module) 9NFP_User::NFP_User(std::shared_ptr<Module> module, Core::System& system)
10 : Module::Interface(std::move(module), "nfp:user") { 10 : Module::Interface(std::move(module), system, "nfp:user") {
11 static const FunctionInfo functions[] = { 11 static const FunctionInfo functions[] = {
12 {0, &NFP_User::CreateUserInterface, "CreateUserInterface"}, 12 {0, &NFP_User::CreateUserInterface, "CreateUserInterface"},
13 }; 13 };
diff --git a/src/core/hle/service/nfp/nfp_user.h b/src/core/hle/service/nfp/nfp_user.h
index 65d9aaf48..1686ebf20 100644
--- a/src/core/hle/service/nfp/nfp_user.h
+++ b/src/core/hle/service/nfp/nfp_user.h
@@ -10,7 +10,7 @@ namespace Service::NFP {
10 10
11class NFP_User final : public Module::Interface { 11class NFP_User final : public Module::Interface {
12public: 12public:
13 explicit NFP_User(std::shared_ptr<Module> module); 13 explicit NFP_User(std::shared_ptr<Module> module, Core::System& system);
14 ~NFP_User() override; 14 ~NFP_User() override;
15}; 15};
16 16
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp
index 76b12b482..24d1813a7 100644
--- a/src/core/hle/service/nifm/nifm.cpp
+++ b/src/core/hle/service/nifm/nifm.cpp
@@ -31,7 +31,7 @@ public:
31 31
32class IRequest final : public ServiceFramework<IRequest> { 32class IRequest final : public ServiceFramework<IRequest> {
33public: 33public:
34 explicit IRequest() : ServiceFramework("IRequest") { 34 explicit IRequest(Core::System& system) : ServiceFramework("IRequest") {
35 static const FunctionInfo functions[] = { 35 static const FunctionInfo functions[] = {
36 {0, &IRequest::GetRequestState, "GetRequestState"}, 36 {0, &IRequest::GetRequestState, "GetRequestState"},
37 {1, &IRequest::GetResult, "GetResult"}, 37 {1, &IRequest::GetResult, "GetResult"},
@@ -61,7 +61,7 @@ public:
61 }; 61 };
62 RegisterHandlers(functions); 62 RegisterHandlers(functions);
63 63
64 auto& kernel = Core::System::GetInstance().Kernel(); 64 auto& kernel = system.Kernel();
65 event1 = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic, 65 event1 = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic,
66 "IRequest:Event1"); 66 "IRequest:Event1");
67 event2 = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic, 67 event2 = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic,
@@ -130,7 +130,7 @@ public:
130 130
131class IGeneralService final : public ServiceFramework<IGeneralService> { 131class IGeneralService final : public ServiceFramework<IGeneralService> {
132public: 132public:
133 IGeneralService(); 133 IGeneralService(Core::System& system);
134 134
135private: 135private:
136 void GetClientId(Kernel::HLERequestContext& ctx) { 136 void GetClientId(Kernel::HLERequestContext& ctx) {
@@ -155,7 +155,7 @@ private:
155 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 155 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
156 156
157 rb.Push(RESULT_SUCCESS); 157 rb.Push(RESULT_SUCCESS);
158 rb.PushIpcInterface<IRequest>(); 158 rb.PushIpcInterface<IRequest>(system);
159 } 159 }
160 void RemoveNetworkProfile(Kernel::HLERequestContext& ctx) { 160 void RemoveNetworkProfile(Kernel::HLERequestContext& ctx) {
161 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 161 LOG_WARNING(Service_NIFM, "(STUBBED) called");
@@ -198,9 +198,11 @@ private:
198 rb.Push(RESULT_SUCCESS); 198 rb.Push(RESULT_SUCCESS);
199 rb.Push<u8>(0); 199 rb.Push<u8>(0);
200 } 200 }
201 Core::System& system;
201}; 202};
202 203
203IGeneralService::IGeneralService() : ServiceFramework("IGeneralService") { 204IGeneralService::IGeneralService(Core::System& system)
205 : ServiceFramework("IGeneralService"), system(system) {
204 static const FunctionInfo functions[] = { 206 static const FunctionInfo functions[] = {
205 {1, &IGeneralService::GetClientId, "GetClientId"}, 207 {1, &IGeneralService::GetClientId, "GetClientId"},
206 {2, &IGeneralService::CreateScanRequest, "CreateScanRequest"}, 208 {2, &IGeneralService::CreateScanRequest, "CreateScanRequest"},
@@ -245,7 +247,8 @@ IGeneralService::IGeneralService() : ServiceFramework("IGeneralService") {
245 247
246class NetworkInterface final : public ServiceFramework<NetworkInterface> { 248class NetworkInterface final : public ServiceFramework<NetworkInterface> {
247public: 249public:
248 explicit NetworkInterface(const char* name) : ServiceFramework{name} { 250 explicit NetworkInterface(const char* name, Core::System& system)
251 : ServiceFramework{name}, system(system) {
249 static const FunctionInfo functions[] = { 252 static const FunctionInfo functions[] = {
250 {4, &NetworkInterface::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, 253 {4, &NetworkInterface::CreateGeneralServiceOld, "CreateGeneralServiceOld"},
251 {5, &NetworkInterface::CreateGeneralService, "CreateGeneralService"}, 254 {5, &NetworkInterface::CreateGeneralService, "CreateGeneralService"},
@@ -258,7 +261,7 @@ public:
258 261
259 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 262 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
260 rb.Push(RESULT_SUCCESS); 263 rb.Push(RESULT_SUCCESS);
261 rb.PushIpcInterface<IGeneralService>(); 264 rb.PushIpcInterface<IGeneralService>(system);
262 } 265 }
263 266
264 void CreateGeneralService(Kernel::HLERequestContext& ctx) { 267 void CreateGeneralService(Kernel::HLERequestContext& ctx) {
@@ -266,14 +269,17 @@ public:
266 269
267 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 270 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
268 rb.Push(RESULT_SUCCESS); 271 rb.Push(RESULT_SUCCESS);
269 rb.PushIpcInterface<IGeneralService>(); 272 rb.PushIpcInterface<IGeneralService>(system);
270 } 273 }
274
275private:
276 Core::System& system;
271}; 277};
272 278
273void InstallInterfaces(SM::ServiceManager& service_manager) { 279void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
274 std::make_shared<NetworkInterface>("nifm:a")->InstallAsService(service_manager); 280 std::make_shared<NetworkInterface>("nifm:a", system)->InstallAsService(service_manager);
275 std::make_shared<NetworkInterface>("nifm:s")->InstallAsService(service_manager); 281 std::make_shared<NetworkInterface>("nifm:s", system)->InstallAsService(service_manager);
276 std::make_shared<NetworkInterface>("nifm:u")->InstallAsService(service_manager); 282 std::make_shared<NetworkInterface>("nifm:u", system)->InstallAsService(service_manager);
277} 283}
278 284
279} // namespace Service::NIFM 285} // namespace Service::NIFM
diff --git a/src/core/hle/service/nifm/nifm.h b/src/core/hle/service/nifm/nifm.h
index 4616b3b48..6857e18f9 100644
--- a/src/core/hle/service/nifm/nifm.h
+++ b/src/core/hle/service/nifm/nifm.h
@@ -8,9 +8,13 @@ namespace Service::SM {
8class ServiceManager; 8class ServiceManager;
9} 9}
10 10
11namespace Core {
12class System;
13}
14
11namespace Service::NIFM { 15namespace Service::NIFM {
12 16
13/// Registers all NIFM services with the specified service manager. 17/// Registers all NIFM services with the specified service manager.
14void InstallInterfaces(SM::ServiceManager& service_manager); 18void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
15 19
16} // namespace Service::NIFM 20} // namespace Service::NIFM
diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp
index f319a3ca1..75d414952 100644
--- a/src/core/hle/service/nim/nim.cpp
+++ b/src/core/hle/service/nim/nim.cpp
@@ -126,7 +126,7 @@ public:
126class IEnsureNetworkClockAvailabilityService final 126class IEnsureNetworkClockAvailabilityService final
127 : public ServiceFramework<IEnsureNetworkClockAvailabilityService> { 127 : public ServiceFramework<IEnsureNetworkClockAvailabilityService> {
128public: 128public:
129 IEnsureNetworkClockAvailabilityService() 129 explicit IEnsureNetworkClockAvailabilityService(Core::System& system)
130 : ServiceFramework("IEnsureNetworkClockAvailabilityService") { 130 : ServiceFramework("IEnsureNetworkClockAvailabilityService") {
131 static const FunctionInfo functions[] = { 131 static const FunctionInfo functions[] = {
132 {0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"}, 132 {0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"},
@@ -139,7 +139,7 @@ public:
139 }; 139 };
140 RegisterHandlers(functions); 140 RegisterHandlers(functions);
141 141
142 auto& kernel = Core::System::GetInstance().Kernel(); 142 auto& kernel = system.Kernel();
143 finished_event = Kernel::WritableEvent::CreateEventPair( 143 finished_event = Kernel::WritableEvent::CreateEventPair(
144 kernel, Kernel::ResetType::Automatic, 144 kernel, Kernel::ResetType::Automatic,
145 "IEnsureNetworkClockAvailabilityService:FinishEvent"); 145 "IEnsureNetworkClockAvailabilityService:FinishEvent");
@@ -200,7 +200,7 @@ private:
200 200
201class NTC final : public ServiceFramework<NTC> { 201class NTC final : public ServiceFramework<NTC> {
202public: 202public:
203 explicit NTC() : ServiceFramework{"ntc"} { 203 explicit NTC(Core::System& system) : ServiceFramework{"ntc"}, system(system) {
204 // clang-format off 204 // clang-format off
205 static const FunctionInfo functions[] = { 205 static const FunctionInfo functions[] = {
206 {0, &NTC::OpenEnsureNetworkClockAvailabilityService, "OpenEnsureNetworkClockAvailabilityService"}, 206 {0, &NTC::OpenEnsureNetworkClockAvailabilityService, "OpenEnsureNetworkClockAvailabilityService"},
@@ -218,7 +218,7 @@ private:
218 218
219 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 219 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
220 rb.Push(RESULT_SUCCESS); 220 rb.Push(RESULT_SUCCESS);
221 rb.PushIpcInterface<IEnsureNetworkClockAvailabilityService>(); 221 rb.PushIpcInterface<IEnsureNetworkClockAvailabilityService>(system);
222 } 222 }
223 223
224 // TODO(ogniK): Do we need these? 224 // TODO(ogniK): Do we need these?
@@ -235,13 +235,14 @@ private:
235 IPC::ResponseBuilder rb{ctx, 2}; 235 IPC::ResponseBuilder rb{ctx, 2};
236 rb.Push(RESULT_SUCCESS); 236 rb.Push(RESULT_SUCCESS);
237 } 237 }
238 Core::System& system;
238}; 239};
239 240
240void InstallInterfaces(SM::ServiceManager& sm) { 241void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
241 std::make_shared<NIM>()->InstallAsService(sm); 242 std::make_shared<NIM>()->InstallAsService(sm);
242 std::make_shared<NIM_ECA>()->InstallAsService(sm); 243 std::make_shared<NIM_ECA>()->InstallAsService(sm);
243 std::make_shared<NIM_SHP>()->InstallAsService(sm); 244 std::make_shared<NIM_SHP>()->InstallAsService(sm);
244 std::make_shared<NTC>()->InstallAsService(sm); 245 std::make_shared<NTC>(system)->InstallAsService(sm);
245} 246}
246 247
247} // namespace Service::NIM 248} // namespace Service::NIM
diff --git a/src/core/hle/service/nim/nim.h b/src/core/hle/service/nim/nim.h
index 2a2a92df0..dbe25dc01 100644
--- a/src/core/hle/service/nim/nim.h
+++ b/src/core/hle/service/nim/nim.h
@@ -8,8 +8,12 @@ namespace Service::SM {
8class ServiceManager; 8class ServiceManager;
9} 9}
10 10
11namespace Core {
12class System;
13}
14
11namespace Service::NIM { 15namespace Service::NIM {
12 16
13void InstallInterfaces(SM::ServiceManager& sm); 17void InstallInterfaces(SM::ServiceManager& sm, Core::System& system);
14 18
15} // namespace Service::NIM 19} // namespace Service::NIM
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp
index 13121c4f1..15c156ce1 100644
--- a/src/core/hle/service/ns/ns.cpp
+++ b/src/core/hle/service/ns/ns.cpp
@@ -617,7 +617,8 @@ public:
617 } 617 }
618}; 618};
619 619
620void InstallInterfaces(SM::ServiceManager& service_manager, FileSystem::FileSystemController& fsc) { 620void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
621
621 std::make_shared<NS>("ns:am2")->InstallAsService(service_manager); 622 std::make_shared<NS>("ns:am2")->InstallAsService(service_manager);
622 std::make_shared<NS>("ns:ec")->InstallAsService(service_manager); 623 std::make_shared<NS>("ns:ec")->InstallAsService(service_manager);
623 std::make_shared<NS>("ns:rid")->InstallAsService(service_manager); 624 std::make_shared<NS>("ns:rid")->InstallAsService(service_manager);
@@ -628,7 +629,7 @@ void InstallInterfaces(SM::ServiceManager& service_manager, FileSystem::FileSyst
628 std::make_shared<NS_SU>()->InstallAsService(service_manager); 629 std::make_shared<NS_SU>()->InstallAsService(service_manager);
629 std::make_shared<NS_VM>()->InstallAsService(service_manager); 630 std::make_shared<NS_VM>()->InstallAsService(service_manager);
630 631
631 std::make_shared<PL_U>(fsc)->InstallAsService(service_manager); 632 std::make_shared<PL_U>(system)->InstallAsService(service_manager);
632} 633}
633 634
634} // namespace Service::NS 635} // namespace Service::NS
diff --git a/src/core/hle/service/ns/ns.h b/src/core/hle/service/ns/ns.h
index d067e7a9a..13a64ad88 100644
--- a/src/core/hle/service/ns/ns.h
+++ b/src/core/hle/service/ns/ns.h
@@ -97,8 +97,7 @@ private:
97}; 97};
98 98
99/// Registers all NS services with the specified service manager. 99/// Registers all NS services with the specified service manager.
100void InstallInterfaces(SM::ServiceManager& service_manager, FileSystem::FileSystemController& fsc); 100void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
101 101
102} // namespace NS 102} // namespace NS
103
104} // namespace Service 103} // namespace Service
diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp
index 9d49f36e8..7dcdb4a07 100644
--- a/src/core/hle/service/ns/pl_u.cpp
+++ b/src/core/hle/service/ns/pl_u.cpp
@@ -150,8 +150,9 @@ struct PL_U::Impl {
150 std::vector<FontRegion> shared_font_regions; 150 std::vector<FontRegion> shared_font_regions;
151}; 151};
152 152
153PL_U::PL_U(FileSystem::FileSystemController& fsc) 153PL_U::PL_U(Core::System& system)
154 : ServiceFramework("pl:u"), impl{std::make_unique<Impl>()} { 154 : ServiceFramework("pl:u"), impl{std::make_unique<Impl>()}, system(system) {
155
155 static const FunctionInfo functions[] = { 156 static const FunctionInfo functions[] = {
156 {0, &PL_U::RequestLoad, "RequestLoad"}, 157 {0, &PL_U::RequestLoad, "RequestLoad"},
157 {1, &PL_U::GetLoadState, "GetLoadState"}, 158 {1, &PL_U::GetLoadState, "GetLoadState"},
@@ -161,6 +162,9 @@ PL_U::PL_U(FileSystem::FileSystemController& fsc)
161 {5, &PL_U::GetSharedFontInOrderOfPriority, "GetSharedFontInOrderOfPriority"}, 162 {5, &PL_U::GetSharedFontInOrderOfPriority, "GetSharedFontInOrderOfPriority"},
162 }; 163 };
163 RegisterHandlers(functions); 164 RegisterHandlers(functions);
165
166 auto& fsc = system.GetFileSystemController();
167
164 // Attempt to load shared font data from disk 168 // Attempt to load shared font data from disk
165 const auto* nand = fsc.GetSystemNANDContents(); 169 const auto* nand = fsc.GetSystemNANDContents();
166 std::size_t offset = 0; 170 std::size_t offset = 0;
@@ -325,7 +329,7 @@ void PL_U::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) {
325 Kernel::MemoryState::Shared); 329 Kernel::MemoryState::Shared);
326 330
327 // Create shared font memory object 331 // Create shared font memory object
328 auto& kernel = Core::System::GetInstance().Kernel(); 332 auto& kernel = system.Kernel();
329 impl->shared_font_mem = Kernel::SharedMemory::Create( 333 impl->shared_font_mem = Kernel::SharedMemory::Create(
330 kernel, Core::CurrentProcess(), SHARED_FONT_MEM_SIZE, Kernel::MemoryPermission::ReadWrite, 334 kernel, Core::CurrentProcess(), SHARED_FONT_MEM_SIZE, Kernel::MemoryPermission::ReadWrite,
331 Kernel::MemoryPermission::Read, SHARED_FONT_MEM_VADDR, Kernel::MemoryRegion::BASE, 335 Kernel::MemoryPermission::Read, SHARED_FONT_MEM_VADDR, Kernel::MemoryRegion::BASE,
diff --git a/src/core/hle/service/ns/pl_u.h b/src/core/hle/service/ns/pl_u.h
index 35ca424d2..1063f4204 100644
--- a/src/core/hle/service/ns/pl_u.h
+++ b/src/core/hle/service/ns/pl_u.h
@@ -17,7 +17,7 @@ namespace NS {
17 17
18class PL_U final : public ServiceFramework<PL_U> { 18class PL_U final : public ServiceFramework<PL_U> {
19public: 19public:
20 PL_U(FileSystem::FileSystemController& fsc); 20 explicit PL_U(Core::System& system);
21 ~PL_U() override; 21 ~PL_U() override;
22 22
23private: 23private:
@@ -30,6 +30,7 @@ private:
30 30
31 struct Impl; 31 struct Impl;
32 std::unique_ptr<Impl> impl; 32 std::unique_ptr<Impl> impl;
33 Core::System& system;
33}; 34};
34 35
35} // namespace NS 36} // namespace NS
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index f9db79370..2e4d707b9 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -29,26 +29,28 @@ namespace Service::NVFlinger {
29constexpr s64 frame_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 60); 29constexpr s64 frame_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 60);
30constexpr s64 frame_ticks_30fps = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 30); 30constexpr s64 frame_ticks_30fps = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 30);
31 31
32NVFlinger::NVFlinger(Core::Timing::CoreTiming& core_timing) : core_timing{core_timing} { 32NVFlinger::NVFlinger(Core::System& system) : system(system) {
33 displays.emplace_back(0, "Default"); 33 displays.emplace_back(0, "Default", system);
34 displays.emplace_back(1, "External"); 34 displays.emplace_back(1, "External", system);
35 displays.emplace_back(2, "Edid"); 35 displays.emplace_back(2, "Edid", system);
36 displays.emplace_back(3, "Internal"); 36 displays.emplace_back(3, "Internal", system);
37 displays.emplace_back(4, "Null"); 37 displays.emplace_back(4, "Null", system);
38 38
39 // Schedule the screen composition events 39 // Schedule the screen composition events
40 composition_event = core_timing.RegisterEvent("ScreenComposition", [this](u64 userdata, 40 composition_event = system.CoreTiming().RegisterEvent(
41 s64 cycles_late) { 41 "ScreenComposition", [this](u64 userdata, s64 cycles_late) {
42 Compose(); 42 Compose();
43 const auto ticks = Settings::values.force_30fps_mode ? frame_ticks_30fps : GetNextTicks(); 43 const auto ticks =
44 this->core_timing.ScheduleEvent(std::max<s64>(0LL, ticks - cycles_late), composition_event); 44 Settings::values.force_30fps_mode ? frame_ticks_30fps : GetNextTicks();
45 }); 45 this->system.CoreTiming().ScheduleEvent(std::max<s64>(0LL, ticks - cycles_late),
46 46 composition_event);
47 core_timing.ScheduleEvent(frame_ticks, composition_event); 47 });
48
49 system.CoreTiming().ScheduleEvent(frame_ticks, composition_event);
48} 50}
49 51
50NVFlinger::~NVFlinger() { 52NVFlinger::~NVFlinger() {
51 core_timing.UnscheduleEvent(composition_event, 0); 53 system.CoreTiming().UnscheduleEvent(composition_event, 0);
52} 54}
53 55
54void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { 56void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) {
@@ -185,11 +187,9 @@ void NVFlinger::Compose() {
185 MicroProfileFlip(); 187 MicroProfileFlip();
186 188
187 if (!buffer) { 189 if (!buffer) {
188 auto& system_instance = Core::System::GetInstance();
189
190 // There was no queued buffer to draw, render previous frame 190 // There was no queued buffer to draw, render previous frame
191 system_instance.GetPerfStats().EndGameFrame(); 191 system.GetPerfStats().EndGameFrame();
192 system_instance.GPU().SwapBuffers({}); 192 system.GPU().SwapBuffers({});
193 continue; 193 continue;
194 } 194 }
195 195
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h
index 988be8726..5d7e3bfb8 100644
--- a/src/core/hle/service/nvflinger/nvflinger.h
+++ b/src/core/hle/service/nvflinger/nvflinger.h
@@ -38,7 +38,7 @@ class BufferQueue;
38 38
39class NVFlinger final { 39class NVFlinger final {
40public: 40public:
41 explicit NVFlinger(Core::Timing::CoreTiming& core_timing); 41 explicit NVFlinger(Core::System& system);
42 ~NVFlinger(); 42 ~NVFlinger();
43 43
44 /// Sets the NVDrv module instance to use to send buffers to the GPU. 44 /// Sets the NVDrv module instance to use to send buffers to the GPU.
@@ -105,8 +105,7 @@ private:
105 /// Event that handles screen composition. 105 /// Event that handles screen composition.
106 Core::Timing::EventType* composition_event; 106 Core::Timing::EventType* composition_event;
107 107
108 /// Core timing instance for registering/unregistering the composition event. 108 Core::System& system;
109 Core::Timing::CoreTiming& core_timing;
110}; 109};
111 110
112} // namespace Service::NVFlinger 111} // namespace Service::NVFlinger
diff --git a/src/core/hle/service/prepo/prepo.cpp b/src/core/hle/service/prepo/prepo.cpp
index 0f79135ff..18d895263 100644
--- a/src/core/hle/service/prepo/prepo.cpp
+++ b/src/core/hle/service/prepo/prepo.cpp
@@ -15,7 +15,7 @@ namespace Service::PlayReport {
15 15
16class PlayReport final : public ServiceFramework<PlayReport> { 16class PlayReport final : public ServiceFramework<PlayReport> {
17public: 17public:
18 explicit PlayReport(Core::System& system, const char* name) 18 explicit PlayReport(const char* name, Core::System& system)
19 : ServiceFramework{name}, system(system) { 19 : ServiceFramework{name}, system(system) {
20 // clang-format off 20 // clang-format off
21 static const FunctionInfo functions[] = { 21 static const FunctionInfo functions[] = {
@@ -128,12 +128,12 @@ private:
128 Core::System& system; 128 Core::System& system;
129}; 129};
130 130
131void InstallInterfaces(Core::System& system) { 131void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
132 std::make_shared<PlayReport>(system, "prepo:a")->InstallAsService(system.ServiceManager()); 132 std::make_shared<PlayReport>("prepo:a", system)->InstallAsService(service_manager);
133 std::make_shared<PlayReport>(system, "prepo:a2")->InstallAsService(system.ServiceManager()); 133 std::make_shared<PlayReport>("prepo:a2", system)->InstallAsService(service_manager);
134 std::make_shared<PlayReport>(system, "prepo:m")->InstallAsService(system.ServiceManager()); 134 std::make_shared<PlayReport>("prepo:m", system)->InstallAsService(service_manager);
135 std::make_shared<PlayReport>(system, "prepo:s")->InstallAsService(system.ServiceManager()); 135 std::make_shared<PlayReport>("prepo:s", system)->InstallAsService(service_manager);
136 std::make_shared<PlayReport>(system, "prepo:u")->InstallAsService(system.ServiceManager()); 136 std::make_shared<PlayReport>("prepo:u", system)->InstallAsService(service_manager);
137} 137}
138 138
139} // namespace Service::PlayReport 139} // namespace Service::PlayReport
diff --git a/src/core/hle/service/prepo/prepo.h b/src/core/hle/service/prepo/prepo.h
index 0ebc3a938..a5682ee26 100644
--- a/src/core/hle/service/prepo/prepo.h
+++ b/src/core/hle/service/prepo/prepo.h
@@ -8,8 +8,12 @@ namespace Service::SM {
8class ServiceManager; 8class ServiceManager;
9} 9}
10 10
11namespace Core {
12class System;
13}
14
11namespace Service::PlayReport { 15namespace Service::PlayReport {
12 16
13void InstallInterfaces(Core::System& system); 17void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
14 18
15} // namespace Service::PlayReport 19} // namespace Service::PlayReport
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 906fdc415..831a427de 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -198,50 +198,50 @@ ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& co
198void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) { 198void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) {
199 // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it 199 // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it
200 // here and pass it into the respective InstallInterfaces functions. 200 // here and pass it into the respective InstallInterfaces functions.
201 auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(system.CoreTiming()); 201 auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(system);
202 system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false); 202 system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false);
203 203
204 SM::ServiceManager::InstallInterfaces(sm); 204 SM::ServiceManager::InstallInterfaces(sm);
205 205
206 Account::InstallInterfaces(system); 206 Account::InstallInterfaces(system);
207 AM::InstallInterfaces(*sm, nv_flinger, system); 207 AM::InstallInterfaces(*sm, nv_flinger, system);
208 AOC::InstallInterfaces(*sm); 208 AOC::InstallInterfaces(*sm, system);
209 APM::InstallInterfaces(system); 209 APM::InstallInterfaces(system);
210 Audio::InstallInterfaces(*sm, system); 210 Audio::InstallInterfaces(*sm, system);
211 BCAT::InstallInterfaces(*sm); 211 BCAT::InstallInterfaces(*sm);
212 BPC::InstallInterfaces(*sm); 212 BPC::InstallInterfaces(*sm);
213 BtDrv::InstallInterfaces(*sm); 213 BtDrv::InstallInterfaces(*sm, system);
214 BTM::InstallInterfaces(*sm); 214 BTM::InstallInterfaces(*sm, system);
215 Capture::InstallInterfaces(*sm); 215 Capture::InstallInterfaces(*sm);
216 ERPT::InstallInterfaces(*sm); 216 ERPT::InstallInterfaces(*sm);
217 ES::InstallInterfaces(*sm); 217 ES::InstallInterfaces(*sm);
218 EUPLD::InstallInterfaces(*sm); 218 EUPLD::InstallInterfaces(*sm);
219 Fatal::InstallInterfaces(*sm); 219 Fatal::InstallInterfaces(*sm, system);
220 FGM::InstallInterfaces(*sm); 220 FGM::InstallInterfaces(*sm);
221 FileSystem::InstallInterfaces(system); 221 FileSystem::InstallInterfaces(system);
222 Friend::InstallInterfaces(*sm); 222 Friend::InstallInterfaces(*sm, system);
223 Glue::InstallInterfaces(system); 223 Glue::InstallInterfaces(system);
224 GRC::InstallInterfaces(*sm); 224 GRC::InstallInterfaces(*sm);
225 HID::InstallInterfaces(*sm); 225 HID::InstallInterfaces(*sm, system);
226 LBL::InstallInterfaces(*sm); 226 LBL::InstallInterfaces(*sm);
227 LDN::InstallInterfaces(*sm); 227 LDN::InstallInterfaces(*sm);
228 LDR::InstallInterfaces(*sm); 228 LDR::InstallInterfaces(*sm, system);
229 LM::InstallInterfaces(*sm); 229 LM::InstallInterfaces(*sm);
230 Migration::InstallInterfaces(*sm); 230 Migration::InstallInterfaces(*sm);
231 Mii::InstallInterfaces(*sm); 231 Mii::InstallInterfaces(*sm);
232 MM::InstallInterfaces(*sm); 232 MM::InstallInterfaces(*sm);
233 NCM::InstallInterfaces(*sm); 233 NCM::InstallInterfaces(*sm);
234 NFC::InstallInterfaces(*sm); 234 NFC::InstallInterfaces(*sm);
235 NFP::InstallInterfaces(*sm); 235 NFP::InstallInterfaces(*sm, system);
236 NIFM::InstallInterfaces(*sm); 236 NIFM::InstallInterfaces(*sm, system);
237 NIM::InstallInterfaces(*sm); 237 NIM::InstallInterfaces(*sm, system);
238 NPNS::InstallInterfaces(*sm); 238 NPNS::InstallInterfaces(*sm);
239 NS::InstallInterfaces(*sm, system.GetFileSystemController()); 239 NS::InstallInterfaces(*sm, system);
240 Nvidia::InstallInterfaces(*sm, *nv_flinger, system); 240 Nvidia::InstallInterfaces(*sm, *nv_flinger, system);
241 PCIe::InstallInterfaces(*sm); 241 PCIe::InstallInterfaces(*sm);
242 PCTL::InstallInterfaces(*sm); 242 PCTL::InstallInterfaces(*sm);
243 PCV::InstallInterfaces(*sm); 243 PCV::InstallInterfaces(*sm);
244 PlayReport::InstallInterfaces(system); 244 PlayReport::InstallInterfaces(*sm, system);
245 PM::InstallInterfaces(system); 245 PM::InstallInterfaces(system);
246 PSC::InstallInterfaces(*sm); 246 PSC::InstallInterfaces(*sm);
247 PSM::InstallInterfaces(*sm); 247 PSM::InstallInterfaces(*sm);
diff --git a/src/core/hle/service/time/interface.cpp b/src/core/hle/service/time/interface.cpp
index 1030185e0..9565e7de5 100644
--- a/src/core/hle/service/time/interface.cpp
+++ b/src/core/hle/service/time/interface.cpp
@@ -7,8 +7,8 @@
7namespace Service::Time { 7namespace Service::Time {
8 8
9Time::Time(std::shared_ptr<Module> time, std::shared_ptr<SharedMemory> shared_memory, 9Time::Time(std::shared_ptr<Module> time, std::shared_ptr<SharedMemory> shared_memory,
10 const char* name) 10 Core::System& system, const char* name)
11 : Module::Interface(std::move(time), std::move(shared_memory), name) { 11 : Module::Interface(std::move(time), std::move(shared_memory), system, name) {
12 // clang-format off 12 // clang-format off
13 static const FunctionInfo functions[] = { 13 static const FunctionInfo functions[] = {
14 {0, &Time::GetStandardUserSystemClock, "GetStandardUserSystemClock"}, 14 {0, &Time::GetStandardUserSystemClock, "GetStandardUserSystemClock"},
diff --git a/src/core/hle/service/time/interface.h b/src/core/hle/service/time/interface.h
index bdf0883e2..5c63a07f4 100644
--- a/src/core/hle/service/time/interface.h
+++ b/src/core/hle/service/time/interface.h
@@ -13,7 +13,7 @@ class SharedMemory;
13class Time final : public Module::Interface { 13class Time final : public Module::Interface {
14public: 14public:
15 explicit Time(std::shared_ptr<Module> time, std::shared_ptr<SharedMemory> shared_memory, 15 explicit Time(std::shared_ptr<Module> time, std::shared_ptr<SharedMemory> shared_memory,
16 const char* name); 16 Core::System& system, const char* name);
17 ~Time() override; 17 ~Time() override;
18}; 18};
19 19
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index ae6446204..1b9ab8401 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -126,8 +126,8 @@ private:
126 126
127class ISteadyClock final : public ServiceFramework<ISteadyClock> { 127class ISteadyClock final : public ServiceFramework<ISteadyClock> {
128public: 128public:
129 ISteadyClock(std::shared_ptr<SharedMemory> shared_memory) 129 ISteadyClock(std::shared_ptr<SharedMemory> shared_memory, Core::System& system)
130 : ServiceFramework("ISteadyClock"), shared_memory(shared_memory) { 130 : ServiceFramework("ISteadyClock"), shared_memory(shared_memory), system(system) {
131 static const FunctionInfo functions[] = { 131 static const FunctionInfo functions[] = {
132 {0, &ISteadyClock::GetCurrentTimePoint, "GetCurrentTimePoint"}, 132 {0, &ISteadyClock::GetCurrentTimePoint, "GetCurrentTimePoint"},
133 }; 133 };
@@ -150,12 +150,13 @@ private:
150 } 150 }
151 151
152 SteadyClockTimePoint GetCurrentTimePoint() const { 152 SteadyClockTimePoint GetCurrentTimePoint() const {
153 const auto& core_timing = Core::System::GetInstance().CoreTiming(); 153 const auto& core_timing = system.CoreTiming();
154 const auto ms = Core::Timing::CyclesToMs(core_timing.GetTicks()); 154 const auto ms = Core::Timing::CyclesToMs(core_timing.GetTicks());
155 return {static_cast<u64_le>(ms.count() / 1000), {}}; 155 return {static_cast<u64_le>(ms.count() / 1000), {}};
156 } 156 }
157 157
158 std::shared_ptr<SharedMemory> shared_memory; 158 std::shared_ptr<SharedMemory> shared_memory;
159 Core::System& system;
159}; 160};
160 161
161class ITimeZoneService final : public ServiceFramework<ITimeZoneService> { 162class ITimeZoneService final : public ServiceFramework<ITimeZoneService> {
@@ -290,7 +291,7 @@ void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
290 291
291 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 292 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
292 rb.Push(RESULT_SUCCESS); 293 rb.Push(RESULT_SUCCESS);
293 rb.PushIpcInterface<ISteadyClock>(shared_memory); 294 rb.PushIpcInterface<ISteadyClock>(shared_memory, system);
294} 295}
295 296
296void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) { 297void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) {
@@ -325,7 +326,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
325 return; 326 return;
326 } 327 }
327 328
328 const auto& core_timing = Core::System::GetInstance().CoreTiming(); 329 const auto& core_timing = system.CoreTiming();
329 const auto ms = Core::Timing::CyclesToMs(core_timing.GetTicks()); 330 const auto ms = Core::Timing::CyclesToMs(core_timing.GetTicks());
330 const SteadyClockTimePoint steady_clock_time_point{static_cast<u64_le>(ms.count() / 1000), {}}; 331 const SteadyClockTimePoint steady_clock_time_point{static_cast<u64_le>(ms.count() / 1000), {}};
331 332
@@ -407,8 +408,10 @@ void Module::Interface::SetStandardUserSystemClockAutomaticCorrectionEnabled(
407} 408}
408 409
409Module::Interface::Interface(std::shared_ptr<Module> time, 410Module::Interface::Interface(std::shared_ptr<Module> time,
410 std::shared_ptr<SharedMemory> shared_memory, const char* name) 411 std::shared_ptr<SharedMemory> shared_memory, Core::System& system,
411 : ServiceFramework(name), time(std::move(time)), shared_memory(std::move(shared_memory)) {} 412 const char* name)
413 : ServiceFramework(name), time(std::move(time)), shared_memory(std::move(shared_memory)),
414 system(system) {}
412 415
413Module::Interface::~Interface() = default; 416Module::Interface::~Interface() = default;
414 417
@@ -416,9 +419,11 @@ void InstallInterfaces(Core::System& system) {
416 auto time = std::make_shared<Module>(); 419 auto time = std::make_shared<Module>();
417 auto shared_mem = std::make_shared<SharedMemory>(system); 420 auto shared_mem = std::make_shared<SharedMemory>(system);
418 421
419 std::make_shared<Time>(time, shared_mem, "time:a")->InstallAsService(system.ServiceManager()); 422 std::make_shared<Time>(time, shared_mem, system, "time:a")
420 std::make_shared<Time>(time, shared_mem, "time:s")->InstallAsService(system.ServiceManager()); 423 ->InstallAsService(system.ServiceManager());
421 std::make_shared<Time>(std::move(time), shared_mem, "time:u") 424 std::make_shared<Time>(time, shared_mem, system, "time:s")
425 ->InstallAsService(system.ServiceManager());
426 std::make_shared<Time>(std::move(time), shared_mem, system, "time:u")
422 ->InstallAsService(system.ServiceManager()); 427 ->InstallAsService(system.ServiceManager());
423} 428}
424 429
diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h
index e0708f856..c32d32860 100644
--- a/src/core/hle/service/time/time.h
+++ b/src/core/hle/service/time/time.h
@@ -80,7 +80,8 @@ public:
80 class Interface : public ServiceFramework<Interface> { 80 class Interface : public ServiceFramework<Interface> {
81 public: 81 public:
82 explicit Interface(std::shared_ptr<Module> time, 82 explicit Interface(std::shared_ptr<Module> time,
83 std::shared_ptr<SharedMemory> shared_memory, const char* name); 83 std::shared_ptr<SharedMemory> shared_memory, Core::System& system,
84 const char* name);
84 ~Interface() override; 85 ~Interface() override;
85 86
86 void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx); 87 void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx);
@@ -97,6 +98,7 @@ public:
97 protected: 98 protected:
98 std::shared_ptr<Module> time; 99 std::shared_ptr<Module> time;
99 std::shared_ptr<SharedMemory> shared_memory; 100 std::shared_ptr<SharedMemory> shared_memory;
101 Core::System& system;
100 }; 102 };
101}; 103};
102 104
diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp
index a8d088305..006a6d9ff 100644
--- a/src/core/hle/service/vi/display/vi_display.cpp
+++ b/src/core/hle/service/vi/display/vi_display.cpp
@@ -15,8 +15,8 @@
15 15
16namespace Service::VI { 16namespace Service::VI {
17 17
18Display::Display(u64 id, std::string name) : id{id}, name{std::move(name)} { 18Display::Display(u64 id, std::string name, Core::System& system) : id{id}, name{std::move(name)} {
19 auto& kernel = Core::System::GetInstance().Kernel(); 19 auto& kernel = system.Kernel();
20 vsync_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual, 20 vsync_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual,
21 fmt::format("Display VSync Event {}", id)); 21 fmt::format("Display VSync Event {}", id));
22} 22}
diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h
index 2acd46ff8..f56b5badc 100644
--- a/src/core/hle/service/vi/display/vi_display.h
+++ b/src/core/hle/service/vi/display/vi_display.h
@@ -26,7 +26,7 @@ public:
26 /// @param id The unique ID for this display. 26 /// @param id The unique ID for this display.
27 /// @param name The name for this display. 27 /// @param name The name for this display.
28 /// 28 ///
29 Display(u64 id, std::string name); 29 Display(u64 id, std::string name, Core::System& system);
30 ~Display(); 30 ~Display();
31 31
32 Display(const Display&) = delete; 32 Display(const Display&) = delete;