X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2Fdrc%2Fcmn.c;h=a07dcbddff53a6747d8d35a27c3ffe4488a829cf;hb=ed06ffd3391ff81fa1f34455f1311ba060a41cac;hp=91bd7eddab428098bfce0d185559e1597cb80133;hpb=c25d78eec11d2a22adbd0bc7d42a24e2d79e40e7;p=picodrive.git diff --git a/cpu/drc/cmn.c b/cpu/drc/cmn.c index 91bd7ed..a07dcbd 100644 --- a/cpu/drc/cmn.c +++ b/cpu/drc/cmn.c @@ -7,17 +7,48 @@ */ #include -#include +#include #include "cmn.h" +#ifdef _MSC_VER +u8 tcache[DRC_TCACHE_SIZE]; +#else u8 __attribute__((aligned(4096))) tcache[DRC_TCACHE_SIZE]; +#endif void drc_cmn_init(void) { - plat_mem_set_exec(tcache, sizeof(tcache)); + int ret = plat_mem_set_exec(tcache, sizeof(tcache)); + elprintf(EL_STATUS, "drc_cmn_init: %p, %zd bytes: %d", + tcache, sizeof(tcache), ret); + +#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; + } + } +#endif } void drc_cmn_cleanup(void) { } + +// vim:shiftwidth=2:expandtab