entry-header.S
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #include <linux/config.h> /* for CONFIG_ARCH_xxxx */
  2. #include <linux/linkage.h>
  3. #include <asm/assembler.h>
  4. #include <asm/constants.h>
  5. #include <asm/errno.h>
  6. #include <asm/hardware.h>
  7. #include <asm/arch/irqs.h>
  8. #include <asm/proc-fns.h>
  9. #ifndef MODE_SVC
  10. #define MODE_SVC 0x13
  11. #endif
  12. .macro zero_fp
  13. #ifdef CONFIG_FRAME_POINTER
  14. mov fp, #0
  15. #endif
  16. .endm
  17. .text
  18. @ Bad Abort numbers
  19. @ -----------------
  20. @
  21. #define BAD_PREFETCH 0
  22. #define BAD_DATA 1
  23. #define BAD_ADDREXCPTN 2
  24. #define BAD_IRQ 3
  25. #define BAD_UNDEFINSTR 4
  26. #define PT_TRACESYS 0x00000002
  27. @ OS version number used in SWIs
  28. @  RISC OS is 0
  29. @  RISC iX is 8
  30. @
  31. #define OS_NUMBER 9
  32. #define ARMSWI_OFFSET 0x000f0000
  33. @
  34. @ Stack format (ensured by USER_* and SVC_*)
  35. @
  36. #define S_FRAME_SIZE 72
  37. #ifdef CONFIG_CPU_32
  38. #define S_OLD_R0 68
  39. #define S_PSR 64
  40. #else
  41. #define S_OLD_R0 64
  42. #define S_PSR 60
  43. #define S_PC 60
  44. #endif
  45. #define S_PC 60
  46. #define S_LR 56
  47. #define S_SP 52
  48. #define S_IP 48
  49. #define S_FP 44
  50. #define S_R10 40
  51. #define S_R9 36
  52. #define S_R8 32
  53. #define S_R7 28
  54. #define S_R6 24
  55. #define S_R5 20
  56. #define S_R4 16
  57. #define S_R3 12
  58. #define S_R2 8
  59. #define S_R1 4
  60. #define S_R0 0
  61. #define S_OFF 8
  62. #ifdef CONFIG_CPU_32
  63. .macro save_user_regs
  64. sub sp, sp, #S_FRAME_SIZE
  65. stmia sp, {r0 - r12} @ Calling r0 - r12
  66. add r8, sp, #S_PC
  67. stmdb r8, {sp, lr}^ @ Calling sp, lr
  68. mrs r8, spsr @ called from non-FIQ mode, so ok.
  69. str lr, [sp, #S_PC] @ Save calling PC
  70. str r8, [sp, #S_PSR] @ Save CPSR
  71. str r0, [sp, #S_OLD_R0] @ Save OLD_R0
  72. .endm
  73. .macro restore_user_regs
  74. ldr r0, [sp, #S_PSR] @ Get calling cpsr
  75. mov ip, #I_BIT | MODE_SVC
  76. msr cpsr_c, ip @ disable IRQs
  77. msr spsr, r0 @ save in spsr_svc
  78. ldr lr, [sp, #S_PC] @ Get PC
  79. ldmia sp, {r0 - lr}^ @ Get calling r0 - lr
  80. mov r0, r0
  81. add sp, sp, #S_FRAME_SIZE
  82. movs pc, lr @ return & move spsr_svc into cpsr
  83. .endm
  84. .macro fast_restore_user_regs
  85. mov ip, #I_BIT | MODE_SVC
  86. msr cpsr_c, ip @ disable IRQs
  87. ldr r1, [sp, #S_OFF + S_PSR] @ get calling cpsr
  88. ldr lr, [sp, #S_OFF + S_PC]! @ get pc
  89.   msr spsr, r1 @ save in spsr_svc
  90. ldmdb sp, {r1 - lr}^ @ get calling r1 - lr
  91. mov r0, r0
  92. add sp, sp, #S_FRAME_SIZE - S_PC
  93. movs pc, lr @ return & move spsr_svc into cpsr
  94. .endm
  95. .macro mask_pc, rd, rm
  96. .endm
  97. .macro enable_irqs, temp
  98. mov temp, #MODE_SVC
  99. msr cpsr_c, temp
  100. .endm
  101. .macro get_current_task, rd
  102. mov rd, sp, lsr #13
  103. mov rd, rd, lsl #13
  104. .endm
  105. /*
  106.  * Like adr, but force SVC mode (if required)
  107.  */
  108. .macro adrsvc, cond, reg, label
  109. adrcond reg, label
  110. .endm
  111. .macro alignment_trap, rbase, rtemp, sym
  112. #ifdef CONFIG_ALIGNMENT_TRAP
  113. #define OFF_CR_ALIGNMENT(x) cr_alignment - x
  114. ldr rtemp, [rbase, #OFF_CR_ALIGNMENT(sym)]
  115. mcr p15, 0, rtemp, c1, c0
  116. #endif
  117. .endm
  118. #else
  119. .macro save_user_regs
  120. str r0, [sp, #-4]!
  121. str lr, [sp, #-4]!
  122. sub sp, sp, #15*4
  123. stmia sp, {r0 - lr}^
  124. mov r0, r0
  125. .endm
  126. .macro restore_user_regs
  127. ldmia sp, {r0 - lr}^
  128. mov r0, r0
  129. ldr lr, [sp, #15*4]
  130. add sp, sp, #15*4+8
  131. movs pc, lr
  132. .endm
  133. .macro fast_restore_user_regs
  134. add sp, sp, #S_OFF
  135. ldmib sp, {r1 - lr}^
  136. mov r0, r0
  137. ldr lr, [sp, #15*4]
  138. add sp, sp, #15*4+8
  139. movs pc, lr
  140. .endm
  141. .macro mask_pc, rd, rm
  142. bic rd, rm, #PCMASK
  143. .endm
  144. .macro enable_irqs, temp
  145. teqp pc, #0x00000003
  146. .endm
  147. .macro initialise_traps_extra
  148. .endm
  149. .macro get_current_task, rd
  150. mov rd, sp, lsr #13
  151. mov rd, rd, lsl #13
  152. .endm
  153. /*
  154.  * Like adr, but force SVC mode (if required)
  155.  */
  156. .macro adrsvc, cond, reg, label
  157. adrcond reg, label
  158. orrcond reg, reg, #0x08000003
  159. .endm
  160. #endif
  161. /*
  162.  * These are the registers used in the syscall handler, and allow us to
  163.  * have in theory up to 7 arguments to a function - r0 to r6.
  164.  *
  165.  * r7 is reserved for the system call number for thumb mode.
  166.  *
  167.  * Note that tbl == why is intentional.
  168.  *
  169.  * We must set at least "tsk" and "why" when calling ret_with_reschedule.
  170.  */
  171. scno .req r7 @ syscall number
  172. tbl .req r8 @ syscall table pointer
  173. why .req r8 @ Linux syscall (!= 0)
  174. tsk .req r9 @ current task
  175. /*
  176.  * Get the system call number.
  177.  */
  178. .macro get_scno
  179. #ifdef CONFIG_ARM_THUMB
  180. tst r8, #T_BIT @ this is SPSR from save_user_regs
  181. addne scno, r7, #OS_NUMBER << 20 @ put OS number in
  182. ldreq scno, [lr, #-4]
  183. #else
  184. mask_pc lr, lr
  185. ldr scno, [lr, #-4] @ get SWI instruction
  186. #endif
  187. .endm