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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * This file is subject to the terms and conditions of the GNU General Public
  3.  * License.  See the file "COPYING" in the main directory of this archive
  4.  * for more details.
  5.  *
  6.  * Copyright (C) 1994 - 2000, 2001 by Ralf Baechle
  7.  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  8.  * Copyright (C) 2001 MIPS Technologies, Inc.
  9.  */
  10. #include <linux/config.h>
  11. #include <linux/init.h>
  12. #include <linux/sys.h>
  13. #include <asm/addrspace.h>
  14. #include <asm/asm.h>
  15. #include <asm/cacheops.h>
  16. #include <asm/current.h>
  17. #include <asm/errno.h>
  18. #include <asm/mipsregs.h>
  19. #include <asm/page.h>
  20. #include <asm/pgtable-bits.h>
  21. #include <asm/stackframe.h>
  22. #include <asm/processor.h>
  23. #include <asm/regdef.h>
  24. #include <asm/fpregdef.h>
  25. #include <asm/unistd.h>
  26. #include <asm/isadep.h>
  27. .text
  28. .align 4
  29. .set push
  30. .set reorder
  31. FEXPORT(ret_from_irq)
  32. FEXPORT(ret_from_exception)
  33. lw t0, PT_STATUS(sp) # returning to kernel mode?
  34. andi t0, t0, KU_USER
  35. beqz t0, restore_all
  36. FEXPORT(ret_from_sys_call) # here to prevent code duplication
  37. ret_from_schedule:
  38. mfc0 t0, CP0_STATUS # need_resched and signals atomic test
  39. ori t0, t0, 1
  40. xori t0, t0, 1
  41. mtc0 t0, CP0_STATUS
  42. SSNOP; SSNOP; SSNOP
  43. lw v0, TASK_NEED_RESCHED($28)
  44. lw v1, TASK_SIGPENDING($28)
  45. bnez v0, reschedule
  46. bnez v1, signal_return
  47. restore_all: .set noat
  48. RESTORE_ALL_AND_RET
  49. .set at
  50. /* Put this behind restore_all for the sake of the branch prediction.  */
  51. signal_return:
  52. .type signal_return, @function
  53. mfc0 t0, CP0_STATUS
  54. ori t0, t0, 1
  55. mtc0 t0, CP0_STATUS
  56. move a0, zero
  57. move a1, sp
  58. jal do_signal
  59. b restore_all
  60. reschedule:
  61. jal schedule
  62. b ret_from_schedule
  63. /*
  64.  * Common spurious interrupt handler.
  65.  */
  66. .text
  67. .align  5
  68. LEAF(spurious_interrupt)
  69. /*
  70.  * Someone tried to fool us by sending an interrupt but we
  71.  * couldn't find a cause for it.
  72.  */
  73. lui     t1,%hi(irq_err_count)
  74. lw      t0,%lo(irq_err_count)(t1)
  75. addiu   t0,1
  76. sw      t0,%lo(irq_err_count)(t1)
  77. j ret_from_irq
  78. END(spurious_interrupt)
  79. __INIT
  80. .set reorder
  81. NESTED(except_vec1_generic, 0, sp)
  82. PANIC("Exception vector 1 called")
  83. END(except_vec1_generic)
  84. /*
  85.  * General exception vector.  Used for all CPUs except R4000
  86.  * and R4400 SC and MC versions.
  87.  */
  88. NESTED(except_vec3_generic, 0, sp)
  89. mfc0 k1, CP0_CAUSE
  90. la k0, exception_handlers
  91. andi k1, k1, 0x7c
  92. addu k0, k0, k1
  93. lw k0, (k0)
  94. jr k0
  95. END(except_vec3_generic)
  96. .set at
  97. /* General exception vector R4000 version. */
  98. NESTED(except_vec3_r4000, 0, sp)
  99. .set push
  100. .set    mips3
  101. .set noat
  102. #if defined(R5432_CP0_INTERRUPT_WAR)
  103. mfc0 k0, CP0_INDEX
  104. #endif
  105. mfc0 k1, CP0_CAUSE
  106. li k0, 31<<2
  107. andi k1, k1, 0x7c
  108. .set noreorder
  109. beq k1, k0, handle_vced
  110.  li k0, 14<<2
  111. beq k1, k0, handle_vcei
  112.  la k0, exception_handlers
  113. .set reorder
  114. addu k0, k0, k1
  115. lw k0, (k0)
  116. jr k0
  117. /*
  118.  * Big shit, we now may have two dirty primary cache lines for
  119.  * the same physical address.  We can savely invalidate the
  120.  * line pointed to by c0_badvaddr because after return from
  121.  * this exception handler the load / store will be re-executed.
  122.  */
  123. handle_vced:
  124. mfc0 k0, CP0_BADVADDR
  125. li k1, -4
  126. and k0, k1
  127. mtc0 zero, CP0_TAGLO
  128. cache Index_Store_Tag_D,(k0)
  129. cache Hit_Writeback_Inv_SD,(k0)
  130. #ifdef CONFIG_PROC_FS
  131. lui k0, %hi(vced_count)
  132. lw k1, %lo(vced_count)(k0)
  133. addiu k1, 1
  134. sw k1, %lo(vced_count)(k0)
  135. #endif
  136. eret
  137. handle_vcei:
  138. mfc0 k0, CP0_BADVADDR
  139. cache Hit_Writeback_Inv_SD, (k0) # also cleans pi
  140. #ifdef CONFIG_PROC_FS
  141. lui k0, %hi(vcei_count)
  142. lw k1, %lo(vcei_count)(k0)
  143. addiu k1, 1
  144. sw k1, %lo(vcei_count)(k0)
  145. #endif
  146. eret
  147. .set    pop
  148. END(except_vec3_r4000)
  149. __FINIT
  150. /*
  151.  * Build a default exception handler for the exceptions that don't need
  152.  * special handlers.  If you didn't know yet - I *like* playing games with
  153.  * the C preprocessor ...
  154.  */
  155. #define __BUILD_clear_none(exception)
  156. #define __BUILD_clear_sti(exception)                                    
  157. STI
  158. #define __BUILD_clear_cli(exception)                                    
  159. CLI
  160. #define __BUILD_clear_fpe(exception)                                    
  161. cfc1 a1,fcr31;                                       
  162. li a2,~(0x3f<<12);                                 
  163. and a2,a1;                                          
  164. ctc1 a2,fcr31;                                       
  165. STI
  166. #define __BUILD_clear_ade(exception)                                    
  167. .set reorder;
  168. MFC0 t0,CP0_BADVADDR;                                
  169. .set noreorder;
  170. REG_S t0,PT_BVADDR(sp);                               
  171. KMODE
  172. #define __BUILD_silent(exception)
  173. #define fmt "Got %s at %08lx.n"
  174. #define __BUILD_verbose(exception)                                      
  175. la a1,8f;                                          
  176. TEXT (#exception);                                   
  177. REG_L a2,PT_EPC(sp);                                  
  178. PRINT(fmt)
  179. #define __BUILD_count(exception)                                        
  180. .set reorder;                                        
  181. lw t0,exception_count_##exception;                 
  182. .set noreorder;                                      
  183. addiu t0, 1;                                          
  184. sw t0,exception_count_##exception;                 
  185. .data;                                                  
  186. EXPORT(exception_count_##exception);                                    
  187. .word 0;                                              
  188. .previous;
  189. #define BUILD_HANDLER(exception,handler,clear,verbose)                  
  190. .align 5;                                              
  191. NESTED(handle_##exception, PT_SIZE, sp);                 
  192. .set noat;                                           
  193. SAVE_ALL;                                               
  194. FEXPORT(handle_##exception##_int);
  195. __BUILD_clear_##clear(exception);                       
  196. .set at;                                             
  197. __BUILD_##verbose(exception);                           
  198. jal do_##handler;                                   
  199.  move a0, sp;                                         
  200. j ret_from_exception;                             
  201.  nop;                                                   
  202. END(handle_##exception)
  203. BUILD_HANDLER(adel,ade,ade,silent) /* #4  */
  204. BUILD_HANDLER(ades,ade,ade,silent) /* #5  */
  205. BUILD_HANDLER(ibe,be,cli,silent) /* #6  */
  206. BUILD_HANDLER(dbe,be,cli,silent) /* #7  */
  207. BUILD_HANDLER(bp,bp,sti,silent) /* #9  */
  208. BUILD_HANDLER(ri,ri,sti,silent) /* #10 */
  209. BUILD_HANDLER(cpu,cpu,sti,silent) /* #11 */
  210. BUILD_HANDLER(ov,ov,sti,silent) /* #12 */
  211. BUILD_HANDLER(tr,tr,sti,silent) /* #13 */
  212. BUILD_HANDLER(fpe,fpe,fpe,silent) /* #15 */
  213. BUILD_HANDLER(watch,watch,sti,silent) /* #23 */
  214. BUILD_HANDLER(mcheck,mcheck,cli,silent) /* #24 */
  215. BUILD_HANDLER(reserved,reserved,sti,silent) /* others */
  216. .set pop
  217. /*
  218.  * Table of syscalls
  219.  */
  220. .data
  221. .align PTRLOG
  222. EXPORT(sys_call_table)
  223. #define SYS(call, narg) PTR call
  224. /* Reserved space for all SVR4 syscalls. */
  225. .space (1000)*PTRSIZE
  226. #ifdef CONFIG_BINFMT_IRIX
  227. /* 32bit IRIX5 system calls. */
  228. #include "irix5sys.h"
  229. #else
  230. .space (1000)*PTRSIZE /* No IRIX syscalls */
  231. #endif
  232. /* Reserved space for all the BSD43 and POSIX syscalls. */
  233. .space (2000)*PTRSIZE
  234. /* Linux flavoured syscalls. */
  235. #include "syscalls.h"
  236. /*
  237.  * Number of arguments of each syscall
  238.  */
  239. EXPORT(sys_narg_table)
  240. #undef SYS
  241. #define SYS(call, narg) .byte narg
  242. /* Reserved space for all SVR4 flavoured syscalls. */
  243. .space (1000)
  244. #ifdef CONFIG_BINFMT_IRIX
  245. /* 32bit IRIX5 system calls. */
  246. #include "irix5sys.h"
  247. #else
  248. .space (1000) /* No IRIX syscalls */
  249. #endif
  250. /* Reserved space for all the BSD43 and POSIX syscalls. */
  251. .space (2000)
  252. /* Linux flavoured syscalls. */
  253. #include "syscalls.h"