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 gr4,@(gr28,#REG_GNER0)
146 # set up kernel global registers
147 sethi.p %hi(__kernel_current_task),gr5
148 setlo %lo(__kernel_current_task),gr5
149 sethi.p %hi(_gp),gr16
152 ldi.p @(gr29,#4),gr15 ; __current_thread_info = current->thread_info
154 # make sure we (the kernel) get div-zero and misalignment exceptions
155 setlos #ISR_EDE|ISR_DTT_DIVBYZERO|ISR_EMAM_EXCEPTION,gr5
158 # switch to the kernel trap table
159 sethi.p %hi(__entry_kerneltrap_table),gr6
160 setlo %lo(__entry_kerneltrap_table),gr6
163 # set the return address
164 sethi.p %hi(__entry_return_from_user_interrupt),gr4
165 setlo %lo(__entry_return_from_user_interrupt),gr4
168 # raise the minimum interrupt priority to 15 (NMI only) and enable exceptions
171 ori gr4,#PSR_PIL_14,gr4
173 ori gr4,#PSR_PIL_14|PSR_ET,gr4
179 .size __entry_uspace_external_interrupt,.-__entry_uspace_external_interrupt
181 ###############################################################################
183 # entry point for External interrupts received whilst executing kernel code
184 # - on arriving here, the following registers should already be set up:
185 # GR15 - current thread_info struct pointer
186 # GR16 - kernel GP-REL pointer
187 # GR29 - current task struct pointer
188 # TBR - kernel trap vector table
189 # ISR - kernel's preferred integer controls
191 ###############################################################################
192 .globl __entry_kernel_external_interrupt
193 .type __entry_kernel_external_interrupt,@function
194 __entry_kernel_external_interrupt:
200 # set up the stack pointer
203 sti gr30,@(sp,#REG_SP)
205 # handle h/w single-step through exceptions
206 sti gr0,@(sp,#REG__STATUS)
208 .globl __entry_kernel_external_interrupt_reentry
209 __entry_kernel_external_interrupt_reentry:
212 # set up the exception frame
213 setlos #REG__END,gr30
216 sti.p gr28,@(sp,#REG_GR(28))
219 # finish building the exception frame
220 stdi gr2,@(gr28,#REG_GR(2))
221 stdi gr4,@(gr28,#REG_GR(4))
222 stdi gr6,@(gr28,#REG_GR(6))
223 stdi gr8,@(gr28,#REG_GR(8))
224 stdi gr10,@(gr28,#REG_GR(10))
225 stdi gr12,@(gr28,#REG_GR(12))
226 stdi gr14,@(gr28,#REG_GR(14))
227 stdi gr16,@(gr28,#REG_GR(16))
228 stdi gr18,@(gr28,#REG_GR(18))
229 stdi gr20,@(gr28,#REG_GR(20))
230 stdi gr22,@(gr28,#REG_GR(22))
231 stdi gr24,@(gr28,#REG_GR(24))
232 stdi gr26,@(gr28,#REG_GR(26))
233 sti gr29,@(gr28,#REG_GR(29))
234 stdi gr30,@(gr28,#REG_GR(30))
246 andi gr22,#PSR_PS,gr5 /* try to rebuild original PSR value */
247 andi.p gr22,#~(PSR_PS|PSR_S),gr6
250 andi.p gr5,#~PSR_ET,gr5
252 # set CCCR.CC3 to Undefined to abort atomic-modify completion inside the kernel
253 # - for an explanation of how it works, see: Documentation/fujitsu/frv/atomic-ops.txt
254 andi gr25,#~0xc0,gr25
256 sti gr20,@(gr28,#REG_TBR)
257 sti gr21,@(gr28,#REG_PC)
258 sti gr5 ,@(gr28,#REG_PSR)
259 sti gr23,@(gr28,#REG_ISR)
260 stdi gr24,@(gr28,#REG_CCR)
261 stdi gr26,@(gr28,#REG_LR)
262 sti gr4 ,@(gr28,#REG_SYSCALLNO)
266 stdi gr4,@(gr28,#REG_IACC0)
270 stdi gr4,@(gr28,#REG_GNER0)
272 # set the return address
273 sethi.p %hi(__entry_return_from_kernel_interrupt),gr4
274 setlo %lo(__entry_return_from_kernel_interrupt),gr4
277 # clear power-saving mode flags
279 andi gr4,#~HSR0_PDM,gr4
282 # raise the minimum interrupt priority to 15 (NMI only) and enable exceptions
284 ori gr4,#PSR_PIL_14,gr4
292 .size __entry_kernel_external_interrupt,.-__entry_kernel_external_interrupt
295 ###############################################################################
297 # entry point for Software and Progam interrupts generated whilst executing userspace code
299 ###############################################################################
300 .globl __entry_uspace_softprog_interrupt
301 .type __entry_uspace_softprog_interrupt,@function
302 .globl __entry_uspace_handle_mmu_fault
303 __entry_uspace_softprog_interrupt:
307 __entry_uspace_handle_mmu_fault:
310 sethi.p %hi(__kernel_frame0_ptr),gr28
311 setlo %lo(__kernel_frame0_ptr),gr28
314 # handle h/w single-step through exceptions
315 sti gr0,@(gr28,#REG__STATUS)
317 .globl __entry_uspace_softprog_interrupt_reentry
318 __entry_uspace_softprog_interrupt_reentry:
321 setlos #REG__END,gr30
324 # set up the kernel stack pointer
325 sti.p sp,@(gr28,#REG_SP)
327 sti gr0,@(gr28,#REG_GR(28))
329 stdi gr20,@(gr28,#REG_GR(20))
330 stdi gr22,@(gr28,#REG_GR(22))
336 sethi.p %hi(__entry_return_from_user_exception),gr23
337 setlo %lo(__entry_return_from_user_exception),gr23
340 .size __entry_uspace_softprog_interrupt,.-__entry_uspace_softprog_interrupt
342 # single-stepping was disabled on entry to a TLB handler that then faulted
344 .globl __entry_uspace_handle_mmu_fault_sstep
345 __entry_uspace_handle_mmu_fault_sstep:
347 sethi.p %hi(__kernel_frame0_ptr),gr28
348 setlo %lo(__kernel_frame0_ptr),gr28
351 # flag single-step re-enablement
352 sti gr0,@(gr28,#REG__STATUS)
353 bra __entry_uspace_softprog_interrupt_reentry
357 ###############################################################################
359 # entry point for Software and Progam interrupts generated whilst executing kernel code
361 ###############################################################################
362 .globl __entry_kernel_softprog_interrupt
363 .type __entry_kernel_softprog_interrupt,@function
364 __entry_kernel_softprog_interrupt:
372 .globl __entry_kernel_handle_mmu_fault
373 __entry_kernel_handle_mmu_fault:
374 # set up the stack pointer
377 sti sp,@(sp,#REG_SP-4)
380 # handle h/w single-step through exceptions
381 sti gr0,@(sp,#REG__STATUS)
383 .globl __entry_kernel_softprog_interrupt_reentry
384 __entry_kernel_softprog_interrupt_reentry:
387 setlos #REG__END,gr30
390 # set up the exception frame
391 sti.p gr28,@(sp,#REG_GR(28))
394 stdi gr20,@(gr28,#REG_GR(20))
395 stdi gr22,@(gr28,#REG_GR(22))
397 ldi @(sp,#REG_SP),gr22 /* reconstruct the old SP */
398 addi gr22,#REG__END,gr22
399 sti gr22,@(sp,#REG_SP)
401 # set CCCR.CC3 to Undefined to abort atomic-modify completion inside the kernel
402 # - for an explanation of how it works, see: Documentation/fujitsu/frv/atomic-ops.txt
404 andi gr20,#~0xc0,gr20
411 sethi.p %hi(__entry_return_from_kernel_exception),gr23
412 setlo %lo(__entry_return_from_kernel_exception),gr23
415 .size __entry_kernel_softprog_interrupt,.-__entry_kernel_softprog_interrupt
417 # single-stepping was disabled on entry to a TLB handler that then faulted
419 .globl __entry_kernel_handle_mmu_fault_sstep
420 __entry_kernel_handle_mmu_fault_sstep:
421 # set up the stack pointer
424 sti sp,@(sp,#REG_SP-4)
427 # flag single-step re-enablement
428 sethi #REG__STATUS_STEP,gr30
429 sti gr30,@(sp,#REG__STATUS)
430 bra __entry_kernel_softprog_interrupt_reentry
434 ###############################################################################
436 # the rest of the kernel entry point code
437 # - on arriving here, the following registers should be set up:
438 # GR1 - kernel stack pointer
439 # GR7 - syscall number (trap 0 only)
440 # GR8-13 - syscall args (trap 0 only)
444 # GR23 - return handler address
445 # GR28 - exception frame on stack
446 # SCR2 - saved EAR0 where applicable (clobbered by ICI & ICEF insns on FR451)
447 # PSR - PSR.S 1, PSR.ET 0
449 ###############################################################################
450 .globl __entry_common
451 .type __entry_common,@function
455 # finish building the exception frame
456 stdi gr2,@(gr28,#REG_GR(2))
457 stdi gr4,@(gr28,#REG_GR(4))
458 stdi gr6,@(gr28,#REG_GR(6))
459 stdi gr8,@(gr28,#REG_GR(8))
460 stdi gr10,@(gr28,#REG_GR(10))
461 stdi gr12,@(gr28,#REG_GR(12))
462 stdi gr14,@(gr28,#REG_GR(14))
463 stdi gr16,@(gr28,#REG_GR(16))
464 stdi gr18,@(gr28,#REG_GR(18))
465 stdi gr24,@(gr28,#REG_GR(24))
466 stdi gr26,@(gr28,#REG_GR(26))
467 sti gr29,@(gr28,#REG_GR(29))
468 stdi gr30,@(gr28,#REG_GR(30))
478 andi gr22,#PSR_PS,gr5 /* try to rebuild original PSR value */
479 andi.p gr22,#~(PSR_PS|PSR_S),gr6
482 andi gr5,#~PSR_ET,gr5
484 sti gr20,@(gr28,#REG_TBR)
485 sti gr21,@(gr28,#REG_PC)
486 sti gr5 ,@(gr28,#REG_PSR)
487 sti gr23,@(gr28,#REG_ISR)
488 stdi gr24,@(gr28,#REG_CCR)
489 stdi gr26,@(gr28,#REG_LR)
490 sti gr4 ,@(gr28,#REG_SYSCALLNO)
494 stdi gr4,@(gr28,#REG_IACC0)
498 stdi gr4,@(gr28,#REG_GNER0)
500 # set up kernel global registers
501 sethi.p %hi(__kernel_current_task),gr5
502 setlo %lo(__kernel_current_task),gr5
503 sethi.p %hi(_gp),gr16
506 ldi @(gr29,#4),gr15 ; __current_thread_info = current->thread_info
508 # switch to the kernel trap table
509 sethi.p %hi(__entry_kerneltrap_table),gr6
510 setlo %lo(__entry_kerneltrap_table),gr6
513 # make sure we (the kernel) get div-zero and misalignment exceptions
514 setlos #ISR_EDE|ISR_DTT_DIVBYZERO|ISR_EMAM_EXCEPTION,gr5
517 # clear power-saving mode flags
519 andi gr4,#~HSR0_PDM,gr4
522 # multiplex again using old TBR as a guide
524 sethi %hi(__entry_vector_table),gr6
526 setlo %lo(__entry_vector_table),gr6
534 .size __entry_common,.-__entry_common
536 ###############################################################################
538 # handle instruction MMU fault
540 ###############################################################################
542 .globl __entry_insn_mmu_fault
543 __entry_insn_mmu_fault:
549 # now that we've accessed the exception regs, we can enable exceptions
554 sethi.p %hi(do_page_fault),gr5
555 setlo %lo(do_page_fault),gr5
556 jmpl @(gr5,gr0) ; call do_page_fault(0,esr0,ear0)
560 ###############################################################################
562 # handle instruction access error
564 ###############################################################################
565 .globl __entry_insn_access_error
566 __entry_insn_access_error:
568 sethi.p %hi(insn_access_error),gr5
569 setlo %lo(insn_access_error),gr5
574 # now that we've accessed the exception regs, we can enable exceptions
578 jmpl @(gr5,gr0) ; call insn_access_error(esfr1,epcr0,esr0)
580 ###############################################################################
582 # handle various instructions of dubious legality
584 ###############################################################################
585 .globl __entry_unsupported_trap
586 .globl __entry_illegal_instruction
587 .globl __entry_privileged_instruction
588 .globl __entry_debug_exception
589 __entry_unsupported_trap:
591 sti gr21,@(gr28,#REG_PC)
592 __entry_illegal_instruction:
593 __entry_privileged_instruction:
594 __entry_debug_exception:
596 sethi.p %hi(illegal_instruction),gr5
597 setlo %lo(illegal_instruction),gr5
602 # now that we've accessed the exception regs, we can enable exceptions
606 jmpl @(gr5,gr0) ; call ill_insn(esfr1,epcr0,esr0)
608 ###############################################################################
610 # handle media exception
612 ###############################################################################
613 .globl __entry_media_exception
614 __entry_media_exception:
616 sethi.p %hi(media_exception),gr5
617 setlo %lo(media_exception),gr5
621 # now that we've accessed the exception regs, we can enable exceptions
625 jmpl @(gr5,gr0) ; call media_excep(msr0,msr1)
627 ###############################################################################
629 # handle data MMU fault
630 # handle data DAT fault (write-protect exception)
632 ###############################################################################
634 .globl __entry_data_mmu_fault
635 __entry_data_mmu_fault:
636 .globl __entry_data_dat_fault
637 __entry_data_dat_fault:
641 movsg scr2,gr10 ; saved EAR0
643 # now that we've accessed the exception regs, we can enable exceptions
648 sethi.p %hi(do_page_fault),gr5
649 setlo %lo(do_page_fault),gr5
650 jmpl @(gr5,gr0) ; call do_page_fault(1,esr0,ear0)
653 ###############################################################################
655 # handle data and instruction access exceptions
657 ###############################################################################
658 .globl __entry_insn_access_exception
659 .globl __entry_data_access_exception
660 __entry_insn_access_exception:
661 __entry_data_access_exception:
663 sethi.p %hi(memory_access_exception),gr5
664 setlo %lo(memory_access_exception),gr5
666 movsg scr2,gr9 ; saved EAR0
669 # now that we've accessed the exception regs, we can enable exceptions
673 jmpl @(gr5,gr0) ; call memory_access_error(esr0,ear0,epcr0)
675 ###############################################################################
677 # handle data access error
679 ###############################################################################
680 .globl __entry_data_access_error
681 __entry_data_access_error:
683 sethi.p %hi(data_access_error),gr5
684 setlo %lo(data_access_error),gr5
689 # now that we've accessed the exception regs, we can enable exceptions
693 jmpl @(gr5,gr0) ; call data_access_error(esfr1,esr15,ear15)
695 ###############################################################################
697 # handle data store error
699 ###############################################################################
700 .globl __entry_data_store_error
701 __entry_data_store_error:
703 sethi.p %hi(data_store_error),gr5
704 setlo %lo(data_store_error),gr5
708 # now that we've accessed the exception regs, we can enable exceptions
712 jmpl @(gr5,gr0) ; call data_store_error(esfr1,esr14)
714 ###############################################################################
716 # handle division exception
718 ###############################################################################
719 .globl __entry_division_exception
720 __entry_division_exception:
722 sethi.p %hi(division_exception),gr5
723 setlo %lo(division_exception),gr5
728 # now that we've accessed the exception regs, we can enable exceptions
732 jmpl @(gr5,gr0) ; call div_excep(esfr1,esr0,isr)
734 ###############################################################################
736 # handle compound exception
738 ###############################################################################
739 .globl __entry_compound_exception
740 __entry_compound_exception:
742 sethi.p %hi(compound_exception),gr5
743 setlo %lo(compound_exception),gr5
751 # now that we've accessed the exception regs, we can enable exceptions
755 jmpl @(gr5,gr0) ; call comp_excep(esfr1,esr0,esr14,esr15,msr0,msr1)
757 ###############################################################################
759 # handle interrupts and NMIs
761 ###############################################################################
762 .globl __entry_do_IRQ
766 # we can enable exceptions
772 .globl __entry_do_NMI
776 # we can enable exceptions
782 ###############################################################################
784 # the return path for a newly forked child process
785 # - __switch_to() saved the old current pointer in GR8 for us
787 ###############################################################################
793 # fork & co. return 0 to child
797 ###################################################################################################
799 # Return to user mode is not as complex as all this looks,
800 # but we want the default path for a system call return to
801 # go as quickly as possible which is why some of this is
802 # less clear than it otherwise should be.
804 ###################################################################################################
805 .balign L1_CACHE_BYTES
809 movsg psr,gr4 ; enable exceptions
813 sti gr7,@(gr28,#REG_SYSCALLNO)
814 sti.p gr8,@(gr28,#REG_ORIG_GR8)
816 subicc gr7,#nr_syscalls,gr0,icc0
817 bnc icc0,#0,__syscall_badsys
819 ldi @(gr15,#TI_FLAGS),gr4
820 ori gr4,#_TIF_SYSCALL_TRACE,gr4
821 andicc gr4,#_TIF_SYSCALL_TRACE,gr0,icc0
822 bne icc0,#0,__syscall_trace_entry
826 sethi %hi(sys_call_table),gr5
827 setlo %lo(sys_call_table),gr5
832 ###############################################################################
834 # return to interrupted process
836 ###############################################################################
840 sti gr8,@(gr28,#REG_GR(8)) ; save return value
842 # rebuild saved psr - execve will change it for init/main.c
843 ldi @(gr28,#REG_PSR),gr22
845 andi.p gr22,#~PSR_PS,gr22
850 # keep current PSR in GR23
853 # make sure we don't miss an interrupt setting need_resched or sigpending between
854 # sampling and the RETT
855 ori gr23,#PSR_PIL_14,gr23
858 ldi @(gr15,#TI_FLAGS),gr4
859 sethi.p %hi(_TIF_ALLWORK_MASK),gr5
860 setlo %lo(_TIF_ALLWORK_MASK),gr5
861 andcc gr4,gr5,gr0,icc0
862 bne icc0,#0,__syscall_exit_work
864 # restore all registers and return
865 __entry_return_direct:
868 andi gr22,#~PSR_ET,gr22
871 ldi @(gr28,#REG_ISR),gr23
872 lddi @(gr28,#REG_CCR),gr24
873 lddi @(gr28,#REG_LR) ,gr26
874 ldi @(gr28,#REG_PC) ,gr21
875 ldi @(gr28,#REG_TBR),gr20
885 lddi @(gr28,#REG_GNER0),gr4
889 lddi @(gr28,#REG_IACC0),gr4
893 lddi @(gr28,#REG_GR(4)) ,gr4
894 lddi @(gr28,#REG_GR(6)) ,gr6
895 lddi @(gr28,#REG_GR(8)) ,gr8
896 lddi @(gr28,#REG_GR(10)),gr10
897 lddi @(gr28,#REG_GR(12)),gr12
898 lddi @(gr28,#REG_GR(14)),gr14
899 lddi @(gr28,#REG_GR(16)),gr16
900 lddi @(gr28,#REG_GR(18)),gr18
901 lddi @(gr28,#REG_GR(20)),gr20
902 lddi @(gr28,#REG_GR(22)),gr22
903 lddi @(gr28,#REG_GR(24)),gr24
904 lddi @(gr28,#REG_GR(26)),gr26
905 ldi @(gr28,#REG_GR(29)),gr29
906 lddi @(gr28,#REG_GR(30)),gr30
908 # check to see if a debugging return is required
911 ldi @(gr28,#REG__STATUS),gr3
912 andicc gr3,#REG__STATUS_STEP,gr0,icc0
913 bne icc0,#0,__entry_return_singlestep
916 ldi @(gr28,#REG_SP) ,sp
917 lddi @(gr28,#REG_GR(2)) ,gr2
918 ldi @(gr28,#REG_GR(28)),gr28
925 # store the current frame in the workram on the FR451
927 sethi.p %hi(0xfe800000),gr28
928 setlo %lo(0xfe800000),gr28
930 stdi gr2,@(gr28,#REG_GR(2))
931 stdi gr4,@(gr28,#REG_GR(4))
932 stdi gr6,@(gr28,#REG_GR(6))
933 stdi gr8,@(gr28,#REG_GR(8))
934 stdi gr10,@(gr28,#REG_GR(10))
935 stdi gr12,@(gr28,#REG_GR(12))
936 stdi gr14,@(gr28,#REG_GR(14))
937 stdi gr16,@(gr28,#REG_GR(16))
938 stdi gr18,@(gr28,#REG_GR(18))
939 stdi gr24,@(gr28,#REG_GR(24))
940 stdi gr26,@(gr28,#REG_GR(26))
941 sti gr29,@(gr28,#REG_GR(29))
942 stdi gr30,@(gr28,#REG_GR(30))
945 sti gr30,@(gr28,#REG_TBR)
947 sti gr30,@(gr28,#REG_PC)
949 sti gr30,@(gr28,#REG_PSR)
951 sti gr30,@(gr28,#REG_ISR)
954 stdi gr30,@(gr28,#REG_CCR)
957 stdi gr30,@(gr28,#REG_LR)
958 sti gr0 ,@(gr28,#REG_SYSCALLNO)
965 __entry_return_singlestep:
967 lddi @(gr28,#REG_GR(2)) ,gr2
968 ldi @(gr28,#REG_SP) ,sp
969 ldi @(gr28,#REG_GR(28)),gr28
972 .globl __entry_return_singlestep_breaks_here
973 __entry_return_singlestep_breaks_here:
977 ###############################################################################
979 # return to a process interrupted in kernel space
980 # - we need to consider preemption if that is enabled
982 ###############################################################################
983 .balign L1_CACHE_BYTES
984 __entry_return_from_kernel_exception:
987 ori gr23,#PSR_PIL_14,gr23
989 bra __entry_return_direct
991 .balign L1_CACHE_BYTES
992 __entry_return_from_kernel_interrupt:
995 ori gr23,#PSR_PIL_14,gr23
998 #ifdef CONFIG_PREEMPT
999 ldi @(gr15,#TI_PRE_COUNT),gr5
1000 subicc gr5,#0,gr0,icc0
1001 beq icc0,#0,__entry_return_direct
1003 __entry_preempt_need_resched:
1004 ldi @(gr15,#TI_FLAGS),gr4
1005 andicc gr4,#_TIF_NEED_RESCHED,gr0,icc0
1006 beq icc0,#1,__entry_return_direct
1008 setlos #PREEMPT_ACTIVE,gr5
1009 sti gr5,@(gr15,#TI_FLAGS)
1011 andi gr23,#~PSR_PIL,gr23
1015 sti gr0,@(gr15,#TI_PRE_COUNT)
1018 ori gr23,#PSR_PIL_14,gr23
1020 bra __entry_preempt_need_resched
1022 bra __entry_return_direct
1026 ###############################################################################
1028 # perform work that needs to be done immediately before resumption
1030 ###############################################################################
1031 .globl __entry_return_from_user_exception
1032 .balign L1_CACHE_BYTES
1033 __entry_return_from_user_exception:
1036 __entry_resume_userspace:
1037 # make sure we don't miss an interrupt setting need_resched or sigpending between
1038 # sampling and the RETT
1040 ori gr23,#PSR_PIL_14,gr23
1043 __entry_return_from_user_interrupt:
1045 ldi @(gr15,#TI_FLAGS),gr4
1046 sethi.p %hi(_TIF_WORK_MASK),gr5
1047 setlo %lo(_TIF_WORK_MASK),gr5
1048 andcc gr4,gr5,gr0,icc0
1049 beq icc0,#1,__entry_return_direct
1051 __entry_work_pending:
1053 andicc gr4,#_TIF_NEED_RESCHED,gr0,icc0
1054 beq icc0,#1,__entry_work_notifysig
1056 __entry_work_resched:
1059 andi gr23,#~PSR_PIL,gr23
1063 ori gr23,#PSR_PIL_14,gr23
1067 ldi @(gr15,#TI_FLAGS),gr4
1068 sethi.p %hi(_TIF_WORK_MASK),gr5
1069 setlo %lo(_TIF_WORK_MASK),gr5
1070 andcc gr4,gr5,gr0,icc0
1071 beq icc0,#1,__entry_return_direct
1072 andicc gr4,#_TIF_NEED_RESCHED,gr0,icc0
1073 bne icc0,#1,__entry_work_resched
1075 __entry_work_notifysig:
1078 call do_notify_resume
1079 bra __entry_return_direct
1081 # perform syscall entry tracing
1082 __syscall_trace_entry:
1085 call do_syscall_trace
1087 ldi @(gr28,#REG_SYSCALLNO),gr7
1088 lddi @(gr28,#REG_GR(8)) ,gr8
1089 lddi @(gr28,#REG_GR(10)),gr10
1090 lddi.p @(gr28,#REG_GR(12)),gr12
1092 subicc gr7,#nr_syscalls,gr0,icc0
1093 bnc icc0,#0,__syscall_badsys
1096 # perform syscall exit tracing
1097 __syscall_exit_work:
1099 andicc gr4,#_TIF_SYSCALL_TRACE,gr0,icc0
1100 beq icc0,#1,__entry_work_pending
1103 andi gr23,#~PSR_PIL,gr23 ; could let do_syscall_trace() call schedule()
1107 call do_syscall_trace
1108 bra __entry_resume_userspace
1113 sti gr8,@(gr28,#REG_GR(8)) ; save return value
1114 bra __entry_resume_userspace
1117 ###############################################################################
1119 # syscall vector table
1121 ###############################################################################
1125 #define __MMU(X) sys_ni_syscall
1130 .globl sys_call_table
1132 .long sys_restart_syscall /* 0 - old "setup()" system call, used for restarting */
1137 .long sys_open /* 5 */
1142 .long sys_unlink /* 10 */
1147 .long sys_chmod /* 15 */
1149 .long sys_ni_syscall /* old break syscall holder */
1152 .long sys_getpid /* 20 */
1157 .long sys_ni_syscall // sys_stime /* 25 */
1162 .long sys_utime /* 30 */
1163 .long sys_ni_syscall /* old stty syscall holder */
1164 .long sys_ni_syscall /* old gtty syscall holder */
1167 .long sys_ni_syscall /* 35 */ /* old ftime syscall holder */
1172 .long sys_rmdir /* 40 */
1176 .long sys_ni_syscall /* old prof syscall holder */
1177 .long sys_brk /* 45 */
1180 .long sys_ni_syscall // sys_signal
1182 .long sys_getegid16 /* 50 */
1184 .long sys_umount /* recycled never used phys( */
1185 .long sys_ni_syscall /* old lock syscall holder */
1187 .long sys_fcntl /* 55 */
1188 .long sys_ni_syscall /* old mpx syscall holder */
1190 .long sys_ni_syscall /* old ulimit syscall holder */
1191 .long sys_ni_syscall /* old old uname syscall */
1192 .long sys_umask /* 60 */
1197 .long sys_getpgrp /* 65 */
1200 .long sys_ni_syscall // sys_sgetmask
1201 .long sys_ni_syscall // sys_ssetmask
1202 .long sys_setreuid16 /* 70 */
1203 .long sys_setregid16
1204 .long sys_sigsuspend
1205 .long sys_ni_syscall // sys_sigpending
1206 .long sys_sethostname
1207 .long sys_setrlimit /* 75 */
1208 .long sys_ni_syscall // sys_old_getrlimit
1210 .long sys_gettimeofday
1211 .long sys_settimeofday
1212 .long sys_getgroups16 /* 80 */
1213 .long sys_setgroups16
1214 .long sys_ni_syscall /* old_select slot */
1217 .long sys_readlink /* 85 */
1221 .long sys_ni_syscall // old_readdir
1222 .long sys_ni_syscall /* 90 */ /* old_mmap slot */
1227 .long sys_fchown16 /* 95 */
1228 .long sys_getpriority
1229 .long sys_setpriority
1230 .long sys_ni_syscall /* old profil syscall holder */
1232 .long sys_fstatfs /* 100 */
1233 .long sys_ni_syscall /* ioperm for i386 */
1234 .long sys_socketcall
1237 .long sys_getitimer /* 105 */
1241 .long sys_ni_syscall /* obsolete olduname( syscall */
1242 .long sys_ni_syscall /* iopl for i386 */ /* 110 */
1244 .long sys_ni_syscall /* obsolete idle( syscall */
1245 .long sys_ni_syscall /* vm86old for i386 */
1247 .long sys_swapoff /* 115 */
1252 .long sys_clone /* 120 */
1253 .long sys_setdomainname
1255 .long sys_ni_syscall /* old "cacheflush" */
1257 .long __MMU(sys_mprotect) /* 125 */
1258 .long sys_sigprocmask
1259 .long sys_ni_syscall /* old "create_module" */
1260 .long sys_init_module
1261 .long sys_delete_module
1262 .long sys_ni_syscall /* old "get_kernel_syms" */
1267 .long sys_sysfs /* 135 */
1268 .long sys_personality
1269 .long sys_ni_syscall /* for afs_syscall */
1270 .long sys_setfsuid16
1271 .long sys_setfsgid16
1272 .long sys_llseek /* 140 */
1276 .long __MMU(sys_msync)
1277 .long sys_readv /* 145 */
1282 .long __MMU(sys_mlock) /* 150 */
1283 .long __MMU(sys_munlock)
1284 .long __MMU(sys_mlockall)
1285 .long __MMU(sys_munlockall)
1286 .long sys_sched_setparam
1287 .long sys_sched_getparam /* 155 */
1288 .long sys_sched_setscheduler
1289 .long sys_sched_getscheduler
1290 .long sys_sched_yield
1291 .long sys_sched_get_priority_max
1292 .long sys_sched_get_priority_min /* 160 */
1293 .long sys_sched_rr_get_interval
1295 .long __MMU(sys_mremap)
1296 .long sys_setresuid16
1297 .long sys_getresuid16 /* 165 */
1298 .long sys_ni_syscall /* for vm86 */
1299 .long sys_ni_syscall /* Old sys_query_module */
1301 .long sys_nfsservctl
1302 .long sys_setresgid16 /* 170 */
1303 .long sys_getresgid16
1305 .long sys_rt_sigreturn
1306 .long sys_rt_sigaction
1307 .long sys_rt_sigprocmask /* 175 */
1308 .long sys_rt_sigpending
1309 .long sys_rt_sigtimedwait
1310 .long sys_rt_sigqueueinfo
1311 .long sys_rt_sigsuspend
1312 .long sys_pread64 /* 180 */
1317 .long sys_capset /* 185 */
1318 .long sys_sigaltstack
1320 .long sys_ni_syscall /* streams1 */
1321 .long sys_ni_syscall /* streams2 */
1322 .long sys_vfork /* 190 */
1325 .long sys_truncate64
1326 .long sys_ftruncate64
1327 .long sys_stat64 /* 195 */
1332 .long sys_getgid /* 200 */
1337 .long sys_getgroups /* 205 */
1342 .long sys_setresgid /* 210 */
1347 .long sys_setfsuid /* 215 */
1349 .long sys_pivot_root
1350 .long __MMU(sys_mincore)
1351 .long __MMU(sys_madvise)
1352 .long sys_getdents64 /* 220 */
1354 .long sys_ni_syscall /* reserved for TUX */
1355 .long sys_ni_syscall /* Reserved for Security */
1357 .long sys_readahead /* 225 */
1362 .long sys_lgetxattr /* 230 */
1365 .long sys_llistxattr
1366 .long sys_flistxattr
1367 .long sys_removexattr /* 235 */
1368 .long sys_lremovexattr
1369 .long sys_fremovexattr
1371 .long sys_sendfile64
1372 .long sys_futex /* 240 */
1373 .long sys_sched_setaffinity
1374 .long sys_sched_getaffinity
1375 .long sys_ni_syscall //sys_set_thread_area
1376 .long sys_ni_syscall //sys_get_thread_area
1377 .long sys_io_setup /* 245 */
1378 .long sys_io_destroy
1379 .long sys_io_getevents
1382 .long sys_fadvise64 /* 250 */
1383 .long sys_ni_syscall
1384 .long sys_exit_group
1385 .long sys_lookup_dcookie
1386 .long sys_epoll_create
1387 .long sys_epoll_ctl /* 255 */
1388 .long sys_epoll_wait
1389 .long __MMU(sys_remap_file_pages)
1390 .long sys_set_tid_address
1391 .long sys_timer_create
1392 .long sys_timer_settime /* 260 */
1393 .long sys_timer_gettime
1394 .long sys_timer_getoverrun
1395 .long sys_timer_delete
1396 .long sys_clock_settime
1397 .long sys_clock_gettime /* 265 */
1398 .long sys_clock_getres
1399 .long sys_clock_nanosleep
1402 .long sys_tgkill /* 270 */
1404 .long sys_fadvise64_64
1405 .long sys_ni_syscall /* sys_vserver */
1407 .long sys_get_mempolicy
1408 .long sys_set_mempolicy
1411 .long sys_mq_timedsend
1412 .long sys_mq_timedreceive /* 280 */
1414 .long sys_mq_getsetattr
1415 .long sys_ni_syscall /* reserved for kexec */
1417 .long sys_ni_syscall /* 285 */ /* available */
1419 .long sys_request_key
1421 .long sys_ni_syscall // sys_vperfctr_open
1422 .long sys_ni_syscall // sys_vperfctr_control /* 290 */
1423 .long sys_ni_syscall // sys_vperfctr_unlink
1424 .long sys_ni_syscall // sys_vperfctr_iresume
1425 .long sys_ni_syscall // sys_vperfctr_read
1428 syscall_table_size = (. - sys_call_table)