重写rust核心库,构建中断处理框架 #6

Merged
pointer-to-bios merged 18 commits from pointer-to-bios/metaverse-dev:main into main 2024-05-03 05:45:43 +08:00
3 changed files with 8 additions and 57 deletions
Showing only changes of commit e6da1be4f5 - Show all commits

View File

@ -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)

View File

@ -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() -> ! {

View File

@ -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 ) => {{