Skip to content

Commit c429166

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 667a4fa commit c429166

File tree

7 files changed

+31
-262
lines changed

7 files changed

+31
-262
lines changed

assets/html/index.html

-243
This file was deleted.

assets/js/coi-serviceworker.min.js

-2
This file was deleted.

assets/js/pre.js

-9
This file was deleted.

mk/wasm.mk

+2-2
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

+1
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

-1
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

+28-5
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,55 @@
22

33
import os
44

5-
def list_files(d):
5+
6+
def list_files(d, ignore_list=None):
7+
if ignore_list is None:
8+
ignore_list = []
69
try:
710
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'))]
11+
files = [
12+
f
13+
for f in os.listdir(d)
14+
if os.path.isfile(os.path.join(d, f))
15+
and f.endswith(".elf")
16+
and not any(f.endswith(ign) or f.startswith(ign) for ign in ignore_list)
17+
]
918
else:
1019
parent_dir = os.path.dirname(d)
1120
files = [
1221
os.path.relpath(os.path.join(d, f), start=parent_dir)
1322
for f in os.listdir(d)
1423
if os.path.isfile(os.path.join(d, f))
24+
and not any(
25+
f.endswith(ign) or os.path.join(d, f).endswith(ign)
26+
for ign in ignore_list
27+
)
1528
]
1629
return files
1730
except FileNotFoundError:
18-
print(f"Directory {directory} not found.")
31+
print(f"Directory {d} not found.")
1932
return []
2033

34+
2135
elf_exec_dirs = ["build", "build/riscv32"]
36+
msg_less_ignore_files = [
37+
"cc.elf",
38+
"chacha20.elf",
39+
"riscv32/lena",
40+
"riscv32/puzzle",
41+
"riscv32/line",
42+
"riscv32/captcha",
43+
] # List of files to ignore
2244
elf_exec_list = []
2345

2446
for d in elf_exec_dirs:
25-
files = list_files(d)
47+
files = list_files(d, ignore_list=msg_less_ignore_files)
2648
elf_exec_list.extend(files)
27-
#print(elf_exec_list)
49+
2850

2951
def gen_elf_list_js():
3052
js_code = f"const elfFiles = {elf_exec_list};\n"
3153
print(js_code)
3254

55+
3356
gen_elf_list_js()

0 commit comments

Comments
 (0)