/* Copyright (c) [2023] [Syswonder Community]
* [Rukos] is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
use x86_64::instructions::port::PortWriteOnly;
/// Shutdown the whole system (in QEMU), including all CPUs.
///
/// See <https://wiki.osdev.org/Shutdown> for more information.
pub fn terminate() -> ! {
info!("Shutting down...");
#[cfg(platform = "x86_64-pc-oslab")]
{
axlog::ax_println!("System will reboot, press any key to continue ...");
while super::console::getchar().is_none() {}
axlog::ax_println!("Rebooting ...");
unsafe { PortWriteOnly::new(0x64).write(0xfeu8) };
}
#[cfg(platform = "x86_64-qemu-q35")]
unsafe {
PortWriteOnly::new(0x604).write(0x2000u16)
};
crate::arch::halt();
warn!("It should shutdown!");
loop {
crate::arch::halt();
}
}