From 9cef3e77320c6478e7cbc9b12e42d9946d185b56 Mon Sep 17 00:00:00 2001 From: Yash Karandikar Date: Fri, 17 Sep 2021 20:03:44 -0500 Subject: [PATCH] Add shutdown command --- src/shell.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/shell.rs b/src/shell.rs index 1c34f1b..80af286 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -13,6 +13,7 @@ pub fn evaluate(command: &str) { "help" => help, "info" => info, "echo" => echo, + "shutdown" => shutdown, _ => default }; selected(&parts[..]); @@ -31,6 +32,7 @@ fn help(_arguments: &[&str]) { println!("[help] This message"); println!("[info] Info about KarxOS"); println!("[echo ] Echoes whatever arguments you pass in"); + println!("[shutdown] Shuts off the system (QEMU only)"); change_color(Color::White, Color::Black); } @@ -55,3 +57,13 @@ fn echo(arguments: &[&str]) { println!("{}", new); } + +fn shutdown(_arguments: &[&str]) { + use x86_64::instructions::port::Port; + + println!("KarxOS shutting down!"); + let mut shutdown_port: Port = Port::new(0x604); + unsafe { + shutdown_port.write(0x2000); + } +}