rearrange globals
[picodrive.git] / cpu / drc / cmn.c
CommitLineData
cff531af 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 */
41397701 8#include <stdio.h>
41397701 9
570dde61 10#include <pico/pico_int.h>
41397701 11#include "cmn.h"
12
df925153 13u8 ALIGNED(4096) tcache_default[DRC_TCACHE_SIZE];
14u8 *tcache;
41397701 15
16void drc_cmn_init(void)
17{
df925153 18 int ret;
19
20 tcache = plat_mem_get_for_drc(DRC_TCACHE_SIZE);
21 if (tcache == NULL)
22 tcache = tcache_default;
23
24 ret = plat_mem_set_exec(tcache, DRC_TCACHE_SIZE);
570dde61 25 elprintf(EL_STATUS, "drc_cmn_init: %p, %zd bytes: %d",
df925153 26 tcache, DRC_TCACHE_SIZE, ret);
570dde61 27
28#ifdef __arm__
93f9619e 29 if (PicoIn.opt & POPT_EN_DRC)
570dde61 30 {
31 static int test_done;
32 if (!test_done)
33 {
34 int *test_out = (void *)tcache;
35 int (*testfunc)(void) = (void *)tcache;
36
37 elprintf(EL_STATUS, "testing if we can run recompiled code..");
38 *test_out++ = 0xe3a000dd; // mov r0, 0xdd
39 *test_out++ = 0xe12fff1e; // bx lr
40 cache_flush_d_inval_i(tcache, test_out);
41
42 // we'll usually crash on broken platforms or bad ports,
43 // but do a value check too just in case
44 ret = testfunc();
45 elprintf(EL_STATUS, "test %s.", ret == 0xdd ? "passed" : "failed");
46 test_done = 1;
47 }
48 }
49#endif
41397701 50}
51
41397701 52void drc_cmn_cleanup(void)
53{
41397701 54}
570dde61 55
56// vim:shiftwidth=2:expandtab