forked from Bananymous/banan-os
				
			
			update main #1
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -424,4 +424,14 @@ namespace 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 register_irq_handler(uint8_t irq, void(*f)());
 | 
			
		||||
	[[noreturn]] void force_triple_fault();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -3,6 +3,7 @@
 | 
			
		|||
#include <kernel/CriticalScope.h>
 | 
			
		||||
#include <kernel/FS/DevFS/FileSystem.h>
 | 
			
		||||
#include <kernel/FS/VirtualFileSystem.h>
 | 
			
		||||
#include <kernel/IDT.h>
 | 
			
		||||
#include <kernel/InterruptController.h>
 | 
			
		||||
#include <kernel/LockGuard.h>
 | 
			
		||||
#include <kernel/Memory/Heap.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -776,6 +777,18 @@ namespace Kernel
 | 
			
		|||
		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)
 | 
			
		||||
	{
 | 
			
		||||
		if (command != POWEROFF_REBOOT && command != POWEROFF_SHUTDOWN)
 | 
			
		||||
| 
						 | 
				
			
			@ -789,7 +802,7 @@ namespace Kernel
 | 
			
		|||
		switch (command)
 | 
			
		||||
		{
 | 
			
		||||
			case POWEROFF_REBOOT:
 | 
			
		||||
				error = lai_acpi_reset();
 | 
			
		||||
				reset_system();
 | 
			
		||||
				break;
 | 
			
		||||
			case POWEROFF_SHUTDOWN:
 | 
			
		||||
				error = lai_enter_sleep(5);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue