重写rust核心库,构建中断处理框架 #6
|
@ -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" {
|
extern "C" {
|
||||||
pub fn interrupt_open();
|
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();
|
let tty = Tty::from_id(0).unwrap();
|
||||||
tty.enable();
|
tty.enable();
|
||||||
tty.print(message!(
|
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::RED),
|
||||||
FmtMeta::Color(Color::YELLOW)
|
FmtMeta::Color(Color::YELLOW),
|
||||||
|
FmtMeta::Pointer(rip as usize),
|
||||||
|
FmtMeta::Pointer(rsp as usize)
|
||||||
));
|
));
|
||||||
loop {}
|
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();
|
let tty = Tty::from_id(0).unwrap();
|
||||||
tty.enable();
|
tty.enable();
|
||||||
tty.print(message!(
|
tty.print(message!(
|
||||||
"{Panic}: Kernel hit {Divid Error} on rip=0x{} and rsp=0x{}.\n",
|
"{Warning}: Kernel hit {Divid Error} on rip=0x{} and rsp=0x{}.\n",
|
||||||
FmtMeta::Color(Color::RED),
|
FmtMeta::Color(Color::PURPLE),
|
||||||
FmtMeta::Color(Color::YELLOW),
|
FmtMeta::Color(Color::YELLOW),
|
||||||
FmtMeta::Pointer(rip as usize),
|
FmtMeta::Pointer(rip as usize),
|
||||||
FmtMeta::Pointer(rsp as usize)
|
FmtMeta::Pointer(rsp as usize)
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
use crate::{
|
use crate::kernel::tty::tty::Tty;
|
||||||
kernel::{
|
|
||||||
klog::{KernelLogger, LoggerLevel},
|
|
||||||
tty::tty::Tty,
|
|
||||||
},
|
|
||||||
message_raw,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn kmain_rust() -> ! {
|
extern "C" fn kmain_rust() -> ! {
|
||||||
|
|
|
@ -1,50 +1,5 @@
|
||||||
pub mod tty;
|
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_export]
|
||||||
macro_rules! message {
|
macro_rules! message {
|
||||||
( $fmtter : expr ) => {{
|
( $fmtter : expr ) => {{
|
||||||
|
|
Reference in New Issue