mirror of
https://github.com/copy/v86.git
synced 2025-12-31 04:23:15 +00:00
minor refactoring (remove readfile, use direct import for libv86.js)
This commit is contained in:
parent
611bc7d394
commit
121a5170f2
4 changed files with 17 additions and 47 deletions
|
|
@ -1,20 +1,12 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import path from "node:path";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import url from "node:url";
|
import url from "node:url";
|
||||||
import { V86 } from "../build/libv86.js";
|
import { V86 } from "../build/libv86.mjs";
|
||||||
|
|
||||||
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
||||||
|
|
||||||
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.setRawMode(true);
|
||||||
process.stdin.resume();
|
process.stdin.resume();
|
||||||
process.stdin.setEncoding("utf8");
|
process.stdin.setEncoding("utf8");
|
||||||
|
|
@ -22,9 +14,14 @@ process.stdin.setEncoding("utf8");
|
||||||
console.log("Now booting, please stand by ...");
|
console.log("Now booting, please stand by ...");
|
||||||
|
|
||||||
var emulator = new V86({
|
var emulator = new V86({
|
||||||
bios: { buffer: bios },
|
bios: { url: __dirname + "/../bios/seabios.bin" },
|
||||||
cdrom: { buffer: linux },
|
vga_bios: { url: __dirname + "/../bios/vgabios.bin" },
|
||||||
|
cdrom: { url: __dirname + "/../images/linux4.iso" },
|
||||||
autostart: true,
|
autostart: true,
|
||||||
|
net_device: {
|
||||||
|
type: "virtio",
|
||||||
|
relay_url: "fetch",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
emulator.add_listener("serial0-output-byte", function(byte)
|
emulator.add_listener("serial0-output-byte", function(byte)
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,13 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import url from "node:url";
|
import url from "node:url";
|
||||||
var V86 = await import("../build/libv86.js").V86;
|
import { V86 } from "../build/libv86.mjs";
|
||||||
|
|
||||||
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
||||||
|
|
||||||
function readfile(path)
|
|
||||||
{
|
|
||||||
return new Uint8Array(fs.readFileSync(path)).buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("Use F2 to save the state and F3 to restore.");
|
console.log("Use F2 to save the state and F3 to restore.");
|
||||||
|
|
||||||
var bios = readfile(__dirname + "/../bios/seabios.bin");
|
|
||||||
var linux = readfile(__dirname + "/../images/linux4.iso");
|
|
||||||
|
|
||||||
process.stdin.setRawMode(true);
|
process.stdin.setRawMode(true);
|
||||||
process.stdin.resume();
|
process.stdin.resume();
|
||||||
process.stdin.setEncoding("utf8");
|
process.stdin.setEncoding("utf8");
|
||||||
|
|
@ -23,8 +15,8 @@ process.stdin.setEncoding("utf8");
|
||||||
console.log("Now booting, please stand by ...");
|
console.log("Now booting, please stand by ...");
|
||||||
|
|
||||||
var emulator = new V86({
|
var emulator = new V86({
|
||||||
bios: { buffer: bios },
|
bios: { url: __dirname + "/../bios/seabios.bin" },
|
||||||
cdrom: { buffer: linux },
|
cdrom: { url: __dirname + "/../images/linux4.iso" },
|
||||||
autostart: true,
|
autostart: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,29 +11,10 @@ process.on("unhandledRejection", exn => { throw exn; });
|
||||||
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
|
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
|
||||||
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
|
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
|
||||||
|
|
||||||
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({
|
var emulator = new V86({
|
||||||
bios: { buffer: bios },
|
bios: { url: __dirname + "/../../bios/seabios.bin" },
|
||||||
vga_bios: { buffer: vga_bios },
|
vga_bios: { url: __dirname + "/../../bios/vgabios.bin" },
|
||||||
multiboot: new Loader(process.argv[2]),
|
multiboot: { url: process.argv[2] },
|
||||||
autostart: true,
|
autostart: true,
|
||||||
memory_size: 64 * 1024 * 1024,
|
memory_size: 64 * 1024 * 1024,
|
||||||
disable_jit: +process.env.DISABLE_JIT,
|
disable_jit: +process.env.DISABLE_JIT,
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import url from "node:url";
|
import url from "node:url";
|
||||||
|
import { V86 } from "../../../build/libv86.mjs";
|
||||||
|
|
||||||
console.log("Don't forget to run `make all` before running this script");
|
console.log("Don't forget to run `make all` before running this script");
|
||||||
|
|
||||||
const { V86 } = await import("./../../../build/libv86.js");
|
|
||||||
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
||||||
|
|
||||||
const V86_ROOT = path.join(__dirname, "../../..");
|
const V86_ROOT = path.join(__dirname, "../../..");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue