12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <!doctype html>
- <title>Serial example</title>
- <script src="../build/libv86.js"></script>
- <script>
- "use strict";
- window.onload = function()
- {
- var emulator = new V86({
- wasm_path: "../build/v86.wasm",
- // Uncomment to see what's going on
- //screen_container: document.getElementById("screen_container"),
- bios: {
- url: "../bios/seabios.bin",
- },
- vga_bios: {
- url: "../bios/vgabios.bin",
- },
- bzimage: {
- url: "../images/buildroot-bzimage.bin",
- size: 5166352,
- async: false,
- },
- filesystem: {},
- cmdline: "tsc=reliable mitigations=off random.trust_cpu=on",
- autostart: true,
- disable_keyboard: true,
- });
- // In this example we wait for output from the serial terminal, which
- // should be running busybox. We log in as soon as a prompt appears and then
- // retrieve a directory listing of the root directory
- var data = "";
- var stages = [
- {
- test: "~% ",
- send: "ls -1 --color=never /\n",
- },
- {
- test: "~% ",
- send: "lua -e 'print(3+4)'\n",
- },
- ];
- var stage = 0;
- emulator.add_listener("serial0-output-byte", function(byte)
- {
- var char = String.fromCharCode(byte);
- if(char === "\r")
- {
- return;
- }
- data += char;
- document.getElementById("terminal").value += char;
- var current = stages[stage];
- if(!current)
- {
- return;
- }
- if(data.endsWith(current.test))
- {
- stage++;
- emulator.serial0_send(current.send);
- var log = "Sending: " + current.send.replace(/\n/g, "\\n") + "\n";
- document.getElementById("log").value += log;
- }
- });
- };
- </script>
- <textarea readonly rows=25 cols=60 id="log">Waiting for boot ...
- </textarea>
- <textarea readonly rows=25 cols=60 id="terminal"></textarea>
- <div id="screen_container">
- <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
- <canvas style="display: none"></canvas>
- </div>
|