| 1 | /* |
| 2 | * PicoDrive |
| 3 | * Copyright (C) 2009,2010 notaz |
| 4 | * |
| 5 | * This work is licensed under the terms of MAME license. |
| 6 | * See COPYING file in the top-level directory. |
| 7 | */ |
| 8 | #include <stdio.h> |
| 9 | |
| 10 | #include <pico/pico_int.h> |
| 11 | #include "cmn.h" |
| 12 | |
| 13 | u8 __attribute__((aligned(4096))) tcache[DRC_TCACHE_SIZE]; |
| 14 | |
| 15 | |
| 16 | void drc_cmn_init(void) |
| 17 | { |
| 18 | int ret = plat_mem_set_exec(tcache, sizeof(tcache)); |
| 19 | elprintf(EL_STATUS, "drc_cmn_init: %p, %zd bytes: %d", |
| 20 | tcache, sizeof(tcache), ret); |
| 21 | |
| 22 | #ifdef __arm__ |
| 23 | if (PicoOpt & POPT_EN_DRC) |
| 24 | { |
| 25 | static int test_done; |
| 26 | if (!test_done) |
| 27 | { |
| 28 | int *test_out = (void *)tcache; |
| 29 | int (*testfunc)(void) = (void *)tcache; |
| 30 | |
| 31 | elprintf(EL_STATUS, "testing if we can run recompiled code.."); |
| 32 | *test_out++ = 0xe3a000dd; // mov r0, 0xdd |
| 33 | *test_out++ = 0xe12fff1e; // bx lr |
| 34 | cache_flush_d_inval_i(tcache, test_out); |
| 35 | |
| 36 | // we'll usually crash on broken platforms or bad ports, |
| 37 | // but do a value check too just in case |
| 38 | ret = testfunc(); |
| 39 | elprintf(EL_STATUS, "test %s.", ret == 0xdd ? "passed" : "failed"); |
| 40 | test_done = 1; |
| 41 | } |
| 42 | } |
| 43 | #endif |
| 44 | } |
| 45 | |
| 46 | void drc_cmn_cleanup(void) |
| 47 | { |
| 48 | } |
| 49 | |
| 50 | // vim:shiftwidth=2:expandtab |