mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 16:16:16 +04:00
Let halt quit QEMU with zero exit code
This commit is contained in:
parent
0bd8e58a47
commit
14f74aaaeb
@ -6,11 +6,15 @@ use x86_64::registers::control::{Cr0, Cr0Flags};
|
|||||||
/// Exit qemu
|
/// Exit qemu
|
||||||
/// See: https://wiki.osdev.org/Shutdown
|
/// See: https://wiki.osdev.org/Shutdown
|
||||||
/// Must run qemu with `-device isa-debug-exit`
|
/// Must run qemu with `-device isa-debug-exit`
|
||||||
/// The error code is `value written to 0x501` *2 +1, so it should be odd
|
/// The error code is `value written to 0x501` *2 +1, so it should be odd when non-zero
|
||||||
pub unsafe fn exit_in_qemu(error_code: u8) -> ! {
|
pub unsafe fn exit_in_qemu(error_code: u8) -> ! {
|
||||||
use x86_64::instructions::port::Port;
|
use x86_64::instructions::port::Port;
|
||||||
assert_eq!(error_code & 1, 1, "error code should be odd");
|
if error_code == 0 {
|
||||||
Port::new(0x501).write((error_code - 1) / 2);
|
Port::new(0xB004).write(0x2000 as u16);
|
||||||
|
} else {
|
||||||
|
assert_eq!(error_code & 1, 1, "error code should be odd");
|
||||||
|
Port::new(0x501).write((error_code - 1) / 2);
|
||||||
|
}
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ impl Syscall<'_> {
|
|||||||
// we will skip verifying magic
|
// we will skip verifying magic
|
||||||
if cmd == LINUX_REBOOT_CMD_HALT {
|
if cmd == LINUX_REBOOT_CMD_HALT {
|
||||||
unsafe {
|
unsafe {
|
||||||
cpu::exit_in_qemu(1);
|
cpu::exit_in_qemu(0);
|
||||||
}
|
}
|
||||||
} else if cmd == LINUX_REBOOT_CMD_RESTART {
|
} else if cmd == LINUX_REBOOT_CMD_RESTART {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
Loading…
Reference in New Issue
Block a user