platform ps2, handle audio similar to psp
[picodrive.git] / cpu / drc / cmn.c
... / ...
CommitLineData
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#if defined(__linux__) && (defined(__aarch64__) || defined(__VFP_FP__))
14// might be running on a 64k-page kernel
15#define PICO_PAGE_ALIGN 65536
16#else
17#define PICO_PAGE_ALIGN 4096
18#endif
19u8 ALIGNED(PICO_PAGE_ALIGN) tcache_default[DRC_TCACHE_SIZE];
20u8 *tcache;
21
22void drc_cmn_init(void)
23{
24 int ret;
25
26 tcache = plat_mem_get_for_drc(DRC_TCACHE_SIZE);
27 if (tcache == NULL)
28 tcache = tcache_default;
29
30 ret = plat_mem_set_exec(tcache, DRC_TCACHE_SIZE);
31 elprintf(EL_STATUS, "drc_cmn_init: %p, %zd bytes: %d",
32 tcache, DRC_TCACHE_SIZE, ret);
33
34#ifdef __arm__
35 if (PicoIn.opt & POPT_EN_DRC)
36 {
37 static int test_done;
38 if (!test_done)
39 {
40 int *test_out = (void *)tcache;
41 int (*testfunc)(void) = (void *)tcache;
42
43 elprintf(EL_STATUS, "testing if we can run recompiled code..");
44 *test_out++ = 0xe3a000dd; // mov r0, 0xdd
45 *test_out++ = 0xe12fff1e; // bx lr
46 cache_flush_d_inval_i(tcache, test_out);
47
48 // we'll usually crash on broken platforms or bad ports,
49 // but do a value check too just in case
50 ret = testfunc();
51 elprintf(EL_STATUS, "test %s.", ret == 0xdd ? "passed" : "failed");
52 test_done = 1;
53 }
54 }
55#endif
56}
57
58void drc_cmn_cleanup(void)
59{
60}
61
62// vim:shiftwidth=2:expandtab