(MSVC) Compatibility fixes
[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
ed06ffd3
T
13#ifdef _MSC_VER
14u8 tcache[DRC_TCACHE_SIZE];
15#else
f4bb5d6b 16u8 __attribute__((aligned(4096))) tcache[DRC_TCACHE_SIZE];
ed06ffd3 17#endif
41397701 18
19
20void drc_cmn_init(void)
21{
570dde61 22 int ret = plat_mem_set_exec(tcache, sizeof(tcache));
23 elprintf(EL_STATUS, "drc_cmn_init: %p, %zd bytes: %d",
24 tcache, sizeof(tcache), ret);
25
26#ifdef __arm__
0185b677 27 if (PicoOpt & POPT_EN_DRC)
570dde61 28 {
29 static int test_done;
30 if (!test_done)
31 {
32 int *test_out = (void *)tcache;
33 int (*testfunc)(void) = (void *)tcache;
34
35 elprintf(EL_STATUS, "testing if we can run recompiled code..");
36 *test_out++ = 0xe3a000dd; // mov r0, 0xdd
37 *test_out++ = 0xe12fff1e; // bx lr
38 cache_flush_d_inval_i(tcache, test_out);
39
40 // we'll usually crash on broken platforms or bad ports,
41 // but do a value check too just in case
42 ret = testfunc();
43 elprintf(EL_STATUS, "test %s.", ret == 0xdd ? "passed" : "failed");
44 test_done = 1;
45 }
46 }
47#endif
41397701 48}
49
41397701 50void drc_cmn_cleanup(void)
51{
41397701 52}
570dde61 53
54// vim:shiftwidth=2:expandtab