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
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
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:
-m32 -ffreestandingRelevant Code:
What Works:
What Fails:
Debugging Attempted
Hypothesis
Possible causes:
Next Steps