3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 * Entry to the kernel is "interesting":
13 * (1) There are no stack pointers, not even for the kernel
14 * (2) General Registers should not be clobbered
15 * (3) There are no kernel-only data registers
16 * (4) Since all addressing modes are wrt to a General Register, no global
17 * variables can be reached
19 * We deal with this by declaring that we shall kill GR28 on entering the
20 * kernel from userspace
22 * However, since break interrupts can interrupt the CPU even when PSR.ET==0,
23 * they can't rely on GR28 to be anything useful, and so need to clobber a
24 * separate register (GR31). Break interrupts are managed in break.S
26 * GR29 _is_ saved, and holds the current task pointer globally
30 #include <linux/sys.h>
31 #include <linux/config.h>
32 #include <linux/linkage.h>
33 #include <asm/thread_info.h>
34 #include <asm/setup.h>
35 #include <asm/segment.h>
36 #include <asm/ptrace.h>
37 #include <asm/errno.h>
38 #include <asm/cache.h>
39 #include <asm/spr-regs.h>
41 #define nr_syscalls ((syscall_table_size)/4)
47 # sethi.p %hi(0xe1200004),gr30
48 # setlo %lo(0xe1200004),gr30
51 # sethi.p %hi(0xffc00100),gr30
52 # setlo %lo(0xffc00100),gr30
59 # sethi.p %hi(0xe1200004),gr30
60 # setlo %lo(0xe1200004),gr30
61 # st.p gr31,@(gr30,gr0)
63 # sethi.p %hi(0xffc00100),gr30
64 # setlo %lo(0xffc00100),gr30
65 # sth gr31,@(gr30,gr0)
69 ###############################################################################
71 # entry point for External interrupts received whilst executing userspace code
73 ###############################################################################
74 .globl __entry_uspace_external_interrupt
75 .type __entry_uspace_external_interrupt,@function
76 __entry_uspace_external_interrupt:
78 sethi.p %hi(__kernel_frame0_ptr),gr28
79 setlo %lo(__kernel_frame0_ptr),gr28
82 # handle h/w single-step through exceptions
83 sti gr0,@(gr28,#REG__STATUS)
85 .globl __entry_uspace_external_interrupt_reentry
86 __entry_uspace_external_interrupt_reentry:
92 # finish building the exception frame
93 sti sp, @(gr28,#REG_SP)
94 stdi gr2, @(gr28,#REG_GR(2))
95 stdi gr4, @(gr28,#REG_GR(4))
96 stdi gr6, @(gr28,#REG_GR(6))
97 stdi gr8, @(gr28,#REG_GR(8))
98 stdi gr10,@(gr28,#REG_GR(10))
99 stdi gr12,@(gr28,#REG_GR(12))
100 stdi gr14,@(gr28,#REG_GR(14))
101 stdi gr16,@(gr28,#REG_GR(16))
102 stdi gr18,@(gr28,#REG_GR(18))
103 stdi gr20,@(gr28,#REG_GR(20))
104 stdi gr22,@(gr28,#REG_GR(22))
105 stdi gr24,@(gr28,#REG_GR(24))
106 stdi gr26,@(gr28,#REG_GR(26))
107 sti gr0, @(gr28,#REG_GR(28))
108 sti gr29,@(gr28,#REG_GR(29))
109 stdi.p gr30,@(gr28,#REG_GR(30))
111 # set up the kernel stack pointer
124 andi gr22,#PSR_PS,gr5 /* try to rebuild original PSR value */
125 andi.p gr22,#~(PSR_PS|PSR_S),gr6
128 andi gr5,#~PSR_ET,gr5
130 sti gr20,@(gr28,#REG_TBR)
131 sti gr21,@(gr28,#REG_PC)
132 sti gr5 ,@(gr28,#REG_PSR)
133 sti gr23,@(gr28,#REG_ISR)
134 stdi gr24,@(gr28,#REG_CCR)
135 stdi gr26,@(gr28,#REG_LR)
136 sti gr4 ,@(gr28,#REG_SYSCALLNO)
140 stdi gr4,@(gr28,#REG_IACC0)
144 stdi.p gr4,@(gr28,#REG_GNER0)
146 # interrupts start off fully disabled in the interrupt handler
147 subcc gr0,gr0,gr0,icc2 /* set Z and clear C */
149 # set up kernel global registers
150 sethi.p %hi(__kernel_current_task),gr5
151 setlo %lo(__kernel_current_task),gr5
152 sethi.p %hi(_gp),gr16
155 ldi.p @(gr29,#4),gr15 ; __current_thread_info = current->thread_info
157 # make sure we (the kernel) get div-zero and misalignment exceptions
158 setlos #ISR_EDE|ISR_DTT_DIVBYZERO|ISR_EMAM_EXCEPTION,gr5
161 # switch to the kernel trap table
162 sethi.p %hi(__entry_kerneltrap_table),gr6
163 setlo %lo(__entry_kerneltrap_table),gr6
166 # set the return address
167 sethi.p %hi(__entry_return_from_user_interrupt),gr4
168 setlo %lo(__entry_return_from_user_interrupt),gr4
171 # raise the minimum interrupt priority to 15 (NMI only) and enable exceptions
174 ori gr4,#PSR_PIL_14,gr4
176 ori gr4,#PSR_PIL_14|PSR_ET,gr4
182 .size __entry_uspace_external_interrupt,.-__entry_uspace_external_interrupt
184 ###############################################################################
186 # entry point for External interrupts received whilst executing kernel code
187 # - on arriving here, the following registers should already be set up:
188 # GR15 - current thread_info struct pointer
189 # GR16 - kernel GP-REL pointer
190 # GR29 - current task struct pointer
191 # TBR - kernel trap vector table
192 # ISR - kernel's preferred integer controls
194 ###############################################################################
195 .globl __entry_kernel_external_interrupt
196 .type __entry_kernel_external_interrupt,@function
197 __entry_kernel_external_interrupt:
202 # set up the stack pointer
205 sti gr30,@(sp,#REG_SP)
207 # handle h/w single-step through exceptions
208 sti gr0,@(sp,#REG__STATUS)
210 .globl __entry_kernel_external_interrupt_reentry
211 __entry_kernel_external_interrupt_reentry:
214 # set up the exception frame
215 setlos #REG__END,gr30
218 sti.p gr28,@(sp,#REG_GR(28))
221 # finish building the exception frame
222 stdi gr2,@(gr28,#REG_GR(2))
223 stdi gr4,@(gr28,#REG_GR(4))
224 stdi gr6,@(gr28,#REG_GR(6))
225 stdi gr8,@(gr28,#REG_GR(8))
226 stdi gr10,@(gr28,#REG_GR(10))
227 stdi gr12,@(gr28,#REG_GR(12))
228 stdi gr14,@(gr28,#REG_GR(14))
229 stdi gr16,@(gr28,#REG_GR(16))
230 stdi gr18,@(gr28,#REG_GR(18))
231 stdi gr20,@(gr28,#REG_GR(20))
232 stdi gr22,@(gr28,#REG_GR(22))
233 stdi gr24,@(gr28,#REG_GR(24))
234 stdi gr26,@(gr28,#REG_GR(26))
235 sti gr29,@(gr28,#REG_GR(29))
236 stdi.p gr30,@(gr28,#REG_GR(30))
238 # note virtual interrupts will be fully enabled upon return
239 subicc gr0,#1,gr0,icc2 /* clear Z, set C */
251 andi gr22,#PSR_PS,gr5 /* try to rebuild original PSR value */
252 andi.p gr22,#~(PSR_PS|PSR_S),gr6
255 andi.p gr5,#~PSR_ET,gr5
257 # set CCCR.CC3 to Undefined to abort atomic-modify completion inside the kernel
258 # - for an explanation of how it works, see: Documentation/fujitsu/frv/atomic-ops.txt
259 andi gr25,#~0xc0,gr25
261 sti gr20,@(gr28,#REG_TBR)
262 sti gr21,@(gr28,#REG_PC)
263 sti gr5 ,@(gr28,#REG_PSR)
264 sti gr23,@(gr28,#REG_ISR)
265 stdi gr24,@(gr28,#REG_CCR)
266 stdi gr26,@(gr28,#REG_LR)
267 sti gr4 ,@(gr28,#REG_SYSCALLNO)
271 stdi gr4,@(gr28,#REG_IACC0)
275 stdi.p gr4,@(gr28,#REG_GNER0)
277 # interrupts start off fully disabled in the interrupt handler
278 subcc gr0,gr0,gr0,icc2 /* set Z and clear C */
280 # set the return address
281 sethi.p %hi(__entry_return_from_kernel_interrupt),gr4
282 setlo %lo(__entry_return_from_kernel_interrupt),gr4
285 # clear power-saving mode flags
287 andi gr4,#~HSR0_PDM,gr4
290 # raise the minimum interrupt priority to 15 (NMI only) and enable exceptions
292 ori gr4,#PSR_PIL_14,gr4
300 .size __entry_kernel_external_interrupt,.-__entry_kernel_external_interrupt
302 ###############################################################################
304 # deal with interrupts that were actually virtually disabled
305 # - we need to really disable them, flag the fact and return immediately
306 # - if you change this, you must alter break.S also
308 ###############################################################################
309 .balign L1_CACHE_BYTES
310 .globl __entry_kernel_external_interrupt_virtually_disabled
311 .type __entry_kernel_external_interrupt_virtually_disabled,@function
312 __entry_kernel_external_interrupt_virtually_disabled:
314 andi gr30,#~PSR_PIL,gr30
315 ori gr30,#PSR_PIL_14,gr30 ; debugging interrupts only
317 subcc gr0,gr0,gr0,icc2 ; leave Z set, clear C
320 .size __entry_kernel_external_interrupt_virtually_disabled,.-__entry_kernel_external_interrupt_virtually_disabled
322 ###############################################################################
324 # deal with re-enablement of interrupts that were pending when virtually re-enabled
325 # - set ICC2.C, re-enable the real interrupts and return
326 # - we can clear ICC2.Z because we shouldn't be here if it's not 0 [due to TIHI]
327 # - if you change this, you must alter break.S also
329 ###############################################################################
330 .balign L1_CACHE_BYTES
331 .globl __entry_kernel_external_interrupt_virtual_reenable
332 .type __entry_kernel_external_interrupt_virtual_reenable,@function
333 __entry_kernel_external_interrupt_virtual_reenable:
335 andi gr30,#~PSR_PIL,gr30 ; re-enable interrupts
337 subicc gr0,#1,gr0,icc2 ; clear Z, set C
340 .size __entry_kernel_external_interrupt_virtual_reenable,.-__entry_kernel_external_interrupt_virtual_reenable
342 ###############################################################################
344 # entry point for Software and Progam interrupts generated whilst executing userspace code
346 ###############################################################################
347 .globl __entry_uspace_softprog_interrupt
348 .type __entry_uspace_softprog_interrupt,@function
349 .globl __entry_uspace_handle_mmu_fault
350 __entry_uspace_softprog_interrupt:
354 __entry_uspace_handle_mmu_fault:
357 sethi.p %hi(__kernel_frame0_ptr),gr28
358 setlo %lo(__kernel_frame0_ptr),gr28
361 # handle h/w single-step through exceptions
362 sti gr0,@(gr28,#REG__STATUS)
364 .globl __entry_uspace_softprog_interrupt_reentry
365 __entry_uspace_softprog_interrupt_reentry:
368 setlos #REG__END,gr30
371 # set up the kernel stack pointer
372 sti.p sp,@(gr28,#REG_SP)
374 sti gr0,@(gr28,#REG_GR(28))
376 stdi gr20,@(gr28,#REG_GR(20))
377 stdi gr22,@(gr28,#REG_GR(22))
383 sethi.p %hi(__entry_return_from_user_exception),gr23
384 setlo %lo(__entry_return_from_user_exception),gr23
388 .size __entry_uspace_softprog_interrupt,.-__entry_uspace_softprog_interrupt
390 # single-stepping was disabled on entry to a TLB handler that then faulted
392 .globl __entry_uspace_handle_mmu_fault_sstep
393 __entry_uspace_handle_mmu_fault_sstep:
395 sethi.p %hi(__kernel_frame0_ptr),gr28
396 setlo %lo(__kernel_frame0_ptr),gr28
399 # flag single-step re-enablement
400 sti gr0,@(gr28,#REG__STATUS)
401 bra __entry_uspace_softprog_interrupt_reentry
405 ###############################################################################
407 # entry point for Software and Progam interrupts generated whilst executing kernel code
409 ###############################################################################
410 .globl __entry_kernel_softprog_interrupt
411 .type __entry_kernel_softprog_interrupt,@function
412 __entry_kernel_softprog_interrupt:
420 .globl __entry_kernel_handle_mmu_fault
421 __entry_kernel_handle_mmu_fault:
422 # set up the stack pointer
425 sti sp,@(sp,#REG_SP-4)
428 # handle h/w single-step through exceptions
429 sti gr0,@(sp,#REG__STATUS)
431 .globl __entry_kernel_softprog_interrupt_reentry
432 __entry_kernel_softprog_interrupt_reentry:
435 setlos #REG__END,gr30
438 # set up the exception frame
439 sti.p gr28,@(sp,#REG_GR(28))
442 stdi gr20,@(gr28,#REG_GR(20))
443 stdi gr22,@(gr28,#REG_GR(22))
445 ldi @(sp,#REG_SP),gr22 /* reconstruct the old SP */
446 addi gr22,#REG__END,gr22
447 sti gr22,@(sp,#REG_SP)
449 # set CCCR.CC3 to Undefined to abort atomic-modify completion inside the kernel
450 # - for an explanation of how it works, see: Documentation/fujitsu/frv/atomic-ops.txt
452 andi gr20,#~0xc0,gr20
459 sethi.p %hi(__entry_return_from_kernel_exception),gr23
460 setlo %lo(__entry_return_from_kernel_exception),gr23
463 .size __entry_kernel_softprog_interrupt,.-__entry_kernel_softprog_interrupt
465 # single-stepping was disabled on entry to a TLB handler that then faulted
467 .globl __entry_kernel_handle_mmu_fault_sstep
468 __entry_kernel_handle_mmu_fault_sstep:
469 # set up the stack pointer
472 sti sp,@(sp,#REG_SP-4)
475 # flag single-step re-enablement
476 sethi #REG__STATUS_STEP,gr30
477 sti gr30,@(sp,#REG__STATUS)
478 bra __entry_kernel_softprog_interrupt_reentry
482 ###############################################################################
484 # the rest of the kernel entry point code
485 # - on arriving here, the following registers should be set up:
486 # GR1 - kernel stack pointer
487 # GR7 - syscall number (trap 0 only)
488 # GR8-13 - syscall args (trap 0 only)
492 # GR23 - return handler address
493 # GR28 - exception frame on stack
494 # SCR2 - saved EAR0 where applicable (clobbered by ICI & ICEF insns on FR451)
495 # PSR - PSR.S 1, PSR.ET 0
497 ###############################################################################
498 .globl __entry_common
499 .type __entry_common,@function
503 # finish building the exception frame
504 stdi gr2,@(gr28,#REG_GR(2))
505 stdi gr4,@(gr28,#REG_GR(4))
506 stdi gr6,@(gr28,#REG_GR(6))
507 stdi gr8,@(gr28,#REG_GR(8))
508 stdi gr10,@(gr28,#REG_GR(10))
509 stdi gr12,@(gr28,#REG_GR(12))
510 stdi gr14,@(gr28,#REG_GR(14))
511 stdi gr16,@(gr28,#REG_GR(16))
512 stdi gr18,@(gr28,#REG_GR(18))
513 stdi gr24,@(gr28,#REG_GR(24))
514 stdi gr26,@(gr28,#REG_GR(26))
515 sti gr29,@(gr28,#REG_GR(29))
516 stdi gr30,@(gr28,#REG_GR(30))
526 andi gr22,#PSR_PS,gr5 /* try to rebuild original PSR value */
527 andi.p gr22,#~(PSR_PS|PSR_S),gr6
530 andi gr5,#~PSR_ET,gr5
532 sti gr20,@(gr28,#REG_TBR)
533 sti gr21,@(gr28,#REG_PC)
534 sti gr5 ,@(gr28,#REG_PSR)
535 sti gr23,@(gr28,#REG_ISR)
536 stdi gr24,@(gr28,#REG_CCR)
537 stdi gr26,@(gr28,#REG_LR)
538 sti gr4 ,@(gr28,#REG_SYSCALLNO)
542 stdi gr4,@(gr28,#REG_IACC0)
546 stdi.p gr4,@(gr28,#REG_GNER0)
548 # set up virtual interrupt disablement
549 subicc gr0,#1,gr0,icc2 /* clear Z flag, set C flag */
551 # set up kernel global registers
552 sethi.p %hi(__kernel_current_task),gr5
553 setlo %lo(__kernel_current_task),gr5
554 sethi.p %hi(_gp),gr16
557 ldi @(gr29,#4),gr15 ; __current_thread_info = current->thread_info
559 # switch to the kernel trap table
560 sethi.p %hi(__entry_kerneltrap_table),gr6
561 setlo %lo(__entry_kerneltrap_table),gr6
564 # make sure we (the kernel) get div-zero and misalignment exceptions
565 setlos #ISR_EDE|ISR_DTT_DIVBYZERO|ISR_EMAM_EXCEPTION,gr5
568 # clear power-saving mode flags
570 andi gr4,#~HSR0_PDM,gr4
573 # multiplex again using old TBR as a guide
575 sethi %hi(__entry_vector_table),gr6
577 setlo %lo(__entry_vector_table),gr6
585 .size __entry_common,.-__entry_common
587 ###############################################################################
589 # handle instruction MMU fault
591 ###############################################################################
593 .globl __entry_insn_mmu_fault
594 __entry_insn_mmu_fault:
600 # now that we've accessed the exception regs, we can enable exceptions
605 sethi.p %hi(do_page_fault),gr5
606 setlo %lo(do_page_fault),gr5
607 jmpl @(gr5,gr0) ; call do_page_fault(0,esr0,ear0)
611 ###############################################################################
613 # handle instruction access error
615 ###############################################################################
616 .globl __entry_insn_access_error
617 __entry_insn_access_error:
619 sethi.p %hi(insn_access_error),gr5
620 setlo %lo(insn_access_error),gr5
625 # now that we've accessed the exception regs, we can enable exceptions
629 jmpl @(gr5,gr0) ; call insn_access_error(esfr1,epcr0,esr0)
631 ###############################################################################
633 # handle various instructions of dubious legality
635 ###############################################################################
636 .globl __entry_unsupported_trap
637 .globl __entry_illegal_instruction
638 .globl __entry_privileged_instruction
639 .globl __entry_debug_exception
640 __entry_unsupported_trap:
642 sti gr21,@(gr28,#REG_PC)
643 __entry_illegal_instruction:
644 __entry_privileged_instruction:
645 __entry_debug_exception:
647 sethi.p %hi(illegal_instruction),gr5
648 setlo %lo(illegal_instruction),gr5
653 # now that we've accessed the exception regs, we can enable exceptions
657 jmpl @(gr5,gr0) ; call ill_insn(esfr1,epcr0,esr0)
659 ###############################################################################
661 # handle media exception
663 ###############################################################################
664 .globl __entry_media_exception
665 __entry_media_exception:
667 sethi.p %hi(media_exception),gr5
668 setlo %lo(media_exception),gr5
672 # now that we've accessed the exception regs, we can enable exceptions
676 jmpl @(gr5,gr0) ; call media_excep(msr0,msr1)
678 ###############################################################################
680 # handle data MMU fault
681 # handle data DAT fault (write-protect exception)
683 ###############################################################################
685 .globl __entry_data_mmu_fault
686 __entry_data_mmu_fault:
687 .globl __entry_data_dat_fault
688 __entry_data_dat_fault:
692 movsg scr2,gr10 ; saved EAR0
694 # now that we've accessed the exception regs, we can enable exceptions
699 sethi.p %hi(do_page_fault),gr5
700 setlo %lo(do_page_fault),gr5
701 jmpl @(gr5,gr0) ; call do_page_fault(1,esr0,ear0)
704 ###############################################################################
706 # handle data and instruction access exceptions
708 ###############################################################################
709 .globl __entry_insn_access_exception
710 .globl __entry_data_access_exception
711 __entry_insn_access_exception:
712 __entry_data_access_exception:
714 sethi.p %hi(memory_access_exception),gr5
715 setlo %lo(memory_access_exception),gr5
717 movsg scr2,gr9 ; saved EAR0
720 # now that we've accessed the exception regs, we can enable exceptions
724 jmpl @(gr5,gr0) ; call memory_access_error(esr0,ear0,epcr0)
726 ###############################################################################
728 # handle data access error
730 ###############################################################################
731 .globl __entry_data_access_error
732 __entry_data_access_error:
734 sethi.p %hi(data_access_error),gr5
735 setlo %lo(data_access_error),gr5
740 # now that we've accessed the exception regs, we can enable exceptions
744 jmpl @(gr5,gr0) ; call data_access_error(esfr1,esr15,ear15)
746 ###############################################################################
748 # handle data store error
750 ###############################################################################
751 .globl __entry_data_store_error
752 __entry_data_store_error:
754 sethi.p %hi(data_store_error),gr5
755 setlo %lo(data_store_error),gr5
759 # now that we've accessed the exception regs, we can enable exceptions
763 jmpl @(gr5,gr0) ; call data_store_error(esfr1,esr14)
765 ###############################################################################
767 # handle division exception
769 ###############################################################################
770 .globl __entry_division_exception
771 __entry_division_exception:
773 sethi.p %hi(division_exception),gr5
774 setlo %lo(division_exception),gr5
779 # now that we've accessed the exception regs, we can enable exceptions
783 jmpl @(gr5,gr0) ; call div_excep(esfr1,esr0,isr)
785 ###############################################################################
787 # handle compound exception
789 ###############################################################################
790 .globl __entry_compound_exception
791 __entry_compound_exception:
793 sethi.p %hi(compound_exception),gr5
794 setlo %lo(compound_exception),gr5
802 # now that we've accessed the exception regs, we can enable exceptions
806 jmpl @(gr5,gr0) ; call comp_excep(esfr1,esr0,esr14,esr15,msr0,msr1)
808 ###############################################################################
810 # handle interrupts and NMIs
812 ###############################################################################
813 .globl __entry_do_IRQ
817 # we can enable exceptions
823 .globl __entry_do_NMI
827 # we can enable exceptions
833 ###############################################################################
835 # the return path for a newly forked child process
836 # - __switch_to() saved the old current pointer in GR8 for us
838 ###############################################################################
844 # fork & co. return 0 to child
848 ###################################################################################################
850 # Return to user mode is not as complex as all this looks,
851 # but we want the default path for a system call return to
852 # go as quickly as possible which is why some of this is
853 # less clear than it otherwise should be.
855 ###################################################################################################
856 .balign L1_CACHE_BYTES
860 movsg psr,gr4 ; enable exceptions
864 sti gr7,@(gr28,#REG_SYSCALLNO)
865 sti.p gr8,@(gr28,#REG_ORIG_GR8)
867 subicc gr7,#nr_syscalls,gr0,icc0
868 bnc icc0,#0,__syscall_badsys
870 ldi @(gr15,#TI_FLAGS),gr4
871 ori gr4,#_TIF_SYSCALL_TRACE,gr4
872 andicc gr4,#_TIF_SYSCALL_TRACE,gr0,icc0
873 bne icc0,#0,__syscall_trace_entry
877 sethi %hi(sys_call_table),gr5
878 setlo %lo(sys_call_table),gr5
883 ###############################################################################
885 # return to interrupted process
887 ###############################################################################
891 sti gr8,@(gr28,#REG_GR(8)) ; save return value
893 # rebuild saved psr - execve will change it for init/main.c
894 ldi @(gr28,#REG_PSR),gr22
896 andi.p gr22,#~PSR_PS,gr22
901 # keep current PSR in GR23
904 # make sure we don't miss an interrupt setting need_resched or sigpending between
905 # sampling and the RETT
906 ori gr23,#PSR_PIL_14,gr23
909 ldi @(gr15,#TI_FLAGS),gr4
910 sethi.p %hi(_TIF_ALLWORK_MASK),gr5
911 setlo %lo(_TIF_ALLWORK_MASK),gr5
912 andcc gr4,gr5,gr0,icc0
913 bne icc0,#0,__syscall_exit_work
915 # restore all registers and return
916 __entry_return_direct:
919 andi gr22,#~PSR_ET,gr22
922 ldi @(gr28,#REG_ISR),gr23
923 lddi @(gr28,#REG_CCR),gr24
924 lddi @(gr28,#REG_LR) ,gr26
925 ldi @(gr28,#REG_PC) ,gr21
926 ldi @(gr28,#REG_TBR),gr20
936 lddi @(gr28,#REG_GNER0),gr4
940 lddi @(gr28,#REG_IACC0),gr4
944 lddi @(gr28,#REG_GR(4)) ,gr4
945 lddi @(gr28,#REG_GR(6)) ,gr6
946 lddi @(gr28,#REG_GR(8)) ,gr8
947 lddi @(gr28,#REG_GR(10)),gr10
948 lddi @(gr28,#REG_GR(12)),gr12
949 lddi @(gr28,#REG_GR(14)),gr14
950 lddi @(gr28,#REG_GR(16)),gr16
951 lddi @(gr28,#REG_GR(18)),gr18
952 lddi @(gr28,#REG_GR(20)),gr20
953 lddi @(gr28,#REG_GR(22)),gr22
954 lddi @(gr28,#REG_GR(24)),gr24
955 lddi @(gr28,#REG_GR(26)),gr26
956 ldi @(gr28,#REG_GR(29)),gr29
957 lddi @(gr28,#REG_GR(30)),gr30
959 # check to see if a debugging return is required
962 ldi @(gr28,#REG__STATUS),gr3
963 andicc gr3,#REG__STATUS_STEP,gr0,icc0
964 bne icc0,#0,__entry_return_singlestep
967 ldi @(gr28,#REG_SP) ,sp
968 lddi @(gr28,#REG_GR(2)) ,gr2
969 ldi @(gr28,#REG_GR(28)),gr28
976 # store the current frame in the workram on the FR451
978 sethi.p %hi(0xfe800000),gr28
979 setlo %lo(0xfe800000),gr28
981 stdi gr2,@(gr28,#REG_GR(2))
982 stdi gr4,@(gr28,#REG_GR(4))
983 stdi gr6,@(gr28,#REG_GR(6))
984 stdi gr8,@(gr28,#REG_GR(8))
985 stdi gr10,@(gr28,#REG_GR(10))
986 stdi gr12,@(gr28,#REG_GR(12))
987 stdi gr14,@(gr28,#REG_GR(14))
988 stdi gr16,@(gr28,#REG_GR(16))
989 stdi gr18,@(gr28,#REG_GR(18))
990 stdi gr24,@(gr28,#REG_GR(24))
991 stdi gr26,@(gr28,#REG_GR(26))
992 sti gr29,@(gr28,#REG_GR(29))
993 stdi gr30,@(gr28,#REG_GR(30))
996 sti gr30,@(gr28,#REG_TBR)
998 sti gr30,@(gr28,#REG_PC)
1000 sti gr30,@(gr28,#REG_PSR)
1002 sti gr30,@(gr28,#REG_ISR)
1005 stdi gr30,@(gr28,#REG_CCR)
1008 stdi gr30,@(gr28,#REG_LR)
1009 sti gr0 ,@(gr28,#REG_SYSCALLNO)
1015 # return via break.S
1016 __entry_return_singlestep:
1018 lddi @(gr28,#REG_GR(2)) ,gr2
1019 ldi @(gr28,#REG_SP) ,sp
1020 ldi @(gr28,#REG_GR(28)),gr28
1023 .globl __entry_return_singlestep_breaks_here
1024 __entry_return_singlestep_breaks_here:
1028 ###############################################################################
1030 # return to a process interrupted in kernel space
1031 # - we need to consider preemption if that is enabled
1033 ###############################################################################
1034 .balign L1_CACHE_BYTES
1035 __entry_return_from_kernel_exception:
1038 ori gr23,#PSR_PIL_14,gr23
1040 bra __entry_return_direct
1042 .balign L1_CACHE_BYTES
1043 __entry_return_from_kernel_interrupt:
1046 ori gr23,#PSR_PIL_14,gr23
1049 #ifdef CONFIG_PREEMPT
1050 ldi @(gr15,#TI_PRE_COUNT),gr5
1051 subicc gr5,#0,gr0,icc0
1052 beq icc0,#0,__entry_return_direct
1054 __entry_preempt_need_resched:
1055 ldi @(gr15,#TI_FLAGS),gr4
1056 andicc gr4,#_TIF_NEED_RESCHED,gr0,icc0
1057 beq icc0,#1,__entry_return_direct
1059 setlos #PREEMPT_ACTIVE,gr5
1060 sti gr5,@(gr15,#TI_FLAGS)
1062 andi gr23,#~PSR_PIL,gr23
1066 sti gr0,@(gr15,#TI_PRE_COUNT)
1069 ori gr23,#PSR_PIL_14,gr23
1071 bra __entry_preempt_need_resched
1073 bra __entry_return_direct
1077 ###############################################################################
1079 # perform work that needs to be done immediately before resumption
1081 ###############################################################################
1082 .globl __entry_return_from_user_exception
1083 .balign L1_CACHE_BYTES
1084 __entry_return_from_user_exception:
1087 __entry_resume_userspace:
1088 # make sure we don't miss an interrupt setting need_resched or sigpending between
1089 # sampling and the RETT
1091 ori gr23,#PSR_PIL_14,gr23
1094 __entry_return_from_user_interrupt:
1096 ldi @(gr15,#TI_FLAGS),gr4
1097 sethi.p %hi(_TIF_WORK_MASK),gr5
1098 setlo %lo(_TIF_WORK_MASK),gr5
1099 andcc gr4,gr5,gr0,icc0
1100 beq icc0,#1,__entry_return_direct
1102 __entry_work_pending:
1104 andicc gr4,#_TIF_NEED_RESCHED,gr0,icc0
1105 beq icc0,#1,__entry_work_notifysig
1107 __entry_work_resched:
1110 andi gr23,#~PSR_PIL,gr23
1114 ori gr23,#PSR_PIL_14,gr23
1118 ldi @(gr15,#TI_FLAGS),gr4
1119 sethi.p %hi(_TIF_WORK_MASK),gr5
1120 setlo %lo(_TIF_WORK_MASK),gr5
1121 andcc gr4,gr5,gr0,icc0
1122 beq icc0,#1,__entry_return_direct
1123 andicc gr4,#_TIF_NEED_RESCHED,gr0,icc0
1124 bne icc0,#1,__entry_work_resched
1126 __entry_work_notifysig:
1129 call do_notify_resume
1130 bra __entry_resume_userspace
1132 # perform syscall entry tracing
1133 __syscall_trace_entry:
1136 call do_syscall_trace
1138 ldi @(gr28,#REG_SYSCALLNO),gr7
1139 lddi @(gr28,#REG_GR(8)) ,gr8
1140 lddi @(gr28,#REG_GR(10)),gr10
1141 lddi.p @(gr28,#REG_GR(12)),gr12
1143 subicc gr7,#nr_syscalls,gr0,icc0
1144 bnc icc0,#0,__syscall_badsys
1147 # perform syscall exit tracing
1148 __syscall_exit_work:
1150 andicc gr4,#_TIF_SYSCALL_TRACE,gr0,icc0
1151 beq icc0,#1,__entry_work_pending
1154 andi gr23,#~PSR_PIL,gr23 ; could let do_syscall_trace() call schedule()
1158 call do_syscall_trace
1159 bra __entry_resume_userspace
1164 sti gr8,@(gr28,#REG_GR(8)) ; save return value
1165 bra __entry_resume_userspace
1168 ###############################################################################
1170 # syscall vector table
1172 ###############################################################################
1176 #define __MMU(X) sys_ni_syscall
1181 .globl sys_call_table
1183 .long sys_restart_syscall /* 0 - old "setup()" system call, used for restarting */
1188 .long sys_open /* 5 */
1193 .long sys_unlink /* 10 */
1198 .long sys_chmod /* 15 */
1200 .long sys_ni_syscall /* old break syscall holder */
1203 .long sys_getpid /* 20 */
1208 .long sys_ni_syscall // sys_stime /* 25 */
1213 .long sys_utime /* 30 */
1214 .long sys_ni_syscall /* old stty syscall holder */
1215 .long sys_ni_syscall /* old gtty syscall holder */
1218 .long sys_ni_syscall /* 35 */ /* old ftime syscall holder */
1223 .long sys_rmdir /* 40 */
1227 .long sys_ni_syscall /* old prof syscall holder */
1228 .long sys_brk /* 45 */
1231 .long sys_ni_syscall // sys_signal
1233 .long sys_getegid16 /* 50 */
1235 .long sys_umount /* recycled never used phys( */
1236 .long sys_ni_syscall /* old lock syscall holder */
1238 .long sys_fcntl /* 55 */
1239 .long sys_ni_syscall /* old mpx syscall holder */
1241 .long sys_ni_syscall /* old ulimit syscall holder */
1242 .long sys_ni_syscall /* old old uname syscall */
1243 .long sys_umask /* 60 */
1248 .long sys_getpgrp /* 65 */
1251 .long sys_ni_syscall // sys_sgetmask
1252 .long sys_ni_syscall // sys_ssetmask
1253 .long sys_setreuid16 /* 70 */
1254 .long sys_setregid16
1255 .long sys_sigsuspend
1256 .long sys_ni_syscall // sys_sigpending
1257 .long sys_sethostname
1258 .long sys_setrlimit /* 75 */
1259 .long sys_ni_syscall // sys_old_getrlimit
1261 .long sys_gettimeofday
1262 .long sys_settimeofday
1263 .long sys_getgroups16 /* 80 */
1264 .long sys_setgroups16
1265 .long sys_ni_syscall /* old_select slot */
1268 .long sys_readlink /* 85 */
1272 .long sys_ni_syscall // old_readdir
1273 .long sys_ni_syscall /* 90 */ /* old_mmap slot */
1278 .long sys_fchown16 /* 95 */
1279 .long sys_getpriority
1280 .long sys_setpriority
1281 .long sys_ni_syscall /* old profil syscall holder */
1283 .long sys_fstatfs /* 100 */
1284 .long sys_ni_syscall /* ioperm for i386 */
1285 .long sys_socketcall
1288 .long sys_getitimer /* 105 */
1292 .long sys_ni_syscall /* obsolete olduname( syscall */
1293 .long sys_ni_syscall /* iopl for i386 */ /* 110 */
1295 .long sys_ni_syscall /* obsolete idle( syscall */
1296 .long sys_ni_syscall /* vm86old for i386 */
1298 .long sys_swapoff /* 115 */
1303 .long sys_clone /* 120 */
1304 .long sys_setdomainname
1306 .long sys_ni_syscall /* old "cacheflush" */
1308 .long __MMU(sys_mprotect) /* 125 */
1309 .long sys_sigprocmask
1310 .long sys_ni_syscall /* old "create_module" */
1311 .long sys_init_module
1312 .long sys_delete_module
1313 .long sys_ni_syscall /* old "get_kernel_syms" */
1318 .long sys_sysfs /* 135 */
1319 .long sys_personality
1320 .long sys_ni_syscall /* for afs_syscall */
1321 .long sys_setfsuid16
1322 .long sys_setfsgid16
1323 .long sys_llseek /* 140 */
1327 .long __MMU(sys_msync)
1328 .long sys_readv /* 145 */
1333 .long __MMU(sys_mlock) /* 150 */
1334 .long __MMU(sys_munlock)
1335 .long __MMU(sys_mlockall)
1336 .long __MMU(sys_munlockall)
1337 .long sys_sched_setparam
1338 .long sys_sched_getparam /* 155 */
1339 .long sys_sched_setscheduler
1340 .long sys_sched_getscheduler
1341 .long sys_sched_yield
1342 .long sys_sched_get_priority_max
1343 .long sys_sched_get_priority_min /* 160 */
1344 .long sys_sched_rr_get_interval
1346 .long __MMU(sys_mremap)
1347 .long sys_setresuid16
1348 .long sys_getresuid16 /* 165 */
1349 .long sys_ni_syscall /* for vm86 */
1350 .long sys_ni_syscall /* Old sys_query_module */
1352 .long sys_nfsservctl
1353 .long sys_setresgid16 /* 170 */
1354 .long sys_getresgid16
1356 .long sys_rt_sigreturn
1357 .long sys_rt_sigaction
1358 .long sys_rt_sigprocmask /* 175 */
1359 .long sys_rt_sigpending
1360 .long sys_rt_sigtimedwait
1361 .long sys_rt_sigqueueinfo
1362 .long sys_rt_sigsuspend
1363 .long sys_pread64 /* 180 */
1368 .long sys_capset /* 185 */
1369 .long sys_sigaltstack
1371 .long sys_ni_syscall /* streams1 */
1372 .long sys_ni_syscall /* streams2 */
1373 .long sys_vfork /* 190 */
1376 .long sys_truncate64
1377 .long sys_ftruncate64
1378 .long sys_stat64 /* 195 */
1383 .long sys_getgid /* 200 */
1388 .long sys_getgroups /* 205 */
1393 .long sys_setresgid /* 210 */
1398 .long sys_setfsuid /* 215 */
1400 .long sys_pivot_root
1401 .long __MMU(sys_mincore)
1402 .long __MMU(sys_madvise)
1403 .long sys_getdents64 /* 220 */
1405 .long sys_ni_syscall /* reserved for TUX */
1406 .long sys_ni_syscall /* Reserved for Security */
1408 .long sys_readahead /* 225 */
1413 .long sys_lgetxattr /* 230 */
1416 .long sys_llistxattr
1417 .long sys_flistxattr
1418 .long sys_removexattr /* 235 */
1419 .long sys_lremovexattr
1420 .long sys_fremovexattr
1422 .long sys_sendfile64
1423 .long sys_futex /* 240 */
1424 .long sys_sched_setaffinity
1425 .long sys_sched_getaffinity
1426 .long sys_ni_syscall //sys_set_thread_area
1427 .long sys_ni_syscall //sys_get_thread_area
1428 .long sys_io_setup /* 245 */
1429 .long sys_io_destroy
1430 .long sys_io_getevents
1433 .long sys_fadvise64 /* 250 */
1434 .long sys_ni_syscall
1435 .long sys_exit_group
1436 .long sys_lookup_dcookie
1437 .long sys_epoll_create
1438 .long sys_epoll_ctl /* 255 */
1439 .long sys_epoll_wait
1440 .long __MMU(sys_remap_file_pages)
1441 .long sys_set_tid_address
1442 .long sys_timer_create
1443 .long sys_timer_settime /* 260 */
1444 .long sys_timer_gettime
1445 .long sys_timer_getoverrun
1446 .long sys_timer_delete
1447 .long sys_clock_settime
1448 .long sys_clock_gettime /* 265 */
1449 .long sys_clock_getres
1450 .long sys_clock_nanosleep
1453 .long sys_tgkill /* 270 */
1455 .long sys_fadvise64_64
1456 .long sys_ni_syscall /* sys_vserver */
1458 .long sys_get_mempolicy
1459 .long sys_set_mempolicy
1462 .long sys_mq_timedsend
1463 .long sys_mq_timedreceive /* 280 */
1465 .long sys_mq_getsetattr
1466 .long sys_ni_syscall /* reserved for kexec */
1468 .long sys_ni_syscall /* 285 */ /* available */
1470 .long sys_request_key
1472 .long sys_ioprio_set
1473 .long sys_ioprio_get /* 290 */
1474 .long sys_inotify_init
1475 .long sys_inotify_add_watch
1476 .long sys_inotify_rm_watch
1477 .long sys_migrate_pages
1478 .long sys_openat /* 295 */
1483 .long sys_newfstatat /* 300 */
1488 .long sys_readlinkat /* 305 */
1495 syscall_table_size = (. - sys_call_table)