20 Commits

Author SHA1 Message Date
pi0x
d7b538a7a3 sdk: name virgl.wasm in the web entry so that bundlers emit it: Vite and Rolldown copied virgl.mjs as an asset without the virgl.wasm it loads next to itself, so createKernel({ gl }) failed on the guest's first GL use; the entry hands the URL to the module (locateFile), and gl.wasm does the same for a gl.module of your own (#108)
Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-11-30 11:17:04 +01:00
Pooya Parsa
e8f60af86a web: redesign the top bar's right side as applets, each a status item with its own panel that opens on hover or click: CPU, Memory, Disk, Network (with Tailscale, a mode row and a sketch of the traffic's path), Ports, Display (the theme and the GPU), Sound and media (with a live microphone and camera indicator), Bluetooth, Serial, USB and Transfers (with the clipboard); bigger spacing, icons on a plate over the wallpaper, glassy popovers, and a Kernel log that opens at its bottom 2026-11-29 19:27:49 +00:00
Pooya Parsa
d8e442a641 Keep the page's data disk in OPFS in worker mode: OpfsDisk (8 MiB extent files), the SDK's backend option for the data disk, a one-way migration from IndexedDB, a storage quota block and a free Disk size in Settings, and a question in a second tab instead of an in-memory copy 2026-11-29 17:37:06 +00:00
Pooya Parsa
495fe30a91 Add guest USB on WebUSB: kwusb (a USB host controller whose transfers the host serves, with usbfs and the FTDI, CP210x, CH341 and PL2303 serial drivers), the SDK's usb option and vm.usb with a fake test device, and a USB devices section in the page's Settings 2026-11-29 15:43:56 +00:00
Pooya Parsa
42b91da2a8 Add guest Bluetooth on Web Bluetooth: kwbt (an HCI transport, hci0 while a controller is attached), the SDK's bluetooth option and vm.bluetooth with an emulated LE controller, Bluetooth and Serial ports sections in the page's Settings with Terminal buttons, and the Bluetooth and Serial Monitor launcher apps 2026-11-29 15:22:20 +00:00
Pooya Parsa
ab334389af Add guest serial ports on Web Serial: kwserial (/dev/ttyACM0..3), the SDK's serial option and vm.serial, Connect in the page's Settings and from a toast, and the Thonny and GTKTerm launcher apps 2026-11-29 13:31:16 +00:00
Pooya Parsa
4b713a5aed Merge branch 'main' into tailscale 2026-11-29 10:24:54 +00:00
Pooya Parsa
1b229902b2 Add a guest microphone and camera: kwsnd capture, kwcam (V4L2, raw and host-encoded H.264), and camera frames named to the kwva encoder
Microphone: kwsnd gains a capture substream fed by the host (SDK option
soundIn, the page's Microphone setting and ?mic=0, the CLI's
--sound-in-wav and --sound-in).

Camera: kwcam is a V4L2 capture device (/dev/video0) fed by the host: I420,
NV12 and YUYV at 320x240 to 1280x720, and H.264 encoded by the host's
WebCodecs encoder where it has one, with bitrate, GOP and key frame
controls (SDK option camera, the page's Camera setting and ?cam=0, the
CLI's --camera). The base's rc writes the udev database entry of
/dev/video*, so programs that list cameras through libudev find it.

kwva (protocol 5): an encode whose input surface is a camera buffer's
dma-buf names the frame to the host instead of sending its pixels, and
pixels an app writes into an exported surface reach the host (put).
2026-11-29 10:23:01 +00:00
Pooya Parsa
d382f7fa9b js: add a pure-JS Tailscale network device (work in progress)
The guest joins a tailnet from Node or the page: ts2021 control over
WebSocket, DERP relays, WireGuard and the packet filter in JS, loaded as
a separate chunk only when the option is used. SDK net option, CLI
--tailscale* flags and a page panel. Relay only; exit nodes, IPv6 and
real peer traffic are not covered yet.
2026-11-28 22:06:18 +00:00
Pooya Parsa
5a4ba76d79 js: export the page's Web Audio sink as createAudioOut() from unkernel/web (#17)
web/src/audio.ts becomes js/web/audio.ts. It creates no AudioContext
before the page has had a gesture, holds the latest 10 s of what plays
until then (a clip that has ended plays whole, a stream joins live), and
has state, onChange, muted, resume() and close() for a page's control.
test/audio.test.ts runs the worklet and the sink without a browser.

Closes #17
2026-11-24 20:41:32 +00:00
Pooya Parsa
3538073b0f Add guest Vulkan on the page's WebGPU (kwvk): a Vulkan 1.2 ICD in the base (vk/icd, libvulkan_kw.so under the stock loader) sends commands over vsock port 1018 to a renderer in the SDK (createKernel({ vk }), js/core/vk*.ts) that implements them on a GPUDevice, with SPIR-V translated to WGSL by naga as wasm (vk/naga); Wayland, X11 and headless presentation by readback; the page's Guest Vulkan option, Environment row and vkcube, vkmark and GTK tiles; checks in test/vk 2026-11-24 07:23:03 +00:00
Pooya Parsa
6b74afbf34 js, guest: let the data disk grow past its 4 GiB template: openDataDisk({ size }) (and the data disk spec's size) makes a new disk that large or relabels a smaller saved one to it, never shrinking, and the base's /init grows /data's ext4 to its device with kwbox growfs (EXT4_IOC_RESIZE_FS) 2026-11-22 22:56:21 +00:00
Pooya Parsa
7d4272fc4f js: log an error with its name and message where the engine's stack leaves them out (errorText): on Firefox and Safari a trap on another CPU was logged as its frames alone 2026-11-22 12:29:17 +00:00
Pooya Parsa
d4c9b459f7 js, web: default memory 2 GiB on desktops and Node and 512 MiB on phones, fallback sizes from 1024, 2 and 4 GiB on the page's slider, and a sparse copy of a snapshot on its way to a worker 2026-11-22 09:48:43 +00:00
Pooya Parsa
ff792f6121 gl: guest GL in unkernel behind createKernel({ gl }): the SDK loads the wasm renderer from dist (virgl.mjs, virgl.wasm), listens on vsock port 1019 and starts the vtest forwarder shipped in the base's kw layer; a prepared Debian disk and an end-to-end check in headless Chromium (eglinfo, frame checksums, glmark2 against llvmpipe) 2026-11-21 17:38:25 +00:00
Pooya Parsa
be940d2c91 sdk: boot distro images from a file or over HTTP
createKernel({ distro }), fetchDistro() and the CLI's --distro; the npm
package ships the distroless bundle only. HttpBase streams the image's
prefetch and reuses cached chunks after one validation.
2026-11-19 14:46:13 +00:00
Pooya Parsa
b5b75b53de Run WASI programs from the guest on the host's wasm engine (prototype)
binfmt_misc hands a wasm module to kwwasi (kernel/guest/kwwasi.c), which
connects to the host over AF_VSOCK port 1021 and serves the program's
file I/O with its own descriptors, cwd and credentials. The host
(js/core/wasi-exec.ts, serveWasiPrograms(), the CLI's --wasi) compiles
the module once and runs each program in a worker of its own
(js/core/wasi-program.ts) with WASI preview 1, or preview 0 adapted.
Requests cross through a SharedArrayBuffer where one can be used, else
with JSPI and messages. kwwasi sends a module only when the host has not
compiled it for that file, resolves paths against the cwd or / by what
exists, and maps open flags from their asm-generic values to the
guest's.

alpine.sh builds kwwasi and kw-binfmt.sh registers it; no image with
them has been built yet, so test/wasi-binfmt.ts brings kwwasi in through
a mount.
2026-11-19 07:08:32 +00:00
Pooya Parsa
70a0e0a82e SDK: send every CPU's console output through a shared ring
With more than one CPU, each CPU's fd_write puts its bytes into one
shared ring (js/core/console-ring.ts), reserving its place inside the
import, so the ring keeps the kernel's order. With the shared transport
the owner reads it (Atomics.waitAsync), independent of CPU 0, and a full
ring makes writers wait; inline and with --worker=messages CPU 0's host
reads it, and another CPU that finds it full posts the records as a
numbered batch instead of waiting for CPU 0.

Output from a secondary CPU no longer arrives as one message per write
nor waits for CPU 0 to suspend: seq 1 200000 on CPU 1 takes as long as
on CPU 0, and a shell on CPU 1 echoes in under a millisecond while CPU 0
runs user code (10 ms before).

ConsoleOutput's unread backlog dropped old chunks with Array.shift(),
which copied a long array per chunk: drop them by index.
2026-11-17 14:02:29 +00:00
Pooya Parsa
82c7d36d92 SDK: start an SMP kernel's CPUs as Web Workers in browsers
js/web/cpu.ts is the browser Platform.spawnCpu: each CPU is a module
Web Worker running runCpu(), nested in worker mode's kernel worker.
webCpuBlocker() (Platform.whyNoCpus) gives the kernel one CPU where a
thread cannot run CPUs: no cross-origin isolation, no Worker, no
Atomics.waitAsync, or a page's main thread, where CPU 0's
memory.atomic.wait32 would trap. stats().cpus says how many CPUs the
kernel got. The dist inlines the CPU worker as a Blob URL, in the web
entry and inside the web kernel worker.
2026-11-17 11:26:41 +00:00
Pooya Parsa
26d08730cc Initial commit 2026-11-15 23:27:04 +00:00