- tmp = mmap(tcache, DRC_TCACHE_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
- printf("mmap tcache: %p, asked %p\n", tmp, tcache);
+#ifdef __arm__
+ if (PicoOpt & POPT_EN_DRC)
+ {
+ static int test_done;
+ if (!test_done)
+ {
+ int *test_out = (void *)tcache;
+ int (*testfunc)(void) = (void *)tcache;
+
+ elprintf(EL_STATUS, "testing if we can run recompiled code..");
+ *test_out++ = 0xe3a000dd; // mov r0, 0xdd
+ *test_out++ = 0xe12fff1e; // bx lr
+ cache_flush_d_inval_i(tcache, test_out);
+
+ // we'll usually crash on broken platforms or bad ports,
+ // but do a value check too just in case
+ ret = testfunc();
+ elprintf(EL_STATUS, "test %s.", ret == 0xdd ? "passed" : "failed");
+ test_done = 1;
+ }
+ }