summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Rozlette2018-01-18 10:58:29 -0600
committerGravatar Rozlette2018-01-18 10:58:29 -0600
commitc7c180fdf1075827075e7aad6f821cafd09f02f3 (patch)
tree93b648056717d25c93e5ad52fcd9d02bd5582895 /src
parentMerge pull request #84 from lioncash/cmake (diff)
downloadyuzu-c7c180fdf1075827075e7aad6f821cafd09f02f3.tar.gz
yuzu-c7c180fdf1075827075e7aad6f821cafd09f02f3.tar.xz
yuzu-c7c180fdf1075827075e7aad6f821cafd09f02f3.zip
time: Refactor time:* to use a single shared module
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt4
-rw-r--r--src/core/hle/service/time/time.cpp28
-rw-r--r--src/core/hle/service/time/time.h22
-rw-r--r--src/core/hle/service/time/time_s.cpp20
-rw-r--r--src/core/hle/service/time/time_s.h18
-rw-r--r--src/core/hle/service/time/time_u.cpp23
-rw-r--r--src/core/hle/service/time/time_u.h18
7 files changed, 107 insertions, 26 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index c05244b7e..98fd2a4cc 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -130,6 +130,10 @@ add_library(core STATIC
130 hle/service/sm/sm.h 130 hle/service/sm/sm.h
131 hle/service/time/time.cpp 131 hle/service/time/time.cpp
132 hle/service/time/time.h 132 hle/service/time/time.h
133 hle/service/time/time_s.cpp
134 hle/service/time/time_s.h
135 hle/service/time/time_u.cpp
136 hle/service/time/time_u.h
133 hle/service/vi/vi.cpp 137 hle/service/vi/vi.cpp
134 hle/service/vi/vi.h 138 hle/service/vi/vi.h
135 hle/service/vi/vi_m.cpp 139 hle/service/vi/vi_m.cpp
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index 674b59509..1d08e968f 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -8,6 +8,8 @@
8#include "core/hle/kernel/client_port.h" 8#include "core/hle/kernel/client_port.h"
9#include "core/hle/kernel/client_session.h" 9#include "core/hle/kernel/client_session.h"
10#include "core/hle/service/time/time.h" 10#include "core/hle/service/time/time.h"
11#include "core/hle/service/time/time_s.h"
12#include "core/hle/service/time/time_u.h"
11 13
12namespace Service { 14namespace Service {
13namespace Time { 15namespace Time {
@@ -72,7 +74,7 @@ private:
72 } 74 }
73}; 75};
74 76
75void TIME::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) { 77void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) {
76 auto client_port = std::make_shared<ISystemClock>()->CreatePort(); 78 auto client_port = std::make_shared<ISystemClock>()->CreatePort();
77 auto session = client_port->Connect(); 79 auto session = client_port->Connect();
78 if (session.Succeeded()) { 80 if (session.Succeeded()) {
@@ -86,7 +88,7 @@ void TIME::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) {
86 } 88 }
87} 89}
88 90
89void TIME::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) { 91void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) {
90 auto client_port = std::make_shared<ISystemClock>()->CreatePort(); 92 auto client_port = std::make_shared<ISystemClock>()->CreatePort();
91 auto session = client_port->Connect(); 93 auto session = client_port->Connect();
92 if (session.Succeeded()) { 94 if (session.Succeeded()) {
@@ -100,7 +102,7 @@ void TIME::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) {
100 } 102 }
101} 103}
102 104
103void TIME::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) { 105void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
104 auto client_port = std::make_shared<ISteadyClock>()->CreatePort(); 106 auto client_port = std::make_shared<ISteadyClock>()->CreatePort();
105 auto session = client_port->Connect(); 107 auto session = client_port->Connect();
106 if (session.Succeeded()) { 108 if (session.Succeeded()) {
@@ -114,28 +116,20 @@ void TIME::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
114 } 116 }
115} 117}
116 118
117void TIME::GetTimeZoneService(Kernel::HLERequestContext& ctx) { 119void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) {
118 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 120 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1};
119 rb.Push(RESULT_SUCCESS); 121 rb.Push(RESULT_SUCCESS);
120 rb.PushIpcInterface<ITimeZoneService>(); 122 rb.PushIpcInterface<ITimeZoneService>();
121 LOG_DEBUG(Service, "called"); 123 LOG_DEBUG(Service, "called");
122} 124}
123 125
124TIME::TIME(const char* name) : ServiceFramework(name) { 126Module::Interface::Interface(std::shared_ptr<Module> time, const char* name)
125 static const FunctionInfo functions[] = { 127 : ServiceFramework(name), time(std::move(time)) {}
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 128
134void InstallInterfaces(SM::ServiceManager& service_manager) { 129void InstallInterfaces(SM::ServiceManager& service_manager) {
135 std::make_shared<TIME>("time:a")->InstallAsService(service_manager); 130 auto time = std::make_shared<Module>();
136 std::make_shared<TIME>("time:r")->InstallAsService(service_manager); 131 std::make_shared<TIME_S>(time)->InstallAsService(service_manager);
137 std::make_shared<TIME>("time:s")->InstallAsService(service_manager); 132 std::make_shared<TIME_U>(time)->InstallAsService(service_manager);
138 std::make_shared<TIME>("time:u")->InstallAsService(service_manager);
139} 133}
140 134
141} // namespace Time 135} // namespace Time
diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h
index 5f332d057..2aa424dbb 100644
--- a/src/core/hle/service/time/time.h
+++ b/src/core/hle/service/time/time.h
@@ -33,16 +33,20 @@ struct CalendarAdditionalInfo {
33static_assert(sizeof(CalendarAdditionalInfo) == 0x18, 33static_assert(sizeof(CalendarAdditionalInfo) == 0x18,
34 "CalendarAdditionalInfo structure has incorrect size"); 34 "CalendarAdditionalInfo structure has incorrect size");
35 35
36class TIME final : public ServiceFramework<TIME> { 36class Module final {
37public: 37public:
38 explicit TIME(const char* name); 38 class Interface : public ServiceFramework<Interface> {
39 ~TIME() = default; 39 public:
40 40 Interface(std::shared_ptr<Module> time, const char* name);
41private: 41
42 void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx); 42 void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx);
43 void GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx); 43 void GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx);
44 void GetStandardSteadyClock(Kernel::HLERequestContext& ctx); 44 void GetStandardSteadyClock(Kernel::HLERequestContext& ctx);
45 void GetTimeZoneService(Kernel::HLERequestContext& ctx); 45 void GetTimeZoneService(Kernel::HLERequestContext& ctx);
46
47 protected:
48 std::shared_ptr<Module> time;
49 };
46}; 50};
47 51
48/// Registers all Time services with the specified service manager. 52/// Registers all Time services with the specified service manager.
diff --git a/src/core/hle/service/time/time_s.cpp b/src/core/hle/service/time/time_s.cpp
new file mode 100644
index 000000000..52de888d3
--- /dev/null
+++ b/src/core/hle/service/time/time_s.cpp
@@ -0,0 +1,20 @@
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/service/time/time_s.h"
8
9namespace Service {
10namespace Time {
11
12TIME_S::TIME_S(std::shared_ptr<Module> time) : Module::Interface(std::move(time), "time:s") {
13 static const FunctionInfo functions[] = {
14 {0, &TIME_S::GetStandardUserSystemClock, "GetStandardUserSystemClock"},
15 };
16 RegisterHandlers(functions);
17}
18
19} // namespace Time
20} // namespace Service \ No newline at end of file
diff --git a/src/core/hle/service/time/time_s.h b/src/core/hle/service/time/time_s.h
new file mode 100644
index 000000000..6a9c5e673
--- /dev/null
+++ b/src/core/hle/service/time/time_s.h
@@ -0,0 +1,18 @@
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/service/time/time.h"
8
9namespace Service {
10namespace Time {
11
12class TIME_S final : public Module::Interface {
13public:
14 explicit TIME_S(std::shared_ptr<Module> time);
15};
16
17} // namespace Time
18} // namespace Service \ No newline at end of file
diff --git a/src/core/hle/service/time/time_u.cpp b/src/core/hle/service/time/time_u.cpp
new file mode 100644
index 000000000..87fa9da79
--- /dev/null
+++ b/src/core/hle/service/time/time_u.cpp
@@ -0,0 +1,23 @@
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/service/time/time_u.h"
8
9namespace Service {
10namespace Time {
11
12TIME_U::TIME_U(std::shared_ptr<Module> time) : Module::Interface(std::move(time), "time:u") {
13 static const FunctionInfo functions[] = {
14 {0, &TIME_U::GetStandardUserSystemClock, "GetStandardUserSystemClock"},
15 {1, &TIME_U::GetStandardNetworkSystemClock, "GetStandardNetworkSystemClock"},
16 {2, &TIME_U::GetStandardSteadyClock, "GetStandardSteadyClock"},
17 {3, &TIME_U::GetTimeZoneService, "GetTimeZoneService"},
18 };
19 RegisterHandlers(functions);
20}
21
22} // namespace Time
23} // namespace Service \ No newline at end of file
diff --git a/src/core/hle/service/time/time_u.h b/src/core/hle/service/time/time_u.h
new file mode 100644
index 000000000..44e17425f
--- /dev/null
+++ b/src/core/hle/service/time/time_u.h
@@ -0,0 +1,18 @@
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/service/time/time.h"
8
9namespace Service {
10namespace Time {
11
12class TIME_U final : public Module::Interface {
13public:
14 explicit TIME_U(std::shared_ptr<Module> time);
15};
16
17} // namespace Time
18} // namespace Service \ No newline at end of file