forked from riscv-software-src/riscv-angel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebworker.js
60 lines (48 loc) · 1.77 KB
/
webworker.js
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
// this code will run in a separate worker and interface with the run.html
// page's DOM through message passing
importScripts("lib/closure-compiled/long.js");
goog.require("goog.math.Long");
importScripts("lib/javascript-biginteger/biginteger.js");
Long = goog.math.Long;
importScripts("devices/character.js", "lib/binfile/binfile.js",
"mappings.js", "utils.js", "mmu.js", "trap.js", "elfload.js", "inst.js",
"cpu.js", "elfrun.js");
//onmessage = function(oEvent) {
// // handle term event
// console.log(oEvent.data);
//};
self.addEventListener("message", function (oEvent) {
if (oEvent.data.type == "r") {
//continue running
readTest.push("\n");
elfRunNextInst();
} else if (oEvent.data.type == "u") {
// copy user input
DAT = oEvent.data.inp;
if (DAT == 'THIS_IS_ESC') {
readTest.push(DAT);
} else {
for (var x = 0; x < DAT.length; x++) {
readTest.push(DAT.charAt(x));
}
}
elfRunNextInst();
}
}, false);
function runCodeC(userIn) {
//compilestat = document.getElementById("compilestatus");
//compilestat.innerHTML = "Compile Status: Compiling, waiting for server response.";
filesList = ["lib/riscv_compiled/vmlinux" ];
handle_file_continue(filesList);
RISCV = new CPU();
}
function handle_file_continue(filesList) {
//document.getElementById("testresult").innerHTML = "ELF not loaded";
//tab = document.getElementById("regtable");
//elfproptab = document.getElementById("elfprops");
//debugtab = document.getElementById("debugprops");
// execution pause
pauseExec = false;
GetBinaryFile(filesList[0], chainedFileLoader, filesList.slice(1, filesList.length));
}
runCodeC();