2015-12-30 18:18:23 +01:00
|
|
|
#!/usr/bin/env node
|
2025-04-07 19:39:08 +07:00
|
|
|
|
2025-04-10 18:36:12 +07:00
|
|
|
import path from "node:path";
|
2025-03-18 00:29:11 -07:00
|
|
|
import fs from "node:fs";
|
|
|
|
|
import url from "node:url";
|
2025-04-10 18:36:12 +07:00
|
|
|
import { V86 } from "../build/libv86.mjs";
|
2025-03-18 00:29:11 -07:00
|
|
|
|
|
|
|
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
2015-01-17 20:48:11 +01:00
|
|
|
|
2015-08-22 16:37:55 +02:00
|
|
|
process.stdin.setRawMode(true);
|
|
|
|
|
process.stdin.resume();
|
|
|
|
|
process.stdin.setEncoding("utf8");
|
|
|
|
|
|
2015-12-30 18:18:23 +01:00
|
|
|
console.log("Now booting, please stand by ...");
|
|
|
|
|
|
2023-09-14 11:50:16 -05:00
|
|
|
var emulator = new V86({
|
2025-04-10 18:36:12 +07:00
|
|
|
bios: { url: __dirname + "/../bios/seabios.bin" },
|
|
|
|
|
vga_bios: { url: __dirname + "/../bios/vgabios.bin" },
|
|
|
|
|
cdrom: { url: __dirname + "/../images/linux4.iso" },
|
2015-01-17 20:48:11 +01:00
|
|
|
autostart: true,
|
2025-04-10 18:36:12 +07:00
|
|
|
net_device: {
|
|
|
|
|
type: "virtio",
|
|
|
|
|
relay_url: "fetch",
|
|
|
|
|
},
|
2015-01-17 20:48:11 +01:00
|
|
|
});
|
|
|
|
|
|
2023-09-20 20:30:35 -07:00
|
|
|
emulator.add_listener("serial0-output-byte", function(byte)
|
2015-01-17 20:48:11 +01:00
|
|
|
{
|
2023-09-20 20:30:35 -07:00
|
|
|
var chr = String.fromCharCode(byte);
|
2021-01-01 20:10:47 -06:00
|
|
|
if(chr <= "~")
|
2015-08-22 16:37:55 +02:00
|
|
|
{
|
2021-01-01 20:10:47 -06:00
|
|
|
process.stdout.write(chr);
|
2015-08-22 16:37:55 +02:00
|
|
|
}
|
2015-01-17 20:48:11 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
process.stdin.on("data", function(c)
|
|
|
|
|
{
|
|
|
|
|
if(c === "\u0003")
|
|
|
|
|
{
|
|
|
|
|
// ctrl c
|
2024-12-20 10:35:55 -07:00
|
|
|
emulator.destroy();
|
2015-12-30 21:00:37 +01:00
|
|
|
process.stdin.pause();
|
2015-01-17 20:48:11 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
emulator.serial0_send(c);
|
|
|
|
|
}
|
|
|
|
|
});
|