-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.js
executable file
·58 lines (47 loc) · 1.35 KB
/
run.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
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env node
"use strict";
process.on("unhandledRejection", exn => { throw exn; });
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
var V86 = require(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.js`).V86;
var fs = require("fs");
function readfile(path)
{
return new Uint8Array(fs.readFileSync(path)).buffer;
}
function Loader(path)
{
this.buffer = readfile(path);
this.byteLength = this.buffer.byteLength;
}
Loader.prototype.load = function()
{
this.onload && this.onload({});
};
var bios = readfile(__dirname + "/../../bios/seabios.bin");
var vga_bios = readfile(__dirname + "/../../bios/vgabios.bin");
var emulator = new V86({
bios: { buffer: bios },
vga_bios: { buffer: vga_bios },
multiboot: new Loader(process.argv[2]),
autostart: true,
memory_size: 64 * 1024 * 1024,
disable_jit: +process.env.DISABLE_JIT,
log_level: 0,
});
emulator.bus.register("emulator-started", function()
{
emulator.v86.cpu.io.register_write_consecutive(0xF4, {},
function(value)
{
console.log("Test exited with code " + value);
process.exit(value);
},
function() {},
function() {},
function() {});
});
emulator.add_listener("serial0-output-byte", function(byte)
{
var chr = String.fromCharCode(byte);
process.stdout.write(chr);
});