Support virtio console device

This commit is contained in:
Yuke Peng
2023-11-07 22:13:15 -08:00
committed by Tate, Hongliang Tian
parent e9544d489f
commit 01e485b96e
16 changed files with 324 additions and 6 deletions

View File

@ -12,6 +12,7 @@ pod = { git = "https://github.com/jinzhao-dev/pod", rev = "d7dba56" }
jinux-input = { path = "../../comps/input" }
jinux-block = { path = "../../comps/block" }
jinux-network = { path = "../../comps/network" }
jinux-console = { path = "../../comps/console" }
jinux-time = { path = "../../comps/time" }
jinux-virtio = { path = "../../comps/virtio" }
jinux-rights = { path = "../jinux-rights" }

View File

@ -9,7 +9,9 @@ use crate::{
pub static TTY_DRIVER: Once<Arc<TtyDriver>> = Once::new();
pub(super) fn init() {
register_console_input_callback(&serial_input_callback);
for (_, device) in jinux_console::all_devices() {
device.register_callback(&console_input_callback)
}
let tty_driver = Arc::new(TtyDriver::new());
// FIXME: install n_tty into tty_driver?
let n_tty = get_n_tty();
@ -66,6 +68,13 @@ impl TtyDriver {
}
}
fn console_input_callback(items: &[u8]) {
let tty_driver = get_tty_driver();
for item in items {
tty_driver.receive_char(*item);
}
}
fn serial_input_callback(item: u8) {
let tty_driver = get_tty_driver();
tty_driver.receive_char(item);