/* main.c — the arch-agnostic OS entry point. * * By the time kmain() runs, the arch's asm entry has: set up a stack, * cleared .bss (or the arch stub did), and jumped here. Everything below * is identical C for x86, RISC-V and ARM — that's the whole point of the * exercise: same core, three ISAs. */ #include "arch.h" #include "console.h" void kmain(void) { arch_early_init(); arch_set_trap_vector(); puts("\n"); puts("========================================\n"); puts(" minos — minimal multi-arch kernel\n"); puts(" arch: "); puts(arch_name()); puts("\n"); puts(" cpu mode: "); puts(arch_cpu_mode()); puts(" (most privileged; no user mode yet)\n"); puts(" M1: booted, UART up, trap vector set\n"); puts("========================================\n"); puts("hello from kmain()\n"); /* Interactive echo: proves UART input (RX) works. Type on the serial * console and minos echoes each key back. This is the seed of a real * console — M3 will turn it into a command interface. */ puts("\nType something (keys are echoed back):\n> "); drain_rx(); /* drop any bytes already sitting in the RX FIFO */ for (;;) { char c = getc(); if (c == '\r' || c == '\n') { puts("\n> "); /* newline + fresh prompt */ continue; } if (c == 0x7f || c == 0x08) { /* DEL / backspace */ puts("\b \b"); continue; } putc(c); /* echo the key */ } }