entry.S 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. ;
  2. ; Port on Texas Instruments TMS320C6x architecture
  3. ;
  4. ; Copyright (C) 2004-2011 Texas Instruments Incorporated
  5. ; Author: Aurelien Jacquiot (aurelien.jacquiot@virtuallogix.com)
  6. ; Updated for 2.6.34: Mark Salter <msalter@redhat.com>
  7. ;
  8. ; This program is free software; you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License version 2 as
  10. ; published by the Free Software Foundation.
  11. ;
  12. #include <linux/sys.h>
  13. #include <linux/linkage.h>
  14. #include <asm/thread_info.h>
  15. #include <asm/asm-offsets.h>
  16. #include <asm/unistd.h>
  17. #include <asm/errno.h>
  18. ; Registers naming
  19. #define DP B14
  20. #define SP B15
  21. #ifndef CONFIG_PREEMPT
  22. #define resume_kernel restore_all
  23. #endif
  24. .altmacro
  25. .macro MASK_INT reg
  26. MVC .S2 CSR,reg
  27. CLR .S2 reg,0,0,reg
  28. MVC .S2 reg,CSR
  29. .endm
  30. .macro UNMASK_INT reg
  31. MVC .S2 CSR,reg
  32. SET .S2 reg,0,0,reg
  33. MVC .S2 reg,CSR
  34. .endm
  35. .macro GET_THREAD_INFO reg
  36. SHR .S1X SP,THREAD_SHIFT,reg
  37. SHL .S1 reg,THREAD_SHIFT,reg
  38. .endm
  39. ;;
  40. ;; This defines the normal kernel pt_regs layout.
  41. ;;
  42. .macro SAVE_ALL __rp __tsr
  43. STW .D2T2 B0,*SP--[2] ; save original B0
  44. MVKL .S2 current_ksp,B0
  45. MVKH .S2 current_ksp,B0
  46. LDW .D2T2 *B0,B1 ; KSP
  47. NOP 3
  48. STW .D2T2 B1,*+SP[1] ; save original B1
  49. XOR .D2 SP,B1,B0 ; (SP ^ KSP)
  50. LDW .D2T2 *+SP[1],B1 ; restore B0/B1
  51. LDW .D2T2 *++SP[2],B0
  52. SHR .S2 B0,THREAD_SHIFT,B0 ; 0 if already using kstack
  53. [B0] STDW .D2T2 SP:DP,*--B1[1] ; user: save user sp/dp kstack
  54. [B0] MV .S2 B1,SP ; and switch to kstack
  55. ||[!B0] STDW .D2T2 SP:DP,*--SP[1] ; kernel: save on current stack
  56. SUBAW .D2 SP,2,SP
  57. ADD .D1X SP,-8,A15
  58. || STDW .D2T1 A15:A14,*SP--[16] ; save A15:A14
  59. STDW .D2T2 B13:B12,*SP--[1]
  60. || STDW .D1T1 A13:A12,*A15--[1]
  61. || MVC .S2 __rp,B13
  62. STDW .D2T2 B11:B10,*SP--[1]
  63. || STDW .D1T1 A11:A10,*A15--[1]
  64. || MVC .S2 CSR,B12
  65. STDW .D2T2 B9:B8,*SP--[1]
  66. || STDW .D1T1 A9:A8,*A15--[1]
  67. || MVC .S2 RILC,B11
  68. STDW .D2T2 B7:B6,*SP--[1]
  69. || STDW .D1T1 A7:A6,*A15--[1]
  70. || MVC .S2 ILC,B10
  71. STDW .D2T2 B5:B4,*SP--[1]
  72. || STDW .D1T1 A5:A4,*A15--[1]
  73. STDW .D2T2 B3:B2,*SP--[1]
  74. || STDW .D1T1 A3:A2,*A15--[1]
  75. || MVC .S2 __tsr,B5
  76. STDW .D2T2 B1:B0,*SP--[1]
  77. || STDW .D1T1 A1:A0,*A15--[1]
  78. || MV .S1X B5,A5
  79. STDW .D2T2 B31:B30,*SP--[1]
  80. || STDW .D1T1 A31:A30,*A15--[1]
  81. STDW .D2T2 B29:B28,*SP--[1]
  82. || STDW .D1T1 A29:A28,*A15--[1]
  83. STDW .D2T2 B27:B26,*SP--[1]
  84. || STDW .D1T1 A27:A26,*A15--[1]
  85. STDW .D2T2 B25:B24,*SP--[1]
  86. || STDW .D1T1 A25:A24,*A15--[1]
  87. STDW .D2T2 B23:B22,*SP--[1]
  88. || STDW .D1T1 A23:A22,*A15--[1]
  89. STDW .D2T2 B21:B20,*SP--[1]
  90. || STDW .D1T1 A21:A20,*A15--[1]
  91. STDW .D2T2 B19:B18,*SP--[1]
  92. || STDW .D1T1 A19:A18,*A15--[1]
  93. STDW .D2T2 B17:B16,*SP--[1]
  94. || STDW .D1T1 A17:A16,*A15--[1]
  95. STDW .D2T2 B13:B12,*SP--[1] ; save PC and CSR
  96. STDW .D2T2 B11:B10,*SP--[1] ; save RILC and ILC
  97. STDW .D2T1 A5:A4,*SP--[1] ; save TSR and orig A4
  98. ;; We left an unused word on the stack just above pt_regs.
  99. ;; It is used to save whether or not this frame is due to
  100. ;; a syscall. It is cleared here, but the syscall handler
  101. ;; sets it to a non-zero value.
  102. MVK .L2 0,B1
  103. STW .D2T2 B1,*+SP(REGS__END+8) ; clear syscall flag
  104. .endm
  105. .macro RESTORE_ALL __rp __tsr
  106. LDDW .D2T2 *++SP[1],B9:B8 ; get TSR (B9)
  107. LDDW .D2T2 *++SP[1],B11:B10 ; get RILC (B11) and ILC (B10)
  108. LDDW .D2T2 *++SP[1],B13:B12 ; get PC (B13) and CSR (B12)
  109. ADDAW .D1X SP,30,A15
  110. LDDW .D1T1 *++A15[1],A17:A16
  111. || LDDW .D2T2 *++SP[1],B17:B16
  112. LDDW .D1T1 *++A15[1],A19:A18
  113. || LDDW .D2T2 *++SP[1],B19:B18
  114. LDDW .D1T1 *++A15[1],A21:A20
  115. || LDDW .D2T2 *++SP[1],B21:B20
  116. LDDW .D1T1 *++A15[1],A23:A22
  117. || LDDW .D2T2 *++SP[1],B23:B22
  118. LDDW .D1T1 *++A15[1],A25:A24
  119. || LDDW .D2T2 *++SP[1],B25:B24
  120. LDDW .D1T1 *++A15[1],A27:A26
  121. || LDDW .D2T2 *++SP[1],B27:B26
  122. LDDW .D1T1 *++A15[1],A29:A28
  123. || LDDW .D2T2 *++SP[1],B29:B28
  124. LDDW .D1T1 *++A15[1],A31:A30
  125. || LDDW .D2T2 *++SP[1],B31:B30
  126. LDDW .D1T1 *++A15[1],A1:A0
  127. || LDDW .D2T2 *++SP[1],B1:B0
  128. LDDW .D1T1 *++A15[1],A3:A2
  129. || LDDW .D2T2 *++SP[1],B3:B2
  130. || MVC .S2 B9,__tsr
  131. LDDW .D1T1 *++A15[1],A5:A4
  132. || LDDW .D2T2 *++SP[1],B5:B4
  133. || MVC .S2 B11,RILC
  134. LDDW .D1T1 *++A15[1],A7:A6
  135. || LDDW .D2T2 *++SP[1],B7:B6
  136. || MVC .S2 B10,ILC
  137. LDDW .D1T1 *++A15[1],A9:A8
  138. || LDDW .D2T2 *++SP[1],B9:B8
  139. || MVC .S2 B13,__rp
  140. LDDW .D1T1 *++A15[1],A11:A10
  141. || LDDW .D2T2 *++SP[1],B11:B10
  142. || MVC .S2 B12,CSR
  143. LDDW .D1T1 *++A15[1],A13:A12
  144. || LDDW .D2T2 *++SP[1],B13:B12
  145. MV .D2X A15,SP
  146. || MVKL .S1 current_ksp,A15
  147. MVKH .S1 current_ksp,A15
  148. || ADDAW .D1X SP,6,A14
  149. STW .D1T1 A14,*A15 ; save kernel stack pointer
  150. LDDW .D2T1 *++SP[1],A15:A14
  151. B .S2 __rp ; return from interruption
  152. LDDW .D2T2 *+SP[1],SP:DP
  153. NOP 4
  154. .endm
  155. .section .text
  156. ;;
  157. ;; Jump to schedule() then return to ret_from_exception
  158. ;;
  159. _reschedule:
  160. #ifdef CONFIG_C6X_BIG_KERNEL
  161. MVKL .S1 schedule,A0
  162. MVKH .S1 schedule,A0
  163. B .S2X A0
  164. #else
  165. B .S1 schedule
  166. #endif
  167. ADDKPC .S2 ret_from_exception,B3,4
  168. ;;
  169. ;; Called before syscall handler when process is being debugged
  170. ;;
  171. tracesys_on:
  172. #ifdef CONFIG_C6X_BIG_KERNEL
  173. MVKL .S1 syscall_trace_entry,A0
  174. MVKH .S1 syscall_trace_entry,A0
  175. B .S2X A0
  176. #else
  177. B .S1 syscall_trace_entry
  178. #endif
  179. ADDKPC .S2 ret_from_syscall_trace,B3,3
  180. ADD .S1X 8,SP,A4
  181. ret_from_syscall_trace:
  182. ;; tracing returns (possibly new) syscall number
  183. MV .D2X A4,B0
  184. || MVK .S2 __NR_syscalls,B1
  185. CMPLTU .L2 B0,B1,B1
  186. [!B1] BNOP .S2 ret_from_syscall_function,5
  187. || MVK .S1 -ENOSYS,A4
  188. ;; reload syscall args from (possibly modified) stack frame
  189. ;; and get syscall handler addr from sys_call_table:
  190. LDW .D2T2 *+SP(REGS_B4+8),B4
  191. || MVKL .S2 sys_call_table,B1
  192. LDW .D2T1 *+SP(REGS_A6+8),A6
  193. || MVKH .S2 sys_call_table,B1
  194. LDW .D2T2 *+B1[B0],B0
  195. || MVKL .S2 ret_from_syscall_function,B3
  196. LDW .D2T2 *+SP(REGS_B6+8),B6
  197. || MVKH .S2 ret_from_syscall_function,B3
  198. LDW .D2T1 *+SP(REGS_A8+8),A8
  199. LDW .D2T2 *+SP(REGS_B8+8),B8
  200. NOP
  201. ; B0 = sys_call_table[__NR_*]
  202. BNOP .S2 B0,5 ; branch to syscall handler
  203. || LDW .D2T1 *+SP(REGS_ORIG_A4+8),A4
  204. syscall_exit_work:
  205. AND .D1 _TIF_SYSCALL_TRACE,A2,A0
  206. [!A0] BNOP .S1 work_pending,5
  207. [A0] B .S2 syscall_trace_exit
  208. ADDKPC .S2 resume_userspace,B3,1
  209. MVC .S2 CSR,B1
  210. SET .S2 B1,0,0,B1
  211. MVC .S2 B1,CSR ; enable ints
  212. work_pending:
  213. AND .D1 _TIF_NEED_RESCHED,A2,A0
  214. [!A0] BNOP .S1 work_notifysig,5
  215. work_resched:
  216. #ifdef CONFIG_C6X_BIG_KERNEL
  217. MVKL .S1 schedule,A1
  218. MVKH .S1 schedule,A1
  219. B .S2X A1
  220. #else
  221. B .S2 schedule
  222. #endif
  223. ADDKPC .S2 work_rescheduled,B3,4
  224. work_rescheduled:
  225. ;; make sure we don't miss an interrupt setting need_resched or
  226. ;; sigpending between sampling and the rti
  227. MASK_INT B2
  228. GET_THREAD_INFO A12
  229. LDW .D1T1 *+A12(THREAD_INFO_FLAGS),A2
  230. MVK .S1 _TIF_WORK_MASK,A1
  231. MVK .S1 _TIF_NEED_RESCHED,A3
  232. NOP 2
  233. AND .D1 A1,A2,A0
  234. || AND .S1 A3,A2,A1
  235. [!A0] BNOP .S1 restore_all,5
  236. [A1] BNOP .S1 work_resched,5
  237. work_notifysig:
  238. ;; enable interrupts for do_notify_resume()
  239. UNMASK_INT B2
  240. B .S2 do_notify_resume
  241. LDW .D2T1 *+SP(REGS__END+8),A6 ; syscall flag
  242. ADDKPC .S2 resume_userspace,B3,1
  243. ADD .S1X 8,SP,A4 ; pt_regs pointer is first arg
  244. MV .D2X A2,B4 ; thread_info flags is second arg
  245. ;;
  246. ;; On C64x+, the return way from exception and interrupt
  247. ;; is a little bit different
  248. ;;
  249. ENTRY(ret_from_exception)
  250. #ifdef CONFIG_PREEMPT
  251. MASK_INT B2
  252. #endif
  253. ENTRY(ret_from_interrupt)
  254. ;;
  255. ;; Check if we are comming from user mode.
  256. ;;
  257. LDW .D2T2 *+SP(REGS_TSR+8),B0
  258. MVK .S2 0x40,B1
  259. NOP 3
  260. AND .D2 B0,B1,B0
  261. [!B0] BNOP .S2 resume_kernel,5
  262. resume_userspace:
  263. ;; make sure we don't miss an interrupt setting need_resched or
  264. ;; sigpending between sampling and the rti
  265. MASK_INT B2
  266. GET_THREAD_INFO A12
  267. LDW .D1T1 *+A12(THREAD_INFO_FLAGS),A2
  268. MVK .S1 _TIF_WORK_MASK,A1
  269. MVK .S1 _TIF_NEED_RESCHED,A3
  270. NOP 2
  271. AND .D1 A1,A2,A0
  272. [A0] BNOP .S1 work_pending,5
  273. BNOP .S1 restore_all,5
  274. ;;
  275. ;; System call handling
  276. ;; B0 = syscall number (in sys_call_table)
  277. ;; A4,B4,A6,B6,A8,B8 = arguments of the syscall function
  278. ;; A4 is the return value register
  279. ;;
  280. system_call_saved:
  281. MVK .L2 1,B2
  282. STW .D2T2 B2,*+SP(REGS__END+8) ; set syscall flag
  283. MVC .S2 B2,ECR ; ack the software exception
  284. UNMASK_INT B2 ; re-enable global IT
  285. system_call_saved_noack:
  286. ;; Check system call number
  287. MVK .S2 __NR_syscalls,B1
  288. #ifdef CONFIG_C6X_BIG_KERNEL
  289. || MVKL .S1 sys_ni_syscall,A0
  290. #endif
  291. CMPLTU .L2 B0,B1,B1
  292. #ifdef CONFIG_C6X_BIG_KERNEL
  293. || MVKH .S1 sys_ni_syscall,A0
  294. #endif
  295. ;; Check for ptrace
  296. GET_THREAD_INFO A12
  297. #ifdef CONFIG_C6X_BIG_KERNEL
  298. [!B1] B .S2X A0
  299. #else
  300. [!B1] B .S2 sys_ni_syscall
  301. #endif
  302. [!B1] ADDKPC .S2 ret_from_syscall_function,B3,4
  303. ;; Get syscall handler addr from sys_call_table
  304. ;; call tracesys_on or call syscall handler
  305. LDW .D1T1 *+A12(THREAD_INFO_FLAGS),A2
  306. || MVKL .S2 sys_call_table,B1
  307. MVKH .S2 sys_call_table,B1
  308. LDW .D2T2 *+B1[B0],B0
  309. NOP 2
  310. ; A2 = thread_info flags
  311. AND .D1 _TIF_SYSCALL_TRACE,A2,A2
  312. [A2] BNOP .S1 tracesys_on,5
  313. ;; B0 = _sys_call_table[__NR_*]
  314. B .S2 B0
  315. ADDKPC .S2 ret_from_syscall_function,B3,4
  316. ret_from_syscall_function:
  317. STW .D2T1 A4,*+SP(REGS_A4+8) ; save return value in A4
  318. ; original A4 is in orig_A4
  319. syscall_exit:
  320. ;; make sure we don't miss an interrupt setting need_resched or
  321. ;; sigpending between sampling and the rti
  322. MASK_INT B2
  323. LDW .D1T1 *+A12(THREAD_INFO_FLAGS),A2
  324. MVK .S1 _TIF_ALLWORK_MASK,A1
  325. NOP 3
  326. AND .D1 A1,A2,A2 ; check for work to do
  327. [A2] BNOP .S1 syscall_exit_work,5
  328. restore_all:
  329. RESTORE_ALL NRP,NTSR
  330. ;;
  331. ;; After a fork we jump here directly from resume,
  332. ;; so that A4 contains the previous task structure.
  333. ;;
  334. ENTRY(ret_from_fork)
  335. #ifdef CONFIG_C6X_BIG_KERNEL
  336. MVKL .S1 schedule_tail,A0
  337. MVKH .S1 schedule_tail,A0
  338. B .S2X A0
  339. #else
  340. B .S2 schedule_tail
  341. #endif
  342. ADDKPC .S2 ret_from_fork_2,B3,4
  343. ret_from_fork_2:
  344. ;; return 0 in A4 for child process
  345. GET_THREAD_INFO A12
  346. BNOP .S2 syscall_exit,3
  347. MVK .L2 0,B0
  348. STW .D2T2 B0,*+SP(REGS_A4+8)
  349. ENDPROC(ret_from_fork)
  350. ENTRY(ret_from_kernel_thread)
  351. #ifdef CONFIG_C6X_BIG_KERNEL
  352. MVKL .S1 schedule_tail,A0
  353. MVKH .S1 schedule_tail,A0
  354. B .S2X A0
  355. #else
  356. B .S2 schedule_tail
  357. #endif
  358. LDW .D2T2 *+SP(REGS_A0+8),B10 /* get fn */
  359. ADDKPC .S2 0f,B3,3
  360. 0:
  361. B .S2 B10 /* call fn */
  362. LDW .D2T1 *+SP(REGS_A1+8),A4 /* get arg */
  363. ADDKPC .S2 ret_from_fork_2,B3,3
  364. ENDPROC(ret_from_kernel_thread)
  365. ;;
  366. ;; These are the interrupt handlers, responsible for calling c6x_do_IRQ()
  367. ;;
  368. .macro SAVE_ALL_INT
  369. SAVE_ALL IRP,ITSR
  370. .endm
  371. .macro CALL_INT int
  372. #ifdef CONFIG_C6X_BIG_KERNEL
  373. MVKL .S1 c6x_do_IRQ,A0
  374. MVKH .S1 c6x_do_IRQ,A0
  375. BNOP .S2X A0,1
  376. MVK .S1 int,A4
  377. ADDAW .D2 SP,2,B4
  378. MVKL .S2 ret_from_interrupt,B3
  379. MVKH .S2 ret_from_interrupt,B3
  380. #else
  381. CALLP .S2 c6x_do_IRQ,B3
  382. || MVK .S1 int,A4
  383. || ADDAW .D2 SP,2,B4
  384. B .S1 ret_from_interrupt
  385. NOP 5
  386. #endif
  387. .endm
  388. ENTRY(_int4_handler)
  389. SAVE_ALL_INT
  390. CALL_INT 4
  391. ENDPROC(_int4_handler)
  392. ENTRY(_int5_handler)
  393. SAVE_ALL_INT
  394. CALL_INT 5
  395. ENDPROC(_int5_handler)
  396. ENTRY(_int6_handler)
  397. SAVE_ALL_INT
  398. CALL_INT 6
  399. ENDPROC(_int6_handler)
  400. ENTRY(_int7_handler)
  401. SAVE_ALL_INT
  402. CALL_INT 7
  403. ENDPROC(_int7_handler)
  404. ENTRY(_int8_handler)
  405. SAVE_ALL_INT
  406. CALL_INT 8
  407. ENDPROC(_int8_handler)
  408. ENTRY(_int9_handler)
  409. SAVE_ALL_INT
  410. CALL_INT 9
  411. ENDPROC(_int9_handler)
  412. ENTRY(_int10_handler)
  413. SAVE_ALL_INT
  414. CALL_INT 10
  415. ENDPROC(_int10_handler)
  416. ENTRY(_int11_handler)
  417. SAVE_ALL_INT
  418. CALL_INT 11
  419. ENDPROC(_int11_handler)
  420. ENTRY(_int12_handler)
  421. SAVE_ALL_INT
  422. CALL_INT 12
  423. ENDPROC(_int12_handler)
  424. ENTRY(_int13_handler)
  425. SAVE_ALL_INT
  426. CALL_INT 13
  427. ENDPROC(_int13_handler)
  428. ENTRY(_int14_handler)
  429. SAVE_ALL_INT
  430. CALL_INT 14
  431. ENDPROC(_int14_handler)
  432. ENTRY(_int15_handler)
  433. SAVE_ALL_INT
  434. CALL_INT 15
  435. ENDPROC(_int15_handler)
  436. ;;
  437. ;; Handler for uninitialized and spurious interrupts
  438. ;;
  439. ENTRY(_bad_interrupt)
  440. B .S2 IRP
  441. NOP 5
  442. ENDPROC(_bad_interrupt)
  443. ;;
  444. ;; Entry for NMI/exceptions/syscall
  445. ;;
  446. ENTRY(_nmi_handler)
  447. SAVE_ALL NRP,NTSR
  448. MVC .S2 EFR,B2
  449. CMPEQ .L2 1,B2,B2
  450. || MVC .S2 TSR,B1
  451. CLR .S2 B1,10,10,B1
  452. MVC .S2 B1,TSR
  453. #ifdef CONFIG_C6X_BIG_KERNEL
  454. [!B2] MVKL .S1 process_exception,A0
  455. [!B2] MVKH .S1 process_exception,A0
  456. [!B2] B .S2X A0
  457. #else
  458. [!B2] B .S2 process_exception
  459. #endif
  460. [B2] B .S2 system_call_saved
  461. [!B2] ADDAW .D2 SP,2,B1
  462. [!B2] MV .D1X B1,A4
  463. ADDKPC .S2 ret_from_trap,B3,2
  464. ret_from_trap:
  465. MV .D2X A4,B0
  466. [!B0] BNOP .S2 ret_from_exception,5
  467. #ifdef CONFIG_C6X_BIG_KERNEL
  468. MVKL .S2 system_call_saved_noack,B3
  469. MVKH .S2 system_call_saved_noack,B3
  470. #endif
  471. LDW .D2T2 *+SP(REGS_B0+8),B0
  472. LDW .D2T1 *+SP(REGS_A4+8),A4
  473. LDW .D2T2 *+SP(REGS_B4+8),B4
  474. LDW .D2T1 *+SP(REGS_A6+8),A6
  475. LDW .D2T2 *+SP(REGS_B6+8),B6
  476. LDW .D2T1 *+SP(REGS_A8+8),A8
  477. #ifdef CONFIG_C6X_BIG_KERNEL
  478. || B .S2 B3
  479. #else
  480. || B .S2 system_call_saved_noack
  481. #endif
  482. LDW .D2T2 *+SP(REGS_B8+8),B8
  483. NOP 4
  484. ENDPROC(_nmi_handler)
  485. ;;
  486. ;; Jump to schedule() then return to ret_from_isr
  487. ;;
  488. #ifdef CONFIG_PREEMPT
  489. resume_kernel:
  490. GET_THREAD_INFO A12
  491. LDW .D1T1 *+A12(THREAD_INFO_PREEMPT_COUNT),A1
  492. NOP 4
  493. [A1] BNOP .S2 restore_all,5
  494. preempt_schedule:
  495. GET_THREAD_INFO A2
  496. LDW .D1T1 *+A2(THREAD_INFO_FLAGS),A1
  497. #ifdef CONFIG_C6X_BIG_KERNEL
  498. MVKL .S2 preempt_schedule_irq,B0
  499. MVKH .S2 preempt_schedule_irq,B0
  500. NOP 2
  501. #else
  502. NOP 4
  503. #endif
  504. AND .D1 _TIF_NEED_RESCHED,A1,A1
  505. [!A1] BNOP .S2 restore_all,5
  506. #ifdef CONFIG_C6X_BIG_KERNEL
  507. B .S2 B0
  508. #else
  509. B .S2 preempt_schedule_irq
  510. #endif
  511. ADDKPC .S2 preempt_schedule,B3,4
  512. #endif /* CONFIG_PREEMPT */
  513. ENTRY(enable_exception)
  514. DINT
  515. MVC .S2 TSR,B0
  516. MVC .S2 B3,NRP
  517. MVK .L2 0xc,B1
  518. OR .D2 B0,B1,B0
  519. MVC .S2 B0,TSR ; Set GEE and XEN in TSR
  520. B .S2 NRP
  521. NOP 5
  522. ENDPROC(enable_exception)
  523. ;;
  524. ;; Special system calls
  525. ;; return address is in B3
  526. ;;
  527. ENTRY(sys_rt_sigreturn)
  528. ADD .D1X SP,8,A4
  529. #ifdef CONFIG_C6X_BIG_KERNEL
  530. || MVKL .S1 do_rt_sigreturn,A0
  531. MVKH .S1 do_rt_sigreturn,A0
  532. BNOP .S2X A0,5
  533. #else
  534. || B .S2 do_rt_sigreturn
  535. NOP 5
  536. #endif
  537. ENDPROC(sys_rt_sigreturn)
  538. ENTRY(sys_pread_c6x)
  539. MV .D2X A8,B7
  540. #ifdef CONFIG_C6X_BIG_KERNEL
  541. || MVKL .S1 sys_pread64,A0
  542. MVKH .S1 sys_pread64,A0
  543. BNOP .S2X A0,5
  544. #else
  545. || B .S2 sys_pread64
  546. NOP 5
  547. #endif
  548. ENDPROC(sys_pread_c6x)
  549. ENTRY(sys_pwrite_c6x)
  550. MV .D2X A8,B7
  551. #ifdef CONFIG_C6X_BIG_KERNEL
  552. || MVKL .S1 sys_pwrite64,A0
  553. MVKH .S1 sys_pwrite64,A0
  554. BNOP .S2X A0,5
  555. #else
  556. || B .S2 sys_pwrite64
  557. NOP 5
  558. #endif
  559. ENDPROC(sys_pwrite_c6x)
  560. ;; On Entry
  561. ;; A4 - path
  562. ;; B4 - offset_lo (LE), offset_hi (BE)
  563. ;; A6 - offset_lo (BE), offset_hi (LE)
  564. ENTRY(sys_truncate64_c6x)
  565. #ifdef CONFIG_CPU_BIG_ENDIAN
  566. MV .S2 B4,B5
  567. MV .D2X A6,B4
  568. #else
  569. MV .D2X A6,B5
  570. #endif
  571. #ifdef CONFIG_C6X_BIG_KERNEL
  572. || MVKL .S1 sys_truncate64,A0
  573. MVKH .S1 sys_truncate64,A0
  574. BNOP .S2X A0,5
  575. #else
  576. || B .S2 sys_truncate64
  577. NOP 5
  578. #endif
  579. ENDPROC(sys_truncate64_c6x)
  580. ;; On Entry
  581. ;; A4 - fd
  582. ;; B4 - offset_lo (LE), offset_hi (BE)
  583. ;; A6 - offset_lo (BE), offset_hi (LE)
  584. ENTRY(sys_ftruncate64_c6x)
  585. #ifdef CONFIG_CPU_BIG_ENDIAN
  586. MV .S2 B4,B5
  587. MV .D2X A6,B4
  588. #else
  589. MV .D2X A6,B5
  590. #endif
  591. #ifdef CONFIG_C6X_BIG_KERNEL
  592. || MVKL .S1 sys_ftruncate64,A0
  593. MVKH .S1 sys_ftruncate64,A0
  594. BNOP .S2X A0,5
  595. #else
  596. || B .S2 sys_ftruncate64
  597. NOP 5
  598. #endif
  599. ENDPROC(sys_ftruncate64_c6x)
  600. ;; On Entry
  601. ;; A4 - fd
  602. ;; B4 - offset_lo (LE), offset_hi (BE)
  603. ;; A6 - offset_lo (BE), offset_hi (LE)
  604. ;; B6 - len_lo (LE), len_hi (BE)
  605. ;; A8 - len_lo (BE), len_hi (LE)
  606. ;; B8 - advice
  607. ENTRY(sys_fadvise64_64_c6x)
  608. #ifdef CONFIG_C6X_BIG_KERNEL
  609. MVKL .S1 sys_fadvise64_64,A0
  610. MVKH .S1 sys_fadvise64_64,A0
  611. BNOP .S2X A0,2
  612. #else
  613. B .S2 sys_fadvise64_64
  614. NOP 2
  615. #endif
  616. #ifdef CONFIG_CPU_BIG_ENDIAN
  617. MV .L2 B4,B5
  618. || MV .D2X A6,B4
  619. MV .L1 A8,A6
  620. || MV .D1X B6,A7
  621. #else
  622. MV .D2X A6,B5
  623. MV .L1 A8,A7
  624. || MV .D1X B6,A6
  625. #endif
  626. MV .L2 B8,B6
  627. ENDPROC(sys_fadvise64_64_c6x)
  628. ;; On Entry
  629. ;; A4 - fd
  630. ;; B4 - mode
  631. ;; A6 - offset_hi
  632. ;; B6 - offset_lo
  633. ;; A8 - len_hi
  634. ;; B8 - len_lo
  635. ENTRY(sys_fallocate_c6x)
  636. #ifdef CONFIG_C6X_BIG_KERNEL
  637. MVKL .S1 sys_fallocate,A0
  638. MVKH .S1 sys_fallocate,A0
  639. BNOP .S2X A0,1
  640. #else
  641. B .S2 sys_fallocate
  642. NOP
  643. #endif
  644. MV .D1 A6,A7
  645. MV .D1X B6,A6
  646. MV .D2X A8,B7
  647. MV .D2 B8,B6
  648. ENDPROC(sys_fallocate_c6x)
  649. ;; put this in .neardata for faster access when using DSBT mode
  650. .section .neardata,"aw",@progbits
  651. .global current_ksp
  652. .hidden current_ksp
  653. current_ksp:
  654. .word init_thread_union + THREAD_START_SP