cmn.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #include <pico/pico_int.h>
  10. #include "cmn.h"
  11. u8 __attribute__((aligned(4096))) tcache[DRC_TCACHE_SIZE];
  12. void drc_cmn_init(void)
  13. {
  14. int ret = plat_mem_set_exec(tcache, sizeof(tcache));
  15. elprintf(EL_STATUS, "drc_cmn_init: %p, %zd bytes: %d",
  16. tcache, sizeof(tcache), ret);
  17. #ifdef __arm__
  18. if (PicoOpt & POPT_EN_DRC)
  19. {
  20. static int test_done;
  21. if (!test_done)
  22. {
  23. int *test_out = (void *)tcache;
  24. int (*testfunc)(void) = (void *)tcache;
  25. elprintf(EL_STATUS, "testing if we can run recompiled code..");
  26. *test_out++ = 0xe3a000dd; // mov r0, 0xdd
  27. *test_out++ = 0xe12fff1e; // bx lr
  28. cache_flush_d_inval_i(tcache, test_out);
  29. // we'll usually crash on broken platforms or bad ports,
  30. // but do a value check too just in case
  31. ret = testfunc();
  32. elprintf(EL_STATUS, "test %s.", ret == 0xdd ? "passed" : "failed");
  33. test_done = 1;
  34. }
  35. }
  36. #endif
  37. }
  38. void drc_cmn_cleanup(void)
  39. {
  40. }
  41. // vim:shiftwidth=2:expandtab