20 Commits

Author SHA1 Message Date
Pooya Parsa
307de13f37 kernel: loadable modules (CONFIG_MODULES, off in the default kernel): a module is a wasm side module in an ELF .ko that the generic loader and the kmod tools read, built by Kbuild (kernel/build.sh modules, kw_modules.config with iso9660 and Bluetooth as modules), instantiated by the host against the kernel's memory and table on every CPU and again after a restored snapshot, and refused when its kernel build or configuration differs; the SMP kernel with modules reports 7.3.4-smp+ so one root holds both module sets 2026-11-30 08:51:33 +00:00
Pooya Parsa
73856e96f4 Bump the version to 0.3.0 2026-11-29 17:40:14 +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
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
1f0648d812 va: guest VA-API on the browser's WebCodecs (kwva): a libva driver in the base's kw layer sends each picture over vsock to a VideoDecoder or VideoEncoder on the page (createKernel({ va }), on by default on Debian, ?va=0); it decodes VP9, H.264, AV1 and HEVC (HEVC not yet run in a browser), encodes VP9, reads pictures back as exact NV12, exports surfaces as dmabufs of virtio-gpu resources and draws a decoded VideoFrame into a BGRX surface on the GPU (mpv --hwdec=vaapi --vo=dmabuf-wayland: 1080p H.264 at 30 fps on an M4 Pro) 2026-11-25 13:09:05 +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
fda0adc839 Credit the GL renderer's and the page's upstreams, and ship their notices in THIRD-PARTY.md: in the npm package, the release assets and the page's /licenses.md 2026-11-23 11:06:46 +00:00
Pooya Parsa
827dfa04d8 web: WebSockets in the guest preview: the service worker puts the shim /vm-ws.js into the HTML documents it relays, whose WebSocket reaches the guest (ws://localhost:<port>, /vm/<id>/<port>/, root-relative paths) through the page over a BroadcastChannel, where websocketOver() (js/core/ws.ts, RFC 6455 over vm.connect()) runs it, with credits, a socket cap and Web Locks for teardown; a preview document's root-relative requests are relayed to its port, so a Vite dev server's client and HMR work 2026-11-22 15:22:51 +00:00
Pooya Parsa
cdb3ddc467 gl: window images and WebGL2 fixes in the renderer: vm.gl.gpu.image() gives a resource as an ImageBitmap with alpha, without readback (kw_vgpu_blit; the context now has alpha and presentation writes it opaque), for a page compositor showing guest dmabufs by resource id; snapshots are refused only while a 3D resource exists or a context has submitted commands, and a restored device recreates an idle context; a failed 3D command records its reason (stats.lastError), a lost WebGL context fails every command at once, and the blit clears the GL errors it leaves; virglrenderer patches 14 to 16: border clamp maps to edge clamp, vertex inputs and colour outputs are typed on WebGL2 (Firefox's WebRender draws with integer attributes: its context went into error and its window stayed transparent), integer colour buffers are cleared with glClearBuffer 2026-11-22 09:38:49 +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
ccf57e51a9 Add a guest pc sampling profiler driven from the host: time samples through a profile IRQ bit set by a sampler thread (SMP kernel) and instruction samples through the budget, per-CPU rings in the kernel, the tier and the block before each stop from kwemu, and --profile in the CLI 2026-11-20 16:38:47 +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
0deeb1b541 Bump the package to 0.2.0, the first release of the aarch64 guest 2026-11-19 00:12:56 +00:00
Pooya Parsa
783c48c76e Switch the guest CPU to AArch64
User space is now unmodified aarch64 Linux ELF. kwemu gets an A64
interpreter (src/a64): integer, scalar and vector floating point,
AdvSIMD, exclusives and load-acquire/store-release, the EL0 system
registers, AES, PMULL, SHA1, SHA256 and CRC32. The kernel runs arm64
user space (signal frames, HWCAP, ptrace regsets, the arm64 syscall ABI),
and the guest image, the bundle, kwtest and the page's texts are built
for aarch64.
2026-11-19 00:12:38 +00:00
Pooya Parsa
0e1cd96b77 Build the SMP kernel and the bundle's SMP patch with kernel/build.sh
kernel/build.sh smp builds the SMP kernel (kw_defconfig + kw_smp.config,
kwemu with atomics) from the same tree into vendor/build/kernel-smp; all
builds both kernels, and every bundle refresh adds the UP-to-SMP patch
when the SMP kernel is the same build of the tree (KW_SMP=1 requires it,
KW_SMP=0 leaves it out). kernel stays the UP-only quick loop. The patch is
cached in kernel-smp/up.kwpatch. Fixed build stamps (user, host, a build
id hashed from the tree and kwemu sources, the tree's newest commit date)
make kernels and patch reproducible while every other build keeps its own
banner for snapshot matching. Configs are checked against their fragments
after a reconfigure. KW_BUILD, KOUT_SMP, KWEMU_SMP and LINUX_REPO make the
script runnable against another tree and output root.

bundle.mjs --smp refuses two kernels that are not the UP and SMP builds
of one tree (banner, KW_ABI_VERSION, wasm_cpu_start, memory type), with
--smp-optional to warn instead and --smp-patch to reuse a cached patch.
The release workflow builds both kernels, runs kwtest on 2 CPUs and the
kernel patch tests (unexercised).
2026-11-17 13:23:55 +00:00
Pooya Parsa
26d08730cc Initial commit 2026-11-15 23:27:04 +00:00