From e6da1be4f5e5d587b07d31acf2aa3af86ac4e262 Mon Sep 17 00:00:00 2001 From: pointer-to-bios Date: Thu, 2 May 2024 23:16:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=B2=A1=E6=9C=89=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=8E=9Fmessage=5Fraw!=E5=AE=8F=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=B9=B6=E7=A7=BB=E9=99=A4message=5Fraw!=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 | 12 ++++---- src/kernel/main.rs | 8 +---- src/kernel/tty/mod.rs | 45 ----------------------------- 3 files changed, 8 insertions(+), 57 deletions(-) diff --git a/src/kernel/arch/x86_64/interrupt.rs b/src/kernel/arch/x86_64/interrupt.rs index e957a4f..7e8160b 100644 --- a/src/kernel/arch/x86_64/interrupt.rs +++ b/src/kernel/arch/x86_64/interrupt.rs @@ -1,4 +1,4 @@ -use crate::{kernel::tty::tty::Tty, libk::alloc::string::ToString, message, message_raw}; +use crate::{kernel::tty::tty::Tty, message}; extern "C" { pub fn interrupt_open(); @@ -14,9 +14,11 @@ unsafe extern "C" fn interrupt_req_UNSUPPORTED(rip: u64, rsp: u64, errcode: u64) let tty = Tty::from_id(0).unwrap(); tty.enable(); tty.print(message!( - "{Panic}: Kernel hit an {Unsupported} interrupt. \n", + "{Panic}: Kernel hit an {Unsupported} interrupt on rip=0x{} and rsp=0x{}.\n", FmtMeta::Color(Color::RED), - FmtMeta::Color(Color::YELLOW) + FmtMeta::Color(Color::YELLOW), + FmtMeta::Pointer(rip as usize), + FmtMeta::Pointer(rsp as usize) )); loop {} } @@ -27,8 +29,8 @@ 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}: Kernel hit {Divid Error} on rip=0x{} and rsp=0x{}.\n", - FmtMeta::Color(Color::RED), + "{Warning}: Kernel hit {Divid Error} on rip=0x{} and rsp=0x{}.\n", + FmtMeta::Color(Color::PURPLE), FmtMeta::Color(Color::YELLOW), FmtMeta::Pointer(rip as usize), FmtMeta::Pointer(rsp as usize) diff --git a/src/kernel/main.rs b/src/kernel/main.rs index 2be7822..c3d29cd 100644 --- a/src/kernel/main.rs +++ b/src/kernel/main.rs @@ -1,10 +1,4 @@ -use crate::{ - kernel::{ - klog::{KernelLogger, LoggerLevel}, - tty::tty::Tty, - }, - message_raw, -}; +use crate::kernel::tty::tty::Tty; #[no_mangle] extern "C" fn kmain_rust() -> ! { diff --git a/src/kernel/tty/mod.rs b/src/kernel/tty/mod.rs index 0a899bd..0e8fc16 100644 --- a/src/kernel/tty/mod.rs +++ b/src/kernel/tty/mod.rs @@ -1,50 +1,5 @@ pub mod tty; -#[macro_export] -macro_rules! message_msg { - () => {}; - ( $builder : expr, $e : expr) => { - $builder.message_mut($e); - }; -} - -#[macro_export] -macro_rules! message_fgc { - () => {}; - ( $builder : expr, $e : expr) => { - $builder.foreground_color_mut($e); - }; -} - -#[macro_export] -macro_rules! message_bgc { - () => {}; - ( $builder : expr, $e : expr ) => { - $builder.background_color_mut($e); - }; -} - -#[macro_export] -macro_rules! message_raw { - ( $( $e : expr ),* ) => {{ - use crate::{ - kernel::tty::tty::{MessageBuilder, BuilderFunctions::*, Color}, - message_msg, message_fgc, message_bgc - }; - let mut tmp_builder = MessageBuilder::new(); - $( - if let Msg(e) = $e { - message_msg!(tmp_builder, &e); - } else if let FgColor(c) = $e { - message_fgc!(tmp_builder, c); - } else if let BgColor(c) = $e { - message_bgc!(tmp_builder, c); - } - )* - tmp_builder.build() - }}; -} - #[macro_export] macro_rules! message { ( $fmtter : expr ) => {{