summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar David Marcec2018-09-20 15:14:07 +1000
committerGravatar David Marcec2018-09-20 15:14:07 +1000
commit335e9d18ae643fd9aa5e945fa6f86b26be491f7f (patch)
tree5854b720a2d5b0d766b9f603da5f156d494d300b /src
parentReworked incorrect nifm stubs (#1355) (diff)
downloadyuzu-335e9d18ae643fd9aa5e945fa6f86b26be491f7f.tar.gz
yuzu-335e9d18ae643fd9aa5e945fa6f86b26be491f7f.tar.xz
yuzu-335e9d18ae643fd9aa5e945fa6f86b26be491f7f.zip
Implemented NTC & IEnsureNetworkClockAvailabilityService
Needed because of the recent nim fixes
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nim/nim.cpp103
1 files changed, 100 insertions, 3 deletions
diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp
index bd05b0a70..44d929c9a 100644
--- a/src/core/hle/service/nim/nim.cpp
+++ b/src/core/hle/service/nim/nim.cpp
@@ -2,6 +2,10 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <chrono>
6#include <ctime>
7#include "core/hle/ipc_helpers.h"
8#include "core/hle/kernel/event.h"
5#include "core/hle/service/nim/nim.h" 9#include "core/hle/service/nim/nim.h"
6#include "core/hle/service/service.h" 10#include "core/hle/service/service.h"
7#include "core/hle/service/sm/sm.h" 11#include "core/hle/service/sm/sm.h"
@@ -100,19 +104,112 @@ public:
100 } 104 }
101}; 105};
102 106
107class IEnsureNetworkClockAvailabilityService final
108 : public ServiceFramework<IEnsureNetworkClockAvailabilityService> {
109public:
110 IEnsureNetworkClockAvailabilityService()
111 : ServiceFramework("IEnsureNetworkClockAvailabilityService") {
112 static const FunctionInfo functions[] = {
113 {0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"},
114 {1, &IEnsureNetworkClockAvailabilityService::GetFinishNotificationEvent,
115 "GetFinishNotificationEvent"},
116 {2, &IEnsureNetworkClockAvailabilityService::GetResult, "GetResult"},
117 {3, &IEnsureNetworkClockAvailabilityService::Cancel, "Cancel"},
118 {4, &IEnsureNetworkClockAvailabilityService::IsProcessing, "IsProcessing"},
119 {5, &IEnsureNetworkClockAvailabilityService::GetServerTime, "GetServerTime"},
120 };
121 RegisterHandlers(functions);
122
123 auto& kernel = Core::System::GetInstance().Kernel();
124 finished_event =
125 Kernel::Event::Create(kernel, Kernel::ResetType::OneShot,
126 "IEnsureNetworkClockAvailabilityService:FinishEvent");
127 }
128
129private:
130 Kernel::SharedPtr<Kernel::Event> finished_event;
131
132 void StartTask(Kernel::HLERequestContext& ctx) {
133 // No need to connect to the internet, just finish the task straight away.
134 finished_event->Signal();
135 IPC::ResponseBuilder rb{ctx, 2};
136 rb.Push(RESULT_SUCCESS);
137 LOG_DEBUG(Service_NIM, "called");
138 }
139
140 void GetFinishNotificationEvent(Kernel::HLERequestContext& ctx) {
141 IPC::ResponseBuilder rb{ctx, 2, 1};
142 rb.Push(RESULT_SUCCESS);
143 rb.PushCopyObjects(finished_event);
144 LOG_DEBUG(Service_NIM, "called");
145 }
146
147 void GetResult(Kernel::HLERequestContext& ctx) {
148 finished_event->Clear();
149 IPC::ResponseBuilder rb{ctx, 2};
150 rb.Push(RESULT_SUCCESS);
151 LOG_DEBUG(Service_NIM, "called");
152 }
153
154 void Cancel(Kernel::HLERequestContext& ctx) {
155 finished_event->Clear();
156 IPC::ResponseBuilder rb{ctx, 2};
157 rb.Push(RESULT_SUCCESS);
158 LOG_DEBUG(Service_NIM, "called");
159 }
160
161 void IsProcessing(Kernel::HLERequestContext& ctx) {
162 IPC::ResponseBuilder rb{ctx, 3};
163 rb.Push(RESULT_SUCCESS);
164 rb.PushRaw<u32>(0); // We instantly process the request
165 LOG_DEBUG(Service_NIM, "called");
166 }
167
168 void GetServerTime(Kernel::HLERequestContext& ctx) {
169 const s64 server_time{std::chrono::duration_cast<std::chrono::seconds>(
170 std::chrono::system_clock::now().time_since_epoch())
171 .count()};
172 IPC::ResponseBuilder rb{ctx, 4};
173 rb.Push(RESULT_SUCCESS);
174 rb.PushRaw<s64>(server_time);
175 LOG_DEBUG(Service_NIM, "called");
176 }
177};
178
103class NTC final : public ServiceFramework<NTC> { 179class NTC final : public ServiceFramework<NTC> {
104public: 180public:
105 explicit NTC() : ServiceFramework{"ntc"} { 181 explicit NTC() : ServiceFramework{"ntc"} {
106 // clang-format off 182 // clang-format off
107 static const FunctionInfo functions[] = { 183 static const FunctionInfo functions[] = {
108 {0, nullptr, "OpenEnsureNetworkClockAvailabilityService"}, 184 {0, &NTC::OpenEnsureNetworkClockAvailabilityService, "OpenEnsureNetworkClockAvailabilityService"},
109 {100, nullptr, "SuspendAutonomicTimeCorrection"}, 185 {100, &NTC::SuspendAutonomicTimeCorrection, "SuspendAutonomicTimeCorrection"},
110 {101, nullptr, "ResumeAutonomicTimeCorrection"}, 186 {101, &NTC::ResumeAutonomicTimeCorrection, "ResumeAutonomicTimeCorrection"},
111 }; 187 };
112 // clang-format on 188 // clang-format on
113 189
114 RegisterHandlers(functions); 190 RegisterHandlers(functions);
115 } 191 }
192
193private:
194 void OpenEnsureNetworkClockAvailabilityService(Kernel::HLERequestContext& ctx) {
195 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
196 rb.Push(RESULT_SUCCESS);
197 rb.PushIpcInterface<IEnsureNetworkClockAvailabilityService>();
198 LOG_DEBUG(Service_NIM, "called");
199 }
200
201 // TODO(ogniK): Do we need these?
202 void SuspendAutonomicTimeCorrection(Kernel::HLERequestContext& ctx) {
203 IPC::ResponseBuilder rb{ctx, 2};
204 rb.Push(RESULT_SUCCESS);
205 LOG_WARNING(Service_NIM, "(STUBBED) called");
206 }
207
208 void ResumeAutonomicTimeCorrection(Kernel::HLERequestContext& ctx) {
209 IPC::ResponseBuilder rb{ctx, 2};
210 rb.Push(RESULT_SUCCESS);
211 LOG_WARNING(Service_NIM, "(STUBBED) called");
212 }
116}; 213};
117 214
118void InstallInterfaces(SM::ServiceManager& sm) { 215void InstallInterfaces(SM::ServiceManager& sm) {