Kernel: Reboot will now always succeed
If acpi reset fails, we forcefully trigger a triple fault to restart the system.
This commit is contained in:
parent
79851394b3
commit
547eabb403
|
@ -424,4 +424,14 @@ namespace IDT
|
||||||
flush_idt();
|
flush_idt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[noreturn]] void force_triple_fault()
|
||||||
|
{
|
||||||
|
// load 0 sized IDT and trigger an interrupt to force triple fault
|
||||||
|
asm volatile("cli");
|
||||||
|
s_idtr.size = 0;
|
||||||
|
flush_idt();
|
||||||
|
asm volatile("int $0x00");
|
||||||
|
ASSERT_NOT_REACHED();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,5 +9,6 @@ namespace IDT
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
void register_irq_handler(uint8_t irq, void(*f)());
|
void register_irq_handler(uint8_t irq, void(*f)());
|
||||||
|
[[noreturn]] void force_triple_fault();
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,6 +3,7 @@
|
||||||
#include <kernel/CriticalScope.h>
|
#include <kernel/CriticalScope.h>
|
||||||
#include <kernel/FS/DevFS/FileSystem.h>
|
#include <kernel/FS/DevFS/FileSystem.h>
|
||||||
#include <kernel/FS/VirtualFileSystem.h>
|
#include <kernel/FS/VirtualFileSystem.h>
|
||||||
|
#include <kernel/IDT.h>
|
||||||
#include <kernel/InterruptController.h>
|
#include <kernel/InterruptController.h>
|
||||||
#include <kernel/LockGuard.h>
|
#include <kernel/LockGuard.h>
|
||||||
#include <kernel/Memory/Heap.h>
|
#include <kernel/Memory/Heap.h>
|
||||||
|
@ -776,6 +777,18 @@ namespace Kernel
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[noreturn]] static void reset_system()
|
||||||
|
{
|
||||||
|
lai_acpi_reset();
|
||||||
|
|
||||||
|
// acpi reset did not work
|
||||||
|
|
||||||
|
dwarnln("Could not reset with ACPI, crashing the cpu");
|
||||||
|
|
||||||
|
// reset through triple fault
|
||||||
|
IDT::force_triple_fault();
|
||||||
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<long> Process::sys_poweroff(int command)
|
BAN::ErrorOr<long> Process::sys_poweroff(int command)
|
||||||
{
|
{
|
||||||
if (command != POWEROFF_REBOOT && command != POWEROFF_SHUTDOWN)
|
if (command != POWEROFF_REBOOT && command != POWEROFF_SHUTDOWN)
|
||||||
|
@ -789,7 +802,7 @@ namespace Kernel
|
||||||
switch (command)
|
switch (command)
|
||||||
{
|
{
|
||||||
case POWEROFF_REBOOT:
|
case POWEROFF_REBOOT:
|
||||||
error = lai_acpi_reset();
|
reset_system();
|
||||||
break;
|
break;
|
||||||
case POWEROFF_SHUTDOWN:
|
case POWEROFF_SHUTDOWN:
|
||||||
error = lai_enter_sleep(5);
|
error = lai_enter_sleep(5);
|
||||||
|
|
Loading…
Reference in New Issue