mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-18 08:22:04 +00:00
fatal: use TimeSpan for timing
This commit is contained in:
parent
501280b6e5
commit
ee3e0fa537
3 changed files with 28 additions and 26 deletions
|
@ -57,9 +57,6 @@ namespace ams::fatal::srv {
|
||||||
}
|
}
|
||||||
|
|
||||||
FatalConfig::FatalConfig() {
|
FatalConfig::FatalConfig() {
|
||||||
/* Clear this. */
|
|
||||||
std::memset(this, 0, sizeof(*this));
|
|
||||||
|
|
||||||
/* Get information from set. */
|
/* Get information from set. */
|
||||||
settings::system::GetSerialNumber(std::addressof(this->serial_number));
|
settings::system::GetSerialNumber(std::addressof(this->serial_number));
|
||||||
settings::system::GetFirmwareVersion(std::addressof(this->firmware_version));
|
settings::system::GetFirmwareVersion(std::addressof(this->firmware_version));
|
||||||
|
@ -69,11 +66,16 @@ namespace ams::fatal::srv {
|
||||||
/* Read information from settings. */
|
/* Read information from settings. */
|
||||||
settings::fwdbg::GetSettingsItemValue(&this->transition_to_fatal, sizeof(this->transition_to_fatal), "fatal", "transition_to_fatal");
|
settings::fwdbg::GetSettingsItemValue(&this->transition_to_fatal, sizeof(this->transition_to_fatal), "fatal", "transition_to_fatal");
|
||||||
settings::fwdbg::GetSettingsItemValue(&this->show_extra_info, sizeof(this->show_extra_info), "fatal", "show_extra_info");
|
settings::fwdbg::GetSettingsItemValue(&this->show_extra_info, sizeof(this->show_extra_info), "fatal", "show_extra_info");
|
||||||
settings::fwdbg::GetSettingsItemValue(&this->quest_reboot_interval_second, sizeof(this->quest_reboot_interval_second), "fatal", "quest_reboot_interval_second");
|
|
||||||
|
u64 quest_interval_second;
|
||||||
|
settings::fwdbg::GetSettingsItemValue(&quest_interval_second, sizeof(quest_interval_second), "fatal", "quest_reboot_interval_second");
|
||||||
|
this->quest_reboot_interval = TimeSpan::FromSeconds(quest_interval_second);
|
||||||
|
|
||||||
/* Atmosphere extension for automatic reboot. */
|
/* Atmosphere extension for automatic reboot. */
|
||||||
if (settings::fwdbg::GetSettingsItemValue(&this->fatal_auto_reboot_interval, sizeof(this->fatal_auto_reboot_interval), "atmosphere", "fatal_auto_reboot_interval") == sizeof(this->fatal_auto_reboot_interval)) {
|
u64 auto_reboot_ms;
|
||||||
this->fatal_auto_reboot_enabled = this->fatal_auto_reboot_interval != 0;
|
if (settings::fwdbg::GetSettingsItemValue(&auto_reboot_ms, sizeof(auto_reboot_ms), "atmosphere", "fatal_auto_reboot_interval") == sizeof(auto_reboot_ms)) {
|
||||||
|
this->fatal_auto_reboot_interval = TimeSpan::FromMilliSeconds(auto_reboot_ms);
|
||||||
|
this->fatal_auto_reboot_enabled = auto_reboot_ms != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup messages. */
|
/* Setup messages. */
|
||||||
|
|
|
@ -20,18 +20,18 @@ namespace ams::fatal::srv {
|
||||||
|
|
||||||
class FatalConfig {
|
class FatalConfig {
|
||||||
private:
|
private:
|
||||||
settings::system::SerialNumber serial_number;
|
settings::system::SerialNumber serial_number{};
|
||||||
settings::system::FirmwareVersion firmware_version;
|
settings::system::FirmwareVersion firmware_version{};
|
||||||
u64 language_code;
|
u64 language_code{};
|
||||||
u64 quest_reboot_interval_second;
|
TimeSpan quest_reboot_interval{};
|
||||||
bool transition_to_fatal;
|
bool transition_to_fatal{};
|
||||||
bool show_extra_info;
|
bool show_extra_info{};
|
||||||
bool quest_flag;
|
bool quest_flag{};
|
||||||
const char *error_msg;
|
const char *error_msg{};
|
||||||
const char *error_desc;
|
const char *error_desc{};
|
||||||
const char *quest_desc;
|
const char *quest_desc{};
|
||||||
u64 fatal_auto_reboot_interval;
|
TimeSpan fatal_auto_reboot_interval{};
|
||||||
bool fatal_auto_reboot_enabled;
|
bool fatal_auto_reboot_enabled{};
|
||||||
public:
|
public:
|
||||||
FatalConfig();
|
FatalConfig();
|
||||||
|
|
||||||
|
@ -67,11 +67,11 @@ namespace ams::fatal::srv {
|
||||||
return this->fatal_auto_reboot_enabled;
|
return this->fatal_auto_reboot_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 GetQuestRebootTimeoutInterval() const {
|
TimeSpan GetQuestRebootTimeoutInterval() const {
|
||||||
return this->quest_reboot_interval_second * 1'000ul;
|
return this->quest_reboot_interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 GetFatalRebootTimeoutInterval() const {
|
TimeSpan GetFatalRebootTimeoutInterval() const {
|
||||||
return this->fatal_auto_reboot_interval;
|
return this->fatal_auto_reboot_interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,16 +54,16 @@ namespace ams::fatal::srv {
|
||||||
class RebootTimingObserver {
|
class RebootTimingObserver {
|
||||||
private:
|
private:
|
||||||
os::Tick start_tick;
|
os::Tick start_tick;
|
||||||
|
TimeSpan interval;
|
||||||
bool flag;
|
bool flag;
|
||||||
s64 interval;
|
|
||||||
public:
|
public:
|
||||||
RebootTimingObserver(bool flag, s64 interval) : start_tick(os::GetSystemTick()), flag(flag), interval(interval) {
|
RebootTimingObserver(bool flag, TimeSpan iv) : start_tick(os::GetSystemTick()), interval(iv), flag(flag) {
|
||||||
/* ... */
|
/* ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsRebootTiming() const {
|
bool IsRebootTiming() const {
|
||||||
auto current_tick = os::GetSystemTick();
|
auto current_tick = os::GetSystemTick();
|
||||||
return this->flag && (current_tick - this->start_tick).ToTimeSpan().GetMilliSeconds() >= this->interval;
|
return this->flag && (current_tick - this->start_tick).ToTimeSpan() >= this->interval;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ namespace ams::fatal::srv {
|
||||||
/* Task Implementations. */
|
/* Task Implementations. */
|
||||||
bool PowerControlTask::TryShutdown() {
|
bool PowerControlTask::TryShutdown() {
|
||||||
/* Set a timeout of 30 seconds. */
|
/* Set a timeout of 30 seconds. */
|
||||||
constexpr s32 MaxShutdownWaitSeconds = 30;
|
constexpr auto MaxShutdownWaitInterval = TimeSpan::FromSeconds(30);
|
||||||
|
|
||||||
auto start_tick = os::GetSystemTick();
|
auto start_tick = os::GetSystemTick();
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ namespace ams::fatal::srv {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
auto cur_tick = os::GetSystemTick();
|
auto cur_tick = os::GetSystemTick();
|
||||||
if ((cur_tick - start_tick).ToTimeSpan().GetSeconds() > MaxShutdownWaitSeconds) {
|
if ((cur_tick - start_tick).ToTimeSpan() > MaxShutdownWaitInterval) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue