Deglobalize System: Time
This commit is contained in:
parent
36a97dd8a2
commit
2c6e4ce0ad
|
@ -7,8 +7,8 @@
|
||||||
namespace Service::Time {
|
namespace Service::Time {
|
||||||
|
|
||||||
Time::Time(std::shared_ptr<Module> time, std::shared_ptr<SharedMemory> shared_memory,
|
Time::Time(std::shared_ptr<Module> time, std::shared_ptr<SharedMemory> shared_memory,
|
||||||
const char* name)
|
Core::System& system, const char* name)
|
||||||
: Module::Interface(std::move(time), std::move(shared_memory), name) {
|
: Module::Interface(std::move(time), std::move(shared_memory), system, name) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &Time::GetStandardUserSystemClock, "GetStandardUserSystemClock"},
|
{0, &Time::GetStandardUserSystemClock, "GetStandardUserSystemClock"},
|
||||||
|
|
|
@ -13,7 +13,7 @@ class SharedMemory;
|
||||||
class Time final : public Module::Interface {
|
class Time final : public Module::Interface {
|
||||||
public:
|
public:
|
||||||
explicit Time(std::shared_ptr<Module> time, std::shared_ptr<SharedMemory> shared_memory,
|
explicit Time(std::shared_ptr<Module> time, std::shared_ptr<SharedMemory> shared_memory,
|
||||||
const char* name);
|
Core::System& system, const char* name);
|
||||||
~Time() override;
|
~Time() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -126,8 +126,8 @@ private:
|
||||||
|
|
||||||
class ISteadyClock final : public ServiceFramework<ISteadyClock> {
|
class ISteadyClock final : public ServiceFramework<ISteadyClock> {
|
||||||
public:
|
public:
|
||||||
ISteadyClock(std::shared_ptr<SharedMemory> shared_memory)
|
ISteadyClock(std::shared_ptr<SharedMemory> shared_memory, Core::System& system)
|
||||||
: ServiceFramework("ISteadyClock"), shared_memory(shared_memory) {
|
: ServiceFramework("ISteadyClock"), shared_memory(shared_memory), system(system) {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &ISteadyClock::GetCurrentTimePoint, "GetCurrentTimePoint"},
|
{0, &ISteadyClock::GetCurrentTimePoint, "GetCurrentTimePoint"},
|
||||||
};
|
};
|
||||||
|
@ -150,12 +150,13 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
SteadyClockTimePoint GetCurrentTimePoint() const {
|
SteadyClockTimePoint GetCurrentTimePoint() const {
|
||||||
const auto& core_timing = Core::System::GetInstance().CoreTiming();
|
const auto& core_timing = system.CoreTiming();
|
||||||
const auto ms = Core::Timing::CyclesToMs(core_timing.GetTicks());
|
const auto ms = Core::Timing::CyclesToMs(core_timing.GetTicks());
|
||||||
return {static_cast<u64_le>(ms.count() / 1000), {}};
|
return {static_cast<u64_le>(ms.count() / 1000), {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<SharedMemory> shared_memory;
|
std::shared_ptr<SharedMemory> shared_memory;
|
||||||
|
Core::System& system;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ITimeZoneService final : public ServiceFramework<ITimeZoneService> {
|
class ITimeZoneService final : public ServiceFramework<ITimeZoneService> {
|
||||||
|
@ -290,7 +291,7 @@ void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushIpcInterface<ISteadyClock>(shared_memory);
|
rb.PushIpcInterface<ISteadyClock>(shared_memory, system);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) {
|
||||||
|
@ -325,7 +326,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& core_timing = Core::System::GetInstance().CoreTiming();
|
const auto& core_timing = system.CoreTiming();
|
||||||
const auto ms = Core::Timing::CyclesToMs(core_timing.GetTicks());
|
const auto ms = Core::Timing::CyclesToMs(core_timing.GetTicks());
|
||||||
const SteadyClockTimePoint steady_clock_time_point{static_cast<u64_le>(ms.count() / 1000), {}};
|
const SteadyClockTimePoint steady_clock_time_point{static_cast<u64_le>(ms.count() / 1000), {}};
|
||||||
|
|
||||||
|
@ -407,8 +408,10 @@ void Module::Interface::SetStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||||
}
|
}
|
||||||
|
|
||||||
Module::Interface::Interface(std::shared_ptr<Module> time,
|
Module::Interface::Interface(std::shared_ptr<Module> time,
|
||||||
std::shared_ptr<SharedMemory> shared_memory, const char* name)
|
std::shared_ptr<SharedMemory> shared_memory, Core::System& system,
|
||||||
: ServiceFramework(name), time(std::move(time)), shared_memory(std::move(shared_memory)) {}
|
const char* name)
|
||||||
|
: ServiceFramework(name), time(std::move(time)), shared_memory(std::move(shared_memory)),
|
||||||
|
system(system) {}
|
||||||
|
|
||||||
Module::Interface::~Interface() = default;
|
Module::Interface::~Interface() = default;
|
||||||
|
|
||||||
|
@ -416,9 +419,11 @@ void InstallInterfaces(Core::System& system) {
|
||||||
auto time = std::make_shared<Module>();
|
auto time = std::make_shared<Module>();
|
||||||
auto shared_mem = std::make_shared<SharedMemory>(system);
|
auto shared_mem = std::make_shared<SharedMemory>(system);
|
||||||
|
|
||||||
std::make_shared<Time>(time, shared_mem, "time:a")->InstallAsService(system.ServiceManager());
|
std::make_shared<Time>(time, shared_mem, system, "time:a")
|
||||||
std::make_shared<Time>(time, shared_mem, "time:s")->InstallAsService(system.ServiceManager());
|
->InstallAsService(system.ServiceManager());
|
||||||
std::make_shared<Time>(std::move(time), shared_mem, "time:u")
|
std::make_shared<Time>(time, shared_mem, system, "time:s")
|
||||||
|
->InstallAsService(system.ServiceManager());
|
||||||
|
std::make_shared<Time>(std::move(time), shared_mem, system, "time:u")
|
||||||
->InstallAsService(system.ServiceManager());
|
->InstallAsService(system.ServiceManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,8 @@ public:
|
||||||
class Interface : public ServiceFramework<Interface> {
|
class Interface : public ServiceFramework<Interface> {
|
||||||
public:
|
public:
|
||||||
explicit Interface(std::shared_ptr<Module> time,
|
explicit Interface(std::shared_ptr<Module> time,
|
||||||
std::shared_ptr<SharedMemory> shared_memory, const char* name);
|
std::shared_ptr<SharedMemory> shared_memory, Core::System& system,
|
||||||
|
const char* name);
|
||||||
~Interface() override;
|
~Interface() override;
|
||||||
|
|
||||||
void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx);
|
void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx);
|
||||||
|
@ -97,6 +98,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<Module> time;
|
std::shared_ptr<Module> time;
|
||||||
std::shared_ptr<SharedMemory> shared_memory;
|
std::shared_ptr<SharedMemory> shared_memory;
|
||||||
|
Core::System& system;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Reference in New Issue