rumpk/hal
Markus Maiwald a0ac0ddb64 feat(rumpk): Achieve interactive Mksh shell & formalize Sovereign FSH
CHECKPOINT 7: Nuke LwIP, Fix Stack

🎯 PRIMARY ACHIEVEMENTS:
-  Interactive Mksh shell successfully boots and accepts input
-  Kernel-side LwIP networking disabled (moved to userland intent)
-  C-ABI handover fully operational (argc, argv, environ)
-  SPEC-130: Sovereign Filesystem Hierarchy formalized

🔧 KERNEL FIXES:
1. **Nuked Kernel LwIP**
   - Disabled membrane_init() in kernel.nim
   - Prevented automatic DHCP/IP acquisition
   - Network stack deferred to userland control

2. **Fixed C-ABI Stack Handover**
   - Updated rumpk_enter_userland signature: (entry, argc, argv, sp)
   - Kernel prepares userland stack at 0x8FFFFFE0 (top of user RAM)
   - Stack layout: [argc][argv[0]][argv[1]=NULL][envp[0]=NULL][string data]
   - Preserved kernel-passed arguments through subject_entry.S

3. **Fixed Trap Return Stack Switching**
   - Added sscratch swap before sret in entry_riscv.zig
   - Properly restores user stack and preserves kernel stack pointer
   - Fixes post-syscall instruction page fault

4. **Rebuilt Mksh with Fixed Runtime**
   - subject_entry.S no longer zeros a0/a1
   - Arguments flow: Kernel -> switch.S -> subject_entry.S -> main()

📐 ARCHITECTURAL SPECS:
- **SPEC-130: Sovereign Filesystem Hierarchy**
  - Tri-State (+1) Storage Model: /sysro, /etc, /run, /state
  - Declarative Stateless Doctrine (inspired by Clear Linux/Silverblue)
  - Ghost Writer Pattern: KDL recipes -> /etc generation
  - Bind-Mount Strategy for legacy app grafting
  - Database Contract for /state (transactional, encrypted)

🛠️ DEVELOPER EXPERIENCE:
- Fixed filesystem.nim to fallback to .nexus/ for local builds
- Prevents permission errors during development

🧪 VERIFICATION:

Syscalls confirmed working: write (0x200, 0x204), read (0x203)

NEXT: Implement proper TTY/PTY subsystem for full job control

Co-authored-by: Forge <voxis@nexus-os.org>
2026-01-05 01:14:24 +01:00
..
arch feat(rumpk): Achieve interactive Mksh shell & formalize Sovereign FSH 2026-01-05 01:14:24 +01:00
crypto feat(rumpk): Phase 7 Verified - Subject Zero Launch 2025-12-31 20:18:48 +01:00
README.md docs(rumpk): Add module READMEs per Panopticum doctrine 2025-12-31 20:18:47 +01:00
abi.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
channel.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
crypto.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
entry_riscv.zig feat(rumpk): Achieve interactive Mksh shell & formalize Sovereign FSH 2026-01-05 01:14:24 +01:00
fb_wrapper.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
framebuffer.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
gpu.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
hud.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
main.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
matrix.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
mm.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
ram_blk.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
stubs.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
stubs_user.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
surface.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
uart.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
ui.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
virtio_block.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
virtio_net.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00
virtio_pci.zig Rumpk Stability, NipBox Boot, and Repository Cleanup 2026-01-04 21:39:06 +01:00

README.md

Rumpk HAL (L0)

Language: Zig + Assembly
Purpose: Hardware Abstraction Layer

Module Index

File Purpose
main.zig Entry point (_start), stack setup, calls Nim kmain
stubs.zig Freestanding libc (memcpy, malloc, printf, etc.)
uart.zig PL011 UART driver (QEMU virt)
abi.zig C ABI structs shared with Nim

Architecture Directory (arch/)

Contains per-architecture implementations:

arch/
├── aarch64/        # ARM64 (VisionFive 2, RPi, AWS Graviton)
│   ├── switch.S    # Context switch (96 bytes)
│   └── constants.nim
├── x86_64/         # System V ABI (servers, trading)
│   ├── switch.S    # Context switch (56 bytes)
│   └── constants.nim
└── riscv64/        # RISC-V LP64 (satellites, drones)
    ├── switch.S    # Context switch (112 bytes)
    └── constants.nim

Freestanding Doctrine

This HAL provides ALL C ABI symbols. No glibc, no musl.

Exported Symbols:

  • Memory: memcpy, memset, memmove, memcmp
  • Strings: strlen, strcmp, strcpy
  • Heap: malloc, free, realloc, calloc
  • I/O: printf, puts, putchar
  • Exit: exit, abort
  • Signals: signal, raise (no-op stubs)

Build

Compiled via zig build-obj -target <arch>-freestanding-none