From 47f16d060e38aac95eec25303ca5bbcd32a55e18 Mon Sep 17 00:00:00 2001 From: pointer-to-bios Date: Thu, 2 May 2024 20:51:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E4=B8=AD=E6=96=AD=E4=B8=AD=E6=89=80?= =?UTF-8?q?=E6=9C=89=E6=B6=88=E6=81=AF=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=8D=A2?= =?UTF-8?q?=E4=B8=BA=E6=96=B0=E7=9A=84message!=E5=AE=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kernel/arch/x86_64/interrupt.rs | 21 +++++++++------------ src/kernel/tty/mod.rs | 6 ++++++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/kernel/arch/x86_64/interrupt.rs b/src/kernel/arch/x86_64/interrupt.rs index 7fb3265..e957a4f 100644 --- a/src/kernel/arch/x86_64/interrupt.rs +++ b/src/kernel/arch/x86_64/interrupt.rs @@ -13,15 +13,11 @@ unsafe extern "C" fn interrupt_req_UNSUPPORTED(rip: u64, rsp: u64, errcode: u64) interrupt_rust_enter(); let tty = Tty::from_id(0).unwrap(); tty.enable(); - let msg = message_raw!( - Msg("Panic:"), - FgColor::(Color::RED), - Msg(" Kernel hit an unsupported interrupt\n\twith %rip=0x"), - Msg(rip.to_hex_string()), - Msg(" and %rsp=0x"), - Msg(rsp.to_hex_string()) - ); - tty.print(msg); + tty.print(message!( + "{Panic}: Kernel hit an {Unsupported} interrupt. \n", + FmtMeta::Color(Color::RED), + FmtMeta::Color(Color::YELLOW) + )); loop {} } @@ -31,11 +27,12 @@ unsafe extern "C" fn interrupt_req_DE(rip: u64, rsp: u64, errcode: u64) { let tty = Tty::from_id(0).unwrap(); tty.enable(); tty.print(message!( - "{Panic}: divided by zero. rip=0x{}.\n", + "{Panic}: Kernel hit {Divid Error} on rip=0x{} and rsp=0x{}.\n", FmtMeta::Color(Color::RED), - FmtMeta::Pointer(rip as usize) + FmtMeta::Color(Color::YELLOW), + FmtMeta::Pointer(rip as usize), + FmtMeta::Pointer(rsp as usize) )); - loop {} interrupt_rust_leave(); } diff --git a/src/kernel/tty/mod.rs b/src/kernel/tty/mod.rs index cebad05..0a899bd 100644 --- a/src/kernel/tty/mod.rs +++ b/src/kernel/tty/mod.rs @@ -47,6 +47,12 @@ macro_rules! message_raw { #[macro_export] macro_rules! message { + ( $fmtter : expr ) => {{ + use crate::kernel::tty::tty::MessageBuilder; + MessageBuilder::new() + .message($fmtter) + .build() + }}; ( $fmtter : expr, $( $e : expr ),* ) => {{ use crate::{ kernel::tty::tty::{