summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-09-20 16:12:35 +0200
committerGitHub <noreply@github.com>2018-09-20 16:12:35 +0200
commite57aa62b11ccf8188c8b5d1778f83797b27565dd (patch)
tree8b4e3f56641fc0d17bdf1f1e314e35f0bc873e90
parentReworked incorrect nifm stubs (#1355) (diff)
parentRemoved unneeded event clear (diff)
downloadyuzu-e57aa62b11ccf8188c8b5d1778f83797b27565dd.tar
yuzu-e57aa62b11ccf8188c8b5d1778f83797b27565dd.tar.gz
yuzu-e57aa62b11ccf8188c8b5d1778f83797b27565dd.tar.bz2
yuzu-e57aa62b11ccf8188c8b5d1778f83797b27565dd.tar.lz
yuzu-e57aa62b11ccf8188c8b5d1778f83797b27565dd.tar.xz
yuzu-e57aa62b11ccf8188c8b5d1778f83797b27565dd.tar.zst
yuzu-e57aa62b11ccf8188c8b5d1778f83797b27565dd.zip
-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 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <chrono>
+#include <ctime>
+#include "core/hle/ipc_helpers.h"
+#include "core/hle/kernel/event.h"
#include "core/hle/service/nim/nim.h"
#include "core/hle/service/service.h"
#include "core/hle/service/sm/sm.h"
@@ -100,19 +104,111 @@ public:
}
};
+class IEnsureNetworkClockAvailabilityService final
+ : public ServiceFramework<IEnsureNetworkClockAvailabilityService> {
+public:
+ IEnsureNetworkClockAvailabilityService()
+ : ServiceFramework("IEnsureNetworkClockAvailabilityService") {
+ static const FunctionInfo functions[] = {
+ {0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"},
+ {1, &IEnsureNetworkClockAvailabilityService::GetFinishNotificationEvent,
+ "GetFinishNotificationEvent"},
+ {2, &IEnsureNetworkClockAvailabilityService::GetResult, "GetResult"},
+ {3, &IEnsureNetworkClockAvailabilityService::Cancel, "Cancel"},
+ {4, &IEnsureNetworkClockAvailabilityService::IsProcessing, "IsProcessing"},
+ {5, &IEnsureNetworkClockAvailabilityService::GetServerTime, "GetServerTime"},
+ };
+ RegisterHandlers(functions);
+
+ auto& kernel = Core::System::GetInstance().Kernel();
+ finished_event =
+ Kernel::Event::Create(kernel, Kernel::ResetType::OneShot,
+ "IEnsureNetworkClockAvailabilityService:FinishEvent");
+ }
+
+private:
+ Kernel::SharedPtr<Kernel::Event> finished_event;
+
+ void StartTask(Kernel::HLERequestContext& ctx) {
+ // No need to connect to the internet, just finish the task straight away.
+ finished_event->Signal();
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(RESULT_SUCCESS);
+ LOG_DEBUG(Service_NIM, "called");
+ }
+
+ void GetFinishNotificationEvent(Kernel::HLERequestContext& ctx) {
+ IPC::ResponseBuilder rb{ctx, 2, 1};
+ rb.Push(RESULT_SUCCESS);
+ rb.PushCopyObjects(finished_event);
+ LOG_DEBUG(Service_NIM, "called");
+ }
+
+ void GetResult(Kernel::HLERequestContext& ctx) {
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(RESULT_SUCCESS);
+ LOG_DEBUG(Service_NIM, "called");
+ }
+
+ void Cancel(Kernel::HLERequestContext& ctx) {
+ finished_event->Clear();
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(RESULT_SUCCESS);
+ LOG_DEBUG(Service_NIM, "called");
+ }
+
+ void IsProcessing(Kernel::HLERequestContext& ctx) {
+ IPC::ResponseBuilder rb{ctx, 3};
+ rb.Push(RESULT_SUCCESS);
+ rb.PushRaw<u32>(0); // We instantly process the request
+ LOG_DEBUG(Service_NIM, "called");
+ }
+
+ void GetServerTime(Kernel::HLERequestContext& ctx) {
+ const s64 server_time{std::chrono::duration_cast<std::chrono::seconds>(
+ std::chrono::system_clock::now().time_since_epoch())
+ .count()};
+ IPC::ResponseBuilder rb{ctx, 4};
+ rb.Push(RESULT_SUCCESS);
+ rb.PushRaw<s64>(server_time);
+ LOG_DEBUG(Service_NIM, "called");
+ }
+};
+
class NTC final : public ServiceFramework<NTC> {
public:
explicit NTC() : ServiceFramework{"ntc"} {
// clang-format off
static const FunctionInfo functions[] = {
- {0, nullptr, "OpenEnsureNetworkClockAvailabilityService"},
- {100, nullptr, "SuspendAutonomicTimeCorrection"},
- {101, nullptr, "ResumeAutonomicTimeCorrection"},
+ {0, &NTC::OpenEnsureNetworkClockAvailabilityService, "OpenEnsureNetworkClockAvailabilityService"},
+ {100, &NTC::SuspendAutonomicTimeCorrection, "SuspendAutonomicTimeCorrection"},
+ {101, &NTC::ResumeAutonomicTimeCorrection, "ResumeAutonomicTimeCorrection"},
};
// clang-format on
RegisterHandlers(functions);
}
+
+private:
+ void OpenEnsureNetworkClockAvailabilityService(Kernel::HLERequestContext& ctx) {
+ IPC::ResponseBuilder rb{ctx, 2, 0, 1};
+ rb.Push(RESULT_SUCCESS);
+ rb.PushIpcInterface<IEnsureNetworkClockAvailabilityService>();
+ LOG_DEBUG(Service_NIM, "called");
+ }
+
+ // TODO(ogniK): Do we need these?
+ void SuspendAutonomicTimeCorrection(Kernel::HLERequestContext& ctx) {
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(RESULT_SUCCESS);
+ LOG_WARNING(Service_NIM, "(STUBBED) called");
+ }
+
+ void ResumeAutonomicTimeCorrection(Kernel::HLERequestContext& ctx) {
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(RESULT_SUCCESS);
+ LOG_WARNING(Service_NIM, "(STUBBED) called");
+ }
};
void InstallInterfaces(SM::ServiceManager& sm) {