Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[unstable]
build-std = ["core", "compiler_builtins", "alloc"]
build-std-features = ["compiler-builtins-mem"]
panic-abort-tests = true # Or remove this from Cargo.toml: `panic = "abort"`
panic-abort-tests = true # Or remove this from Cargo.toml: `panic = "abort"`

[build]
target = "x86_64-infinity_os.json"
rustflags = ["-C", "force-frame-pointers=yes"]

[target.'cfg(target_os = "none")']
runner = "bootimage runner"
runner = "bootimage runner"
1 change: 1 addition & 0 deletions src/kernel/debug/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod stack_trace;
20 changes: 20 additions & 0 deletions src/kernel/debug/stack_trace.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use crate::print;
use core::arch::asm;

#[repr(C)]
struct StackFrame {
rbp: *const StackFrame,
rip: usize,
}

pub fn walk_stack() {
let mut frame: *const StackFrame;
unsafe {
asm!("mov {}, rbp", out(reg) frame);
}

while let Some(stack_frame) = unsafe { frame.as_ref() } {
print!("Function address: {:#x}\n", stack_frame.rip);
frame = stack_frame.rbp;
}
}
1 change: 1 addition & 0 deletions src/kernel/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod allocator;
pub mod clock;
pub mod debug;
pub mod gdt;
pub mod interrupts;
pub mod memory;
Expand Down
23 changes: 18 additions & 5 deletions src/kernel/task/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use core::{
task::{Context, Poll},
};
use crossbeam_queue::ArrayQueue;
use futures_util::{stream::Stream, StreamExt};
use futures_util::task::AtomicWaker;
use pc_keyboard::{layouts, DecodedKey, HandleControl, Keyboard, ScancodeSet1};
use futures_util::{stream::Stream, StreamExt};
use pc_keyboard::{layouts, HandleControl, KeyCode, Keyboard, ScancodeSet1};

static SCANCODE_QUEUE: OnceCell<ArrayQueue<u8>> = OnceCell::uninit();
static WAKER: AtomicWaker = AtomicWaker::new();
Expand All @@ -20,7 +20,7 @@ pub(crate) fn add_scancode(scancode: u8) {
if let Err(_) = queue.push(scancode) {
print!("WARNING: scancode queue full; dropping keyboard input\n");
} else {
WAKER.wake(); // new
WAKER.wake();
}
} else {
print!("WARNING: scancode queue uninitialized\n");
Expand Down Expand Up @@ -75,8 +75,21 @@ pub async fn keyboard_task() {
if let Ok(Some(key_event)) = keyboard.add_byte(scancode) {
if let Some(key) = keyboard.process_keyevent(key_event) {
match key {
DecodedKey::Unicode(character) => print!("{}", character),
DecodedKey::RawKey(key) => print!("{:?}", key),
pc_keyboard::DecodedKey::RawKey(
KeyCode::LAlt
| KeyCode::RAlt2
| KeyCode::RAltGr
| KeyCode::LControl
| KeyCode::RControl
| KeyCode::RShift
| KeyCode::LShift
| KeyCode::PageDown
| KeyCode::PageUp
| KeyCode::Home
| KeyCode::CapsLock,
) => {}
pc_keyboard::DecodedKey::Unicode(character) => print!("{}", character),
pc_keyboard::DecodedKey::RawKey(key) => print!("{:?}", key),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ pub fn kernel_main(boot_info: &'static BootInfo) -> ! {
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
print!("{}\n", info);
kernel::debug::stack_trace::walk_stack();
infinity_os::hlt_loop();
}
Loading