Files
k-os/scripts/make-disk-image.sh
Gabriel Kaszewski 38f20cc3c4 feat: proper IPC-based boot — init loads servers from storage via IPC, VirtIO GPU driver
Complete microkernel boot pipeline: adapter loads only init + storage + display
from disk. Init bootstraps all other servers by reading binaries from the
storage server via IPC, parsing ELF, creating processes, mapping pages, and
spawning threads.

New syscalls:
- CreateEndpoint: userspace endpoint creation with full capability grant
- DebugPutchar: debug output to UART from userspace
- MapPage: cross-process page mapping (init loads binaries into children)
- SpawnThreadIn: spawn thread in another process via capability

Key fixes:
- Per-process L1 page tables for VPN[2]=0 (prevents cross-process corruption)
- Separate kernel_pt from page_tables[0] (init pid=0 overwrote kernel PT ref)
- Thread Running state set in switch_to_next (syscalls rejected without it)
- Pending IPC results applied during context switch
- SIE disabled during boot (timer can't preempt into unready processes)
- User heap VA starts at 0x40000 (avoids shared buffer at 0x30000)
- RequestPages maps at user VAs via per-process heap allocator

VirtIO GPU:
- Adapter probes for GPU device, initializes resource/scanout/backing
- Display server writes to mapped framebuffer, flushes via GPU virtqueue
- 640x480 BGRA framebuffer with transfer-to-host and resource-flush

Storage server:
- Userspace VirtIO block driver using pre-mapped MMIO and DMA pages
- FAT16 filesystem reader serving file-read requests via IPC
- Shared buffer protocol: init writes filename, storage writes file data

Echo app for IPC testing (adapter-loaded echo proved the pipeline end-to-end).
2026-10-18 13:02:30 +02:00

38 lines
965 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
IMG="boot.img"
IMG_SIZE_KB=4096
TARGET="riscv64gc-unknown-none-elf"
BUILD_DIR="target/${TARGET}/release"
echo "=== Creating k-os boot disk image ==="
dd if=/dev/zero of="${IMG}" bs=1K count=${IMG_SIZE_KB} 2>/dev/null
mformat -i "${IMG}" -t 8 -h 2 -s 32 -r 16 -c 1 -M 512 ::
echo "Created and formatted ${IMG} (${IMG_SIZE_KB}KB, FAT16)"
# Copy with 8.3 names (no long filenames, no tilde mangling)
copy() {
local src="$1" dst="$2"
if [ -f "${BUILD_DIR}/${src}" ]; then
mcopy -i "${IMG}" "${BUILD_DIR}/${src}" "::${dst}"
echo " ${dst}"
fi
}
copy init "init.elf"
copy echo "echo.elf"
copy snake "snake.elf"
copy display-server "display.elf"
copy input-server "input.elf"
copy log-server "log.elf"
copy permission-manager "permis.elf"
copy storage-server "storage.elf"
copy session-server "session.elf"
echo ""
echo "Disk contents:"
mdir -i "${IMG}" ::
echo "=== Done: ${IMG} ==="