From 0863531b534bb22df7d4663d9075484a27ed4f7c Mon Sep 17 00:00:00 2001
From: Thomas Stokes
- It's only early days for this port, and it doesn't make it all the way - through boot yet, but we're getting close, and all the fundamentals are - there. + We've got a patched version of the Linux kernel and Musl libc running, + complete with virtio devices, memory isolation, and multi-core support.
-- (context switching was particularly painful to implement in such a - constrained environment, but I think the solution ended up being quite - elegant.) -
- -All that's left to implement before we can boot BusyBox is:
-
If this sounds interesting, you can check out the source at
github.com/tombl/linux
@@ -105,6 +90,8 @@
+
+
@@ -145,11 +132,14 @@
term.write("Error: not cross origin isolated\n");
}
- const { cmdline = "no_hash_pointers console=hvc0", memory = 128 } = Object.fromEntries(
- new URLSearchParams(location.search)
- );
+ const {
+ cmdline = "",
+ memory = 128,
+ initcpio: initcpioPath = "initramfs.cpio",
+ } = Object.fromEntries(new URLSearchParams(location.search));
document.querySelector("input[name=cmdline]").value = cmdline;
document.querySelector("input[name=memory]").value = memory;
+ document.querySelector("input[name=initcpio]").value = initcpioPath;
const stdin = new ReadableStream({
start(controller) {
@@ -170,6 +160,11 @@
},
});
+ const initcpio = await fetch(initcpioPath).then((res) => res.ok && res.arrayBuffer());
+ if (!initcpio) {
+ term.write(`Failed to fetch initramfs.\n`);
+ }
+
const machine = new Machine({
cmdline: cmdline.replace(/\+/g, " "),
memoryMib: memory,
@@ -178,6 +173,7 @@
new EntropyDevice(),
new BlockDevice(new Uint8Array(8 * 1024 * 1024)),
],
+ initcpio,
});
machine.bootConsole.pipeTo(stdout2);
diff --git a/tools/wasm/public/initramfs.cpio b/tools/wasm/public/initramfs.cpio
new file mode 100644
index 0000000000000000000000000000000000000000..fc37a77f5b0f984ae108f94afbe715bd84bc3f63
GIT binary patch
literal 11777
zcmV+cF8