Skip to content

Commit adb46ef

Browse files
authored
Upload data files needed to rebuild the demo
Here goes: - Firmware, kernel, drive image - HTML shell for the web page - Preload JS for passing arguments to the VM - COI serviceworker (See https://github.com/gzuidhof/coi-serviceworker) - Tiny build script to drive the Makefile (For clariry on what's needed)
1 parent a76f706 commit adb46ef

File tree

7 files changed

+145
-0
lines changed

7 files changed

+145
-0
lines changed

build/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
make CC=emcc LDFLAGS="--pre-js pre.js --preload-file fw_jump.bin --preload-file linux_6.2 --preload-file rootfs.img --shell-file shell_minimal.html"

build/coi-serviceworker.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/fw_jump.bin

119 KB
Binary file not shown.

build/linux_6.2

4.91 MB
Binary file not shown.

build/pre.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Module['arguments'] = ['/fw_jump.bin', '-k', '/linux_6.2', '-i', '/rootfs.img', '-m', '64M'];

build/rootfs.img

18 MB
Binary file not shown.

build/shell_minimal.html

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<!doctype html>
2+
<html lang="en-us">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6+
<title>RVVM Web Demo</title>
7+
<style>
8+
body {
9+
padding: 25px;
10+
font-size: 25px;
11+
background-color: #101010;
12+
color: white;
13+
}
14+
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
15+
textarea.emscripten { font-family: monospace; width: 80%; background-color: black; color: white; }
16+
div.emscripten { text-align: center; }
17+
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
18+
canvas.emscripten { border: 0px none; background-color: black; }
19+
20+
.spinner {
21+
height: 50px;
22+
width: 50px;
23+
margin: 0px auto;
24+
-webkit-animation: rotation .8s linear infinite;
25+
-moz-animation: rotation .8s linear infinite;
26+
-o-animation: rotation .8s linear infinite;
27+
animation: rotation 0.8s linear infinite;
28+
border-left: 10px solid rgb(16,16,16);
29+
border-right: 10px solid rgb(16,16,16);
30+
border-bottom: 10px solid rgb(16,16,16);
31+
border-top: 10px solid rgb(200,50,50);
32+
border-radius: 100%;
33+
}
34+
@-webkit-keyframes rotation {
35+
from {-webkit-transform: rotate(0deg);}
36+
to {-webkit-transform: rotate(360deg);}
37+
}
38+
@-moz-keyframes rotation {
39+
from {-moz-transform: rotate(0deg);}
40+
to {-moz-transform: rotate(360deg);}
41+
}
42+
@-o-keyframes rotation {
43+
from {-o-transform: rotate(0deg);}
44+
to {-o-transform: rotate(360deg);}
45+
}
46+
@keyframes rotation {
47+
from {transform: rotate(0deg);}
48+
to {transform: rotate(360deg);}
49+
}
50+
51+
</style>
52+
</head>
53+
<body>
54+
<script src="coi-serviceworker.min.js"></script>
55+
<figure style="overflow:visible;" id="spinner"><div class="spinner"></div><center style="margin-top:0.5em"><strong>Loading...</strong></center></figure>
56+
<div class="emscripten" id="status">Downloading...</div>
57+
<div class="emscripten">
58+
<progress value="0" max="100" id="progress" hidden=1></progress>
59+
</div>
60+
<div>
61+
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
62+
</div>
63+
64+
<hr/>
65+
<textarea class="emscripten" id="output" rows="8"></textarea>
66+
<hr>
67+
<script type='text/javascript'>
68+
var statusElement = document.getElementById('status');
69+
var progressElement = document.getElementById('progress');
70+
var spinnerElement = document.getElementById('spinner');
71+
72+
var Module = {
73+
preRun: [],
74+
postRun: [],
75+
print: (function() {
76+
var element = document.getElementById('output');
77+
if (element) element.value = ''; // clear browser cache
78+
return function(text) {
79+
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
80+
// These replacements are necessary if you render to raw HTML
81+
//text = text.replace(/&/g, "&amp;");
82+
//text = text.replace(/</g, "&lt;");
83+
//text = text.replace(/>/g, "&gt;");
84+
//text = text.replace('\n', '<br>', 'g');
85+
console.log(text);
86+
if (element) {
87+
element.value += text + "\n";
88+
element.scrollTop = element.scrollHeight; // focus on bottom
89+
}
90+
};
91+
})(),
92+
canvas: (function() {
93+
var canvas = document.getElementById('canvas');
94+
95+
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
96+
// application robust, you may want to override this behavior before shipping!
97+
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
98+
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
99+
100+
return canvas;
101+
})(),
102+
setStatus: function(text) {
103+
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
104+
if (text === Module.setStatus.last.text) return;
105+
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
106+
var now = Date.now();
107+
if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon
108+
Module.setStatus.last.time = now;
109+
Module.setStatus.last.text = text;
110+
if (m) {
111+
text = m[1];
112+
progressElement.value = parseInt(m[2])*100;
113+
progressElement.max = parseInt(m[4])*100;
114+
progressElement.hidden = false;
115+
spinnerElement.hidden = false;
116+
} else {
117+
progressElement.value = null;
118+
progressElement.max = null;
119+
progressElement.hidden = true;
120+
if (!text) spinnerElement.hidden = true;
121+
}
122+
statusElement.innerHTML = text;
123+
},
124+
totalDependencies: 0,
125+
monitorRunDependencies: function(left) {
126+
this.totalDependencies = Math.max(this.totalDependencies, left);
127+
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : '');
128+
}
129+
};
130+
Module.setStatus('Downloading...');
131+
window.onerror = function() {
132+
Module.setStatus('Exception thrown, see JavaScript console');
133+
spinnerElement.style.display = 'none';
134+
Module.setStatus = function(text) {
135+
if (text) console.error('[post-exception status] ' + text);
136+
};
137+
};
138+
</script>
139+
{{{ SCRIPT }}}
140+
</body>
141+
</html>

0 commit comments

Comments
 (0)