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/linkage.h>
32 #include <asm/thread_info.h>
33 #include <asm/setup.h>
34 #include <asm/segment.h>
35 #include <asm/ptrace.h>
36 #include <asm/errno.h>
37 #include <asm/cache.h>
38 #include <asm/spr-regs.h>
40 #define nr_syscalls ((syscall_table_size)/4)
46 # sethi.p %hi(0xe1200004),gr30
47 # setlo %lo(0xe1200004),gr30
50 # sethi.p %hi(0xffc00100),gr30
51 # setlo %lo(0xffc00100),gr30
58 # sethi.p %hi(0xe1200004),gr30
59 # setlo %lo(0xe1200004),gr30
60 # st.p gr31,@(gr30,gr0)
62 # sethi.p %hi(0xffc00100),gr30
63 # setlo %lo(0xffc00100),gr30
64 # sth gr31,@(gr30,gr0)
68 ###############################################################################
70 # entry point for External interrupts received whilst executing userspace code
72 ###############################################################################
73 .globl __entry_uspace_external_interrupt
74 .type __entry_uspace_external_interrupt,@function
75 __entry_uspace_external_interrupt:
77 sethi.p %hi(__kernel_frame0_ptr),gr28
78 setlo %lo(__kernel_frame0_ptr),gr28
81 # handle h/w single-step through exceptions
82 sti gr0,@(gr28,#REG__STATUS)
84 .globl __entry_uspace_external_interrupt_reentry
85 __entry_uspace_external_interrupt_reentry:
91 # finish building the exception frame
92 sti sp, @(gr28,#REG_SP)
93 stdi gr2, @(gr28,#REG_GR(2))
94 stdi gr4, @(gr28,#REG_GR(4))
95 stdi gr6, @(gr28,#REG_GR(6))
96 stdi gr8, @(gr28,#REG_GR(8))
97 stdi gr10,@(gr28,#REG_GR(10))
98 stdi gr12,@(gr28,#REG_GR(12))
99 stdi gr14,@(gr28,#REG_GR(14))
100 stdi gr16,@(gr28,#REG_GR(16))
101 stdi gr18,@(gr28,#REG_GR(18))
102 stdi gr20,@(gr28,#REG_GR(20))
103 stdi gr22,@(gr28,#REG_GR(22))
104 stdi gr24,@(gr28,#REG_GR(24))
105 stdi gr26,@(gr28,#REG_GR(26))
106 sti gr0, @(gr28,#REG_GR(28))
107 sti gr29,@(gr28,#REG_GR(29))
108 stdi.p gr30,@(gr28,#REG_GR(30))
110 # set up the kernel stack pointer
123 andi gr22,#PSR_PS,gr5 /* try to rebuild original PSR value */
124 andi.p gr22,#~(PSR_PS|PSR_S),gr6
127 andi gr5,#~PSR_ET,gr5
129 sti gr20,@(gr28,#REG_TBR)
130 sti gr21,@(gr28,#REG_PC)
131 sti gr5 ,@(gr28,#REG_PSR)
132 sti gr23,@(gr28,#REG_ISR)
133 stdi gr24,@(gr28,#REG_CCR)
134 stdi gr26,@(gr28,#REG_LR)
135 sti gr4 ,@(gr28,#REG_SYSCALLNO)
139 stdi gr4,@(gr28,#REG_IACC0)
143 stdi.p gr4,@(gr28,#REG_GNER0)
145 # interrupts start off fully disabled in the interrupt handler
146 subcc gr0,gr0,gr0,icc2 /* set Z and clear C */
148 # set up kernel global registers
149 sethi.p %hi(__kernel_current_task),gr5
150 setlo %lo(__kernel_current_task),gr5
151 sethi.p %hi(_gp),gr16
154 ldi.p @(gr29,#4),gr15 ; __current_thread_info = current->thread_info
156 # make sure we (the kernel) get div-zero and misalignment exceptions
157 setlos #ISR_EDE|ISR_DTT_DIVBYZERO|ISR_EMAM_EXCEPTION,gr5
160 # switch to the kernel trap table
161 sethi.p %hi(__entry_kerneltrap_table),gr6
162 setlo %lo(__entry_kerneltrap_table),gr6
165 # set the return address
166 sethi.p %hi(__entry_return_from_user_interrupt),gr4
167 setlo %lo(__entry_return_from_user_interrupt),gr4
170 # raise the minimum interrupt priority to 15 (NMI only) and enable exceptions
173 ori gr4,#PSR_PIL_14,gr4
175 ori gr4,#PSR_PIL_14|PSR_ET,gr4
181 .size __entry_uspace_external_interrupt,.-__entry_uspace_external_interrupt
183 ###############################################################################
185 # entry point for External interrupts received whilst executing kernel code
186 # - on arriving here, the following registers should already be set up:
187 # GR15 - current thread_info struct pointer
188 # GR16 - kernel GP-REL pointer
189 # GR29 - current task struct pointer
190 # TBR - kernel trap vector table
191 # ISR - kernel's preferred integer controls
193 ###############################################################################
194 .globl __entry_kernel_external_interrupt
195 .type __entry_kernel_external_interrupt,@function
196 __entry_kernel_external_interrupt:
201 # set up the stack pointer
204 sti gr30,@(sp,#REG_SP)
206 # handle h/w single-step through exceptions
207 sti gr0,@(sp,#REG__STATUS)
209 .globl __entry_kernel_external_interrupt_reentry
210 __entry_kernel_external_interrupt_reentry:
213 # set up the exception frame
214 setlos #REG__END,gr30
217 sti.p gr28,@(sp,#REG_GR(28))
220 # finish building the exception frame
221 stdi gr2,@(gr28,#REG_GR(2))
222 stdi gr4,@(gr28,#REG_GR(4))
223 stdi gr6,@(gr28,#REG_GR(6))
224 stdi gr8,@(gr28,#REG_GR(8))
225 stdi gr10,@(gr28,#REG_GR(10))
226 stdi gr12,@(gr28,#REG_GR(12))
227 stdi gr14,@(gr28,#REG_GR(14))
228 stdi gr16,@(gr28,#REG_GR(16))
229 stdi gr18,@(gr28,#REG_GR(18))
230 stdi gr20,@(gr28,#REG_GR(20))
231 stdi gr22,@(gr28,#REG_GR(22))
232 stdi gr24,@(gr28,#REG_GR(24))
233 stdi gr26,@(gr28,#REG_GR(26))
234 sti gr29,@(gr28,#REG_GR(29))
235 stdi.p gr30,@(gr28,#REG_GR(30))
237 # note virtual interrupts will be fully enabled upon return
238 subicc gr0,#1,gr0,icc2 /* clear Z, set C */
250 andi gr22,#PSR_PS,gr5 /* try to rebuild original PSR value */
251 andi.p gr22,#~(PSR_PS|PSR_S),gr6
254 andi.p gr5,#~PSR_ET,gr5
256 # set CCCR.CC3 to Undefined to abort atomic-modify completion inside the kernel
257 # - for an explanation of how it works, see: Documentation/fujitsu/frv/atomic-ops.txt
258 andi gr25,#~0xc0,gr25
260 sti gr20,@(gr28,#REG_TBR)
261 sti gr21,@(gr28,#REG_PC)
262 sti gr5 ,@(gr28,#REG_PSR)
263 sti gr23,@(gr28,#REG_ISR)
264 stdi gr24,@(gr28,#REG_CCR)
265 stdi gr26,@(gr28,#REG_LR)
266 sti gr4 ,@(gr28,#REG_SYSCALLNO)
270 stdi gr4,@(gr28,#REG_IACC0)
274 stdi.p gr4,@(gr28,#REG_GNER0)
276 # interrupts start off fully disabled in the interrupt handler
277 subcc gr0,gr0,gr0,icc2 /* set Z and clear C */
279 # set the return address
280 sethi.p %hi(__entry_return_from_kernel_interrupt),gr4
281 setlo %lo(__entry_return_from_kernel_interrupt),gr4
284 # clear power-saving mode flags
286 andi gr4,#~HSR0_PDM,gr4
289 # raise the minimum interrupt priority to 15 (NMI only) and enable exceptions
291 ori gr4,#PSR_PIL_14,gr4
299 .size __entry_kernel_external_interrupt,.-__entry_kernel_external_interrupt
301 ###############################################################################
303 # deal with interrupts that were actually virtually disabled
304 # - we need to really disable them, flag the fact and return immediately
305 # - if you change this, you must alter break.S also
307 ###############################################################################
308 .balign L1_CACHE_BYTES
309 .globl __entry_kernel_external_interrupt_virtually_disabled
310 .type __entry_kernel_external_interrupt_virtually_disabled,@function
311 __entry_kernel_external_interrupt_virtually_disabled:
313 andi gr30,#~PSR_PIL,gr30
314 ori gr30,#PSR_PIL_14,gr30 ; debugging interrupts only
316 subcc gr0,gr0,gr0,icc2 ; leave Z set, clear C
319 .size __entry_kernel_external_interrupt_virtually_disabled,.-__entry_kernel_external_interrupt_virtually_disabled
321 ###############################################################################
323 # deal with re-enablement of interrupts that were pending when virtually re-enabled
324 # - set ICC2.C, re-enable the real interrupts and return
325 # - we can clear ICC2.Z because we shouldn't be here if it's not 0 [due to TIHI]
326 # - if you change this, you must alter break.S also
328 ###############################################################################
329 .balign L1_CACHE_BYTES
330 .globl __entry_kernel_external_interrupt_virtual_reenable
331 .type __entry_kernel_external_interrupt_virtual_reenable,@function
332 __entry_kernel_external_interrupt_virtual_reenable:
334 andi gr30,#~PSR_PIL,gr30 ; re-enable interrupts
336 subicc gr0,#1,gr0,icc2 ; clear Z, set C
339 .size __entry_kernel_external_interrupt_virtual_reenable,.-__entry_kernel_external_interrupt_virtual_reenable
341 ###############################################################################
343 # entry point for Software and Progam interrupts generated whilst executing userspace code
345 ###############################################################################
346 .globl __entry_uspace_softprog_interrupt
347 .type __entry_uspace_softprog_interrupt,@function
348 .globl __entry_uspace_handle_mmu_fault
349 __entry_uspace_softprog_interrupt:
353 __entry_uspace_handle_mmu_fault:
356 sethi.p %hi(__kernel_frame0_ptr),gr28
357 setlo %lo(__kernel_frame0_ptr),gr28
360 # handle h/w single-step through exceptions
361 sti gr0,@(gr28,#REG__STATUS)
363 .globl __entry_uspace_softprog_interrupt_reentry
364 __entry_uspace_softprog_interrupt_reentry:
367 setlos #REG__END,gr30
370 # set up the kernel stack pointer
371 sti.p sp,@(gr28,#REG_SP)
373 sti gr0,@(gr28,#REG_GR(28))
375 stdi gr20,@(gr28,#REG_GR(20))
376 stdi gr22,@(gr28,#REG_GR(22))
382 sethi.p %hi(__entry_return_from_user_exception),gr23
383 setlo %lo(__entry_return_from_user_exception),gr23
387 .size __entry_uspace_softprog_interrupt,.-__entry_uspace_softprog_interrupt
389 # single-stepping was disabled on entry to a TLB handler that then faulted
391 .globl __entry_uspace_handle_mmu_fault_sstep
392 __entry_uspace_handle_mmu_fault_sstep:
394 sethi.p %hi(__kernel_frame0_ptr),gr28
395 setlo %lo(__kernel_frame0_ptr),gr28
398 # flag single-step re-enablement
399 sti gr0,@(gr28,#REG__STATUS)
400 bra __entry_uspace_softprog_interrupt_reentry
404 ###############################################################################
406 # entry point for Software and Progam interrupts generated whilst executing kernel code
408 ###############################################################################
409 .globl __entry_kernel_softprog_interrupt
410 .type __entry_kernel_softprog_interrupt,@function
411 __entry_kernel_softprog_interrupt:
419 .globl __entry_kernel_handle_mmu_fault
420 __entry_kernel_handle_mmu_fault:
421 # set up the stack pointer
424 sti sp,@(sp,#REG_SP-4)
427 # handle h/w single-step through exceptions
428 sti gr0,@(sp,#REG__STATUS)
430 .globl __entry_kernel_softprog_interrupt_reentry
431 __entry_kernel_softprog_interrupt_reentry:
434 setlos #REG__END,gr30
437 # set up the exception frame
438 sti.p gr28,@(sp,#REG_GR(28))
441 stdi gr20,@(gr28,#REG_GR(20))
442 stdi gr22,@(gr28,#REG_GR(22))
444 ldi @(sp,#REG_SP),gr22 /* reconstruct the old SP */
445 addi gr22,#REG__END,gr22
446 sti gr22,@(sp,#REG_SP)
448 # set CCCR.CC3 to Undefined to abort atomic-modify completion inside the kernel
449 # - for an explanation of how it works, see: Documentation/fujitsu/frv/atomic-ops.txt
451 andi gr20,#~0xc0,gr20
458 sethi.p %hi(__entry_return_from_kernel_exception),gr23
459 setlo %lo(__entry_return_from_kernel_exception),gr23
462 .size __entry_kernel_softprog_interrupt,.-__entry_kernel_softprog_interrupt
464 # single-stepping was disabled on entry to a TLB handler that then faulted
466 .globl __entry_kernel_handle_mmu_fault_sstep
467 __entry_kernel_handle_mmu_fault_sstep:
468 # set up the stack pointer
471 sti sp,@(sp,#REG_SP-4)
474 # flag single-step re-enablement
475 sethi #REG__STATUS_STEP,gr30
476 sti gr30,@(sp,#REG__STATUS)
477 bra __entry_kernel_softprog_interrupt_reentry
481 ###############################################################################
483 # the rest of the kernel entry point code
484 # - on arriving here, the following registers should be set up:
485 # GR1 - kernel stack pointer
486 # GR7 - syscall number (trap 0 only)
487 # GR8-13 - syscall args (trap 0 only)
491 # GR23 - return handler address
492 # GR28 - exception frame on stack
493 # SCR2 - saved EAR0 where applicable (clobbered by ICI & ICEF insns on FR451)
494 # PSR - PSR.S 1, PSR.ET 0
496 ###############################################################################
497 .globl __entry_common
498 .type __entry_common,@function
502 # finish building the exception frame
503 stdi gr2,@(gr28,#REG_GR(2))
504 stdi gr4,@(gr28,#REG_GR(4))
505 stdi gr6,@(gr28,#REG_GR(6))
506 stdi gr8,@(gr28,#REG_GR(8))
507 stdi gr10,@(gr28,#REG_GR(10))
508 stdi gr12,@(gr28,#REG_GR(12))
509 stdi gr14,@(gr28,#REG_GR(14))
510 stdi gr16,@(gr28,#REG_GR(16))
511 stdi gr18,@(gr28,#REG_GR(18))
512 stdi gr24,@(gr28,#REG_GR(24))
513 stdi gr26,@(gr28,#REG_GR(26))
514 sti gr29,@(gr28,#REG_GR(29))
515 stdi gr30,@(gr28,#REG_GR(30))
525 andi gr22,#PSR_PS,gr5 /* try to rebuild original PSR value */
526 andi.p gr22,#~(PSR_PS|PSR_S),gr6
529 andi gr5,#~PSR_ET,gr5
531 sti gr20,@(gr28,#REG_TBR)
532 sti gr21,@(gr28,#REG_PC)
533 sti gr5 ,@(gr28,#REG_PSR)
534 sti gr23,@(gr28,#REG_ISR)
535 stdi gr24,@(gr28,#REG_CCR)
536 stdi gr26,@(gr28,#REG_LR)
537 sti gr4 ,@(gr28,#REG_SYSCALLNO)
541 stdi gr4,@(gr28,#REG_IACC0)
545 stdi.p gr4,@(gr28,#REG_GNER0)
547 # set up virtual interrupt disablement
548 subicc gr0,#1,gr0,icc2 /* clear Z flag, set C flag */
550 # set up kernel global registers
551 sethi.p %hi(__kernel_current_task),gr5
552 setlo %lo(__kernel_current_task),gr5
553 sethi.p %hi(_gp),gr16
556 ldi @(gr29,#4),gr15 ; __current_thread_info = current->thread_info
558 # switch to the kernel trap table
559 sethi.p %hi(__entry_kerneltrap_table),gr6
560 setlo %lo(__entry_kerneltrap_table),gr6
563 # make sure we (the kernel) get div-zero and misalignment exceptions
564 setlos #ISR_EDE|ISR_DTT_DIVBYZERO|ISR_EMAM_EXCEPTION,gr5
567 # clear power-saving mode flags
569 andi gr4,#~HSR0_PDM,gr4
572 # multiplex again using old TBR as a guide
574 sethi %hi(__entry_vector_table),gr6
576 setlo %lo(__entry_vector_table),gr6
584 .size __entry_common,.-__entry_common
586 ###############################################################################
588 # handle instruction MMU fault
590 ###############################################################################
592 .globl __entry_insn_mmu_fault
593 __entry_insn_mmu_fault:
599 # now that we've accessed the exception regs, we can enable exceptions
604 sethi.p %hi(do_page_fault),gr5
605 setlo %lo(do_page_fault),gr5
606 jmpl @(gr5,gr0) ; call do_page_fault(0,esr0,ear0)
610 ###############################################################################
612 # handle instruction access error
614 ###############################################################################
615 .globl __entry_insn_access_error
616 __entry_insn_access_error:
618 sethi.p %hi(insn_access_error),gr5
619 setlo %lo(insn_access_error),gr5
624 # now that we've accessed the exception regs, we can enable exceptions
628 jmpl @(gr5,gr0) ; call insn_access_error(esfr1,epcr0,esr0)
630 ###############################################################################
632 # handle various instructions of dubious legality
634 ###############################################################################
635 .globl __entry_unsupported_trap
636 .globl __entry_illegal_instruction
637 .globl __entry_privileged_instruction
638 .globl __entry_debug_exception
639 __entry_unsupported_trap:
641 sti gr21,@(gr28,#REG_PC)
642 __entry_illegal_instruction:
643 __entry_privileged_instruction:
644 __entry_debug_exception:
646 sethi.p %hi(illegal_instruction),gr5
647 setlo %lo(illegal_instruction),gr5
652 # now that we've accessed the exception regs, we can enable exceptions
656 jmpl @(gr5,gr0) ; call ill_insn(esfr1,epcr0,esr0)
658 ###############################################################################
660 # handle media exception
662 ###############################################################################
663 .globl __entry_media_exception
664 __entry_media_exception:
666 sethi.p %hi(media_exception),gr5
667 setlo %lo(media_exception),gr5
671 # now that we've accessed the exception regs, we can enable exceptions
675 jmpl @(gr5,gr0) ; call media_excep(msr0,msr1)
677 ###############################################################################
679 # handle data MMU fault
680 # handle data DAT fault (write-protect exception)
682 ###############################################################################
684 .globl __entry_data_mmu_fault
685 __entry_data_mmu_fault:
686 .globl __entry_data_dat_fault
687 __entry_data_dat_fault:
691 movsg scr2,gr10 ; saved EAR0
693 # now that we've accessed the exception regs, we can enable exceptions
698 sethi.p %hi(do_page_fault),gr5
699 setlo %lo(do_page_fault),gr5
700 jmpl @(gr5,gr0) ; call do_page_fault(1,esr0,ear0)
703 ###############################################################################
705 # handle data and instruction access exceptions
707 ###############################################################################
708 .globl __entry_insn_access_exception
709 .globl __entry_data_access_exception
710 __entry_insn_access_exception:
711 __entry_data_access_exception:
713 sethi.p %hi(memory_access_exception),gr5
714 setlo %lo(memory_access_exception),gr5
716 movsg scr2,gr9 ; saved EAR0
719 # now that we've accessed the exception regs, we can enable exceptions
723 jmpl @(gr5,gr0) ; call memory_access_error(esr0,ear0,epcr0)
725 ###############################################################################
727 # handle data access error
729 ###############################################################################
730 .globl __entry_data_access_error
731 __entry_data_access_error:
733 sethi.p %hi(data_access_error),gr5
734 setlo %lo(data_access_error),gr5
739 # now that we've accessed the exception regs, we can enable exceptions
743 jmpl @(gr5,gr0) ; call data_access_error(esfr1,esr15,ear15)
745 ###############################################################################
747 # handle data store error
749 ###############################################################################
750 .globl __entry_data_store_error
751 __entry_data_store_error:
753 sethi.p %hi(data_store_error),gr5
754 setlo %lo(data_store_error),gr5
758 # now that we've accessed the exception regs, we can enable exceptions
762 jmpl @(gr5,gr0) ; call data_store_error(esfr1,esr14)
764 ###############################################################################
766 # handle division exception
768 ###############################################################################
769 .globl __entry_division_exception
770 __entry_division_exception:
772 sethi.p %hi(division_exception),gr5
773 setlo %lo(division_exception),gr5
778 # now that we've accessed the exception regs, we can enable exceptions
782 jmpl @(gr5,gr0) ; call div_excep(esfr1,esr0,isr)
784 ###############################################################################
786 # handle compound exception
788 ###############################################################################
789 .globl __entry_compound_exception
790 __entry_compound_exception:
792 sethi.p %hi(compound_exception),gr5
793 setlo %lo(compound_exception),gr5
801 # now that we've accessed the exception regs, we can enable exceptions
805 jmpl @(gr5,gr0) ; call comp_excep(esfr1,esr0,esr14,esr15,msr0,msr1)
807 ###############################################################################
809 # handle interrupts and NMIs
811 ###############################################################################
812 .globl __entry_do_IRQ
816 # we can enable exceptions
822 .globl __entry_do_NMI
826 # we can enable exceptions
832 ###############################################################################
834 # the return path for a newly forked child process
835 # - __switch_to() saved the old current pointer in GR8 for us
837 ###############################################################################
843 # fork & co. return 0 to child
847 ###################################################################################################
849 # Return to user mode is not as complex as all this looks,
850 # but we want the default path for a system call return to
851 # go as quickly as possible which is why some of this is
852 # less clear than it otherwise should be.
854 ###################################################################################################
855 .balign L1_CACHE_BYTES
859 movsg psr,gr4 ; enable exceptions
863 sti gr7,@(gr28,#REG_SYSCALLNO)
864 sti.p gr8,@(gr28,#REG_ORIG_GR8)
866 subicc gr7,#nr_syscalls,gr0,icc0
867 bnc icc0,#0,__syscall_badsys
869 ldi @(gr15,#TI_FLAGS),gr4
870 ori gr4,#_TIF_SYSCALL_TRACE,gr4
871 andicc gr4,#_TIF_SYSCALL_TRACE,gr0,icc0
872 bne icc0,#0,__syscall_trace_entry
876 sethi %hi(sys_call_table),gr5
877 setlo %lo(sys_call_table),gr5
882 ###############################################################################
884 # return to interrupted process
886 ###############################################################################
890 sti gr8,@(gr28,#REG_GR(8)) ; save return value
892 # rebuild saved psr - execve will change it for init/main.c
893 ldi @(gr28,#REG_PSR),gr22
895 andi.p gr22,#~PSR_PS,gr22
900 # keep current PSR in GR23
903 # make sure we don't miss an interrupt setting need_resched or sigpending between
904 # sampling and the RETT
905 ori gr23,#PSR_PIL_14,gr23
908 ldi @(gr15,#TI_FLAGS),gr4
909 sethi.p %hi(_TIF_ALLWORK_MASK),gr5
910 setlo %lo(_TIF_ALLWORK_MASK),gr5
911 andcc gr4,gr5,gr0,icc0
912 bne icc0,#0,__syscall_exit_work
914 # restore all registers and return
915 __entry_return_direct:
918 andi gr22,#~PSR_ET,gr22
921 ldi @(gr28,#REG_ISR),gr23
922 lddi @(gr28,#REG_CCR),gr24
923 lddi @(gr28,#REG_LR) ,gr26
924 ldi @(gr28,#REG_PC) ,gr21
925 ldi @(gr28,#REG_TBR),gr20
935 lddi @(gr28,#REG_GNER0),gr4
939 lddi @(gr28,#REG_IACC0),gr4
943 lddi @(gr28,#REG_GR(4)) ,gr4
944 lddi @(gr28,#REG_GR(6)) ,gr6
945 lddi @(gr28,#REG_GR(8)) ,gr8
946 lddi @(gr28,#REG_GR(10)),gr10
947 lddi @(gr28,#REG_GR(12)),gr12
948 lddi @(gr28,#REG_GR(14)),gr14
949 lddi @(gr28,#REG_GR(16)),gr16
950 lddi @(gr28,#REG_GR(18)),gr18
951 lddi @(gr28,#REG_GR(20)),gr20
952 lddi @(gr28,#REG_GR(22)),gr22
953 lddi @(gr28,#REG_GR(24)),gr24
954 lddi @(gr28,#REG_GR(26)),gr26
955 ldi @(gr28,#REG_GR(29)),gr29
956 lddi @(gr28,#REG_GR(30)),gr30
958 # check to see if a debugging return is required
961 ldi @(gr28,#REG__STATUS),gr3
962 andicc gr3,#REG__STATUS_STEP,gr0,icc0
963 bne icc0,#0,__entry_return_singlestep
966 ldi @(gr28,#REG_SP) ,sp
967 lddi @(gr28,#REG_GR(2)) ,gr2
968 ldi @(gr28,#REG_GR(28)),gr28
975 # store the current frame in the workram on the FR451
977 sethi.p %hi(0xfe800000),gr28
978 setlo %lo(0xfe800000),gr28
980 stdi gr2,@(gr28,#REG_GR(2))
981 stdi gr4,@(gr28,#REG_GR(4))
982 stdi gr6,@(gr28,#REG_GR(6))
983 stdi gr8,@(gr28,#REG_GR(8))
984 stdi gr10,@(gr28,#REG_GR(10))
985 stdi gr12,@(gr28,#REG_GR(12))
986 stdi gr14,@(gr28,#REG_GR(14))
987 stdi gr16,@(gr28,#REG_GR(16))
988 stdi gr18,@(gr28,#REG_GR(18))
989 stdi gr24,@(gr28,#REG_GR(24))
990 stdi gr26,@(gr28,#REG_GR(26))
991 sti gr29,@(gr28,#REG_GR(29))
992 stdi gr30,@(gr28,#REG_GR(30))
995 sti gr30,@(gr28,#REG_TBR)
997 sti gr30,@(gr28,#REG_PC)
999 sti gr30,@(gr28,#REG_PSR)
1001 sti gr30,@(gr28,#REG_ISR)
1004 stdi gr30,@(gr28,#REG_CCR)
1007 stdi gr30,@(gr28,#REG_LR)
1008 sti gr0 ,@(gr28,#REG_SYSCALLNO)
1014 # return via break.S
1015 __entry_return_singlestep:
1017 lddi @(gr28,#REG_GR(2)) ,gr2
1018 ldi @(gr28,#REG_SP) ,sp
1019 ldi @(gr28,#REG_GR(28)),gr28
1022 .globl __entry_return_singlestep_breaks_here
1023 __entry_return_singlestep_breaks_here:
1027 ###############################################################################
1029 # return to a process interrupted in kernel space
1030 # - we need to consider preemption if that is enabled
1032 ###############################################################################
1033 .balign L1_CACHE_BYTES
1034 __entry_return_from_kernel_exception:
1037 ori gr23,#PSR_PIL_14,gr23
1039 bra __entry_return_direct
1041 .balign L1_CACHE_BYTES
1042 __entry_return_from_kernel_interrupt:
1045 ori gr23,#PSR_PIL_14,gr23
1048 #ifdef CONFIG_PREEMPT
1049 ldi @(gr15,#TI_PRE_COUNT),gr5
1050 subicc gr5,#0,gr0,icc0
1051 beq icc0,#0,__entry_return_direct
1053 __entry_preempt_need_resched:
1054 ldi @(gr15,#TI_FLAGS),gr4
1055 andicc gr4,#_TIF_NEED_RESCHED,gr0,icc0
1056 beq icc0,#1,__entry_return_direct
1058 setlos #PREEMPT_ACTIVE,gr5
1059 sti gr5,@(gr15,#TI_FLAGS)
1061 andi gr23,#~PSR_PIL,gr23
1065 sti gr0,@(gr15,#TI_PRE_COUNT)
1068 ori gr23,#PSR_PIL_14,gr23
1070 bra __entry_preempt_need_resched
1072 bra __entry_return_direct
1076 ###############################################################################
1078 # perform work that needs to be done immediately before resumption
1080 ###############################################################################
1081 .globl __entry_return_from_user_exception
1082 .balign L1_CACHE_BYTES
1083 __entry_return_from_user_exception:
1086 __entry_resume_userspace:
1087 # make sure we don't miss an interrupt setting need_resched or sigpending between
1088 # sampling and the RETT
1090 ori gr23,#PSR_PIL_14,gr23
1093 __entry_return_from_user_interrupt:
1095 ldi @(gr15,#TI_FLAGS),gr4
1096 sethi.p %hi(_TIF_WORK_MASK),gr5
1097 setlo %lo(_TIF_WORK_MASK),gr5
1098 andcc gr4,gr5,gr0,icc0
1099 beq icc0,#1,__entry_return_direct
1101 __entry_work_pending:
1103 andicc gr4,#_TIF_NEED_RESCHED,gr0,icc0
1104 beq icc0,#1,__entry_work_notifysig
1106 __entry_work_resched:
1109 andi gr23,#~PSR_PIL,gr23
1113 ori gr23,#PSR_PIL_14,gr23
1117 ldi @(gr15,#TI_FLAGS),gr4
1118 sethi.p %hi(_TIF_WORK_MASK),gr5
1119 setlo %lo(_TIF_WORK_MASK),gr5
1120 andcc gr4,gr5,gr0,icc0
1121 beq icc0,#1,__entry_return_direct
1122 andicc gr4,#_TIF_NEED_RESCHED,gr0,icc0
1123 bne icc0,#1,__entry_work_resched
1125 __entry_work_notifysig:
1128 call do_notify_resume
1129 bra __entry_resume_userspace
1131 # perform syscall entry tracing
1132 __syscall_trace_entry:
1135 call do_syscall_trace
1137 ldi @(gr28,#REG_SYSCALLNO),gr7
1138 lddi @(gr28,#REG_GR(8)) ,gr8
1139 lddi @(gr28,#REG_GR(10)),gr10
1140 lddi.p @(gr28,#REG_GR(12)),gr12
1142 subicc gr7,#nr_syscalls,gr0,icc0
1143 bnc icc0,#0,__syscall_badsys
1146 # perform syscall exit tracing
1147 __syscall_exit_work:
1149 andicc gr4,#_TIF_SYSCALL_TRACE,gr0,icc0
1150 beq icc0,#1,__entry_work_pending
1153 andi gr23,#~PSR_PIL,gr23 ; could let do_syscall_trace() call schedule()
1157 call do_syscall_trace
1158 bra __entry_resume_userspace
1163 sti gr8,@(gr28,#REG_GR(8)) ; save return value
1164 bra __entry_resume_userspace
1167 ###############################################################################
1169 # syscall vector table
1171 ###############################################################################
1174 .globl sys_call_table
1176 .long sys_restart_syscall /* 0 - old "setup()" system call, used for restarting */
1181 .long sys_open /* 5 */
1186 .long sys_unlink /* 10 */
1191 .long sys_chmod /* 15 */
1193 .long sys_ni_syscall /* old break syscall holder */
1196 .long sys_getpid /* 20 */
1201 .long sys_ni_syscall // sys_stime /* 25 */
1206 .long sys_utime /* 30 */
1207 .long sys_ni_syscall /* old stty syscall holder */
1208 .long sys_ni_syscall /* old gtty syscall holder */
1211 .long sys_ni_syscall /* 35 */ /* old ftime syscall holder */
1216 .long sys_rmdir /* 40 */
1220 .long sys_ni_syscall /* old prof syscall holder */
1221 .long sys_brk /* 45 */
1224 .long sys_ni_syscall // sys_signal
1226 .long sys_getegid16 /* 50 */
1228 .long sys_umount /* recycled never used phys( */
1229 .long sys_ni_syscall /* old lock syscall holder */
1231 .long sys_fcntl /* 55 */
1232 .long sys_ni_syscall /* old mpx syscall holder */
1234 .long sys_ni_syscall /* old ulimit syscall holder */
1235 .long sys_ni_syscall /* old old uname syscall */
1236 .long sys_umask /* 60 */
1241 .long sys_getpgrp /* 65 */
1244 .long sys_ni_syscall // sys_sgetmask
1245 .long sys_ni_syscall // sys_ssetmask
1246 .long sys_setreuid16 /* 70 */
1247 .long sys_setregid16
1248 .long sys_sigsuspend
1249 .long sys_ni_syscall // sys_sigpending
1250 .long sys_sethostname
1251 .long sys_setrlimit /* 75 */
1252 .long sys_ni_syscall // sys_old_getrlimit
1254 .long sys_gettimeofday
1255 .long sys_settimeofday
1256 .long sys_getgroups16 /* 80 */
1257 .long sys_setgroups16
1258 .long sys_ni_syscall /* old_select slot */
1261 .long sys_readlink /* 85 */
1265 .long sys_ni_syscall // old_readdir
1266 .long sys_ni_syscall /* 90 */ /* old_mmap slot */
1271 .long sys_fchown16 /* 95 */
1272 .long sys_getpriority
1273 .long sys_setpriority
1274 .long sys_ni_syscall /* old profil syscall holder */
1276 .long sys_fstatfs /* 100 */
1277 .long sys_ni_syscall /* ioperm for i386 */
1278 .long sys_socketcall
1281 .long sys_getitimer /* 105 */
1285 .long sys_ni_syscall /* obsolete olduname( syscall */
1286 .long sys_ni_syscall /* iopl for i386 */ /* 110 */
1288 .long sys_ni_syscall /* obsolete idle( syscall */
1289 .long sys_ni_syscall /* vm86old for i386 */
1291 .long sys_swapoff /* 115 */
1296 .long sys_clone /* 120 */
1297 .long sys_setdomainname
1299 .long sys_ni_syscall /* old "cacheflush" */
1301 .long sys_mprotect /* 125 */
1302 .long sys_sigprocmask
1303 .long sys_ni_syscall /* old "create_module" */
1304 .long sys_init_module
1305 .long sys_delete_module
1306 .long sys_ni_syscall /* old "get_kernel_syms" */
1311 .long sys_sysfs /* 135 */
1312 .long sys_personality
1313 .long sys_ni_syscall /* for afs_syscall */
1314 .long sys_setfsuid16
1315 .long sys_setfsgid16
1316 .long sys_llseek /* 140 */
1321 .long sys_readv /* 145 */
1326 .long sys_mlock /* 150 */
1329 .long sys_munlockall
1330 .long sys_sched_setparam
1331 .long sys_sched_getparam /* 155 */
1332 .long sys_sched_setscheduler
1333 .long sys_sched_getscheduler
1334 .long sys_sched_yield
1335 .long sys_sched_get_priority_max
1336 .long sys_sched_get_priority_min /* 160 */
1337 .long sys_sched_rr_get_interval
1340 .long sys_setresuid16
1341 .long sys_getresuid16 /* 165 */
1342 .long sys_ni_syscall /* for vm86 */
1343 .long sys_ni_syscall /* Old sys_query_module */
1345 .long sys_nfsservctl
1346 .long sys_setresgid16 /* 170 */
1347 .long sys_getresgid16
1349 .long sys_rt_sigreturn
1350 .long sys_rt_sigaction
1351 .long sys_rt_sigprocmask /* 175 */
1352 .long sys_rt_sigpending
1353 .long sys_rt_sigtimedwait
1354 .long sys_rt_sigqueueinfo
1355 .long sys_rt_sigsuspend
1356 .long sys_pread64 /* 180 */
1361 .long sys_capset /* 185 */
1362 .long sys_sigaltstack
1364 .long sys_ni_syscall /* streams1 */
1365 .long sys_ni_syscall /* streams2 */
1366 .long sys_vfork /* 190 */
1369 .long sys_truncate64
1370 .long sys_ftruncate64
1371 .long sys_stat64 /* 195 */
1376 .long sys_getgid /* 200 */
1381 .long sys_getgroups /* 205 */
1386 .long sys_setresgid /* 210 */
1391 .long sys_setfsuid /* 215 */
1393 .long sys_pivot_root
1396 .long sys_getdents64 /* 220 */
1398 .long sys_ni_syscall /* reserved for TUX */
1399 .long sys_ni_syscall /* Reserved for Security */
1401 .long sys_readahead /* 225 */
1406 .long sys_lgetxattr /* 230 */
1409 .long sys_llistxattr
1410 .long sys_flistxattr
1411 .long sys_removexattr /* 235 */
1412 .long sys_lremovexattr
1413 .long sys_fremovexattr
1415 .long sys_sendfile64
1416 .long sys_futex /* 240 */
1417 .long sys_sched_setaffinity
1418 .long sys_sched_getaffinity
1419 .long sys_ni_syscall //sys_set_thread_area
1420 .long sys_ni_syscall //sys_get_thread_area
1421 .long sys_io_setup /* 245 */
1422 .long sys_io_destroy
1423 .long sys_io_getevents
1426 .long sys_fadvise64 /* 250 */
1427 .long sys_ni_syscall
1428 .long sys_exit_group
1429 .long sys_lookup_dcookie
1430 .long sys_epoll_create
1431 .long sys_epoll_ctl /* 255 */
1432 .long sys_epoll_wait
1433 .long sys_remap_file_pages
1434 .long sys_set_tid_address
1435 .long sys_timer_create
1436 .long sys_timer_settime /* 260 */
1437 .long sys_timer_gettime
1438 .long sys_timer_getoverrun
1439 .long sys_timer_delete
1440 .long sys_clock_settime
1441 .long sys_clock_gettime /* 265 */
1442 .long sys_clock_getres
1443 .long sys_clock_nanosleep
1446 .long sys_tgkill /* 270 */
1448 .long sys_fadvise64_64
1449 .long sys_ni_syscall /* sys_vserver */
1451 .long sys_get_mempolicy
1452 .long sys_set_mempolicy
1455 .long sys_mq_timedsend
1456 .long sys_mq_timedreceive /* 280 */
1458 .long sys_mq_getsetattr
1459 .long sys_ni_syscall /* reserved for kexec */
1461 .long sys_ni_syscall /* 285 */ /* available */
1463 .long sys_request_key
1465 .long sys_ioprio_set
1466 .long sys_ioprio_get /* 290 */
1467 .long sys_inotify_init
1468 .long sys_inotify_add_watch
1469 .long sys_inotify_rm_watch
1470 .long sys_migrate_pages
1471 .long sys_openat /* 295 */
1476 .long sys_fstatat64 /* 300 */
1481 .long sys_readlinkat /* 305 */
1488 syscall_table_size = (. - sys_call_table)