X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2Fdrc%2Fcmn.c;h=3f174a0311d955d6c81d4b4e0ec0911d282add88;hb=93f9619ed819dee07948416c98ca2f1c70a22666;hp=1f15a0f3d6bd6d8810d7d22a3314acbe5cc9abc1;hpb=41397701210c08b9d25ca66cbe372c7ed86d6927;p=picodrive.git diff --git a/cpu/drc/cmn.c b/cpu/drc/cmn.c index 1f15a0f..3f174a0 100644 --- a/cpu/drc/cmn.c +++ b/cpu/drc/cmn.c @@ -1,36 +1,56 @@ +/* + * PicoDrive + * Copyright (C) 2009,2010 notaz + * + * This work is licensed under the terms of MAME license. + * See COPYING file in the top-level directory. + */ #include -#if defined(__linux__) && defined(ARM) -#include -#endif +#include #include "cmn.h" -#ifndef ARM -unsigned int tcache[SSP_TCACHE_SIZE/4]; -unsigned int *ssp_block_table[0x5090/2]; -unsigned int *ssp_block_table_iram[15][0x800/2]; -char ssp_align[SSP_BLOCKTAB_ALIGN_SIZE]; -#endif - +u8 ALIGNED(4096) tcache_default[DRC_TCACHE_SIZE]; +u8 *tcache; void drc_cmn_init(void) { -#if defined(__linux__) && defined(ARM) - void *tmp; - - tmp = mmap(tcache, SSP_DRC_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED|MAP_ANONYMOUS, -1, 0); - printf("mmap tcache: %p, asked %p\n", tmp, tcache); + int ret; + + tcache = plat_mem_get_for_drc(DRC_TCACHE_SIZE); + if (tcache == NULL) + tcache = tcache_default; + + ret = plat_mem_set_exec(tcache, DRC_TCACHE_SIZE); + elprintf(EL_STATUS, "drc_cmn_init: %p, %zd bytes: %d", + tcache, DRC_TCACHE_SIZE, ret); + +#ifdef __arm__ + if (PicoIn.opt & 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 - } -// TODO: add calls in core, possibly to cart.c? void drc_cmn_cleanup(void) { -#if defined(__linux__) && defined(ARM) - int ret; - ret = munmap(tcache, SSP_DRC_SIZE); - printf("munmap tcache: %i\n", ret); -#endif } +// vim:shiftwidth=2:expandtab