77 lines
2.5 KiB
Nim
77 lines
2.5 KiB
Nim
# Rumpk Layer 1: The Logic Core
|
|
# Markus Maiwald (Architect) | Voxis Forge (AI)
|
|
#
|
|
# This is the Nim kernel entry point.
|
|
# Compiled with --os:standalone --mm:arc
|
|
|
|
{.push stackTrace: off, lineTrace: off.}
|
|
|
|
# =========================================================
|
|
# HAL Imports from Zig (Layer 0)
|
|
# =========================================================
|
|
|
|
proc console_write(p: pointer, len: csize_t) {.importc, cdecl.}
|
|
proc rumpk_halt() {.importc, cdecl, noreturn.}
|
|
|
|
# =========================================================
|
|
# Kernel I/O
|
|
# =========================================================
|
|
|
|
proc kprint(s: string) =
|
|
if s.len > 0:
|
|
console_write(unsafeAddr s[0], csize_t(s.len))
|
|
|
|
proc kprintln(s: string) =
|
|
kprint(s)
|
|
kprint("\n")
|
|
|
|
# =========================================================
|
|
# Panic Handler (Required for --os:standalone)
|
|
# =========================================================
|
|
|
|
proc nimPanic(msg: cstring) {.exportc: "panic", cdecl, noreturn.} =
|
|
kprint("\n[PANIC] ")
|
|
if msg != nil:
|
|
var i = 0
|
|
while msg[i] != '\0':
|
|
var buf: array[1, char]
|
|
buf[0] = msg[i]
|
|
console_write(addr buf[0], 1)
|
|
inc i
|
|
kprint("\n")
|
|
rumpk_halt()
|
|
|
|
# =========================================================
|
|
# Memory Allocator - Provided by Zig L0 (hal/stubs.zig)
|
|
# =========================================================
|
|
|
|
# Zig exports: malloc, free, realloc, calloc
|
|
# We just import them for any explicit usage
|
|
proc malloc(size: csize_t): pointer {.importc, cdecl.}
|
|
proc free(p: pointer) {.importc, cdecl.}
|
|
proc realloc(p: pointer, size: csize_t): pointer {.importc, cdecl.}
|
|
|
|
# =========================================================
|
|
# Kernel Main Entry
|
|
# =========================================================
|
|
|
|
proc kmain() {.exportc, cdecl.} =
|
|
kprintln("╔═══════════════════════════════════════╗")
|
|
kprintln("║ Layer 1: Nim Kernel Alive! ║")
|
|
kprintln("╚═══════════════════════════════════════╝")
|
|
kprintln("")
|
|
kprintln("[Rumpk L1] Memory: ARC (Deterministic)")
|
|
kprintln("[Rumpk L1] POSIX: None (Hostile)")
|
|
kprintln("[Rumpk L1] Status: OPERATIONAL")
|
|
kprintln("")
|
|
kprintln("[Rumpk L1] The Rubicon is crossed.")
|
|
kprintln("[Rumpk L1] Zig + Nim = Sovereign Metal.")
|
|
kprintln("")
|
|
kprintln("[Rumpk L1] Entering idle loop...")
|
|
|
|
# Idle loop - in real kernel, this would be the scheduler
|
|
while true:
|
|
{.emit: "asm volatile(\"wfi\");".}
|
|
|
|
{.pop.}
|