// Rumpk Layer 0: The Concrete Foundation // Markus Maiwald (Architect) | Voxis Forge (AI) // // This is the hardware floor. Sets up stack and calls Nim. const uart = @import("uart.zig"); // ========================================================= // Stack Setup (16KB) // ========================================================= export var stack_bytes: [16 * 1024]u8 align(16) = undefined; // ========================================================= // Entry Point (Naked - no prologue) // ========================================================= export fn _start() callconv(.naked) noreturn { // ARM64: Set up stack pointer, then call zig_entry asm volatile ( \\ adrp x0, stack_bytes \\ add x0, x0, :lo12:stack_bytes \\ add sp, x0, #16384 \\ bl zig_entry \\ b . ); unreachable; } // ========================================================= // HAL Exports to Nim (The ABI Contract) // ========================================================= export fn console_write(ptr: [*]const u8, len: usize) void { uart.write_bytes(ptr[0..len]); } export fn rumpk_halt() noreturn { uart.puts("[Rumpk L0] Halting.\n"); while (true) { asm volatile ("wfi"); } } // ========================================================= // Nim Entry Point (extern) // ========================================================= extern fn kmain() void; // ========================================================= // Zig Entry (called from _start) // ========================================================= export fn zig_entry() void { uart.init(); uart.puts("\n"); uart.puts("╔═══════════════════════════════════════╗\n"); uart.puts("║ RUMPK UNIKERNEL v0.1 ║\n"); uart.puts("║ Layer 0: Zig HAL Initialized ║\n"); uart.puts("╚═══════════════════════════════════════╝\n"); uart.puts("\n"); uart.puts("[Rumpk L0] Stack: 16KB @ stack_bytes\n"); uart.puts("[Rumpk L0] UART: 0x09000000 (QEMU virt)\n"); uart.puts("[Rumpk L0] Handing off to Nim L1...\n"); uart.puts("\n"); // THE RUBICON CROSSING kmain(); // If Nim returns, halt uart.puts("[Rumpk L0] Nim returned unexpectedly.\n"); rumpk_halt(); }