mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
drc: do a test on startup
saves time for porting help
This commit is contained in:
parent
2dbc96b1c7
commit
570dde615d
1 changed files with 28 additions and 2 deletions
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include <pico/pico.h>
|
||||
#include <pico/pico_int.h>
|
||||
#include "cmn.h"
|
||||
|
||||
u8 __attribute__((aligned(4096))) tcache[DRC_TCACHE_SIZE];
|
||||
|
@ -15,9 +15,35 @@ u8 __attribute__((aligned(4096))) tcache[DRC_TCACHE_SIZE];
|
|||
|
||||
void drc_cmn_init(void)
|
||||
{
|
||||
plat_mem_set_exec(tcache, sizeof(tcache));
|
||||
int ret = plat_mem_set_exec(tcache, sizeof(tcache));
|
||||
elprintf(EL_STATUS, "drc_cmn_init: %p, %zd bytes: %d",
|
||||
tcache, sizeof(tcache), ret);
|
||||
|
||||
#ifdef __arm__
|
||||
{
|
||||
static int test_done;
|
||||
if (!test_done)
|
||||
{
|
||||
int *test_out = (void *)tcache;
|
||||
int (*testfunc)(void) = (void *)tcache;
|
||||
|
||||
elprintf(EL_STATUS, "testing if we can run recompiled code..");
|
||||
*test_out++ = 0xe3a000dd; // mov r0, 0xdd
|
||||
*test_out++ = 0xe12fff1e; // bx lr
|
||||
cache_flush_d_inval_i(tcache, test_out);
|
||||
|
||||
// we'll usually crash on broken platforms or bad ports,
|
||||
// but do a value check too just in case
|
||||
ret = testfunc();
|
||||
elprintf(EL_STATUS, "test %s.", ret == 0xdd ? "passed" : "failed");
|
||||
test_done = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void drc_cmn_cleanup(void)
|
||||
{
|
||||
}
|
||||
|
||||
// vim:shiftwidth=2:expandtab
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue