mirror of
https://github.com/hexagonal-sun/moss-kernel.git
synced 2025-12-23 22:47:55 -05:00
implement restarting
This commit is contained in:
committed by
Matthew Leach
parent
b8edd4af68
commit
f63ad250f4
@@ -121,6 +121,16 @@ impl Arch for Aarch64 {
|
||||
Self::halt()
|
||||
}
|
||||
|
||||
fn restart() -> ! {
|
||||
const PSCI_SYSTEM_RESET: u32 = 0x8400_0009;
|
||||
unsafe {
|
||||
psci::do_psci_hyp_call(PSCI_SYSTEM_RESET, 0, 0, 0);
|
||||
}
|
||||
|
||||
// Fallback: halt the CPU indefinitely.
|
||||
Self::halt()
|
||||
}
|
||||
|
||||
unsafe fn copy_from_user(
|
||||
src: UA,
|
||||
dst: *mut (),
|
||||
|
||||
@@ -42,6 +42,9 @@ pub trait Arch: CpuOps + VirtualMemory {
|
||||
/// Powers off the machine. Implementations must never return.
|
||||
fn power_off() -> !;
|
||||
|
||||
/// Restarts the machine. Implementations must never return.
|
||||
fn restart() -> !;
|
||||
|
||||
/// Call a user-specified signal handler in the current process.
|
||||
fn do_signal(
|
||||
sig: SigId,
|
||||
|
||||
@@ -12,7 +12,7 @@ pub async fn sys_reboot(magic: u32, magic2: u32, op: u32, _arg: usize) -> Result
|
||||
// const LINUX_REBOOT_CMD_HALT: u32 = 0xcdef_0123;
|
||||
// const LINUX_REBOOT_CMD_KEXEC: u32 = 0x4558_4543;
|
||||
const LINUX_REBOOT_CMD_POWER_OFF: u32 = 0x4321_fedc;
|
||||
// const LINUX_REBOOT_CMD_RESTART: u32 = 0x0123_4567;
|
||||
const LINUX_REBOOT_CMD_RESTART: u32 = 0x0123_4567;
|
||||
// const LINUX_REBOOT_CMD_RESTART2: u32 = 0xa1b2_c3d4;
|
||||
// const LINUX_REBOOT_CMD_SW_SUSPEND: u32 = 0xd000_fce1;
|
||||
if magic != LINUX_REBOOT_MAGIC1
|
||||
@@ -28,6 +28,7 @@ pub async fn sys_reboot(magic: u32, magic2: u32, op: u32, _arg: usize) -> Result
|
||||
// User is supposed to sync first.
|
||||
ArchImpl::power_off()
|
||||
}
|
||||
LINUX_REBOOT_CMD_RESTART => ArchImpl::restart(),
|
||||
// TODO: Implement other reboot operations.
|
||||
_ => Err(KernelError::InvalidValue),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user