Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Merge the stage-2 runtime-profile experiment into main (launcher architecture B's foundation)

LNPANDY3b36083ff757
diff --git a/dm/host/tests/Makefile b/dm/host/tests/Makefile
index 667509a7..0fe4b71f 100644
--- a/dm/host/tests/Makefile
+++ b/dm/host/tests/Makefile
@@ -39,8 +39,8 @@ run: $(B)/t_heap_size $(B)/t_touch $(B)/t_gesture $(B)/t_oe $(B)/t_fs $(B)/t_fs_
$(B)/t_symbols
run: $(B)/t_nro
run: $(B)/t_symbols
-$(B)/t_symbols: t_symbols.c ../hle.c ../loader.c ../hle.h ../dm.h $(GAME_H) | $(B)
- clang -O1 -g -Wall -Werror -Wno-unused-function -Wno-deprecated-declarations -I.. $(GINC) -o $@ t_symbols.c
+$(B)/t_symbols: t_symbols.c ../hle.c ../loader.c ../hle.h ../dm.h $(GAME_H) ../hle_profile.c ../hle_profile.h | $(B)
+ clang -O1 -g -Wall -Werror -Wno-unused-function -Wno-deprecated-declarations -I.. $(GINC) -o $@ t_symbols.c ../hle_profile.c
.PHONY: symbols
symbols: $(B)/t_symbols
$(B)/t_symbols
@@ -75,16 +75,16 @@ $(B)/t_gesture: t_gesture.c ../hle_touch.c ../front.h ../dm.h $(GAME_H) ../hle_p
$(B)/t_thread_leak: t_thread_leak.c ../thread.c ../dm.h $(GAME_H) ../hle_profile.c ../hle_profile.h | $(B)
clang -O1 -Wno-unused-function -I.. $(GINC) -o $@ t_thread_leak.c
$(B)/t_fs: t_fs.c t_fs_stub.c ../hle_fs.c ../hle_bigstack.c ../romfs_arc.c ../hle.h ../dm.h $(GAME_H) ../hle_profile.c ../hle_profile.h | $(B)
- clang -O1 -Wno-unused-function -I.. $(GINC) -o $@ t_fs.c t_fs_stub.c ../hle_bigstack.c ../romfs_arc.c
+ clang -O1 -Wno-unused-function -I.. $(GINC) -o $@ t_fs.c t_fs_stub.c ../hle_bigstack.c ../romfs_arc.c ../hle_profile.c
$(B)/t_fs_commit_list: t_fs_commit_list.c t_fs_stub.c ../hle_fs.c ../hle_bigstack.c ../romfs_arc.c ../hle.h ../dm.h $(GAME_H) ../hle_profile.c ../hle_profile.h | $(B)
- clang -O1 -Wall -Wno-unused-function -I.. $(GINC) -o $@ t_fs_commit_list.c t_fs_stub.c ../hle_bigstack.c ../romfs_arc.c
+ clang -O1 -Wall -Wno-unused-function -I.. $(GINC) -o $@ t_fs_commit_list.c t_fs_stub.c ../hle_bigstack.c ../romfs_arc.c ../hle_profile.c
$(B)/t_fs_commit_list_tsan: t_fs_commit_list.c t_fs_stub.c ../hle_fs.c ../hle_bigstack.c ../hle.h ../dm.h $(GAME_H) ../hle_profile.c ../hle_profile.h | $(B)
- clang -O1 -g -fsanitize=thread -Wall -Wno-unused-function -I.. $(GINC) -o $@ t_fs_commit_list.c t_fs_stub.c ../hle_bigstack.c
+ clang -O1 -g -fsanitize=thread -Wall -Wno-unused-function -I.. $(GINC) -o $@ t_fs_commit_list.c t_fs_stub.c ../hle_bigstack.c ../hle_profile.c
.PHONY: fs-tsan
fs-tsan: $(B)/t_fs_commit_list_tsan
TMPDIR="$(abspath $(B))" $(B)/t_fs_commit_list_tsan
$(B)/t_fs_case: t_fs_case.c ../hle_fs.c ../hle_bigstack.c ../romfs_arc.c ../hle.h ../dm.h $(GAME_H) ../hle_profile.c ../hle_profile.h | $(B)
- clang -O1 -Wno-unused-function -I.. $(GINC) -o $@ t_fs_case.c ../hle_bigstack.c ../romfs_arc.c
+ clang -O1 -Wno-unused-function -I.. $(GINC) -o $@ t_fs_case.c ../hle_bigstack.c ../romfs_arc.c ../hle_profile.c
$(B)/t_audio: t_audio.c ../hle_audio.c ../hle.h ../dm.h $(GAME_H) | $(B)
clang -O1 -Wno-unused-function -I.. $(GINC) -o $@ t_audio.c -framework AudioToolbox
$(B)/t_audio_spsc: t_audio_spsc.c ../hle_audio.c ../hle.h ../dm.h $(GAME_H) ../hle_profile.c ../hle_profile.h | $(B)
@@ -98,8 +98,8 @@ run: audio-device
$(B)/t_audio_spsc_tsan: t_audio_spsc.c ../hle_audio.c ../hle.h ../dm.h $(GAME_H) | $(B)
clang -O1 -g -O1 -fsanitize=thread -Wno-unused-function -I.. $(GINC) -o $@ t_audio_spsc.c -framework AudioToolbox
run: $(B)/t_fpslock
-$(B)/t_fpslock: t_fpslock.c ../hle_fpslock.c ../hle.h ../dm.h $(GAME_H) | $(B)
- clang -O1 -g -Wno-unused-function $(GINC) -o $@ t_fpslock.c
+$(B)/t_fpslock: t_fpslock.c ../hle_fpslock.c ../hle.h ../dm.h $(GAME_H) ../hle_profile.c ../hle_profile.h | $(B)
+ clang -O1 -g -Wno-unused-function $(GINC) -o $@ t_fpslock.c ../hle_profile.c
$(B)/t_swkbd: t_swkbd.c ../hle_swkbd.c ../hle.h ../dm.h $(GAME_H) | $(B)
clang -O1 -Wno-unused-function -I.. $(GINC) -o $@ t_swkbd.c ../hle_swkbd.c
$(B)/t_altstack: t_altstack.c t_altstack_stub.c ../crash.c ../dm.h $(GAME_H) | $(B)
@@ -177,8 +177,8 @@ memory-profile: $(B)/t_svc_memory
run: memory memory-dirty memory-profile
# A native blocking notification wait must release the thread's guest core.
-$(B)/t_notify_sched: t_notify_sched.c t_condvar_stub.c ../hle_thread.c ../hle_oe.c ../hle.h ../dm.h $(GAME_H) | $(B)
- clang -O1 -g -Wall -Werror -Wno-unused-function -DDM_TEST_THREAD_ENTER -I.. $(GINC) -o $@ t_notify_sched.c t_condvar_stub.c
+$(B)/t_notify_sched: t_notify_sched.c t_condvar_stub.c ../hle_thread.c ../hle_oe.c ../hle.h ../dm.h $(GAME_H) ../hle_profile.c ../hle_profile.h | $(B)
+ clang -O1 -g -Wall -Werror -Wno-unused-function -DDM_TEST_THREAD_ENTER -I.. $(GINC) -o $@ t_notify_sched.c t_condvar_stub.c ../hle_profile.c
.PHONY: notify-scheduler
notify-scheduler: $(B)/t_notify_sched
$(B)/t_notify_sched
diff --git a/dm/host/tests/layout_13s.tsv b/dm/host/tests/layout_13s.tsv
new file mode 100644
index 00000000..36b0d1ea
--- /dev/null
+++ b/dm/host/tests/layout_13s.tsv
@@ -0,0 +1,9 @@
+# generated by t_layout_runtime: the case table above is the source of truth
+name 13s (runtime layout test)
+mem_reserve 0x140000000
+mem_alias 0x118000000
+mem_stack 0x10000000
+app_pool 0x40000000
+mem_used 0x4000000
+sys_resource 0x1000000
+mem_map_limit 1
diff --git a/dm/host/tests/layout_acnh.tsv b/dm/host/tests/layout_acnh.tsv
new file mode 100644
index 00000000..334cad37
--- /dev/null
+++ b/dm/host/tests/layout_acnh.tsv
@@ -0,0 +1,9 @@
+# generated by t_layout_runtime: the case table above is the source of truth
+name acnh (runtime layout test)
+mem_reserve 0x100000000
+mem_alias 0x10000000
+mem_stack 0x10000000
+app_pool 0xcd500000
+mem_used 0x7a00000
+sys_resource 0
+mem_map_limit 0
diff --git a/dm/host/tests/layout_smg.tsv b/dm/host/tests/layout_smg.tsv
new file mode 100644
index 00000000..558073c0
--- /dev/null
+++ b/dm/host/tests/layout_smg.tsv
@@ -0,0 +1,9 @@
+# generated by t_layout_runtime: the case table above is the source of truth
+name smg (runtime layout test)
+mem_reserve 0x40000000
+mem_alias 0x10000000
+mem_stack 0x10000000
+app_pool 0xcd500000
+mem_used 0x4000000
+sys_resource 0
+mem_map_limit 1
diff --git a/dm/host/tests/layout_totk.tsv b/dm/host/tests/layout_totk.tsv
new file mode 100644
index 00000000..6bfcb22e
--- /dev/null
+++ b/dm/host/tests/layout_totk.tsv
@@ -0,0 +1,9 @@
+# generated by t_layout_runtime: the case table above is the source of truth
+name totk (runtime layout test)
+mem_reserve 0x140000000
+mem_alias 0x98000000
+mem_stack 0x10000000
+app_pool 0xcd500000
+mem_used 0x4000000
+sys_resource 0x2000000
+mem_map_limit 0
diff --git a/dm/host/tests/t_layout_runtime.c b/dm/host/tests/t_layout_runtime.c
index ab581a44..20b210d4 100644
--- a/dm/host/tests/t_layout_runtime.c
+++ b/dm/host/tests/t_layout_runtime.c
@@ -7,6 +7,7 @@
#include <assert.h>
#include <sys/wait.h>
#include <unistd.h>
+#include <errno.h>
module_t g_mod[MAX_MOD];
int g_nmod;
@@ -72,6 +73,24 @@ int main(int argc, char **argv) {
for (int i = 0; i < NCASES; i++) if (!strcmp(argv[1], CASES[i].name)) return child(&CASES[i]);
return 2;
}
+ // Write each case's profile where the child will find it (the profile loader takes a path in
+ // DM_PROFILE and reads game.tsv's key/value form). Generated here rather than committed: the
+ // values live in CASES above, and a fixture that can drift from them is a test that lies.
+ for (int i = 0; i < NCASES; i++) {
+ char path[256]; snprintf(path, sizeof path, "layout_%s.tsv", CASES[i].name);
+ FILE *f = fopen(path, "w");
+ if (!f) { printf("[RED] cannot write %s (errno %d)\n", path, errno); return 1; }
+ fprintf(f, "# generated by t_layout_runtime: the case table above is the source of truth\n");
+ fprintf(f, "name %s (runtime layout test)\n", CASES[i].name);
+ fprintf(f, "mem_reserve %#llx\n", (unsigned long long)CASES[i].reserve);
+ fprintf(f, "mem_alias %#llx\n", (unsigned long long)CASES[i].alias);
+ fprintf(f, "mem_stack %#llx\n", (unsigned long long)CASES[i].stack);
+ fprintf(f, "app_pool %#llx\n", (unsigned long long)CASES[i].pool);
+ fprintf(f, "mem_used %#llx\n", (unsigned long long)CASES[i].used);
+ fprintf(f, "sys_resource %#llx\n", (unsigned long long)CASES[i].sysres);
+ fprintf(f, "mem_map_limit %d\n", CASES[i].limit);
+ fclose(f);
+ }
int bad = 0;
for (int i = 0; i < NCASES; i++) {
pid_t pid = fork();