Commit Graph

30 Commits

Author SHA1 Message Date
e8a2963b24 feat(userspace): Call/ReplyRecv IPC, malformed-request replies, servers exit on dead endpoint; drop send/receive compat, select!, async_syscall 2026-10-27 12:06:10 +01:00
818eaecadd refactor: replace manual debug_putchar with libkos::println!
Init, storage server, and hello app now use println!/print! macros
instead of manual byte-by-byte UART output.
2026-10-19 01:00:33 +02:00
9dd400656c refactor: migrate all servers, apps, binaries to libkos 2026-10-19 00:57:27 +02:00
194024bc08 fix(ext4): remove old monolithic ext4.rs superseded by ext4/ directory 2026-10-18 23:30:56 +02:00
9be67e403b fix(ext4): review fixes — bounds checks, delete safety, blocks_count, multi-extent dirs 2026-10-18 23:28:34 +02:00
73661e925d test(ext4): comprehensive edge case and integration tests 2026-10-18 23:17:15 +02:00
bc4659eabd feat(ext4): mkdir and nested directory support 2026-10-18 23:16:35 +02:00
2ede01bdd2 feat(ext4): file create, write, and delete with extent management 2026-10-18 23:15:38 +02:00
bff18df349 feat(ext4): directory entry find/add/remove operations 2026-10-18 23:14:02 +02:00
fe0693b969 feat(ext4): block and inode bitmap allocation/deallocation 2026-10-18 23:12:33 +02:00
381669d9dd feat(ext4): inode read/write, init_empty_inode, multi-extent read 2026-10-18 23:09:57 +02:00
5d5714914f refactor(ext4): split into submodules, add io/superblock/bgd with write-back 2026-10-18 23:08:07 +02:00
d85cb5b55d feat(storage): add mkdir to FileSystem trait with stubs 2026-10-18 23:06:26 +02:00
7c7e3b8748 refactor: apply newtypes throughout userspace API and display types
Every syscall stub now uses proper types from types/ — CapSlot,
EntryPoint, StackPointer, VirtualAddress, PageCount, ProcessId,
PermissionSet, Ticks. The compiler prevents swapping entry/stack,
passing a ProcessId where a CapSlot is expected, or using an
address as a page count.

New display types in types/display.rs:
  - Color(u32) with rgb() constructor
  - ScreenCoord(u16) for x/y positions
  - Dimension(u16) for width/height

Updated throughout:
  - userspace/syscall.rs: all params typed, returns Option instead
    of sentinel usize::MAX
  - server-framework: endpoint param is CapSlot
  - port-framebuffer: trait uses Color, ScreenCoord, Dimension
  - hw-virtio: DmaAddrs uses PhysicalAddress/VirtualAddress,
    GPU commands use Dimension
  - All servers, drivers, bins, apps updated for new signatures
  - permission-manager: process field uses ProcessId
  - PermissionSet: added bits() accessor

89 tests pass, full QEMU boot verified.
2026-10-18 13:45:40 +02:00
3a0395453b refactor: extract shared hw-virtio crate, eliminate VirtIO protocol duplication
Two VirtIO block and two VirtIO GPU implementations (adapter + driver)
shared 90% of their protocol logic. Extracted the common code into
hw-virtio, parameterized by MmioAccess trait.

New crate: hw-virtio (no_std, zero deps)
  - mmio.rs: MmioAccess trait, DirectMmio, init_legacy_device(), scan
  - queue.rs: VirtioQueue with descriptor chain submit + poll
  - block.rs: block read protocol (3-descriptor chain)
  - gpu.rs: GPU commands (create_2d, attach_backing, set_scanout,
            transfer_to_host, resource_flush)

Adapter thin wrappers (identity-mapped, statics for DMA):
  - virtio_blk.rs: 220 → 53 lines
  - virtio_gpu.rs: 165 → 37 lines

Driver thin wrappers (mapped VAs, phys-info for DMA):
  - drivers/block/virtio: 139 → 70 lines
  - drivers/framebuffer/virtio: 146 → 95 lines

Also deleted input-server/input_device.rs (1-line re-export,
superseded by port-input-device).
2026-10-18 13:29:28 +02:00
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
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
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
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
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
bb99c3001d init 2026-10-16 02:32:24 +02:00