Merge pull request #12499 from Kelebek1/time

Rework time services
This commit is contained in:
liamwhite
2024-01-25 14:19:01 -05:00
committed by GitHub
144 changed files with 8734 additions and 3972 deletions

View File

@ -0,0 +1,72 @@
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <array>
#include "common/bit_field.h"
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/uuid.h"
#include "core/hle/service/psc/time/common.h"
namespace Service::Set {
/// This is nn::settings::system::InitialLaunchFlag
struct InitialLaunchFlag {
union {
u32 raw{};
BitField<0, 1, u32> InitialLaunchCompletionFlag;
BitField<8, 1, u32> InitialLaunchUserAdditionFlag;
BitField<16, 1, u32> InitialLaunchTimestampFlag;
};
};
static_assert(sizeof(InitialLaunchFlag) == 4, "InitialLaunchFlag is an invalid size");
/// This is nn::settings::system::InitialLaunchSettings
struct InitialLaunchSettings {
InitialLaunchFlag flags;
INSERT_PADDING_BYTES(0x4);
Service::PSC::Time::SteadyClockTimePoint timestamp;
};
static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size");
#pragma pack(push, 4)
struct InitialLaunchSettingsPacked {
InitialLaunchFlag flags;
Service::PSC::Time::SteadyClockTimePoint timestamp;
};
#pragma pack(pop)
static_assert(sizeof(InitialLaunchSettingsPacked) == 0x1C,
"InitialLaunchSettingsPacked is incorrect size");
struct PrivateSettings {
std::array<u8, 0x10> reserved_00;
// nn::settings::system::InitialLaunchSettings
InitialLaunchSettings initial_launch_settings;
std::array<u8, 0x20> reserved_30;
Common::UUID external_clock_source_id;
s64 shutdown_rtc_value;
s64 external_steady_clock_internal_offset;
std::array<u8, 0x60> reserved_70;
// nn::settings::system::PlatformRegion
std::array<u8, 0x4> platform_region;
std::array<u8, 0x4> reserved_D4;
};
static_assert(offsetof(PrivateSettings, initial_launch_settings) == 0x10);
static_assert(offsetof(PrivateSettings, external_clock_source_id) == 0x50);
static_assert(offsetof(PrivateSettings, reserved_70) == 0x70);
static_assert(offsetof(PrivateSettings, platform_region) == 0xD0);
static_assert(sizeof(PrivateSettings) == 0xD8, "PrivateSettings has the wrong size!");
PrivateSettings DefaultPrivateSettings();
} // namespace Service::Set

View File

