mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 02:41:49 -05:00
Merge pull request #100 from Rozelette/master
time: Refactor time:* to use a single shared module
This commit is contained in:
commit
952dba9c2b
7 changed files with 112 additions and 31 deletions
|
@ -135,6 +135,10 @@ add_library(core STATIC
|
||||||
hle/service/sockets/sockets.h
|
hle/service/sockets/sockets.h
|
||||||
hle/service/time/time.cpp
|
hle/service/time/time.cpp
|
||||||
hle/service/time/time.h
|
hle/service/time/time.h
|
||||||
|
hle/service/time/time_s.cpp
|
||||||
|
hle/service/time/time_s.h
|
||||||
|
hle/service/time/time_u.cpp
|
||||||
|
hle/service/time/time_u.h
|
||||||
hle/service/vi/vi.cpp
|
hle/service/vi/vi.cpp
|
||||||
hle/service/vi/vi.h
|
hle/service/vi/vi.h
|
||||||
hle/service/vi/vi_m.cpp
|
hle/service/vi/vi_m.cpp
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include "core/hle/kernel/client_port.h"
|
#include "core/hle/kernel/client_port.h"
|
||||||
#include "core/hle/kernel/client_session.h"
|
#include "core/hle/kernel/client_session.h"
|
||||||
#include "core/hle/service/time/time.h"
|
#include "core/hle/service/time/time.h"
|
||||||
|
#include "core/hle/service/time/time_s.h"
|
||||||
|
#include "core/hle/service/time/time_u.h"
|
||||||
|
|
||||||
namespace Service {
|
namespace Service {
|
||||||
namespace Time {
|
namespace Time {
|
||||||
|
@ -59,20 +61,20 @@ private:
|
||||||
|
|
||||||
void ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx) {
|
void ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
u64 posixTime = rp.Pop<u64>();
|
u64 posix_time = rp.Pop<u64>();
|
||||||
|
|
||||||
LOG_WARNING(Service, "(STUBBED) called, posixTime=0x%016llX", posixTime);
|
LOG_WARNING(Service, "(STUBBED) called, posix_time=0x%016llX", posix_time);
|
||||||
|
|
||||||
CalendarTime calendarTime{2018, 1, 1, 0, 0, 0};
|
CalendarTime calendar_time{2018, 1, 1, 0, 0, 0};
|
||||||
CalendarAdditionalInfo additionalInfo{};
|
CalendarAdditionalInfo additional_info{};
|
||||||
IPC::RequestBuilder rb{ctx, 10};
|
IPC::RequestBuilder rb{ctx, 10};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushRaw(calendarTime);
|
rb.PushRaw(calendar_time);
|
||||||
rb.PushRaw(additionalInfo);
|
rb.PushRaw(additional_info);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void TIME::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) {
|
||||||
auto client_port = std::make_shared<ISystemClock>()->CreatePort();
|
auto client_port = std::make_shared<ISystemClock>()->CreatePort();
|
||||||
auto session = client_port->Connect();
|
auto session = client_port->Connect();
|
||||||
if (session.Succeeded()) {
|
if (session.Succeeded()) {
|
||||||
|
@ -86,7 +88,7 @@ void TIME::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIME::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) {
|
||||||
auto client_port = std::make_shared<ISystemClock>()->CreatePort();
|
auto client_port = std::make_shared<ISystemClock>()->CreatePort();
|
||||||
auto session = client_port->Connect();
|
auto session = client_port->Connect();
|
||||||
if (session.Succeeded()) {
|
if (session.Succeeded()) {
|
||||||
|
@ -100,7 +102,7 @@ void TIME::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIME::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
|
||||||
auto client_port = std::make_shared<ISteadyClock>()->CreatePort();
|
auto client_port = std::make_shared<ISteadyClock>()->CreatePort();
|
||||||
auto session = client_port->Connect();
|
auto session = client_port->Connect();
|
||||||
if (session.Succeeded()) {
|
if (session.Succeeded()) {
|
||||||
|
@ -114,28 +116,20 @@ void TIME::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIME::GetTimeZoneService(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestBuilder rb{ctx, 2, 0, 0, 1};
|
IPC::RequestBuilder rb{ctx, 2, 0, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushIpcInterface<ITimeZoneService>();
|
rb.PushIpcInterface<ITimeZoneService>();
|
||||||
LOG_DEBUG(Service, "called");
|
LOG_DEBUG(Service, "called");
|
||||||
}
|
}
|
||||||
|
|
||||||
TIME::TIME(const char* name) : ServiceFramework(name) {
|
Module::Interface::Interface(std::shared_ptr<Module> time, const char* name)
|
||||||
static const FunctionInfo functions[] = {
|
: ServiceFramework(name), time(std::move(time)) {}
|
||||||
{0x00000000, &TIME::GetStandardUserSystemClock, "GetStandardUserSystemClock"},
|
|
||||||
{0x00000001, &TIME::GetStandardNetworkSystemClock, "GetStandardNetworkSystemClock"},
|
|
||||||
{0x00000002, &TIME::GetStandardSteadyClock, "GetStandardSteadyClock"},
|
|
||||||
{0x00000003, &TIME::GetTimeZoneService, "GetTimeZoneService"},
|
|
||||||
};
|
|
||||||
RegisterHandlers(functions);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
||||||
std::make_shared<TIME>("time:a")->InstallAsService(service_manager);
|
auto time = std::make_shared<Module>();
|
||||||
std::make_shared<TIME>("time:r")->InstallAsService(service_manager);
|
std::make_shared<TIME_S>(time)->InstallAsService(service_manager);
|
||||||
std::make_shared<TIME>("time:s")->InstallAsService(service_manager);
|
std::make_shared<TIME_U>(time)->InstallAsService(service_manager);
|
||||||
std::make_shared<TIME>("time:u")->InstallAsService(service_manager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Time
|
} // namespace Time
|
||||||
|
|
|
@ -33,16 +33,20 @@ struct CalendarAdditionalInfo {
|
||||||
static_assert(sizeof(CalendarAdditionalInfo) == 0x18,
|
static_assert(sizeof(CalendarAdditionalInfo) == 0x18,
|
||||||
"CalendarAdditionalInfo structure has incorrect size");
|
"CalendarAdditionalInfo structure has incorrect size");
|
||||||
|
|
||||||
class TIME final : public ServiceFramework<TIME> {
|
class Module final {
|
||||||
public:
|
public:
|
||||||
explicit TIME(const char* name);
|
class Interface : public ServiceFramework<Interface> {
|
||||||
~TIME() = default;
|
public:
|
||||||
|
Interface(std::shared_ptr<Module> time, const char* name);
|
||||||
|
|
||||||
private:
|
void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx);
|
||||||
void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx);
|
void GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx);
|
||||||
void GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx);
|
void GetStandardSteadyClock(Kernel::HLERequestContext& ctx);
|
||||||
void GetStandardSteadyClock(Kernel::HLERequestContext& ctx);
|
void GetTimeZoneService(Kernel::HLERequestContext& ctx);
|
||||||
void GetTimeZoneService(Kernel::HLERequestContext& ctx);
|
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<Module> time;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Registers all Time services with the specified service manager.
|
/// Registers all Time services with the specified service manager.
|
||||||
|
|
20
src/core/hle/service/time/time_s.cpp
Normal file
20
src/core/hle/service/time/time_s.cpp
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright 2018 yuzu emulator team
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/service/time/time_s.h"
|
||||||
|
|
||||||
|
namespace Service {
|
||||||
|
namespace Time {
|
||||||
|
|
||||||
|
TIME_S::TIME_S(std::shared_ptr<Module> time) : Module::Interface(std::move(time), "time:s") {
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
|
{0, &TIME_S::GetStandardUserSystemClock, "GetStandardUserSystemClock"},
|
||||||
|
};
|
||||||
|
RegisterHandlers(functions);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Time
|
||||||
|
} // namespace Service
|
18
src/core/hle/service/time/time_s.h
Normal file
18
src/core/hle/service/time/time_s.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// Copyright 2018 yuzu emulator team
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/service/time/time.h"
|
||||||
|
|
||||||
|
namespace Service {
|
||||||
|
namespace Time {
|
||||||
|
|
||||||
|
class TIME_S final : public Module::Interface {
|
||||||
|
public:
|
||||||
|
explicit TIME_S(std::shared_ptr<Module> time);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Time
|
||||||
|
} // namespace Service
|
23
src/core/hle/service/time/time_u.cpp
Normal file
23
src/core/hle/service/time/time_u.cpp
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// Copyright 2018 yuzu emulator team
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/service/time/time_u.h"
|
||||||
|
|
||||||
|
namespace Service {
|
||||||
|
namespace Time {
|
||||||
|
|
||||||
|
TIME_U::TIME_U(std::shared_ptr<Module> time) : Module::Interface(std::move(time), "time:u") {
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
|
{0, &TIME_U::GetStandardUserSystemClock, "GetStandardUserSystemClock"},
|
||||||
|
{1, &TIME_U::GetStandardNetworkSystemClock, "GetStandardNetworkSystemClock"},
|
||||||
|
{2, &TIME_U::GetStandardSteadyClock, "GetStandardSteadyClock"},
|
||||||
|
{3, &TIME_U::GetTimeZoneService, "GetTimeZoneService"},
|
||||||
|
};
|
||||||
|
RegisterHandlers(functions);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Time
|
||||||
|
} // namespace Service
|
18
src/core/hle/service/time/time_u.h
Normal file
18
src/core/hle/service/time/time_u.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// Copyright 2018 yuzu emulator team
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/service/time/time.h"
|
||||||
|
|
||||||
|
namespace Service {
|
||||||
|
namespace Time {
|
||||||
|
|
||||||
|
class TIME_U final : public Module::Interface {
|
||||||
|
public:
|
||||||
|
explicit TIME_U(std::shared_ptr<Module> time);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Time
|
||||||
|
} // namespace Service
|
Loading…
Reference in a new issue