Improve efficiency of kernel console
This commit is contained in:
parent
04f6e7b558
commit
0ccfd2125a
1 changed files with 99 additions and 53 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use core::fmt::{self, Write};
|
||||
use spin::Mutex;
|
||||
|
||||
use device::display::DISPLAY;
|
||||
use device::display;
|
||||
use device::serial::COM1;
|
||||
|
||||
pub static CONSOLE: Mutex<Console> = Mutex::new(Console::new());
|
||||
|
|
@ -16,8 +16,13 @@ impl Console {
|
|||
|
||||
impl Write for Console {
|
||||
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
|
||||
if let Some(ref mut display) = *DISPLAY.lock() {
|
||||
display.write(s.as_bytes());
|
||||
if let Some(ref mut console) = *display::CONSOLE.lock() {
|
||||
if let Some(ref mut display) = *display::DISPLAY.lock() {
|
||||
console.write(s.as_bytes(), |event| {
|
||||
display.event(event);
|
||||
});
|
||||
}
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
COM1.lock().write_str(s)
|
||||
|
|
|
|||
Loading…
Reference in a new issue