Move time services to new IPC.
Add some fixes/improvements to usage with the new IPC
This commit is contained in:
parent
bd8635e26a
commit
da410506a4
42 changed files with 1256 additions and 2091 deletions
|
@ -41,7 +41,7 @@ bool AlarmWorker::GetClosestAlarmInfo(Service::PSC::Time::AlarmInfo& out_alarm_i
|
|||
Service::PSC::Time::AlarmInfo alarm_info{};
|
||||
s64 closest_time{};
|
||||
|
||||
auto res = m_time_m->GetClosestAlarmInfo(is_valid, alarm_info, closest_time);
|
||||
auto res = m_time_m->GetClosestAlarmInfo(&is_valid, &alarm_info, &closest_time);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
if (is_valid) {
|
||||
|
@ -76,6 +76,7 @@ void AlarmWorker::OnPowerStateChanged() {
|
|||
|
||||
Result AlarmWorker::AttachToClosestAlarmEvent() {
|
||||
m_time_m->GetClosestAlarmUpdatedEvent(&m_event);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
|
||||
void Initialize(std::shared_ptr<Service::PSC::Time::ServiceManager> time_m);
|
||||
|
||||
Kernel::KEvent& GetEvent() {
|
||||
Kernel::KReadableEvent& GetEvent() {
|
||||
return *m_event;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ private:
|
|||
KernelHelpers::ServiceContext m_ctx;
|
||||
std::shared_ptr<Service::PSC::Time::ServiceManager> m_time_m;
|
||||
|
||||
Kernel::KEvent* m_event{};
|
||||
Kernel::KReadableEvent* m_event{};
|
||||
Kernel::KEvent* m_timer_event{};
|
||||
std::shared_ptr<Core::Timing::EventType> m_timer_timing_event;
|
||||
StandardSteadyClockResource& m_steady_clock_resource;
|
||||
|
|
|
@ -13,8 +13,8 @@ void FileTimestampWorker::SetFilesystemPosixTime() {
|
|||
Service::PSC::Time::CalendarTime calendar_time{};
|
||||
Service::PSC::Time::CalendarAdditionalInfo additional_info{};
|
||||
|
||||
if (m_initialized && m_system_clock->GetCurrentTime(time) == ResultSuccess &&
|
||||
m_time_zone->ToCalendarTimeWithMyRule(calendar_time, additional_info, time) ==
|
||||
if (m_initialized && m_system_clock->GetCurrentTime(&time) == ResultSuccess &&
|
||||
m_time_zone->ToCalendarTimeWithMyRule(&calendar_time, &additional_info, time) ==
|
||||
ResultSuccess) {
|
||||
// TODO IFileSystemProxy::SetCurrentPosixTime
|
||||
}
|
||||
|
|
|
@ -79,18 +79,18 @@ Service::PSC::Time::LocationName GetTimeZoneString(Service::PSC::Time::LocationN
|
|||
auto configured_zone = Settings::GetTimeZoneString(Settings::values.time_zone_index.GetValue());
|
||||
|
||||
Service::PSC::Time::LocationName configured_name{};
|
||||
std::memcpy(configured_name.name.data(), configured_zone.data(),
|
||||
std::min(configured_name.name.size(), configured_zone.size()));
|
||||
std::memcpy(configured_name.data(), configured_zone.data(),
|
||||
std::min(configured_name.size(), configured_zone.size()));
|
||||
|
||||
if (!IsTimeZoneBinaryValid(configured_name)) {
|
||||
configured_zone = Common::TimeZone::FindSystemTimeZone();
|
||||
configured_name = {};
|
||||
std::memcpy(configured_name.name.data(), configured_zone.data(),
|
||||
std::min(configured_name.name.size(), configured_zone.size()));
|
||||
std::memcpy(configured_name.data(), configured_zone.data(),
|
||||
std::min(configured_name.size(), configured_zone.size()));
|
||||
}
|
||||
|
||||
ASSERT_MSG(IsTimeZoneBinaryValid(configured_name), "Invalid time zone {}!",
|
||||
configured_name.name.data());
|
||||
configured_name.data());
|
||||
|
||||
return configured_name;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ TimeManager::TimeManager(Core::System& system)
|
|||
m_time_m =
|
||||
system.ServiceManager().GetService<Service::PSC::Time::ServiceManager>("time:m", true);
|
||||
|
||||
auto res = m_time_m->GetStaticServiceAsServiceManager(m_time_sm);
|
||||
auto res = m_time_m->GetStaticServiceAsServiceManager(&m_time_sm);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
m_set_sys =
|
||||
|
@ -114,10 +114,10 @@ TimeManager::TimeManager(Core::System& system)
|
|||
|
||||
m_worker.Initialize(m_time_sm, m_set_sys);
|
||||
|
||||
res = m_time_sm->GetStandardUserSystemClock(m_file_timestamp_worker.m_system_clock);
|
||||
res = m_time_sm->GetStandardUserSystemClock(&m_file_timestamp_worker.m_system_clock);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = m_time_sm->GetTimeZoneService(m_file_timestamp_worker.m_time_zone);
|
||||
res = m_time_sm->GetTimeZoneService(&m_file_timestamp_worker.m_time_zone);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = SetupStandardSteadyClockCore();
|
||||
|
@ -161,8 +161,8 @@ TimeManager::TimeManager(Core::System& system)
|
|||
automatic_correction_time_point);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = m_time_m->SetupStandardUserSystemClockCore(automatic_correction_time_point,
|
||||
is_automatic_correction_enabled);
|
||||
res = m_time_m->SetupStandardUserSystemClockCore(is_automatic_correction_enabled,
|
||||
automatic_correction_time_point);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = m_time_m->SetupEphemeralNetworkSystemClockCore();
|
||||
|
@ -184,12 +184,12 @@ TimeManager::TimeManager(Core::System& system)
|
|||
m_file_timestamp_worker.m_initialized = true;
|
||||
|
||||
s64 system_clock_time{};
|
||||
if (m_file_timestamp_worker.m_system_clock->GetCurrentTime(system_clock_time) ==
|
||||
if (m_file_timestamp_worker.m_system_clock->GetCurrentTime(&system_clock_time) ==
|
||||
ResultSuccess) {
|
||||
Service::PSC::Time::CalendarTime calendar_time{};
|
||||
Service::PSC::Time::CalendarAdditionalInfo calendar_additional{};
|
||||
if (m_file_timestamp_worker.m_time_zone->ToCalendarTimeWithMyRule(
|
||||
calendar_time, calendar_additional, system_clock_time) == ResultSuccess) {
|
||||
&calendar_time, &calendar_additional, system_clock_time) == ResultSuccess) {
|
||||
// TODO IFileSystemProxy::SetCurrentPosixTime(system_clock_time,
|
||||
// calendar_additional.ut_offset)
|
||||
}
|
||||
|
@ -228,10 +228,9 @@ Result TimeManager::SetupStandardSteadyClockCore() {
|
|||
m_set_sys->SetExternalSteadyClockSourceId(clock_source_id);
|
||||
}
|
||||
|
||||
res = m_time_m->SetupStandardSteadyClockCore(clock_source_id, m_steady_clock_resource.GetTime(),
|
||||
external_steady_clock_internal_offset_ns,
|
||||
standard_steady_clock_test_offset_ns,
|
||||
reset_detected);
|
||||
res = m_time_m->SetupStandardSteadyClockCore(
|
||||
reset_detected, clock_source_id, m_steady_clock_resource.GetTime(),
|
||||
external_steady_clock_internal_offset_ns, standard_steady_clock_test_offset_ns);
|
||||
ASSERT(res == ResultSuccess);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
@ -243,14 +242,15 @@ Result TimeManager::SetupTimeZoneServiceCore() {
|
|||
|
||||
auto configured_zone = GetTimeZoneString(name);
|
||||
|
||||
if (configured_zone.name != name.name) {
|
||||
if (configured_zone != name) {
|
||||
m_set_sys->SetDeviceTimeZoneLocationName(configured_zone);
|
||||
name = configured_zone;
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> local_clock;
|
||||
m_time_sm->GetStandardLocalSystemClock(local_clock);
|
||||
m_time_sm->GetStandardLocalSystemClock(&local_clock);
|
||||
|
||||
Service::PSC::Time::SystemClockContext context{};
|
||||
local_clock->GetSystemClockContext(context);
|
||||
local_clock->GetSystemClockContext(&context);
|
||||
m_set_sys->SetDeviceTimeZoneLocationUpdatedTime(context.steady_time_point);
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ Result TimeManager::SetupTimeZoneServiceCore() {
|
|||
res = GetTimeZoneRule(rule_buffer, rule_size, name);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = m_time_m->SetupTimeZoneServiceCore(name, time_point, rule_version, location_count,
|
||||
res = m_time_m->SetupTimeZoneServiceCore(name, rule_version, location_count, time_point,
|
||||
rule_buffer);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
|
||||
#include <chrono>
|
||||
|
||||
#include "common/scope_exit.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/kernel/k_shared_memory.h"
|
||||
#include "core/hle/kernel/svc.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/glue/time/file_timestamp_worker.h"
|
||||
#include "core/hle/service/glue/time/static.h"
|
||||
#include "core/hle/service/psc/time/errors.h"
|
||||
|
@ -41,25 +43,25 @@ StaticService::StaticService(Core::System& system_,
|
|||
time->m_steady_clock_resource} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &StaticService::Handle_GetStandardUserSystemClock, "GetStandardUserSystemClock"},
|
||||
{1, &StaticService::Handle_GetStandardNetworkSystemClock, "GetStandardNetworkSystemClock"},
|
||||
{2, &StaticService::Handle_GetStandardSteadyClock, "GetStandardSteadyClock"},
|
||||
{3, &StaticService::Handle_GetTimeZoneService, "GetTimeZoneService"},
|
||||
{4, &StaticService::Handle_GetStandardLocalSystemClock, "GetStandardLocalSystemClock"},
|
||||
{5, &StaticService::Handle_GetEphemeralNetworkSystemClock, "GetEphemeralNetworkSystemClock"},
|
||||
{20, &StaticService::Handle_GetSharedMemoryNativeHandle, "GetSharedMemoryNativeHandle"},
|
||||
{50, &StaticService::Handle_SetStandardSteadyClockInternalOffset, "SetStandardSteadyClockInternalOffset"},
|
||||
{51, &StaticService::Handle_GetStandardSteadyClockRtcValue, "GetStandardSteadyClockRtcValue"},
|
||||
{100, &StaticService::Handle_IsStandardUserSystemClockAutomaticCorrectionEnabled, "IsStandardUserSystemClockAutomaticCorrectionEnabled"},
|
||||
{101, &StaticService::Handle_SetStandardUserSystemClockAutomaticCorrectionEnabled, "SetStandardUserSystemClockAutomaticCorrectionEnabled"},
|
||||
{102, &StaticService::Handle_GetStandardUserSystemClockInitialYear, "GetStandardUserSystemClockInitialYear"},
|
||||
{200, &StaticService::Handle_IsStandardNetworkSystemClockAccuracySufficient, "IsStandardNetworkSystemClockAccuracySufficient"},
|
||||
{201, &StaticService::Handle_GetStandardUserSystemClockAutomaticCorrectionUpdatedTime, "GetStandardUserSystemClockAutomaticCorrectionUpdatedTime"},
|
||||
{300, &StaticService::Handle_CalculateMonotonicSystemClockBaseTimePoint, "CalculateMonotonicSystemClockBaseTimePoint"},
|
||||
{400, &StaticService::Handle_GetClockSnapshot, "GetClockSnapshot"},
|
||||
{401, &StaticService::Handle_GetClockSnapshotFromSystemClockContext, "GetClockSnapshotFromSystemClockContext"},
|
||||
{500, &StaticService::Handle_CalculateStandardUserSystemClockDifferenceByUser, "CalculateStandardUserSystemClockDifferenceByUser"},
|
||||
{501, &StaticService::Handle_CalculateSpanBetween, "CalculateSpanBetween"},
|
||||
{0, D<&StaticService::GetStandardUserSystemClock>, "GetStandardUserSystemClock"},
|
||||
{1, D<&StaticService::GetStandardNetworkSystemClock>, "GetStandardNetworkSystemClock"},
|
||||
{2, D<&StaticService::GetStandardSteadyClock>, "GetStandardSteadyClock"},
|
||||
{3, D<&StaticService::GetTimeZoneService>, "GetTimeZoneService"},
|
||||
{4, D<&StaticService::GetStandardLocalSystemClock>, "GetStandardLocalSystemClock"},
|
||||
{5, D<&StaticService::GetEphemeralNetworkSystemClock>, "GetEphemeralNetworkSystemClock"},
|
||||
{20, D<&StaticService::GetSharedMemoryNativeHandle>, "GetSharedMemoryNativeHandle"},
|
||||
{50, D<&StaticService::SetStandardSteadyClockInternalOffset>, "SetStandardSteadyClockInternalOffset"},
|
||||
{51, D<&StaticService::GetStandardSteadyClockRtcValue>, "GetStandardSteadyClockRtcValue"},
|
||||
{100, D<&StaticService::IsStandardUserSystemClockAutomaticCorrectionEnabled>, "IsStandardUserSystemClockAutomaticCorrectionEnabled"},
|
||||
{101, D<&StaticService::SetStandardUserSystemClockAutomaticCorrectionEnabled>, "SetStandardUserSystemClockAutomaticCorrectionEnabled"},
|
||||
{102, D<&StaticService::GetStandardUserSystemClockInitialYear>, "GetStandardUserSystemClockInitialYear"},
|
||||
{200, D<&StaticService::IsStandardNetworkSystemClockAccuracySufficient>, "IsStandardNetworkSystemClockAccuracySufficient"},
|
||||
{201, D<&StaticService::GetStandardUserSystemClockAutomaticCorrectionUpdatedTime>, "GetStandardUserSystemClockAutomaticCorrectionUpdatedTime"},
|
||||
{300, D<&StaticService::CalculateMonotonicSystemClockBaseTimePoint>, "CalculateMonotonicSystemClockBaseTimePoint"},
|
||||
{400, D<&StaticService::GetClockSnapshot>, "GetClockSnapshot"},
|
||||
{401, D<&StaticService::GetClockSnapshotFromSystemClockContext>, "GetClockSnapshotFromSystemClockContext"},
|
||||
{500, D<&StaticService::CalculateStandardUserSystemClockDifferenceByUser>, "CalculateStandardUserSystemClockDifferenceByUser"},
|
||||
{501, D<&StaticService::CalculateSpanBetween>, "CalculateSpanBetween"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
|
@ -71,314 +73,80 @@ StaticService::StaticService(Core::System& system_,
|
|||
if (m_setup_info.can_write_local_clock && m_setup_info.can_write_user_clock &&
|
||||
!m_setup_info.can_write_network_clock && m_setup_info.can_write_timezone_device_location &&
|
||||
!m_setup_info.can_write_steady_clock && !m_setup_info.can_write_uninitialized_clock) {
|
||||
m_time_m->GetStaticServiceAsAdmin(m_wrapped_service);
|
||||
m_time_m->GetStaticServiceAsAdmin(&m_wrapped_service);
|
||||
} else if (!m_setup_info.can_write_local_clock && !m_setup_info.can_write_user_clock &&
|
||||
!m_setup_info.can_write_network_clock &&
|
||||
!m_setup_info.can_write_timezone_device_location &&
|
||||
!m_setup_info.can_write_steady_clock &&
|
||||
!m_setup_info.can_write_uninitialized_clock) {
|
||||
m_time_m->GetStaticServiceAsUser(m_wrapped_service);
|
||||
m_time_m->GetStaticServiceAsUser(&m_wrapped_service);
|
||||
} else if (!m_setup_info.can_write_local_clock && !m_setup_info.can_write_user_clock &&
|
||||
!m_setup_info.can_write_network_clock &&
|
||||
!m_setup_info.can_write_timezone_device_location &&
|
||||
m_setup_info.can_write_steady_clock && !m_setup_info.can_write_uninitialized_clock) {
|
||||
m_time_m->GetStaticServiceAsRepair(m_wrapped_service);
|
||||
m_time_m->GetStaticServiceAsRepair(&m_wrapped_service);
|
||||
} else {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
auto res = m_wrapped_service->GetTimeZoneService(m_time_zone);
|
||||
auto res = m_wrapped_service->GetTimeZoneService(&m_time_zone);
|
||||
ASSERT(res == ResultSuccess);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardUserSystemClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> service{};
|
||||
auto res = GetStandardUserSystemClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<Service::PSC::Time::SystemClock>(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardNetworkSystemClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> service{};
|
||||
auto res = GetStandardNetworkSystemClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<Service::PSC::Time::SystemClock>(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardSteadyClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SteadyClock> service{};
|
||||
auto res = GetStandardSteadyClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetTimeZoneService(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<TimeZoneService> service{};
|
||||
auto res = GetTimeZoneService(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardLocalSystemClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> service{};
|
||||
auto res = GetStandardLocalSystemClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<Service::PSC::Time::SystemClock>(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetEphemeralNetworkSystemClock(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock> service{};
|
||||
auto res = GetEphemeralNetworkSystemClock(service);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(res);
|
||||
rb.PushIpcInterface<Service::PSC::Time::SystemClock>(std::move(service));
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetSharedMemoryNativeHandle(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Kernel::KSharedMemory* shared_memory{};
|
||||
auto res = GetSharedMemoryNativeHandle(&shared_memory);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(res);
|
||||
rb.PushCopyObjects(shared_memory);
|
||||
}
|
||||
|
||||
void StaticService::Handle_SetStandardSteadyClockInternalOffset(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto offset_ns{rp.Pop<s64>()};
|
||||
|
||||
auto res = SetStandardSteadyClockInternalOffset(offset_ns);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardSteadyClockRtcValue(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
s64 rtc_value{};
|
||||
auto res = GetStandardSteadyClockRtcValue(rtc_value);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push(rtc_value);
|
||||
}
|
||||
|
||||
void StaticService::Handle_IsStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
bool is_enabled{};
|
||||
auto res = IsStandardUserSystemClockAutomaticCorrectionEnabled(is_enabled);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push<bool>(is_enabled);
|
||||
}
|
||||
|
||||
void StaticService::Handle_SetStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto automatic_correction{rp.Pop<bool>()};
|
||||
|
||||
auto res = SetStandardUserSystemClockAutomaticCorrectionEnabled(automatic_correction);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardUserSystemClockInitialYear(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
s32 initial_year{};
|
||||
auto res = GetStandardUserSystemClockInitialYear(initial_year);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push(initial_year);
|
||||
}
|
||||
|
||||
void StaticService::Handle_IsStandardNetworkSystemClockAccuracySufficient(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
bool is_sufficient{};
|
||||
auto res = IsStandardNetworkSystemClockAccuracySufficient(is_sufficient);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push<bool>(is_sufficient);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Service::PSC::Time::SteadyClockTimePoint time_point{};
|
||||
auto res = GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(time_point);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx,
|
||||
2 + sizeof(Service::PSC::Time::SteadyClockTimePoint) / sizeof(u32)};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<Service::PSC::Time::SteadyClockTimePoint>(time_point);
|
||||
}
|
||||
|
||||
void StaticService::Handle_CalculateMonotonicSystemClockBaseTimePoint(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()};
|
||||
|
||||
s64 time{};
|
||||
auto res = CalculateMonotonicSystemClockBaseTimePoint(time, context);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push<s64>(time);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetClockSnapshot(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto type{rp.PopEnum<Service::PSC::Time::TimeType>()};
|
||||
|
||||
Service::PSC::Time::ClockSnapshot snapshot{};
|
||||
auto res = GetClockSnapshot(snapshot, type);
|
||||
|
||||
ctx.WriteBuffer(snapshot);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void StaticService::Handle_GetClockSnapshotFromSystemClockContext(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto clock_type{rp.PopEnum<Service::PSC::Time::TimeType>()};
|
||||
[[maybe_unused]] auto alignment{rp.Pop<u32>()};
|
||||
auto user_context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()};
|
||||
auto network_context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()};
|
||||
|
||||
Service::PSC::Time::ClockSnapshot snapshot{};
|
||||
auto res =
|
||||
GetClockSnapshotFromSystemClockContext(snapshot, user_context, network_context, clock_type);
|
||||
|
||||
ctx.WriteBuffer(snapshot);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void StaticService::Handle_CalculateStandardUserSystemClockDifferenceByUser(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Service::PSC::Time::ClockSnapshot a{};
|
||||
Service::PSC::Time::ClockSnapshot b{};
|
||||
|
||||
auto a_buffer{ctx.ReadBuffer(0)};
|
||||
auto b_buffer{ctx.ReadBuffer(1)};
|
||||
|
||||
std::memcpy(&a, a_buffer.data(), sizeof(Service::PSC::Time::ClockSnapshot));
|
||||
std::memcpy(&b, b_buffer.data(), sizeof(Service::PSC::Time::ClockSnapshot));
|
||||
|
||||
s64 difference{};
|
||||
auto res = CalculateStandardUserSystemClockDifferenceByUser(difference, a, b);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push(difference);
|
||||
}
|
||||
|
||||
void StaticService::Handle_CalculateSpanBetween(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Service::PSC::Time::ClockSnapshot a{};
|
||||
Service::PSC::Time::ClockSnapshot b{};
|
||||
|
||||
auto a_buffer{ctx.ReadBuffer(0)};
|
||||
auto b_buffer{ctx.ReadBuffer(1)};
|
||||
|
||||
std::memcpy(&a, a_buffer.data(), sizeof(Service::PSC::Time::ClockSnapshot));
|
||||
std::memcpy(&b, b_buffer.data(), sizeof(Service::PSC::Time::ClockSnapshot));
|
||||
|
||||
s64 time{};
|
||||
auto res = CalculateSpanBetween(time, a, b);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(res);
|
||||
rb.Push(time);
|
||||
}
|
||||
|
||||
// =============================== Implementations ===========================
|
||||
|
||||
Result StaticService::GetStandardUserSystemClock(
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service) {
|
||||
OutInterface<Service::PSC::Time::SystemClock> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
R_RETURN(m_wrapped_service->GetStandardUserSystemClock(out_service));
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardNetworkSystemClock(
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service) {
|
||||
OutInterface<Service::PSC::Time::SystemClock> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
R_RETURN(m_wrapped_service->GetStandardNetworkSystemClock(out_service));
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardSteadyClock(
|
||||
std::shared_ptr<Service::PSC::Time::SteadyClock>& out_service) {
|
||||
OutInterface<Service::PSC::Time::SteadyClock> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
R_RETURN(m_wrapped_service->GetStandardSteadyClock(out_service));
|
||||
}
|
||||
|
||||
Result StaticService::GetTimeZoneService(std::shared_ptr<TimeZoneService>& out_service) {
|
||||
out_service = std::make_shared<TimeZoneService>(m_system, m_file_timestamp_worker,
|
||||
m_setup_info.can_write_timezone_device_location,
|
||||
m_time_zone);
|
||||
Result StaticService::GetTimeZoneService(OutInterface<TimeZoneService> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
*out_service = std::make_shared<TimeZoneService>(
|
||||
m_system, m_file_timestamp_worker, m_setup_info.can_write_timezone_device_location,
|
||||
m_time_zone);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardLocalSystemClock(
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service) {
|
||||
OutInterface<Service::PSC::Time::SystemClock> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
R_RETURN(m_wrapped_service->GetStandardLocalSystemClock(out_service));
|
||||
}
|
||||
|
||||
Result StaticService::GetEphemeralNetworkSystemClock(
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service) {
|
||||
OutInterface<Service::PSC::Time::SystemClock> out_service) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
R_RETURN(m_wrapped_service->GetEphemeralNetworkSystemClock(out_service));
|
||||
}
|
||||
|
||||
Result StaticService::GetSharedMemoryNativeHandle(Kernel::KSharedMemory** out_shared_memory) {
|
||||
Result StaticService::GetSharedMemoryNativeHandle(
|
||||
OutCopyHandle<Kernel::KSharedMemory> out_shared_memory) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
R_RETURN(m_wrapped_service->GetSharedMemoryNativeHandle(out_shared_memory));
|
||||
}
|
||||
|
||||
Result StaticService::SetStandardSteadyClockInternalOffset(s64 offset_ns) {
|
||||
LOG_DEBUG(Service_Time, "called. offset_ns={}", offset_ns);
|
||||
|
||||
R_UNLESS(m_setup_info.can_write_steady_clock, Service::PSC::Time::ResultPermissionDenied);
|
||||
|
||||
R_RETURN(m_set_sys->SetExternalSteadyClockInternalOffset(
|
||||
|
@ -386,62 +154,92 @@ Result StaticService::SetStandardSteadyClockInternalOffset(s64 offset_ns) {
|
|||
std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::seconds(1)).count()));
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardSteadyClockRtcValue(s64& out_rtc_value) {
|
||||
R_RETURN(m_standard_steady_clock_resource.GetRtcTimeInSeconds(out_rtc_value));
|
||||
Result StaticService::GetStandardSteadyClockRtcValue(Out<s64> out_rtc_value) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_rtc_value={}", *out_rtc_value); });
|
||||
|
||||
R_RETURN(m_standard_steady_clock_resource.GetRtcTimeInSeconds(*out_rtc_value));
|
||||
}
|
||||
|
||||
Result StaticService::IsStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
bool& out_automatic_correction) {
|
||||
Out<bool> out_automatic_correction) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time, "called. out_automatic_correction={}", *out_automatic_correction);
|
||||
});
|
||||
|
||||
R_RETURN(m_wrapped_service->IsStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
out_automatic_correction));
|
||||
}
|
||||
|
||||
Result StaticService::SetStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
bool automatic_correction) {
|
||||
LOG_DEBUG(Service_Time, "called. automatic_correction={}", automatic_correction);
|
||||
|
||||
R_RETURN(m_wrapped_service->SetStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
automatic_correction));
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardUserSystemClockInitialYear(s32& out_year) {
|
||||
out_year = GetSettingsItemValue<s32>(m_set_sys, "time", "standard_user_clock_initial_year");
|
||||
Result StaticService::GetStandardUserSystemClockInitialYear(Out<s32> out_year) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_year={}", *out_year); });
|
||||
|
||||
*out_year = GetSettingsItemValue<s32>(m_set_sys, "time", "standard_user_clock_initial_year");
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result StaticService::IsStandardNetworkSystemClockAccuracySufficient(bool& out_is_sufficient) {
|
||||
Result StaticService::IsStandardNetworkSystemClockAccuracySufficient(Out<bool> out_is_sufficient) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_is_sufficient={}", *out_is_sufficient); });
|
||||
|
||||
R_RETURN(m_wrapped_service->IsStandardNetworkSystemClockAccuracySufficient(out_is_sufficient));
|
||||
}
|
||||
|
||||
Result StaticService::GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
|
||||
Service::PSC::Time::SteadyClockTimePoint& out_time_point) {
|
||||
Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_time_point={}", *out_time_point); });
|
||||
|
||||
R_RETURN(m_wrapped_service->GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
|
||||
out_time_point));
|
||||
}
|
||||
|
||||
Result StaticService::CalculateMonotonicSystemClockBaseTimePoint(
|
||||
s64& out_time, Service::PSC::Time::SystemClockContext& context) {
|
||||
Out<s64> out_time, Service::PSC::Time::SystemClockContext& context) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. context={} out_time={}", context, *out_time); });
|
||||
|
||||
R_RETURN(m_wrapped_service->CalculateMonotonicSystemClockBaseTimePoint(out_time, context));
|
||||
}
|
||||
|
||||
Result StaticService::GetClockSnapshot(Service::PSC::Time::ClockSnapshot& out_snapshot,
|
||||
Result StaticService::GetClockSnapshot(OutClockSnapshot out_snapshot,
|
||||
Service::PSC::Time::TimeType type) {
|
||||
SCOPE_EXIT(
|
||||
{ LOG_DEBUG(Service_Time, "called. type={} out_snapshot={}", type, *out_snapshot); });
|
||||
|
||||
R_RETURN(m_wrapped_service->GetClockSnapshot(out_snapshot, type));
|
||||
}
|
||||
|
||||
Result StaticService::GetClockSnapshotFromSystemClockContext(
|
||||
Service::PSC::Time::ClockSnapshot& out_snapshot,
|
||||
Service::PSC::Time::TimeType type, OutClockSnapshot out_snapshot,
|
||||
Service::PSC::Time::SystemClockContext& user_context,
|
||||
Service::PSC::Time::SystemClockContext& network_context, Service::PSC::Time::TimeType type) {
|
||||
R_RETURN(m_wrapped_service->GetClockSnapshotFromSystemClockContext(out_snapshot, user_context,
|
||||
network_context, type));
|
||||
Service::PSC::Time::SystemClockContext& network_context) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time,
|
||||
"called. type={} out_snapshot={} user_context={} network_context={}", type,
|
||||
*out_snapshot, user_context, network_context);
|
||||
});
|
||||
|
||||
R_RETURN(m_wrapped_service->GetClockSnapshotFromSystemClockContext(
|
||||
type, out_snapshot, user_context, network_context));
|
||||
}
|
||||
|
||||
Result StaticService::CalculateStandardUserSystemClockDifferenceByUser(
|
||||
s64& out_time, Service::PSC::Time::ClockSnapshot& a, Service::PSC::Time::ClockSnapshot& b) {
|
||||
Result StaticService::CalculateStandardUserSystemClockDifferenceByUser(Out<s64> out_time,
|
||||
InClockSnapshot a,
|
||||
InClockSnapshot b) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. a={} b={} out_time={}", *a, *b, *out_time); });
|
||||
|
||||
R_RETURN(m_wrapped_service->CalculateStandardUserSystemClockDifferenceByUser(out_time, a, b));
|
||||
}
|
||||
|
||||
Result StaticService::CalculateSpanBetween(s64& out_time, Service::PSC::Time::ClockSnapshot& a,
|
||||
Service::PSC::Time::ClockSnapshot& b) {
|
||||
Result StaticService::CalculateSpanBetween(Out<s64> out_time, InClockSnapshot a,
|
||||
InClockSnapshot b) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. a={} b={} out_time={}", *a, *b, *out_time); });
|
||||
|
||||
R_RETURN(m_wrapped_service->CalculateSpanBetween(out_time, a, b));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/glue/time/manager.h"
|
||||
#include "core/hle/service/glue/time/time_zone.h"
|
||||
#include "core/hle/service/psc/time/common.h"
|
||||
|
@ -29,6 +30,10 @@ class FileTimestampWorker;
|
|||
class StandardSteadyClockResource;
|
||||
|
||||
class StaticService final : public ServiceFramework<StaticService> {
|
||||
using InClockSnapshot = InLargeData<Service::PSC::Time::ClockSnapshot, BufferAttr_HipcPointer>;
|
||||
using OutClockSnapshot =
|
||||
OutLargeData<Service::PSC::Time::ClockSnapshot, BufferAttr_HipcPointer>;
|
||||
|
||||
public:
|
||||
explicit StaticService(Core::System& system,
|
||||
Service::PSC::Time::StaticServiceSetupInfo setup_info,
|
||||
|
@ -36,65 +41,34 @@ public:
|
|||
|
||||
~StaticService() override = default;
|
||||
|
||||
Result GetStandardUserSystemClock(
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service);
|
||||
Result GetStandardNetworkSystemClock(
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service);
|
||||
Result GetStandardSteadyClock(std::shared_ptr<Service::PSC::Time::SteadyClock>& out_service);
|
||||
Result GetTimeZoneService(std::shared_ptr<TimeZoneService>& out_service);
|
||||
Result GetStandardLocalSystemClock(
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service);
|
||||
Result GetStandardUserSystemClock(OutInterface<Service::PSC::Time::SystemClock> out_service);
|
||||
Result GetStandardNetworkSystemClock(OutInterface<Service::PSC::Time::SystemClock> out_service);
|
||||
Result GetStandardSteadyClock(OutInterface<Service::PSC::Time::SteadyClock> out_service);
|
||||
Result GetTimeZoneService(OutInterface<TimeZoneService> out_service);
|
||||
Result GetStandardLocalSystemClock(OutInterface<Service::PSC::Time::SystemClock> out_service);
|
||||
Result GetEphemeralNetworkSystemClock(
|
||||
std::shared_ptr<Service::PSC::Time::SystemClock>& out_service);
|
||||
Result GetSharedMemoryNativeHandle(Kernel::KSharedMemory** out_shared_memory);
|
||||
Result SetStandardSteadyClockInternalOffset(s64 offset);
|
||||
Result GetStandardSteadyClockRtcValue(s64& out_rtc_value);
|
||||
Result IsStandardUserSystemClockAutomaticCorrectionEnabled(bool& out_automatic_correction);
|
||||
OutInterface<Service::PSC::Time::SystemClock> out_service);
|
||||
Result GetSharedMemoryNativeHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory);
|
||||
Result SetStandardSteadyClockInternalOffset(s64 offset_ns);
|
||||
Result GetStandardSteadyClockRtcValue(Out<s64> out_rtc_value);
|
||||
Result IsStandardUserSystemClockAutomaticCorrectionEnabled(Out<bool> out_is_enabled);
|
||||
Result SetStandardUserSystemClockAutomaticCorrectionEnabled(bool automatic_correction);
|
||||
Result GetStandardUserSystemClockInitialYear(s32& out_year);
|
||||
Result IsStandardNetworkSystemClockAccuracySufficient(bool& out_is_sufficient);
|
||||
Result GetStandardUserSystemClockInitialYear(Out<s32> out_year);
|
||||
Result IsStandardNetworkSystemClockAccuracySufficient(Out<bool> out_is_sufficient);
|
||||
Result GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
|
||||
Service::PSC::Time::SteadyClockTimePoint& out_time_point);
|
||||
Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point);
|
||||
Result CalculateMonotonicSystemClockBaseTimePoint(
|
||||
s64& out_time, Service::PSC::Time::SystemClockContext& context);
|
||||
Result GetClockSnapshot(Service::PSC::Time::ClockSnapshot& out_snapshot,
|
||||
Service::PSC::Time::TimeType type);
|
||||
Out<s64> out_time, Service::PSC::Time::SystemClockContext& context);
|
||||
Result GetClockSnapshot(OutClockSnapshot out_snapshot, Service::PSC::Time::TimeType type);
|
||||
Result GetClockSnapshotFromSystemClockContext(
|
||||
Service::PSC::Time::ClockSnapshot& out_snapshot,
|
||||
Service::PSC::Time::TimeType type, OutClockSnapshot out_snapshot,
|
||||
Service::PSC::Time::SystemClockContext& user_context,
|
||||
Service::PSC::Time::SystemClockContext& network_context, Service::PSC::Time::TimeType type);
|
||||
Result CalculateStandardUserSystemClockDifferenceByUser(s64& out_time,
|
||||
Service::PSC::Time::ClockSnapshot& a,
|
||||
Service::PSC::Time::ClockSnapshot& b);
|
||||
Result CalculateSpanBetween(s64& out_time, Service::PSC::Time::ClockSnapshot& a,
|
||||
Service::PSC::Time::ClockSnapshot& b);
|
||||
Service::PSC::Time::SystemClockContext& network_context);
|
||||
Result CalculateStandardUserSystemClockDifferenceByUser(Out<s64> out_difference,
|
||||
InClockSnapshot a, InClockSnapshot b);
|
||||
Result CalculateSpanBetween(Out<s64> out_time, InClockSnapshot a, InClockSnapshot b);
|
||||
|
||||
private:
|
||||
Result GetClockSnapshotImpl(Service::PSC::Time::ClockSnapshot& out_snapshot,
|
||||
Service::PSC::Time::SystemClockContext& user_context,
|
||||
Service::PSC::Time::SystemClockContext& network_context,
|
||||
Service::PSC::Time::TimeType type);
|
||||
|
||||
void Handle_GetStandardUserSystemClock(HLERequestContext& ctx);
|
||||
void Handle_GetStandardNetworkSystemClock(HLERequestContext& ctx);
|
||||
void Handle_GetStandardSteadyClock(HLERequestContext& ctx);
|
||||
void Handle_GetTimeZoneService(HLERequestContext& ctx);
|
||||
void Handle_GetStandardLocalSystemClock(HLERequestContext& ctx);
|
||||
void Handle_GetEphemeralNetworkSystemClock(HLERequestContext& ctx);
|
||||
void Handle_GetSharedMemoryNativeHandle(HLERequestContext& ctx);
|
||||
void Handle_SetStandardSteadyClockInternalOffset(HLERequestContext& ctx);
|
||||
void Handle_GetStandardSteadyClockRtcValue(HLERequestContext& ctx);
|
||||
void Handle_IsStandardUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
|
||||
void Handle_SetStandardUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
|
||||
void Handle_GetStandardUserSystemClockInitialYear(HLERequestContext& ctx);
|
||||
void Handle_IsStandardNetworkSystemClockAccuracySufficient(HLERequestContext& ctx);
|
||||
void Handle_GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(HLERequestContext& ctx);
|
||||
void Handle_CalculateMonotonicSystemClockBaseTimePoint(HLERequestContext& ctx);
|
||||
void Handle_GetClockSnapshot(HLERequestContext& ctx);
|
||||
void Handle_GetClockSnapshotFromSystemClockContext(HLERequestContext& ctx);
|
||||
void Handle_CalculateStandardUserSystemClockDifferenceByUser(HLERequestContext& ctx);
|
||||
void Handle_CalculateSpanBetween(HLERequestContext& ctx);
|
||||
|
||||
Core::System& m_system;
|
||||
|
||||
std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
|
||||
#include <chrono>
|
||||
|
||||
#include "common/scope_exit.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/kernel/svc.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/glue/time/file_timestamp_worker.h"
|
||||
#include "core/hle/service/glue/time/time_zone.h"
|
||||
#include "core/hle/service/glue/time/time_zone_binary.h"
|
||||
|
@ -28,20 +30,20 @@ TimeZoneService::TimeZoneService(
|
|||
m_wrapped_service{std::move(time_zone_service)}, m_operation_event{m_system} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &TimeZoneService::Handle_GetDeviceLocationName, "GetDeviceLocationName"},
|
||||
{1, &TimeZoneService::Handle_SetDeviceLocationName, "SetDeviceLocationName"},
|
||||
{2, &TimeZoneService::Handle_GetTotalLocationNameCount, "GetTotalLocationNameCount"},
|
||||
{3, &TimeZoneService::Handle_LoadLocationNameList, "LoadLocationNameList"},
|
||||
{4, &TimeZoneService::Handle_LoadTimeZoneRule, "LoadTimeZoneRule"},
|
||||
{5, &TimeZoneService::Handle_GetTimeZoneRuleVersion, "GetTimeZoneRuleVersion"},
|
||||
{6, &TimeZoneService::Handle_GetDeviceLocationNameAndUpdatedTime, "GetDeviceLocationNameAndUpdatedTime"},
|
||||
{7, &TimeZoneService::Handle_SetDeviceLocationNameWithTimeZoneRule, "SetDeviceLocationNameWithTimeZoneRule"},
|
||||
{8, &TimeZoneService::Handle_ParseTimeZoneBinary, "ParseTimeZoneBinary"},
|
||||
{20, &TimeZoneService::Handle_GetDeviceLocationNameOperationEventReadableHandle, "GetDeviceLocationNameOperationEventReadableHandle"},
|
||||
{100, &TimeZoneService::Handle_ToCalendarTime, "ToCalendarTime"},
|
||||
{101, &TimeZoneService::Handle_ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"},
|
||||
{201, &TimeZoneService::Handle_ToPosixTime, "ToPosixTime"},
|
||||
{202, &TimeZoneService::Handle_ToPosixTimeWithMyRule, "ToPosixTimeWithMyRule"},
|
||||
{0, D<&TimeZoneService::GetDeviceLocationName>, "GetDeviceLocationName"},
|
||||
{1, D<&TimeZoneService::SetDeviceLocationName>, "SetDeviceLocationName"},
|
||||
{2, D<&TimeZoneService::GetTotalLocationNameCount>, "GetTotalLocationNameCount"},
|
||||
{3, D<&TimeZoneService::LoadLocationNameList>, "LoadLocationNameList"},
|
||||
{4, D<&TimeZoneService::LoadTimeZoneRule>, "LoadTimeZoneRule"},
|
||||
{5, D<&TimeZoneService::GetTimeZoneRuleVersion>, "GetTimeZoneRuleVersion"},
|
||||
{6, D<&TimeZoneService::GetDeviceLocationNameAndUpdatedTime>, "GetDeviceLocationNameAndUpdatedTime"},
|
||||
{7, D<&TimeZoneService::SetDeviceLocationNameWithTimeZoneRule>, "SetDeviceLocationNameWithTimeZoneRule"},
|
||||
{8, D<&TimeZoneService::ParseTimeZoneBinary>, "ParseTimeZoneBinary"},
|
||||
{20, D<&TimeZoneService::GetDeviceLocationNameOperationEventReadableHandle>, "GetDeviceLocationNameOperationEventReadableHandle"},
|
||||
{100, D<&TimeZoneService::ToCalendarTime>, "ToCalendarTime"},
|
||||
{101, D<&TimeZoneService::ToCalendarTimeWithMyRule>, "ToCalendarTimeWithMyRule"},
|
||||
{201, D<&TimeZoneService::ToPosixTime>, "ToPosixTime"},
|
||||
{202, D<&TimeZoneService::ToPosixTimeWithMyRule>, "ToPosixTimeWithMyRule"},
|
||||
};
|
||||
// clang-format on
|
||||
RegisterHandlers(functions);
|
||||
|
@ -53,220 +55,16 @@ TimeZoneService::TimeZoneService(
|
|||
|
||||
TimeZoneService::~TimeZoneService() = default;
|
||||
|
||||
void TimeZoneService::Handle_GetDeviceLocationName(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
Result TimeZoneService::GetDeviceLocationName(
|
||||
Out<Service::PSC::Time::LocationName> out_location_name) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_location_name={}", *out_location_name); });
|
||||
|
||||
Service::PSC::Time::LocationName name{};
|
||||
auto res = GetDeviceLocationName(name);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::LocationName) / sizeof(u32)};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<Service::PSC::Time::LocationName>(name);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_SetDeviceLocationName(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto name{rp.PopRaw<Service::PSC::Time::LocationName>()};
|
||||
|
||||
auto res = SetDeviceLocation(name);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_GetTotalLocationNameCount(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
u32 count{};
|
||||
auto res = GetTotalLocationNameCount(count);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push(count);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_LoadLocationNameList(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto index{rp.Pop<u32>()};
|
||||
|
||||
auto max_names{ctx.GetWriteBufferSize() / sizeof(Service::PSC::Time::LocationName)};
|
||||
|
||||
std::vector<Service::PSC::Time::LocationName> names{};
|
||||
u32 count{};
|
||||
auto res = LoadLocationNameList(count, names, max_names, index);
|
||||
|
||||
ctx.WriteBuffer(names);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push(count);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_LoadTimeZoneRule(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto name{rp.PopRaw<Service::PSC::Time::LocationName>()};
|
||||
|
||||
Tz::Rule rule{};
|
||||
auto res = LoadTimeZoneRule(rule, name);
|
||||
|
||||
ctx.WriteBuffer(rule);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_GetTimeZoneRuleVersion(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Service::PSC::Time::RuleVersion rule_version{};
|
||||
auto res = GetTimeZoneRuleVersion(rule_version);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::RuleVersion) / sizeof(u32)};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<Service::PSC::Time::RuleVersion>(rule_version);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_GetDeviceLocationNameAndUpdatedTime(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Service::PSC::Time::LocationName name{};
|
||||
Service::PSC::Time::SteadyClockTimePoint time_point{};
|
||||
auto res = GetDeviceLocationNameAndUpdatedTime(time_point, name);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx,
|
||||
2 + (sizeof(Service::PSC::Time::LocationName) / sizeof(u32)) +
|
||||
(sizeof(Service::PSC::Time::SteadyClockTimePoint) / sizeof(u32))};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<Service::PSC::Time::LocationName>(name);
|
||||
rb.PushRaw<Service::PSC::Time::SteadyClockTimePoint>(time_point);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_SetDeviceLocationNameWithTimeZoneRule(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
auto res = SetDeviceLocationNameWithTimeZoneRule();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(res);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_ParseTimeZoneBinary(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(Service::PSC::Time::ResultNotImplemented);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_GetDeviceLocationNameOperationEventReadableHandle(
|
||||
HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
Kernel::KEvent* event{};
|
||||
auto res = GetDeviceLocationNameOperationEventReadableHandle(&event);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(res);
|
||||
rb.PushCopyObjects(event->GetReadableEvent());
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_ToCalendarTime(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto time{rp.Pop<s64>()};
|
||||
|
||||
auto rule_buffer{ctx.ReadBuffer()};
|
||||
Tz::Rule rule{};
|
||||
std::memcpy(&rule, rule_buffer.data(), sizeof(Tz::Rule));
|
||||
|
||||
Service::PSC::Time::CalendarTime calendar_time{};
|
||||
Service::PSC::Time::CalendarAdditionalInfo additional_info{};
|
||||
auto res = ToCalendarTime(calendar_time, additional_info, time, rule);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx,
|
||||
2 + (sizeof(Service::PSC::Time::CalendarTime) / sizeof(u32)) +
|
||||
(sizeof(Service::PSC::Time::CalendarAdditionalInfo) / sizeof(u32))};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<Service::PSC::Time::CalendarTime>(calendar_time);
|
||||
rb.PushRaw<Service::PSC::Time::CalendarAdditionalInfo>(additional_info);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_ToCalendarTimeWithMyRule(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto time{rp.Pop<s64>()};
|
||||
|
||||
LOG_DEBUG(Service_Time, "called. time={}", time);
|
||||
|
||||
Service::PSC::Time::CalendarTime calendar_time{};
|
||||
Service::PSC::Time::CalendarAdditionalInfo additional_info{};
|
||||
auto res = ToCalendarTimeWithMyRule(calendar_time, additional_info, time);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx,
|
||||
2 + (sizeof(Service::PSC::Time::CalendarTime) / sizeof(u32)) +
|
||||
(sizeof(Service::PSC::Time::CalendarAdditionalInfo) / sizeof(u32))};
|
||||
rb.Push(res);
|
||||
rb.PushRaw<Service::PSC::Time::CalendarTime>(calendar_time);
|
||||
rb.PushRaw<Service::PSC::Time::CalendarAdditionalInfo>(additional_info);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_ToPosixTime(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto calendar{rp.PopRaw<Service::PSC::Time::CalendarTime>()};
|
||||
|
||||
LOG_DEBUG(Service_Time, "called. calendar year {} month {} day {} hour {} minute {} second {}",
|
||||
calendar.year, calendar.month, calendar.day, calendar.hour, calendar.minute,
|
||||
calendar.second);
|
||||
|
||||
auto binary{ctx.ReadBuffer()};
|
||||
|
||||
Tz::Rule rule{};
|
||||
std::memcpy(&rule, binary.data(), sizeof(Tz::Rule));
|
||||
|
||||
u32 count{};
|
||||
std::array<s64, 2> times{};
|
||||
u32 times_count{static_cast<u32>(ctx.GetWriteBufferSize() / sizeof(s64))};
|
||||
|
||||
auto res = ToPosixTime(count, times, times_count, calendar, rule);
|
||||
|
||||
ctx.WriteBuffer(times);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push(count);
|
||||
}
|
||||
|
||||
void TimeZoneService::Handle_ToPosixTimeWithMyRule(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto calendar{rp.PopRaw<Service::PSC::Time::CalendarTime>()};
|
||||
|
||||
u32 count{};
|
||||
std::array<s64, 2> times{};
|
||||
u32 times_count{static_cast<u32>(ctx.GetWriteBufferSize() / sizeof(s64))};
|
||||
|
||||
auto res = ToPosixTimeWithMyRule(count, times, times_count, calendar);
|
||||
|
||||
ctx.WriteBuffer(times);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(res);
|
||||
rb.Push(count);
|
||||
}
|
||||
|
||||
// =============================== Implementations ===========================
|
||||
|
||||
Result TimeZoneService::GetDeviceLocationName(Service::PSC::Time::LocationName& out_location_name) {
|
||||
R_RETURN(m_wrapped_service->GetDeviceLocationName(out_location_name));
|
||||
}
|
||||
|
||||
Result TimeZoneService::SetDeviceLocation(Service::PSC::Time::LocationName& location_name) {
|
||||
Result TimeZoneService::SetDeviceLocationName(Service::PSC::Time::LocationName& location_name) {
|
||||
LOG_DEBUG(Service_Time, "called. location_name={}", location_name);
|
||||
|
||||
R_UNLESS(m_can_write_timezone_device_location, Service::PSC::Time::ResultPermissionDenied);
|
||||
R_UNLESS(IsTimeZoneBinaryValid(location_name), Service::PSC::Time::ResultTimeZoneNotFound);
|
||||
|
||||
|
@ -282,7 +80,7 @@ Result TimeZoneService::SetDeviceLocation(Service::PSC::Time::LocationName& loca
|
|||
|
||||
Service::PSC::Time::SteadyClockTimePoint time_point{};
|
||||
Service::PSC::Time::LocationName name{};
|
||||
R_TRY(m_wrapped_service->GetDeviceLocationNameAndUpdatedTime(time_point, name));
|
||||
R_TRY(m_wrapped_service->GetDeviceLocationNameAndUpdatedTime(&name, &time_point));
|
||||
|
||||
m_set_sys->SetDeviceTimeZoneLocationName(name);
|
||||
m_set_sys->SetDeviceTimeZoneLocationUpdatedTime(time_point);
|
||||
|
@ -294,19 +92,27 @@ Result TimeZoneService::SetDeviceLocation(Service::PSC::Time::LocationName& loca
|
|||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result TimeZoneService::GetTotalLocationNameCount(u32& out_count) {
|
||||
Result TimeZoneService::GetTotalLocationNameCount(Out<u32> out_count) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_count={}", *out_count); });
|
||||
|
||||
R_RETURN(m_wrapped_service->GetTotalLocationNameCount(out_count));
|
||||
}
|
||||
|
||||
Result TimeZoneService::LoadLocationNameList(
|
||||
u32& out_count, std::vector<Service::PSC::Time::LocationName>& out_names, size_t max_names,
|
||||
u32 index) {
|
||||
Out<u32> out_count,
|
||||
OutArray<Service::PSC::Time::LocationName, BufferAttr_HipcMapAlias> out_names, u32 index) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time, "called. index={} out_count={} out_names[0]={} out_names[1]={}",
|
||||
index, *out_count, out_names[0], out_names[1]);
|
||||
});
|
||||
|
||||
std::scoped_lock l{m_mutex};
|
||||
R_RETURN(GetTimeZoneLocationList(out_count, out_names, max_names, index));
|
||||
R_RETURN(GetTimeZoneLocationList(*out_count, out_names, out_names.size(), index));
|
||||
}
|
||||
|
||||
Result TimeZoneService::LoadTimeZoneRule(Tz::Rule& out_rule,
|
||||
Service::PSC::Time::LocationName& name) {
|
||||
Result TimeZoneService::LoadTimeZoneRule(OutRule out_rule, Service::PSC::Time::LocationName& name) {
|
||||
LOG_DEBUG(Service_Time, "called. name={}", name);
|
||||
|
||||
std::scoped_lock l{m_mutex};
|
||||
std::span<const u8> binary{};
|
||||
size_t binary_size{};
|
||||
|
@ -314,23 +120,43 @@ Result TimeZoneService::LoadTimeZoneRule(Tz::Rule& out_rule,
|
|||
R_RETURN(m_wrapped_service->ParseTimeZoneBinary(out_rule, binary));
|
||||
}
|
||||
|
||||
Result TimeZoneService::GetTimeZoneRuleVersion(Service::PSC::Time::RuleVersion& out_rule_version) {
|
||||
Result TimeZoneService::GetTimeZoneRuleVersion(
|
||||
Out<Service::PSC::Time::RuleVersion> out_rule_version) {
|
||||
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_rule_version={}", *out_rule_version); });
|
||||
|
||||
R_RETURN(m_wrapped_service->GetTimeZoneRuleVersion(out_rule_version));
|
||||
}
|
||||
|
||||
Result TimeZoneService::GetDeviceLocationNameAndUpdatedTime(
|
||||
Service::PSC::Time::SteadyClockTimePoint& out_time_point,
|
||||
Service::PSC::Time::LocationName& location_name) {
|
||||
R_RETURN(m_wrapped_service->GetDeviceLocationNameAndUpdatedTime(out_time_point, location_name));
|
||||
Out<Service::PSC::Time::LocationName> location_name,
|
||||
Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time, "called. location_name={} out_time_point={}", *location_name,
|
||||
*out_time_point);
|
||||
});
|
||||
|
||||
R_RETURN(m_wrapped_service->GetDeviceLocationNameAndUpdatedTime(location_name, out_time_point));
|
||||
}
|
||||
|
||||
Result TimeZoneService::SetDeviceLocationNameWithTimeZoneRule() {
|
||||
Result TimeZoneService::SetDeviceLocationNameWithTimeZoneRule(
|
||||
Service::PSC::Time::LocationName& location_name, InBuffer<BufferAttr_HipcAutoSelect> binary) {
|
||||
LOG_DEBUG(Service_Time, "called. location_name={}", location_name);
|
||||
|
||||
R_UNLESS(m_can_write_timezone_device_location, Service::PSC::Time::ResultPermissionDenied);
|
||||
R_RETURN(Service::PSC::Time::ResultNotImplemented);
|
||||
}
|
||||
|
||||
Result TimeZoneService::ParseTimeZoneBinary(OutRule out_rule,
|
||||
InBuffer<BufferAttr_HipcAutoSelect> binary) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
R_RETURN(Service::PSC::Time::ResultNotImplemented);
|
||||
}
|
||||
|
||||
Result TimeZoneService::GetDeviceLocationNameOperationEventReadableHandle(
|
||||
Kernel::KEvent** out_event) {
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event) {
|
||||
LOG_DEBUG(Service_Time, "called.");
|
||||
|
||||
if (!operation_event_initialized) {
|
||||
operation_event_initialized = false;
|
||||
|
||||
|
@ -342,34 +168,59 @@ Result TimeZoneService::GetDeviceLocationNameOperationEventReadableHandle(
|
|||
g_list_nodes.push_back(m_operation_event);
|
||||
}
|
||||
|
||||
*out_event = m_operation_event.m_event;
|
||||
*out_event = &m_operation_event.m_event->GetReadableEvent();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result TimeZoneService::ToCalendarTime(
|
||||
Service::PSC::Time::CalendarTime& out_calendar_time,
|
||||
Service::PSC::Time::CalendarAdditionalInfo& out_additional_info, s64 time, Tz::Rule& rule) {
|
||||
Out<Service::PSC::Time::CalendarTime> out_calendar_time,
|
||||
Out<Service::PSC::Time::CalendarAdditionalInfo> out_additional_info, s64 time, InRule rule) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time, "called. time={} out_calendar_time={} out_additional_info={}", time,
|
||||
*out_calendar_time, *out_additional_info);
|
||||
});
|
||||
|
||||
R_RETURN(m_wrapped_service->ToCalendarTime(out_calendar_time, out_additional_info, time, rule));
|
||||
}
|
||||
|
||||
Result TimeZoneService::ToCalendarTimeWithMyRule(
|
||||
Service::PSC::Time::CalendarTime& out_calendar_time,
|
||||
Service::PSC::Time::CalendarAdditionalInfo& out_additional_info, s64 time) {
|
||||
Out<Service::PSC::Time::CalendarTime> out_calendar_time,
|
||||
Out<Service::PSC::Time::CalendarAdditionalInfo> out_additional_info, s64 time) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time, "called. time={} out_calendar_time={} out_additional_info={}", time,
|
||||
*out_calendar_time, *out_additional_info);
|
||||
});
|
||||
|
||||
R_RETURN(
|
||||
m_wrapped_service->ToCalendarTimeWithMyRule(out_calendar_time, out_additional_info, time));
|
||||
}
|
||||
|
||||
Result TimeZoneService::ToPosixTime(u32& out_count, std::span<s64, 2> out_times,
|
||||
u32 out_times_count,
|
||||
Service::PSC::Time::CalendarTime& calendar_time,
|
||||
Tz::Rule& rule) {
|
||||
Result TimeZoneService::ToPosixTime(Out<u32> out_count,
|
||||
OutArray<s64, BufferAttr_HipcPointer> out_times,
|
||||
Out<u32> out_times_count,
|
||||
Service::PSC::Time::CalendarTime& calendar_time, InRule rule) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time,
|
||||
"called. calendar_time={} out_count={} out_times[0]={} out_times[1]={} "
|
||||
"out_times_count={}",
|
||||
calendar_time, *out_count, out_times[0], out_times[1], *out_times_count);
|
||||
});
|
||||
|
||||
R_RETURN(
|
||||
m_wrapped_service->ToPosixTime(out_count, out_times, out_times_count, calendar_time, rule));
|
||||
}
|
||||
|
||||
Result TimeZoneService::ToPosixTimeWithMyRule(u32& out_count, std::span<s64, 2> out_times,
|
||||
u32 out_times_count,
|
||||
Result TimeZoneService::ToPosixTimeWithMyRule(Out<u32> out_count,
|
||||
OutArray<s64, BufferAttr_HipcPointer> out_times,
|
||||
Out<u32> out_times_count,
|
||||
Service::PSC::Time::CalendarTime& calendar_time) {
|
||||
SCOPE_EXIT({
|
||||
LOG_DEBUG(Service_Time,
|
||||
"called. calendar_time={} out_count={} out_times[0]={} out_times[1]={} "
|
||||
"out_times_count={}",
|
||||
calendar_time, *out_count, out_times[0], out_times[1], *out_times_count);
|
||||
});
|
||||
|
||||
R_RETURN(m_wrapped_service->ToPosixTimeWithMyRule(out_count, out_times, out_times_count,
|
||||
calendar_time));
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/psc/time/common.h"
|
||||
#include "core/hle/service/server_manager.h"
|
||||
|
@ -33,6 +34,9 @@ namespace Service::Glue::Time {
|
|||
class FileTimestampWorker;
|
||||
|
||||
class TimeZoneService final : public ServiceFramework<TimeZoneService> {
|
||||
using InRule = InLargeData<Tz::Rule, BufferAttr_HipcMapAlias>;
|
||||
using OutRule = OutLargeData<Tz::Rule, BufferAttr_HipcMapAlias>;
|
||||
|
||||
public:
|
||||
explicit TimeZoneService(
|
||||
Core::System& system, FileTimestampWorker& file_timestamp_worker,
|
||||
|
@ -41,46 +45,37 @@ public:
|
|||
|
||||
~TimeZoneService() override;
|
||||
|
||||
Result GetDeviceLocationName(Service::PSC::Time::LocationName& out_location_name);
|
||||
Result SetDeviceLocation(Service::PSC::Time::LocationName& location_name);
|
||||
Result GetTotalLocationNameCount(u32& out_count);
|
||||
Result LoadLocationNameList(u32& out_count,
|
||||
std::vector<Service::PSC::Time::LocationName>& out_names,
|
||||
size_t max_names, u32 index);
|
||||
Result LoadTimeZoneRule(Tz::Rule& out_rule, Service::PSC::Time::LocationName& name);
|
||||
Result GetTimeZoneRuleVersion(Service::PSC::Time::RuleVersion& out_rule_version);
|
||||
Result GetDeviceLocationName(Out<Service::PSC::Time::LocationName> out_location_name);
|
||||
Result SetDeviceLocationName(Service::PSC::Time::LocationName& location_name);
|
||||
Result GetTotalLocationNameCount(Out<u32> out_count);
|
||||
Result LoadLocationNameList(
|
||||
Out<u32> out_count,
|
||||
OutArray<Service::PSC::Time::LocationName, BufferAttr_HipcMapAlias> out_names, u32 index);
|
||||
Result LoadTimeZoneRule(OutRule out_rule, Service::PSC::Time::LocationName& location_name);
|
||||
Result GetTimeZoneRuleVersion(Out<Service::PSC::Time::RuleVersion> out_rule_version);
|
||||
Result GetDeviceLocationNameAndUpdatedTime(
|
||||
Service::PSC::Time::SteadyClockTimePoint& out_time_point,
|
||||
Service::PSC::Time::LocationName& location_name);
|
||||
Result SetDeviceLocationNameWithTimeZoneRule();
|
||||
Result GetDeviceLocationNameOperationEventReadableHandle(Kernel::KEvent** out_event);
|
||||
Result ToCalendarTime(Service::PSC::Time::CalendarTime& out_calendar_time,
|
||||
Service::PSC::Time::CalendarAdditionalInfo& out_additional_info, s64 time,
|
||||
Tz::Rule& rule);
|
||||
Result ToCalendarTimeWithMyRule(Service::PSC::Time::CalendarTime& out_calendar_time,
|
||||
Service::PSC::Time::CalendarAdditionalInfo& out_additional_info,
|
||||
s64 time);
|
||||
Result ToPosixTime(u32& out_count, std::span<s64, 2> out_times, u32 out_times_count,
|
||||
Service::PSC::Time::CalendarTime& calendar_time, Tz::Rule& rule);
|
||||
Result ToPosixTimeWithMyRule(u32& out_count, std::span<s64, 2> out_times, u32 out_times_count,
|
||||
Out<Service::PSC::Time::LocationName> location_name,
|
||||
Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point);
|
||||
Result SetDeviceLocationNameWithTimeZoneRule(Service::PSC::Time::LocationName& location_name,
|
||||
InBuffer<BufferAttr_HipcAutoSelect> binary);
|
||||
Result ParseTimeZoneBinary(OutRule out_rule, InBuffer<BufferAttr_HipcAutoSelect> binary);
|
||||
Result GetDeviceLocationNameOperationEventReadableHandle(
|
||||
OutCopyHandle<Kernel::KReadableEvent> out_event);
|
||||
Result ToCalendarTime(Out<Service::PSC::Time::CalendarTime> out_calendar_time,
|
||||
Out<Service::PSC::Time::CalendarAdditionalInfo> out_additional_info,
|
||||
s64 time, InRule rule);
|
||||
Result ToCalendarTimeWithMyRule(
|
||||
Out<Service::PSC::Time::CalendarTime> out_calendar_time,
|
||||
Out<Service::PSC::Time::CalendarAdditionalInfo> out_additional_info, s64 time);
|
||||
Result ToPosixTime(Out<u32> out_count, OutArray<s64, BufferAttr_HipcPointer> out_times,
|
||||
Out<u32> out_times_count, Service::PSC::Time::CalendarTime& calendar_time,
|
||||
InRule rule);
|
||||
Result ToPosixTimeWithMyRule(Out<u32> out_count,
|
||||
OutArray<s64, BufferAttr_HipcPointer> out_times,
|
||||
Out<u32> out_times_count,
|
||||
Service::PSC::Time::CalendarTime& calendar_time);
|
||||
|
||||
private:
|
||||
void Handle_GetDeviceLocationName(HLERequestContext& ctx);
|
||||
void Handle_SetDeviceLocationName(HLERequestContext& ctx);
|
||||
void Handle_GetTotalLocationNameCount(HLERequestContext& ctx);
|
||||
void Handle_LoadLocationNameList(HLERequestContext& ctx);
|
||||
void Handle_LoadTimeZoneRule(HLERequestContext& ctx);
|
||||
void Handle_GetTimeZoneRuleVersion(HLERequestContext& ctx);
|
||||
void Handle_GetDeviceLocationNameAndUpdatedTime(HLERequestContext& ctx);
|
||||
void Handle_SetDeviceLocationNameWithTimeZoneRule(HLERequestContext& ctx);
|
||||
void Handle_ParseTimeZoneBinary(HLERequestContext& ctx);
|
||||
void Handle_GetDeviceLocationNameOperationEventReadableHandle(HLERequestContext& ctx);
|
||||
void Handle_ToCalendarTime(HLERequestContext& ctx);
|
||||
void Handle_ToCalendarTimeWithMyRule(HLERequestContext& ctx);
|
||||
void Handle_ToPosixTime(HLERequestContext& ctx);
|
||||
void Handle_ToPosixTimeWithMyRule(HLERequestContext& ctx);
|
||||
|
||||
Core::System& m_system;
|
||||
std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ void GetTimeZoneZonePath(std::string& out_path, Service::PSC::Time::LocationName
|
|||
return;
|
||||
}
|
||||
// out_path = fmt::format("{}:/zoneinfo/{}", "TimeZoneBinary", name);
|
||||
out_path = fmt::format("/zoneinfo/{}", name.name.data());
|
||||
out_path = fmt::format("/zoneinfo/{}", name.data());
|
||||
}
|
||||
|
||||
bool IsTimeZoneBinaryValid(Service::PSC::Time::LocationName& name) {
|
||||
|
@ -169,7 +169,7 @@ Result GetTimeZoneRule(std::span<const u8>& out_rule, size_t& out_rule_size,
|
|||
}
|
||||
|
||||
Result GetTimeZoneLocationList(u32& out_count,
|
||||
std::vector<Service::PSC::Time::LocationName>& out_names,
|
||||
std::span<Service::PSC::Time::LocationName> out_names,
|
||||
size_t max_names, u32 index) {
|
||||
std::string path{};
|
||||
GetTimeZoneBinaryListPath(path);
|
||||
|
@ -193,7 +193,7 @@ Result GetTimeZoneLocationList(u32& out_count,
|
|||
|
||||
if (chr == '\n') {
|
||||
if (name_count >= index) {
|
||||
out_names.push_back(current_name);
|
||||
out_names[out_count] = current_name;
|
||||
out_count++;
|
||||
if (out_count >= max_names) {
|
||||
break;
|
||||
|
@ -209,10 +209,9 @@ Result GetTimeZoneLocationList(u32& out_count,
|
|||
break;
|
||||
}
|
||||
|
||||
R_UNLESS(current_name_len <= current_name.name.size() - 2,
|
||||
Service::PSC::Time::ResultFailed);
|
||||
R_UNLESS(current_name_len <= current_name.size() - 2, Service::PSC::Time::ResultFailed);
|
||||
|
||||
current_name.name[current_name_len++] = chr;
|
||||
current_name[current_name_len++] = chr;
|
||||
}
|
||||
|
||||
R_SUCCEED();
|
||||
|
|
|
@ -26,7 +26,7 @@ Result GetTimeZoneVersion(Service::PSC::Time::RuleVersion& out_rule_version);
|
|||
Result GetTimeZoneRule(std::span<const u8>& out_rule, size_t& out_rule_size,
|
||||
Service::PSC::Time::LocationName& name);
|
||||
Result GetTimeZoneLocationList(u32& out_count,
|
||||
std::vector<Service::PSC::Time::LocationName>& out_names,
|
||||
std::span<Service::PSC::Time::LocationName> out_names,
|
||||
size_t max_names, u32 index);
|
||||
|
||||
} // namespace Service::Glue::Time
|
||||
|
|
|
@ -38,11 +38,12 @@ T GetSettingsItemValue(std::shared_ptr<Service::Set::ISystemSettingsServer>& set
|
|||
|
||||
TimeWorker::TimeWorker(Core::System& system, StandardSteadyClockResource& steady_clock_resource,
|
||||
FileTimestampWorker& file_timestamp_worker)
|
||||
: m_system{system}, m_ctx{m_system, "Glue:58"}, m_event{m_ctx.CreateEvent("Glue:58:Event")},
|
||||
: m_system{system}, m_ctx{m_system, "Glue:TimeWorker"}, m_event{m_ctx.CreateEvent(
|
||||
"Glue:TimeWorker:Event")},
|
||||
m_steady_clock_resource{steady_clock_resource},
|
||||
m_file_timestamp_worker{file_timestamp_worker}, m_timer_steady_clock{m_ctx.CreateEvent(
|
||||
"Glue:58:SteadyClockTimerEvent")},
|
||||
m_timer_file_system{m_ctx.CreateEvent("Glue:58:FileTimeTimerEvent")},
|
||||
"Glue:TimeWorker:SteadyClockTimerEvent")},
|
||||
m_timer_file_system{m_ctx.CreateEvent("Glue:TimeWorker:FileTimeTimerEvent")},
|
||||
m_alarm_worker{m_system, m_steady_clock_resource}, m_pm_state_change_handler{m_alarm_worker} {
|
||||
g_ig_report_network_clock_context_set = false;
|
||||
g_report_network_clock_context = {};
|
||||
|
@ -113,17 +114,17 @@ void TimeWorker::Initialize(std::shared_ptr<Service::PSC::Time::StaticService> t
|
|||
std::chrono::nanoseconds(fs_notify_time_ns),
|
||||
m_timer_file_system_timing_event);
|
||||
|
||||
auto res = m_time_sm->GetStandardLocalSystemClock(m_local_clock);
|
||||
auto res = m_time_sm->GetStandardLocalSystemClock(&m_local_clock);
|
||||
ASSERT(res == ResultSuccess);
|
||||
res = m_time_m->GetStandardLocalClockOperationEvent(&m_local_clock_event);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = m_time_sm->GetStandardNetworkSystemClock(m_network_clock);
|
||||
res = m_time_sm->GetStandardNetworkSystemClock(&m_network_clock);
|
||||
ASSERT(res == ResultSuccess);
|
||||
res = m_time_m->GetStandardNetworkClockOperationEventForServiceManager(&m_network_clock_event);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
res = m_time_sm->GetEphemeralNetworkSystemClock(m_ephemeral_clock);
|
||||
res = m_time_sm->GetEphemeralNetworkSystemClock(&m_ephemeral_clock);
|
||||
ASSERT(res == ResultSuccess);
|
||||
res =
|
||||
m_time_m->GetEphemeralNetworkClockOperationEventForServiceManager(&m_ephemeral_clock_event);
|
||||
|
@ -183,22 +184,19 @@ void TimeWorker::ThreadFunc(std::stop_token stop_token) {
|
|||
AddWaiter(&m_event->GetReadableEvent(), EventType::Exit);
|
||||
// TODO
|
||||
// AddWaiter(gIPmModuleService::GetEvent(), 1);
|
||||
AddWaiter(&m_alarm_worker.GetEvent().GetReadableEvent(), EventType::PowerStateChange);
|
||||
AddWaiter(&m_alarm_worker.GetEvent(), EventType::PowerStateChange);
|
||||
} else {
|
||||
AddWaiter(&m_event->GetReadableEvent(), EventType::Exit);
|
||||
// TODO
|
||||
// AddWaiter(gIPmModuleService::GetEvent(), 1);
|
||||
AddWaiter(&m_alarm_worker.GetEvent().GetReadableEvent(), EventType::PowerStateChange);
|
||||
AddWaiter(&m_alarm_worker.GetEvent(), EventType::PowerStateChange);
|
||||
AddWaiter(&m_alarm_worker.GetTimerEvent().GetReadableEvent(), EventType::SignalAlarms);
|
||||
AddWaiter(&m_local_clock_event->GetReadableEvent(), EventType::UpdateLocalSystemClock);
|
||||
AddWaiter(&m_network_clock_event->GetReadableEvent(),
|
||||
EventType::UpdateNetworkSystemClock);
|
||||
AddWaiter(&m_ephemeral_clock_event->GetReadableEvent(),
|
||||
EventType::UpdateEphemeralSystemClock);
|
||||
AddWaiter(m_local_clock_event, EventType::UpdateLocalSystemClock);
|
||||
AddWaiter(m_network_clock_event, EventType::UpdateNetworkSystemClock);
|
||||
AddWaiter(m_ephemeral_clock_event, EventType::UpdateEphemeralSystemClock);
|
||||
AddWaiter(&m_timer_steady_clock->GetReadableEvent(), EventType::UpdateSteadyClock);
|
||||
AddWaiter(&m_timer_file_system->GetReadableEvent(), EventType::UpdateFileTimestamp);
|
||||
AddWaiter(&m_standard_user_auto_correct_clock_event->GetReadableEvent(),
|
||||
EventType::AutoCorrect);
|
||||
AddWaiter(m_standard_user_auto_correct_clock_event, EventType::AutoCorrect);
|
||||
}
|
||||
|
||||
s32 out_index{-1};
|
||||
|
@ -237,7 +235,7 @@ void TimeWorker::ThreadFunc(std::stop_token stop_token) {
|
|||
m_local_clock_event->Clear();
|
||||
|
||||
Service::PSC::Time::SystemClockContext context{};
|
||||
auto res = m_local_clock->GetSystemClockContext(context);
|
||||
auto res = m_local_clock->GetSystemClockContext(&context);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
m_set_sys->SetUserSystemClockContext(context);
|
||||
|
@ -248,12 +246,12 @@ void TimeWorker::ThreadFunc(std::stop_token stop_token) {
|
|||
case EventType::UpdateNetworkSystemClock: {
|
||||
m_network_clock_event->Clear();
|
||||
Service::PSC::Time::SystemClockContext context{};
|
||||
auto res = m_network_clock->GetSystemClockContext(context);
|
||||
auto res = m_network_clock->GetSystemClockContext(&context);
|
||||
ASSERT(res == ResultSuccess);
|
||||
m_set_sys->SetNetworkSystemClockContext(context);
|
||||
|
||||
s64 time{};
|
||||
if (m_network_clock->GetCurrentTime(time) != ResultSuccess) {
|
||||
if (m_network_clock->GetCurrentTime(&time) != ResultSuccess) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -275,13 +273,13 @@ void TimeWorker::ThreadFunc(std::stop_token stop_token) {
|
|||
m_ephemeral_clock_event->Clear();
|
||||
|
||||
Service::PSC::Time::SystemClockContext context{};
|
||||
auto res = m_ephemeral_clock->GetSystemClockContext(context);
|
||||
auto res = m_ephemeral_clock->GetSystemClockContext(&context);
|
||||
if (res != ResultSuccess) {
|
||||
break;
|
||||
}
|
||||
|
||||
s64 time{};
|
||||
res = m_ephemeral_clock->GetCurrentTime(time);
|
||||
res = m_ephemeral_clock->GetCurrentTime(&time);
|
||||
if (res != ResultSuccess) {
|
||||
break;
|
||||
}
|
||||
|
@ -317,11 +315,11 @@ void TimeWorker::ThreadFunc(std::stop_token stop_token) {
|
|||
|
||||
bool automatic_correction{};
|
||||
auto res = m_time_sm->IsStandardUserSystemClockAutomaticCorrectionEnabled(
|
||||
automatic_correction);
|
||||
&automatic_correction);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
Service::PSC::Time::SteadyClockTimePoint time_point{};
|
||||
res = m_time_sm->GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(time_point);
|
||||
res = m_time_sm->GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(&time_point);
|
||||
ASSERT(res == ResultSuccess);
|
||||
|
||||
m_set_sys->SetUserSystemClockAutomaticCorrectionEnabled(automatic_correction);
|
||||
|
|
|
@ -49,10 +49,10 @@ private:
|
|||
std::shared_ptr<Service::PSC::Time::SystemClock> m_ephemeral_clock;
|
||||
StandardSteadyClockResource& m_steady_clock_resource;
|
||||
FileTimestampWorker& m_file_timestamp_worker;
|
||||
Kernel::KEvent* m_local_clock_event{};
|
||||
Kernel::KEvent* m_network_clock_event{};
|
||||
Kernel::KEvent* m_ephemeral_clock_event{};
|
||||
Kernel::KEvent* m_standard_user_auto_correct_clock_event{};
|
||||
Kernel::KReadableEvent* m_local_clock_event{};
|
||||
Kernel::KReadableEvent* m_network_clock_event{};
|
||||
Kernel::KReadableEvent* m_ephemeral_clock_event{};
|
||||
Kernel::KReadableEvent* m_standard_user_auto_correct_clock_event{};
|
||||
Kernel::KEvent* m_timer_steady_clock{};
|
||||
std::shared_ptr<Core::Timing::EventType> m_timer_steady_clock_timing_event;
|
||||
Kernel::KEvent* m_timer_file_system{};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue