Commit Graph

176 Commits

Author SHA1 Message Date
5766c6f7f7 refactor: extract ports/drivers/bins layers — clean dependency inversion
Separate abstractions from implementations following DIP:

  servers/              drivers/
      │                     │
      ▼                     ▼
    ports/  (trait-only crates, zero deps)

New crates:

ports/ (abstractions):
  - port-framebuffer: Framebuffer trait
  - port-block-device: BlockDevice trait + SectorId
  - port-input-device: InputDevice trait + InputEvent types

drivers/ (implementations depend on ports/):
  - driver-framebuffer-virtio: VirtIO GPU framebuffer
  - driver-framebuffer-mock: test double
  - driver-block-virtio: VirtIO block device

bins/ (composition roots wire server + driver):
  - display-qemu: DisplayServer<VirtioFramebuffer>
  - storage-qemu: storage server with VirtIO block

Servers no longer own their hardware traits or driver code.
Neither server nor driver depends on the other — both point
inward to the port abstraction.
2026-10-18 13:13:53 +02:00
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
ffde4065ba fix: full init boot logic works — CreateProcess no longer spawns threads, boot uses out-param to avoid sret bug
- CreateProcess only creates process + grants cap, no thread spawning
- boot::boot takes &mut BootResult instead of returning it (fixes -> ! sret convention issue)
- Init creates 6 server processes, sets up supervisor, enters receive loop
- No faults on QEMU with full boot sequence
2026-10-18 04:57:20 +02:00
29cd0e7dfe feat: userspace linker script at 0x10000, proper ELF segment loading, full disk boot pipeline working
- Userspace linker script: apps/servers link at 0x10000 (user VA)
- Adapter linker script: kernel links at 0x80200000 (S-mode)
- Each uses build.rs to emit its own -T flag, global config only sets panic=abort
- ELF loader: page-aligns segment mappings, handles non-aligned vaddrs
- Stack: 4 pages (16K) mapped below program
- SP set to top of stack (0x10000), not bottom
- FAT16 disk image forced (mformat was creating FAT32)
- End-to-end verified: VirtIO → FAT16 → ELF → userspace → ecall → exit
2026-10-18 04:51:07 +02:00
924baede9e fix(adapter-riscv): fix VirtIO block driver — scan all MMIO slots, handle legacy mode, fix virtqueue layout
VirtIO now properly scans 8 MMIO slots, detects legacy vs modern mode,
uses correct virtqueue page alignment for legacy, and reads sectors.
Fixed disk image script to force FAT16 (mformat was creating FAT32).
init.elf successfully loaded from FAT16 disk via VirtIO on QEMU.
2026-10-18 04:42:13 +02:00
7649cb0b18 feat: add run() and binary entry points for all servers and init
Every server now has lib.rs (testable) + main.rs (deployable binary).
Binary is 3 lines: extern crate userspace_rt + call run().
Hardware servers use feature flags for adapter selection.
9 RISC-V binaries ready for the disk image.
2026-10-18 04:26:42 +02:00
d43c6a7e74 feat(adapter-riscv): load init from VirtIO block device with FAT16 filesystem
Adapter probes for VirtIO block device, reads init.elf from FAT16 disk,
parses ELF, maps into userspace, and launches. Falls back to embedded
minimal init if no disk is present.

