Skip to content

Commit 03866de

Browse files
josephlrrbradford
authored andcommitted
x86_64: Use hlt() instead of raw ASM
Signed-off-by: Joe Richey <joerichey@google.com>
1 parent 412ebc4 commit 03866de

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/asm/ram64.s

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,3 @@ ram64_start:
2323
movq $ram_max, %rsp
2424

2525
jmp rust64_start
26-
27-
halt_loop:
28-
hlt
29-
jmp halt_loop

src/main.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
use core::panic::PanicInfo;
2222

23+
use x86_64::instructions::hlt;
24+
2325
#[macro_use]
2426
mod serial;
2527

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

43-
extern "C" {
44-
fn halt_loop() -> !;
45-
}
46-
4745
#[cfg(all(not(test), feature = "log-panic"))]
4846
#[panic_handler]
4947
fn panic(info: &PanicInfo) -> ! {
5048
log!("PANIC: {}", info);
51-
unsafe { halt_loop() }
49+
loop {
50+
hlt()
51+
}
5252
}
5353

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

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

0 commit comments

Comments
 (0)