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