entry.S 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. /*
  2. * linux/arch/cris/entry.S
  3. *
  4. * Copyright (C) 2000, 2001, 2002 Axis Communications AB
  5. *
  6. * Authors: Bjorn Wesen (bjornw@axis.com)
  7. */
  8. /*
  9. * entry.S contains the system-call and fault low-level handling routines.
  10. *
  11. * NOTE: This code handles signal-recognition, which happens every time
  12. * after a timer-interrupt and after each system call.
  13. *
  14. * Stack layout in 'ret_from_system_call':
  15. * ptrace needs to have all regs on the stack.
  16. * if the order here is changed, it needs to be
  17. * updated in fork.c:copy_process, signal.c:do_signal,
  18. * ptrace.c and ptrace.h
  19. *
  20. */
  21. #include <linux/linkage.h>
  22. #include <linux/sys.h>
  23. #include <asm/unistd.h>
  24. #include <arch/sv_addr_ag.h>
  25. #include <asm/errno.h>
  26. #include <asm/thread_info.h>
  27. #include <asm/asm-offsets.h>
  28. #include <asm/page.h>
  29. #include <asm/pgtable.h>
  30. ;; functions exported from this file
  31. .globl system_call
  32. .globl ret_from_intr
  33. .globl ret_from_fork
  34. .globl resume
  35. .globl multiple_interrupt
  36. .globl hwbreakpoint
  37. .globl IRQ1_interrupt
  38. .globl spurious_interrupt
  39. .globl hw_bp_trigs
  40. .globl mmu_bus_fault
  41. .globl do_sigtrap
  42. .globl gdb_handle_breakpoint
  43. .globl sys_call_table
  44. ;; below are various parts of system_call which are not in the fast-path
  45. #ifdef CONFIG_PREEMPT
  46. ; Check if preemptive kernel scheduling should be done
  47. _resume_kernel:
  48. di
  49. ; Load current task struct
  50. movs.w -8192, $r0 ; THREAD_SIZE = 8192
  51. and.d $sp, $r0
  52. move.d [$r0+TI_preempt_count], $r10 ; Preemption disabled?
  53. bne _Rexit
  54. nop
  55. _need_resched:
  56. move.d [$r0+TI_flags], $r10
  57. btstq TIF_NEED_RESCHED, $r10 ; Check if need_resched is set
  58. bpl _Rexit
  59. nop
  60. ; Ok, lets's do some preemptive kernel scheduling
  61. jsr preempt_schedule_irq
  62. ; Load new task struct
  63. movs.w -8192, $r0 ; THREAD_SIZE = 8192
  64. and.d $sp, $r0
  65. ; One more time (with new task)
  66. ba _need_resched
  67. nop
  68. #else
  69. #define _resume_kernel _Rexit
  70. #endif
  71. ; Called at exit from fork. schedule_tail must be called to drop
  72. ; spinlock if CONFIG_PREEMPT
  73. ret_from_fork:
  74. jsr schedule_tail
  75. ba ret_from_sys_call
  76. nop
  77. ret_from_intr:
  78. ;; check for resched if preemptive kernel or if we're going back to user-mode
  79. ;; this test matches the user_regs(regs) macro
  80. ;; we cannot simply test $dccr, because that does not necessarily
  81. ;; reflect what mode we'll return into.
  82. move.d [$sp + PT_dccr], $r0; regs->dccr
  83. btstq 8, $r0 ; U-flag
  84. bpl _resume_kernel
  85. ; Note that di below is in delay slot
  86. _resume_userspace:
  87. di ; so need_resched and sigpending don't change
  88. movs.w -8192, $r0 ; THREAD_SIZE == 8192
  89. and.d $sp, $r0
  90. move.d [$r0+TI_flags], $r10 ; current->work
  91. and.d _TIF_WORK_MASK, $r10 ; is there any work to be done on return
  92. bne _work_pending
  93. nop
  94. ba _Rexit
  95. nop
  96. ;; The system_call is called by a BREAK instruction, which works like
  97. ;; an interrupt call but it stores the return PC in BRP instead of IRP.
  98. ;; Since we dont really want to have two epilogues (one for system calls
  99. ;; and one for interrupts) we push the contents of BRP instead of IRP in the
  100. ;; system call prologue, to make it look like an ordinary interrupt on the
  101. ;; stackframe.
  102. ;;
  103. ;; Since we can't have system calls inside interrupts, it should not matter
  104. ;; that we don't stack IRP.
  105. ;;
  106. ;; In r9 we have the wanted syscall number. Arguments come in r10,r11,r12,r13,mof,srp
  107. ;;
  108. ;; This function looks on the _surface_ like spaghetti programming, but it's
  109. ;; really designed so that the fast-path does not force cache-loading of non-used
  110. ;; instructions. Only the non-common cases cause the outlined code to run..
  111. system_call:
  112. ;; stack-frame similar to the irq heads, which is reversed in ret_from_sys_call
  113. move $brp,[$sp=$sp-16]; instruction pointer and room for a fake SBFS frame
  114. push $srp
  115. push $dccr
  116. push $mof
  117. subq 14*4, $sp ; make room for r0-r13
  118. movem $r13, [$sp] ; push r0-r13
  119. push $r10 ; push orig_r10
  120. clear.d [$sp=$sp-4] ; frametype == 0, normal stackframe
  121. movs.w -ENOSYS, $r0
  122. move.d $r0, [$sp+PT_r10] ; put the default return value in r10 in the frame
  123. ;; check if this process is syscall-traced
  124. movs.w -8192, $r0 ; THREAD_SIZE == 8192
  125. and.d $sp, $r0
  126. move.d [$r0+TI_flags], $r0
  127. btstq TIF_SYSCALL_TRACE, $r0
  128. bmi _syscall_trace_entry
  129. nop
  130. _syscall_traced:
  131. ;; check for sanity in the requested syscall number
  132. cmpu.w NR_syscalls, $r9
  133. bcc ret_from_sys_call
  134. lslq 2, $r9 ; multiply by 4, in the delay slot
  135. ;; as a bonus 7th parameter, we give the location on the stack
  136. ;; of the register structure itself. some syscalls need this.
  137. push $sp
  138. ;; the parameter carrying registers r10, r11, r12 and 13 are intact.
  139. ;; the fifth and sixth parameters (if any) was in mof and srp
  140. ;; respectively, and we need to put them on the stack.
  141. push $srp
  142. push $mof
  143. jsr [$r9+sys_call_table] ; actually do the system call
  144. addq 3*4, $sp ; pop the mof, srp and regs parameters
  145. move.d $r10, [$sp+PT_r10] ; save the return value
  146. moveq 1, $r9 ; "parameter" to ret_from_sys_call to show it was a sys call
  147. ;; fall through into ret_from_sys_call to return
  148. ret_from_sys_call:
  149. ;; r9 is a parameter - if >=1 we came from a syscall, if 0, from an irq
  150. ;; get the current task-struct pointer (see top for defs)
  151. movs.w -8192, $r0 ; THREAD_SIZE == 8192
  152. and.d $sp, $r0
  153. di ; make sure need_resched and sigpending don't change
  154. move.d [$r0+TI_flags],$r1
  155. and.d _TIF_ALLWORK_MASK, $r1
  156. bne _syscall_exit_work
  157. nop
  158. _Rexit:
  159. ;; this epilogue MUST match the prologues in multiple_interrupt, irq.h and ptregs.h
  160. pop $r10 ; frametype
  161. bne _RBFexit ; was not CRIS_FRAME_NORMAL, handle otherwise
  162. addq 4, $sp ; skip orig_r10, in delayslot
  163. movem [$sp+], $r13 ; registers r0-r13
  164. pop $mof ; multiply overflow register
  165. pop $dccr ; condition codes
  166. pop $srp ; subroutine return pointer
  167. ;; now we have a 4-word SBFS frame which we do not want to restore
  168. ;; using RBF since it was not stacked with SBFS. instead we would like to
  169. ;; just get the PC value to restart it with, and skip the rest of
  170. ;; the frame.
  171. ;; Also notice that it's important to use instructions here that
  172. ;; keep the interrupts disabled (since we've already popped DCCR)
  173. move [$sp=$sp+16], $p8; pop the SBFS frame from the sp
  174. jmpu [$sp-16] ; return through the irp field in the sbfs frame
  175. _RBFexit:
  176. movem [$sp+], $r13 ; registers r0-r13, in delay slot
  177. pop $mof ; multiply overflow register
  178. pop $dccr ; condition codes
  179. pop $srp ; subroutine return pointer
  180. rbf [$sp+] ; return by popping the CPU status
  181. ;; We get here after doing a syscall if extra work might need to be done
  182. ;; perform syscall exit tracing if needed
  183. _syscall_exit_work:
  184. ;; $r0 contains current at this point and irq's are disabled
  185. move.d [$r0+TI_flags], $r1
  186. btstq TIF_SYSCALL_TRACE, $r1
  187. bpl _work_pending
  188. nop
  189. ei
  190. move.d $r9, $r1 ; preserve r9
  191. jsr do_syscall_trace
  192. move.d $r1, $r9
  193. ba _resume_userspace
  194. nop
  195. _work_pending:
  196. move.d [$r0+TI_flags], $r1
  197. btstq TIF_NEED_RESCHED, $r1
  198. bpl _work_notifysig ; was neither trace nor sched, must be signal/notify
  199. nop
  200. _work_resched:
  201. move.d $r9, $r1 ; preserve r9
  202. jsr schedule
  203. move.d $r1, $r9
  204. di
  205. move.d [$r0+TI_flags], $r1
  206. and.d _TIF_WORK_MASK, $r1; ignore the syscall trace counter
  207. beq _Rexit
  208. nop
  209. btstq TIF_NEED_RESCHED, $r1
  210. bmi _work_resched ; current->work.need_resched
  211. nop
  212. _work_notifysig:
  213. ;; deal with pending signals and notify-resume requests
  214. move.d $r9, $r10 ; do_notify_resume syscall/irq param
  215. move.d $sp, $r11 ; the regs param
  216. move.d $r1, $r12 ; the thread_info_flags parameter
  217. jsr do_notify_resume
  218. ba _Rexit
  219. nop
  220. ;; We get here as a sidetrack when we've entered a syscall with the
  221. ;; trace-bit set. We need to call do_syscall_trace and then continue
  222. ;; with the call.
  223. _syscall_trace_entry:
  224. ;; PT_r10 in the frame contains -ENOSYS as required, at this point
  225. jsr do_syscall_trace
  226. ;; now re-enter the syscall code to do the syscall itself
  227. ;; we need to restore $r9 here to contain the wanted syscall, and
  228. ;; the other parameter-bearing registers
  229. move.d [$sp+PT_r9], $r9
  230. move.d [$sp+PT_orig_r10], $r10 ; PT_r10 is already filled with -ENOSYS.
  231. move.d [$sp+PT_r11], $r11
  232. move.d [$sp+PT_r12], $r12
  233. move.d [$sp+PT_r13], $r13
  234. move [$sp+PT_mof], $mof
  235. move [$sp+PT_srp], $srp
  236. ba _syscall_traced
  237. nop
  238. ;; resume performs the actual task-switching, by switching stack pointers
  239. ;; input arguments: r10 = prev, r11 = next, r12 = thread offset in task struct
  240. ;; returns old current in r10
  241. ;;
  242. ;; TODO: see the i386 version. The switch_to which calls resume in our version
  243. ;; could really be an inline asm of this.
  244. resume:
  245. push $srp ; we keep the old/new PC on the stack
  246. add.d $r12, $r10 ; r10 = current tasks tss
  247. move $dccr, [$r10+THREAD_dccr]; save irq enable state
  248. di
  249. move $usp, [$r10+ THREAD_usp] ; save user-mode stackpointer
  250. ;; See copy_thread for the reason why register R9 is saved.
  251. subq 10*4, $sp
  252. movem $r9, [$sp] ; save non-scratch registers and R9.
  253. move.d $sp, [$r10+THREAD_ksp] ; save the kernel stack pointer for the old task
  254. move.d $sp, $r10 ; return last running task in r10
  255. and.d -8192, $r10 ; get thread_info from stackpointer
  256. move.d [$r10+TI_task], $r10 ; get task
  257. add.d $r12, $r11 ; find the new tasks tss
  258. move.d [$r11+THREAD_ksp], $sp ; switch into the new stackframe by restoring kernel sp
  259. movem [$sp+], $r9 ; restore non-scratch registers and R9.
  260. move [$r11+THREAD_usp], $usp ; restore user-mode stackpointer
  261. move [$r11+THREAD_dccr], $dccr ; restore irq enable status
  262. jump [$sp+] ; restore PC
  263. ;; This is the MMU bus fault handler.
  264. ;; It needs to stack the CPU status and overall is different
  265. ;; from the other interrupt handlers.
  266. mmu_bus_fault:
  267. ;; For refills we try to do a quick page table lookup. If it is
  268. ;; a real fault we let the mm subsystem handle it.
  269. ;; the first longword in the sbfs frame was the interrupted PC
  270. ;; which fits nicely with the "IRP" slot in pt_regs normally used to
  271. ;; contain the return address. used by Oops to print kernel errors.
  272. sbfs [$sp=$sp-16] ; push the internal CPU status
  273. push $dccr
  274. di
  275. subq 2*4, $sp
  276. movem $r1, [$sp]
  277. move.d [R_MMU_CAUSE], $r1
  278. ;; ETRAX 100LX TR89 bugfix: if the second half of an unaligned
  279. ;; write causes a MMU-fault, it will not be restarted correctly.
  280. ;; This could happen if a write crosses a page-boundary and the
  281. ;; second page is not yet COW'ed or even loaded. The workaround
  282. ;; is to clear the unaligned bit in the CPU status record, so
  283. ;; that the CPU will rerun both the first and second halves of
  284. ;; the instruction. This will not have any sideeffects unless
  285. ;; the first half goes to any device or memory that can't be
  286. ;; written twice, and which is mapped through the MMU.
  287. ;;
  288. ;; We only need to do this for writes.
  289. btstq 8, $r1 ; Write access?
  290. bpl 1f
  291. nop
  292. move.d [$sp+16], $r0 ; Clear unaligned bit in csrinstr
  293. and.d ~(1<<5), $r0
  294. move.d $r0, [$sp+16]
  295. 1: btstq 12, $r1 ; Refill?
  296. bpl 2f
  297. lsrq 24, $r1 ; Get PGD index (bit 24-31)
  298. move.d [current_pgd], $r0 ; PGD for the current process
  299. move.d [$r0+$r1.d], $r0 ; Get PMD
  300. beq 2f
  301. nop
  302. and.w PAGE_MASK, $r0 ; Remove PMD flags
  303. move.d [R_MMU_CAUSE], $r1
  304. lsrq PAGE_SHIFT, $r1
  305. and.d 0x7ff, $r1 ; Get PTE index into PGD (bit 13-23)
  306. move.d [$r0+$r1.d], $r1 ; Get PTE
  307. beq 2f
  308. nop
  309. ;; Store in TLB
  310. move.d $r1, [R_TLB_LO]
  311. ;; Return
  312. movem [$sp+], $r1
  313. pop $dccr
  314. rbf [$sp+] ; return by popping the CPU status
  315. 2: ; PMD or PTE missing, let the mm subsystem fix it up.
  316. movem [$sp+], $r1
  317. pop $dccr
  318. ; Ok, not that easy, pass it on to the mm subsystem
  319. ; The MMU status record is now on the stack
  320. push $srp ; make a stackframe similar to pt_regs
  321. push $dccr
  322. push $mof
  323. di
  324. subq 14*4, $sp
  325. movem $r13, [$sp]
  326. push $r10 ; dummy orig_r10
  327. moveq 1, $r10
  328. push $r10 ; frametype == 1, BUSFAULT frame type
  329. move.d $sp, $r10 ; pt_regs argument to handle_mmu_bus_fault
  330. jsr handle_mmu_bus_fault ; in arch/cris/arch-v10/mm/fault.c
  331. ;; now we need to return through the normal path, we cannot just
  332. ;; do the RBFexit since we might have killed off the running
  333. ;; process due to a SEGV, scheduled due to a page blocking or
  334. ;; whatever.
  335. moveq 0, $r9 ; busfault is equivalent to an irq
  336. ba ret_from_intr
  337. nop
  338. ;; special handlers for breakpoint and NMI
  339. hwbreakpoint:
  340. push $dccr
  341. di
  342. push $r10
  343. push $r11
  344. move.d [hw_bp_trig_ptr],$r10
  345. move $brp,$r11
  346. move.d $r11,[$r10+]
  347. move.d $r10,[hw_bp_trig_ptr]
  348. 1: pop $r11
  349. pop $r10
  350. pop $dccr
  351. retb
  352. nop
  353. IRQ1_interrupt:
  354. ;; this prologue MUST match the one in irq.h and the struct in ptregs.h!!!
  355. move $brp,[$sp=$sp-16]; instruction pointer and room for a fake SBFS frame
  356. push $srp
  357. push $dccr
  358. push $mof
  359. di
  360. subq 14*4, $sp
  361. movem $r13, [$sp]
  362. push $r10 ; push orig_r10
  363. clear.d [$sp=$sp-4] ; frametype == 0, normal frame
  364. ;; If there is a glitch on the NMI pin shorter than ~100ns
  365. ;; (i.e. non-active by the time we get here) then the nmi_pin bit
  366. ;; in R_IRQ_MASK0_RD will already be cleared. The watchdog_nmi bit
  367. ;; is cleared by us however (when feeding the watchdog), which is why
  368. ;; we use that bit to determine what brought us here.
  369. move.d [R_IRQ_MASK0_RD], $r1 ; External NMI or watchdog?
  370. and.d (1<<30), $r1
  371. bne wdog
  372. move.d $sp, $r10
  373. jsr handle_nmi
  374. setf m ; Enable NMI again
  375. ba _Rexit ; Return the standard way
  376. nop
  377. wdog:
  378. #if defined(CONFIG_ETRAX_WATCHDOG) && !defined(CONFIG_SVINTO_SIM)
  379. ;; Check if we're waiting for reset to happen, as signalled by
  380. ;; hard_reset_now setting cause_of_death to a magic value. If so, just
  381. ;; get stuck until reset happens.
  382. .comm cause_of_death, 4 ;; Don't declare this anywhere.
  383. move.d [cause_of_death], $r10
  384. cmp.d 0xbedead, $r10
  385. _killed_by_death:
  386. beq _killed_by_death
  387. nop
  388. ;; We'll see this in ksymoops dumps.
  389. Watchdog_bite:
  390. #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
  391. ;; We just restart the watchdog here to be sure we dont get
  392. ;; hit while printing the watchdogmsg below
  393. ;; This restart is compatible with the rest of the C-code, so
  394. ;; the C-code can keep restarting the watchdog after this point.
  395. ;; The non-NICE_DOGGY code below though, disables the possibility
  396. ;; to restart since it changes the watchdog key, to avoid any
  397. ;; buggy loops etc. keeping the watchdog alive after this.
  398. jsr reset_watchdog
  399. #else
  400. ;; We need to extend the 3.3ms after the NMI at watchdog bite, so we have
  401. ;; time for an oops-dump over a 115k2 serial wire. Another 100ms should do.
  402. ;; Change the watchdog key to an arbitrary 3-bit value and restart the
  403. ;; watchdog.
  404. #define WD_INIT 2
  405. moveq IO_FIELD (R_WATCHDOG, key, WD_INIT), $r10
  406. move.d R_WATCHDOG, $r11
  407. move.d $r10, [$r11]
  408. moveq IO_FIELD (R_WATCHDOG, key, \
  409. IO_EXTRACT (R_WATCHDOG, key, \
  410. IO_MASK (R_WATCHDOG, key)) \
  411. ^ WD_INIT) \
  412. | IO_STATE (R_WATCHDOG, enable, start), $r10
  413. move.d $r10, [$r11]
  414. #endif
  415. ;; Note that we don't do "setf m" here (or after two necessary NOPs),
  416. ;; since *not* doing that saves us from re-entrancy checks. We don't want
  417. ;; to get here again due to possible subsequent NMIs; we want the watchdog
  418. ;; to reset us.
  419. move.d _watchdogmsg,$r10
  420. jsr printk
  421. move.d $sp, $r10
  422. jsr watchdog_bite_hook
  423. ;; This nop is here so we see the "Watchdog_bite" label in ksymoops dumps
  424. ;; rather than "spurious_interrupt".
  425. nop
  426. ;; At this point we drop down into spurious_interrupt, which will do a
  427. ;; hard reset.
  428. .section .rodata,"a"
  429. _watchdogmsg:
  430. .ascii "Oops: bitten by watchdog\n\0"
  431. .previous
  432. #endif /* CONFIG_ETRAX_WATCHDOG and not CONFIG_SVINTO_SIM */
  433. spurious_interrupt:
  434. di
  435. jump hard_reset_now
  436. ;; this handles the case when multiple interrupts arrive at the same time
  437. ;; we jump to the first set interrupt bit in a priority fashion
  438. ;; the hardware will call the unserved interrupts after the handler finishes
  439. multiple_interrupt:
  440. ;; this prologue MUST match the one in irq.h and the struct in ptregs.h!!!
  441. move $irp,[$sp=$sp-16]; instruction pointer and room for a fake SBFS frame
  442. push $srp
  443. push $dccr
  444. push $mof
  445. di
  446. subq 14*4, $sp
  447. movem $r13, [$sp]
  448. push $r10 ; push orig_r10
  449. clear.d [$sp=$sp-4] ; frametype == 0, normal frame
  450. move.d $sp, $r10
  451. jsr do_multiple_IRQ
  452. jump ret_from_intr
  453. do_sigtrap:
  454. ;;
  455. ;; SIGTRAP the process that executed the break instruction.
  456. ;; Make a frame that Rexit in entry.S expects.
  457. ;;
  458. move $brp, [$sp=$sp-16] ; Push BRP while faking a cpu status record.
  459. push $srp ; Push subroutine return pointer.
  460. push $dccr ; Push condition codes.
  461. push $mof ; Push multiply overflow reg.
  462. di ; Need to disable irq's at this point.
  463. subq 14*4, $sp ; Make room for r0-r13.
  464. movem $r13, [$sp] ; Push the r0-r13 registers.
  465. push $r10 ; Push orig_r10.
  466. clear.d [$sp=$sp-4] ; Frametype - this is a normal stackframe.
  467. movs.w -8192,$r9 ; THREAD_SIZE == 8192
  468. and.d $sp, $r9
  469. move.d [$r9+TI_task], $r10
  470. move.d [$r10+TASK_pid], $r10 ; current->pid as arg1.
  471. moveq 5, $r11 ; SIGTRAP as arg2.
  472. jsr sys_kill
  473. jump ret_from_intr ; Use the return routine for interrupts.
  474. gdb_handle_breakpoint:
  475. push $dccr
  476. push $r0
  477. #ifdef CONFIG_ETRAX_KGDB
  478. move $dccr, $r0 ; U-flag not affected by previous insns.
  479. btstq 8, $r0 ; Test the U-flag.
  480. bmi _ugdb_handle_breakpoint ; Go to user mode debugging.
  481. nop ; Empty delay slot (cannot pop r0 here).
  482. pop $r0 ; Restore r0.
  483. ba kgdb_handle_breakpoint ; Go to kernel debugging.
  484. pop $dccr ; Restore dccr in delay slot.
  485. #endif
  486. _ugdb_handle_breakpoint:
  487. move $brp, $r0 ; Use r0 temporarily for calculation.
  488. subq 2, $r0 ; Set to address of previous instruction.
  489. move $r0, $brp
  490. pop $r0 ; Restore r0.
  491. ba do_sigtrap ; SIGTRAP the offending process.
  492. pop $dccr ; Restore dccr in delay slot.
  493. .global kernel_execve
  494. kernel_execve:
  495. move.d __NR_execve, $r9
  496. break 13
  497. ret
  498. nop
  499. .data
  500. hw_bp_trigs:
  501. .space 64*4
  502. hw_bp_trig_ptr:
  503. .dword hw_bp_trigs
  504. .section .rodata,"a"
  505. sys_call_table:
  506. .long sys_restart_syscall /* 0 - old "setup()" system call, used for restarting */
  507. .long sys_exit
  508. .long sys_fork
  509. .long sys_read
  510. .long sys_write
  511. .long sys_open /* 5 */
  512. .long sys_close
  513. .long sys_waitpid
  514. .long sys_creat
  515. .long sys_link
  516. .long sys_unlink /* 10 */
  517. .long sys_execve
  518. .long sys_chdir
  519. .long sys_time
  520. .long sys_mknod
  521. .long sys_chmod /* 15 */
  522. .long sys_lchown16
  523. .long sys_ni_syscall /* old break syscall holder */
  524. .long sys_stat
  525. .long sys_lseek
  526. .long sys_getpid /* 20 */
  527. .long sys_mount
  528. .long sys_oldumount
  529. .long sys_setuid16
  530. .long sys_getuid16
  531. .long sys_stime /* 25 */
  532. .long sys_ptrace
  533. .long sys_alarm
  534. .long sys_fstat
  535. .long sys_pause
  536. .long sys_utime /* 30 */
  537. .long sys_ni_syscall /* old stty syscall holder */
  538. .long sys_ni_syscall /* old gtty syscall holder */
  539. .long sys_access
  540. .long sys_nice
  541. .long sys_ni_syscall /* 35 old ftime syscall holder */
  542. .long sys_sync
  543. .long sys_kill
  544. .long sys_rename
  545. .long sys_mkdir
  546. .long sys_rmdir /* 40 */
  547. .long sys_dup
  548. .long sys_pipe
  549. .long sys_times
  550. .long sys_ni_syscall /* old prof syscall holder */
  551. .long sys_brk /* 45 */
  552. .long sys_setgid16
  553. .long sys_getgid16
  554. .long sys_signal
  555. .long sys_geteuid16
  556. .long sys_getegid16 /* 50 */
  557. .long sys_acct
  558. .long sys_umount /* recycled never used phys( */
  559. .long sys_ni_syscall /* old lock syscall holder */
  560. .long sys_ioctl
  561. .long sys_fcntl /* 55 */
  562. .long sys_ni_syscall /* old mpx syscall holder */
  563. .long sys_setpgid
  564. .long sys_ni_syscall /* old ulimit syscall holder */
  565. .long sys_ni_syscall /* old sys_olduname holder */
  566. .long sys_umask /* 60 */
  567. .long sys_chroot
  568. .long sys_ustat
  569. .long sys_dup2
  570. .long sys_getppid
  571. .long sys_getpgrp /* 65 */
  572. .long sys_setsid
  573. .long sys_sigaction
  574. .long sys_sgetmask
  575. .long sys_ssetmask
  576. .long sys_setreuid16 /* 70 */
  577. .long sys_setregid16
  578. .long sys_sigsuspend
  579. .long sys_sigpending
  580. .long sys_sethostname
  581. .long sys_setrlimit /* 75 */
  582. .long sys_old_getrlimit
  583. .long sys_getrusage
  584. .long sys_gettimeofday
  585. .long sys_settimeofday
  586. .long sys_getgroups16 /* 80 */
  587. .long sys_setgroups16
  588. .long sys_select /* was old_select in Linux/E100 */
  589. .long sys_symlink
  590. .long sys_lstat
  591. .long sys_readlink /* 85 */
  592. .long sys_uselib
  593. .long sys_swapon
  594. .long sys_reboot
  595. .long sys_old_readdir
  596. .long sys_old_mmap /* 90 */
  597. .long sys_munmap
  598. .long sys_truncate
  599. .long sys_ftruncate
  600. .long sys_fchmod
  601. .long sys_fchown16 /* 95 */
  602. .long sys_getpriority
  603. .long sys_setpriority
  604. .long sys_ni_syscall /* old profil syscall holder */
  605. .long sys_statfs
  606. .long sys_fstatfs /* 100 */
  607. .long sys_ni_syscall /* sys_ioperm in i386 */
  608. .long sys_socketcall
  609. .long sys_syslog
  610. .long sys_setitimer
  611. .long sys_getitimer /* 105 */
  612. .long sys_newstat
  613. .long sys_newlstat
  614. .long sys_newfstat
  615. .long sys_ni_syscall /* old sys_uname holder */
  616. .long sys_ni_syscall /* sys_iopl in i386 */
  617. .long sys_vhangup
  618. .long sys_ni_syscall /* old "idle" system call */
  619. .long sys_ni_syscall /* vm86old in i386 */
  620. .long sys_wait4
  621. .long sys_swapoff /* 115 */
  622. .long sys_sysinfo
  623. .long sys_ipc
  624. .long sys_fsync
  625. .long sys_sigreturn
  626. .long sys_clone /* 120 */
  627. .long sys_setdomainname
  628. .long sys_newuname
  629. .long sys_ni_syscall /* sys_modify_ldt */
  630. .long sys_adjtimex
  631. .long sys_mprotect /* 125 */
  632. .long sys_sigprocmask
  633. .long sys_ni_syscall /* old "create_module" */
  634. .long sys_init_module
  635. .long sys_delete_module
  636. .long sys_ni_syscall /* 130: old "get_kernel_syms" */
  637. .long sys_quotactl
  638. .long sys_getpgid
  639. .long sys_fchdir
  640. .long sys_bdflush
  641. .long sys_sysfs /* 135 */
  642. .long sys_personality
  643. .long sys_ni_syscall /* for afs_syscall */
  644. .long sys_setfsuid16
  645. .long sys_setfsgid16
  646. .long sys_llseek /* 140 */
  647. .long sys_getdents
  648. .long sys_select
  649. .long sys_flock
  650. .long sys_msync
  651. .long sys_readv /* 145 */
  652. .long sys_writev
  653. .long sys_getsid
  654. .long sys_fdatasync
  655. .long sys_sysctl
  656. .long sys_mlock /* 150 */
  657. .long sys_munlock
  658. .long sys_mlockall
  659. .long sys_munlockall
  660. .long sys_sched_setparam
  661. .long sys_sched_getparam /* 155 */
  662. .long sys_sched_setscheduler
  663. .long sys_sched_getscheduler
  664. .long sys_sched_yield
  665. .long sys_sched_get_priority_max
  666. .long sys_sched_get_priority_min /* 160 */
  667. .long sys_sched_rr_get_interval
  668. .long sys_nanosleep
  669. .long sys_mremap
  670. .long sys_setresuid16
  671. .long sys_getresuid16 /* 165 */
  672. .long sys_ni_syscall /* sys_vm86 */
  673. .long sys_ni_syscall /* Old sys_query_module */
  674. .long sys_poll
  675. .long sys_nfsservctl
  676. .long sys_setresgid16 /* 170 */
  677. .long sys_getresgid16
  678. .long sys_prctl
  679. .long sys_rt_sigreturn
  680. .long sys_rt_sigaction
  681. .long sys_rt_sigprocmask /* 175 */
  682. .long sys_rt_sigpending
  683. .long sys_rt_sigtimedwait
  684. .long sys_rt_sigqueueinfo
  685. .long sys_rt_sigsuspend
  686. .long sys_pread64 /* 180 */
  687. .long sys_pwrite64
  688. .long sys_chown16
  689. .long sys_getcwd
  690. .long sys_capget
  691. .long sys_capset /* 185 */
  692. .long sys_sigaltstack
  693. .long sys_sendfile
  694. .long sys_ni_syscall /* streams1 */
  695. .long sys_ni_syscall /* streams2 */
  696. .long sys_vfork /* 190 */
  697. .long sys_getrlimit
  698. .long sys_mmap2
  699. .long sys_truncate64
  700. .long sys_ftruncate64
  701. .long sys_stat64 /* 195 */
  702. .long sys_lstat64
  703. .long sys_fstat64
  704. .long sys_lchown
  705. .long sys_getuid
  706. .long sys_getgid /* 200 */
  707. .long sys_geteuid
  708. .long sys_getegid
  709. .long sys_setreuid
  710. .long sys_setregid
  711. .long sys_getgroups /* 205 */
  712. .long sys_setgroups
  713. .long sys_fchown
  714. .long sys_setresuid
  715. .long sys_getresuid
  716. .long sys_setresgid /* 210 */
  717. .long sys_getresgid
  718. .long sys_chown
  719. .long sys_setuid
  720. .long sys_setgid
  721. .long sys_setfsuid /* 215 */
  722. .long sys_setfsgid
  723. .long sys_pivot_root
  724. .long sys_mincore
  725. .long sys_madvise
  726. .long sys_getdents64 /* 220 */
  727. .long sys_fcntl64
  728. .long sys_ni_syscall /* reserved for TUX */
  729. .long sys_ni_syscall
  730. .long sys_gettid
  731. .long sys_readahead /* 225 */
  732. .long sys_setxattr
  733. .long sys_lsetxattr
  734. .long sys_fsetxattr
  735. .long sys_getxattr
  736. .long sys_lgetxattr /* 230 */
  737. .long sys_fgetxattr
  738. .long sys_listxattr
  739. .long sys_llistxattr
  740. .long sys_flistxattr
  741. .long sys_removexattr /* 235 */
  742. .long sys_lremovexattr
  743. .long sys_fremovexattr
  744. .long sys_tkill
  745. .long sys_sendfile64
  746. .long sys_futex /* 240 */
  747. .long sys_sched_setaffinity
  748. .long sys_sched_getaffinity
  749. .long sys_ni_syscall /* sys_set_thread_area */
  750. .long sys_ni_syscall /* sys_get_thread_area */
  751. .long sys_io_setup /* 245 */
  752. .long sys_io_destroy
  753. .long sys_io_getevents
  754. .long sys_io_submit
  755. .long sys_io_cancel
  756. .long sys_fadvise64 /* 250 */
  757. .long sys_ni_syscall
  758. .long sys_exit_group
  759. .long sys_lookup_dcookie
  760. .long sys_epoll_create
  761. .long sys_epoll_ctl /* 255 */
  762. .long sys_epoll_wait
  763. .long sys_remap_file_pages
  764. .long sys_set_tid_address
  765. .long sys_timer_create
  766. .long sys_timer_settime /* 260 */
  767. .long sys_timer_gettime
  768. .long sys_timer_getoverrun
  769. .long sys_timer_delete
  770. .long sys_clock_settime
  771. .long sys_clock_gettime /* 265 */
  772. .long sys_clock_getres
  773. .long sys_clock_nanosleep
  774. .long sys_statfs64
  775. .long sys_fstatfs64
  776. .long sys_tgkill /* 270 */
  777. .long sys_utimes
  778. .long sys_fadvise64_64
  779. .long sys_ni_syscall /* sys_vserver */
  780. .long sys_ni_syscall /* sys_mbind */
  781. .long sys_ni_syscall /* 275 sys_get_mempolicy */
  782. .long sys_ni_syscall /* sys_set_mempolicy */
  783. .long sys_mq_open
  784. .long sys_mq_unlink
  785. .long sys_mq_timedsend
  786. .long sys_mq_timedreceive /* 280 */
  787. .long sys_mq_notify
  788. .long sys_mq_getsetattr
  789. .long sys_ni_syscall /* reserved for kexec */
  790. .long sys_waitid
  791. .long sys_ni_syscall /* 285 */ /* available */
  792. .long sys_add_key
  793. .long sys_request_key
  794. .long sys_keyctl
  795. .long sys_ioprio_set
  796. .long sys_ioprio_get /* 290 */
  797. .long sys_inotify_init
  798. .long sys_inotify_add_watch
  799. .long sys_inotify_rm_watch
  800. .long sys_migrate_pages
  801. .long sys_openat /* 295 */
  802. .long sys_mkdirat
  803. .long sys_mknodat
  804. .long sys_fchownat
  805. .long sys_futimesat
  806. .long sys_fstatat64 /* 300 */
  807. .long sys_unlinkat
  808. .long sys_renameat
  809. .long sys_linkat
  810. .long sys_symlinkat
  811. .long sys_readlinkat /* 305 */
  812. .long sys_fchmodat
  813. .long sys_faccessat
  814. .long sys_pselect6
  815. .long sys_ppoll
  816. .long sys_unshare /* 310 */
  817. .long sys_set_robust_list
  818. .long sys_get_robust_list
  819. .long sys_splice
  820. .long sys_sync_file_range
  821. .long sys_tee /* 315 */
  822. .long sys_vmsplice
  823. .long sys_move_pages
  824. .long sys_getcpu
  825. .long sys_epoll_pwait
  826. .long sys_utimensat /* 320 */
  827. .long sys_signalfd
  828. .long sys_timerfd_create
  829. .long sys_eventfd
  830. .long sys_fallocate
  831. .long sys_timerfd_settime /* 325 */
  832. .long sys_timerfd_gettime
  833. .long sys_signalfd4
  834. .long sys_eventfd2
  835. .long sys_epoll_create1
  836. .long sys_dup3 /* 330 */
  837. .long sys_pipe2
  838. .long sys_inotify_init1
  839. .long sys_preadv
  840. .long sys_pwritev
  841. .long sys_setns /* 335 */
  842. /*
  843. * NOTE!! This doesn't have to be exact - we just have
  844. * to make sure we have _enough_ of the "sys_ni_syscall"
  845. * entries. Don't panic if you notice that this hasn't
  846. * been shrunk every time we add a new system call.
  847. */
  848. .rept NR_syscalls-(.-sys_call_table)/4
  849. .long sys_ni_syscall
  850. .endr