arm_entry_gcc.S 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * File : arm_entry_gcc.S
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2014-11-07 weety first version
  23. */
  24. #include <rtconfig.h>
  25. #include "armv6.h"
  26. //#define DEBUG
  27. .macro PRINT, str
  28. #ifdef DEBUG
  29. stmfd sp!, {r0-r3, ip, lr}
  30. add r0, pc, #4
  31. bl rt_kprintf
  32. b 1f
  33. .asciz "UNDEF: \str\n"
  34. .balign 4
  35. 1: ldmfd sp!, {r0-r3, ip, lr}
  36. #endif
  37. .endm
  38. .macro PRINT1, str, arg
  39. #ifdef DEBUG
  40. stmfd sp!, {r0-r3, ip, lr}
  41. mov r1, \arg
  42. add r0, pc, #4
  43. bl rt_kprintf
  44. b 1f
  45. .asciz "UNDEF: \str\n"
  46. .balign 4
  47. 1: ldmfd sp!, {r0-r3, ip, lr}
  48. #endif
  49. .endm
  50. .macro PRINT3, str, arg1, arg2, arg3
  51. #ifdef DEBUG
  52. stmfd sp!, {r0-r3, ip, lr}
  53. mov r3, \arg3
  54. mov r2, \arg2
  55. mov r1, \arg1
  56. add r0, pc, #4
  57. bl rt_kprintf
  58. b 1f
  59. .asciz "UNDEF: \str\n"
  60. .balign 4
  61. 1: ldmfd sp!, {r0-r3, ip, lr}
  62. #endif
  63. .endm
  64. .macro get_current_thread, rd
  65. ldr \rd, .current_thread
  66. ldr \rd, [\rd]
  67. .endm
  68. .current_thread:
  69. .word rt_current_thread
  70. #ifdef RT_USING_NEON
  71. .align 6
  72. /* is the neon instuction on arm mode? */
  73. .neon_opcode:
  74. .word 0xfe000000 @ mask
  75. .word 0xf2000000 @ opcode
  76. .word 0xff100000 @ mask
  77. .word 0xf4000000 @ opcode
  78. .word 0x00000000 @ end mask
  79. .word 0x00000000 @ end opcode
  80. #endif
  81. /* undefined instruction exception processing */
  82. .globl undef_entry
  83. undef_entry:
  84. PRINT1 "r0=0x%08x", r0
  85. PRINT1 "r2=0x%08x", r2
  86. PRINT1 "r9=0x%08x", r9
  87. PRINT1 "sp=0x%08x", sp
  88. #ifdef RT_USING_NEON
  89. ldr r6, .neon_opcode
  90. __check_neon_instruction:
  91. ldr r7, [r6], #4 @ load mask value
  92. cmp r7, #0 @ end mask?
  93. beq __check_vfp_instruction
  94. and r8, r0, r7
  95. ldr r7, [r6], #4 @ load opcode value
  96. cmp r8, r7 @ is NEON instruction?
  97. bne __check_neon_instruction
  98. b vfp_entry
  99. __check_vfp_instruction:
  100. #endif
  101. tst r0, #0x08000000 @ only CDP/CPRT/LDC/STC instruction has bit 27
  102. tstne r0, #0x04000000 @ bit 26 set on both ARM and Thumb-2 instruction
  103. moveq pc, lr @ no vfp coprocessor instruction, return
  104. get_current_thread r10
  105. and r8, r0, #0x00000f00 @ get coprocessor number
  106. PRINT1 "CP=0x%08x", r8
  107. add pc, pc, r8, lsr #6
  108. nop
  109. mov pc, lr @ CP0
  110. mov pc, lr @ CP1
  111. mov pc, lr @ CP2
  112. mov pc, lr @ CP3
  113. mov pc, lr @ CP4
  114. mov pc, lr @ CP5
  115. mov pc, lr @ CP6
  116. mov pc, lr @ CP7
  117. mov pc, lr @ CP8
  118. mov pc, lr @ CP9
  119. mov pc, lr @ CP10 VFP
  120. mov pc, lr @ CP11 VFP
  121. mov pc, lr @ CP12
  122. mov pc, lr @ CP13
  123. mov pc, lr @ CP14 DEBUG
  124. mov pc, lr @ CP15 SYS CONTROL