From 453affb1010c6d53f280d17c76bac4329abbb918 Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 26 Aug 2020 03:51:05 +0100 Subject: [PATCH] Kernel: Add shutdown commands for other virtualizers Source: https://wiki.osdev.org/Shutdown --- Kernel/Syscalls/shutdown.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Kernel/Syscalls/shutdown.cpp b/Kernel/Syscalls/shutdown.cpp index a00343bec86..ddfb09c46e2 100644 --- a/Kernel/Syscalls/shutdown.cpp +++ b/Kernel/Syscalls/shutdown.cpp @@ -63,7 +63,13 @@ int Process::sys$halt() dbg() << "syncing mounted filesystems..."; FS::sync(); dbg() << "attempting system shutdown..."; + // QEMU Shutdown IO::out16(0x604, 0x2000); + // If we're here, the shutdown failed. Try VirtualBox shutdown. + IO::out16(0x4004, 0x3400); + // VirtualBox shutdown failed. Try Bochs/Old QEMU shutdown. + IO::out16(0xb004, 0x2000); + dbg() << "shutdown attempts failed, applications will stop responding."; return 0; }