feat(virtio): riscv: 添加virtio-blk driver,并在riscv下能够正确挂载FAT32 (#761)

This commit is contained in:
LoGin
2024-04-23 17:19:54 +08:00
committed by GitHub
parent 0c1ef30087
commit 731bc2b32d
27 changed files with 998 additions and 124 deletions

View File

@ -4,6 +4,7 @@ use core::{
};
use alloc::string::ToString;
use log::{info, Log};
use super::lib_ui::textui::{textui_putstr, FontColor};
@ -129,3 +130,42 @@ impl Logger {
}
}
}
/// 内核自定义日志器
///
/// todo: 完善他的功能并且逐步把kinfo等宏迁移到这个logger上面来。
struct CustomLogger;
impl Log for CustomLogger {
fn enabled(&self, _metadata: &log::Metadata) -> bool {
// 这里可以自定义日志过滤规则
true
}
fn log(&self, record: &log::Record) {
if self.enabled(record.metadata()) {
// todo: 接入kmsg
writeln!(
PrintkWriter,
"[ {} ] {} ({}:{}) {}",
record.level(),
record.target(),
record.file().unwrap_or(""),
record.line().unwrap_or(0),
record.args()
)
.unwrap();
}
}
fn flush(&self) {
// 如果需要的话,可以在这里实现缓冲区刷新逻辑
}
}
pub fn early_init_logging() {
log::set_logger(&CustomLogger).unwrap();
log::set_max_level(log::LevelFilter::Debug);
info!("Logging initialized");
}