Start stdin
This commit is contained in:
22
src/main.rs
22
src/main.rs
@@ -19,7 +19,7 @@ use embedded_alloc::LlffHeap as Heap;
|
||||
use log::info;
|
||||
|
||||
use crate::{
|
||||
draw::{Color, Draw},
|
||||
cursor::{clear_cursor, draw_cursor},
|
||||
io::init_log,
|
||||
pci::{PciDeviceIterator, scan_virtio_devices},
|
||||
riscv::enable_supervisor_interrupt,
|
||||
@@ -28,14 +28,16 @@ use crate::{
|
||||
vga::Vga,
|
||||
virtio::{
|
||||
Virtqueue,
|
||||
input::{VirtioPciDriver, init_plic_pci},
|
||||
input::{EventCodeValue, VirtioPciDriver, init_plic_pci},
|
||||
},
|
||||
virtual_fs::init_file_system,
|
||||
virtual_fs::{FILE_SYSTEM, VirtualFileSystem, init_file_system},
|
||||
};
|
||||
|
||||
extern crate alloc;
|
||||
mod boot;
|
||||
mod critical_section;
|
||||
mod cursor;
|
||||
mod data_structures;
|
||||
mod draw;
|
||||
mod fs;
|
||||
mod interrupt;
|
||||
@@ -72,11 +74,15 @@ static mut KBD_QUEUE: Virtqueue = unsafe { core::mem::zeroed() };
|
||||
pub static mut KBD_DRIVER: VirtioPciDriver = unsafe {
|
||||
VirtioPciDriver::new(
|
||||
|event| {
|
||||
let mut kbd_buffer = FILE_SYSTEM.open("/dev/input/keyboard".as_ref()).unwrap();
|
||||
if event.is_key() {
|
||||
let event = event.as_key_event();
|
||||
println!("key, {:#?}", event);
|
||||
if event.value == EventCodeValue::Pressed {
|
||||
println!("event: {:#?}", event);
|
||||
kbd_buffer.write(&[event.code as u8]).unwrap();
|
||||
}
|
||||
} else {
|
||||
println!("key pressed, {:#?}", event);
|
||||
// println!("key pressed, {:#?}", event);
|
||||
}
|
||||
},
|
||||
&mut KBD_QUEUE,
|
||||
@@ -92,7 +98,7 @@ pub static mut MOUSE_DRIVER: VirtioPciDriver = unsafe {
|
||||
if event.is_relative() {
|
||||
let event = event.as_relative_event();
|
||||
|
||||
vga::Vga.write_pixel_unsafe(MOUSE_POSITION.0, MOUSE_POSITION.1, Color::BLACK);
|
||||
clear_cursor(&mut Vga, MOUSE_POSITION.0, MOUSE_POSITION.1);
|
||||
|
||||
match event.code {
|
||||
virtio::input::EventCodeRelative::X => {
|
||||
@@ -104,7 +110,7 @@ pub static mut MOUSE_DRIVER: VirtioPciDriver = unsafe {
|
||||
_ => {}
|
||||
}
|
||||
|
||||
vga::Vga.write_pixel_unsafe(MOUSE_POSITION.0, MOUSE_POSITION.1, Color::RED);
|
||||
draw_cursor(&mut Vga, MOUSE_POSITION.0, MOUSE_POSITION.1);
|
||||
|
||||
// println!("mouse moved relatively, {:#?}", event);
|
||||
} else {
|
||||
@@ -122,8 +128,8 @@ pub extern "C" fn supervisor_mode_entry() {
|
||||
HEAP_INITIALIZED.store(true, core::sync::atomic::Ordering::Relaxed);
|
||||
init_log().unwrap();
|
||||
Vga::init();
|
||||
SCHEDULER.lock().init();
|
||||
init_file_system();
|
||||
SCHEDULER.lock().init();
|
||||
}
|
||||
|
||||
info!("Hello World !");
|
||||
|
||||
Reference in New Issue
Block a user