Update examples
This commit is contained in:
parent
e41a4d4158
commit
e0bbc019a7
|
@ -9,7 +9,7 @@ window.onload = function()
|
|||
{
|
||||
var emulator = new V86Starter({
|
||||
wasm_path: "../build/v86.wasm",
|
||||
memory_size: 128 * 1024 * 1024,
|
||||
memory_size: 512 * 1024 * 1024,
|
||||
vga_memory_size: 8 * 1024 * 1024,
|
||||
screen_container: document.getElementById("screen_container"),
|
||||
bios: {
|
||||
|
@ -18,16 +18,17 @@ window.onload = function()
|
|||
vga_bios: {
|
||||
url: "../bios/vgabios.bin",
|
||||
},
|
||||
hda: {
|
||||
url: "http://localhost/v86-images/arch3.img",
|
||||
async: true,
|
||||
size: 8 * 1024 * 1024 * 1024,
|
||||
},
|
||||
filesystem: {
|
||||
baseurl: "http://localhost/v86-images/arch/",
|
||||
basefs: "http://localhost/v86-images/fs.json",
|
||||
baseurl: "../images/arch/",
|
||||
basefs: "../images/fs.json",
|
||||
},
|
||||
autostart: true,
|
||||
bzimage_initrd_from_filesystem: true,
|
||||
cmdline: [
|
||||
"rw",
|
||||
"root=host9p rootfstype=9p rootflags=trans=virtio,cache=loose",
|
||||
"init=/usr/bin/init-openrc",
|
||||
].join(" "),
|
||||
});
|
||||
|
||||
document.getElementById("save_file").onclick = function()
|
||||
|
|
|
@ -25,7 +25,7 @@ window.onload = function()
|
|||
url: "../bios/vgabios.bin",
|
||||
},
|
||||
cdrom: {
|
||||
url: "https://dl.dropboxusercontent.com/u/61029208/dsl-4.11.rc2.iso",
|
||||
url: "../images/dsl-4.11.rc2.iso",
|
||||
async: true,
|
||||
|
||||
// size can be determined automatically, but costs an extra request
|
||||
|
|
|
@ -16,7 +16,7 @@ window.onload = function()
|
|||
|
||||
var emulator = new V86Starter({
|
||||
wasm_path: "../build/v86.wasm",
|
||||
memory_size: 128 * 1024 * 1024,
|
||||
memory_size: 512 * 1024 * 1024,
|
||||
vga_memory_size: 8 * 1024 * 1024,
|
||||
screen_container: document.getElementById("screen_container"),
|
||||
bios: {
|
||||
|
@ -25,17 +25,11 @@ window.onload = function()
|
|||
vga_bios: {
|
||||
url: "../bios/vgabios.bin",
|
||||
},
|
||||
hda: {
|
||||
url: "http://localhost/v86-images/arch3.img",
|
||||
size: 8 * 1024 * 1024 * 1024,
|
||||
async: true,
|
||||
},
|
||||
initial_state: {
|
||||
url: "http://localhost/v86-images/v86state.bin",
|
||||
url: "../images/arch_state.bin.zst",
|
||||
},
|
||||
filesystem: {
|
||||
baseurl: "http://localhost/v86-images/arch/",
|
||||
basefs: "http://localhost/v86-images/fs.json",
|
||||
baseurl: "../images/arch/",
|
||||
},
|
||||
autostart: true,
|
||||
});
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
<!doctype html>
|
||||
<title>Interpreter 2</title>
|
||||
|
||||
<script src="../build/libv86.js"></script>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
window.onload = function()
|
||||
{
|
||||
var start = Date.now();
|
||||
|
||||
document.getElementById("status").textContent = "Loading ...";
|
||||
|
||||
setInterval(function()
|
||||
{
|
||||
document.getElementById("time").textContent = Math.round((Date.now() - start) / 1000);
|
||||
}, 999);
|
||||
|
||||
if(location.host === "localhost")
|
||||
{
|
||||
var urlbase = "http://localhost/v86-images/";
|
||||
}
|
||||
else
|
||||
{
|
||||
var urlbase = "http://104.131.53.7:8086/";
|
||||
}
|
||||
|
||||
var emulator = new V86Starter({
|
||||
wasm_path: "../build/v86.wasm",
|
||||
memory_size: 128 * 1024 * 1024,
|
||||
vga_memory_size: 8 * 1024 * 1024,
|
||||
screen_container: document.getElementById("screen_container"),
|
||||
bios: {
|
||||
url: "../bios/seabios.bin",
|
||||
},
|
||||
vga_bios: {
|
||||
url: "../bios/vgabios.bin",
|
||||
},
|
||||
hda: {
|
||||
url: urlbase + "arch3.img",
|
||||
size: 8 * 1024 * 1024 * 1024,
|
||||
async: true,
|
||||
},
|
||||
initial_state: {
|
||||
url: urlbase + "v86state-node.bin",
|
||||
},
|
||||
filesystem: {
|
||||
baseurl: urlbase + "arch/",
|
||||
basefs: urlbase + "fs.json",
|
||||
},
|
||||
autostart: true,
|
||||
});
|
||||
|
||||
window.emulator = emulator;
|
||||
|
||||
emulator.add_listener("emulator-ready", function()
|
||||
{
|
||||
document.getElementById("status").textContent = "Running code ...";
|
||||
var code = "var fs = require('fs');\n" +
|
||||
"module.exports = function() {\n" +
|
||||
" fs.writeFileSync('/root/out.txt', 'The result is: ' + 2 * 3 * 4 * 5 * 6 * 7 * 8);\n" +
|
||||
"}\n";
|
||||
var buffer = new Uint8Array(code.length);
|
||||
|
||||
buffer.set(code.split("").map(function(chr) { return chr.charCodeAt(0); }));
|
||||
|
||||
emulator.create_file("/root/code.js", buffer, function(error)
|
||||
{
|
||||
if(error) throw error;
|
||||
|
||||
emulator.serial0_send('require("/root/code.js")()\n\n');
|
||||
});
|
||||
});
|
||||
|
||||
var interval = setInterval(function()
|
||||
{
|
||||
emulator.read_file("/root/out.txt", function(error, data)
|
||||
{
|
||||
if(error || !data)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById("status").textContent = "Done!";
|
||||
document.getElementById("output").textContent = String.fromCharCode.apply(this, data);
|
||||
clearInterval(interval);
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
</script>
|
||||
|
||||
<pre><span id=time>0</span>s -- <span id=status></span></pre>
|
||||
<hr>
|
||||
|
||||
<pre id=output>
|
||||
|
||||
</pre>
|
||||
<hr>
|
||||
|
||||
<!-- A minimal structure for the ScreenAdapter defined in browser/screen.js -->
|
||||
<div id="screen_container">
|
||||
<div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
|
||||
<canvas style="display: none"></canvas>
|
||||
</div>
|
||||
|
|
@ -21,8 +21,8 @@ window.onload = function()
|
|||
vga_bios: {
|
||||
url: "../bios/vgabios.bin",
|
||||
},
|
||||
cdrom: {
|
||||
url: "../images/linux.iso",
|
||||
bzimage: {
|
||||
url: "../images/buildroot-bzimage.bin",
|
||||
},
|
||||
autostart: true,
|
||||
disable_keyboard: true,
|
||||
|
@ -37,12 +37,7 @@ window.onload = function()
|
|||
data += char;
|
||||
}
|
||||
|
||||
if(data.endsWith("login: "))
|
||||
{
|
||||
console.log("Do login");
|
||||
emulator.serial0_send("root\n");
|
||||
}
|
||||
else if(data.endsWith("/root% "))
|
||||
if(data.endsWith("~% "))
|
||||
{
|
||||
console.log("Now ready");
|
||||
document.getElementById("status").textContent = "Ready.\n";
|
||||
|
|
|
@ -10,15 +10,12 @@ function readfile(path)
|
|||
}
|
||||
|
||||
var bios = readfile(__dirname + "/../bios/seabios.bin");
|
||||
var linux = readfile(__dirname + "/../images/linux.iso");
|
||||
var linux = readfile(__dirname + "/../images/linux4.iso");
|
||||
|
||||
process.stdin.setRawMode(true);
|
||||
process.stdin.resume();
|
||||
process.stdin.setEncoding("utf8");
|
||||
|
||||
var boot_start = Date.now();
|
||||
var booted = false;
|
||||
|
||||
console.log("Now booting, please stand by ...");
|
||||
|
||||
var emulator = new V86Starter({
|
||||
|
@ -29,14 +26,10 @@ var emulator = new V86Starter({
|
|||
|
||||
emulator.add_listener("serial0-output-char", function(chr)
|
||||
{
|
||||
if(!booted)
|
||||
if(chr <= "~")
|
||||
{
|
||||
var now = Date.now();
|
||||
console.log("Took %dms to boot", now - boot_start);
|
||||
booted = true;
|
||||
process.stdout.write(chr);
|
||||
}
|
||||
|
||||
process.stdout.write(chr);
|
||||
});
|
||||
|
||||
process.stdin.on("data", function(c)
|
||||
|
|
|
@ -12,7 +12,7 @@ function readfile(path)
|
|||
console.log("Use F2 to save the state and F3 to restore.");
|
||||
|
||||
var bios = readfile(__dirname + "/../bios/seabios.bin");
|
||||
var linux = readfile(__dirname + "/../images/linux.iso");
|
||||
var linux = readfile(__dirname + "/../images/linux4.iso");
|
||||
|
||||
process.stdin.setRawMode(true);
|
||||
process.stdin.resume();
|
||||
|
@ -28,7 +28,10 @@ var emulator = new V86Starter({
|
|||
|
||||
emulator.add_listener("serial0-output-char", function(chr)
|
||||
{
|
||||
process.stdout.write(chr);
|
||||
if(chr <= "~")
|
||||
{
|
||||
process.stdout.write(chr);
|
||||
}
|
||||
});
|
||||
|
||||
var state;
|
||||
|
|
|
@ -20,7 +20,7 @@ window.onload = function()
|
|||
url: "../bios/vgabios.bin",
|
||||
},
|
||||
cdrom: {
|
||||
url: "../images/linux.iso",
|
||||
url: "../images/linux4.iso",
|
||||
},
|
||||
autostart: true,
|
||||
disable_keyboard: true,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
importScripts("../build/libv86.js");
|
||||
|
||||
var emulator = new V86Starter({
|
||||
wasm_path: "../build/v86.wasm",
|
||||
memory_size: 32 * 1024 * 1024,
|
||||
vga_memory_size: 2 * 1024 * 1024,
|
||||
bios: {
|
||||
|
@ -10,7 +11,7 @@ var emulator = new V86Starter({
|
|||
url: "../bios/vgabios.bin",
|
||||
},
|
||||
cdrom: {
|
||||
url: "../images/linux.iso",
|
||||
url: "../images/linux4.iso",
|
||||
},
|
||||
autostart: true,
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue