Эх сурвалжийг харах

x86: add shutdown support

Perform the shutdown with some port IO in an emulator-specific method.

Signed-off-by: greatbridf <greatbridf@icloud.com>
greatbridf 1 долоо хоног өмнө
parent
commit
b1aa66e28f

+ 1 - 0
build.rs

@@ -32,6 +32,7 @@ fn set_arch_config(config: &str) {
 
 fn set_arch_configs_x86() {
     set_arch_config("has_stacktrace");
+    set_arch_config("has_shutdown");
 }
 
 fn set_arch_configs_riscv64() {

+ 11 - 0
crates/eonix_hal/src/arch/x86_64/bootstrap.rs

@@ -538,3 +538,14 @@ pub unsafe extern "C" fn start_64bit() {
         options(att_syntax)
     )
 }
+
+pub fn shutdown() -> ! {
+    unsafe {
+        core::arch::asm!(
+            "mov $0x2000, %ax",
+            "mov $0x604, %dx",
+            "outw %ax, %dx",
+            options(att_syntax, nomem, noreturn)
+        );
+    }
+}