arm_dyncom_run.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Copyright (C)
  2. * 2011 - Michael.Kang blackfin.kang@gmail.com
  3. * This program is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU General Public License
  5. * as published by the Free Software Foundation; either version 2
  6. * of the License, or (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. *
  17. */
  18. #pragma once
  19. void switch_mode(ARMul_State* core, uint32_t mode);
  20. /* FIXME, we temporarily think thumb instruction is always 16 bit */
  21. static inline u32 GET_INST_SIZE(ARMul_State* core) {
  22. return core->TFlag? 2 : 4;
  23. }
  24. /**
  25. * @brief Read R15 and forced R15 to wold align, used address calculation
  26. *
  27. * @param core
  28. * @param Rn
  29. *
  30. * @return
  31. */
  32. static inline addr_t CHECK_READ_REG15_WA(ARMul_State* core, int Rn) {
  33. return (Rn == 15)? ((core->Reg[15] & ~0x3) + GET_INST_SIZE(core) * 2) : core->Reg[Rn];
  34. }
  35. /**
  36. * @brief Read R15, used to data processing with pc
  37. *
  38. * @param core
  39. * @param Rn
  40. *
  41. * @return
  42. */
  43. static inline u32 CHECK_READ_REG15(ARMul_State* core, int Rn) {
  44. return (Rn == 15)? ((core->Reg[15] & ~0x1) + GET_INST_SIZE(core) * 2) : core->Reg[Rn];
  45. }