mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 12:21:18 +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() {
|
||||
/* Clear this. */
|
||||
std::memset(this, 0, sizeof(*this));
|
||||
|
||||
/* Get information from set. */
|
||||
settings::system::GetSerialNumber(std::addressof(this->serial_number));
|
||||
settings::system::GetFirmwareVersion(std::addressof(this->firmware_version));
|
||||
|
@ -69,11 +66,16 @@ namespace ams::fatal::srv {
|
|||
/* Read information from settings. */
|
||||
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->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. */
|
||||
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)) {
|
||||
this->fatal_auto_reboot_enabled = this->fatal_auto_reboot_interval != 0;
|
||||
u64 auto_reboot_ms;
|
||||
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. */
|
||||
|
|
|
@ -20,18 +20,18 @@ namespace ams::fatal::srv {
|
|||
|
||||
class FatalConfig {
|
||||
private:
|
||||
settings::system::SerialNumber serial_number;
|
||||
settings::system::FirmwareVersion firmware_version;
|
||||
u64 language_code;
|
||||
u64 quest_reboot_interval_second;
|
||||
bool transition_to_fatal;
|
||||
bool show_extra_info;
|
||||
bool quest_flag;
|
||||
const char *error_msg;
|
||||
const char *error_desc;
|
||||
const char *quest_desc;
|
||||
u64 fatal_auto_reboot_interval;
|
||||
bool fatal_auto_reboot_enabled;
|
||||
settings::system::SerialNumber serial_number{};
|
||||
settings::system::FirmwareVersion firmware_version{};
|
||||
u64 language_code{};
|
||||
TimeSpan quest_reboot_interval{};
|
||||
bool transition_to_fatal{};
|
||||
bool show_extra_info{};
|
||||
bool quest_flag{};
|
||||
const char *error_msg{};
|
||||
const char *error_desc{};
|
||||
const char *quest_desc{};
|
||||
TimeSpan fatal_auto_reboot_interval{};
|
||||
bool fatal_auto_reboot_enabled{};
|
||||
public:
|
||||
FatalConfig();
|
||||
|
||||
|
@ -67,11 +67,11 @@ namespace ams::fatal::srv {
|
|||
return this->fatal_auto_reboot_enabled;
|
||||
}
|
||||
|
||||
u64 GetQuestRebootTimeoutInterval() const {
|
||||
return this->quest_reboot_interval_second * 1'000ul;
|
||||
TimeSpan GetQuestRebootTimeoutInterval() const {
|
||||
return this->quest_reboot_interval;
|
||||
}
|
||||
|
||||
u64 GetFatalRebootTimeoutInterval() const {
|
||||
TimeSpan GetFatalRebootTimeoutInterval() const {
|
||||
return this->fatal_auto_reboot_interval;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,16 +54,16 @@ namespace ams::fatal::srv {
|
|||
class RebootTimingObserver {
|
||||
private:
|
||||
os::Tick start_tick;
|
||||
TimeSpan interval;
|
||||
bool flag;
|
||||
s64 interval;
|
||||
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 {
|
||||
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. */
|
||||
bool PowerControlTask::TryShutdown() {
|
||||
/* Set a timeout of 30 seconds. */
|
||||
constexpr s32 MaxShutdownWaitSeconds = 30;
|
||||
constexpr auto MaxShutdownWaitInterval = TimeSpan::FromSeconds(30);
|
||||
|
||||
auto start_tick = os::GetSystemTick();
|
||||
|
||||
|
@ -84,7 +84,7 @@ namespace ams::fatal::srv {
|
|||
|
||||
while (true) {
|
||||
auto cur_tick = os::GetSystemTick();
|
||||
if ((cur_tick - start_tick).ToTimeSpan().GetSeconds() > MaxShutdownWaitSeconds) {
|
||||
if ((cur_tick - start_tick).ToTimeSpan() > MaxShutdownWaitInterval) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue