-
Notifications
You must be signed in to change notification settings - Fork 196
/
main.html
274 lines (240 loc) · 11.2 KB
/
main.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jor1k: OpenRISC OR1K Javascript Emulator Running Linux With Network Support</title>
<meta name="keywords" content="opencore, emulation, or1000, javascript, linux">
<meta name="author" content="Sebastian Macke">
<link rel="stylesheet" href="css/default.css">
</head>
<body onload="Start()">
<canvas id="fbfullscreen" width="640" height="400" style="width: 0px; height: 0px;">
Framebuffer uses canvas
</canvas>
<div class="heading">
<a href="http://opencores.org/or1k/"><img src="images/globe.png"/></a>
<h1>jor1k: OpenRISC OR1K Javascript Emulator Running Linux With Network Support</h1>
</div>
<div class="windows">
<table>
<tr>
<td style="vertical-align: top">
<table>
<tr><td>
<table id="tty" class="terminal" cellpadding="0" cellspacing="0">
</table>
</td></tr>
<tr><td>
<span style="float: left" >
<form style="display: inline;">
<select id="coreselect" onchange='jor1k.ChangeCore(this.options[this.selectedIndex].value)'>
<option value="asm">asm.js Core</option>
<option value="safe">Safe Core (Slow)</option>
</select>
<select id="fpsselect" onchange='jor1k.framebuffer.SetFPS(this.options[this.selectedIndex].value)'>
<option value="0">0 FPS</option>
<option value="5"> 5 FPS</option>
<option value="10" selected>10 FPS </option>
<option value="20">20 FPS</option>
<option value="30">30 FPS</option>
</select>
</form>
<label>
<img src="images/upload.png" width="20px" height="20px" title="Upload to home folder" />
<input type="file" id="files" style="visibility:hidden;width:0; height:0;" name="files[]" onchange='OnUploadFiles(this.files)' multiple />
</label>
<img src="images/tar.png" width="20px" height="20px" onclick='jor1k.fs.TAR("home/user")' title="Download of home folder" />
<img src="images/sync.png" width="20px" height="20px" onclick='jor1k.fs.Sync("home/user")' title="Sync with server" />
<img src="images/fullscreen.png" width="20px" height="20px" onclick='Fullscreen()' title="Windowed fullscreen of framebuffer" />
<textarea style="height: 20px;" type=text cols="5" rows="1" id="clipboard">clipb</textarea>
<input type="checkbox" onclick='jor1k.sound.Enabled(this.checked)'>Sound
</span>
<span id="stats" style="float: right"></span>
</td></tr>
</table>
</td>
<td style="vertical-align: top">
<canvas id="fb" class="screen" width="640" height="400">
Framebuffer uses canvas
</canvas>
</td>
</tr>
</table>
</div>
<div class="infobox">
<h3>Links</h3>
<ul>
<li><a href="compile.html">Edit, compile and run</a> C code in your browser</li>
<li><a href="https://github.com/s-macke/jor1k/wiki/Explore-the-emulator">Explore the emulator</a> wiki page</li>
<li><a href="http://www.benjamincburns.com/2013/11/10/jor1k-ethmac-support.html">Ben's blog post about network support</a></li>
<li><a href="https://github.com/s-macke/jor1k/">Project</a> page at github</li>
<li><a href="https://github.com/s-macke/jor1k/issues">Bugtracker</a> to report any issues or feature requests</li>
<li><a href="https://github.com/s-macke/jor1k/wiki">Wiki</a> containing more detailed descriptions</li>
<li><a href="http://opencores.org/or1k/">Official site</a> of the openrisc project</li>
</ul>
<h3>Developer and contributors</h3>
<ul>
<li class="contributor">
<ul>
<li class="contributor-info">Main developer - Sebastian Macke <a href="http://simulationcorner.net/">simulationcorner.net</a></li>
</ul>
</li>
<li class="contributor">
<ul>
<li class="contributor-info">Network support - Ben Burns <a href="http://www.benjamincburns.com">benjamincburns.com</a></li>
</ul>
</li>
<li class="contributor">
<ul>
<li class="contributor-info">Gerard Braad <a href="http://gbraad.nl">gbraad.nl</a></li>
</ul>
</li>
<li class="contributor">
<ul>
<li class="contributor-info">Compilation Demo - Neelabh Gupta</li>
</ul>
</li>
<li class="contributor">
<ul>
<li class="contributor-info">Compilation Demo and UART support - Lawrence Angrave</li>
</ul>
</li>
</ul>
<h3>Donate</h3>
<ul>
<li>If you like the project, please support it</li>
<li class="donate">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="YNEZT8JALL7VS">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
</form>
</li>
</ul>
</div>
<script src="jor1k-master-min.js"></script>
<script>
var Jor1k = require("Jor1k");
var LinuxTerm = require("LinuxTerm");
function Fullscreen()
{
document.body.style.margin = '0px';
window.onresize = function(event) {
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
var d = x/y;
if (d > 1.6) x = y*1.6; else y = x/1.6;
var fb = document.getElementById("fbfullscreen");
fb.style.width = "" + x + "px";
fb.style.height = "" + y + "px";
};
window.onresize();
jor1k.framebuffer.Init("fbfullscreen");
}
function OnUploadFiles(files)
{
for (var i = 0, f; f = files[i]; i++) {
jor1k.fs.UploadExternalFile(f);
}
}
function RandomString(length) {
var chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var result = '';
for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
return result;
}
// from https://css-tricks.com/snippets/javascript/get-url-variables/
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return decodeURIComponent(pair[1]);}
}
return(false);
}
function Start() {
var pushState = false, loadUserData = false;
var userid = getQueryVariable("user");
if (userid == false) {
userid = RandomString(10);
pushState = true;
} else {
loadUserData = true;
}
// allow specifying relay URL via querystring
var relayURL = getQueryVariable("relayURL")
if (relayURL == false) {
relayURL = "wss://relay.widgetry.org/";
pushState = true;
}
jor1kparameters = {
system: {
kernelURL: "vmlinux.bin.bz2", // kernel image
memorysize: 32, // in MB, must be a power of two
cpu: "asm", // short name for the cpu to use
ncores: 1,
},
fs: {
basefsURL: "basefs.json", // json file with the basic filesystem configuration.
extendedfsURL: "../fs.json", // json file with extended filesystem informations. Loaded after the basic filesystem has been loaded.
earlyload: [], // list of files which should be loaded immediately after they appear in the filesystem
lazyloadimages: [
] // list of automatically loaded images after the basic filesystem has been loaded
},
term: new LinuxTerm("tty"), // canvas id for the terminal
fbid: "fb", // canvas id for the framebuffer
clipboardid: "clipboard", // input id for the clipboard
statsid: "stats", // object id for the statistics test
fps: 10, // update interval of framebuffer
relayURL: relayURL, // relay url for the network
userid: userid, // unique user id string. Empty, choosen randomly, from a url, or from a cookie.
syncURL: "//jor1k.com/sync/upload.php", // url to sync a certain folder
path: "../sys/or1k/",
}
// --------------------------------------------------------
if (loadUserData)
jor1kparameters.fs.lazyloadimages.push("sync/tarballs/"+userid+".tar.bz2");
var nCores = getQueryVariable("n");
if (nCores != false) {
jor1kparameters.system.ncores = nCores;
} else {
pushState = true;
}
var cpu = getQueryVariable("cpu");
if (cpu != false) {
jor1kparameters.system.cpu = cpu;
if (jor1kparameters.system.cpu == "smp") {
console.log("Load smp kernel");
jor1kparameters.system.kernelURL = "vmlinuxsmp.bin.bz2";
if (jor1kparameters.system.ncores != 4) {
jor1kparameters.system.ncores = 4;
pushState = true;
}
}
} else {
pushState = true;
}
if (pushState) {
window.history.pushState([], "", "?user="+encodeURIComponent(jor1kparameters.userid)+"&cpu="+encodeURIComponent(jor1kparameters.system.cpu)+"&n="+encodeURIComponent(jor1kparameters.system.ncores)+"&relayURL="+encodeURIComponent(relayURL));
}
// --------------------------------------------------------
jor1k = new Jor1k(jor1kparameters);
}
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-44129312-1', 'auto');
ga('send', 'pageview');
</script>
<div id="console">
</div>
</body>
</html>