Remove obsolete #include <linux/config.h>
[linux-2.6] / arch / frv / kernel / entry.S
1 /* entry.S: FR-V entry
2  *
3  * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  *
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.
10  *
11  *
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
18  *
19  * We deal with this by declaring that we shall kill GR28 on entering the
20  * kernel from userspace
21  *
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
25  *
26  * GR29 _is_ saved, and holds the current task pointer globally
27  *
28  */
29
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>
39
40 #define nr_syscalls ((syscall_table_size)/4)
41
42         .text
43         .balign         4
44
45 .macro LEDS val
46 #       sethi.p         %hi(0xe1200004),gr30
47 #       setlo           %lo(0xe1200004),gr30
48 #       setlos          #~\val,gr31
49 #       st              gr31,@(gr30,gr0)
50 #       sethi.p         %hi(0xffc00100),gr30
51 #       setlo           %lo(0xffc00100),gr30
52 #       sth             gr0,@(gr30,gr0)
53 #       membar
54 .endm
55
56 .macro LEDS32
57 #       not             gr31,gr31
58 #       sethi.p         %hi(0xe1200004),gr30
59 #       setlo           %lo(0xe1200004),gr30
60 #       st.p            gr31,@(gr30,gr0)
61 #       srli            gr31,#16,gr31
62 #       sethi.p         %hi(0xffc00100),gr30
63 #       setlo           %lo(0xffc00100),gr30
64 #       sth             gr31,@(gr30,gr0)
65 #       membar
66 .endm
67
68 ###############################################################################
69 #
70 # entry point for External interrupts received whilst executing userspace code
71 #
72 ###############################################################################
73         .globl          __entry_uspace_external_interrupt
74         .type           __entry_uspace_external_interrupt,@function
75 __entry_uspace_external_interrupt:
76         LEDS            0x6200
77         sethi.p         %hi(__kernel_frame0_ptr),gr28
78         setlo           %lo(__kernel_frame0_ptr),gr28
79         ldi             @(gr28,#0),gr28
80
81         # handle h/w single-step through exceptions
82         sti             gr0,@(gr28,#REG__STATUS)
83
84         .globl          __entry_uspace_external_interrupt_reentry
85 __entry_uspace_external_interrupt_reentry:
86         LEDS            0x6201
87
88         setlos          #REG__END,gr30
89         dcpl            gr28,gr30,#0
90
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))
109
110         # set up the kernel stack pointer
111         ori             gr28,0,sp
112
113         movsg           tbr ,gr20
114         movsg           psr ,gr22
115         movsg           pcsr,gr21
116         movsg           isr ,gr23
117         movsg           ccr ,gr24
118         movsg           cccr,gr25
119         movsg           lr  ,gr26
120         movsg           lcr ,gr27
121
122         setlos.p        #-1,gr4
123         andi            gr22,#PSR_PS,gr5                /* try to rebuild original PSR value */
124         andi.p          gr22,#~(PSR_PS|PSR_S),gr6
125         slli            gr5,#1,gr5
126         or              gr6,gr5,gr5
127         andi            gr5,#~PSR_ET,gr5
128
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)
136
137         movsg           iacc0h,gr4
138         movsg           iacc0l,gr5
139         stdi            gr4,@(gr28,#REG_IACC0)
140
141         movsg           gner0,gr4
142         movsg           gner1,gr5
143         stdi.p          gr4,@(gr28,#REG_GNER0)
144
145         # interrupts start off fully disabled in the interrupt handler
146         subcc           gr0,gr0,gr0,icc2                /* set Z and clear C */
147
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
152         setlo           %lo(_gp),gr16
153         ldi             @(gr5,#0),gr29
154         ldi.p           @(gr29,#4),gr15         ; __current_thread_info = current->thread_info
155
156         # make sure we (the kernel) get div-zero and misalignment exceptions
157         setlos          #ISR_EDE|ISR_DTT_DIVBYZERO|ISR_EMAM_EXCEPTION,gr5
158         movgs           gr5,isr
159
160         # switch to the kernel trap table
161         sethi.p         %hi(__entry_kerneltrap_table),gr6
162         setlo           %lo(__entry_kerneltrap_table),gr6
163         movgs           gr6,tbr
164
165         # set the return address
166         sethi.p         %hi(__entry_return_from_user_interrupt),gr4
167         setlo           %lo(__entry_return_from_user_interrupt),gr4
168         movgs           gr4,lr
169
170         # raise the minimum interrupt priority to 15 (NMI only) and enable exceptions
171         movsg           psr,gr4
172
173         ori             gr4,#PSR_PIL_14,gr4
174         movgs           gr4,psr
175         ori             gr4,#PSR_PIL_14|PSR_ET,gr4
176         movgs           gr4,psr
177
178         LEDS            0x6202
179         bra             do_IRQ
180
181         .size           __entry_uspace_external_interrupt,.-__entry_uspace_external_interrupt
182
183 ###############################################################################
184 #
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
192 #
193 ###############################################################################
194         .globl          __entry_kernel_external_interrupt
195         .type           __entry_kernel_external_interrupt,@function
196 __entry_kernel_external_interrupt:
197         LEDS            0x6210
198 //      sub             sp,gr15,gr31
199 //      LEDS32
200
201         # set up the stack pointer
202         or.p            sp,gr0,gr30
203         subi            sp,#REG__END,sp
204         sti             gr30,@(sp,#REG_SP)
205
206         # handle h/w single-step through exceptions
207         sti             gr0,@(sp,#REG__STATUS)
208
209         .globl          __entry_kernel_external_interrupt_reentry
210 __entry_kernel_external_interrupt_reentry:
211         LEDS            0x6211
212
213         # set up the exception frame
214         setlos          #REG__END,gr30
215         dcpl            sp,gr30,#0
216
217         sti.p           gr28,@(sp,#REG_GR(28))
218         ori             sp,0,gr28
219
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))
236
237         # note virtual interrupts will be fully enabled upon return
238         subicc          gr0,#1,gr0,icc2                 /* clear Z, set C */
239
240         movsg           tbr ,gr20
241         movsg           psr ,gr22
242         movsg           pcsr,gr21
243         movsg           isr ,gr23
244         movsg           ccr ,gr24
245         movsg           cccr,gr25
246         movsg           lr  ,gr26
247         movsg           lcr ,gr27
248
249         setlos.p        #-1,gr4
250         andi            gr22,#PSR_PS,gr5                /* try to rebuild original PSR value */
251         andi.p          gr22,#~(PSR_PS|PSR_S),gr6
252         slli            gr5,#1,gr5
253         or              gr6,gr5,gr5
254         andi.p          gr5,#~PSR_ET,gr5
255
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
259
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)
267
268         movsg           iacc0h,gr4
269         movsg           iacc0l,gr5
270         stdi            gr4,@(gr28,#REG_IACC0)
271
272         movsg           gner0,gr4
273         movsg           gner1,gr5
274         stdi.p          gr4,@(gr28,#REG_GNER0)
275
276         # interrupts start off fully disabled in the interrupt handler
277         subcc           gr0,gr0,gr0,icc2                        /* set Z and clear C */
278
279         # set the return address
280         sethi.p         %hi(__entry_return_from_kernel_interrupt),gr4
281         setlo           %lo(__entry_return_from_kernel_interrupt),gr4
282         movgs           gr4,lr
283
284         # clear power-saving mode flags
285         movsg           hsr0,gr4
286         andi            gr4,#~HSR0_PDM,gr4
287         movgs           gr4,hsr0
288
289         # raise the minimum interrupt priority to 15 (NMI only) and enable exceptions
290         movsg           psr,gr4
291         ori             gr4,#PSR_PIL_14,gr4
292         movgs           gr4,psr
293         ori             gr4,#PSR_ET,gr4
294         movgs           gr4,psr
295
296         LEDS            0x6212
297         bra             do_IRQ
298
299         .size           __entry_kernel_external_interrupt,.-__entry_kernel_external_interrupt
300
301 ###############################################################################
302 #
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
306 #
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:
312         movsg           psr,gr30
313         andi            gr30,#~PSR_PIL,gr30
314         ori             gr30,#PSR_PIL_14,gr30           ; debugging interrupts only
315         movgs           gr30,psr
316         subcc           gr0,gr0,gr0,icc2                ; leave Z set, clear C
317         rett            #0
318
319         .size           __entry_kernel_external_interrupt_virtually_disabled,.-__entry_kernel_external_interrupt_virtually_disabled
320
321 ###############################################################################
322 #
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
327 #
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:
333         movsg           psr,gr30
334         andi            gr30,#~PSR_PIL,gr30             ; re-enable interrupts
335         movgs           gr30,psr
336         subicc          gr0,#1,gr0,icc2                 ; clear Z, set C
337         rett            #0
338
339         .size           __entry_kernel_external_interrupt_virtual_reenable,.-__entry_kernel_external_interrupt_virtual_reenable
340
341 ###############################################################################
342 #
343 # entry point for Software and Progam interrupts generated whilst executing userspace code
344 #
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:
350         LEDS            0x6000
351 #ifdef CONFIG_MMU
352         movsg           ear0,gr28
353 __entry_uspace_handle_mmu_fault:
354         movgs           gr28,scr2
355 #endif
356         sethi.p         %hi(__kernel_frame0_ptr),gr28
357         setlo           %lo(__kernel_frame0_ptr),gr28
358         ldi             @(gr28,#0),gr28
359
360         # handle h/w single-step through exceptions
361         sti             gr0,@(gr28,#REG__STATUS)
362
363         .globl          __entry_uspace_softprog_interrupt_reentry
364 __entry_uspace_softprog_interrupt_reentry:
365         LEDS            0x6001
366
367         setlos          #REG__END,gr30
368         dcpl            gr28,gr30,#0
369
370         # set up the kernel stack pointer
371         sti.p           sp,@(gr28,#REG_SP)
372         ori             gr28,0,sp
373         sti             gr0,@(gr28,#REG_GR(28))
374
375         stdi            gr20,@(gr28,#REG_GR(20))
376         stdi            gr22,@(gr28,#REG_GR(22))
377
378         movsg           tbr,gr20
379         movsg           pcsr,gr21
380         movsg           psr,gr22
381
382         sethi.p         %hi(__entry_return_from_user_exception),gr23
383         setlo           %lo(__entry_return_from_user_exception),gr23
384
385         bra             __entry_common
386
387         .size           __entry_uspace_softprog_interrupt,.-__entry_uspace_softprog_interrupt
388
389         # single-stepping was disabled on entry to a TLB handler that then faulted
390 #ifdef CONFIG_MMU
391         .globl          __entry_uspace_handle_mmu_fault_sstep
392 __entry_uspace_handle_mmu_fault_sstep:
393         movgs           gr28,scr2
394         sethi.p         %hi(__kernel_frame0_ptr),gr28
395         setlo           %lo(__kernel_frame0_ptr),gr28
396         ldi             @(gr28,#0),gr28
397
398         # flag single-step re-enablement
399         sti             gr0,@(gr28,#REG__STATUS)
400         bra             __entry_uspace_softprog_interrupt_reentry
401 #endif
402
403
404 ###############################################################################
405 #
406 # entry point for Software and Progam interrupts generated whilst executing kernel code
407 #
408 ###############################################################################
409         .globl          __entry_kernel_softprog_interrupt
410         .type           __entry_kernel_softprog_interrupt,@function
411 __entry_kernel_softprog_interrupt:
412         LEDS            0x6004
413
414 #ifdef CONFIG_MMU
415         movsg           ear0,gr30
416         movgs           gr30,scr2
417 #endif
418
419         .globl          __entry_kernel_handle_mmu_fault
420 __entry_kernel_handle_mmu_fault:
421         # set up the stack pointer
422         subi            sp,#REG__END,sp
423         sti             sp,@(sp,#REG_SP)
424         sti             sp,@(sp,#REG_SP-4)
425         andi            sp,#~7,sp
426
427         # handle h/w single-step through exceptions
428         sti             gr0,@(sp,#REG__STATUS)
429
430         .globl          __entry_kernel_softprog_interrupt_reentry
431 __entry_kernel_softprog_interrupt_reentry:
432         LEDS            0x6005
433
434         setlos          #REG__END,gr30
435         dcpl            sp,gr30,#0
436
437         # set up the exception frame
438         sti.p           gr28,@(sp,#REG_GR(28))
439         ori             sp,0,gr28
440
441         stdi            gr20,@(gr28,#REG_GR(20))
442         stdi            gr22,@(gr28,#REG_GR(22))
443
444         ldi             @(sp,#REG_SP),gr22              /* reconstruct the old SP */
445         addi            gr22,#REG__END,gr22
446         sti             gr22,@(sp,#REG_SP)
447
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
450         movsg           cccr,gr20
451         andi            gr20,#~0xc0,gr20
452         movgs           gr20,cccr
453
454         movsg           tbr,gr20
455         movsg           pcsr,gr21
456         movsg           psr,gr22
457
458         sethi.p         %hi(__entry_return_from_kernel_exception),gr23
459         setlo           %lo(__entry_return_from_kernel_exception),gr23
460         bra             __entry_common
461
462         .size           __entry_kernel_softprog_interrupt,.-__entry_kernel_softprog_interrupt
463
464         # single-stepping was disabled on entry to a TLB handler that then faulted
465 #ifdef CONFIG_MMU
466         .globl          __entry_kernel_handle_mmu_fault_sstep
467 __entry_kernel_handle_mmu_fault_sstep:
468         # set up the stack pointer
469         subi            sp,#REG__END,sp
470         sti             sp,@(sp,#REG_SP)
471         sti             sp,@(sp,#REG_SP-4)
472         andi            sp,#~7,sp
473
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
478 #endif
479
480
481 ###############################################################################
482 #
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)
488 #       GR20    - saved TBR
489 #       GR21    - saved PC
490 #       GR22    - saved PSR
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
495 #
496 ###############################################################################
497         .globl          __entry_common
498         .type           __entry_common,@function
499 __entry_common:
500         LEDS            0x6008
501
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))
516
517         movsg           lcr ,gr27
518         movsg           lr  ,gr26
519         movgs           gr23,lr
520         movsg           cccr,gr25
521         movsg           ccr ,gr24
522         movsg           isr ,gr23
523
524         setlos.p        #-1,gr4
525         andi            gr22,#PSR_PS,gr5                /* try to rebuild original PSR value */
526         andi.p          gr22,#~(PSR_PS|PSR_S),gr6
527         slli            gr5,#1,gr5
528         or              gr6,gr5,gr5
529         andi            gr5,#~PSR_ET,gr5
530
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)
538
539         movsg           iacc0h,gr4
540         movsg           iacc0l,gr5
541         stdi            gr4,@(gr28,#REG_IACC0)
542
543         movsg           gner0,gr4
544         movsg           gner1,gr5
545         stdi.p          gr4,@(gr28,#REG_GNER0)
546
547         # set up virtual interrupt disablement
548         subicc          gr0,#1,gr0,icc2                 /* clear Z flag, set C flag */
549
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
554         setlo           %lo(_gp),gr16
555         ldi             @(gr5,#0),gr29
556         ldi             @(gr29,#4),gr15         ; __current_thread_info = current->thread_info
557
558         # switch to the kernel trap table
559         sethi.p         %hi(__entry_kerneltrap_table),gr6
560         setlo           %lo(__entry_kerneltrap_table),gr6
561         movgs           gr6,tbr
562
563         # make sure we (the kernel) get div-zero and misalignment exceptions
564         setlos          #ISR_EDE|ISR_DTT_DIVBYZERO|ISR_EMAM_EXCEPTION,gr5
565         movgs           gr5,isr
566
567         # clear power-saving mode flags
568         movsg           hsr0,gr4
569         andi            gr4,#~HSR0_PDM,gr4
570         movgs           gr4,hsr0
571
572         # multiplex again using old TBR as a guide
573         setlos.p        #TBR_TT,gr3
574         sethi           %hi(__entry_vector_table),gr6
575         and.p           gr20,gr3,gr5
576         setlo           %lo(__entry_vector_table),gr6
577         srli            gr5,#2,gr5
578         ld              @(gr5,gr6),gr5
579
580         LEDS            0x6009
581         jmpl            @(gr5,gr0)
582
583
584         .size           __entry_common,.-__entry_common
585
586 ###############################################################################
587 #
588 # handle instruction MMU fault
589 #
590 ###############################################################################
591 #ifdef CONFIG_MMU
592         .globl          __entry_insn_mmu_fault
593 __entry_insn_mmu_fault:
594         LEDS            0x6010
595         setlos          #0,gr8
596         movsg           esr0,gr9
597         movsg           scr2,gr10
598
599         # now that we've accessed the exception regs, we can enable exceptions
600         movsg           psr,gr4
601         ori             gr4,#PSR_ET,gr4
602         movgs           gr4,psr
603
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)
607 #endif
608
609
610 ###############################################################################
611 #
612 # handle instruction access error
613 #
614 ###############################################################################
615         .globl          __entry_insn_access_error
616 __entry_insn_access_error:
617         LEDS            0x6011
618         sethi.p         %hi(insn_access_error),gr5
619         setlo           %lo(insn_access_error),gr5
620         movsg           esfr1,gr8
621         movsg           epcr0,gr9
622         movsg           esr0,gr10
623
624         # now that we've accessed the exception regs, we can enable exceptions
625         movsg           psr,gr4
626         ori             gr4,#PSR_ET,gr4
627         movgs           gr4,psr
628         jmpl            @(gr5,gr0)      ; call insn_access_error(esfr1,epcr0,esr0)
629
630 ###############################################################################
631 #
632 # handle various instructions of dubious legality
633 #
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:
640         subi            gr21,#4,gr21
641         sti             gr21,@(gr28,#REG_PC)
642 __entry_illegal_instruction:
643 __entry_privileged_instruction:
644 __entry_debug_exception:
645         LEDS            0x6012
646         sethi.p         %hi(illegal_instruction),gr5
647         setlo           %lo(illegal_instruction),gr5
648         movsg           esfr1,gr8
649         movsg           epcr0,gr9
650         movsg           esr0,gr10
651
652         # now that we've accessed the exception regs, we can enable exceptions
653         movsg           psr,gr4
654         ori             gr4,#PSR_ET,gr4
655         movgs           gr4,psr
656         jmpl            @(gr5,gr0)      ; call ill_insn(esfr1,epcr0,esr0)
657
658 ###############################################################################
659 #
660 # handle media exception
661 #
662 ###############################################################################
663         .globl          __entry_media_exception
664 __entry_media_exception:
665         LEDS            0x6013
666         sethi.p         %hi(media_exception),gr5
667         setlo           %lo(media_exception),gr5
668         movsg           msr0,gr8
669         movsg           msr1,gr9
670
671         # now that we've accessed the exception regs, we can enable exceptions
672         movsg           psr,gr4
673         ori             gr4,#PSR_ET,gr4
674         movgs           gr4,psr
675         jmpl            @(gr5,gr0)      ; call media_excep(msr0,msr1)
676
677 ###############################################################################
678 #
679 # handle data MMU fault
680 # handle data DAT fault (write-protect exception)
681 #
682 ###############################################################################
683 #ifdef CONFIG_MMU
684         .globl          __entry_data_mmu_fault
685 __entry_data_mmu_fault:
686         .globl          __entry_data_dat_fault
687 __entry_data_dat_fault:
688         LEDS            0x6014
689         setlos          #1,gr8
690         movsg           esr0,gr9
691         movsg           scr2,gr10       ; saved EAR0
692
693         # now that we've accessed the exception regs, we can enable exceptions
694         movsg           psr,gr4
695         ori             gr4,#PSR_ET,gr4
696         movgs           gr4,psr
697
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)
701 #endif
702
703 ###############################################################################
704 #
705 # handle data and instruction access exceptions
706 #
707 ###############################################################################
708         .globl          __entry_insn_access_exception
709         .globl          __entry_data_access_exception
710 __entry_insn_access_exception:
711 __entry_data_access_exception:
712         LEDS            0x6016
713         sethi.p         %hi(memory_access_exception),gr5
714         setlo           %lo(memory_access_exception),gr5
715         movsg           esr0,gr8
716         movsg           scr2,gr9        ; saved EAR0
717         movsg           epcr0,gr10
718
719         # now that we've accessed the exception regs, we can enable exceptions
720         movsg           psr,gr4
721         ori             gr4,#PSR_ET,gr4
722         movgs           gr4,psr
723         jmpl            @(gr5,gr0)      ; call memory_access_error(esr0,ear0,epcr0)
724
725 ###############################################################################
726 #
727 # handle data access error
728 #
729 ###############################################################################
730         .globl          __entry_data_access_error
731 __entry_data_access_error:
732         LEDS            0x6016
733         sethi.p         %hi(data_access_error),gr5
734         setlo           %lo(data_access_error),gr5
735         movsg           esfr1,gr8
736         movsg           esr15,gr9
737         movsg           ear15,gr10
738
739         # now that we've accessed the exception regs, we can enable exceptions
740         movsg           psr,gr4
741         ori             gr4,#PSR_ET,gr4
742         movgs           gr4,psr
743         jmpl            @(gr5,gr0)      ; call data_access_error(esfr1,esr15,ear15)
744
745 ###############################################################################
746 #
747 # handle data store error
748 #
749 ###############################################################################
750         .globl          __entry_data_store_error
751 __entry_data_store_error:
752         LEDS            0x6017
753         sethi.p         %hi(data_store_error),gr5
754         setlo           %lo(data_store_error),gr5
755         movsg           esfr1,gr8
756         movsg           esr14,gr9
757
758         # now that we've accessed the exception regs, we can enable exceptions
759         movsg           psr,gr4
760         ori             gr4,#PSR_ET,gr4
761         movgs           gr4,psr
762         jmpl            @(gr5,gr0)      ; call data_store_error(esfr1,esr14)
763
764 ###############################################################################
765 #
766 # handle division exception
767 #
768 ###############################################################################
769         .globl          __entry_division_exception
770 __entry_division_exception:
771         LEDS            0x6018
772         sethi.p         %hi(division_exception),gr5
773         setlo           %lo(division_exception),gr5
774         movsg           esfr1,gr8
775         movsg           esr0,gr9
776         movsg           isr,gr10
777
778         # now that we've accessed the exception regs, we can enable exceptions
779         movsg           psr,gr4
780         ori             gr4,#PSR_ET,gr4
781         movgs           gr4,psr
782         jmpl            @(gr5,gr0)      ; call div_excep(esfr1,esr0,isr)
783
784 ###############################################################################
785 #
786 # handle compound exception
787 #
788 ###############################################################################
789         .globl          __entry_compound_exception
790 __entry_compound_exception:
791         LEDS            0x6019
792         sethi.p         %hi(compound_exception),gr5
793         setlo           %lo(compound_exception),gr5
794         movsg           esfr1,gr8
795         movsg           esr0,gr9
796         movsg           esr14,gr10
797         movsg           esr15,gr11
798         movsg           msr0,gr12
799         movsg           msr1,gr13
800
801         # now that we've accessed the exception regs, we can enable exceptions
802         movsg           psr,gr4
803         ori             gr4,#PSR_ET,gr4
804         movgs           gr4,psr
805         jmpl            @(gr5,gr0)      ; call comp_excep(esfr1,esr0,esr14,esr15,msr0,msr1)
806
807 ###############################################################################
808 #
809 # handle interrupts and NMIs
810 #
811 ###############################################################################
812         .globl          __entry_do_IRQ
813 __entry_do_IRQ:
814         LEDS            0x6020
815
816         # we can enable exceptions
817         movsg           psr,gr4
818         ori             gr4,#PSR_ET,gr4
819         movgs           gr4,psr
820         bra             do_IRQ
821
822         .globl          __entry_do_NMI
823 __entry_do_NMI:
824         LEDS            0x6021
825
826         # we can enable exceptions
827         movsg           psr,gr4
828         ori             gr4,#PSR_ET,gr4
829         movgs           gr4,psr
830         bra             do_NMI
831
832 ###############################################################################
833 #
834 # the return path for a newly forked child process
835 # - __switch_to() saved the old current pointer in GR8 for us
836 #
837 ###############################################################################
838         .globl          ret_from_fork
839 ret_from_fork:
840         LEDS            0x6100
841         call            schedule_tail
842
843         # fork & co. return 0 to child
844         setlos.p        #0,gr8
845         bra             __syscall_exit
846
847 ###################################################################################################
848 #
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.
853 #
854 ###################################################################################################
855         .balign         L1_CACHE_BYTES
856         .globl          system_call
857 system_call:
858         LEDS            0x6101
859         movsg           psr,gr4                 ; enable exceptions
860         ori             gr4,#PSR_ET,gr4
861         movgs           gr4,psr
862
863         sti             gr7,@(gr28,#REG_SYSCALLNO)
864         sti.p           gr8,@(gr28,#REG_ORIG_GR8)
865
866         subicc          gr7,#nr_syscalls,gr0,icc0
867         bnc             icc0,#0,__syscall_badsys
868
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
873
874 __syscall_call:
875         slli.p          gr7,#2,gr7
876         sethi           %hi(sys_call_table),gr5
877         setlo           %lo(sys_call_table),gr5
878         ld              @(gr5,gr7),gr4
879         calll           @(gr4,gr0)
880
881
882 ###############################################################################
883 #
884 # return to interrupted process
885 #
886 ###############################################################################
887 __syscall_exit:
888         LEDS            0x6300
889
890         sti             gr8,@(gr28,#REG_GR(8))  ; save return value
891
892         # rebuild saved psr - execve will change it for init/main.c
893         ldi             @(gr28,#REG_PSR),gr22
894         srli            gr22,#1,gr5
895         andi.p          gr22,#~PSR_PS,gr22
896         andi            gr5,#PSR_PS,gr5
897         or              gr5,gr22,gr22
898         ori             gr22,#PSR_S,gr22
899
900         # keep current PSR in GR23
901         movsg           psr,gr23
902
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
906         movgs           gr23,psr
907
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
913
914         # restore all registers and return
915 __entry_return_direct:
916         LEDS            0x6301
917
918         andi            gr22,#~PSR_ET,gr22
919         movgs           gr22,psr
920
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
926
927         movgs           gr20,tbr
928         movgs           gr21,pcsr
929         movgs           gr23,isr
930         movgs           gr24,ccr
931         movgs           gr25,cccr
932         movgs           gr26,lr
933         movgs           gr27,lcr
934
935         lddi            @(gr28,#REG_GNER0),gr4
936         movgs           gr4,gner0
937         movgs           gr5,gner1
938
939         lddi            @(gr28,#REG_IACC0),gr4
940         movgs           gr4,iacc0h
941         movgs           gr5,iacc0l
942
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
957
958         # check to see if a debugging return is required
959         LEDS            0x67f0
960         movsg           ccr,gr2
961         ldi             @(gr28,#REG__STATUS),gr3
962         andicc          gr3,#REG__STATUS_STEP,gr0,icc0
963         bne             icc0,#0,__entry_return_singlestep
964         movgs           gr2,ccr
965
966         ldi             @(gr28,#REG_SP)    ,sp
967         lddi            @(gr28,#REG_GR(2)) ,gr2
968         ldi             @(gr28,#REG_GR(28)),gr28
969
970         LEDS            0x67fe
971 //      movsg           pcsr,gr31
972 //      LEDS32
973
974 #if 0
975         # store the current frame in the workram on the FR451
976         movgs           gr28,scr2
977         sethi.p         %hi(0xfe800000),gr28
978         setlo           %lo(0xfe800000),gr28
979
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))
993
994         movsg           tbr ,gr30
995         sti             gr30,@(gr28,#REG_TBR)
996         movsg           pcsr,gr30
997         sti             gr30,@(gr28,#REG_PC)
998         movsg           psr ,gr30
999         sti             gr30,@(gr28,#REG_PSR)
1000         movsg           isr ,gr30
1001         sti             gr30,@(gr28,#REG_ISR)
1002         movsg           ccr ,gr30
1003         movsg           cccr,gr31
1004         stdi            gr30,@(gr28,#REG_CCR)
1005         movsg           lr  ,gr30
1006         movsg           lcr ,gr31
1007         stdi            gr30,@(gr28,#REG_LR)
1008         sti             gr0 ,@(gr28,#REG_SYSCALLNO)
1009         movsg           scr2,gr28
1010 #endif
1011
1012         rett            #0
1013
1014         # return via break.S
1015 __entry_return_singlestep:
1016         movgs           gr2,ccr
1017         lddi            @(gr28,#REG_GR(2)) ,gr2
1018         ldi             @(gr28,#REG_SP)    ,sp
1019         ldi             @(gr28,#REG_GR(28)),gr28
1020         LEDS            0x67ff
1021         break
1022         .globl          __entry_return_singlestep_breaks_here
1023 __entry_return_singlestep_breaks_here:
1024         nop
1025
1026
1027 ###############################################################################
1028 #
1029 # return to a process interrupted in kernel space
1030 # - we need to consider preemption if that is enabled
1031 #
1032 ###############################################################################
1033         .balign         L1_CACHE_BYTES
1034 __entry_return_from_kernel_exception:
1035         LEDS            0x6302
1036         movsg           psr,gr23
1037         ori             gr23,#PSR_PIL_14,gr23
1038         movgs           gr23,psr
1039         bra             __entry_return_direct
1040
1041         .balign         L1_CACHE_BYTES
1042 __entry_return_from_kernel_interrupt:
1043         LEDS            0x6303
1044         movsg           psr,gr23
1045         ori             gr23,#PSR_PIL_14,gr23
1046         movgs           gr23,psr
1047
1048 #ifdef CONFIG_PREEMPT
1049         ldi             @(gr15,#TI_PRE_COUNT),gr5
1050         subicc          gr5,#0,gr0,icc0
1051         beq             icc0,#0,__entry_return_direct
1052
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
1057
1058         setlos          #PREEMPT_ACTIVE,gr5
1059         sti             gr5,@(gr15,#TI_FLAGS)
1060
1061         andi            gr23,#~PSR_PIL,gr23
1062         movgs           gr23,psr
1063
1064         call            schedule
1065         sti             gr0,@(gr15,#TI_PRE_COUNT)
1066
1067         movsg           psr,gr23
1068         ori             gr23,#PSR_PIL_14,gr23
1069         movgs           gr23,psr
1070         bra             __entry_preempt_need_resched
1071 #else
1072         bra             __entry_return_direct
1073 #endif
1074
1075
1076 ###############################################################################
1077 #
1078 # perform work that needs to be done immediately before resumption
1079 #
1080 ###############################################################################
1081         .globl          __entry_return_from_user_exception
1082         .balign         L1_CACHE_BYTES
1083 __entry_return_from_user_exception:
1084         LEDS            0x6501
1085
1086 __entry_resume_userspace:
1087         # make sure we don't miss an interrupt setting need_resched or sigpending between
1088         # sampling and the RETT
1089         movsg           psr,gr23
1090         ori             gr23,#PSR_PIL_14,gr23
1091         movgs           gr23,psr
1092
1093 __entry_return_from_user_interrupt:
1094         LEDS            0x6402
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
1100
1101 __entry_work_pending:
1102         LEDS            0x6404
1103         andicc          gr4,#_TIF_NEED_RESCHED,gr0,icc0
1104         beq             icc0,#1,__entry_work_notifysig
1105
1106 __entry_work_resched:
1107         LEDS            0x6408
1108         movsg           psr,gr23
1109         andi            gr23,#~PSR_PIL,gr23
1110         movgs           gr23,psr
1111         call            schedule
1112         movsg           psr,gr23
1113         ori             gr23,#PSR_PIL_14,gr23
1114         movgs           gr23,psr
1115
1116         LEDS            0x6401
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
1124
1125 __entry_work_notifysig:
1126         LEDS            0x6410
1127         ori.p           gr4,#0,gr8
1128         call            do_notify_resume
1129         bra             __entry_resume_userspace
1130
1131         # perform syscall entry tracing
1132 __syscall_trace_entry:
1133         LEDS            0x6320
1134         setlos.p        #0,gr8
1135         call            do_syscall_trace
1136
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
1141
1142         subicc          gr7,#nr_syscalls,gr0,icc0
1143         bnc             icc0,#0,__syscall_badsys
1144         bra             __syscall_call
1145
1146         # perform syscall exit tracing
1147 __syscall_exit_work:
1148         LEDS            0x6340
1149         andicc          gr4,#_TIF_SYSCALL_TRACE,gr0,icc0
1150         beq             icc0,#1,__entry_work_pending
1151
1152         movsg           psr,gr23
1153         andi            gr23,#~PSR_PIL,gr23     ; could let do_syscall_trace() call schedule()
1154         movgs           gr23,psr
1155
1156         setlos.p        #1,gr8
1157         call            do_syscall_trace
1158         bra             __entry_resume_userspace
1159
1160 __syscall_badsys:
1161         LEDS            0x6380
1162         setlos          #-ENOSYS,gr8
1163         sti             gr8,@(gr28,#REG_GR(8))  ; save return value
1164         bra             __entry_resume_userspace
1165
1166
1167 ###############################################################################
1168 #
1169 # syscall vector table
1170 #
1171 ###############################################################################
1172         .section .rodata
1173 ALIGN
1174         .globl          sys_call_table
1175 sys_call_table:
1176         .long sys_restart_syscall       /* 0 - old "setup()" system call, used for restarting */
1177         .long sys_exit
1178         .long sys_fork
1179         .long sys_read
1180         .long sys_write
1181         .long sys_open          /* 5 */
1182         .long sys_close
1183         .long sys_waitpid
1184         .long sys_creat
1185         .long sys_link
1186         .long sys_unlink                /* 10 */
1187         .long sys_execve
1188         .long sys_chdir
1189         .long sys_time
1190         .long sys_mknod
1191         .long sys_chmod         /* 15 */
1192         .long sys_lchown16
1193         .long sys_ni_syscall                    /* old break syscall holder */
1194         .long sys_stat
1195         .long sys_lseek
1196         .long sys_getpid                /* 20 */
1197         .long sys_mount
1198         .long sys_oldumount
1199         .long sys_setuid16
1200         .long sys_getuid16
1201         .long sys_ni_syscall // sys_stime               /* 25 */
1202         .long sys_ptrace
1203         .long sys_alarm
1204         .long sys_fstat
1205         .long sys_pause
1206         .long sys_utime         /* 30 */
1207         .long sys_ni_syscall                    /* old stty syscall holder */
1208         .long sys_ni_syscall                    /* old gtty syscall holder */
1209         .long sys_access
1210         .long sys_nice
1211         .long sys_ni_syscall    /* 35 */        /* old ftime syscall holder */
1212         .long sys_sync
1213         .long sys_kill
1214         .long sys_rename
1215         .long sys_mkdir
1216         .long sys_rmdir         /* 40 */
1217         .long sys_dup
1218         .long sys_pipe
1219         .long sys_times
1220         .long sys_ni_syscall                    /* old prof syscall holder */
1221         .long sys_brk           /* 45 */
1222         .long sys_setgid16
1223         .long sys_getgid16
1224         .long sys_ni_syscall // sys_signal
1225         .long sys_geteuid16
1226         .long sys_getegid16     /* 50 */
1227         .long sys_acct
1228         .long sys_umount                                /* recycled never used phys( */
1229         .long sys_ni_syscall                    /* old lock syscall holder */
1230         .long sys_ioctl
1231         .long sys_fcntl         /* 55 */
1232         .long sys_ni_syscall                    /* old mpx syscall holder */
1233         .long sys_setpgid
1234         .long sys_ni_syscall                    /* old ulimit syscall holder */
1235         .long sys_ni_syscall                    /* old old uname syscall */
1236         .long sys_umask         /* 60 */
1237         .long sys_chroot
1238         .long sys_ustat
1239         .long sys_dup2
1240         .long sys_getppid
1241         .long sys_getpgrp       /* 65 */
1242         .long sys_setsid
1243         .long sys_sigaction
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
1253         .long sys_getrusage
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 */
1259         .long sys_symlink
1260         .long sys_lstat
1261         .long sys_readlink              /* 85 */
1262         .long sys_uselib
1263         .long sys_swapon
1264         .long sys_reboot
1265         .long sys_ni_syscall // old_readdir
1266         .long sys_ni_syscall    /* 90 */        /* old_mmap slot */
1267         .long sys_munmap
1268         .long sys_truncate
1269         .long sys_ftruncate
1270         .long sys_fchmod
1271         .long sys_fchown16              /* 95 */
1272         .long sys_getpriority
1273         .long sys_setpriority
1274         .long sys_ni_syscall                    /* old profil syscall holder */
1275         .long sys_statfs
1276         .long sys_fstatfs               /* 100 */
1277         .long sys_ni_syscall                    /* ioperm for i386 */
1278         .long sys_socketcall
1279         .long sys_syslog
1280         .long sys_setitimer
1281         .long sys_getitimer     /* 105 */
1282         .long sys_newstat
1283         .long sys_newlstat
1284         .long sys_newfstat
1285         .long sys_ni_syscall    /* obsolete olduname( syscall */
1286         .long sys_ni_syscall    /* iopl for i386 */ /* 110 */
1287         .long sys_vhangup
1288         .long sys_ni_syscall    /* obsolete idle( syscall */
1289         .long sys_ni_syscall    /* vm86old for i386 */
1290         .long sys_wait4
1291         .long sys_swapoff               /* 115 */
1292         .long sys_sysinfo
1293         .long sys_ipc
1294         .long sys_fsync
1295         .long sys_sigreturn
1296         .long sys_clone         /* 120 */
1297         .long sys_setdomainname
1298         .long sys_newuname
1299         .long sys_ni_syscall    /* old "cacheflush" */
1300         .long sys_adjtimex
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" */
1307         .long sys_quotactl
1308         .long sys_getpgid
1309         .long sys_fchdir
1310         .long sys_bdflush
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 */
1317         .long sys_getdents
1318         .long sys_select
1319         .long sys_flock
1320         .long sys_msync
1321         .long sys_readv         /* 145 */
1322         .long sys_writev
1323         .long sys_getsid
1324         .long sys_fdatasync
1325         .long sys_sysctl
1326         .long sys_mlock         /* 150 */
1327         .long sys_munlock
1328         .long sys_mlockall
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
1338         .long sys_nanosleep
1339         .long sys_mremap
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 */
1344         .long sys_poll
1345         .long sys_nfsservctl
1346         .long sys_setresgid16   /* 170 */
1347         .long sys_getresgid16
1348         .long sys_prctl
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 */
1357         .long sys_pwrite64
1358         .long sys_chown16
1359         .long sys_getcwd
1360         .long sys_capget
1361         .long sys_capset           /* 185 */
1362         .long sys_sigaltstack
1363         .long sys_sendfile
1364         .long sys_ni_syscall            /* streams1 */
1365         .long sys_ni_syscall            /* streams2 */
1366         .long sys_vfork            /* 190 */
1367         .long sys_getrlimit
1368         .long sys_mmap2
1369         .long sys_truncate64
1370         .long sys_ftruncate64
1371         .long sys_stat64                /* 195 */
1372         .long sys_lstat64
1373         .long sys_fstat64
1374         .long sys_lchown
1375         .long sys_getuid
1376         .long sys_getgid                /* 200 */
1377         .long sys_geteuid
1378         .long sys_getegid
1379         .long sys_setreuid
1380         .long sys_setregid
1381         .long sys_getgroups     /* 205 */
1382         .long sys_setgroups
1383         .long sys_fchown
1384         .long sys_setresuid
1385         .long sys_getresuid
1386         .long sys_setresgid     /* 210 */
1387         .long sys_getresgid
1388         .long sys_chown
1389         .long sys_setuid
1390         .long sys_setgid
1391         .long sys_setfsuid              /* 215 */
1392         .long sys_setfsgid
1393         .long sys_pivot_root
1394         .long sys_mincore
1395         .long sys_madvise
1396         .long sys_getdents64    /* 220 */
1397         .long sys_fcntl64
1398         .long sys_ni_syscall    /* reserved for TUX */
1399         .long sys_ni_syscall    /* Reserved for Security */
1400         .long sys_gettid
1401         .long sys_readahead     /* 225 */
1402         .long sys_setxattr
1403         .long sys_lsetxattr
1404         .long sys_fsetxattr
1405         .long sys_getxattr
1406         .long sys_lgetxattr     /* 230 */
1407         .long sys_fgetxattr
1408         .long sys_listxattr
1409         .long sys_llistxattr
1410         .long sys_flistxattr
1411         .long sys_removexattr   /* 235 */
1412         .long sys_lremovexattr
1413         .long sys_fremovexattr
1414         .long sys_tkill
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
1424         .long sys_io_submit
1425         .long sys_io_cancel
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
1444         .long sys_statfs64
1445         .long sys_fstatfs64
1446         .long sys_tgkill        /* 270 */
1447         .long sys_utimes
1448         .long sys_fadvise64_64
1449         .long sys_ni_syscall    /* sys_vserver */
1450         .long sys_mbind
1451         .long sys_get_mempolicy
1452         .long sys_set_mempolicy
1453         .long sys_mq_open
1454         .long sys_mq_unlink
1455         .long sys_mq_timedsend
1456         .long sys_mq_timedreceive       /* 280 */
1457         .long sys_mq_notify
1458         .long sys_mq_getsetattr
1459         .long sys_ni_syscall            /* reserved for kexec */
1460         .long sys_waitid
1461         .long sys_ni_syscall            /* 285 */ /* available */
1462         .long sys_add_key
1463         .long sys_request_key
1464         .long sys_keyctl
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 */
1472         .long sys_mkdirat
1473         .long sys_mknodat
1474         .long sys_fchownat
1475         .long sys_futimesat
1476         .long sys_fstatat64             /* 300 */
1477         .long sys_unlinkat
1478         .long sys_renameat
1479         .long sys_linkat
1480         .long sys_symlinkat
1481         .long sys_readlinkat            /* 305 */
1482         .long sys_fchmodat
1483         .long sys_faccessat
1484         .long sys_pselect6
1485         .long sys_ppoll
1486
1487
1488 syscall_table_size = (. - sys_call_table)