Also: VirtIO MMIO driver, boot FAT16 reader, disk image build script,
Makefile targets for build/run/run-disk.
2026-10-18 04:19:19 +02:00
a910c06cf7 refactor(adapter-riscv): replace hardcoded demo with proper init launch via ELF parsing
Adapter now: parses init binary (ELF or raw), allocates pages, creates
user page table, sets thread entry point in SavedContext, enters U-mode.
Init takes over from there — no more IPC demo hardcoded in the adapter.
2026-10-18 04:13:13 +02:00
41f7e7db10 feat(session-server): add session server for app launching, remove apps from init manifest
Init now only starts servers. The session server holds ProcessCreate cap
and launches apps on demand. Snake is no longer in the boot manifest.
2026-10-18 04:09:28 +02:00
29434805a6 feat(userspace-rt): add runtime crate with entry point, panic handler, and allocator re-export
Snake and hello apps now use extern crate userspace_rt — no more boilerplate assembly or panic handlers in app code.
2026-10-18 04:04:52 +02:00
e092fa4ae5 fix: disable test harness for no_std binaries, fix shutdown to best-effort notify-and-halt, use CapSlot newtypes 2026-10-18 04:01:39 +02:00
0389c85108 feat(snake): implement snake game with pure game logic, renderer, and IPC-based main loop 2026-10-18 04:00:09 +02:00
a7913ddeef feat(userspace): add KosAllocator — free-list allocator backed by RequestPages syscall 2026-10-18 03:55:58 +02:00
f72a434e1a refactor(init): replace raw usize with CapSlot, StorageHandle, PhysicalAddress newtypes throughout supervisor and boot 2026-10-18 03:54:07 +02:00
0a2e01bec9 feat(init): implement supervisor with storage-backed restart, binary source tracking, and back-off delays 2026-10-18 03:52:07 +02:00
29c3841679 feat(storage-server): implement ext4 read-only filesystem with superblock, inode, extent, and directory parsing 2026-10-18 03:49:24 +02:00
dd5c2c7268 feat(storage-server): implement FAT16 filesystem with read, write, create, delete, list, and cluster chain management 2026-10-18 03:45:30 +02:00
2dc503e07e refactor(storage-server): add SectorId, FileName, PackedPath newtypes, eliminate raw primitives and DRY violations 2026-10-18 03:41:14 +02:00
7a4600b3a2 feat(storage-server): add StorageServer<F: FileSystem> with BlockDevice trait, mock adapters, and tests 2026-10-18 03:37:40 +02:00
b7bc223a79 feat: add Halt syscall, fault notification to fault handler, supervisor with back-off, shutdown with timeout
- Halt syscall: only pid 0 (init) can halt, adapter uses SBI SRST
- Fault notification: kernel delivers fault info to process fault handler endpoint before killing
- Supervisor: tracks restart counts, back-off up to 5 restarts
- Shutdown: notifies servers, waits with timeout, calls halt
- Trap handler: faults now call kernel.handle_fault instead of halting
2026-10-18 03:29:05 +02:00
a83b53d962 feat(init): add init crate with declarative boot manifest, boot sequence, supervisor and shutdown stubs
Also: make types from_raw/raw const fn, add create_process/kill/delegate/revoke to userspace syscall stubs.
2026-10-18 03:21:17 +02:00
962df75f85 refactor(permission-manager): deduplicate kind mapping into CapabilityKind::index/from_index 2026-10-18 03:17:03 +02:00
36cab28506 feat: add log-server (ring buffer) and permission-manager (grant/revoke/check) system servers 2026-10-18 03:14:48 +02:00
919e918c0a feat(input-server): expand protocol with pointer, scroll, and gamepad events 2026-10-18 03:11:15 +02:00
c9bd1d2c35 feat(input-server): add InputServer<D: InputDevice> with protocol, mock + UART adapters, and tests 2026-10-18 03:08:36 +02:00
5600ce0260 feat(display-server): add VirtioFramebuffer adapter for QEMU 2026-10-18 03:05:27 +02:00
b6cfea814a feat(display-server): add DisplayServer<F: Framebuffer> with protocol, mock adapter, and tests 2026-10-18 03:03:58 +02:00
c14fe50c23 feat(server-framework): add Server trait, Encode/Decode, async executor, syscall wrappers, and mock arch for host testing 2026-10-18 02:55:22 +02:00
5c29c0845d refactor: move Mapping<F> to types crate with VirtualAddress/PhysicalAddress newtypes, rename MapFlags to Sv39Flags 2026-10-18 02:45:53 +02:00
7df3034fca refactor(mmu): replace bool-heavy map_range with Mapping struct and MapFlags builders 2026-10-18 02:41:27 +02:00
896c78088a feat: implement configure_protection and map_shared with real page mapping, remove dead context_switch from Platform trait 2026-10-18 02:39:36 +02:00
7724a5bd0a feat: implement context switching, SavedContext with pc/status fields, wire all syscall outcomes and timer preemption 2026-10-18 02:34:36 +02:00
5a45c14cf5 feat(adapter-riscv): replace static mut with KernelCell, complete all 17 syscall decoders, wire timer and PLIC interrupts to kernel 2026-10-18 02:29:46 +02:00
ededdb2ed9 refactor(userspace): split syscall stubs into arch-agnostic API + arch/riscv backend 2026-10-18 02:19:30 +02:00
570fe22bee feat: userspace round-trip — syscall stubs, ecall dispatch, U-mode entry and exit on QEMU 2026-10-18 02:15:35 +02:00
d327794d33 refactor(adapter-riscv): restructure into hw/, mmu/, trap/ modules with board constants
Add Priority::DEFAULT and TimeSlice::DEFAULT to types crate.
All QEMU virt addresses consolidated in board.rs.
Structure mirrors future adapter-arm/ layout.
2026-10-18 02:05:57 +02:00
66a730b2fe feat(adapter-riscv): IPC demo — two processes exchange a message on QEMU virt 2026-10-18 01:58:18 +02:00
2436061215 feat(adapter-riscv): add RiscVPlatform, PLIC driver, and kernel boot on QEMU 2026-10-18 01:56:18 +02:00
941704bbbc feat(adapter-riscv): add trap handling, timer via SBI, and S/U-mode trap vector 2026-10-18 01:53:37 +02:00
d9de828420 feat(adapter-riscv): add Sv39 page tables with identity mapping and MMU activation 2026-10-18 01:48:00 +02:00
44a0ead7f2 feat(adapter-riscv): boot on QEMU virt with UART hello world 2026-10-18 01:46:47 +02:00
dcadb83088 feat: add Platform::map_shared and wire memory delegation to page mapping 2026-10-18 01:30:23 +02:00
4844b6c2d2 feat(elf): add no_std ELF64 parser for loading process binaries 2026-10-18 01:26:18 +02:00
142505d8a4 feat: add SavedContext::with_entry_and_stack, wire SpawnThread to preserve entry point and stack 2026-10-18 01:24:56 +02:00
4833f2e2bb feat(kernel): add Revoke syscall for generation-based capability revocation 2026-10-18 01:23:24 +02:00
241fefe2d4 refactor(kernel): extract MockPlatform and test helpers into separate modules 2026-10-18 01:16:24 +02:00
192631d506 feat(kernel): implement generation-based capability revocation with proofs and tests 2026-10-18 01:11:24 +02:00
71518a93a4 refactor(proofs): split into per-topic modules with shared helpers across types, domain, and kernel 2026-10-18 01:08:05 +02:00
e5fd6372b3 feat(proofs): add complete mediation, message integrity, and revocation proofs 2026-10-18 01:03:54 +02:00
74bdd1fd08 fix(proofs): replace tautological delegate guard proof with check_cap path verification 2026-10-18 01:01:20 +02:00