summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nim/nim.cpp102
1 files changed, 99 insertions, 3 deletions
diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp
index bd05b0a70..c1737defa 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,111 @@ 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 IPC::ResponseBuilder rb{ctx, 2};
149 rb.Push(RESULT_SUCCESS);
150 LOG_DEBUG(Service_NIM, "called");
151 }
152
153 void Cancel(Kernel::HLERequestContext& ctx) {
154 finished_event->Clear();
155 IPC::ResponseBuilder rb{ctx, 2};
156 rb.Push(RESULT_SUCCESS);
157 LOG_DEBUG(Service_NIM, "called");
158 }
159
160 void IsProcessing(Kernel::HLERequestContext& ctx) {
161 IPC::ResponseBuilder rb{ctx, 3};
162 rb.Push(RESULT_SUCCESS);
163 rb.PushRaw<u32>(0); // We instantly process the request
164 LOG_DEBUG(Service_NIM, "called");
165 }
166
167 void GetServerTime(Kernel::HLERequestContext& ctx) {
168 const s64 server_time{std::chrono::duration_cast<std::chrono::seconds>(
169 std::chrono::system_clock::now().time_since_epoch())
170 .count()};
171 IPC::ResponseBuilder rb{ctx, 4};
172 rb.Push(RESULT_SUCCESS);
173 rb.PushRaw<s64>(server_time);
174 LOG_DEBUG(Service_NIM, "called");
175 }
176};
177
103class NTC final : public ServiceFramework<NTC> { 178class NTC final : public ServiceFramework<NTC> {
104public: 179public:
105 explicit NTC() : ServiceFramework{"ntc"} { 180 explicit NTC() : ServiceFramework{"ntc"} {
106 // clang-format off 181 // clang-format off
107 static const FunctionInfo functions[] = { 182 static const FunctionInfo functions[] = {
108 {0, nullptr, "OpenEnsureNetworkClockAvailabilityService"}, 183 {0, &NTC::OpenEnsureNetworkClockAvailabilityService, "OpenEnsureNetworkClockAvailabilityService"},
109 {100, nullptr, "SuspendAutonomicTimeCorrection"}, 184 {100, &NTC::SuspendAutonomicTimeCorrection, "SuspendAutonomicTimeCorrection"},
110 {101, nullptr, "ResumeAutonomicTimeCorrection"}, 185 {101, &NTC::ResumeAutonomicTimeCorrection, "ResumeAutonomicTimeCorrection"},
111 }; 186 };
112 // clang-format on 187 // clang-format on
113 188
114 RegisterHandlers(functions); 189 RegisterHandlers(functions);
115 } 190 }
191
192private:
193 void OpenEnsureNetworkClockAvailabilityService(Kernel::HLERequestContext& ctx) {
194 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
195 rb.Push(RESULT_SUCCESS);
196 rb.PushIpcInterface<IEnsureNetworkClockAvailabilityService>();
197 LOG_DEBUG(Service_NIM, "called");
198 }
199
200 // TODO(ogniK): Do we need these?
201 void SuspendAutonomicTimeCorrection(Kernel::HLERequestContext& ctx) {
202 IPC::ResponseBuilder rb{ctx, 2};
203 rb.Push(RESULT_SUCCESS);
204 LOG_WARNING(Service_NIM, "(STUBBED) called");
205 }
206
207 void ResumeAutonomicTimeCorrection(Kernel::HLERequestContext& ctx) {
208 IPC::ResponseBuilder rb{ctx, 2};
209 rb.Push(RESULT_SUCCESS);
210 LOG_WARNING(Service_NIM, "(STUBBED) called");
211 }
116}; 212};
117 213
118void InstallInterfaces(SM::ServiceManager& sm) { 214void InstallInterfaces(SM::ServiceManager& sm) {