#include #include #include #if defined(__x86_64__) #include #include #include #endif #include #include #include #include void poweroff::prepare_for_shutdown() { drivers::nvme::disable(); log("poweroff", "NVME is disabled"); #if defined(__x86_64__) x86_64::schedule_timer::off(); #endif locks::is_disabled = true; log("poweroff", "preparing for shutdown is successful"); } void poweroff::off() { arch::disable_interrupts(); prepare_for_shutdown(); if(time::timer) { log("poweroff", "shutdowning after 3 seconds"); time::timer->sleep(3 * (1000 * 1000)); } #if defined(__x86_64__) uacpi_prepare_for_sleep_state(UACPI_SLEEP_STATE_S5); uacpi_enter_sleep_state(UACPI_SLEEP_STATE_S5); #endif klibc::printf("uhh its safe to shutdown yk\r\n"); arch::hcf(); } void poweroff::reboot() { arch::disable_interrupts(); prepare_for_shutdown(); if(time::timer) { log("poweroff","rebooting after 3 seconds"); time::timer->sleep(3 * (1000 * 1000)); } #if defined(__x86_64__) uacpi_reboot(); #endif klibc::printf("uhh its safe to reboot yk\r\n"); arch::hcf(); }