diff --git a/ch2/user/src/user_lang_items/user_console.rs b/ch2/user/src/user_lang_items/user_console.rs index d1ca998..39f3daf 100644 --- a/ch2/user/src/user_lang_items/user_console.rs +++ b/ch2/user/src/user_lang_items/user_console.rs @@ -1,4 +1,5 @@ use core::fmt::{Arguments, Write, Result}; +use crate::syscall::sys_write; struct Stdout; @@ -6,7 +7,7 @@ const STDOUT: usize = 1; impl Write for Stdout { fn write_str(&mut self, s: &str) -> Result { - // ... todo 实现系统调用 + sys_write(STDOUT, s.as_bytes()); Ok(()) } } diff --git a/ch2/user/src/user_lang_items/user_panic.rs b/ch2/user/src/user_lang_items/user_panic.rs index 0fd119e..e38650e 100644 --- a/ch2/user/src/user_lang_items/user_panic.rs +++ b/ch2/user/src/user_lang_items/user_panic.rs @@ -1,16 +1,17 @@ use core::panic::PanicInfo; +use crate::println; #[panic_handler] fn panic(info: &PanicInfo) -> ! { if let Some(location) = info.location() { - // println!( - // "Panicked at {}:{} {}", - // location.file(), - // location.line(), - // info.message().unwrap() - // ); + println!( + "Panicked at {}:{} {}", + location.file(), + location.line(), + info.message().unwrap() + ); } else { - // println!("Panicked: {}", info.message().unwrap()); + println!("Panicked: {}", info.message().unwrap()); } loop {