arm_entry_gcc.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2014-11-07 weety first version
  9. */
  10. #include <rtconfig.h>
  11. #include "armv6.h"
  12. //#define DEBUG
  13. .macro PRINT, str
  14. #ifdef DEBUG
  15. stmfd sp!, {r0-r3, ip, lr}
  16. add r0, pc, #4
  17. bl rt_kprintf
  18. b 1f
  19. .asciz "UNDEF: \str\n"
  20. .balign 4
  21. 1: ldmfd sp!, {r0-r3, ip, lr}
  22. #endif
  23. .endm
  24. .macro PRINT1, str, arg
  25. #ifdef DEBUG
  26. stmfd sp!, {r0-r3, ip, lr}
  27. mov r1, \arg
  28. add r0, pc, #4
  29. bl rt_kprintf
  30. b 1f
  31. .asciz "UNDEF: \str\n"
  32. .balign 4
  33. 1: ldmfd sp!, {r0-r3, ip, lr}
  34. #endif
  35. .endm
  36. .macro PRINT3, str, arg1, arg2, arg3
  37. #ifdef DEBUG
  38. stmfd sp!, {r0-r3, ip, lr}
  39. mov r3, \arg3
  40. mov r2, \arg2
  41. mov r1, \arg1
  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 get_current_thread, rd
  51. ldr \rd, .current_thread
  52. ldr \rd, [\rd]
  53. .endm
  54. .current_thread:
  55. .word rt_current_thread
  56. #ifdef RT_USING_NEON
  57. .align 6
  58. /* is the neon instuction on arm mode? */
  59. .neon_opcode:
  60. .word 0xfe000000 @ mask
  61. .word 0xf2000000 @ opcode
  62. .word 0xff100000 @ mask
  63. .word 0xf4000000 @ opcode
  64. .word 0x00000000 @ end mask
  65. .word 0x00000000 @ end opcode
  66. #endif
  67. /* undefined instruction exception processing */
  68. .globl undef_entry
  69. undef_entry:
  70. PRINT1 "r0=0x%08x", r0
  71. PRINT1 "r2=0x%08x", r2
  72. PRINT1 "r9=0x%08x", r9
  73. PRINT1 "sp=0x%08x", sp
  74. #ifdef RT_USING_NEON
  75. ldr r6, .neon_opcode
  76. __check_neon_instruction:
  77. ldr r7, [r6], #4 @ load mask value
  78. cmp r7, #0 @ end mask?
  79. beq __check_vfp_instruction
  80. and r8, r0, r7
  81. ldr r7, [r6], #4 @ load opcode value
  82. cmp r8, r7 @ is NEON instruction?
  83. bne __check_neon_instruction
  84. b vfp_entry
  85. __check_vfp_instruction:
  86. #endif
  87. tst r0, #0x08000000 @ only CDP/CPRT/LDC/STC instruction has bit 27
  88. tstne r0, #0x04000000 @ bit 26 set on both ARM and Thumb-2 instruction
  89. moveq pc, lr @ no vfp coprocessor instruction, return
  90. get_current_thread r10
  91. and r8, r0, #0x00000f00 @ get coprocessor number
  92. PRINT1 "CP=0x%08x", r8
  93. add pc, pc, r8, lsr #6
  94. nop
  95. mov pc, lr @ CP0
  96. mov pc, lr @ CP1
  97. mov pc, lr @ CP2
  98. mov pc, lr @ CP3
  99. mov pc, lr @ CP4
  100. mov pc, lr @ CP5
  101. mov pc, lr @ CP6
  102. mov pc, lr @ CP7
  103. mov pc, lr @ CP8
  104. mov pc, lr @ CP9
  105. mov pc, lr @ CP10 VFP
  106. mov pc, lr @ CP11 VFP
  107. mov pc, lr @ CP12
  108. mov pc, lr @ CP13
  109. mov pc, lr @ CP14 DEBUG
  110. mov pc, lr @ CP15 SYS CONTROL