Skip to content

Commit 717ee36

Browse files
committed
Miscellaneous changes
- cycle_per_step is hooked by build variable CYCLE_PER_STEP, so hard-coded is not needed. - emscripten_cancel_main_loop is done in src/emulate.c, so show the terminating log at there too. - Drop redundant WASM assets. - Add ignore list and apply Black formatter for tools/gen-elf-list-js.py.
1 parent 734cdcd commit 717ee36

File tree

7 files changed

+33
-262
lines changed

7 files changed

+33
-262
lines changed

assets/html/index.html

Lines changed: 0 additions & 243 deletions
This file was deleted.

assets/js/coi-serviceworker.min.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

assets/js/pre.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

mk/wasm.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ WEB_JS_RESOURCES := $(ASSETS)/js
66
EXPORTED_FUNCS := _main,_indirect_rv_halt
77
DEMO_DIR := demo
88
WEB_FILES := $(BIN).js \
9-
$(BIN).wasm \
10-
$(BIN).worker.js \
9+
$(BIN).wasm \
10+
$(BIN).worker.js \
1111
$(OUT)/elf_list.js
1212

1313
ifeq ("$(CC_IS_EMCC)", "1")

src/emulate.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,7 @@ void rv_step(void *arg)
11751175
if (rv_has_halted(rv)) {
11761176
emscripten_cancel_main_loop();
11771177
rv_delete(rv); /* clean up and reuse memory */
1178+
rv_log_info("RISC-V emulator is destroyed");
11781179
}
11791180
#endif
11801181
}

src/riscv.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ void rv_run(riscv_t *rv)
615615
attr->data.user.elf_program
616616
#endif
617617
);
618-
attr->cycle_per_step = 100000000;
619618

620619
if (!(attr->run_flag & (RV_RUN_TRACE | RV_RUN_GDBSTUB))) {
621620
#ifdef __EMSCRIPTEN__

tools/gen-elf-list-js.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,58 @@
11
#!/usr/bin/env python3
22

3+
# Formatted by black: https://github.com/psf/black
4+
35
import os
46

5-
def list_files(d):
7+
8+
def list_files(d, ignore_list=None):
9+
if ignore_list is None:
10+
ignore_list = []
611
try:
712
if d == "build":
8-
files = [f for f in os.listdir(d) if (os.path.isfile(os.path.join(d, f)) and f.endswith('.elf'))]
13+
files = [
14+
f
15+
for f in os.listdir(d)
16+
if os.path.isfile(os.path.join(d, f))
17+
and f.endswith(".elf")
18+
and not any(f.endswith(ign) or f.startswith(ign) for ign in ignore_list)
19+
]
920
else:
1021
parent_dir = os.path.dirname(d)
1122
files = [
1223
os.path.relpath(os.path.join(d, f), start=parent_dir)
1324
for f in os.listdir(d)
1425
if os.path.isfile(os.path.join(d, f))
26+
and not any(
27+
f.endswith(ign) or os.path.join(d, f).endswith(ign)
28+
for ign in ignore_list
29+
)
1530
]
1631
return files
1732
except FileNotFoundError:
18-
print(f"Directory {directory} not found.")
33+
print(f"Directory {d} not found.")
1934
return []
2035

36+
2137
elf_exec_dirs = ["build", "build/riscv32"]
38+
msg_less_ignore_files = [
39+
"cc.elf",
40+
"chacha20.elf",
41+
"riscv32/lena",
42+
"riscv32/puzzle",
43+
"riscv32/line",
44+
"riscv32/captcha",
45+
] # List of files to ignore
2246
elf_exec_list = []
2347

2448
for d in elf_exec_dirs:
25-
files = list_files(d)
49+
files = list_files(d, ignore_list=msg_less_ignore_files)
2650
elf_exec_list.extend(files)
27-
#print(elf_exec_list)
51+
2852

2953
def gen_elf_list_js():
3054
js_code = f"const elfFiles = {elf_exec_list};\n"
3155
print(js_code)
3256

57+
3358
gen_elf_list_js()

0 commit comments

Comments
 (0)