feat: shell (sh) with keyboard driver, SYS_READ, SYS_EXEC

- PS/2 keyboard driver: IRQ1 handler, scancode set 1 translation,
  ring buffer, shift key support
- SYS_READ (fd=0): non-blocking keyboard read for stdin
- SYS_YIELD: calls schedule_tick directly (no nested INT 0x80)
- SYS_EXEC: loads binary from CPIO initrd, replaces process image
- User-space libc: crt0.S (C runtime startup), syscalls.h (inline
  syscall wrappers, basic string functions)
- Shell app (sh): readline with echo/backspace, builtins (cd, env,
  help, exit), fork+exec for external commands
- Updated build_apps.sh: C app support with crt0 linking, libc
  include path, .bss section in objcopy

Tested: shell boots, keyboard input works, hello-world runs via
fork+exec, env shows CWD, exit cleanly terminates.
This commit is contained in:
AI
2026-02-23 13:08:06 +00:00
parent e9b66cd60e
commit c25ba1fccd
10 changed files with 745 additions and 16 deletions

View File

@@ -16,6 +16,7 @@
#include "cpio.h"
#include "vfs.h"
#include "initrd_fs.h"
#include "keyboard.h"
void offset_print(const char *str)
{
@@ -52,6 +53,8 @@ void kernel_main(uint32_t magic, uint32_t addr) {
offset_print("IDT initialized\n");
init_pic();
/* Unmask timer IRQ (IRQ0) explicitly */
pic_clear_mask(0);
offset_print("PIC initialized\n");
init_pmm(addr);
@@ -130,6 +133,9 @@ void kernel_main(uint32_t magic, uint32_t addr) {
init_syscalls();
offset_print("Syscalls initialized\n");
keyboard_init();
offset_print("Keyboard initialized\n");
init_process();
offset_print("Process subsystem initialized\n");