Merge ../linus
[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/config.h>
32 #include <linux/linkage.h>
33 #include <asm/thread_info.h>
34 #include <asm/setup.h>
35 #include <asm/segment.h>
36 #include <asm/ptrace.h>
37 #include <asm/errno.h>
38 #include <asm/cache.h>
39 #include <asm/spr-regs.h>
40
41 #define nr_syscalls ((syscall_table_size)/4)
42
43         .text
44         .balign         4
45
46 .macro LEDS val
47 #       sethi.p         %hi(0xe1200004),gr30
48 #       setlo           %lo(0xe1200004),gr30
49 #       setlos          #~\val,gr31
50 #       st              gr31,@(gr30,gr0)
51 #       sethi.p         %hi(0xffc00100),gr30
52 #       setlo           %lo(0xffc00100),gr30
53 #       sth             gr0,@(gr30,gr0)
54 #       membar
55 .endm
56
57 .macro LEDS32
58 #       not             gr31,gr31
59 #       sethi.p         %hi(0xe1200004),gr30
60 #       setlo           %lo(0xe1200004),gr30
61 #       st.p            gr31,@(gr30,gr0)
62 #       srli            gr31,#16,gr31
63 #       sethi.p         %hi(0xffc00100),gr30
64 #       setlo           %lo(0xffc00100),gr30
65 #       sth             gr31,@(gr30,gr0)
66 #       membar
67 .endm
68
69 ###############################################################################
70 #
71 # entry point for External interrupts received whilst executing userspace code
72 #
73 ###############################################################################
74         .globl          __entry_uspace_external_interrupt
75         .type           __entry_uspace_external_interrupt,@function
76 __entry_uspace_external_interrupt:
77         LEDS            0x6200
78         sethi.p         %hi(__kernel_frame0_ptr),gr28
79         setlo           %lo(__kernel_frame0_ptr),gr28
80         ldi             @(gr28,#0),gr28
81
82         # handle h/w single-step through exceptions
83         sti             gr0,@(gr28,#REG__STATUS)
84
85         .globl          __entry_uspace_external_interrupt_reentry
86 __entry_uspace_external_interrupt_reentry:
87         LEDS            0x6201
88
89         setlos          #REG__END,gr30
90         dcpl            gr28,gr30,#0
91
92         # finish building the exception frame
93         sti             sp,  @(gr28,#REG_SP)
94         stdi            gr2, @(gr28,#REG_GR(2))
95         stdi            gr4, @(gr28,#REG_GR(4))
96         stdi            gr6, @(gr28,#REG_GR(6))
97         stdi            gr8, @(gr28,#REG_GR(8))
98         stdi            gr10,@(gr28,#REG_GR(10))
99         stdi            gr12,@(gr28,#REG_GR(12))
100         stdi            gr14,@(gr28,#REG_GR(14))
101         stdi            gr16,@(gr28,#REG_GR(16))
102         stdi            gr18,@(gr28,#REG_GR(18))
103         stdi            gr20,@(gr28,#REG_GR(20))
104         stdi            gr22,@(gr28,#REG_GR(22))
105         stdi            gr24,@(gr28,#REG_GR(24))
106         stdi            gr26,@(gr28,#REG_GR(26))
107         sti             gr0, @(gr28,#REG_GR(28))
108         sti             gr29,@(gr28,#REG_GR(29))
109         stdi.p          gr30,@(gr28,#REG_GR(30))
110
111         # set up the kernel stack pointer
112         ori             gr28,0,sp
113
114         movsg           tbr ,gr20
115         movsg           psr ,gr22
116         movsg           pcsr,gr21
117         movsg           isr ,gr23
118         movsg           ccr ,gr24
119         movsg           cccr,gr25
120         movsg           lr  ,gr26
121         movsg           lcr ,gr27
122
123         setlos.p        #-1,gr4
124         andi            gr22,#PSR_PS,gr5                /* try to rebuild original PSR value */
125         andi.p          gr22,#~(PSR_PS|PSR_S),gr6
126         slli            gr5,#1,gr5
127         or              gr6,gr5,gr5
128         andi            gr5,#~PSR_ET,gr5
129
130         sti             gr20,@(gr28,#REG_TBR)
131         sti             gr21,@(gr28,#REG_PC)
132         sti             gr5 ,@(gr28,#REG_PSR)
133         sti             gr23,@(gr28,#REG_ISR)
134         stdi            gr24,@(gr28,#REG_CCR)
135         stdi            gr26,@(gr28,#REG_LR)
136         sti             gr4 ,@(gr28,#REG_SYSCALLNO)
137
138         movsg           iacc0h,gr4
139         movsg           iacc0l,gr5
140         stdi            gr4,@(gr28,#REG_IACC0)
141
142         movsg           gner0,gr4
143         movsg           gner1,gr5
144         stdi.p          gr4,@(gr28,#REG_GNER0)
145
146         # interrupts start off fully disabled in the interrupt handler
147         subcc           gr0,gr0,gr0,icc2                /* set Z and clear C */
148
149         # set up kernel global registers
150         sethi.p         %hi(__kernel_current_task),gr5
151         setlo           %lo(__kernel_current_task),gr5
152         sethi.p         %hi(_gp),gr16
153         setlo           %lo(_gp),gr16
154         ldi             @(gr5,#0),gr29
155         ldi.p           @(gr29,#4),gr15         ; __current_thread_info = current->thread_info
156
157         # make sure we (the kernel) get div-zero and misalignment exceptions
158         setlos          #ISR_EDE|ISR_DTT_DIVBYZERO|ISR_EMAM_EXCEPTION,gr5
159         movgs           gr5,isr
160
161         # switch to the kernel trap table
162         sethi.p         %hi(__entry_kerneltrap_table),gr6
163         setlo           %lo(__entry_kerneltrap_table),gr6
164         movgs           gr6,tbr
165
166         # set the return address
167         sethi.p         %hi(__entry_return_from_user_interrupt),gr4
168         setlo           %lo(__entry_return_from_user_interrupt),gr4
169         movgs           gr4,lr
170
171         # raise the minimum interrupt priority to 15 (NMI only) and enable exceptions
172         movsg           psr,gr4
173
174         ori             gr4,#PSR_PIL_14,gr4
175         movgs           gr4,psr
176         ori             gr4,#PSR_PIL_14|PSR_ET,gr4
177         movgs           gr4,psr
178
179         LEDS            0x6202
180         bra             do_IRQ
181
182         .size           __entry_uspace_external_interrupt,.-__entry_uspace_external_interrupt
183
184 ###############################################################################
185 #
186 # entry point for External interrupts received whilst executing kernel code
187 # - on arriving here, the following registers should already be set up:
188 #       GR15    - current thread_info struct pointer
189 #       GR16    - kernel GP-REL pointer
190 #       GR29    - current task struct pointer
191 #       TBR     - kernel trap vector table
192 #       ISR     - kernel's preferred integer controls
193 #
194 ###############################################################################
195         .globl          __entry_kernel_external_interrupt
196         .type           __entry_kernel_external_interrupt,@function
197 __entry_kernel_external_interrupt:
198         LEDS            0x6210
199 //      sub             sp,gr15,gr31
200 //      LEDS32
201
202         # set up the stack pointer
203         or.p            sp,gr0,gr30
204         subi            sp,#REG__END,sp
205         sti             gr30,@(sp,#REG_SP)
206
207         # handle h/w single-step through exceptions
208         sti             gr0,@(sp,#REG__STATUS)
209
210         .globl          __entry_kernel_external_interrupt_reentry
211 __entry_kernel_external_interrupt_reentry:
212         LEDS            0x6211
213
214         # set up the exception frame
215         setlos          #REG__END,gr30
216         dcpl            sp,gr30,#0
217
218         sti.p           gr28,@(sp,#REG_GR(28))
219         ori             sp,0,gr28
220
221         # finish building the exception frame
222         stdi            gr2,@(gr28,#REG_GR(2))
223         stdi            gr4,@(gr28,#REG_GR(4))
224         stdi            gr6,@(gr28,#REG_GR(6))
225         stdi            gr8,@(gr28,#REG_GR(8))
226         stdi            gr10,@(gr28,#REG_GR(10))
227         stdi            gr12,@(gr28,#REG_GR(12))
228         stdi            gr14,@(gr28,#REG_GR(14))
229         stdi            gr16,@(gr28,#REG_GR(16))
230         stdi            gr18,@(gr28,#REG_GR(18))
231         stdi            gr20,@(gr28,#REG_GR(20))
232         stdi            gr22,@(gr28,#REG_GR(22))
233         stdi            gr24,@(gr28,#REG_GR(24))
234         stdi            gr26,@(gr28,#REG_GR(26))
235         sti             gr29,@(gr28,#REG_GR(29))
236         stdi.p          gr30,@(gr28,#REG_GR(30))
237
238         # note virtual interrupts will be fully enabled upon return
239         subicc          gr0,#1,gr0,icc2                 /* clear Z, set C */
240
241         movsg           tbr ,gr20
242         movsg           psr ,gr22
243         movsg           pcsr,gr21
244         movsg           isr ,gr23
245         movsg           ccr ,gr24
246         movsg           cccr,gr25
247         movsg           lr  ,gr26
248         movsg           lcr ,gr27
249
250         setlos.p        #-1,gr4
251         andi            gr22,#PSR_PS,gr5                /* try to rebuild original PSR value */
252         andi.p          gr22,#~(PSR_PS|PSR_S),gr6
253         slli            gr5,#1,gr5
254         or              gr6,gr5,gr5
255         andi.p          gr5,#~PSR_ET,gr5
256
257         # set CCCR.CC3 to Undefined to abort atomic-modify completion inside the kernel
258         # - for an explanation of how it works, see: Documentation/fujitsu/frv/atomic-ops.txt
259         andi            gr25,#~0xc0,gr25
260
261         sti             gr20,@(gr28,#REG_TBR)
262         sti             gr21,@(gr28,#REG_PC)
263         sti             gr5 ,@(gr28,#REG_PSR)
264         sti             gr23,@(gr28,#REG_ISR)
265         stdi            gr24,@(gr28,#REG_CCR)
266         stdi            gr26,@(gr28,#REG_LR)
267         sti             gr4 ,@(gr28,#REG_SYSCALLNO)
268
269         movsg           iacc0h,gr4
270         movsg           iacc0l,gr5
271         stdi            gr4,@(gr28,#REG_IACC0)
272
273         movsg           gner0,gr4
274         movsg           gner1,gr5
275         stdi.p          gr4,@(gr28,#REG_GNER0)
276
277         # interrupts start off fully disabled in the interrupt handler
278         subcc           gr0,gr0,gr0,icc2                        /* set Z and clear C */
279
280         # set the return address
281         sethi.p         %hi(__entry_return_from_kernel_interrupt),gr4
282         setlo           %lo(__entry_return_from_kernel_interrupt),gr4
283         movgs           gr4,lr
284
285         # clear power-saving mode flags
286         movsg           hsr0,gr4
287         andi            gr4,#~HSR0_PDM,gr4
288         movgs           gr4,hsr0
289
290         # raise the minimum interrupt priority to 15 (NMI only) and enable exceptions
291         movsg           psr,gr4
292         ori             gr4,#PSR_PIL_14,gr4
293         movgs           gr4,psr
294         ori             gr4,#PSR_ET,gr4
295         movgs           gr4,psr
296
297         LEDS            0x6212
298         bra             do_IRQ
299
300         .size           __entry_kernel_external_interrupt,.-__entry_kernel_external_interrupt
301
302 ###############################################################################
303 #
304 # deal with interrupts that were actually virtually disabled
305 # - we need to really disable them, flag the fact and return immediately
306 # - if you change this, you must alter break.S also
307 #
308 ###############################################################################
309         .balign         L1_CACHE_BYTES
310         .globl          __entry_kernel_external_interrupt_virtually_disabled
311         .type           __entry_kernel_external_interrupt_virtually_disabled,@function
312 __entry_kernel_external_interrupt_virtually_disabled:
313         movsg           psr,gr30
314         andi            gr30,#~PSR_PIL,gr30
315         ori             gr30,#PSR_PIL_14,gr30           ; debugging interrupts only
316         movgs           gr30,psr
317         subcc           gr0,gr0,gr0,icc2                ; leave Z set, clear C
318         rett            #0
319
320         .size           __entry_kernel_external_interrupt_virtually_disabled,.-__entry_kernel_external_interrupt_virtually_disabled
321
322 ###############################################################################
323 #
324 # deal with re-enablement of interrupts that were pending when virtually re-enabled
325 # - set ICC2.C, re-enable the real interrupts and return
326 # - we can clear ICC2.Z because we shouldn't be here if it's not 0 [due to TIHI]
327 # - if you change this, you must alter break.S also
328 #
329 ###############################################################################
330         .balign         L1_CACHE_BYTES
331         .globl          __entry_kernel_external_interrupt_virtual_reenable
332         .type           __entry_kernel_external_interrupt_virtual_reenable,@function
333 __entry_kernel_external_interrupt_virtual_reenable:
334         movsg           psr,gr30
335         andi            gr30,#~PSR_PIL,gr30             ; re-enable interrupts
336         movgs           gr30,psr
337         subicc          gr0,#1,gr0,icc2                 ; clear Z, set C
338         rett            #0
339
340         .size           __entry_kernel_external_interrupt_virtual_reenable,.-__entry_kernel_external_interrupt_virtual_reenable
341
342 ###############################################################################
343 #
344 # entry point for Software and Progam interrupts generated whilst executing userspace code
345 #
346 ###############################################################################
347         .globl          __entry_uspace_softprog_interrupt
348         .type           __entry_uspace_softprog_interrupt,@function
349         .globl          __entry_uspace_handle_mmu_fault
350 __entry_uspace_softprog_interrupt:
351         LEDS            0x6000
352 #ifdef CONFIG_MMU
353         movsg           ear0,gr28
354 __entry_uspace_handle_mmu_fault:
355         movgs           gr28,scr2
356 #endif
357         sethi.p         %hi(__kernel_frame0_ptr),gr28
358         setlo           %lo(__kernel_frame0_ptr),gr28
359         ldi             @(gr28,#0),gr28
360
361         # handle h/w single-step through exceptions
362         sti             gr0,@(gr28,#REG__STATUS)
363
364         .globl          __entry_uspace_softprog_interrupt_reentry
365 __entry_uspace_softprog_interrupt_reentry:
366         LEDS            0x6001
367
368         setlos          #REG__END,gr30
369         dcpl            gr28,gr30,#0
370
371         # set up the kernel stack pointer
372         sti.p           sp,@(gr28,#REG_SP)
373         ori             gr28,0,sp
374         sti             gr0,@(gr28,#REG_GR(28))
375
376         stdi            gr20,@(gr28,#REG_GR(20))
377         stdi            gr22,@(gr28,#REG_GR(22))
378
379         movsg           tbr,gr20
380         movsg           pcsr,gr21
381         movsg           psr,gr22
382
383         sethi.p         %hi(__entry_return_from_user_exception),gr23
384         setlo           %lo(__entry_return_from_user_exception),gr23
385
386         bra             __entry_common
387
388         .size           __entry_uspace_softprog_interrupt,.-__entry_uspace_softprog_interrupt
389
390         # single-stepping was disabled on entry to a TLB handler that then faulted
391 #ifdef CONFIG_MMU
392         .globl          __entry_uspace_handle_mmu_fault_sstep
393 __entry_uspace_handle_mmu_fault_sstep:
394         movgs           gr28,scr2
395         sethi.p         %hi(__kernel_frame0_ptr),gr28
396         setlo           %lo(__kernel_frame0_ptr),gr28
397         ldi             @(gr28,#0),gr28
398
399         # flag single-step re-enablement
400         sti             gr0,@(gr28,#REG__STATUS)
401         bra             __entry_uspace_softprog_interrupt_reentry
402 #endif
403
404
405 ###############################################################################
406 #
407 # entry point for Software and Progam interrupts generated whilst executing kernel code
408 #
409 ###############################################################################
410         .globl          __entry_kernel_softprog_interrupt
411         .type           __entry_kernel_softprog_interrupt,@function
412 __entry_kernel_softprog_interrupt:
413         LEDS            0x6004
414
415 #ifdef CONFIG_MMU
416         movsg           ear0,gr30
417         movgs           gr30,scr2
418 #endif
419
420         .globl          __entry_kernel_handle_mmu_fault
421 __entry_kernel_handle_mmu_fault:
422         # set up the stack pointer
423         subi            sp,#REG__END,sp
424         sti             sp,@(sp,#REG_SP)
425         sti             sp,@(sp,#REG_SP-4)
426         andi            sp,#~7,sp
427
428         # handle h/w single-step through exceptions
429         sti             gr0,@(sp,#REG__STATUS)
430
431         .globl          __entry_kernel_softprog_interrupt_reentry
432 __entry_kernel_softprog_interrupt_reentry:
433         LEDS            0x6005
434
435         setlos          #REG__END,gr30
436         dcpl            sp,gr30,#0
437
438         # set up the exception frame
439         sti.p           gr28,@(sp,#REG_GR(28))
440         ori             sp,0,gr28
441
442         stdi            gr20,@(gr28,#REG_GR(20))
443         stdi            gr22,@(gr28,#REG_GR(22))
444
445         ldi             @(sp,#REG_SP),gr22              /* reconstruct the old SP */
446         addi            gr22,#REG__END,gr22
447         sti             gr22,@(sp,#REG_SP)
448
449         # set CCCR.CC3 to Undefined to abort atomic-modify completion inside the kernel
450         # - for an explanation of how it works, see: Documentation/fujitsu/frv/atomic-ops.txt
451         movsg           cccr,gr20
452         andi            gr20,#~0xc0,gr20
453         movgs           gr20,cccr
454
455         movsg           tbr,gr20
456         movsg           pcsr,gr21
457         movsg           psr,gr22
458
459         sethi.p         %hi(__entry_return_from_kernel_exception),gr23
460         setlo           %lo(__entry_return_from_kernel_exception),gr23
461         bra             __entry_common
462
463         .size           __entry_kernel_softprog_interrupt,.-__entry_kernel_softprog_interrupt
464
465         # single-stepping was disabled on entry to a TLB handler that then faulted
466 #ifdef CONFIG_MMU
467         .globl          __entry_kernel_handle_mmu_fault_sstep
468 __entry_kernel_handle_mmu_fault_sstep:
469         # set up the stack pointer
470         subi            sp,#REG__END,sp
471         sti             sp,@(sp,#REG_SP)
472         sti             sp,@(sp,#REG_SP-4)
473         andi            sp,#~7,sp
474
475         # flag single-step re-enablement
476         sethi           #REG__STATUS_STEP,gr30
477         sti             gr30,@(sp,#REG__STATUS)
478         bra             __entry_kernel_softprog_interrupt_reentry
479 #endif
480
481
482 ###############################################################################
483 #
484 # the rest of the kernel entry point code
485 # - on arriving here, the following registers should be set up:
486 #       GR1     - kernel stack pointer
487 #       GR7     - syscall number (trap 0 only)
488 #       GR8-13  - syscall args (trap 0 only)
489 #       GR20    - saved TBR
490 #       GR21    - saved PC
491 #       GR22    - saved PSR
492 #       GR23    - return handler address
493 #       GR28    - exception frame on stack
494 #       SCR2    - saved EAR0 where applicable (clobbered by ICI & ICEF insns on FR451)
495 #       PSR     - PSR.S 1, PSR.ET 0
496 #
497 ###############################################################################
498         .globl          __entry_common
499         .type           __entry_common,@function
500 __entry_common:
501         LEDS            0x6008
502
503         # finish building the exception frame
504         stdi            gr2,@(gr28,#REG_GR(2))
505         stdi            gr4,@(gr28,#REG_GR(4))
506         stdi            gr6,@(gr28,#REG_GR(6))
507         stdi            gr8,@(gr28,#REG_GR(8))
508         stdi            gr10,@(gr28,#REG_GR(10))
509         stdi            gr12,@(gr28,#REG_GR(12))
510         stdi            gr14,@(gr28,#REG_GR(14))
511         stdi            gr16,@(gr28,#REG_GR(16))
512         stdi            gr18,@(gr28,#REG_GR(18))
513         stdi            gr24,@(gr28,#REG_GR(24))
514         stdi            gr26,@(gr28,#REG_GR(26))
515         sti             gr29,@(gr28,#REG_GR(29))
516         stdi            gr30,@(gr28,#REG_GR(30))
517
518         movsg           lcr ,gr27
519         movsg           lr  ,gr26
520         movgs           gr23,lr
521         movsg           cccr,gr25
522         movsg           ccr ,gr24
523         movsg           isr ,gr23
524
525         setlos.p        #-1,gr4
526         andi            gr22,#PSR_PS,gr5                /* try to rebuild original PSR value */
527         andi.p          gr22,#~(PSR_PS|PSR_S),gr6
528         slli            gr5,#1,gr5
529         or              gr6,gr5,gr5
530         andi            gr5,#~PSR_ET,gr5
531
532         sti             gr20,@(gr28,#REG_TBR)
533         sti             gr21,@(gr28,#REG_PC)
534         sti             gr5 ,@(gr28,#REG_PSR)
535         sti             gr23,@(gr28,#REG_ISR)
536         stdi            gr24,@(gr28,#REG_CCR)
537         stdi            gr26,@(gr28,#REG_LR)
538         sti             gr4 ,@(gr28,#REG_SYSCALLNO)
539
540         movsg           iacc0h,gr4
541         movsg           iacc0l,gr5
542         stdi            gr4,@(gr28,#REG_IACC0)
543
544         movsg           gner0,gr4
545         movsg           gner1,gr5
546         stdi.p          gr4,@(gr28,#REG_GNER0)
547
548         # set up virtual interrupt disablement
549         subicc          gr0,#1,gr0,icc2                 /* clear Z flag, set C flag */
550
551         # set up kernel global registers
552         sethi.p         %hi(__kernel_current_task),gr5
553         setlo           %lo(__kernel_current_task),gr5
554         sethi.p         %hi(_gp),gr16
555         setlo           %lo(_gp),gr16
556         ldi             @(gr5,#0),gr29
557         ldi             @(gr29,#4),gr15         ; __current_thread_info = current->thread_info
558
559         # switch to the kernel trap table
560         sethi.p         %hi(__entry_kerneltrap_table),gr6
561         setlo           %lo(__entry_kerneltrap_table),gr6
562         movgs           gr6,tbr
563
564         # make sure we (the kernel) get div-zero and misalignment exceptions
565         setlos          #ISR_EDE|ISR_DTT_DIVBYZERO|ISR_EMAM_EXCEPTION,gr5
566         movgs           gr5,isr
567
568         # clear power-saving mode flags
569         movsg           hsr0,gr4
570         andi            gr4,#~HSR0_PDM,gr4
571         movgs           gr4,hsr0
572
573         # multiplex again using old TBR as a guide
574         setlos.p        #TBR_TT,gr3
575         sethi           %hi(__entry_vector_table),gr6
576         and.p           gr20,gr3,gr5
577         setlo           %lo(__entry_vector_table),gr6
578         srli            gr5,#2,gr5
579         ld              @(gr5,gr6),gr5
580
581         LEDS            0x6009
582         jmpl            @(gr5,gr0)
583
584
585         .size           __entry_common,.-__entry_common
586
587 ###############################################################################
588 #
589 # handle instruction MMU fault
590 #
591 ###############################################################################
592 #ifdef CONFIG_MMU
593         .globl          __entry_insn_mmu_fault
594 __entry_insn_mmu_fault:
595         LEDS            0x6010
596         setlos          #0,gr8
597         movsg           esr0,gr9
598         movsg           scr2,gr10
599
600         # now that we've accessed the exception regs, we can enable exceptions
601         movsg           psr,gr4
602         ori             gr4,#PSR_ET,gr4
603         movgs           gr4,psr
604
605         sethi.p         %hi(do_page_fault),gr5
606         setlo           %lo(do_page_fault),gr5
607         jmpl            @(gr5,gr0)      ; call do_page_fault(0,esr0,ear0)
608 #endif
609
610
611 ###############################################################################
612 #
613 # handle instruction access error
614 #
615 ###############################################################################
616         .globl          __entry_insn_access_error
617 __entry_insn_access_error:
618         LEDS            0x6011
619         sethi.p         %hi(insn_access_error),gr5
620         setlo           %lo(insn_access_error),gr5
621         movsg           esfr1,gr8
622         movsg           epcr0,gr9
623         movsg           esr0,gr10
624
625         # now that we've accessed the exception regs, we can enable exceptions
626         movsg           psr,gr4
627         ori             gr4,#PSR_ET,gr4
628         movgs           gr4,psr
629         jmpl            @(gr5,gr0)      ; call insn_access_error(esfr1,epcr0,esr0)
630
631 ###############################################################################
632 #
633 # handle various instructions of dubious legality
634 #
635 ###############################################################################
636         .globl          __entry_unsupported_trap
637         .globl          __entry_illegal_instruction
638         .globl          __entry_privileged_instruction
639         .globl          __entry_debug_exception
640 __entry_unsupported_trap:
641         subi            gr21,#4,gr21
642         sti             gr21,@(gr28,#REG_PC)
643 __entry_illegal_instruction:
644 __entry_privileged_instruction:
645 __entry_debug_exception:
646         LEDS            0x6012
647         sethi.p         %hi(illegal_instruction),gr5
648         setlo           %lo(illegal_instruction),gr5
649         movsg           esfr1,gr8
650         movsg           epcr0,gr9
651         movsg           esr0,gr10
652
653         # now that we've accessed the exception regs, we can enable exceptions
654         movsg           psr,gr4
655         ori             gr4,#PSR_ET,gr4
656         movgs           gr4,psr
657         jmpl            @(gr5,gr0)      ; call ill_insn(esfr1,epcr0,esr0)
658
659 ###############################################################################
660 #
661 # handle media exception
662 #
663 ###############################################################################
664         .globl          __entry_media_exception
665 __entry_media_exception:
666         LEDS            0x6013
667         sethi.p         %hi(media_exception),gr5
668         setlo           %lo(media_exception),gr5
669         movsg           msr0,gr8
670         movsg           msr1,gr9
671
672         # now that we've accessed the exception regs, we can enable exceptions
673         movsg           psr,gr4
674         ori             gr4,#PSR_ET,gr4
675         movgs           gr4,psr
676         jmpl            @(gr5,gr0)      ; call media_excep(msr0,msr1)
677
678 ###############################################################################
679 #
680 # handle data MMU fault
681 # handle data DAT fault (write-protect exception)
682 #
683 ###############################################################################
684 #ifdef CONFIG_MMU
685         .globl          __entry_data_mmu_fault
686 __entry_data_mmu_fault:
687         .globl          __entry_data_dat_fault
688 __entry_data_dat_fault:
689         LEDS            0x6014
690         setlos          #1,gr8
691         movsg           esr0,gr9
692         movsg           scr2,gr10       ; saved EAR0
693
694         # now that we've accessed the exception regs, we can enable exceptions
695         movsg           psr,gr4
696         ori             gr4,#PSR_ET,gr4
697         movgs           gr4,psr
698
699         sethi.p         %hi(do_page_fault),gr5
700         setlo           %lo(do_page_fault),gr5
701         jmpl            @(gr5,gr0)      ; call do_page_fault(1,esr0,ear0)
702 #endif
703
704 ###############################################################################
705 #
706 # handle data and instruction access exceptions
707 #
708 ###############################################################################
709         .globl          __entry_insn_access_exception
710         .globl          __entry_data_access_exception
711 __entry_insn_access_exception:
712 __entry_data_access_exception:
713         LEDS            0x6016
714         sethi.p         %hi(memory_access_exception),gr5
715         setlo           %lo(memory_access_exception),gr5
716         movsg           esr0,gr8
717         movsg           scr2,gr9        ; saved EAR0
718         movsg           epcr0,gr10
719
720         # now that we've accessed the exception regs, we can enable exceptions
721         movsg           psr,gr4
722         ori             gr4,#PSR_ET,gr4
723         movgs           gr4,psr
724         jmpl            @(gr5,gr0)      ; call memory_access_error(esr0,ear0,epcr0)
725
726 ###############################################################################
727 #
728 # handle data access error
729 #
730 ###############################################################################
731         .globl          __entry_data_access_error
732 __entry_data_access_error:
733         LEDS            0x6016
734         sethi.p         %hi(data_access_error),gr5
735         setlo           %lo(data_access_error),gr5
736         movsg           esfr1,gr8
737         movsg           esr15,gr9
738         movsg           ear15,gr10
739
740         # now that we've accessed the exception regs, we can enable exceptions
741         movsg           psr,gr4
742         ori             gr4,#PSR_ET,gr4
743         movgs           gr4,psr
744         jmpl            @(gr5,gr0)      ; call data_access_error(esfr1,esr15,ear15)
745
746 ###############################################################################
747 #
748 # handle data store error
749 #
750 ###############################################################################
751         .globl          __entry_data_store_error
752 __entry_data_store_error:
753         LEDS            0x6017
754         sethi.p         %hi(data_store_error),gr5
755         setlo           %lo(data_store_error),gr5
756         movsg           esfr1,gr8
757         movsg           esr14,gr9
758
759         # now that we've accessed the exception regs, we can enable exceptions
760         movsg           psr,gr4
761         ori             gr4,#PSR_ET,gr4
762         movgs           gr4,psr
763         jmpl            @(gr5,gr0)      ; call data_store_error(esfr1,esr14)
764
765 ###############################################################################
766 #
767 # handle division exception
768 #
769 ###############################################################################
770         .globl          __entry_division_exception
771 __entry_division_exception:
772         LEDS            0x6018
773         sethi.p         %hi(division_exception),gr5
774         setlo           %lo(division_exception),gr5
775         movsg           esfr1,gr8
776         movsg           esr0,gr9
777         movsg           isr,gr10
778
779         # now that we've accessed the exception regs, we can enable exceptions
780         movsg           psr,gr4
781         ori             gr4,#PSR_ET,gr4
782         movgs           gr4,psr
783         jmpl            @(gr5,gr0)      ; call div_excep(esfr1,esr0,isr)
784
785 ###############################################################################
786 #
787 # handle compound exception
788 #
789 ###############################################################################
790         .globl          __entry_compound_exception
791 __entry_compound_exception:
792         LEDS            0x6019
793         sethi.p         %hi(compound_exception),gr5
794         setlo           %lo(compound_exception),gr5
795         movsg           esfr1,gr8
796         movsg           esr0,gr9
797         movsg           esr14,gr10
798         movsg           esr15,gr11
799         movsg           msr0,gr12
800         movsg           msr1,gr13
801
802         # now that we've accessed the exception regs, we can enable exceptions
803         movsg           psr,gr4
804         ori             gr4,#PSR_ET,gr4
805         movgs           gr4,psr
806         jmpl            @(gr5,gr0)      ; call comp_excep(esfr1,esr0,esr14,esr15,msr0,msr1)
807
808 ###############################################################################
809 #
810 # handle interrupts and NMIs
811 #
812 ###############################################################################
813         .globl          __entry_do_IRQ
814 __entry_do_IRQ:
815         LEDS            0x6020
816
817         # we can enable exceptions
818         movsg           psr,gr4
819         ori             gr4,#PSR_ET,gr4
820         movgs           gr4,psr
821         bra             do_IRQ
822
823         .globl          __entry_do_NMI
824 __entry_do_NMI:
825         LEDS            0x6021
826
827         # we can enable exceptions
828         movsg           psr,gr4
829         ori             gr4,#PSR_ET,gr4
830         movgs           gr4,psr
831         bra             do_NMI
832
833 ###############################################################################
834 #
835 # the return path for a newly forked child process
836 # - __switch_to() saved the old current pointer in GR8 for us
837 #
838 ###############################################################################
839         .globl          ret_from_fork
840 ret_from_fork:
841         LEDS            0x6100
842         call            schedule_tail
843
844         # fork & co. return 0 to child
845         setlos.p        #0,gr8
846         bra             __syscall_exit
847
848 ###################################################################################################
849 #
850 # Return to user mode is not as complex as all this looks,
851 # but we want the default path for a system call return to
852 # go as quickly as possible which is why some of this is
853 # less clear than it otherwise should be.
854 #
855 ###################################################################################################
856         .balign         L1_CACHE_BYTES
857         .globl          system_call
858 system_call:
859         LEDS            0x6101
860         movsg           psr,gr4                 ; enable exceptions
861         ori             gr4,#PSR_ET,gr4
862         movgs           gr4,psr
863
864         sti             gr7,@(gr28,#REG_SYSCALLNO)
865         sti.p           gr8,@(gr28,#REG_ORIG_GR8)
866
867         subicc          gr7,#nr_syscalls,gr0,icc0
868         bnc             icc0,#0,__syscall_badsys
869
870         ldi             @(gr15,#TI_FLAGS),gr4
871         ori             gr4,#_TIF_SYSCALL_TRACE,gr4
872         andicc          gr4,#_TIF_SYSCALL_TRACE,gr0,icc0
873         bne             icc0,#0,__syscall_trace_entry
874
875 __syscall_call:
876         slli.p          gr7,#2,gr7
877         sethi           %hi(sys_call_table),gr5
878         setlo           %lo(sys_call_table),gr5
879         ld              @(gr5,gr7),gr4
880         calll           @(gr4,gr0)
881
882
883 ###############################################################################
884 #
885 # return to interrupted process
886 #
887 ###############################################################################
888 __syscall_exit:
889         LEDS            0x6300
890
891         sti             gr8,@(gr28,#REG_GR(8))  ; save return value
892
893         # rebuild saved psr - execve will change it for init/main.c
894         ldi             @(gr28,#REG_PSR),gr22
895         srli            gr22,#1,gr5
896         andi.p          gr22,#~PSR_PS,gr22
897         andi            gr5,#PSR_PS,gr5
898         or              gr5,gr22,gr22
899         ori             gr22,#PSR_S,gr22
900
901         # keep current PSR in GR23
902         movsg           psr,gr23
903
904         # make sure we don't miss an interrupt setting need_resched or sigpending between
905         # sampling and the RETT
906         ori             gr23,#PSR_PIL_14,gr23
907         movgs           gr23,psr
908
909         ldi             @(gr15,#TI_FLAGS),gr4
910         sethi.p         %hi(_TIF_ALLWORK_MASK),gr5
911         setlo           %lo(_TIF_ALLWORK_MASK),gr5
912         andcc           gr4,gr5,gr0,icc0
913         bne             icc0,#0,__syscall_exit_work
914
915         # restore all registers and return
916 __entry_return_direct:
917         LEDS            0x6301
918
919         andi            gr22,#~PSR_ET,gr22
920         movgs           gr22,psr
921
922         ldi             @(gr28,#REG_ISR),gr23
923         lddi            @(gr28,#REG_CCR),gr24
924         lddi            @(gr28,#REG_LR) ,gr26
925         ldi             @(gr28,#REG_PC) ,gr21
926         ldi             @(gr28,#REG_TBR),gr20
927
928         movgs           gr20,tbr
929         movgs           gr21,pcsr
930         movgs           gr23,isr
931         movgs           gr24,ccr
932         movgs           gr25,cccr
933         movgs           gr26,lr
934         movgs           gr27,lcr
935
936         lddi            @(gr28,#REG_GNER0),gr4
937         movgs           gr4,gner0
938         movgs           gr5,gner1
939
940         lddi            @(gr28,#REG_IACC0),gr4
941         movgs           gr4,iacc0h
942         movgs           gr5,iacc0l
943
944         lddi            @(gr28,#REG_GR(4)) ,gr4
945         lddi            @(gr28,#REG_GR(6)) ,gr6
946         lddi            @(gr28,#REG_GR(8)) ,gr8
947         lddi            @(gr28,#REG_GR(10)),gr10
948         lddi            @(gr28,#REG_GR(12)),gr12
949         lddi            @(gr28,#REG_GR(14)),gr14
950         lddi            @(gr28,#REG_GR(16)),gr16
951         lddi            @(gr28,#REG_GR(18)),gr18
952         lddi            @(gr28,#REG_GR(20)),gr20
953         lddi            @(gr28,#REG_GR(22)),gr22
954         lddi            @(gr28,#REG_GR(24)),gr24
955         lddi            @(gr28,#REG_GR(26)),gr26
956         ldi             @(gr28,#REG_GR(29)),gr29
957         lddi            @(gr28,#REG_GR(30)),gr30
958
959         # check to see if a debugging return is required
960         LEDS            0x67f0
961         movsg           ccr,gr2
962         ldi             @(gr28,#REG__STATUS),gr3
963         andicc          gr3,#REG__STATUS_STEP,gr0,icc0
964         bne             icc0,#0,__entry_return_singlestep
965         movgs           gr2,ccr
966
967         ldi             @(gr28,#REG_SP)    ,sp
968         lddi            @(gr28,#REG_GR(2)) ,gr2
969         ldi             @(gr28,#REG_GR(28)),gr28
970
971         LEDS            0x67fe
972 //      movsg           pcsr,gr31
973 //      LEDS32
974
975 #if 0
976         # store the current frame in the workram on the FR451
977         movgs           gr28,scr2
978         sethi.p         %hi(0xfe800000),gr28
979         setlo           %lo(0xfe800000),gr28
980
981         stdi            gr2,@(gr28,#REG_GR(2))
982         stdi            gr4,@(gr28,#REG_GR(4))
983         stdi            gr6,@(gr28,#REG_GR(6))
984         stdi            gr8,@(gr28,#REG_GR(8))
985         stdi            gr10,@(gr28,#REG_GR(10))
986         stdi            gr12,@(gr28,#REG_GR(12))
987         stdi            gr14,@(gr28,#REG_GR(14))
988         stdi            gr16,@(gr28,#REG_GR(16))
989         stdi            gr18,@(gr28,#REG_GR(18))
990         stdi            gr24,@(gr28,#REG_GR(24))
991         stdi            gr26,@(gr28,#REG_GR(26))
992         sti             gr29,@(gr28,#REG_GR(29))
993         stdi            gr30,@(gr28,#REG_GR(30))
994
995         movsg           tbr ,gr30
996         sti             gr30,@(gr28,#REG_TBR)
997         movsg           pcsr,gr30
998         sti             gr30,@(gr28,#REG_PC)
999         movsg           psr ,gr30
1000         sti             gr30,@(gr28,#REG_PSR)
1001         movsg           isr ,gr30
1002         sti             gr30,@(gr28,#REG_ISR)
1003         movsg           ccr ,gr30
1004         movsg           cccr,gr31
1005         stdi            gr30,@(gr28,#REG_CCR)
1006         movsg           lr  ,gr30
1007         movsg           lcr ,gr31
1008         stdi            gr30,@(gr28,#REG_LR)
1009         sti             gr0 ,@(gr28,#REG_SYSCALLNO)
1010         movsg           scr2,gr28
1011 #endif
1012
1013         rett            #0
1014
1015         # return via break.S
1016 __entry_return_singlestep:
1017         movgs           gr2,ccr
1018         lddi            @(gr28,#REG_GR(2)) ,gr2
1019         ldi             @(gr28,#REG_SP)    ,sp
1020         ldi             @(gr28,#REG_GR(28)),gr28
1021         LEDS            0x67ff
1022         break
1023         .globl          __entry_return_singlestep_breaks_here
1024 __entry_return_singlestep_breaks_here:
1025         nop
1026
1027
1028 ###############################################################################
1029 #
1030 # return to a process interrupted in kernel space
1031 # - we need to consider preemption if that is enabled
1032 #
1033 ###############################################################################
1034         .balign         L1_CACHE_BYTES
1035 __entry_return_from_kernel_exception:
1036         LEDS            0x6302
1037         movsg           psr,gr23
1038         ori             gr23,#PSR_PIL_14,gr23
1039         movgs           gr23,psr
1040         bra             __entry_return_direct
1041
1042         .balign         L1_CACHE_BYTES
1043 __entry_return_from_kernel_interrupt:
1044         LEDS            0x6303
1045         movsg           psr,gr23
1046         ori             gr23,#PSR_PIL_14,gr23
1047         movgs           gr23,psr
1048
1049 #ifdef CONFIG_PREEMPT
1050         ldi             @(gr15,#TI_PRE_COUNT),gr5
1051         subicc          gr5,#0,gr0,icc0
1052         beq             icc0,#0,__entry_return_direct
1053
1054 __entry_preempt_need_resched:
1055         ldi             @(gr15,#TI_FLAGS),gr4
1056         andicc          gr4,#_TIF_NEED_RESCHED,gr0,icc0
1057         beq             icc0,#1,__entry_return_direct
1058
1059         setlos          #PREEMPT_ACTIVE,gr5
1060         sti             gr5,@(gr15,#TI_FLAGS)
1061
1062         andi            gr23,#~PSR_PIL,gr23
1063         movgs           gr23,psr
1064
1065         call            schedule
1066         sti             gr0,@(gr15,#TI_PRE_COUNT)
1067
1068         movsg           psr,gr23
1069         ori             gr23,#PSR_PIL_14,gr23
1070         movgs           gr23,psr
1071         bra             __entry_preempt_need_resched
1072 #else
1073         bra             __entry_return_direct
1074 #endif
1075
1076
1077 ###############################################################################
1078 #
1079 # perform work that needs to be done immediately before resumption
1080 #
1081 ###############################################################################
1082         .globl          __entry_return_from_user_exception
1083         .balign         L1_CACHE_BYTES
1084 __entry_return_from_user_exception:
1085         LEDS            0x6501
1086
1087 __entry_resume_userspace:
1088         # make sure we don't miss an interrupt setting need_resched or sigpending between
1089         # sampling and the RETT
1090         movsg           psr,gr23
1091         ori             gr23,#PSR_PIL_14,gr23
1092         movgs           gr23,psr
1093
1094 __entry_return_from_user_interrupt:
1095         LEDS            0x6402
1096         ldi             @(gr15,#TI_FLAGS),gr4
1097         sethi.p         %hi(_TIF_WORK_MASK),gr5
1098         setlo           %lo(_TIF_WORK_MASK),gr5
1099         andcc           gr4,gr5,gr0,icc0
1100         beq             icc0,#1,__entry_return_direct
1101
1102 __entry_work_pending:
1103         LEDS            0x6404
1104         andicc          gr4,#_TIF_NEED_RESCHED,gr0,icc0
1105         beq             icc0,#1,__entry_work_notifysig
1106
1107 __entry_work_resched:
1108         LEDS            0x6408
1109         movsg           psr,gr23
1110         andi            gr23,#~PSR_PIL,gr23
1111         movgs           gr23,psr
1112         call            schedule
1113         movsg           psr,gr23
1114         ori             gr23,#PSR_PIL_14,gr23
1115         movgs           gr23,psr
1116
1117         LEDS            0x6401
1118         ldi             @(gr15,#TI_FLAGS),gr4
1119         sethi.p         %hi(_TIF_WORK_MASK),gr5
1120         setlo           %lo(_TIF_WORK_MASK),gr5
1121         andcc           gr4,gr5,gr0,icc0
1122         beq             icc0,#1,__entry_return_direct
1123         andicc          gr4,#_TIF_NEED_RESCHED,gr0,icc0
1124         bne             icc0,#1,__entry_work_resched
1125
1126 __entry_work_notifysig:
1127         LEDS            0x6410
1128         ori.p           gr4,#0,gr8
1129         call            do_notify_resume
1130         bra             __entry_resume_userspace
1131
1132         # perform syscall entry tracing
1133 __syscall_trace_entry:
1134         LEDS            0x6320
1135         setlos.p        #0,gr8
1136         call            do_syscall_trace
1137
1138         ldi             @(gr28,#REG_SYSCALLNO),gr7
1139         lddi            @(gr28,#REG_GR(8)) ,gr8
1140         lddi            @(gr28,#REG_GR(10)),gr10
1141         lddi.p          @(gr28,#REG_GR(12)),gr12
1142
1143         subicc          gr7,#nr_syscalls,gr0,icc0
1144         bnc             icc0,#0,__syscall_badsys
1145         bra             __syscall_call
1146
1147         # perform syscall exit tracing
1148 __syscall_exit_work:
1149         LEDS            0x6340
1150         andicc          gr4,#_TIF_SYSCALL_TRACE,gr0,icc0
1151         beq             icc0,#1,__entry_work_pending
1152
1153         movsg           psr,gr23
1154         andi            gr23,#~PSR_PIL,gr23     ; could let do_syscall_trace() call schedule()
1155         movgs           gr23,psr
1156
1157         setlos.p        #1,gr8
1158         call            do_syscall_trace
1159         bra             __entry_resume_userspace
1160
1161 __syscall_badsys:
1162         LEDS            0x6380
1163         setlos          #-ENOSYS,gr8
1164         sti             gr8,@(gr28,#REG_GR(8))  ; save return value
1165         bra             __entry_resume_userspace
1166
1167
1168 ###############################################################################
1169 #
1170 # syscall vector table
1171 #
1172 ###############################################################################
1173         .section .rodata
1174 ALIGN
1175         .globl          sys_call_table
1176 sys_call_table:
1177         .long sys_restart_syscall       /* 0 - old "setup()" system call, used for restarting */
1178         .long sys_exit
1179         .long sys_fork
1180         .long sys_read
1181         .long sys_write
1182         .long sys_open          /* 5 */
1183         .long sys_close
1184         .long sys_waitpid
1185         .long sys_creat
1186         .long sys_link
1187         .long sys_unlink                /* 10 */
1188         .long sys_execve
1189         .long sys_chdir
1190         .long sys_time
1191         .long sys_mknod
1192         .long sys_chmod         /* 15 */
1193         .long sys_lchown16
1194         .long sys_ni_syscall                    /* old break syscall holder */
1195         .long sys_stat
1196         .long sys_lseek
1197         .long sys_getpid                /* 20 */
1198         .long sys_mount
1199         .long sys_oldumount
1200         .long sys_setuid16
1201         .long sys_getuid16
1202         .long sys_ni_syscall // sys_stime               /* 25 */
1203         .long sys_ptrace
1204         .long sys_alarm
1205         .long sys_fstat
1206         .long sys_pause
1207         .long sys_utime         /* 30 */
1208         .long sys_ni_syscall                    /* old stty syscall holder */
1209         .long sys_ni_syscall                    /* old gtty syscall holder */
1210         .long sys_access
1211         .long sys_nice
1212         .long sys_ni_syscall    /* 35 */        /* old ftime syscall holder */
1213         .long sys_sync
1214         .long sys_kill
1215         .long sys_rename
1216         .long sys_mkdir
1217         .long sys_rmdir         /* 40 */
1218         .long sys_dup
1219         .long sys_pipe
1220         .long sys_times
1221         .long sys_ni_syscall                    /* old prof syscall holder */
1222         .long sys_brk           /* 45 */
1223         .long sys_setgid16
1224         .long sys_getgid16
1225         .long sys_ni_syscall // sys_signal
1226         .long sys_geteuid16
1227         .long sys_getegid16     /* 50 */
1228         .long sys_acct
1229         .long sys_umount                                /* recycled never used phys( */
1230         .long sys_ni_syscall                    /* old lock syscall holder */
1231         .long sys_ioctl
1232         .long sys_fcntl         /* 55 */
1233         .long sys_ni_syscall                    /* old mpx syscall holder */
1234         .long sys_setpgid
1235         .long sys_ni_syscall                    /* old ulimit syscall holder */
1236         .long sys_ni_syscall                    /* old old uname syscall */
1237         .long sys_umask         /* 60 */
1238         .long sys_chroot
1239         .long sys_ustat
1240         .long sys_dup2
1241         .long sys_getppid
1242         .long sys_getpgrp       /* 65 */
1243         .long sys_setsid
1244         .long sys_sigaction
1245         .long sys_ni_syscall // sys_sgetmask
1246         .long sys_ni_syscall // sys_ssetmask
1247         .long sys_setreuid16    /* 70 */
1248         .long sys_setregid16
1249         .long sys_sigsuspend
1250         .long sys_ni_syscall // sys_sigpending
1251         .long sys_sethostname
1252         .long sys_setrlimit     /* 75 */
1253         .long sys_ni_syscall // sys_old_getrlimit
1254         .long sys_getrusage
1255         .long sys_gettimeofday
1256         .long sys_settimeofday
1257         .long sys_getgroups16   /* 80 */
1258         .long sys_setgroups16
1259         .long sys_ni_syscall                    /* old_select slot */
1260         .long sys_symlink
1261         .long sys_lstat
1262         .long sys_readlink              /* 85 */
1263         .long sys_uselib
1264         .long sys_swapon
1265         .long sys_reboot
1266         .long sys_ni_syscall // old_readdir
1267         .long sys_ni_syscall    /* 90 */        /* old_mmap slot */
1268         .long sys_munmap
1269         .long sys_truncate
1270         .long sys_ftruncate
1271         .long sys_fchmod
1272         .long sys_fchown16              /* 95 */
1273         .long sys_getpriority
1274         .long sys_setpriority
1275         .long sys_ni_syscall                    /* old profil syscall holder */
1276         .long sys_statfs
1277         .long sys_fstatfs               /* 100 */
1278         .long sys_ni_syscall                    /* ioperm for i386 */
1279         .long sys_socketcall
1280         .long sys_syslog
1281         .long sys_setitimer
1282         .long sys_getitimer     /* 105 */
1283         .long sys_newstat
1284         .long sys_newlstat
1285         .long sys_newfstat
1286         .long sys_ni_syscall    /* obsolete olduname( syscall */
1287         .long sys_ni_syscall    /* iopl for i386 */ /* 110 */
1288         .long sys_vhangup
1289         .long sys_ni_syscall    /* obsolete idle( syscall */
1290         .long sys_ni_syscall    /* vm86old for i386 */
1291         .long sys_wait4
1292         .long sys_swapoff               /* 115 */
1293         .long sys_sysinfo
1294         .long sys_ipc
1295         .long sys_fsync
1296         .long sys_sigreturn
1297         .long sys_clone         /* 120 */
1298         .long sys_setdomainname
1299         .long sys_newuname
1300         .long sys_ni_syscall    /* old "cacheflush" */
1301         .long sys_adjtimex
1302         .long sys_mprotect      /* 125 */
1303         .long sys_sigprocmask
1304         .long sys_ni_syscall    /* old "create_module" */
1305         .long sys_init_module
1306         .long sys_delete_module
1307         .long sys_ni_syscall    /* old "get_kernel_syms" */
1308         .long sys_quotactl
1309         .long sys_getpgid
1310         .long sys_fchdir
1311         .long sys_bdflush
1312         .long sys_sysfs         /* 135 */
1313         .long sys_personality
1314         .long sys_ni_syscall    /* for afs_syscall */
1315         .long sys_setfsuid16
1316         .long sys_setfsgid16
1317         .long sys_llseek                /* 140 */
1318         .long sys_getdents
1319         .long sys_select
1320         .long sys_flock
1321         .long sys_msync
1322         .long sys_readv         /* 145 */
1323         .long sys_writev
1324         .long sys_getsid
1325         .long sys_fdatasync
1326         .long sys_sysctl
1327         .long sys_mlock         /* 150 */
1328         .long sys_munlock
1329         .long sys_mlockall
1330         .long sys_munlockall
1331         .long sys_sched_setparam
1332         .long sys_sched_getparam   /* 155 */
1333         .long sys_sched_setscheduler
1334         .long sys_sched_getscheduler
1335         .long sys_sched_yield
1336         .long sys_sched_get_priority_max
1337         .long sys_sched_get_priority_min  /* 160 */
1338         .long sys_sched_rr_get_interval
1339         .long sys_nanosleep
1340         .long sys_mremap
1341         .long sys_setresuid16
1342         .long sys_getresuid16   /* 165 */
1343         .long sys_ni_syscall    /* for vm86 */
1344         .long sys_ni_syscall    /* Old sys_query_module */
1345         .long sys_poll
1346         .long sys_nfsservctl
1347         .long sys_setresgid16   /* 170 */
1348         .long sys_getresgid16
1349         .long sys_prctl
1350         .long sys_rt_sigreturn
1351         .long sys_rt_sigaction
1352         .long sys_rt_sigprocmask        /* 175 */
1353         .long sys_rt_sigpending
1354         .long sys_rt_sigtimedwait
1355         .long sys_rt_sigqueueinfo
1356         .long sys_rt_sigsuspend
1357         .long sys_pread64               /* 180 */
1358         .long sys_pwrite64
1359         .long sys_chown16
1360         .long sys_getcwd
1361         .long sys_capget
1362         .long sys_capset           /* 185 */
1363         .long sys_sigaltstack
1364         .long sys_sendfile
1365         .long sys_ni_syscall            /* streams1 */
1366         .long sys_ni_syscall            /* streams2 */
1367         .long sys_vfork            /* 190 */
1368         .long sys_getrlimit
1369         .long sys_mmap2
1370         .long sys_truncate64
1371         .long sys_ftruncate64
1372         .long sys_stat64                /* 195 */
1373         .long sys_lstat64
1374         .long sys_fstat64
1375         .long sys_lchown
1376         .long sys_getuid
1377         .long sys_getgid                /* 200 */
1378         .long sys_geteuid
1379         .long sys_getegid
1380         .long sys_setreuid
1381         .long sys_setregid
1382         .long sys_getgroups     /* 205 */
1383         .long sys_setgroups
1384         .long sys_fchown
1385         .long sys_setresuid
1386         .long sys_getresuid
1387         .long sys_setresgid     /* 210 */
1388         .long sys_getresgid
1389         .long sys_chown
1390         .long sys_setuid
1391         .long sys_setgid
1392         .long sys_setfsuid              /* 215 */
1393         .long sys_setfsgid
1394         .long sys_pivot_root
1395         .long sys_mincore
1396         .long sys_madvise
1397         .long sys_getdents64    /* 220 */
1398         .long sys_fcntl64
1399         .long sys_ni_syscall    /* reserved for TUX */
1400         .long sys_ni_syscall    /* Reserved for Security */
1401         .long sys_gettid
1402         .long sys_readahead     /* 225 */
1403         .long sys_setxattr
1404         .long sys_lsetxattr
1405         .long sys_fsetxattr
1406         .long sys_getxattr
1407         .long sys_lgetxattr     /* 230 */
1408         .long sys_fgetxattr
1409         .long sys_listxattr
1410         .long sys_llistxattr
1411         .long sys_flistxattr
1412         .long sys_removexattr   /* 235 */
1413         .long sys_lremovexattr
1414         .long sys_fremovexattr
1415         .long sys_tkill
1416         .long sys_sendfile64
1417         .long sys_futex         /* 240 */
1418         .long sys_sched_setaffinity
1419         .long sys_sched_getaffinity
1420         .long sys_ni_syscall    //sys_set_thread_area
1421         .long sys_ni_syscall    //sys_get_thread_area
1422         .long sys_io_setup      /* 245 */
1423         .long sys_io_destroy
1424         .long sys_io_getevents
1425         .long sys_io_submit
1426         .long sys_io_cancel
1427         .long sys_fadvise64     /* 250 */
1428         .long sys_ni_syscall
1429         .long sys_exit_group
1430         .long sys_lookup_dcookie
1431         .long sys_epoll_create
1432         .long sys_epoll_ctl     /* 255 */
1433         .long sys_epoll_wait
1434         .long sys_remap_file_pages
1435         .long sys_set_tid_address
1436         .long sys_timer_create
1437         .long sys_timer_settime         /* 260 */
1438         .long sys_timer_gettime
1439         .long sys_timer_getoverrun
1440         .long sys_timer_delete
1441         .long sys_clock_settime
1442         .long sys_clock_gettime         /* 265 */
1443         .long sys_clock_getres
1444         .long sys_clock_nanosleep
1445         .long sys_statfs64
1446         .long sys_fstatfs64
1447         .long sys_tgkill        /* 270 */
1448         .long sys_utimes
1449         .long sys_fadvise64_64
1450         .long sys_ni_syscall    /* sys_vserver */
1451         .long sys_mbind
1452         .long sys_get_mempolicy
1453         .long sys_set_mempolicy
1454         .long sys_mq_open
1455         .long sys_mq_unlink
1456         .long sys_mq_timedsend
1457         .long sys_mq_timedreceive       /* 280 */
1458         .long sys_mq_notify
1459         .long sys_mq_getsetattr
1460         .long sys_ni_syscall            /* reserved for kexec */
1461         .long sys_waitid
1462         .long sys_ni_syscall            /* 285 */ /* available */
1463         .long sys_add_key
1464         .long sys_request_key
1465         .long sys_keyctl
1466         .long sys_ioprio_set
1467         .long sys_ioprio_get            /* 290 */
1468         .long sys_inotify_init
1469         .long sys_inotify_add_watch
1470         .long sys_inotify_rm_watch
1471         .long sys_migrate_pages
1472         .long sys_openat                /* 295 */
1473         .long sys_mkdirat
1474         .long sys_mknodat
1475         .long sys_fchownat
1476         .long sys_futimesat
1477         .long sys_fstatat64             /* 300 */
1478         .long sys_unlinkat
1479         .long sys_renameat
1480         .long sys_linkat
1481         .long sys_symlinkat
1482         .long sys_readlinkat            /* 305 */
1483         .long sys_fchmodat
1484         .long sys_faccessat
1485         .long sys_pselect6
1486         .long sys_ppoll
1487
1488
1489 syscall_table_size = (. - sys_call_table)