feat(userspace): terminal server + shell desktop; US keymap w/ shift; libkos allocator multi-page fix; panics print

This commit is contained in:
2026-10-27 16:50:35 +01:00
parent 2845d190f0
commit b80303f553
26 changed files with 739 additions and 53 deletions

View File

@@ -1,5 +1,7 @@
#![no_std]
mod keymap;
use hw_virtio::mmio::MmioAccess;
use port_input_device::{InputDevice, InputEvent, Key};
@@ -28,6 +30,7 @@ pub struct VirtioInputDevice {
last_used: u16,
next_avail: u16,
evbuf_pa: usize,
shift: bool,
}
impl VirtioInputDevice {
@@ -45,7 +48,7 @@ impl VirtioInputDevice {
let evbuf_pa = libkos::device::dma(1, EVBUF_VA).ok()?;
hw_virtio::mmio::init_legacy_device(&regs, vq_pa, QUEUE_SIZE as u32);
let mut dev = Self { last_used: 0, next_avail: 0, evbuf_pa };
let mut dev = Self { last_used: 0, next_avail: 0, evbuf_pa, shift: false };
dev.fill_queue();
Some(dev)
}
@@ -118,25 +121,6 @@ impl VirtioInputDevice {
}
}
fn linux_keycode_to_key(code: u16) -> Option<Key> {
match code {
17 => Some(Key::Up), // KEY_W
31 => Some(Key::Down), // KEY_S
30 => Some(Key::Left), // KEY_A
32 => Some(Key::Right), // KEY_D
103 => Some(Key::Up), // KEY_UP
108 => Some(Key::Down), // KEY_DOWN
105 => Some(Key::Left), // KEY_LEFT
106 => Some(Key::Right),// KEY_RIGHT
28 => Some(Key::Enter), // KEY_ENTER
1 => Some(Key::Escape), // KEY_ESC
57 => Some(Key::Space), // KEY_SPACE
14 => Some(Key::Backspace), // KEY_BACKSPACE
15 => Some(Key::Tab), // KEY_TAB
_ => None,
}
}
impl InputDevice for VirtioInputDevice {
fn poll(&mut self) -> Option<InputEvent> {
loop {
@@ -151,8 +135,12 @@ impl InputDevice for VirtioInputDevice {
let (ev_type, ev_code, ev_value) = self.read_event(desc_idx);
self.resubmit(desc_idx);
if ev_type == EV_KEY && matches!(ev_code, keymap::LEFT_SHIFT | keymap::RIGHT_SHIFT) {
self.shift = ev_value != 0;
continue;
}
if ev_type == EV_KEY {
if let Some(key) = linux_keycode_to_key(ev_code) {
if let Some(key) = keymap::key(ev_code, self.shift) {
if ev_value == KEY_PRESS {
return Some(InputEvent::KeyDown(key));
} else if ev_value == 0 {