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