cmn.c 1.3 KB

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