// MARKUS MAIWALD (ARCHITECT) | VOXIS FORGE (AI) // RUMPK HAL // RISC-V ENTRY const std = @import("std"); const uart = @import("uart.zig"); const virtio_net = @import("virtio_net.zig"); // ========================================================= // Entry Point (Naked) // ========================================================= export fn _start() callconv(.naked) noreturn { asm volatile ( // 1. Disable Interrupts \\ csrw sie, zero \\ csrw satp, zero // 1.1 Enable FPU (sstatus.FS = Initial [01]) \\ li t0, 0x2000 \\ csrs sstatus, t0 // 2. Set up Stack (Load address of stack_bytes, add size) \\ la sp, stack_bytes \\ li t0, 65536 \\ add sp, sp, t0 // 3. Jump to Zig Entry \\ call zig_entry \\ 1: wfi \\ j 1b ); unreachable; } // ========================================================= // Stack (64KB) // ========================================================= export var stack_bytes: [64 * 1024]u8 align(16) = undefined; const hud = @import("hud.zig"); // ========================================================= // Zig Higher-Level Entry // ========================================================= extern fn kmain() void; extern fn NimMain() void; export fn zig_entry() void { // UART init (QEMU default 0x10000000) uart.init_riscv(); uart.print("[Rumpk L0] zig_entry reached\n"); // HUD DRAW (No CLEAR for debug) hud.set_color(36); // Cyan hud.draw_box(1, 1, 80, 3, "RUMPK HUD v0.1"); hud.draw_box(1, 4, 80, 20, "NEXSHELL CONSOLE"); hud.draw_box(1, 24, 80, 2, "IDENTITY"); hud.move_to(2, 4); uart.print("CPU: RISC-V 64 | STATUS: INITIALIZING | MASK: SOVEREIGN"); hud.move_to(25, 4); uart.print("CELL: /Cell/Root | ID: 0xDEADBEEF"); hud.move_to(5, 4); hud.reset_color(); uart.print("[Rumpk RISC-V] Handing off to Nim L1...\n"); // VirtIO Init moved to Kernel L1 (Sovereign Mode) _ = virtio_net; // Initialize Nim Runtime NimMain(); // Call Kernel kmain(); // Halt if return rumpk_halt(); } // ========================================================= // HAL Exports to Nim (ABI Contract) // ========================================================= export fn console_write(ptr: [*]const u8, len: usize) void { uart.write_bytes(ptr[0..len]); } export fn rumpk_halt() noreturn { uart.print("[Rumpk L0] Halting.\n"); while (true) { asm volatile ("wfi"); } }