arm_dyncom_run.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef __ARM_DYNCOM_RUN__
  19. #define __ARM_DYNCOM_RUN__
  20. void switch_mode(arm_core_t *core, uint32_t mode);
  21. /* FIXME, we temporarily think thumb instruction is always 16 bit */
  22. static inline u32 GET_INST_SIZE(arm_core_t* core) {
  23. return core->TFlag? 2 : 4;
  24. }
  25. /**
  26. * @brief Read R15 and forced R15 to wold align, used address calculation
  27. *
  28. * @param core
  29. * @param Rn
  30. *
  31. * @return
  32. */
  33. static inline addr_t CHECK_READ_REG15_WA(arm_core_t* core, int Rn) {
  34. return (Rn == 15)? ((core->Reg[15] & ~0x3) + GET_INST_SIZE(core) * 2) : core->Reg[Rn];
  35. }
  36. /**
  37. * @brief Read R15, used to data processing with pc
  38. *
  39. * @param core
  40. * @param Rn
  41. *
  42. * @return
  43. */
  44. static inline u32 CHECK_READ_REG15(arm_core_t* core, int Rn) {
  45. return (Rn == 15)? ((core->Reg[15] & ~0x1) + GET_INST_SIZE(core) * 2) : core->Reg[Rn];
  46. }
  47. #endif