forked from copy/v86
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodejs.js
executable file
·47 lines (39 loc) · 919 Bytes
/
nodejs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env node
"use strict";
var fs = require("fs");
var V86Starter = require("../build/libv86.js").V86Starter;
function readfile(path)
{
return new Uint8Array(fs.readFileSync(path)).buffer;
}
var bios = readfile(__dirname + "/../bios/seabios.bin");
var linux = readfile(__dirname + "/../images/linux4.iso");
process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.setEncoding("utf8");
console.log("Now booting, please stand by ...");
var emulator = new V86Starter({
bios: { buffer: bios },
cdrom: { buffer: linux },
autostart: true,
});
emulator.add_listener("serial0-output-char", function(chr)
{
if(chr <= "~")
{
process.stdout.write(chr);
}
});
process.stdin.on("data", function(c)
{
if(c === "\u0003")
{
// ctrl c
emulator.stop();
process.stdin.pause();
}
else
{
emulator.serial0_send(c);
}
});