Skip to content

Commit cb85a91

Browse files
committed
main: Move halt to common function
1 parent 652c66f commit cb85a91

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/main.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,16 @@ mod pci;
3838
mod pe;
3939
mod virtio;
4040

41+
fn halt() -> ! {
42+
loop {
43+
unsafe { asm!("hlt") };
44+
}
45+
}
46+
4147
#[cfg_attr(not(test), panic_handler)]
42-
fn panic(_info: &PanicInfo) -> ! {
43-
loop {}
48+
fn panic(info: &PanicInfo) -> ! {
49+
log!("PANIC: {}", info);
50+
halt()
4451
}
4552

4653
/// Enable SSE2 for XMM registers (needed for EFI calling)
@@ -179,10 +186,5 @@ pub extern "C" fn _start() -> ! {
179186
let mut device = block::VirtioBlockDevice::new(&mut mmio_transport);
180187
boot_from_device(&mut device);
181188

182-
#[allow(clippy::empty_loop)]
183-
loop {
184-
unsafe {
185-
asm!("hlt");
186-
}
187-
}
189+
halt()
188190
}

0 commit comments

Comments
 (0)