1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 10:57:26 +00:00
serenity/Kernel/Tasks/PowerStateSwitchTask.h
Liav A ef6133337e Kernel: Merge PowerStateSwitchTask reboot and shutdown procedures
The reboot procedure should prepare to "shutdown" the system cleanly and
therefore has to be merged with how shutdown is handled.
2023-08-20 13:04:42 -06:00

42 lines
957 B
C++

/*
* Copyright (c) 2023, kleines Filmröllchen <filmroellchen@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Forward.h>
#include <Kernel/Forward.h>
namespace Kernel {
enum class PowerStateCommand : uintptr_t {
Shutdown,
Reboot,
};
// We will pass the power state command to the task in place of a void* as to avoid the complications of raw allocations.
static_assert(sizeof(PowerStateCommand) == sizeof(void*));
extern bool g_in_system_shutdown;
class PowerStateSwitchTask {
public:
static void shutdown() { spawn(PowerStateCommand::Shutdown); }
static void reboot() { spawn(PowerStateCommand::Reboot); }
private:
static void spawn(PowerStateCommand);
static void power_state_switch_task(void* raw_entry_data);
static ErrorOr<void> kill_all_user_processes();
enum class DoReboot {
No,
Yes,
};
static ErrorOr<void> perform_shutdown(DoReboot);
};
}