entry.S 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  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. B .S2 do_notify_resume
  239. LDW .D2T1 *+SP(REGS__END+8),A6 ; syscall flag
  240. ADDKPC .S2 resume_userspace,B3,1
  241. ADD .S1X 8,SP,A4 ; pt_regs pointer is first arg
  242. MV .D2X A2,B4 ; thread_info flags is second arg
  243. ;;
  244. ;; On C64x+, the return way from exception and interrupt
  245. ;; is a little bit different
  246. ;;
  247. ENTRY(ret_from_exception)
  248. #ifdef CONFIG_PREEMPT
  249. MASK_INT B2
  250. #endif
  251. ENTRY(ret_from_interrupt)
  252. ;;
  253. ;; Check if we are comming from user mode.
  254. ;;
  255. LDW .D2T2 *+SP(REGS_TSR+8),B0
  256. MVK .S2 0x40,B1
  257. NOP 3
  258. AND .D2 B0,B1,B0
  259. [!B0] BNOP .S2 resume_kernel,5
  260. resume_userspace:
  261. ;; make sure we don't miss an interrupt setting need_resched or
  262. ;; sigpending between sampling and the rti
  263. MASK_INT B2
  264. GET_THREAD_INFO A12
  265. LDW .D1T1 *+A12(THREAD_INFO_FLAGS),A2
  266. MVK .S1 _TIF_WORK_MASK,A1
  267. MVK .S1 _TIF_NEED_RESCHED,A3
  268. NOP 2
  269. AND .D1 A1,A2,A0
  270. [A0] BNOP .S1 work_pending,5
  271. BNOP .S1 restore_all,5
  272. ;;
  273. ;; System call handling
  274. ;; B0 = syscall number (in sys_call_table)
  275. ;; A4,B4,A6,B6,A8,B8 = arguments of the syscall function
  276. ;; A4 is the return value register
  277. ;;
  278. system_call_saved:
  279. MVK .L2 1,B2
  280. STW .D2T2 B2,*+SP(REGS__END+8) ; set syscall flag
  281. MVC .S2 B2,ECR ; ack the software exception
  282. UNMASK_INT B2 ; re-enable global IT
  283. system_call_saved_noack:
  284. ;; Check system call number
  285. MVK .S2 __NR_syscalls,B1
  286. #ifdef CONFIG_C6X_BIG_KERNEL
  287. || MVKL .S1 sys_ni_syscall,A0
  288. #endif
  289. CMPLTU .L2 B0,B1,B1
  290. #ifdef CONFIG_C6X_BIG_KERNEL
  291. || MVKH .S1 sys_ni_syscall,A0
  292. #endif
  293. ;; Check for ptrace
  294. GET_THREAD_INFO A12
  295. #ifdef CONFIG_C6X_BIG_KERNEL
  296. [!B1] B .S2X A0
  297. #else
  298. [!B1] B .S2 sys_ni_syscall
  299. #endif
  300. [!B1] ADDKPC .S2 ret_from_syscall_function,B3,4
  301. ;; Get syscall handler addr from sys_call_table
  302. ;; call tracesys_on or call syscall handler
  303. LDW .D1T1 *+A12(THREAD_INFO_FLAGS),A2
  304. || MVKL .S2 sys_call_table,B1
  305. MVKH .S2 sys_call_table,B1
  306. LDW .D2T2 *+B1[B0],B0
  307. NOP 2
  308. ; A2 = thread_info flags
  309. AND .D1 _TIF_SYSCALL_TRACE,A2,A2
  310. [A2] BNOP .S1 tracesys_on,5
  311. ;; B0 = _sys_call_table[__NR_*]
  312. B .S2 B0
  313. ADDKPC .S2 ret_from_syscall_function,B3,4
  314. ret_from_syscall_function:
  315. STW .D2T1 A4,*+SP(REGS_A4+8) ; save return value in A4
  316. ; original A4 is in orig_A4
  317. syscall_exit:
  318. ;; make sure we don't miss an interrupt setting need_resched or
  319. ;; sigpending between sampling and the rti
  320. MASK_INT B2
  321. LDW .D1T1 *+A12(THREAD_INFO_FLAGS),A2
  322. MVK .S1 _TIF_ALLWORK_MASK,A1
  323. NOP 3
  324. AND .D1 A1,A2,A2 ; check for work to do
  325. [A2] BNOP .S1 syscall_exit_work,5
  326. restore_all:
  327. RESTORE_ALL NRP,NTSR
  328. ;;
  329. ;; After a fork we jump here directly from resume,
  330. ;; so that A4 contains the previous task structure.
  331. ;;
  332. ENTRY(ret_from_fork)
  333. #ifdef CONFIG_C6X_BIG_KERNEL
  334. MVKL .S1 schedule_tail,A0
  335. MVKH .S1 schedule_tail,A0
  336. B .S2X A0
  337. #else
  338. B .S2 schedule_tail
  339. #endif
  340. ADDKPC .S2 ret_from_fork_2,B3,4
  341. ret_from_fork_2:
  342. ;; return 0 in A4 for child process
  343. GET_THREAD_INFO A12
  344. BNOP .S2 syscall_exit,3
  345. MVK .L2 0,B0
  346. STW .D2T2 B0,*+SP(REGS_A4+8)
  347. ENDPROC(ret_from_fork)
  348. ;;
  349. ;; These are the interrupt handlers, responsible for calling __do_IRQ()
  350. ;; int6 is used for syscalls (see _system_call entry)
  351. ;;
  352. .macro SAVE_ALL_INT
  353. SAVE_ALL IRP,ITSR
  354. .endm
  355. .macro CALL_INT int
  356. #ifdef CONFIG_C6X_BIG_KERNEL
  357. MVKL .S1 c6x_do_IRQ,A0
  358. MVKH .S1 c6x_do_IRQ,A0
  359. BNOP .S2X A0,1
  360. MVK .S1 int,A4
  361. ADDAW .D2 SP,2,B4
  362. MVKL .S2 ret_from_interrupt,B3
  363. MVKH .S2 ret_from_interrupt,B3
  364. #else
  365. CALLP .S2 c6x_do_IRQ,B3
  366. || MVK .S1 int,A4
  367. || ADDAW .D2 SP,2,B4
  368. B .S1 ret_from_interrupt
  369. NOP 5
  370. #endif
  371. .endm
  372. ENTRY(_int4_handler)
  373. SAVE_ALL_INT
  374. CALL_INT 4
  375. ENDPROC(_int4_handler)
  376. ENTRY(_int5_handler)
  377. SAVE_ALL_INT
  378. CALL_INT 5
  379. ENDPROC(_int5_handler)
  380. ENTRY(_int6_handler)
  381. SAVE_ALL_INT
  382. CALL_INT 6
  383. ENDPROC(_int6_handler)
  384. ENTRY(_int7_handler)
  385. SAVE_ALL_INT
  386. CALL_INT 7
  387. ENDPROC(_int7_handler)
  388. ENTRY(_int8_handler)
  389. SAVE_ALL_INT
  390. CALL_INT 8
  391. ENDPROC(_int8_handler)
  392. ENTRY(_int9_handler)
  393. SAVE_ALL_INT
  394. CALL_INT 9
  395. ENDPROC(_int9_handler)
  396. ENTRY(_int10_handler)
  397. SAVE_ALL_INT
  398. CALL_INT 10
  399. ENDPROC(_int10_handler)
  400. ENTRY(_int11_handler)
  401. SAVE_ALL_INT
  402. CALL_INT 11
  403. ENDPROC(_int11_handler)
  404. ENTRY(_int12_handler)
  405. SAVE_ALL_INT
  406. CALL_INT 12
  407. ENDPROC(_int12_handler)
  408. ENTRY(_int13_handler)
  409. SAVE_ALL_INT
  410. CALL_INT 13
  411. ENDPROC(_int13_handler)
  412. ENTRY(_int14_handler)
  413. SAVE_ALL_INT
  414. CALL_INT 14
  415. ENDPROC(_int14_handler)
  416. ENTRY(_int15_handler)
  417. SAVE_ALL_INT
  418. CALL_INT 15
  419. ENDPROC(_int15_handler)
  420. ;;
  421. ;; Handler for uninitialized and spurious interrupts
  422. ;;
  423. ENTRY(_bad_interrupt)
  424. B .S2 IRP
  425. NOP 5
  426. ENDPROC(_bad_interrupt)
  427. ;;
  428. ;; Entry for NMI/exceptions/syscall
  429. ;;
  430. ENTRY(_nmi_handler)
  431. SAVE_ALL NRP,NTSR
  432. MVC .S2 EFR,B2
  433. CMPEQ .L2 1,B2,B2
  434. || MVC .S2 TSR,B1
  435. CLR .S2 B1,10,10,B1
  436. MVC .S2 B1,TSR
  437. #ifdef CONFIG_C6X_BIG_KERNEL
  438. [!B2] MVKL .S1 process_exception,A0
  439. [!B2] MVKH .S1 process_exception,A0
  440. [!B2] B .S2X A0
  441. #else
  442. [!B2] B .S2 process_exception
  443. #endif
  444. [B2] B .S2 system_call_saved
  445. [!B2] ADDAW .D2 SP,2,B1
  446. [!B2] MV .D1X B1,A4
  447. ADDKPC .S2 ret_from_trap,B3,2
  448. ret_from_trap:
  449. MV .D2X A4,B0
  450. [!B0] BNOP .S2 ret_from_exception,5
  451. #ifdef CONFIG_C6X_BIG_KERNEL
  452. MVKL .S2 system_call_saved_noack,B3
  453. MVKH .S2 system_call_saved_noack,B3
  454. #endif
  455. LDW .D2T2 *+SP(REGS_B0+8),B0
  456. LDW .D2T1 *+SP(REGS_A4+8),A4
  457. LDW .D2T2 *+SP(REGS_B4+8),B4
  458. LDW .D2T1 *+SP(REGS_A6+8),A6
  459. LDW .D2T2 *+SP(REGS_B6+8),B6
  460. LDW .D2T1 *+SP(REGS_A8+8),A8
  461. #ifdef CONFIG_C6X_BIG_KERNEL
  462. || B .S2 B3
  463. #else
  464. || B .S2 system_call_saved_noack
  465. #endif
  466. LDW .D2T2 *+SP(REGS_B8+8),B8
  467. NOP 4
  468. ENDPROC(_nmi_handler)
  469. ;;
  470. ;; Jump to schedule() then return to ret_from_isr
  471. ;;
  472. #ifdef CONFIG_PREEMPT
  473. resume_kernel:
  474. GET_THREAD_INFO A12
  475. LDW .D1T1 *+A12(THREAD_INFO_PREEMPT_COUNT),A1
  476. NOP 4
  477. [A1] BNOP .S2 restore_all,5
  478. preempt_schedule:
  479. GET_THREAD_INFO A2
  480. LDW .D1T1 *+A2(THREAD_INFO_FLAGS),A1
  481. #ifdef CONFIG_C6X_BIG_KERNEL
  482. MVKL .S2 preempt_schedule_irq,B0
  483. MVKH .S2 preempt_schedule_irq,B0
  484. NOP 2
  485. #else
  486. NOP 4
  487. #endif
  488. AND .D1 _TIF_NEED_RESCHED,A1,A1
  489. [!A1] BNOP .S2 restore_all,5
  490. #ifdef CONFIG_C6X_BIG_KERNEL
  491. B .S2 B0
  492. #else
  493. B .S2 preempt_schedule_irq
  494. #endif
  495. ADDKPC .S2 preempt_schedule,B3,4
  496. #endif /* CONFIG_PREEMPT */
  497. ENTRY(enable_exception)
  498. DINT
  499. MVC .S2 TSR,B0
  500. MVC .S2 B3,NRP
  501. MVK .L2 0xc,B1
  502. OR .D2 B0,B1,B0
  503. MVC .S2 B0,TSR ; Set GEE and XEN in TSR
  504. B .S2 NRP
  505. NOP 5
  506. ENDPROC(enable_exception)
  507. ENTRY(sys_sigaltstack)
  508. #ifdef CONFIG_C6X_BIG_KERNEL
  509. MVKL .S1 do_sigaltstack,A0 ; branch to do_sigaltstack
  510. MVKH .S1 do_sigaltstack,A0
  511. B .S2X A0
  512. #else
  513. B .S2 do_sigaltstack
  514. #endif
  515. LDW .D2T1 *+SP(REGS_SP+8),A6
  516. NOP 4
  517. ENDPROC(sys_sigaltstack)
  518. ;; kernel_execve
  519. ENTRY(kernel_execve)
  520. MVK .S2 __NR_execve,B0
  521. SWE
  522. BNOP .S2 B3,5
  523. ENDPROC(kernel_execve)
  524. ;;
  525. ;; Special system calls
  526. ;; return address is in B3
  527. ;;
  528. ENTRY(sys_clone)
  529. ADD .D1X SP,8,A4
  530. #ifdef CONFIG_C6X_BIG_KERNEL
  531. || MVKL .S1 sys_c6x_clone,A0
  532. MVKH .S1 sys_c6x_clone,A0
  533. BNOP .S2X A0,5
  534. #else
  535. || B .S2 sys_c6x_clone
  536. NOP 5
  537. #endif
  538. ENDPROC(sys_clone)
  539. ENTRY(sys_rt_sigreturn)
  540. ADD .D1X SP,8,A4
  541. #ifdef CONFIG_C6X_BIG_KERNEL
  542. || MVKL .S1 do_rt_sigreturn,A0
  543. MVKH .S1 do_rt_sigreturn,A0
  544. BNOP .S2X A0,5
  545. #else
  546. || B .S2 do_rt_sigreturn
  547. NOP 5
  548. #endif
  549. ENDPROC(sys_rt_sigreturn)
  550. ENTRY(sys_execve)
  551. ADDAW .D2 SP,2,B6 ; put regs addr in 4th parameter
  552. ; & adjust regs stack addr
  553. LDW .D2T2 *+SP(REGS_B4+8),B4
  554. ;; c6x_execve(char *name, char **argv,
  555. ;; char **envp, struct pt_regs *regs)
  556. #ifdef CONFIG_C6X_BIG_KERNEL
  557. || MVKL .S1 sys_c6x_execve,A0
  558. MVKH .S1 sys_c6x_execve,A0
  559. B .S2X A0
  560. #else
  561. || B .S2 sys_c6x_execve
  562. #endif
  563. STW .D2T2 B3,*SP--[2]
  564. ADDKPC .S2 ret_from_c6x_execve,B3,3
  565. ret_from_c6x_execve:
  566. LDW .D2T2 *++SP[2],B3
  567. NOP 4
  568. BNOP .S2 B3,5
  569. ENDPROC(sys_execve)
  570. ENTRY(sys_pread_c6x)
  571. MV .D2X A8,B7
  572. #ifdef CONFIG_C6X_BIG_KERNEL
  573. || MVKL .S1 sys_pread64,A0
  574. MVKH .S1 sys_pread64,A0
  575. BNOP .S2X A0,5
  576. #else
  577. || B .S2 sys_pread64
  578. NOP 5
  579. #endif
  580. ENDPROC(sys_pread_c6x)
  581. ENTRY(sys_pwrite_c6x)
  582. MV .D2X A8,B7
  583. #ifdef CONFIG_C6X_BIG_KERNEL
  584. || MVKL .S1 sys_pwrite64,A0
  585. MVKH .S1 sys_pwrite64,A0
  586. BNOP .S2X A0,5
  587. #else
  588. || B .S2 sys_pwrite64
  589. NOP 5
  590. #endif
  591. ENDPROC(sys_pwrite_c6x)
  592. ;; On Entry
  593. ;; A4 - path
  594. ;; B4 - offset_lo (LE), offset_hi (BE)
  595. ;; A6 - offset_lo (BE), offset_hi (LE)
  596. ENTRY(sys_truncate64_c6x)
  597. #ifdef CONFIG_CPU_BIG_ENDIAN
  598. MV .S2 B4,B5
  599. MV .D2X A6,B4
  600. #else
  601. MV .D2X A6,B5
  602. #endif
  603. #ifdef CONFIG_C6X_BIG_KERNEL
  604. || MVKL .S1 sys_truncate64,A0
  605. MVKH .S1 sys_truncate64,A0
  606. BNOP .S2X A0,5
  607. #else
  608. || B .S2 sys_truncate64
  609. NOP 5
  610. #endif
  611. ENDPROC(sys_truncate64_c6x)
  612. ;; On Entry
  613. ;; A4 - fd
  614. ;; B4 - offset_lo (LE), offset_hi (BE)
  615. ;; A6 - offset_lo (BE), offset_hi (LE)
  616. ENTRY(sys_ftruncate64_c6x)
  617. #ifdef CONFIG_CPU_BIG_ENDIAN
  618. MV .S2 B4,B5
  619. MV .D2X A6,B4
  620. #else
  621. MV .D2X A6,B5
  622. #endif
  623. #ifdef CONFIG_C6X_BIG_KERNEL
  624. || MVKL .S1 sys_ftruncate64,A0
  625. MVKH .S1 sys_ftruncate64,A0
  626. BNOP .S2X A0,5
  627. #else
  628. || B .S2 sys_ftruncate64
  629. NOP 5
  630. #endif
  631. ENDPROC(sys_ftruncate64_c6x)
  632. ;; On Entry
  633. ;; A4 - fd
  634. ;; B4 - offset_lo (LE), offset_hi (BE)
  635. ;; A6 - offset_lo (BE), offset_hi (LE)
  636. ;; B6 - len_lo (LE), len_hi (BE)
  637. ;; A8 - len_lo (BE), len_hi (LE)
  638. ;; B8 - advice
  639. ENTRY(sys_fadvise64_64_c6x)
  640. #ifdef CONFIG_C6X_BIG_KERNEL
  641. MVKL .S1 sys_fadvise64_64,A0
  642. MVKH .S1 sys_fadvise64_64,A0
  643. BNOP .S2X A0,2
  644. #else
  645. B .S2 sys_fadvise64_64
  646. NOP 2
  647. #endif
  648. #ifdef CONFIG_CPU_BIG_ENDIAN
  649. MV .L2 B4,B5
  650. || MV .D2X A6,B4
  651. MV .L1 A8,A6
  652. || MV .D1X B6,A7
  653. #else
  654. MV .D2X A6,B5
  655. MV .L1 A8,A7
  656. || MV .D1X B6,A6
  657. #endif
  658. MV .L2 B8,B6
  659. ENDPROC(sys_fadvise64_64_c6x)
  660. ;; On Entry
  661. ;; A4 - fd
  662. ;; B4 - mode
  663. ;; A6 - offset_hi
  664. ;; B6 - offset_lo
  665. ;; A8 - len_hi
  666. ;; B8 - len_lo
  667. ENTRY(sys_fallocate_c6x)
  668. #ifdef CONFIG_C6X_BIG_KERNEL
  669. MVKL .S1 sys_fallocate,A0
  670. MVKH .S1 sys_fallocate,A0
  671. BNOP .S2X A0,1
  672. #else
  673. B .S2 sys_fallocate
  674. NOP
  675. #endif
  676. MV .D1 A6,A7
  677. MV .D1X B6,A6
  678. MV .D2X A8,B7
  679. MV .D2 B8,B6
  680. ENDPROC(sys_fallocate_c6x)
  681. ;; put this in .neardata for faster access when using DSBT mode
  682. .section .neardata,"aw",@progbits
  683. .global current_ksp
  684. .hidden current_ksp
  685. current_ksp:
  686. .word init_thread_union + THREAD_START_SP