Back to home page

LXR

 
 

    


0001 /* entry.S: FR-V entry
0002  *
0003  * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
0004  * Written by David Howells (dhowells@redhat.com)
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License
0008  * as published by the Free Software Foundation; either version
0009  * 2 of the License, or (at your option) any later version.
0010  *
0011  *
0012  * Entry to the kernel is "interesting":
0013  *  (1) There are no stack pointers, not even for the kernel
0014  *  (2) General Registers should not be clobbered
0015  *  (3) There are no kernel-only data registers
0016  *  (4) Since all addressing modes are wrt to a General Register, no global
0017  *      variables can be reached
0018  *
0019  * We deal with this by declaring that we shall kill GR28 on entering the
0020  * kernel from userspace
0021  *
0022  * However, since break interrupts can interrupt the CPU even when PSR.ET==0,
0023  * they can't rely on GR28 to be anything useful, and so need to clobber a
0024  * separate register (GR31). Break interrupts are managed in break.S
0025  *
0026  * GR29 _is_ saved, and holds the current task pointer globally
0027  *
0028  */
0029 
0030 #include <linux/linkage.h>
0031 #include <asm/thread_info.h>
0032 #include <asm/setup.h>
0033 #include <asm/segment.h>
0034 #include <asm/ptrace.h>
0035 #include <asm/errno.h>
0036 #include <asm/cache.h>
0037 #include <asm/spr-regs.h>
0038 
0039 #define nr_syscalls ((syscall_table_size)/4)
0040 
0041     .section    .text..entry
0042     .balign     4
0043 
0044 .macro LEDS val
0045 #   sethi.p     %hi(0xe1200004),gr30
0046 #   setlo       %lo(0xe1200004),gr30
0047 #   setlos      #~\val,gr31
0048 #   st      gr31,@(gr30,gr0)
0049 #   sethi.p     %hi(0xffc00100),gr30
0050 #   setlo       %lo(0xffc00100),gr30
0051 #   sth     gr0,@(gr30,gr0)
0052 #   membar
0053 .endm
0054 
0055 .macro LEDS32
0056 #   not     gr31,gr31
0057 #   sethi.p     %hi(0xe1200004),gr30
0058 #   setlo       %lo(0xe1200004),gr30
0059 #   st.p        gr31,@(gr30,gr0)
0060 #   srli        gr31,#16,gr31
0061 #   sethi.p     %hi(0xffc00100),gr30
0062 #   setlo       %lo(0xffc00100),gr30
0063 #   sth     gr31,@(gr30,gr0)
0064 #   membar
0065 .endm
0066 
0067 ###############################################################################
0068 #
0069 # entry point for External interrupts received whilst executing userspace code
0070 #
0071 ###############################################################################
0072     .globl      __entry_uspace_external_interrupt
0073         .type       __entry_uspace_external_interrupt,@function
0074 __entry_uspace_external_interrupt:
0075     LEDS        0x6200
0076     sethi.p     %hi(__kernel_frame0_ptr),gr28
0077     setlo       %lo(__kernel_frame0_ptr),gr28
0078     ldi     @(gr28,#0),gr28
0079 
0080     # handle h/w single-step through exceptions
0081     sti     gr0,@(gr28,#REG__STATUS)
0082 
0083     .globl      __entry_uspace_external_interrupt_reentry
0084 __entry_uspace_external_interrupt_reentry:
0085     LEDS        0x6201
0086 
0087     setlos      #REG__END,gr30
0088     dcpl        gr28,gr30,#0
0089 
0090     # finish building the exception frame
0091     sti     sp,  @(gr28,#REG_SP)
0092     stdi        gr2, @(gr28,#REG_GR(2))
0093     stdi        gr4, @(gr28,#REG_GR(4))
0094     stdi        gr6, @(gr28,#REG_GR(6))
0095     stdi        gr8, @(gr28,#REG_GR(8))
0096     stdi        gr10,@(gr28,#REG_GR(10))
0097     stdi        gr12,@(gr28,#REG_GR(12))
0098     stdi        gr14,@(gr28,#REG_GR(14))
0099     stdi        gr16,@(gr28,#REG_GR(16))
0100     stdi        gr18,@(gr28,#REG_GR(18))
0101     stdi        gr20,@(gr28,#REG_GR(20))
0102     stdi        gr22,@(gr28,#REG_GR(22))
0103     stdi        gr24,@(gr28,#REG_GR(24))
0104     stdi        gr26,@(gr28,#REG_GR(26))
0105     sti     gr0, @(gr28,#REG_GR(28))
0106     sti     gr29,@(gr28,#REG_GR(29))
0107     stdi.p      gr30,@(gr28,#REG_GR(30))
0108 
0109     # set up the kernel stack pointer
0110     ori     gr28,0,sp
0111 
0112     movsg       tbr ,gr20
0113     movsg       psr ,gr22
0114     movsg       pcsr,gr21
0115     movsg       isr ,gr23
0116     movsg       ccr ,gr24
0117     movsg       cccr,gr25
0118     movsg       lr  ,gr26
0119     movsg       lcr ,gr27
0120 
0121     setlos.p    #-1,gr4
0122     andi        gr22,#PSR_PS,gr5        /* try to rebuild original PSR value */
0123     andi.p      gr22,#~(PSR_PS|PSR_S),gr6
0124     slli        gr5,#1,gr5
0125     or      gr6,gr5,gr5
0126     andi        gr5,#~PSR_ET,gr5
0127 
0128     sti     gr20,@(gr28,#REG_TBR)
0129     sti     gr21,@(gr28,#REG_PC)
0130     sti     gr5 ,@(gr28,#REG_PSR)
0131     sti     gr23,@(gr28,#REG_ISR)
0132     stdi        gr24,@(gr28,#REG_CCR)
0133     stdi        gr26,@(gr28,#REG_LR)
0134     sti     gr4 ,@(gr28,#REG_SYSCALLNO)
0135 
0136     movsg       iacc0h,gr4
0137     movsg       iacc0l,gr5
0138     stdi        gr4,@(gr28,#REG_IACC0)
0139 
0140     movsg       gner0,gr4
0141     movsg       gner1,gr5
0142     stdi.p      gr4,@(gr28,#REG_GNER0)
0143 
0144     # interrupts start off fully disabled in the interrupt handler
0145     subcc       gr0,gr0,gr0,icc2        /* set Z and clear C */
0146 
0147     # set up kernel global registers
0148     sethi.p     %hi(__kernel_current_task),gr5
0149     setlo       %lo(__kernel_current_task),gr5
0150     sethi.p     %hi(_gp),gr16
0151     setlo       %lo(_gp),gr16
0152     ldi     @(gr5,#0),gr29
0153     ldi.p       @(gr29,#4),gr15     ; __current_thread_info = current->thread_info
0154 
0155     # make sure we (the kernel) get div-zero and misalignment exceptions
0156     setlos      #ISR_EDE|ISR_DTT_DIVBYZERO|ISR_EMAM_EXCEPTION,gr5
0157     movgs       gr5,isr
0158 
0159     # switch to the kernel trap table
0160     sethi.p     %hi(__entry_kerneltrap_table),gr6
0161     setlo       %lo(__entry_kerneltrap_table),gr6
0162     movgs       gr6,tbr
0163 
0164     # set the return address
0165     sethi.p     %hi(__entry_return_from_user_interrupt),gr4
0166     setlo       %lo(__entry_return_from_user_interrupt),gr4
0167     movgs       gr4,lr
0168 
0169     # raise the minimum interrupt priority to 15 (NMI only) and enable exceptions
0170     movsg       psr,gr4
0171 
0172     ori     gr4,#PSR_PIL_14,gr4
0173     movgs       gr4,psr
0174     ori     gr4,#PSR_PIL_14|PSR_ET,gr4
0175     movgs       gr4,psr
0176 
0177     LEDS        0x6202
0178     bra     do_IRQ
0179 
0180     .size       __entry_uspace_external_interrupt,.-__entry_uspace_external_interrupt
0181 
0182 ###############################################################################
0183 #
0184 # entry point for External interrupts received whilst executing kernel code
0185 # - on arriving here, the following registers should already be set up:
0186 #   GR15    - current thread_info struct pointer
0187 #   GR16    - kernel GP-REL pointer
0188 #   GR29    - current task struct pointer
0189 #   TBR - kernel trap vector table
0190 #   ISR - kernel's preferred integer controls
0191 #
0192 ###############################################################################
0193     .globl      __entry_kernel_external_interrupt
0194         .type       __entry_kernel_external_interrupt,@function
0195 __entry_kernel_external_interrupt:
0196     LEDS        0x6210
0197 //  sub     sp,gr15,gr31
0198 //  LEDS32
0199 
0200     # set up the stack pointer
0201     or.p        sp,gr0,gr30
0202     subi        sp,#REG__END,sp
0203     sti     gr30,@(sp,#REG_SP)
0204 
0205     # handle h/w single-step through exceptions
0206     sti     gr0,@(sp,#REG__STATUS)
0207 
0208     .globl      __entry_kernel_external_interrupt_reentry
0209 __entry_kernel_external_interrupt_reentry:
0210     LEDS        0x6211
0211 
0212     # set up the exception frame
0213     setlos      #REG__END,gr30
0214     dcpl        sp,gr30,#0
0215 
0216     sti.p       gr28,@(sp,#REG_GR(28))
0217     ori     sp,0,gr28
0218 
0219     # finish building the exception frame
0220     stdi        gr2,@(gr28,#REG_GR(2))
0221     stdi        gr4,@(gr28,#REG_GR(4))
0222     stdi        gr6,@(gr28,#REG_GR(6))
0223     stdi        gr8,@(gr28,#REG_GR(8))
0224     stdi        gr10,@(gr28,#REG_GR(10))
0225     stdi        gr12,@(gr28,#REG_GR(12))
0226     stdi        gr14,@(gr28,#REG_GR(14))
0227     stdi        gr16,@(gr28,#REG_GR(16))
0228     stdi        gr18,@(gr28,#REG_GR(18))
0229     stdi        gr20,@(gr28,#REG_GR(20))
0230     stdi        gr22,@(gr28,#REG_GR(22))
0231     stdi        gr24,@(gr28,#REG_GR(24))
0232     stdi        gr26,@(gr28,#REG_GR(26))
0233     sti     gr29,@(gr28,#REG_GR(29))
0234     stdi.p      gr30,@(gr28,#REG_GR(30))
0235 
0236     # note virtual interrupts will be fully enabled upon return
0237     subicc      gr0,#1,gr0,icc2         /* clear Z, set C */
0238 
0239     movsg       tbr ,gr20
0240     movsg       psr ,gr22
0241     movsg       pcsr,gr21
0242     movsg       isr ,gr23
0243     movsg       ccr ,gr24
0244     movsg       cccr,gr25
0245     movsg       lr  ,gr26
0246     movsg       lcr ,gr27
0247 
0248     setlos.p    #-1,gr4
0249     andi        gr22,#PSR_PS,gr5        /* try to rebuild original PSR value */
0250     andi.p      gr22,#~(PSR_PS|PSR_S),gr6
0251     slli        gr5,#1,gr5
0252     or      gr6,gr5,gr5
0253     andi.p      gr5,#~PSR_ET,gr5
0254 
0255     # set CCCR.CC3 to Undefined to abort atomic-modify completion inside the kernel
0256     # - for an explanation of how it works, see: Documentation/frv/atomic-ops.txt
0257     andi        gr25,#~0xc0,gr25
0258 
0259     sti     gr20,@(gr28,#REG_TBR)
0260     sti     gr21,@(gr28,#REG_PC)
0261     sti     gr5 ,@(gr28,#REG_PSR)
0262     sti     gr23,@(gr28,#REG_ISR)
0263     stdi        gr24,@(gr28,#REG_CCR)
0264     stdi        gr26,@(gr28,#REG_LR)
0265     sti     gr4 ,@(gr28,#REG_SYSCALLNO)
0266 
0267     movsg       iacc0h,gr4
0268     movsg       iacc0l,gr5
0269     stdi        gr4,@(gr28,#REG_IACC0)
0270 
0271     movsg       gner0,gr4
0272     movsg       gner1,gr5
0273     stdi.p      gr4,@(gr28,#REG_GNER0)
0274 
0275     # interrupts start off fully disabled in the interrupt handler
0276     subcc       gr0,gr0,gr0,icc2            /* set Z and clear C */
0277 
0278     # set the return address
0279     sethi.p     %hi(__entry_return_from_kernel_interrupt),gr4
0280     setlo       %lo(__entry_return_from_kernel_interrupt),gr4
0281     movgs       gr4,lr
0282 
0283     # clear power-saving mode flags
0284     movsg       hsr0,gr4
0285     andi        gr4,#~HSR0_PDM,gr4
0286     movgs       gr4,hsr0
0287 
0288     # raise the minimum interrupt priority to 15 (NMI only) and enable exceptions
0289     movsg       psr,gr4
0290     ori     gr4,#PSR_PIL_14,gr4
0291     movgs       gr4,psr
0292     ori     gr4,#PSR_ET,gr4
0293     movgs       gr4,psr
0294 
0295     LEDS        0x6212
0296     bra     do_IRQ
0297 
0298     .size       __entry_kernel_external_interrupt,.-__entry_kernel_external_interrupt
0299 
0300 ###############################################################################
0301 #
0302 # deal with interrupts that were actually virtually disabled
0303 # - we need to really disable them, flag the fact and return immediately
0304 # - if you change this, you must alter break.S also
0305 #
0306 ###############################################################################
0307     .balign     L1_CACHE_BYTES
0308     .globl      __entry_kernel_external_interrupt_virtually_disabled
0309     .type       __entry_kernel_external_interrupt_virtually_disabled,@function
0310 __entry_kernel_external_interrupt_virtually_disabled:
0311     movsg       psr,gr30
0312     andi        gr30,#~PSR_PIL,gr30
0313     ori     gr30,#PSR_PIL_14,gr30       ; debugging interrupts only
0314     movgs       gr30,psr
0315     subcc       gr0,gr0,gr0,icc2        ; leave Z set, clear C
0316     rett        #0
0317 
0318     .size       __entry_kernel_external_interrupt_virtually_disabled,.-__entry_kernel_external_interrupt_virtually_disabled
0319 
0320 ###############################################################################
0321 #
0322 # deal with re-enablement of interrupts that were pending when virtually re-enabled
0323 # - set ICC2.C, re-enable the real interrupts and return
0324 # - we can clear ICC2.Z because we shouldn't be here if it's not 0 [due to TIHI]
0325 # - if you change this, you must alter break.S also
0326 #
0327 ###############################################################################
0328     .balign     L1_CACHE_BYTES
0329     .globl      __entry_kernel_external_interrupt_virtual_reenable
0330     .type       __entry_kernel_external_interrupt_virtual_reenable,@function
0331 __entry_kernel_external_interrupt_virtual_reenable:
0332     movsg       psr,gr30
0333     andi        gr30,#~PSR_PIL,gr30     ; re-enable interrupts
0334     movgs       gr30,psr
0335     subicc      gr0,#1,gr0,icc2         ; clear Z, set C
0336     rett        #0
0337 
0338     .size       __entry_kernel_external_interrupt_virtual_reenable,.-__entry_kernel_external_interrupt_virtual_reenable
0339 
0340 ###############################################################################
0341 #
0342 # entry point for Software and Progam interrupts generated whilst executing userspace code
0343 #
0344 ###############################################################################
0345     .globl      __entry_uspace_softprog_interrupt
0346         .type       __entry_uspace_softprog_interrupt,@function
0347     .globl      __entry_uspace_handle_mmu_fault
0348 __entry_uspace_softprog_interrupt:
0349     LEDS        0x6000
0350 #ifdef CONFIG_MMU
0351     movsg       ear0,gr28
0352 __entry_uspace_handle_mmu_fault:
0353     movgs       gr28,scr2
0354 #endif
0355     sethi.p     %hi(__kernel_frame0_ptr),gr28
0356     setlo       %lo(__kernel_frame0_ptr),gr28
0357     ldi     @(gr28,#0),gr28
0358 
0359     # handle h/w single-step through exceptions
0360     sti     gr0,@(gr28,#REG__STATUS)
0361 
0362     .globl      __entry_uspace_softprog_interrupt_reentry
0363 __entry_uspace_softprog_interrupt_reentry:
0364     LEDS        0x6001
0365 
0366     setlos      #REG__END,gr30
0367     dcpl        gr28,gr30,#0
0368 
0369     # set up the kernel stack pointer
0370     sti.p       sp,@(gr28,#REG_SP)
0371     ori     gr28,0,sp
0372     sti     gr0,@(gr28,#REG_GR(28))
0373 
0374     stdi        gr20,@(gr28,#REG_GR(20))
0375     stdi        gr22,@(gr28,#REG_GR(22))
0376 
0377     movsg       tbr,gr20
0378     movsg       pcsr,gr21
0379     movsg       psr,gr22
0380 
0381     sethi.p     %hi(__entry_return_from_user_exception),gr23
0382     setlo       %lo(__entry_return_from_user_exception),gr23
0383 
0384     bra     __entry_common
0385 
0386     .size       __entry_uspace_softprog_interrupt,.-__entry_uspace_softprog_interrupt
0387 
0388     # single-stepping was disabled on entry to a TLB handler that then faulted
0389 #ifdef CONFIG_MMU
0390     .globl      __entry_uspace_handle_mmu_fault_sstep
0391 __entry_uspace_handle_mmu_fault_sstep:
0392     movgs       gr28,scr2
0393     sethi.p     %hi(__kernel_frame0_ptr),gr28
0394     setlo       %lo(__kernel_frame0_ptr),gr28
0395     ldi     @(gr28,#0),gr28
0396 
0397     # flag single-step re-enablement
0398     sti     gr0,@(gr28,#REG__STATUS)
0399     bra     __entry_uspace_softprog_interrupt_reentry
0400 #endif
0401 
0402 
0403 ###############################################################################
0404 #
0405 # entry point for Software and Progam interrupts generated whilst executing kernel code
0406 #
0407 ###############################################################################
0408     .globl      __entry_kernel_softprog_interrupt
0409         .type       __entry_kernel_softprog_interrupt,@function
0410 __entry_kernel_softprog_interrupt:
0411     LEDS        0x6004
0412 
0413 #ifdef CONFIG_MMU
0414     movsg       ear0,gr30
0415     movgs       gr30,scr2
0416 #endif
0417 
0418     .globl      __entry_kernel_handle_mmu_fault
0419 __entry_kernel_handle_mmu_fault:
0420     # set up the stack pointer
0421     subi        sp,#REG__END,sp
0422     sti     sp,@(sp,#REG_SP)
0423     sti     sp,@(sp,#REG_SP-4)
0424     andi        sp,#~7,sp
0425 
0426     # handle h/w single-step through exceptions
0427     sti     gr0,@(sp,#REG__STATUS)
0428 
0429     .globl      __entry_kernel_softprog_interrupt_reentry
0430 __entry_kernel_softprog_interrupt_reentry:
0431     LEDS        0x6005
0432 
0433     setlos      #REG__END,gr30
0434     dcpl        sp,gr30,#0
0435 
0436     # set up the exception frame
0437     sti.p       gr28,@(sp,#REG_GR(28))
0438     ori     sp,0,gr28
0439 
0440     stdi        gr20,@(gr28,#REG_GR(20))
0441     stdi        gr22,@(gr28,#REG_GR(22))
0442 
0443     ldi     @(sp,#REG_SP),gr22      /* reconstruct the old SP */
0444     addi        gr22,#REG__END,gr22
0445     sti     gr22,@(sp,#REG_SP)
0446 
0447     # set CCCR.CC3 to Undefined to abort atomic-modify completion inside the kernel
0448     # - for an explanation of how it works, see: Documentation/frv/atomic-ops.txt
0449     movsg       cccr,gr20
0450     andi        gr20,#~0xc0,gr20
0451     movgs       gr20,cccr
0452 
0453     movsg       tbr,gr20
0454     movsg       pcsr,gr21
0455     movsg       psr,gr22
0456 
0457     sethi.p     %hi(__entry_return_from_kernel_exception),gr23
0458     setlo       %lo(__entry_return_from_kernel_exception),gr23
0459     bra     __entry_common
0460 
0461     .size       __entry_kernel_softprog_interrupt,.-__entry_kernel_softprog_interrupt
0462 
0463     # single-stepping was disabled on entry to a TLB handler that then faulted
0464 #ifdef CONFIG_MMU
0465     .globl      __entry_kernel_handle_mmu_fault_sstep
0466 __entry_kernel_handle_mmu_fault_sstep:
0467     # set up the stack pointer
0468     subi        sp,#REG__END,sp
0469     sti     sp,@(sp,#REG_SP)
0470     sti     sp,@(sp,#REG_SP-4)
0471     andi        sp,#~7,sp
0472 
0473     # flag single-step re-enablement
0474     sethi       #REG__STATUS_STEP,gr30
0475     sti     gr30,@(sp,#REG__STATUS)
0476     bra     __entry_kernel_softprog_interrupt_reentry
0477 #endif
0478 
0479 
0480 ###############################################################################
0481 #
0482 # the rest of the kernel entry point code
0483 # - on arriving here, the following registers should be set up:
0484 #   GR1 - kernel stack pointer
0485 #   GR7 - syscall number (trap 0 only)
0486 #   GR8-13  - syscall args (trap 0 only)
0487 #   GR20    - saved TBR
0488 #   GR21    - saved PC
0489 #   GR22    - saved PSR
0490 #   GR23    - return handler address
0491 #   GR28    - exception frame on stack
0492 #   SCR2    - saved EAR0 where applicable (clobbered by ICI & ICEF insns on FR451)
0493 #   PSR - PSR.S 1, PSR.ET 0
0494 #
0495 ###############################################################################
0496     .globl      __entry_common
0497         .type       __entry_common,@function
0498 __entry_common:
0499     LEDS        0x6008
0500 
0501     # finish building the exception frame
0502     stdi        gr2,@(gr28,#REG_GR(2))
0503     stdi        gr4,@(gr28,#REG_GR(4))
0504     stdi        gr6,@(gr28,#REG_GR(6))
0505     stdi        gr8,@(gr28,#REG_GR(8))
0506     stdi        gr10,@(gr28,#REG_GR(10))
0507     stdi        gr12,@(gr28,#REG_GR(12))
0508     stdi        gr14,@(gr28,#REG_GR(14))
0509     stdi        gr16,@(gr28,#REG_GR(16))
0510     stdi        gr18,@(gr28,#REG_GR(18))
0511     stdi        gr24,@(gr28,#REG_GR(24))
0512     stdi        gr26,@(gr28,#REG_GR(26))
0513     sti     gr29,@(gr28,#REG_GR(29))
0514     stdi        gr30,@(gr28,#REG_GR(30))
0515 
0516     movsg       lcr ,gr27
0517     movsg       lr  ,gr26
0518     movgs       gr23,lr
0519     movsg       cccr,gr25
0520     movsg       ccr ,gr24
0521     movsg       isr ,gr23
0522 
0523     setlos.p    #-1,gr4
0524     andi        gr22,#PSR_PS,gr5        /* try to rebuild original PSR value */
0525     andi.p      gr22,#~(PSR_PS|PSR_S),gr6
0526     slli        gr5,#1,gr5
0527     or      gr6,gr5,gr5
0528     andi        gr5,#~PSR_ET,gr5
0529 
0530     sti     gr20,@(gr28,#REG_TBR)
0531     sti     gr21,@(gr28,#REG_PC)
0532     sti     gr5 ,@(gr28,#REG_PSR)
0533     sti     gr23,@(gr28,#REG_ISR)
0534     stdi        gr24,@(gr28,#REG_CCR)
0535     stdi        gr26,@(gr28,#REG_LR)
0536     sti     gr4 ,@(gr28,#REG_SYSCALLNO)
0537 
0538     movsg       iacc0h,gr4
0539     movsg       iacc0l,gr5
0540     stdi        gr4,@(gr28,#REG_IACC0)
0541 
0542     movsg       gner0,gr4
0543     movsg       gner1,gr5
0544     stdi.p      gr4,@(gr28,#REG_GNER0)
0545 
0546     # set up virtual interrupt disablement
0547     subicc      gr0,#1,gr0,icc2         /* clear Z flag, set C flag */
0548 
0549     # set up kernel global registers
0550     sethi.p     %hi(__kernel_current_task),gr5
0551     setlo       %lo(__kernel_current_task),gr5
0552     sethi.p     %hi(_gp),gr16
0553     setlo       %lo(_gp),gr16
0554     ldi     @(gr5,#0),gr29
0555     ldi     @(gr29,#4),gr15     ; __current_thread_info = current->thread_info
0556 
0557     # switch to the kernel trap table
0558     sethi.p     %hi(__entry_kerneltrap_table),gr6
0559     setlo       %lo(__entry_kerneltrap_table),gr6
0560     movgs       gr6,tbr
0561 
0562     # make sure we (the kernel) get div-zero and misalignment exceptions
0563     setlos      #ISR_EDE|ISR_DTT_DIVBYZERO|ISR_EMAM_EXCEPTION,gr5
0564     movgs       gr5,isr
0565 
0566     # clear power-saving mode flags
0567     movsg       hsr0,gr4
0568     andi        gr4,#~HSR0_PDM,gr4
0569     movgs       gr4,hsr0
0570 
0571     # multiplex again using old TBR as a guide
0572     setlos.p    #TBR_TT,gr3
0573     sethi       %hi(__entry_vector_table),gr6
0574     and.p       gr20,gr3,gr5
0575     setlo       %lo(__entry_vector_table),gr6
0576     srli        gr5,#2,gr5
0577     ld      @(gr5,gr6),gr5
0578 
0579     LEDS        0x6009
0580     jmpl        @(gr5,gr0)
0581 
0582 
0583     .size       __entry_common,.-__entry_common
0584 
0585 ###############################################################################
0586 #
0587 # handle instruction MMU fault
0588 #
0589 ###############################################################################
0590 #ifdef CONFIG_MMU
0591     .globl      __entry_insn_mmu_fault
0592 __entry_insn_mmu_fault:
0593     LEDS        0x6010
0594     setlos      #0,gr8
0595     movsg       esr0,gr9
0596     movsg       scr2,gr10
0597 
0598     # now that we've accessed the exception regs, we can enable exceptions
0599     movsg       psr,gr4
0600     ori     gr4,#PSR_ET,gr4
0601     movgs       gr4,psr
0602 
0603     sethi.p     %hi(do_page_fault),gr5
0604     setlo       %lo(do_page_fault),gr5
0605     jmpl        @(gr5,gr0)  ; call do_page_fault(0,esr0,ear0)
0606 #endif
0607 
0608 
0609 ###############################################################################
0610 #
0611 # handle instruction access error
0612 #
0613 ###############################################################################
0614     .globl      __entry_insn_access_error
0615 __entry_insn_access_error:
0616     LEDS        0x6011
0617     sethi.p     %hi(insn_access_error),gr5
0618     setlo       %lo(insn_access_error),gr5
0619     movsg       esfr1,gr8
0620     movsg       epcr0,gr9
0621     movsg       esr0,gr10
0622 
0623     # now that we've accessed the exception regs, we can enable exceptions
0624     movsg       psr,gr4
0625     ori     gr4,#PSR_ET,gr4
0626     movgs       gr4,psr
0627     jmpl        @(gr5,gr0)  ; call insn_access_error(esfr1,epcr0,esr0)
0628 
0629 ###############################################################################
0630 #
0631 # handle various instructions of dubious legality
0632 #
0633 ###############################################################################
0634     .globl      __entry_unsupported_trap
0635     .globl      __entry_illegal_instruction
0636     .globl      __entry_privileged_instruction
0637     .globl      __entry_debug_exception
0638 __entry_unsupported_trap:
0639     subi        gr21,#4,gr21
0640     sti     gr21,@(gr28,#REG_PC)
0641 __entry_illegal_instruction:
0642 __entry_privileged_instruction:
0643 __entry_debug_exception:
0644     LEDS        0x6012
0645     sethi.p     %hi(illegal_instruction),gr5
0646     setlo       %lo(illegal_instruction),gr5
0647     movsg       esfr1,gr8
0648     movsg       epcr0,gr9
0649     movsg       esr0,gr10
0650 
0651     # now that we've accessed the exception regs, we can enable exceptions
0652     movsg       psr,gr4
0653     ori     gr4,#PSR_ET,gr4
0654     movgs       gr4,psr
0655     jmpl        @(gr5,gr0)  ; call ill_insn(esfr1,epcr0,esr0)
0656 
0657 ###############################################################################
0658 #
0659 # handle atomic operation emulation for userspace
0660 #
0661 ###############################################################################
0662     .globl      __entry_atomic_op
0663 __entry_atomic_op:
0664     LEDS        0x6012
0665     sethi.p     %hi(atomic_operation),gr5
0666     setlo       %lo(atomic_operation),gr5
0667     movsg       esfr1,gr8
0668     movsg       epcr0,gr9
0669     movsg       esr0,gr10
0670 
0671     # now that we've accessed the exception regs, we can enable exceptions
0672     movsg       psr,gr4
0673     ori     gr4,#PSR_ET,gr4
0674     movgs       gr4,psr
0675     jmpl        @(gr5,gr0)  ; call atomic_operation(esfr1,epcr0,esr0)
0676 
0677 ###############################################################################
0678 #
0679 # handle media exception
0680 #
0681 ###############################################################################
0682     .globl      __entry_media_exception
0683 __entry_media_exception:
0684     LEDS        0x6013
0685     sethi.p     %hi(media_exception),gr5
0686     setlo       %lo(media_exception),gr5
0687     movsg       msr0,gr8
0688     movsg       msr1,gr9
0689 
0690     # now that we've accessed the exception regs, we can enable exceptions
0691     movsg       psr,gr4
0692     ori     gr4,#PSR_ET,gr4
0693     movgs       gr4,psr
0694     jmpl        @(gr5,gr0)  ; call media_excep(msr0,msr1)
0695 
0696 ###############################################################################
0697 #
0698 # handle data MMU fault
0699 # handle data DAT fault (write-protect exception)
0700 #
0701 ###############################################################################
0702 #ifdef CONFIG_MMU
0703     .globl      __entry_data_mmu_fault
0704 __entry_data_mmu_fault:
0705     .globl      __entry_data_dat_fault
0706 __entry_data_dat_fault:
0707     LEDS        0x6014
0708     setlos      #1,gr8
0709     movsg       esr0,gr9
0710     movsg       scr2,gr10   ; saved EAR0
0711 
0712     # now that we've accessed the exception regs, we can enable exceptions
0713     movsg       psr,gr4
0714     ori     gr4,#PSR_ET,gr4
0715     movgs       gr4,psr
0716 
0717     sethi.p     %hi(do_page_fault),gr5
0718     setlo       %lo(do_page_fault),gr5
0719     jmpl        @(gr5,gr0)  ; call do_page_fault(1,esr0,ear0)
0720 #endif
0721 
0722 ###############################################################################
0723 #
0724 # handle data and instruction access exceptions
0725 #
0726 ###############################################################################
0727     .globl      __entry_insn_access_exception
0728     .globl      __entry_data_access_exception
0729 __entry_insn_access_exception:
0730 __entry_data_access_exception:
0731     LEDS        0x6016
0732     sethi.p     %hi(memory_access_exception),gr5
0733     setlo       %lo(memory_access_exception),gr5
0734     movsg       esr0,gr8
0735     movsg       scr2,gr9    ; saved EAR0
0736     movsg       epcr0,gr10
0737 
0738     # now that we've accessed the exception regs, we can enable exceptions
0739     movsg       psr,gr4
0740     ori     gr4,#PSR_ET,gr4
0741     movgs       gr4,psr
0742     jmpl        @(gr5,gr0)  ; call memory_access_error(esr0,ear0,epcr0)
0743 
0744 ###############################################################################
0745 #
0746 # handle data access error
0747 #
0748 ###############################################################################
0749     .globl      __entry_data_access_error
0750 __entry_data_access_error:
0751     LEDS        0x6016
0752     sethi.p     %hi(data_access_error),gr5
0753     setlo       %lo(data_access_error),gr5
0754     movsg       esfr1,gr8
0755     movsg       esr15,gr9
0756     movsg       ear15,gr10
0757 
0758     # now that we've accessed the exception regs, we can enable exceptions
0759     movsg       psr,gr4
0760     ori     gr4,#PSR_ET,gr4
0761     movgs       gr4,psr
0762     jmpl        @(gr5,gr0)  ; call data_access_error(esfr1,esr15,ear15)
0763 
0764 ###############################################################################
0765 #
0766 # handle data store error
0767 #
0768 ###############################################################################
0769     .globl      __entry_data_store_error
0770 __entry_data_store_error:
0771     LEDS        0x6017
0772     sethi.p     %hi(data_store_error),gr5
0773     setlo       %lo(data_store_error),gr5
0774     movsg       esfr1,gr8
0775     movsg       esr14,gr9
0776 
0777     # now that we've accessed the exception regs, we can enable exceptions
0778     movsg       psr,gr4
0779     ori     gr4,#PSR_ET,gr4
0780     movgs       gr4,psr
0781     jmpl        @(gr5,gr0)  ; call data_store_error(esfr1,esr14)
0782 
0783 ###############################################################################
0784 #
0785 # handle division exception
0786 #
0787 ###############################################################################
0788     .globl      __entry_division_exception
0789 __entry_division_exception:
0790     LEDS        0x6018
0791     sethi.p     %hi(division_exception),gr5
0792     setlo       %lo(division_exception),gr5
0793     movsg       esfr1,gr8
0794     movsg       esr0,gr9
0795     movsg       isr,gr10
0796 
0797     # now that we've accessed the exception regs, we can enable exceptions
0798     movsg       psr,gr4
0799     ori     gr4,#PSR_ET,gr4
0800     movgs       gr4,psr
0801     jmpl        @(gr5,gr0)  ; call div_excep(esfr1,esr0,isr)
0802 
0803 ###############################################################################
0804 #
0805 # handle compound exception
0806 #
0807 ###############################################################################
0808     .globl      __entry_compound_exception
0809 __entry_compound_exception:
0810     LEDS        0x6019
0811     sethi.p     %hi(compound_exception),gr5
0812     setlo       %lo(compound_exception),gr5
0813     movsg       esfr1,gr8
0814     movsg       esr0,gr9
0815     movsg       esr14,gr10
0816     movsg       esr15,gr11
0817     movsg       msr0,gr12
0818     movsg       msr1,gr13
0819 
0820     # now that we've accessed the exception regs, we can enable exceptions
0821     movsg       psr,gr4
0822     ori     gr4,#PSR_ET,gr4
0823     movgs       gr4,psr
0824     jmpl        @(gr5,gr0)  ; call comp_excep(esfr1,esr0,esr14,esr15,msr0,msr1)
0825 
0826 ###############################################################################
0827 #
0828 # handle interrupts and NMIs
0829 #
0830 ###############################################################################
0831     .globl      __entry_do_IRQ
0832 __entry_do_IRQ:
0833     LEDS        0x6020
0834 
0835     # we can enable exceptions
0836     movsg       psr,gr4
0837     ori     gr4,#PSR_ET,gr4
0838     movgs       gr4,psr
0839     bra     do_IRQ
0840 
0841     .globl      __entry_do_NMI
0842 __entry_do_NMI:
0843     LEDS        0x6021
0844 
0845     # we can enable exceptions
0846     movsg       psr,gr4
0847     ori     gr4,#PSR_ET,gr4
0848     movgs       gr4,psr
0849     bra     do_NMI
0850 
0851 ###############################################################################
0852 #
0853 # the return path for a newly forked child process
0854 # - __switch_to() saved the old current pointer in GR8 for us
0855 #
0856 ###############################################################################
0857     .globl      ret_from_fork
0858 ret_from_fork:
0859     LEDS        0x6100
0860     call        schedule_tail
0861 
0862     # fork & co. return 0 to child
0863     setlos.p    #0,gr8
0864     bra     __syscall_exit
0865 
0866     .globl      ret_from_kernel_thread
0867 ret_from_kernel_thread:
0868     lddi.p      @(gr28,#REG_GR(8)),gr20
0869     call        schedule_tail
0870     calll.p     @(gr21,gr0)
0871     or      gr20,gr20,gr8
0872     bra     __syscall_exit
0873 
0874 ###################################################################################################
0875 #
0876 # Return to user mode is not as complex as all this looks,
0877 # but we want the default path for a system call return to
0878 # go as quickly as possible which is why some of this is
0879 # less clear than it otherwise should be.
0880 #
0881 ###################################################################################################
0882     .balign     L1_CACHE_BYTES
0883     .globl      system_call
0884 system_call:
0885     LEDS        0x6101
0886     movsg       psr,gr4         ; enable exceptions
0887     ori     gr4,#PSR_ET,gr4
0888     movgs       gr4,psr
0889 
0890     sti     gr7,@(gr28,#REG_SYSCALLNO)
0891     sti.p       gr8,@(gr28,#REG_ORIG_GR8)
0892 
0893     subicc      gr7,#nr_syscalls,gr0,icc0
0894     bnc     icc0,#0,__syscall_badsys
0895 
0896     ldi     @(gr15,#TI_FLAGS),gr4
0897     andicc      gr4,#_TIF_SYSCALL_TRACE,gr0,icc0
0898     bne     icc0,#0,__syscall_trace_entry
0899 
0900 __syscall_call:
0901     slli.p      gr7,#2,gr7
0902     sethi       %hi(sys_call_table),gr5
0903     setlo       %lo(sys_call_table),gr5
0904     ld      @(gr5,gr7),gr4
0905     calll       @(gr4,gr0)
0906 
0907 
0908 ###############################################################################
0909 #
0910 # return to interrupted process
0911 #
0912 ###############################################################################
0913 __syscall_exit:
0914     LEDS        0x6300
0915 
0916     # keep current PSR in GR23
0917     movsg       psr,gr23
0918 
0919     ldi     @(gr28,#REG_PSR),gr22
0920 
0921     sti.p       gr8,@(gr28,#REG_GR(8))  ; save return value
0922 
0923     # rebuild saved psr - execve will change it for init/main.c
0924     srli        gr22,#1,gr5
0925     andi.p      gr22,#~PSR_PS,gr22
0926     andi        gr5,#PSR_PS,gr5
0927     or      gr5,gr22,gr22
0928     ori.p       gr22,#PSR_S,gr22
0929 
0930     # make sure we don't miss an interrupt setting need_resched or sigpending between
0931     # sampling and the RETT
0932     ori     gr23,#PSR_PIL_14,gr23
0933     movgs       gr23,psr
0934 
0935     ldi     @(gr15,#TI_FLAGS),gr4
0936     andicc      gr4,#_TIF_ALLWORK_MASK,gr0,icc0
0937     bne     icc0,#0,__syscall_exit_work
0938 
0939     # restore all registers and return
0940 __entry_return_direct:
0941     LEDS        0x6301
0942 
0943     andi        gr22,#~PSR_ET,gr22
0944     movgs       gr22,psr
0945 
0946     ldi     @(gr28,#REG_ISR),gr23
0947     lddi        @(gr28,#REG_CCR),gr24
0948     lddi        @(gr28,#REG_LR) ,gr26
0949     ldi     @(gr28,#REG_PC) ,gr21
0950     ldi     @(gr28,#REG_TBR),gr20
0951 
0952     movgs       gr20,tbr
0953     movgs       gr21,pcsr
0954     movgs       gr23,isr
0955     movgs       gr24,ccr
0956     movgs       gr25,cccr
0957     movgs       gr26,lr
0958     movgs       gr27,lcr
0959 
0960     lddi        @(gr28,#REG_GNER0),gr4
0961     movgs       gr4,gner0
0962     movgs       gr5,gner1
0963 
0964     lddi        @(gr28,#REG_IACC0),gr4
0965     movgs       gr4,iacc0h
0966     movgs       gr5,iacc0l
0967 
0968     lddi        @(gr28,#REG_GR(4)) ,gr4
0969     lddi        @(gr28,#REG_GR(6)) ,gr6
0970     lddi        @(gr28,#REG_GR(8)) ,gr8
0971     lddi        @(gr28,#REG_GR(10)),gr10
0972     lddi        @(gr28,#REG_GR(12)),gr12
0973     lddi        @(gr28,#REG_GR(14)),gr14
0974     lddi        @(gr28,#REG_GR(16)),gr16
0975     lddi        @(gr28,#REG_GR(18)),gr18
0976     lddi        @(gr28,#REG_GR(20)),gr20
0977     lddi        @(gr28,#REG_GR(22)),gr22
0978     lddi        @(gr28,#REG_GR(24)),gr24
0979     lddi        @(gr28,#REG_GR(26)),gr26
0980     ldi     @(gr28,#REG_GR(29)),gr29
0981     lddi        @(gr28,#REG_GR(30)),gr30
0982 
0983     # check to see if a debugging return is required
0984     LEDS        0x67f0
0985     movsg       ccr,gr2
0986     ldi     @(gr28,#REG__STATUS),gr3
0987     andicc      gr3,#REG__STATUS_STEP,gr0,icc0
0988     bne     icc0,#0,__entry_return_singlestep
0989     movgs       gr2,ccr
0990 
0991     ldi     @(gr28,#REG_SP)    ,sp
0992     lddi        @(gr28,#REG_GR(2)) ,gr2
0993     ldi     @(gr28,#REG_GR(28)),gr28
0994 
0995     LEDS        0x67fe
0996 //  movsg       pcsr,gr31
0997 //  LEDS32
0998 
0999 #if 0
1000     # store the current frame in the workram on the FR451
1001     movgs       gr28,scr2
1002     sethi.p     %hi(0xfe800000),gr28
1003     setlo       %lo(0xfe800000),gr28
1004 
1005     stdi        gr2,@(gr28,#REG_GR(2))
1006     stdi        gr4,@(gr28,#REG_GR(4))
1007     stdi        gr6,@(gr28,#REG_GR(6))
1008     stdi        gr8,@(gr28,#REG_GR(8))
1009     stdi        gr10,@(gr28,#REG_GR(10))
1010     stdi        gr12,@(gr28,#REG_GR(12))
1011     stdi        gr14,@(gr28,#REG_GR(14))
1012     stdi        gr16,@(gr28,#REG_GR(16))
1013     stdi        gr18,@(gr28,#REG_GR(18))
1014     stdi        gr24,@(gr28,#REG_GR(24))
1015     stdi        gr26,@(gr28,#REG_GR(26))
1016     sti     gr29,@(gr28,#REG_GR(29))
1017     stdi        gr30,@(gr28,#REG_GR(30))
1018 
1019     movsg       tbr ,gr30
1020     sti     gr30,@(gr28,#REG_TBR)
1021     movsg       pcsr,gr30
1022     sti     gr30,@(gr28,#REG_PC)
1023     movsg       psr ,gr30
1024     sti     gr30,@(gr28,#REG_PSR)
1025     movsg       isr ,gr30
1026     sti     gr30,@(gr28,#REG_ISR)
1027     movsg       ccr ,gr30
1028     movsg       cccr,gr31
1029     stdi        gr30,@(gr28,#REG_CCR)
1030     movsg       lr  ,gr30
1031     movsg       lcr ,gr31
1032     stdi        gr30,@(gr28,#REG_LR)
1033     sti     gr0 ,@(gr28,#REG_SYSCALLNO)
1034     movsg       scr2,gr28
1035 #endif
1036 
1037     rett        #0
1038 
1039     # return via break.S
1040 __entry_return_singlestep:
1041     movgs       gr2,ccr
1042     lddi        @(gr28,#REG_GR(2)) ,gr2
1043     ldi     @(gr28,#REG_SP)    ,sp
1044     ldi     @(gr28,#REG_GR(28)),gr28
1045     LEDS        0x67ff
1046     break
1047     .globl      __entry_return_singlestep_breaks_here
1048 __entry_return_singlestep_breaks_here:
1049     nop
1050 
1051 
1052 ###############################################################################
1053 #
1054 # return to a process interrupted in kernel space
1055 # - we need to consider preemption if that is enabled
1056 #
1057 ###############################################################################
1058     .balign     L1_CACHE_BYTES
1059 __entry_return_from_kernel_exception:
1060     LEDS        0x6302
1061     movsg       psr,gr23
1062     ori     gr23,#PSR_PIL_14,gr23
1063     movgs       gr23,psr
1064     bra     __entry_return_direct
1065 
1066     .balign     L1_CACHE_BYTES
1067 __entry_return_from_kernel_interrupt:
1068     LEDS        0x6303
1069     movsg       psr,gr23
1070     ori     gr23,#PSR_PIL_14,gr23
1071     movgs       gr23,psr
1072 
1073 #ifdef CONFIG_PREEMPT
1074     ldi     @(gr15,#TI_PRE_COUNT),gr5
1075     subicc      gr5,#0,gr0,icc0
1076     beq     icc0,#0,__entry_return_direct
1077 
1078     subcc       gr0,gr0,gr0,icc2        /* set Z and clear C */
1079     call        preempt_schedule_irq
1080 #endif
1081     bra     __entry_return_direct
1082 
1083 
1084 ###############################################################################
1085 #
1086 # perform work that needs to be done immediately before resumption
1087 #
1088 ###############################################################################
1089     .globl      __entry_return_from_user_exception
1090     .balign     L1_CACHE_BYTES
1091 __entry_return_from_user_exception:
1092     LEDS        0x6501
1093 
1094 __entry_resume_userspace:
1095     # make sure we don't miss an interrupt setting need_resched or sigpending between
1096     # sampling and the RETT
1097     movsg       psr,gr23
1098     ori     gr23,#PSR_PIL_14,gr23
1099     movgs       gr23,psr
1100 
1101 __entry_return_from_user_interrupt:
1102     LEDS        0x6402
1103     ldi     @(gr15,#TI_FLAGS),gr4
1104     andicc      gr4,#_TIF_WORK_MASK,gr0,icc0
1105     beq     icc0,#1,__entry_return_direct
1106 
1107 __entry_work_pending:
1108     LEDS        0x6404
1109     andicc      gr4,#_TIF_NEED_RESCHED,gr0,icc0
1110     beq     icc0,#1,__entry_work_notifysig
1111 
1112 __entry_work_resched:
1113     LEDS        0x6408
1114     movsg       psr,gr23
1115     andi        gr23,#~PSR_PIL,gr23
1116     movgs       gr23,psr
1117     call        schedule
1118     movsg       psr,gr23
1119     ori     gr23,#PSR_PIL_14,gr23
1120     movgs       gr23,psr
1121 
1122     LEDS        0x6401
1123     ldi     @(gr15,#TI_FLAGS),gr4
1124     andicc      gr4,#_TIF_WORK_MASK,gr0,icc0
1125     beq     icc0,#1,__entry_return_direct
1126     andicc      gr4,#_TIF_NEED_RESCHED,gr0,icc0
1127     bne     icc0,#1,__entry_work_resched
1128 
1129 __entry_work_notifysig:
1130     LEDS        0x6410
1131     ori.p       gr4,#0,gr8
1132     call        do_notify_resume
1133     bra     __entry_resume_userspace
1134 
1135     # perform syscall entry tracing
1136 __syscall_trace_entry:
1137     LEDS        0x6320
1138     call        syscall_trace_entry
1139 
1140     lddi.p      @(gr28,#REG_GR(8)) ,gr8
1141     ori     gr8,#0,gr7      ; syscall_trace_entry() returned new syscallno
1142     lddi        @(gr28,#REG_GR(10)),gr10
1143     lddi.p      @(gr28,#REG_GR(12)),gr12
1144 
1145     subicc      gr7,#nr_syscalls,gr0,icc0
1146     bnc     icc0,#0,__syscall_badsys
1147     bra     __syscall_call
1148 
1149     # perform syscall exit tracing
1150 __syscall_exit_work:
1151     LEDS        0x6340
1152     andicc      gr22,#PSR_PS,gr0,icc1   ; don't handle on return to kernel mode
1153     andicc.p    gr4,#_TIF_SYSCALL_TRACE,gr0,icc0
1154     bne     icc1,#0,__entry_return_direct
1155     beq     icc0,#1,__entry_work_pending
1156 
1157     movsg       psr,gr23
1158     andi        gr23,#~PSR_PIL,gr23 ; could let syscall_trace_exit() call schedule()
1159     movgs       gr23,psr
1160 
1161     call        syscall_trace_exit
1162     bra     __entry_resume_userspace
1163 
1164 __syscall_badsys:
1165     LEDS        0x6380
1166     setlos      #-ENOSYS,gr8
1167     sti     gr8,@(gr28,#REG_GR(8))  ; save return value
1168     bra     __entry_resume_userspace
1169 
1170 
1171 ###############################################################################
1172 #
1173 # syscall vector table
1174 #
1175 ###############################################################################
1176     .section .rodata
1177 ALIGN
1178     .globl      sys_call_table
1179 sys_call_table:
1180     .long sys_restart_syscall   /* 0 - old "setup()" system call, used for restarting */
1181     .long sys_exit
1182     .long sys_fork
1183     .long sys_read
1184     .long sys_write
1185     .long sys_open      /* 5 */
1186     .long sys_close
1187     .long sys_waitpid
1188     .long sys_creat
1189     .long sys_link
1190     .long sys_unlink        /* 10 */
1191     .long sys_execve
1192     .long sys_chdir
1193     .long sys_time
1194     .long sys_mknod
1195     .long sys_chmod     /* 15 */
1196     .long sys_lchown16
1197     .long sys_ni_syscall            /* old break syscall holder */
1198     .long sys_stat
1199     .long sys_lseek
1200     .long sys_getpid        /* 20 */
1201     .long sys_mount
1202     .long sys_oldumount
1203     .long sys_setuid16
1204     .long sys_getuid16
1205     .long sys_ni_syscall // sys_stime       /* 25 */
1206     .long sys_ptrace
1207     .long sys_alarm
1208     .long sys_fstat
1209     .long sys_pause
1210     .long sys_utime     /* 30 */
1211     .long sys_ni_syscall            /* old stty syscall holder */
1212     .long sys_ni_syscall            /* old gtty syscall holder */
1213     .long sys_access
1214     .long sys_nice
1215     .long sys_ni_syscall    /* 35 */    /* old ftime syscall holder */
1216     .long sys_sync
1217     .long sys_kill
1218     .long sys_rename
1219     .long sys_mkdir
1220     .long sys_rmdir     /* 40 */
1221     .long sys_dup
1222     .long sys_pipe
1223     .long sys_times
1224     .long sys_ni_syscall            /* old prof syscall holder */
1225     .long sys_brk       /* 45 */
1226     .long sys_setgid16
1227     .long sys_getgid16
1228     .long sys_ni_syscall // sys_signal
1229     .long sys_geteuid16
1230     .long sys_getegid16 /* 50 */
1231     .long sys_acct
1232     .long sys_umount                /* recycled never used phys( */
1233     .long sys_ni_syscall            /* old lock syscall holder */
1234     .long sys_ioctl
1235     .long sys_fcntl     /* 55 */
1236     .long sys_ni_syscall            /* old mpx syscall holder */
1237     .long sys_setpgid
1238     .long sys_ni_syscall            /* old ulimit syscall holder */
1239     .long sys_ni_syscall            /* old old uname syscall */
1240     .long sys_umask     /* 60 */
1241     .long sys_chroot
1242     .long sys_ustat
1243     .long sys_dup2
1244     .long sys_getppid
1245     .long sys_getpgrp   /* 65 */
1246     .long sys_setsid
1247     .long sys_sigaction
1248     .long sys_ni_syscall // sys_sgetmask
1249     .long sys_ni_syscall // sys_ssetmask
1250     .long sys_setreuid16    /* 70 */
1251     .long sys_setregid16
1252     .long sys_sigsuspend
1253     .long sys_ni_syscall // sys_sigpending
1254     .long sys_sethostname
1255     .long sys_setrlimit /* 75 */
1256     .long sys_ni_syscall // sys_old_getrlimit
1257     .long sys_getrusage
1258     .long sys_gettimeofday
1259     .long sys_settimeofday
1260     .long sys_getgroups16   /* 80 */
1261     .long sys_setgroups16
1262     .long sys_ni_syscall            /* old_select slot */
1263     .long sys_symlink
1264     .long sys_lstat
1265     .long sys_readlink      /* 85 */
1266     .long sys_uselib
1267     .long sys_swapon
1268     .long sys_reboot
1269     .long sys_ni_syscall // old_readdir
1270     .long sys_ni_syscall    /* 90 */    /* old_mmap slot */
1271     .long sys_munmap
1272     .long sys_truncate
1273     .long sys_ftruncate
1274     .long sys_fchmod
1275     .long sys_fchown16      /* 95 */
1276     .long sys_getpriority
1277     .long sys_setpriority
1278     .long sys_ni_syscall            /* old profil syscall holder */
1279     .long sys_statfs
1280     .long sys_fstatfs       /* 100 */
1281     .long sys_ni_syscall            /* ioperm for i386 */
1282     .long sys_socketcall
1283     .long sys_syslog
1284     .long sys_setitimer
1285     .long sys_getitimer /* 105 */
1286     .long sys_newstat
1287     .long sys_newlstat
1288     .long sys_newfstat
1289     .long sys_ni_syscall    /* obsolete olduname( syscall */
1290     .long sys_ni_syscall    /* iopl for i386 */ /* 110 */
1291     .long sys_vhangup
1292     .long sys_ni_syscall    /* obsolete idle( syscall */
1293     .long sys_ni_syscall    /* vm86old for i386 */
1294     .long sys_wait4
1295     .long sys_swapoff       /* 115 */
1296     .long sys_sysinfo
1297     .long sys_ipc
1298     .long sys_fsync
1299     .long sys_sigreturn
1300     .long sys_clone     /* 120 */
1301     .long sys_setdomainname
1302     .long sys_newuname
1303     .long sys_ni_syscall    /* old "cacheflush" */
1304     .long sys_adjtimex
1305     .long sys_mprotect  /* 125 */
1306     .long sys_sigprocmask
1307     .long sys_ni_syscall    /* old "create_module" */
1308     .long sys_init_module
1309     .long sys_delete_module
1310     .long sys_ni_syscall    /* old "get_kernel_syms" */
1311     .long sys_quotactl
1312     .long sys_getpgid
1313     .long sys_fchdir
1314     .long sys_bdflush
1315     .long sys_sysfs     /* 135 */
1316     .long sys_personality
1317     .long sys_ni_syscall    /* for afs_syscall */
1318     .long sys_setfsuid16
1319     .long sys_setfsgid16
1320     .long sys_llseek        /* 140 */
1321     .long sys_getdents
1322     .long sys_select
1323     .long sys_flock
1324     .long sys_msync
1325     .long sys_readv     /* 145 */
1326     .long sys_writev
1327     .long sys_getsid
1328     .long sys_fdatasync
1329     .long sys_sysctl
1330     .long sys_mlock     /* 150 */
1331     .long sys_munlock
1332     .long sys_mlockall
1333     .long sys_munlockall
1334     .long sys_sched_setparam
1335     .long sys_sched_getparam   /* 155 */
1336     .long sys_sched_setscheduler
1337     .long sys_sched_getscheduler
1338     .long sys_sched_yield
1339     .long sys_sched_get_priority_max
1340     .long sys_sched_get_priority_min  /* 160 */
1341     .long sys_sched_rr_get_interval
1342     .long sys_nanosleep
1343     .long sys_mremap
1344     .long sys_setresuid16
1345     .long sys_getresuid16   /* 165 */
1346     .long sys_ni_syscall    /* for vm86 */
1347     .long sys_ni_syscall    /* Old sys_query_module */
1348     .long sys_poll
1349     .long sys_ni_syscall    /* Old nfsservctl */
1350     .long sys_setresgid16   /* 170 */
1351     .long sys_getresgid16
1352     .long sys_prctl
1353     .long sys_rt_sigreturn
1354     .long sys_rt_sigaction
1355     .long sys_rt_sigprocmask    /* 175 */
1356     .long sys_rt_sigpending
1357     .long sys_rt_sigtimedwait
1358     .long sys_rt_sigqueueinfo
1359     .long sys_rt_sigsuspend
1360     .long sys_pread64       /* 180 */
1361     .long sys_pwrite64
1362     .long sys_chown16
1363     .long sys_getcwd
1364     .long sys_capget
1365     .long sys_capset           /* 185 */
1366     .long sys_sigaltstack
1367     .long sys_sendfile
1368     .long sys_ni_syscall        /* streams1 */
1369     .long sys_ni_syscall        /* streams2 */
1370     .long sys_vfork            /* 190 */
1371     .long sys_getrlimit
1372     .long sys_mmap2
1373     .long sys_truncate64
1374     .long sys_ftruncate64
1375     .long sys_stat64        /* 195 */
1376     .long sys_lstat64
1377     .long sys_fstat64
1378     .long sys_lchown
1379     .long sys_getuid
1380     .long sys_getgid        /* 200 */
1381     .long sys_geteuid
1382     .long sys_getegid
1383     .long sys_setreuid
1384     .long sys_setregid
1385     .long sys_getgroups /* 205 */
1386     .long sys_setgroups
1387     .long sys_fchown
1388     .long sys_setresuid
1389     .long sys_getresuid
1390     .long sys_setresgid /* 210 */
1391     .long sys_getresgid
1392     .long sys_chown
1393     .long sys_setuid
1394     .long sys_setgid
1395     .long sys_setfsuid      /* 215 */
1396     .long sys_setfsgid
1397     .long sys_pivot_root
1398     .long sys_mincore
1399     .long sys_madvise
1400     .long sys_getdents64    /* 220 */
1401     .long sys_fcntl64
1402     .long sys_ni_syscall    /* reserved for TUX */
1403     .long sys_ni_syscall    /* Reserved for Security */
1404     .long sys_gettid
1405     .long sys_readahead /* 225 */
1406     .long sys_setxattr
1407     .long sys_lsetxattr
1408     .long sys_fsetxattr
1409     .long sys_getxattr
1410     .long sys_lgetxattr /* 230 */
1411     .long sys_fgetxattr
1412     .long sys_listxattr
1413     .long sys_llistxattr
1414     .long sys_flistxattr
1415     .long sys_removexattr   /* 235 */
1416     .long sys_lremovexattr
1417     .long sys_fremovexattr
1418     .long sys_tkill
1419     .long sys_sendfile64
1420     .long sys_futex     /* 240 */
1421     .long sys_sched_setaffinity
1422     .long sys_sched_getaffinity
1423     .long sys_ni_syscall    //sys_set_thread_area
1424     .long sys_ni_syscall    //sys_get_thread_area
1425     .long sys_io_setup  /* 245 */
1426     .long sys_io_destroy
1427     .long sys_io_getevents
1428     .long sys_io_submit
1429     .long sys_io_cancel
1430     .long sys_fadvise64 /* 250 */
1431     .long sys_ni_syscall
1432     .long sys_exit_group
1433     .long sys_lookup_dcookie
1434     .long sys_epoll_create
1435     .long sys_epoll_ctl /* 255 */
1436     .long sys_epoll_wait
1437     .long sys_remap_file_pages
1438     .long sys_set_tid_address
1439     .long sys_timer_create
1440     .long sys_timer_settime     /* 260 */
1441     .long sys_timer_gettime
1442     .long sys_timer_getoverrun
1443     .long sys_timer_delete
1444     .long sys_clock_settime
1445     .long sys_clock_gettime     /* 265 */
1446     .long sys_clock_getres
1447     .long sys_clock_nanosleep
1448     .long sys_statfs64
1449     .long sys_fstatfs64
1450     .long sys_tgkill    /* 270 */
1451     .long sys_utimes
1452     .long sys_fadvise64_64
1453     .long sys_ni_syscall    /* sys_vserver */
1454     .long sys_mbind
1455     .long sys_get_mempolicy
1456     .long sys_set_mempolicy
1457     .long sys_mq_open
1458     .long sys_mq_unlink
1459     .long sys_mq_timedsend
1460     .long sys_mq_timedreceive   /* 280 */
1461     .long sys_mq_notify
1462     .long sys_mq_getsetattr
1463     .long sys_ni_syscall        /* reserved for kexec */
1464     .long sys_waitid
1465     .long sys_ni_syscall        /* 285 */ /* available */
1466     .long sys_add_key
1467     .long sys_request_key
1468     .long sys_keyctl
1469     .long sys_ioprio_set
1470     .long sys_ioprio_get        /* 290 */
1471     .long sys_inotify_init
1472     .long sys_inotify_add_watch
1473     .long sys_inotify_rm_watch
1474     .long sys_migrate_pages
1475     .long sys_openat        /* 295 */
1476     .long sys_mkdirat
1477     .long sys_mknodat
1478     .long sys_fchownat
1479     .long sys_futimesat
1480     .long sys_fstatat64     /* 300 */
1481     .long sys_unlinkat
1482     .long sys_renameat
1483     .long sys_linkat
1484     .long sys_symlinkat
1485     .long sys_readlinkat        /* 305 */
1486     .long sys_fchmodat
1487     .long sys_faccessat
1488     .long sys_pselect6
1489     .long sys_ppoll
1490     .long sys_unshare       /* 310 */
1491     .long sys_set_robust_list
1492     .long sys_get_robust_list
1493     .long sys_splice
1494     .long sys_sync_file_range
1495     .long sys_tee           /* 315 */
1496     .long sys_vmsplice
1497     .long sys_move_pages
1498     .long sys_getcpu
1499     .long sys_epoll_pwait
1500     .long sys_utimensat     /* 320 */
1501     .long sys_signalfd
1502     .long sys_timerfd_create
1503     .long sys_eventfd
1504     .long sys_fallocate
1505     .long sys_timerfd_settime   /* 325 */
1506     .long sys_timerfd_gettime
1507     .long sys_signalfd4
1508     .long sys_eventfd2
1509     .long sys_epoll_create1
1510     .long sys_dup3          /* 330 */
1511     .long sys_pipe2
1512     .long sys_inotify_init1
1513     .long sys_preadv
1514     .long sys_pwritev
1515     .long sys_rt_tgsigqueueinfo /* 335 */
1516     .long sys_perf_event_open
1517     .long sys_setns
1518 
1519 syscall_table_size = (. - sys_call_table)