Hardware Interrupts

This commit is contained in:
2022-01-11 17:09:13 +08:00
parent f0f10fc701
commit 6f67926a75
7 changed files with 119 additions and 19 deletions

View File

@@ -153,7 +153,11 @@ macro_rules! println { // println!()
#[doc(hidden)]
pub fn _print(args: fmt::Arguments) {
use core::fmt::Write;
WRITER.lock().write_fmt(args).unwrap();
use x86_64::instructions::interrupts;
interrupts::without_interrupts(|| {
WRITER.lock().write_fmt(args).unwrap();
});
}
#[test_case]
@@ -170,10 +174,16 @@ fn test_println_many() { // 测试多行 println!
#[test_case]
fn test_println_output() { // 测试字符是否真的打印到了屏幕上
use core::fmt::Write;
use x86_64::instructions::interrupts;
let s = "Some test string that fits on a single line";
println!("{}", s);
for (i, c) in s.chars().enumerate() {
let screen_char = WRITER.lock().buffer.chars[BUFFER_HEIGHT - 2][i].read();
assert_eq!(char::from(screen_char.ascii_character), c);
}
interrupts::without_interrupts(|| {
let mut writer = WRITER.lock();
writeln!(writer, "\n{}", s).expect("writeln failed");
for (i, c) in s.chars().enumerate() {
let screen_char = writer.buffer.chars[BUFFER_HEIGHT - 2][i].read();
assert_eq!(char::from(screen_char.ascii_character), c);
}
});
}