arch.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!doctype html>
  2. <title>Archlinux</title>
  3. <script src="../build/libv86.js"></script>
  4. <script>
  5. "use strict";
  6. window.onload = function()
  7. {
  8. var emulator = new V86Starter({
  9. wasm_path: "../build/v86.wasm",
  10. memory_size: 512 * 1024 * 1024,
  11. vga_memory_size: 8 * 1024 * 1024,
  12. screen_container: document.getElementById("screen_container"),
  13. bios: {
  14. url: "../bios/seabios.bin",
  15. },
  16. vga_bios: {
  17. url: "../bios/vgabios.bin",
  18. },
  19. filesystem: {
  20. baseurl: "../images/arch/",
  21. basefs: "../images/fs.json",
  22. },
  23. autostart: true,
  24. bzimage_initrd_from_filesystem: true,
  25. cmdline: [
  26. "rw",
  27. "root=host9p rootfstype=9p rootflags=trans=virtio,cache=loose",
  28. "init=/usr/bin/init-openrc",
  29. ].join(" "),
  30. });
  31. document.getElementById("save_file").onclick = function()
  32. {
  33. emulator.save_state(function(error, new_state)
  34. {
  35. if(error)
  36. {
  37. throw error;
  38. }
  39. var a = document.createElement("a");
  40. a.download = "v86state.bin";
  41. a.href = window.URL.createObjectURL(new Blob([new_state]));
  42. a.dataset.downloadurl = "application/octet-stream:" + a.download + ":" + a.href;
  43. a.click();
  44. });
  45. this.blur();
  46. };
  47. document.getElementById("restore_file").onchange = function()
  48. {
  49. if(this.files.length)
  50. {
  51. var filereader = new FileReader();
  52. emulator.stop();
  53. filereader.onload = function(e)
  54. {
  55. emulator.restore_state(e.target.result);
  56. emulator.run();
  57. };
  58. filereader.readAsArrayBuffer(this.files[0]);
  59. this.value = "";
  60. }
  61. this.blur();
  62. };
  63. };
  64. </script>
  65. <input id="save_file" type="button" value="Save state to file">
  66. Restore from file: <input id="restore_file" type="file">
  67. <hr>
  68. <!-- A minimal structure for the ScreenAdapter defined in browser/screen.js -->
  69. <div id="screen_container">
  70. <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
  71. <canvas style="display: none"></canvas>
  72. </div>