Commit | Line | Data |
---|---|---|
cff531af | 1 | /* |
2 | * PicoDrive | |
3 | * Copyright (C) 2009,2010 notaz | |
0d87bd6a | 4 | * Copyright (C) 2016 lentillog |
5 | * Copyright (C) 2016 Daniel De Matteis | |
cff531af | 6 | * |
7 | * This work is licensed under the terms of MAME license. | |
8 | * See COPYING file in the top-level directory. | |
9 | */ | |
41397701 | 10 | #include <stdio.h> |
41397701 | 11 | |
570dde61 | 12 | #include <pico/pico_int.h> |
41397701 | 13 | #include "cmn.h" |
14 | ||
ed06ffd3 T |
15 | #ifdef _MSC_VER |
16 | u8 tcache[DRC_TCACHE_SIZE]; | |
88f7643f | 17 | #elif defined(VITA) |
18 | #include <psp2/kernel/sysmem.h> | |
19 | u8 *tcache; | |
20 | static int sceBlock; | |
21 | int getVMBlock(); | |
ed06ffd3 | 22 | #else |
f4bb5d6b | 23 | u8 __attribute__((aligned(4096))) tcache[DRC_TCACHE_SIZE]; |
ed06ffd3 | 24 | #endif |
41397701 | 25 | |
26 | ||
27 | void drc_cmn_init(void) | |
28 | { | |
88f7643f | 29 | #ifdef VITA |
30 | sceBlock = getVMBlock(); | |
31 | sceKernelGetMemBlockBase(sceBlock, (void **)&tcache); | |
32 | #endif | |
33 | ||
570dde61 | 34 | int ret = plat_mem_set_exec(tcache, sizeof(tcache)); |
35 | elprintf(EL_STATUS, "drc_cmn_init: %p, %zd bytes: %d", | |
36 | tcache, sizeof(tcache), ret); | |
37 | ||
38 | #ifdef __arm__ | |
0185b677 | 39 | if (PicoOpt & POPT_EN_DRC) |
570dde61 | 40 | { |
41 | static int test_done; | |
42 | if (!test_done) | |
43 | { | |
44 | int *test_out = (void *)tcache; | |
45 | int (*testfunc)(void) = (void *)tcache; | |
46 | ||
47 | elprintf(EL_STATUS, "testing if we can run recompiled code.."); | |
48 | *test_out++ = 0xe3a000dd; // mov r0, 0xdd | |
49 | *test_out++ = 0xe12fff1e; // bx lr | |
50 | cache_flush_d_inval_i(tcache, test_out); | |
51 | ||
52 | // we'll usually crash on broken platforms or bad ports, | |
53 | // but do a value check too just in case | |
54 | ret = testfunc(); | |
55 | elprintf(EL_STATUS, "test %s.", ret == 0xdd ? "passed" : "failed"); | |
56 | test_done = 1; | |
57 | } | |
58 | } | |
59 | #endif | |
41397701 | 60 | } |
61 | ||
41397701 | 62 | void drc_cmn_cleanup(void) |
63 | { | |
41397701 | 64 | } |
570dde61 | 65 | |
66 | // vim:shiftwidth=2:expandtab |