1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#include <linux/sys.h>
16#include <linux/linkage.h>
17#include <asm/smp.h>
18#include <asm/irqflags.h>
19#include <asm/thread_info.h>
20#include <asm/intctl-regs.h>
21#include <asm/busctl-regs.h>
22#include <asm/timer-regs.h>
23#include <unit/leds.h>
24#include <asm/page.h>
25#include <asm/pgtable.h>
26#include <asm/errno.h>
27#include <asm/asm-offsets.h>
28#include <asm/frame.inc>
29
30
31#include <asm/gdb-stub.h>
32#endif
33
34#ifdef CONFIG_PREEMPT
35#define preempt_stop LOCAL_IRQ_DISABLE
36#else
37#define preempt_stop
38#define resume_kernel restore_all
39#endif
40
41 .am33_2
42
43
44
45
46
47
48
49ENTRY(ret_from_fork)
50 call schedule_tail[],0
51 GET_THREAD_INFO a2
52
53
54 clr d0
55 mov d0,(REG_D0,fp)
56 jmp syscall_exit
57
58ENTRY(ret_from_kernel_thread)
59 call schedule_tail[],0
60 mov (REG_D0,fp),d0
61 mov (REG_A0,fp),a0
62 calls (a0)
63 GET_THREAD_INFO a2
64 clr d0
65 mov d0,(REG_D0,fp)
66 jmp syscall_exit
67
68
69
70
71
72
73ENTRY(system_call)
74 add -4,sp
75 SAVE_ALL
76 mov d0,(REG_ORIG_D0,fp)
77 GET_THREAD_INFO a2
78 cmp nr_syscalls,d0
79 bcc syscall_badsys
80 btst _TIF_SYSCALL_TRACE,(TI_flags,a2)
81 bne syscall_entry_trace
82syscall_call:
83 add d0,d0,a1
84 add a1,a1
85 mov (REG_A0,fp),d0
86 mov (sys_call_table,a1),a0
87 calls (a0)
88 mov d0,(REG_D0,fp)
89syscall_exit:
90
91
92 LOCAL_IRQ_DISABLE
93 mov (TI_flags,a2),d2
94 btst _TIF_ALLWORK_MASK,d2
95 bne syscall_exit_work
96restore_all:
97 RESTORE_ALL
98
99
100
101
102
103
104
105 ALIGN
106syscall_exit_work:
107 mov (REG_EPSW,fp),d0
108 and EPSW_nSL,d0
109 beq resume_kernel
110
111 LOCAL_IRQ_ENABLE
112
113 btst _TIF_SYSCALL_TRACE,d2
114 beq work_pending
115 mov fp,d0
116 call syscall_trace_exit[],0
117 jmp resume_userspace
118
119 ALIGN
120work_pending:
121 btst _TIF_NEED_RESCHED,d2
122 beq work_notifysig
123
124work_resched:
125 call schedule[],0
126
127resume_userspace:
128
129
130 LOCAL_IRQ_DISABLE
131
132
133 mov (TI_flags,a2),d2
134 btst _TIF_WORK_MASK,d2
135 beq restore_all
136
137 LOCAL_IRQ_ENABLE
138 btst _TIF_NEED_RESCHED,d2
139 bne work_resched
140
141
142work_notifysig:
143 mov fp,d0
144 mov d2,d1
145 call do_notify_resume[],0
146 jmp resume_userspace
147
148
149syscall_entry_trace:
150 mov -ENOSYS,d0
151 mov d0,(REG_D0,fp)
152 mov fp,d0
153 call syscall_trace_entry[],0
154 mov (REG_D1,fp),d1
155 cmp nr_syscalls,d0
156 bcs syscall_call
157 jmp syscall_exit
158
159syscall_badsys:
160 mov -ENOSYS,d0
161 mov d0,(REG_D0,fp)
162 jmp resume_userspace
163
164
165 .globl ret_from_exception, ret_from_intr
166 ALIGN
167ret_from_exception:
168 preempt_stop
169ret_from_intr:
170 GET_THREAD_INFO a2
171 mov (REG_EPSW,fp),d0
172
173 and EPSW_nSL,d0
174 beq resume_kernel
175
176#ifdef CONFIG_PREEMPT
177ENTRY(resume_kernel)
178 LOCAL_IRQ_DISABLE
179 mov (TI_preempt_count,a2),d0
180 cmp 0,d0
181 bne restore_all
182
183need_resched:
184 btst _TIF_NEED_RESCHED,(TI_flags,a2)
185 beq restore_all
186 mov (REG_EPSW,fp),d0
187 and EPSW_IM,d0
188 cmp EPSW_IM_7,d0
189 bne restore_all
190 call preempt_schedule_irq[],0
191 jmp need_resched
192#endif
193
194
195
196
197
198
199
200
201ENTRY(irq_handler)
202 add -4,sp
203 SAVE_ALL
204
205
206 mov 0xffffffff,d0
207 mov d0,(REG_ORIG_D0,fp)
208
209 mov fp,d0
210 call do_IRQ[],0
211
212 jmp ret_from_intr
213
214
215
216
217
218
219
220 .section .bss
221 .balign THREAD_SIZE
222 .space THREAD_SIZE
223__df_stack:
224 .previous
225
226ENTRY(double_fault)
227 mov a0,(__df_stack-4)
228 mov d0,(__df_stack-8)
229 mn10300_set_dbfleds
230 mov 0xaa55aa55,d0
231 mov d0,(__df_stack-12)
232 mov sp,a0
233 mov __df_stack-12,sp
234 SAVE_ALL
235 mov a0,(REG_A0,fp)
236
237 mov fp,d0
238 calls do_double_fault
239double_fault_loop:
240 bra double_fault_loop
241
242
243
244
245
246
247
248ENTRY(raw_bus_error)
249 add -4,sp
250 mov d0,(sp)
251
252 mov (MMUCTR),d0
253 mov d0,(MMUCTR)
254#endif
255 mov (BCBERR),d0
256 btst BCBERR_BEMR_DMA,d0
257 beq __common_exception_aux
258
259 SAVE_ALL
260 mov (BCBEAR),d1
261
262 mov (REG_ORIG_D0,fp),d2
263 mov d2,(REG_D0,fp)
264 mov -1,d2
265 mov d2,(REG_ORIG_D0,fp)
266
267 add -4,sp
268 mov fp,(12,sp)
269 call io_bus_error[],0
270 jmp restore_all
271
272
273
274
275
276
277
278
279
280
281ENTRY(nmi_handler)
282 add -4,sp
283 mov d0,(sp)
284 mov (TBR),d0
285
286#ifdef CONFIG_SMP
287 add -4,sp
288 mov d0,(sp)
289 movhu (NMIAGR),d0
290 and NMIAGR_GN,d0
291 lsr 0x2,d0
292 cmp CALL_FUNCTION_NMI_IPI,d0
293 bne nmi_not_smp_callfunc
294
295
296 add 4,sp
297 mov GxICR_DETECT,d0
298 movbu d0,(GxICR(CALL_FUNCTION_NMI_IPI))
299 movhu (GxICR(CALL_FUNCTION_NMI_IPI)),d0
300 and ~EPSW_NMID,epsw
301
302 mov (sp),d0
303 SAVE_ALL
304 call smp_nmi_call_function_interrupt[],0
305 RESTORE_ALL
306
307nmi_not_smp_callfunc:
308#ifdef CONFIG_KERNEL_DEBUGGER
309 cmp DEBUGGER_NMI_IPI,d0
310 bne nmi_not_debugger
311
312
313 add 4,sp
314 mov GxICR_DETECT,d0
315 movbu d0,(GxICR(DEBUGGER_NMI_IPI))
316 movhu (GxICR(DEBUGGER_NMI_IPI)),d0
317 and ~EPSW_NMID,epsw
318
319 mov (sp),d0
320 SAVE_ALL
321 mov fp,d0
322 mov a2,d1
323 call debugger_nmi_interrupt[],0
324 RESTORE_ALL
325
326nmi_not_debugger:
327#endif
328 mov (sp),d0
329 add 4,sp
330#endif
331
332 bra __common_exception_nonmi
333
334
335
336
337
338
339ENTRY(__common_exception)
340 add -4,sp
341 mov d0,(sp)
342
343 mov (MMUCTR),d0
344 mov d0,(MMUCTR)
345#endif
346
347__common_exception_aux:
348 mov (TBR),d0
349 and ~EPSW_NMID,epsw
350 or EPSW_IE,epsw
351
352__common_exception_nonmi:
353 and 0x0000FFFF,d0
354
355
356 btst 0x00000007,d0
357 bne 1f
358 cmp 0x00000400,d0
359 bge 1f
360
361 SAVE_ALL
362
363 mov (REG_D0,fp),a2
364 mov (REG_ORIG_D0,fp),d0
365 mov d0,(REG_D0,fp)
366 mov -1,d0
367 mov d0,(REG_ORIG_D0,fp)
368
369#ifdef CONFIG_GDBSTUB
370#ifdef CONFIG_SMP
371 call gdbstub_busy_check[],0
372 and d0,d0
373 beq 2f
374#else
375 btst 0x01,(gdbstub_busy)
376 beq 2f
377#endif
378 and ~EPSW_IE,epsw
379 mov fp,d0
380 mov a2,d1
381 call gdbstub_exception[],0
382 bra restore_all
3832:
384#endif
385
386 mov fp,d0
387 mov a2,d1
388 lsr 1,a2
389
390 mov (exception_table,a2),a2
391 calls (a2)
392 jmp ret_from_exception
393
3941: pi
395
396
397
398
399
400
401 .data
402ENTRY(exception_table)
403 .rept 0x400>>1
404 .long uninitialised_exception
405 .endr
406 .previous
407
408
409
410
411
412
413
414ENTRY(set_excp_vector)
415 lsr 1,d0
416 add exception_table,d0
417 mov d1,(d0)
418 mov 4,d1
419 ret [],0
420
421
422
423
424
425
426 .data
427ENTRY(sys_call_table)
428 .long sys_restart_syscall
429 .long sys_exit
430 .long sys_fork
431 .long sys_read
432 .long sys_write
433 .long sys_open
434 .long sys_close
435 .long sys_waitpid
436 .long sys_creat
437 .long sys_link
438 .long sys_unlink
439 .long sys_execve
440 .long sys_chdir
441 .long sys_time
442 .long sys_mknod
443 .long sys_chmod
444 .long sys_lchown16
445 .long sys_ni_syscall
446 .long sys_stat
447 .long sys_lseek
448 .long sys_getpid
449 .long sys_mount
450 .long sys_oldumount
451 .long sys_setuid16
452 .long sys_getuid16
453 .long sys_stime
454 .long sys_ptrace
455 .long sys_alarm
456 .long sys_fstat
457 .long sys_pause
458 .long sys_utime
459 .long sys_ni_syscall
460 .long sys_ni_syscall
461 .long sys_access
462 .long sys_nice
463 .long sys_ni_syscall
464 .long sys_sync
465 .long sys_kill
466 .long sys_rename
467 .long sys_mkdir
468 .long sys_rmdir
469 .long sys_dup
470 .long sys_pipe
471 .long sys_times
472 .long sys_ni_syscall
473 .long sys_brk
474 .long sys_setgid16
475 .long sys_getgid16
476 .long sys_signal
477 .long sys_geteuid16
478 .long sys_getegid16
479 .long sys_acct
480 .long sys_umount
481 .long sys_ni_syscall
482 .long sys_ioctl
483 .long sys_fcntl
484 .long sys_ni_syscall
485 .long sys_setpgid
486 .long sys_ni_syscall
487 .long sys_ni_syscall
488 .long sys_umask
489 .long sys_chroot
490 .long sys_ustat
491 .long sys_dup2
492 .long sys_getppid
493 .long sys_getpgrp
494 .long sys_setsid
495 .long sys_sigaction
496 .long sys_sgetmask
497 .long sys_ssetmask
498 .long sys_setreuid16
499 .long sys_setregid16
500 .long sys_sigsuspend
501 .long sys_sigpending
502 .long sys_sethostname
503 .long sys_setrlimit
504 .long sys_old_getrlimit
505 .long sys_getrusage
506 .long sys_gettimeofday
507 .long sys_settimeofday
508 .long sys_getgroups16
509 .long sys_setgroups16
510 .long sys_old_select
511 .long sys_symlink
512 .long sys_lstat
513 .long sys_readlink
514 .long sys_uselib
515 .long sys_swapon
516 .long sys_reboot
517 .long sys_old_readdir
518 .long old_mmap
519 .long sys_munmap
520 .long sys_truncate
521 .long sys_ftruncate
522 .long sys_fchmod
523 .long sys_fchown16
524 .long sys_getpriority
525 .long sys_setpriority
526 .long sys_ni_syscall
527 .long sys_statfs
528 .long sys_fstatfs
529 .long sys_ni_syscall
530 .long sys_socketcall
531 .long sys_syslog
532 .long sys_setitimer
533 .long sys_getitimer
534 .long sys_newstat
535 .long sys_newlstat
536 .long sys_newfstat
537 .long sys_ni_syscall
538 .long sys_ni_syscall
539 .long sys_vhangup
540 .long sys_ni_syscall
541 .long sys_ni_syscall
542 .long sys_wait4
543 .long sys_swapoff
544 .long sys_sysinfo
545 .long sys_ipc
546 .long sys_fsync
547 .long sys_sigreturn
548 .long sys_clone
549 .long sys_setdomainname
550 .long sys_newuname
551 .long sys_ni_syscall
552 .long sys_adjtimex
553 .long sys_mprotect
554 .long sys_sigprocmask
555 .long sys_ni_syscall
556 .long sys_init_module
557 .long sys_delete_module
558 .long sys_ni_syscall
559 .long sys_quotactl
560 .long sys_getpgid
561 .long sys_fchdir
562 .long sys_bdflush
563 .long sys_sysfs
564 .long sys_personality
565 .long sys_ni_syscall
566 .long sys_setfsuid16
567 .long sys_setfsgid16
568 .long sys_llseek
569 .long sys_getdents
570 .long sys_select
571 .long sys_flock
572 .long sys_msync
573 .long sys_readv
574 .long sys_writev
575 .long sys_getsid
576 .long sys_fdatasync
577 .long sys_sysctl
578 .long sys_mlock
579 .long sys_munlock
580 .long sys_mlockall
581 .long sys_munlockall
582 .long sys_sched_setparam
583 .long sys_sched_getparam
584 .long sys_sched_setscheduler
585 .long sys_sched_getscheduler
586 .long sys_sched_yield
587 .long sys_sched_get_priority_max
588 .long sys_sched_get_priority_min
589 .long sys_sched_rr_get_interval
590 .long sys_nanosleep
591 .long sys_mremap
592 .long sys_setresuid16
593 .long sys_getresuid16
594 .long sys_ni_syscall
595 .long sys_ni_syscall
596 .long sys_poll
597 .long sys_ni_syscall
598 .long sys_setresgid16
599 .long sys_getresgid16
600 .long sys_prctl
601 .long sys_rt_sigreturn
602 .long sys_rt_sigaction
603 .long sys_rt_sigprocmask
604 .long sys_rt_sigpending
605 .long sys_rt_sigtimedwait
606 .long sys_rt_sigqueueinfo
607 .long sys_rt_sigsuspend
608 .long sys_pread64
609 .long sys_pwrite64
610 .long sys_chown16
611 .long sys_getcwd
612 .long sys_capget
613 .long sys_capset
614 .long sys_sigaltstack
615 .long sys_sendfile
616 .long sys_ni_syscall
617 .long sys_ni_syscall
618 .long sys_vfork
619 .long sys_getrlimit
620 .long sys_mmap_pgoff
621 .long sys_truncate64
622 .long sys_ftruncate64
623 .long sys_stat64
624 .long sys_lstat64
625 .long sys_fstat64
626 .long sys_lchown
627 .long sys_getuid
628 .long sys_getgid
629 .long sys_geteuid
630 .long sys_getegid
631 .long sys_setreuid
632 .long sys_setregid
633 .long sys_getgroups
634 .long sys_setgroups
635 .long sys_fchown
636 .long sys_setresuid
637 .long sys_getresuid
638 .long sys_setresgid
639 .long sys_getresgid
640 .long sys_chown
641 .long sys_setuid
642 .long sys_setgid
643 .long sys_setfsuid
644 .long sys_setfsgid
645 .long sys_pivot_root
646 .long sys_mincore
647 .long sys_madvise
648 .long sys_getdents64
649 .long sys_fcntl64
650 .long sys_ni_syscall
651 .long sys_ni_syscall
652 .long sys_gettid
653 .long sys_readahead
654 .long sys_setxattr
655 .long sys_lsetxattr
656 .long sys_fsetxattr
657 .long sys_getxattr
658 .long sys_lgetxattr
659 .long sys_fgetxattr
660 .long sys_listxattr
661 .long sys_llistxattr
662 .long sys_flistxattr
663 .long sys_removexattr
664 .long sys_lremovexattr
665 .long sys_fremovexattr
666 .long sys_tkill
667 .long sys_sendfile64
668 .long sys_futex
669 .long sys_sched_setaffinity
670 .long sys_sched_getaffinity
671 .long sys_ni_syscall
672 .long sys_ni_syscall
673 .long sys_io_setup
674 .long sys_io_destroy
675 .long sys_io_getevents
676 .long sys_io_submit
677 .long sys_io_cancel
678 .long sys_fadvise64
679 .long sys_ni_syscall
680 .long sys_exit_group
681 .long sys_lookup_dcookie
682 .long sys_epoll_create
683 .long sys_epoll_ctl
684 .long sys_epoll_wait
685 .long sys_remap_file_pages
686 .long sys_set_tid_address
687 .long sys_timer_create
688 .long sys_timer_settime
689 .long sys_timer_gettime
690 .long sys_timer_getoverrun
691 .long sys_timer_delete
692 .long sys_clock_settime
693 .long sys_clock_gettime
694 .long sys_clock_getres
695 .long sys_clock_nanosleep
696 .long sys_statfs64
697 .long sys_fstatfs64
698 .long sys_tgkill
699 .long sys_utimes
700 .long sys_fadvise64_64
701 .long sys_ni_syscall
702 .long sys_mbind
703 .long sys_get_mempolicy
704 .long sys_set_mempolicy
705 .long sys_mq_open
706 .long sys_mq_unlink
707 .long sys_mq_timedsend
708 .long sys_mq_timedreceive
709 .long sys_mq_notify
710 .long sys_mq_getsetattr
711 .long sys_kexec_load
712 .long sys_waitid
713 .long sys_ni_syscall
714 .long sys_add_key
715 .long sys_request_key
716 .long sys_keyctl
717 .long sys_cacheflush
718 .long sys_ioprio_set
719 .long sys_ioprio_get
720 .long sys_inotify_init
721 .long sys_inotify_add_watch
722 .long sys_inotify_rm_watch
723 .long sys_migrate_pages
724 .long sys_openat
725 .long sys_mkdirat
726 .long sys_mknodat
727 .long sys_fchownat
728 .long sys_futimesat
729 .long sys_fstatat64
730 .long sys_unlinkat
731 .long sys_renameat
732 .long sys_linkat
733 .long sys_symlinkat
734 .long sys_readlinkat
735 .long sys_fchmodat
736 .long sys_faccessat
737 .long sys_pselect6
738 .long sys_ppoll
739 .long sys_unshare
740 .long sys_set_robust_list
741 .long sys_get_robust_list
742 .long sys_splice
743 .long sys_sync_file_range
744 .long sys_tee
745 .long sys_vmsplice
746 .long sys_move_pages
747 .long sys_getcpu
748 .long sys_epoll_pwait
749 .long sys_utimensat
750 .long sys_signalfd
751 .long sys_timerfd_create
752 .long sys_eventfd
753 .long sys_fallocate
754 .long sys_timerfd_settime
755 .long sys_timerfd_gettime
756 .long sys_signalfd4
757 .long sys_eventfd2
758 .long sys_epoll_create1
759 .long sys_dup3
760 .long sys_pipe2
761 .long sys_inotify_init1
762 .long sys_preadv
763 .long sys_pwritev
764 .long sys_rt_tgsigqueueinfo
765 .long sys_perf_event_open
766 .long sys_recvmmsg
767 .long sys_setns
768
769
770nr_syscalls=(.-sys_call_table)/4
771