@ -8,7 +8,6 @@
#include "common/common_types.h"
#include "common/uuid.h"
#include "core/hle/service/set/settings_types.h"
#include "core/hle/service/time/clock_types.h"
namespace Service::Set {

View File

@ -45,7 +45,7 @@ SystemSettings DefaultSystemSettings() {
};
settings.device_time_zone_location_name = {"UTC"};
settings.user_system_clock_automatic_correction_enabled = false;
settings.user_system_clock_automatic_correction_enabled = true;
settings.primary_album_storage = PrimaryAlbumStorage::SdCard;
settings.battery_percentage_flag = true;

View File

@ -12,7 +12,6 @@
#include "common/vector_math.h"
#include "core/hle/service/set/setting_formats/private_settings.h"
#include "core/hle/service/set/settings_types.h"
#include "core/hle/service/time/clock_types.h"
namespace Service::Set {
@ -197,12 +196,14 @@ struct SystemSettings {
std::array<u8, 0x2C> backlight_settings_mixed_up;
INSERT_PADDING_BYTES(0x64); // Reserved
Service::Time::Clock::SystemClockContext user_system_clock_context;
Service::Time::Clock::SystemClockContext network_system_clock_context;
// nn::time::SystemClockContext
Service::PSC::Time::SystemClockContext user_system_clock_context;
Service::PSC::Time::SystemClockContext network_system_clock_context;
bool user_system_clock_automatic_correction_enabled;
INSERT_PADDING_BYTES(0x3);
INSERT_PADDING_BYTES(0x4); // Reserved
Service::Time::Clock::SteadyClockTimePoint
// nn::time::SteadyClockTimePoint
Service::PSC::Time::SteadyClockTimePoint
user_system_clock_automatic_correction_updated_time_point;
INSERT_PADDING_BYTES(0x10); // Reserved
@ -280,9 +281,12 @@ struct SystemSettings {
bool requires_run_repair_time_reviser;
INSERT_PADDING_BYTES(0x6B); // Reserved
Service::Time::TimeZone::LocationName device_time_zone_location_name;
// nn::time::LocationName
Service::PSC::Time::LocationName device_time_zone_location_name;
INSERT_PADDING_BYTES(0x4); // Reserved
Service::Time::Clock::SteadyClockTimePoint device_time_zone_location_updated_time;
// nn::time::SteadyClockTimePoint
Service::PSC::Time::SteadyClockTimePoint device_time_zone_location_updated_time;
INSERT_PADDING_BYTES(0xC0); // Reserved
// nn::settings::system::PrimaryAlbumStorage

View File

@ -9,7 +9,7 @@
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/uuid.h"
#include "core/hle/service/time/clock_types.h"
#include "core/hle/service/psc/time/common.h"
namespace Service::Set {
@ -365,7 +365,7 @@ struct EulaVersion {
EulaVersionClockType clock_type;
INSERT_PADDING_BYTES(0x4);
s64 posix_time;
Time::Clock::SteadyClockTimePoint timestamp;
Service::PSC::Time::SteadyClockTimePoint timestamp;
};
static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size");
@ -398,14 +398,14 @@ static_assert(sizeof(HomeMenuScheme) == 0x14, "HomeMenuScheme is incorrect size"
struct InitialLaunchSettings {
InitialLaunchFlag flags;
INSERT_PADDING_BYTES(0x4);
Service::Time::Clock::SteadyClockTimePoint timestamp;
Service::PSC::Time::SteadyClockTimePoint timestamp;
};
static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size");
#pragma pack(push, 4)
struct InitialLaunchSettingsPacked {
InitialLaunchFlag flags;
Service::Time::Clock::SteadyClockTimePoint timestamp;
Service::PSC::Time::SteadyClockTimePoint timestamp;
};
#pragma pack(pop)
static_assert(sizeof(InitialLaunchSettingsPacked) == 0x1C,

View File

@ -489,11 +489,10 @@ void ISystemSettingsServer::SetExternalSteadyClockSourceId(HLERequestContext& ct
void ISystemSettingsServer::GetUserSystemClockContext(HLERequestContext& ctx) {
LOG_INFO(Service_SET, "called");
Service::Time::Clock::SystemClockContext context{};
Service::PSC::Time::SystemClockContext context{};
auto res = GetUserSystemClockContext(context);
IPC::ResponseBuilder rb{ctx,
2 + sizeof(Service::Time::Clock::SystemClockContext) / sizeof(u32)};
IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::SystemClockContext) / sizeof(u32)};
rb.Push(res);
rb.PushRaw(context);
}
@ -502,7 +501,7 @@ void ISystemSettingsServer::SetUserSystemClockContext(HLERequestContext& ctx) {
LOG_INFO(Service_SET, "called");
IPC::RequestParser rp{ctx};
auto context{rp.PopRaw<Service::Time::Clock::SystemClockContext>()};
auto context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()};
auto res = SetUserSystemClockContext(context);
@ -809,19 +808,19 @@ void ISystemSettingsServer::GetQuestFlag(HLERequestContext& ctx) {
void ISystemSettingsServer::GetDeviceTimeZoneLocationName(HLERequestContext& ctx) {
LOG_INFO(Service_SET, "called");
Service::Time::TimeZone::LocationName name{};
Service::PSC::Time::LocationName name{};
auto res = GetDeviceTimeZoneLocationName(name);
IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::Time::TimeZone::LocationName) / sizeof(u32)};
IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::LocationName) / sizeof(u32)};
rb.Push(res);
rb.PushRaw<Service::Time::TimeZone::LocationName>(name);
rb.PushRaw<Service::PSC::Time::LocationName>(name);
}
void ISystemSettingsServer::SetDeviceTimeZoneLocationName(HLERequestContext& ctx) {
LOG_INFO(Service_SET, "called");
IPC::RequestParser rp{ctx};
auto name{rp.PopRaw<Service::Time::TimeZone::LocationName>()};
auto name{rp.PopRaw<Service::PSC::Time::LocationName>()};
auto res = SetDeviceTimeZoneLocationName(name);
@ -843,11 +842,10 @@ void ISystemSettingsServer::SetRegionCode(HLERequestContext& ctx) {
void ISystemSettingsServer::GetNetworkSystemClockContext(HLERequestContext& ctx) {
LOG_INFO(Service_SET, "called");
Service::Time::Clock::SystemClockContext context{};
Service::PSC::Time::SystemClockContext context{};
auto res = GetNetworkSystemClockContext(context);
IPC::ResponseBuilder rb{ctx,
2 + sizeof(Service::Time::Clock::SystemClockContext) / sizeof(u32)};
IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::SystemClockContext) / sizeof(u32)};
rb.Push(res);
rb.PushRaw(context);
}
@ -856,7 +854,7 @@ void ISystemSettingsServer::SetNetworkSystemClockContext(HLERequestContext& ctx)
LOG_INFO(Service_SET, "called");
IPC::RequestParser rp{ctx};
auto context{rp.PopRaw<Service::Time::Clock::SystemClockContext>()};
auto context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()};
auto res = SetNetworkSystemClockContext(context);
@ -1141,19 +1139,19 @@ void ISystemSettingsServer::GetKeyboardLayout(HLERequestContext& ctx) {
void ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) {
LOG_INFO(Service_SET, "called");
Service::Time::Clock::SteadyClockTimePoint time_point{};
Service::PSC::Time::SteadyClockTimePoint time_point{};
auto res = GetDeviceTimeZoneLocationUpdatedTime(time_point);
IPC::ResponseBuilder rb{ctx, 4};
rb.Push(res);
rb.PushRaw<Service::Time::Clock::SteadyClockTimePoint>(time_point);
rb.PushRaw<Service::PSC::Time::SteadyClockTimePoint>(time_point);
}
void ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) {
LOG_INFO(Service_SET, "called");
IPC::RequestParser rp{ctx};
auto time_point{rp.PopRaw<Service::Time::Clock::SteadyClockTimePoint>()};
auto time_point{rp.PopRaw<Service::PSC::Time::SteadyClockTimePoint>()};
auto res = SetDeviceTimeZoneLocationUpdatedTime(time_point);
@ -1165,12 +1163,12 @@ void ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime(
HLERequestContext& ctx) {
LOG_INFO(Service_SET, "called");
Service::Time::Clock::SteadyClockTimePoint time_point{};
Service::PSC::Time::SteadyClockTimePoint time_point{};
auto res = GetUserSystemClockAutomaticCorrectionUpdatedTime(time_point);
IPC::ResponseBuilder rb{ctx, 4};
rb.Push(res);
rb.PushRaw<Service::Time::Clock::SteadyClockTimePoint>(time_point);
rb.PushRaw<Service::PSC::Time::SteadyClockTimePoint>(time_point);
}
void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime(
@ -1178,7 +1176,7 @@ void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime(
LOG_INFO(Service_SET, "called");
IPC::RequestParser rp{ctx};
auto time_point{rp.PopRaw<Service::Time::Clock::SteadyClockTimePoint>()};
auto time_point{rp.PopRaw<Service::PSC::Time::SteadyClockTimePoint>()};
auto res = SetUserSystemClockAutomaticCorrectionUpdatedTime(time_point);
@ -1257,25 +1255,25 @@ void ISystemSettingsServer::StoreSettings() {
auto system_dir =
Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000050";
if (!StoreSettingsFile(system_dir, m_system_settings)) {
LOG_ERROR(HW_GPU, "Failed to store System settings");
LOG_ERROR(Service_SET, "Failed to store System settings");
}
auto private_dir =
Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000052";
if (!StoreSettingsFile(private_dir, m_private_settings)) {
LOG_ERROR(HW_GPU, "Failed to store Private settings");
LOG_ERROR(Service_SET, "Failed to store Private settings");
}
auto device_dir =
Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000053";
if (!StoreSettingsFile(device_dir, m_device_settings)) {
LOG_ERROR(HW_GPU, "Failed to store Device settings");
LOG_ERROR(Service_SET, "Failed to store Device settings");
}
auto appln_dir =
Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000054";
if (!StoreSettingsFile(appln_dir, m_appln_settings)) {
LOG_ERROR(HW_GPU, "Failed to store ApplLn settings");
LOG_ERROR(Service_SET, "Failed to store ApplLn settings");
}
}
@ -1318,39 +1316,39 @@ Result ISystemSettingsServer::SetExternalSteadyClockSourceId(Common::UUID id) {
}
Result ISystemSettingsServer::GetUserSystemClockContext(
Service::Time::Clock::SystemClockContext& out_context) {
Service::PSC::Time::SystemClockContext& out_context) {
out_context = m_system_settings.user_system_clock_context;
R_SUCCEED();
}
Result ISystemSettingsServer::SetUserSystemClockContext(
Service::Time::Clock::SystemClockContext& context) {
Service::PSC::Time::SystemClockContext& context) {
m_system_settings.user_system_clock_context = context;
SetSaveNeeded();
R_SUCCEED();
}
Result ISystemSettingsServer::GetDeviceTimeZoneLocationName(
Service::Time::TimeZone::LocationName& out_name) {
Service::PSC::Time::LocationName& out_name) {
out_name = m_system_settings.device_time_zone_location_name;
R_SUCCEED();
}
Result ISystemSettingsServer::SetDeviceTimeZoneLocationName(
Service::Time::TimeZone::LocationName& name) {
Service::PSC::Time::LocationName& name) {
m_system_settings.device_time_zone_location_name = name;
SetSaveNeeded();
R_SUCCEED();
}
Result ISystemSettingsServer::GetNetworkSystemClockContext(
Service::Time::Clock::SystemClockContext& out_context) {
Service::PSC::Time::SystemClockContext& out_context) {
out_context = m_system_settings.network_system_clock_context;
R_SUCCEED();
}
Result ISystemSettingsServer::SetNetworkSystemClockContext(
Service::Time::Clock::SystemClockContext& context) {
Service::PSC::Time::SystemClockContext& context) {
m_system_settings.network_system_clock_context = context;
SetSaveNeeded();
R_SUCCEED();
@ -1379,26 +1377,26 @@ Result ISystemSettingsServer::GetExternalSteadyClockInternalOffset(s64& out_offs
}
Result ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime(
Service::Time::Clock::SteadyClockTimePoint& out_time_point) {
Service::PSC::Time::SteadyClockTimePoint& out_time_point) {
out_time_point = m_system_settings.device_time_zone_location_updated_time;
R_SUCCEED();
}
Result ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime(
Service::Time::Clock::SteadyClockTimePoint& time_point) {
Service::PSC::Time::SteadyClockTimePoint& time_point) {
m_system_settings.device_time_zone_location_updated_time = time_point;
SetSaveNeeded();
R_SUCCEED();
}
Result ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime(
Service::Time::Clock::SteadyClockTimePoint& out_time_point) {
Service::PSC::Time::SteadyClockTimePoint& out_time_point) {
out_time_point = m_system_settings.user_system_clock_automatic_correction_updated_time_point;
R_SUCCEED();
}
Result ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime(
Service::Time::Clock::SteadyClockTimePoint out_time_point) {
Service::PSC::Time::SteadyClockTimePoint out_time_point) {
m_system_settings.user_system_clock_automatic_correction_updated_time_point = out_time_point;
SetSaveNeeded();
R_SUCCEED();

View File

@ -11,14 +11,13 @@
#include "common/polyfill_thread.h"
#include "common/uuid.h"
#include "core/hle/result.h"
#include "core/hle/service/psc/time/common.h"
#include "core/hle/service/service.h"
#include "core/hle/service/set/setting_formats/appln_settings.h"
#include "core/hle/service/set/setting_formats/device_settings.h"
#include "core/hle/service/set/setting_formats/private_settings.h"
#include "core/hle/service/set/setting_formats/system_settings.h"
#include "core/hle/service/set/settings_types.h"
#include "core/hle/service/time/clock_types.h"
#include "core/hle/service/time/time_zone_types.h"
namespace Core {
class System;
@ -51,24 +50,24 @@ public:
Result GetExternalSteadyClockSourceId(Common::UUID& out_id);
Result SetExternalSteadyClockSourceId(Common::UUID id);
Result GetUserSystemClockContext(Service::Time::Clock::SystemClockContext& out_context);
Result SetUserSystemClockContext(Service::Time::Clock::SystemClockContext& context);
Result GetDeviceTimeZoneLocationName(Service::Time::TimeZone::LocationName& out_name);
Result SetDeviceTimeZoneLocationName(Service::Time::TimeZone::LocationName& name);
Result GetNetworkSystemClockContext(Service::Time::Clock::SystemClockContext& out_context);
Result SetNetworkSystemClockContext(Service::Time::Clock::SystemClockContext& context);
Result GetUserSystemClockContext(Service::PSC::Time::SystemClockContext& out_context);
Result SetUserSystemClockContext(Service::PSC::Time::SystemClockContext& context);
Result GetDeviceTimeZoneLocationName(Service::PSC::Time::LocationName& out_name);
Result SetDeviceTimeZoneLocationName(Service::PSC::Time::LocationName& name);
Result GetNetworkSystemClockContext(Service::PSC::Time::SystemClockContext& out_context);
Result SetNetworkSystemClockContext(Service::PSC::Time::SystemClockContext& context);
Result IsUserSystemClockAutomaticCorrectionEnabled(bool& out_enabled);
Result SetUserSystemClockAutomaticCorrectionEnabled(bool enabled);
Result SetExternalSteadyClockInternalOffset(s64 offset);
Result GetExternalSteadyClockInternalOffset(s64& out_offset);
Result GetDeviceTimeZoneLocationUpdatedTime(
Service::Time::Clock::SteadyClockTimePoint& out_time_point);
Service::PSC::Time::SteadyClockTimePoint& out_time_point);
Result SetDeviceTimeZoneLocationUpdatedTime(
Service::Time::Clock::SteadyClockTimePoint& time_point);
Service::PSC::Time::SteadyClockTimePoint& time_point);
Result GetUserSystemClockAutomaticCorrectionUpdatedTime(
Service::Time::Clock::SteadyClockTimePoint& out_time_point);
Service::PSC::Time::SteadyClockTimePoint& out_time_point);
Result SetUserSystemClockAutomaticCorrectionUpdatedTime(
Service::Time::Clock::SteadyClockTimePoint time_point);
Service::PSC::Time::SteadyClockTimePoint time_point);
private:
void SetLanguageCode(HLERequestContext& ctx);
@ -147,8 +146,8 @@ private:
PrivateSettings m_private_settings{};
DeviceSettings m_device_settings{};
ApplnSettings m_appln_settings{};
std::jthread m_save_thread;
std::mutex m_save_needed_mutex;
std::jthread m_save_thread;
bool m_save_needed{false};
};