diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/service/time/time.cpp | 130 | ||||
| -rw-r--r-- | src/core/hle/service/time/time.h | 36 | ||||
| -rw-r--r-- | src/core/hle/service/time/time_s.cpp | 58 | ||||
| -rw-r--r-- | src/core/hle/service/time/time_s.h | 23 |
5 files changed, 164 insertions, 85 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 20e41038b..661545e96 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -58,7 +58,6 @@ set(SRCS | |||
| 58 | hle/service/sm/controller.cpp | 58 | hle/service/sm/controller.cpp |
| 59 | hle/service/sm/sm.cpp | 59 | hle/service/sm/sm.cpp |
| 60 | hle/service/time/time.cpp | 60 | hle/service/time/time.cpp |
| 61 | hle/service/time/time_s.cpp | ||
| 62 | hle/service/vi/vi.cpp | 61 | hle/service/vi/vi.cpp |
| 63 | hle/service/vi/vi_m.cpp | 62 | hle/service/vi/vi_m.cpp |
| 64 | hle/shared_page.cpp | 63 | hle/shared_page.cpp |
| @@ -148,7 +147,6 @@ set(HEADERS | |||
| 148 | hle/service/sm/controller.h | 147 | hle/service/sm/controller.h |
| 149 | hle/service/sm/sm.h | 148 | hle/service/sm/sm.h |
| 150 | hle/service/time/time.h | 149 | hle/service/time/time.h |
| 151 | hle/service/time/time_s.h | ||
| 152 | hle/service/vi/vi.h | 150 | hle/service/vi/vi.h |
| 153 | hle/service/vi/vi_m.h | 151 | hle/service/vi/vi_m.h |
| 154 | hle/shared_page.h | 152 | hle/shared_page.h |
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index e3d58aa60..674b59509 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp | |||
| @@ -2,14 +2,140 @@ | |||
| 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 "common/logging/log.h" | ||
| 7 | #include "core/hle/ipc_helpers.h" | ||
| 8 | #include "core/hle/kernel/client_port.h" | ||
| 9 | #include "core/hle/kernel/client_session.h" | ||
| 5 | #include "core/hle/service/time/time.h" | 10 | #include "core/hle/service/time/time.h" |
| 6 | #include "core/hle/service/time/time_s.h" | ||
| 7 | 11 | ||
| 8 | namespace Service { | 12 | namespace Service { |
| 9 | namespace Time { | 13 | namespace Time { |
| 10 | 14 | ||
| 15 | class ISystemClock final : public ServiceFramework<ISystemClock> { | ||
| 16 | public: | ||
| 17 | ISystemClock() : ServiceFramework("ISystemClock") { | ||
| 18 | static const FunctionInfo functions[] = { | ||
| 19 | {0, &ISystemClock::GetCurrentTime, "GetCurrentTime"}, | ||
| 20 | }; | ||
| 21 | RegisterHandlers(functions); | ||
| 22 | } | ||
| 23 | |||
| 24 | private: | ||
| 25 | void GetCurrentTime(Kernel::HLERequestContext& ctx) { | ||
| 26 | const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::milliseconds>( | ||
| 27 | std::chrono::system_clock::now().time_since_epoch()) | ||
| 28 | .count()}; | ||
| 29 | IPC::RequestBuilder rb{ctx, 4}; | ||
| 30 | rb.Push(RESULT_SUCCESS); | ||
| 31 | rb.Push<u64>(time_since_epoch); | ||
| 32 | LOG_DEBUG(Service, "called"); | ||
| 33 | } | ||
| 34 | }; | ||
| 35 | |||
| 36 | class ISteadyClock final : public ServiceFramework<ISteadyClock> { | ||
| 37 | public: | ||
| 38 | ISteadyClock() : ServiceFramework("ISteadyClock") {} | ||
| 39 | }; | ||
| 40 | |||
| 41 | class ITimeZoneService final : public ServiceFramework<ITimeZoneService> { | ||
| 42 | public: | ||
| 43 | ITimeZoneService() : ServiceFramework("ITimeZoneService") { | ||
| 44 | static const FunctionInfo functions[] = { | ||
| 45 | {0, &ITimeZoneService::GetDeviceLocationName, "GetDeviceLocationName"}, | ||
| 46 | {101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"}, | ||
| 47 | }; | ||
| 48 | RegisterHandlers(functions); | ||
| 49 | } | ||
| 50 | |||
| 51 | private: | ||
| 52 | void GetDeviceLocationName(Kernel::HLERequestContext& ctx) { | ||
| 53 | LOG_WARNING(Service, "(STUBBED) called"); | ||
| 54 | LocationName name{}; | ||
| 55 | IPC::RequestBuilder rb{ctx, 11}; | ||
| 56 | rb.Push(RESULT_SUCCESS); | ||
| 57 | rb.PushRaw(name); | ||
| 58 | } | ||
| 59 | |||
| 60 | void ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx) { | ||
| 61 | IPC::RequestParser rp{ctx}; | ||
| 62 | u64 posixTime = rp.Pop<u64>(); | ||
| 63 | |||
| 64 | LOG_WARNING(Service, "(STUBBED) called, posixTime=0x%016llX", posixTime); | ||
| 65 | |||
| 66 | CalendarTime calendarTime{2018, 1, 1, 0, 0, 0}; | ||
| 67 | CalendarAdditionalInfo additionalInfo{}; | ||
| 68 | IPC::RequestBuilder rb{ctx, 10}; | ||
| 69 | rb.Push(RESULT_SUCCESS); | ||
| 70 | rb.PushRaw(calendarTime); | ||
| 71 | rb.PushRaw(additionalInfo); | ||
| 72 | } | ||
| 73 | }; | ||
| 74 | |||
| 75 | void TIME::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) { | ||
| 76 | auto client_port = std::make_shared<ISystemClock>()->CreatePort(); | ||
| 77 | auto session = client_port->Connect(); | ||
| 78 | if (session.Succeeded()) { | ||
| 79 | LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", | ||
| 80 | (*session)->GetObjectId()); | ||
| 81 | IPC::RequestBuilder rb{ctx, 2, 0, 1}; | ||
| 82 | rb.Push(RESULT_SUCCESS); | ||
| 83 | rb.PushMoveObjects(std::move(session).Unwrap()); | ||
| 84 | } else { | ||
| 85 | UNIMPLEMENTED(); | ||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | void TIME::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) { | ||
| 90 | auto client_port = std::make_shared<ISystemClock>()->CreatePort(); | ||
| 91 | auto session = client_port->Connect(); | ||
| 92 | if (session.Succeeded()) { | ||
| 93 | LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", | ||
| 94 | (*session)->GetObjectId()); | ||
| 95 | IPC::RequestBuilder rb{ctx, 2, 0, 1}; | ||
| 96 | rb.Push(RESULT_SUCCESS); | ||
| 97 | rb.PushMoveObjects(std::move(session).Unwrap()); | ||
| 98 | } else { | ||
| 99 | UNIMPLEMENTED(); | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | void TIME::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) { | ||
| 104 | auto client_port = std::make_shared<ISteadyClock>()->CreatePort(); | ||
| 105 | auto session = client_port->Connect(); | ||
| 106 | if (session.Succeeded()) { | ||
| 107 | LOG_DEBUG(Service, "called, initialized ISteadyClock -> session=%u", | ||
| 108 | (*session)->GetObjectId()); | ||
| 109 | IPC::RequestBuilder rb{ctx, 2, 0, 1}; | ||
| 110 | rb.Push(RESULT_SUCCESS); | ||
| 111 | rb.PushMoveObjects(std::move(session).Unwrap()); | ||
| 112 | } else { | ||
| 113 | UNIMPLEMENTED(); | ||
| 114 | } | ||
| 115 | } | ||
| 116 | |||
| 117 | void TIME::GetTimeZoneService(Kernel::HLERequestContext& ctx) { | ||
| 118 | IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; | ||
| 119 | rb.Push(RESULT_SUCCESS); | ||
| 120 | rb.PushIpcInterface<ITimeZoneService>(); | ||
| 121 | LOG_DEBUG(Service, "called"); | ||
| 122 | } | ||
| 123 | |||
| 124 | TIME::TIME(const char* name) : ServiceFramework(name) { | ||
| 125 | static const FunctionInfo functions[] = { | ||
| 126 | {0x00000000, &TIME::GetStandardUserSystemClock, "GetStandardUserSystemClock"}, | ||
| 127 | {0x00000001, &TIME::GetStandardNetworkSystemClock, "GetStandardNetworkSystemClock"}, | ||
| 128 | {0x00000002, &TIME::GetStandardSteadyClock, "GetStandardSteadyClock"}, | ||
| 129 | {0x00000003, &TIME::GetTimeZoneService, "GetTimeZoneService"}, | ||
| 130 | }; | ||
| 131 | RegisterHandlers(functions); | ||
| 132 | } | ||
| 133 | |||
| 11 | void InstallInterfaces(SM::ServiceManager& service_manager) { | 134 | void InstallInterfaces(SM::ServiceManager& service_manager) { |
| 12 | std::make_shared<TimeS>()->InstallAsService(service_manager); | 135 | std::make_shared<TIME>("time:a")->InstallAsService(service_manager); |
| 136 | std::make_shared<TIME>("time:r")->InstallAsService(service_manager); | ||
| 137 | std::make_shared<TIME>("time:s")->InstallAsService(service_manager); | ||
| 138 | std::make_shared<TIME>("time:u")->InstallAsService(service_manager); | ||
| 13 | } | 139 | } |
| 14 | 140 | ||
| 15 | } // namespace Time | 141 | } // namespace Time |
diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h index 7d0803e24..5f332d057 100644 --- a/src/core/hle/service/time/time.h +++ b/src/core/hle/service/time/time.h | |||
| @@ -9,6 +9,42 @@ | |||
| 9 | namespace Service { | 9 | namespace Service { |
| 10 | namespace Time { | 10 | namespace Time { |
| 11 | 11 | ||
| 12 | // TODO(Rozelette) RE this structure | ||
| 13 | struct LocationName { | ||
| 14 | INSERT_PADDING_BYTES(0x24); | ||
| 15 | }; | ||
| 16 | static_assert(sizeof(LocationName) == 0x24, "LocationName structure has incorrect size"); | ||
| 17 | |||
| 18 | struct CalendarTime { | ||
| 19 | u16_le year; | ||
| 20 | u8 month; // Starts at 1 | ||
| 21 | u8 day; // Starts at 1 | ||
| 22 | u8 hour; | ||
| 23 | u8 minute; | ||
| 24 | u8 second; | ||
| 25 | INSERT_PADDING_BYTES(1); | ||
| 26 | }; | ||
| 27 | static_assert(sizeof(CalendarTime) == 0x8, "CalendarTime structure has incorrect size"); | ||
| 28 | |||
| 29 | // TODO(Rozelette) RE this structure | ||
| 30 | struct CalendarAdditionalInfo { | ||
| 31 | INSERT_PADDING_BYTES(0x18); | ||
| 32 | }; | ||
| 33 | static_assert(sizeof(CalendarAdditionalInfo) == 0x18, | ||
| 34 | "CalendarAdditionalInfo structure has incorrect size"); | ||
| 35 | |||
| 36 | class TIME final : public ServiceFramework<TIME> { | ||
| 37 | public: | ||
| 38 | explicit TIME(const char* name); | ||
| 39 | ~TIME() = default; | ||
| 40 | |||
| 41 | private: | ||
| 42 | void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx); | ||
| 43 | void GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx); | ||
| 44 | void GetStandardSteadyClock(Kernel::HLERequestContext& ctx); | ||
| 45 | void GetTimeZoneService(Kernel::HLERequestContext& ctx); | ||
| 46 | }; | ||
| 47 | |||
| 12 | /// Registers all Time services with the specified service manager. | 48 | /// Registers all Time services with the specified service manager. |
| 13 | void InstallInterfaces(SM::ServiceManager& service_manager); | 49 | void InstallInterfaces(SM::ServiceManager& service_manager); |
| 14 | 50 | ||
diff --git a/src/core/hle/service/time/time_s.cpp b/src/core/hle/service/time/time_s.cpp deleted file mode 100644 index 6b0597d8e..000000000 --- a/src/core/hle/service/time/time_s.cpp +++ /dev/null | |||
| @@ -1,58 +0,0 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <chrono> | ||
| 6 | #include "common/logging/log.h" | ||
| 7 | #include "core/hle/ipc_helpers.h" | ||
| 8 | #include "core/hle/kernel/client_port.h" | ||
| 9 | #include "core/hle/kernel/client_session.h" | ||
| 10 | #include "core/hle/service/time/time_s.h" | ||
| 11 | |||
| 12 | namespace Service { | ||
| 13 | namespace Time { | ||
| 14 | |||
| 15 | class ISystemClock final : public ServiceFramework<ISystemClock> { | ||
| 16 | public: | ||
| 17 | ISystemClock() : ServiceFramework("ISystemClock") { | ||
| 18 | static const FunctionInfo functions[] = { | ||
| 19 | {0, &ISystemClock::GetCurrentTime, "GetCurrentTime"}, | ||
| 20 | }; | ||
| 21 | RegisterHandlers(functions); | ||
| 22 | } | ||
| 23 | |||
| 24 | private: | ||
| 25 | void GetCurrentTime(Kernel::HLERequestContext& ctx) { | ||
| 26 | const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::milliseconds>( | ||
| 27 | std::chrono::system_clock::now().time_since_epoch()) | ||
| 28 | .count()}; | ||
| 29 | IPC::RequestBuilder rb{ctx, 4}; | ||
| 30 | rb.Push(RESULT_SUCCESS); | ||
| 31 | rb.Push<u64>(time_since_epoch); | ||
| 32 | LOG_DEBUG(Service, "called"); | ||
| 33 | } | ||
| 34 | }; | ||
| 35 | |||
| 36 | void TimeS::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) { | ||
| 37 | auto client_port = std::make_shared<ISystemClock>()->CreatePort(); | ||
| 38 | auto session = client_port->Connect(); | ||
| 39 | if (session.Succeeded()) { | ||
| 40 | LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", | ||
| 41 | (*session)->GetObjectId()); | ||
| 42 | IPC::RequestBuilder rb{ctx, 2, 0, 1}; | ||
| 43 | rb.Push(RESULT_SUCCESS); | ||
| 44 | rb.PushMoveObjects(std::move(session).Unwrap()); | ||
| 45 | } else { | ||
| 46 | UNIMPLEMENTED(); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | TimeS::TimeS() : ServiceFramework("time:s") { | ||
| 51 | static const FunctionInfo functions[] = { | ||
| 52 | {0x00000000, &TimeS::GetStandardUserSystemClock, "GetStandardUserSystemClock"}, | ||
| 53 | }; | ||
| 54 | RegisterHandlers(functions); | ||
| 55 | } | ||
| 56 | |||
| 57 | } // namespace Time | ||
| 58 | } // namespace Service | ||
diff --git a/src/core/hle/service/time/time_s.h b/src/core/hle/service/time/time_s.h deleted file mode 100644 index 073227910..000000000 --- a/src/core/hle/service/time/time_s.h +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/kernel/hle_ipc.h" | ||
| 8 | #include "core/hle/service/service.h" | ||
| 9 | |||
| 10 | namespace Service { | ||
| 11 | namespace Time { | ||
| 12 | |||
| 13 | class TimeS final : public ServiceFramework<TimeS> { | ||
| 14 | public: | ||
| 15 | TimeS(); | ||
| 16 | ~TimeS() = default; | ||
| 17 | |||
| 18 | private: | ||
| 19 | void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx); | ||
| 20 | }; | ||
| 21 | |||
| 22 | } // namespace Time | ||
| 23 | } // namespace Service | ||