-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Description
When attempting to use interactive keyboard input in the shell, the system experiences a crash/reboot upon any keypress. The keyboard interrupt fires correctly, but processing the input causes system instability.
Current Behavior
- ✅ OS boots successfully
- ✅ Shell displays correctly with prompt
- ✅ Keyboard interrupts fire (IRQ1)
- ❌ Any keypress causes screen flicker and system reset
Expected Behavior
User should be able to type commands in the shell, with characters echoing to screen and command execution on Enter.
Technical Details
Environment:
- Architecture: x86 (32-bit)
- Emulator: QEMU (qemu-system-i386)
- Compiler: GCC with
-m32 -ffreestanding - Assembler: NASM
Relevant Code:
- Keyboard driver: kernel/keyboard.c
- Interrupt handler: kernel/isr.asm (IRQ1)
- Shell loop: kernel/shell.c
What Works:
- Keyboard interrupt (IRQ1) fires correctly
- Scancode reading from port 0x60
- Buffer management (tested in isolation)
- Shell command parsing (tested with simulated input)
What Fails:
- System crashes when putchar() is called from any context after keyboard interrupt
- Issue persists whether using direct echo or buffer-based approach
- Crash occurs even with interrupt protection (CLI/STI)
Debugging Attempted
- ✅ Verified IDT setup and IRQ remapping
- ✅ Tested with minimal interrupt handler (just read scancode + EOI)
- ✅ Tried buffer-based approach (interrupt adds to buffer, main loop reads)
- ✅ Disabled hardware cursor updates
- ✅ Simplified IRQ handler to remove argument passing
- ✅ Tested with both GRUB/Multiboot and custom bootloader
Hypothesis
Possible causes:
- Stack corruption in interrupt handler
- Calling convention mismatch (Windows GCC vs standard)
- Race condition between interrupt handler and main loop
- VGA memory access issue from interrupt context
Next Steps
- Use GDB with QEMU to identify exact crash location
- Add serial port debugging for interrupt handler tracing
- Test with different compiler flags
- Review ISR assembly for register preservation issues
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels