mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Add and use hlt_loop function
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
// for a Windows system.
|
// for a Windows system.
|
||||||
#![cfg(not(windows))]
|
#![cfg(not(windows))]
|
||||||
|
|
||||||
use crate::{gdt, print, println};
|
use crate::{gdt, hlt_loop, print, println};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use pic8259_simple::ChainedPics;
|
use pic8259_simple::ChainedPics;
|
||||||
use spin;
|
use spin;
|
||||||
@@ -45,7 +45,7 @@ extern "x86-interrupt" fn double_fault_handler(
|
|||||||
_error_code: u64,
|
_error_code: u64,
|
||||||
) {
|
) {
|
||||||
println!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame);
|
println!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame);
|
||||||
loop {}
|
hlt_loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "x86-interrupt" fn timer_interrupt_handler(_stack_frame: &mut ExceptionStackFrame) {
|
extern "x86-interrupt" fn timer_interrupt_handler(_stack_frame: &mut ExceptionStackFrame) {
|
||||||
|
|||||||
@@ -12,3 +12,9 @@ pub unsafe fn exit_qemu() {
|
|||||||
let mut port = Port::<u32>::new(0xf4);
|
let mut port = Port::<u32>::new(0xf4);
|
||||||
port.write(0);
|
port.write(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn hlt_loop() -> ! {
|
||||||
|
loop {
|
||||||
|
x86_64::instructions::hlt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub extern "C" fn _start() -> ! {
|
|||||||
x86_64::instructions::interrupts::enable();
|
x86_64::instructions::interrupts::enable();
|
||||||
|
|
||||||
println!("It did not crash!");
|
println!("It did not crash!");
|
||||||
loop {}
|
blog_os::hlt_loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This function is called on panic.
|
/// This function is called on panic.
|
||||||
@@ -26,5 +26,5 @@ pub extern "C" fn _start() -> ! {
|
|||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(info: &PanicInfo) -> ! {
|
fn panic(info: &PanicInfo) -> ! {
|
||||||
println!("{}", info);
|
println!("{}", info);
|
||||||
loop {}
|
blog_os::hlt_loop();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user