Skip to content

Commit

Permalink
x86_64: Use hlt() instead of raw ASM
Browse files Browse the repository at this point in the history
  • Loading branch information
josephlr committed Feb 28, 2020
1 parent 743ce2d commit 0266f02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
4 changes: 0 additions & 4 deletions src/asm/ram64.s
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,3 @@ ram64_start:
movq $ram_max, %rsp

jmp rust64_start

halt_loop:
hlt
jmp halt_loop
13 changes: 6 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

use core::panic::PanicInfo;

use x86_64::instructions::hlt;

#[macro_use]
mod serial;

Expand All @@ -40,15 +42,13 @@ mod virtio;
#[cfg(not(test))]
global_asm!(include_str!("asm/ram64.s"));

extern "C" {
fn halt_loop() -> !;
}

#[cfg(all(not(test), feature = "log-panic"))]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
log!("PANIC: {}", info);
unsafe { halt_loop() }
loop {
hlt()
}
}

#[cfg(all(not(test), not(feature = "log-panic")))]
Expand Down Expand Up @@ -181,6 +181,5 @@ pub extern "C" fn rust64_start() -> ! {
},
);

log!("Unable to boot from any virtio-blk device. Halting..");
unsafe { halt_loop() }
panic!("Unable to boot from any virtio-blk device")
}

0 comments on commit 0266f02

Please sign in to comment.