aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mn10300/kernel/entry.S
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-02-08 07:19:31 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 12:22:30 -0500
commitb920de1b77b72ca9432ac3f97edb26541e65e5dd (patch)
tree40fa9be1470e929c47927dea7eddf184c0204229 /arch/mn10300/kernel/entry.S
parentef3d534754f31fed9c3b976fee1ece1b3bc38282 (diff)
mn10300: add the MN10300/AM33 architecture to the kernel
Add architecture support for the MN10300/AM33 CPUs produced by MEI to the kernel. This patch also adds board support for the ASB2303 with the ASB2308 daughter board, and the ASB2305. The only processor supported is the MN103E010, which is an AM33v2 core plus on-chip devices. [akpm@linux-foundation.org: nuke cvs control strings] Signed-off-by: Masakazu Urade <urade.masakazu@jp.panasonic.com> Signed-off-by: Koichi Yasutake <yasutake.koichi@jp.panasonic.com> Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/mn10300/kernel/entry.S')
-rw-r--r--arch/mn10300/kernel/entry.S721
1 files changed, 721 insertions, 0 deletions
diff --git a/arch/mn10300/kernel/entry.S b/arch/mn10300/kernel/entry.S
new file mode 100644
index 000000000000..11de3606eee6
--- /dev/null
+++ b/arch/mn10300/kernel/entry.S
@@ -0,0 +1,721 @@
1###############################################################################
2#
3# MN10300 Exception and interrupt entry points
4#
5# Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
6# Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
7# Modified by David Howells (dhowells@redhat.com)
8#
9# This program is free software; you can redistribute it and/or
10# modify it under the terms of the GNU General Public Licence
11# as published by the Free Software Foundation; either version
12# 2 of the Licence, or (at your option) any later version.
13#
14###############################################################################
15#include <linux/sys.h>
16#include <linux/linkage.h>
17#include <asm/smp.h>
18#include <asm/system.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 <asm/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#ifdef CONFIG_PREEMPT
31#define preempt_stop __cli
32#else
33#define preempt_stop
34#define resume_kernel restore_all
35#endif
36
37 .macro __cli
38 and ~EPSW_IM,epsw
39 or EPSW_IE|MN10300_CLI_LEVEL,epsw
40 nop
41 nop
42 nop
43 .endm
44 .macro __sti
45 or EPSW_IE|EPSW_IM_7,epsw
46 .endm
47
48
49 .am33_2
50
51###############################################################################
52#
53# the return path for a forked child
54# - on entry, D0 holds the address of the previous task to run
55#
56###############################################################################
57ENTRY(ret_from_fork)
58 call schedule_tail[],0
59 GET_THREAD_INFO a2
60
61 # return 0 to indicate child process
62 clr d0
63 mov d0,(REG_D0,fp)
64 jmp syscall_exit
65
66###############################################################################
67#
68# system call handler
69#
70###############################################################################
71ENTRY(system_call)
72 add -4,sp
73 SAVE_ALL
74 mov d0,(REG_ORIG_D0,fp)
75 GET_THREAD_INFO a2
76 cmp nr_syscalls,d0
77 bcc syscall_badsys
78 btst _TIF_SYSCALL_TRACE,(TI_flags,a2)
79 bne syscall_trace_entry
80syscall_call:
81 add d0,d0,a1
82 add a1,a1
83 mov (REG_A0,fp),d0
84 mov (sys_call_table,a1),a0
85 calls (a0)
86 mov d0,(REG_D0,fp)
87syscall_exit:
88 # make sure we don't miss an interrupt setting need_resched or
89 # sigpending between sampling and the rti
90 __cli
91 mov (TI_flags,a2),d2
92 btst _TIF_ALLWORK_MASK,d2
93 bne syscall_exit_work
94restore_all:
95 RESTORE_ALL
96
97###############################################################################
98#
99# perform work that needs to be done immediately before resumption and syscall
100# tracing
101#
102###############################################################################
103 ALIGN
104syscall_exit_work:
105 btst _TIF_SYSCALL_TRACE,d2
106 beq work_pending
107 __sti # could let do_syscall_trace() call
108 # schedule() instead
109 mov fp,d0
110 mov 1,d1
111 call do_syscall_trace[],0 # do_syscall_trace(regs,entryexit)
112 jmp resume_userspace
113
114 ALIGN
115work_pending:
116 btst _TIF_NEED_RESCHED,d2
117 beq work_notifysig
118
119work_resched:
120 call schedule[],0
121
122 # make sure we don't miss an interrupt setting need_resched or
123 # sigpending between sampling and the rti
124 __cli
125
126 # is there any work to be done other than syscall tracing?
127 mov (TI_flags,a2),d2
128 btst _TIF_WORK_MASK,d2
129 beq restore_all
130 btst _TIF_NEED_RESCHED,d2
131 bne work_resched
132
133 # deal with pending signals and notify-resume requests
134work_notifysig:
135 mov fp,d0
136 mov d2,d1
137 call do_notify_resume[],0
138 jmp resume_userspace
139
140 # perform syscall entry tracing
141syscall_trace_entry:
142 mov -ENOSYS,d0
143 mov d0,(REG_D0,fp)
144 mov fp,d0
145 clr d1
146 call do_syscall_trace[],0
147 mov (REG_ORIG_D0,fp),d0
148 mov (REG_D1,fp),d1
149 cmp nr_syscalls,d0
150 bcs syscall_call
151 jmp syscall_exit
152
153syscall_badsys:
154 mov -ENOSYS,d0
155 mov d0,(REG_D0,fp)
156 jmp resume_userspace
157
158 # userspace resumption stub bypassing syscall exit tracing
159 .globl ret_from_exception, ret_from_intr
160 ALIGN
161ret_from_exception:
162 preempt_stop
163ret_from_intr:
164 GET_THREAD_INFO a2
165 mov (REG_EPSW,fp),d0 # need to deliver signals before
166 # returning to userspace
167 and EPSW_nSL,d0
168 beq resume_kernel # returning to supervisor mode
169
170ENTRY(resume_userspace)
171 # make sure we don't miss an interrupt setting need_resched or
172 # sigpending between sampling and the rti
173 __cli
174
175 # is there any work to be done on int/exception return?
176 mov (TI_flags,a2),d2
177 btst _TIF_WORK_MASK,d2
178 bne work_pending
179 jmp restore_all
180
181#ifdef CONFIG_PREEMPT
182ENTRY(resume_kernel)
183 mov (TI_preempt_count,a2),d0 # non-zero preempt_count ?
184 cmp 0,d0
185 bne restore_all
186
187need_resched:
188 btst _TIF_NEED_RESCHED,(TI_flags,a2)
189 beq restore_all
190 mov (REG_EPSW,fp),d0
191 and EPSW_IM,d0
192 cmp EPSW_IM_7,d0 # interrupts off (exception path) ?
193 beq restore_all
194 call preempt_schedule_irq[],0
195 jmp need_resched
196#endif
197
198
199###############################################################################
200#
201# IRQ handler entry point
202# - intended to be entered at multiple priorities
203#
204###############################################################################
205ENTRY(irq_handler)
206 add -4,sp
207 SAVE_ALL
208
209 # it's not a syscall
210 mov 0xffffffff,d0
211 mov d0,(REG_ORIG_D0,fp)
212
213 mov fp,d0
214 call do_IRQ[],0 # do_IRQ(regs)
215
216 jmp ret_from_intr
217
218###############################################################################
219#
220# Monitor Signal handler entry point
221#
222###############################################################################
223ENTRY(monitor_signal)
224 movbu (0xae000001),d1
225 cmp 1,d1
226 beq monsignal
227 ret [],0
228
229monsignal:
230 or EPSW_NMID,epsw
231 mov d0,a0
232 mov a0,sp
233 mov (REG_EPSW,fp),d1
234 and ~EPSW_nSL,d1
235 mov d1,(REG_EPSW,fp)
236 movm (sp),[d2,d3,a2,a3,exreg0,exreg1,exother]
237 mov (sp),a1
238 mov a1,usp
239 movm (sp),[other]
240 add 4,sp
241here: jmp 0x8e000008-here+0x8e000008
242
243###############################################################################
244#
245# Double Fault handler entry point
246# - note that there will not be a stack, D0/A0 will hold EPSW/PC as were
247#
248###############################################################################
249 .section .bss
250 .balign THREAD_SIZE
251 .space THREAD_SIZE
252__df_stack:
253 .previous
254
255ENTRY(double_fault)
256 mov a0,(__df_stack-4) # PC as was
257 mov d0,(__df_stack-8) # EPSW as was
258 mn10300_set_dbfleds # display 'db-f' on the LEDs
259 mov 0xaa55aa55,d0
260 mov d0,(__df_stack-12) # no ORIG_D0
261 mov sp,a0 # save corrupted SP
262 mov __df_stack-12,sp # emergency supervisor stack
263 SAVE_ALL
264 mov a0,(REG_A0,fp) # save corrupted SP as A0 (which got
265 # clobbered by the CPU)
266 mov fp,d0
267 calls do_double_fault
268double_fault_loop:
269 bra double_fault_loop
270
271###############################################################################
272#
273# Bus Error handler entry point
274# - handle external (async) bus errors separately
275#
276###############################################################################
277ENTRY(raw_bus_error)
278 add -4,sp
279 mov d0,(sp)
280 mov (BCBERR),d0 # what
281 btst BCBERR_BEMR_DMA,d0 # see if it was an external bus error
282 beq __common_exception_aux # it wasn't
283
284 SAVE_ALL
285 mov (BCBEAR),d1 # destination of erroneous access
286
287 mov (REG_ORIG_D0,fp),d2
288 mov d2,(REG_D0,fp)
289 mov -1,d2
290 mov d2,(REG_ORIG_D0,fp)
291
292 add -4,sp
293 mov fp,(12,sp) # frame pointer
294 call io_bus_error[],0
295 jmp restore_all
296
297###############################################################################
298#
299# Miscellaneous exception entry points
300#
301###############################################################################
302ENTRY(nmi_handler)
303 add -4,sp
304 mov d0,(sp)
305 mov (TBR),d0
306 bra __common_exception_nonmi
307
308ENTRY(__common_exception)
309 add -4,sp
310 mov d0,(sp)
311
312__common_exception_aux:
313 mov (TBR),d0
314 and ~EPSW_NMID,epsw # turn NMIs back on if not NMI
315 or EPSW_IE,epsw
316
317__common_exception_nonmi:
318 and 0x0000FFFF,d0 # turn the exception code into a vector
319 # table index
320
321 btst 0x00000007,d0
322 bne 1f
323 cmp 0x00000400,d0
324 bge 1f
325
326 SAVE_ALL # build the stack frame
327
328 mov (REG_D0,fp),a2 # get the exception number
329 mov (REG_ORIG_D0,fp),d0
330 mov d0,(REG_D0,fp)
331 mov -1,d0
332 mov d0,(REG_ORIG_D0,fp)
333
334#ifdef CONFIG_GDBSTUB
335 btst 0x01,(gdbstub_busy)
336 beq 2f
337 and ~EPSW_IE,epsw
338 mov fp,d0
339 mov a2,d1
340 call gdbstub_exception[],0 # gdbstub itself caused an exception
341 bra restore_all
3422:
343#endif
344
345 mov fp,d0 # arg 0: stacked register file
346 mov a2,d1 # arg 1: exception number
347 lsr 1,a2
348
349 mov (exception_table,a2),a2
350 calls (a2)
351 jmp ret_from_exception
352
3531: pi # BUG() equivalent
354
355###############################################################################
356#
357# Exception handler functions table
358#
359###############################################################################
360 .data
361ENTRY(exception_table)
362 .rept 0x400>>1
363 .long uninitialised_exception
364 .endr
365 .previous
366
367###############################################################################
368#
369# Change an entry in the exception table
370# - D0 exception code, D1 handler
371#
372###############################################################################
373ENTRY(set_excp_vector)
374 lsr 1,d0
375 add exception_table,d0
376 mov d1,(d0)
377 mov 4,d1
378#if defined(CONFIG_MN10300_CACHE_WBACK)
379 jmp mn10300_dcache_flush_inv_range2
380#else
381 ret [],0
382#endif
383
384###############################################################################
385#
386# System call table
387#
388###############################################################################
389 .data
390ENTRY(sys_call_table)
391 .long sys_restart_syscall /* 0 */
392 .long sys_exit
393 .long sys_fork
394 .long sys_read
395 .long sys_write
396 .long sys_open /* 5 */
397 .long sys_close
398 .long sys_waitpid
399 .long sys_creat
400 .long sys_link
401 .long sys_unlink /* 10 */
402 .long sys_execve
403 .long sys_chdir
404 .long sys_time
405 .long sys_mknod
406 .long sys_chmod /* 15 */
407 .long sys_lchown16
408 .long sys_ni_syscall /* old break syscall holder */
409 .long sys_stat
410 .long sys_lseek
411 .long sys_getpid /* 20 */
412 .long sys_mount
413 .long sys_oldumount
414 .long sys_setuid16
415 .long sys_getuid16
416 .long sys_stime /* 25 */
417 .long sys_ptrace
418 .long sys_alarm
419 .long sys_fstat
420 .long sys_pause
421 .long sys_utime /* 30 */
422 .long sys_ni_syscall /* old stty syscall holder */
423 .long sys_ni_syscall /* old gtty syscall holder */
424 .long sys_access
425 .long sys_nice
426 .long sys_ni_syscall /* 35 - old ftime syscall holder */
427 .long sys_sync
428 .long sys_kill
429 .long sys_rename
430 .long sys_mkdir
431 .long sys_rmdir /* 40 */
432 .long sys_dup
433 .long sys_pipe
434 .long sys_times
435 .long sys_ni_syscall /* old prof syscall holder */
436 .long sys_brk /* 45 */
437 .long sys_setgid16
438 .long sys_getgid16
439 .long sys_signal
440 .long sys_geteuid16
441 .long sys_getegid16 /* 50 */
442 .long sys_acct
443 .long sys_umount /* recycled never used phys() */
444 .long sys_ni_syscall /* old lock syscall holder */
445 .long sys_ioctl
446 .long sys_fcntl /* 55 */
447 .long sys_ni_syscall /* old mpx syscall holder */
448 .long sys_setpgid
449 .long sys_ni_syscall /* old ulimit syscall holder */
450 .long sys_ni_syscall /* old sys_olduname */
451 .long sys_umask /* 60 */
452 .long sys_chroot
453 .long sys_ustat
454 .long sys_dup2
455 .long sys_getppid
456 .long sys_getpgrp /* 65 */
457 .long sys_setsid
458 .long sys_sigaction
459 .long sys_sgetmask
460 .long sys_ssetmask
461 .long sys_setreuid16 /* 70 */
462 .long sys_setregid16
463 .long sys_sigsuspend
464 .long sys_sigpending
465 .long sys_sethostname
466 .long sys_setrlimit /* 75 */
467 .long sys_old_getrlimit
468 .long sys_getrusage
469 .long sys_gettimeofday
470 .long sys_settimeofday
471 .long sys_getgroups16 /* 80 */
472 .long sys_setgroups16
473 .long old_select
474 .long sys_symlink
475 .long sys_lstat
476 .long sys_readlink /* 85 */
477 .long sys_uselib
478 .long sys_swapon
479 .long sys_reboot
480 .long old_readdir
481 .long old_mmap /* 90 */
482 .long sys_munmap
483 .long sys_truncate
484 .long sys_ftruncate
485 .long sys_fchmod
486 .long sys_fchown16 /* 95 */
487 .long sys_getpriority
488 .long sys_setpriority
489 .long sys_ni_syscall /* old profil syscall holder */
490 .long sys_statfs
491 .long sys_fstatfs /* 100 */
492 .long sys_ni_syscall /* ioperm */
493 .long sys_socketcall
494 .long sys_syslog
495 .long sys_setitimer
496 .long sys_getitimer /* 105 */
497 .long sys_newstat
498 .long sys_newlstat
499 .long sys_newfstat
500 .long sys_ni_syscall /* old sys_uname */
501 .long sys_ni_syscall /* 110 - iopl */
502 .long sys_vhangup
503 .long sys_ni_syscall /* old "idle" system call */
504 .long sys_ni_syscall /* vm86old */
505 .long sys_wait4
506 .long sys_swapoff /* 115 */
507 .long sys_sysinfo
508 .long sys_ipc
509 .long sys_fsync
510 .long sys_sigreturn
511 .long sys_clone /* 120 */
512 .long sys_setdomainname
513 .long sys_newuname
514 .long sys_ni_syscall /* modify_ldt */
515 .long sys_adjtimex
516 .long sys_mprotect /* 125 */
517 .long sys_sigprocmask
518 .long sys_ni_syscall /* old "create_module" */
519 .long sys_init_module
520 .long sys_delete_module
521 .long sys_ni_syscall /* 130: old "get_kernel_syms" */
522 .long sys_quotactl
523 .long sys_getpgid
524 .long sys_fchdir
525 .long sys_bdflush
526 .long sys_sysfs /* 135 */
527 .long sys_personality
528 .long sys_ni_syscall /* reserved for afs_syscall */
529 .long sys_setfsuid16
530 .long sys_setfsgid16
531 .long sys_llseek /* 140 */
532 .long sys_getdents
533 .long sys_select
534 .long sys_flock
535 .long sys_msync
536 .long sys_readv /* 145 */
537 .long sys_writev
538 .long sys_getsid
539 .long sys_fdatasync
540 .long sys_sysctl
541 .long sys_mlock /* 150 */
542 .long sys_munlock
543 .long sys_mlockall
544 .long sys_munlockall
545 .long sys_sched_setparam
546 .long sys_sched_getparam /* 155 */
547 .long sys_sched_setscheduler
548 .long sys_sched_getscheduler
549 .long sys_sched_yield
550 .long sys_sched_get_priority_max
551 .long sys_sched_get_priority_min /* 160 */
552 .long sys_sched_rr_get_interval
553 .long sys_nanosleep
554 .long sys_mremap
555 .long sys_setresuid16
556 .long sys_getresuid16 /* 165 */
557 .long sys_ni_syscall /* vm86 */
558 .long sys_ni_syscall /* Old sys_query_module */
559 .long sys_poll
560 .long sys_nfsservctl
561 .long sys_setresgid16 /* 170 */
562 .long sys_getresgid16
563 .long sys_prctl
564 .long sys_rt_sigreturn
565 .long sys_rt_sigaction
566 .long sys_rt_sigprocmask /* 175 */
567 .long sys_rt_sigpending
568 .long sys_rt_sigtimedwait
569 .long sys_rt_sigqueueinfo
570 .long sys_rt_sigsuspend
571 .long sys_pread64 /* 180 */
572 .long sys_pwrite64
573 .long sys_chown16
574 .long sys_getcwd
575 .long sys_capget
576 .long sys_capset /* 185 */
577 .long sys_sigaltstack
578 .long sys_sendfile
579 .long sys_ni_syscall /* reserved for streams1 */
580 .long sys_ni_syscall /* reserved for streams2 */
581 .long sys_vfork /* 190 */
582 .long sys_getrlimit
583 .long sys_mmap2
584 .long sys_truncate64
585 .long sys_ftruncate64
586 .long sys_stat64 /* 195 */
587 .long sys_lstat64
588 .long sys_fstat64
589 .long sys_lchown
590 .long sys_getuid
591 .long sys_getgid /* 200 */
592 .long sys_geteuid
593 .long sys_getegid
594 .long sys_setreuid
595 .long sys_setregid
596 .long sys_getgroups /* 205 */
597 .long sys_setgroups
598 .long sys_fchown
599 .long sys_setresuid
600 .long sys_getresuid
601 .long sys_setresgid /* 210 */
602 .long sys_getresgid
603 .long sys_chown
604 .long sys_setuid
605 .long sys_setgid
606 .long sys_setfsuid /* 215 */
607 .long sys_setfsgid
608 .long sys_pivot_root
609 .long sys_mincore
610 .long sys_madvise
611 .long sys_getdents64 /* 220 */
612 .long sys_fcntl64
613 .long sys_ni_syscall /* reserved for TUX */
614 .long sys_ni_syscall
615 .long sys_gettid
616 .long sys_readahead /* 225 */
617 .long sys_setxattr
618 .long sys_lsetxattr
619 .long sys_fsetxattr
620 .long sys_getxattr
621 .long sys_lgetxattr /* 230 */
622 .long sys_fgetxattr
623 .long sys_listxattr
624 .long sys_llistxattr
625 .long sys_flistxattr
626 .long sys_removexattr /* 235 */
627 .long sys_lremovexattr
628 .long sys_fremovexattr
629 .long sys_tkill
630 .long sys_sendfile64
631 .long sys_futex /* 240 */
632 .long sys_sched_setaffinity
633 .long sys_sched_getaffinity
634 .long sys_ni_syscall /* sys_set_thread_area */
635 .long sys_ni_syscall /* sys_get_thread_area */
636 .long sys_io_setup /* 245 */
637 .long sys_io_destroy
638 .long sys_io_getevents
639 .long sys_io_submit
640 .long sys_io_cancel
641 .long sys_fadvise64 /* 250 */
642 .long sys_ni_syscall
643 .long sys_exit_group
644 .long sys_lookup_dcookie
645 .long sys_epoll_create
646 .long sys_epoll_ctl /* 255 */
647 .long sys_epoll_wait
648 .long sys_remap_file_pages
649 .long sys_set_tid_address
650 .long sys_timer_create
651 .long sys_timer_settime /* 260 */
652 .long sys_timer_gettime
653 .long sys_timer_getoverrun
654 .long sys_timer_delete
655 .long sys_clock_settime
656 .long sys_clock_gettime /* 265 */
657 .long sys_clock_getres
658 .long sys_clock_nanosleep
659 .long sys_statfs64
660 .long sys_fstatfs64
661 .long sys_tgkill /* 270 */
662 .long sys_utimes
663 .long sys_fadvise64_64
664 .long sys_ni_syscall /* sys_vserver */
665 .long sys_mbind
666 .long sys_get_mempolicy /* 275 */
667 .long sys_set_mempolicy
668 .long sys_mq_open
669 .long sys_mq_unlink
670 .long sys_mq_timedsend
671 .long sys_mq_timedreceive /* 280 */
672 .long sys_mq_notify
673 .long sys_mq_getsetattr
674 .long sys_kexec_load
675 .long sys_waitid
676 .long sys_ni_syscall /* 285 */ /* available */
677 .long sys_add_key
678 .long sys_request_key
679 .long sys_keyctl
680 .long sys_cacheflush
681 .long sys_ioprio_set /* 290 */
682 .long sys_ioprio_get
683 .long sys_inotify_init
684 .long sys_inotify_add_watch
685 .long sys_inotify_rm_watch
686 .long sys_migrate_pages /* 295 */
687 .long sys_openat
688 .long sys_mkdirat
689 .long sys_mknodat
690 .long sys_fchownat
691 .long sys_futimesat /* 300 */
692 .long sys_fstatat64
693 .long sys_unlinkat
694 .long sys_renameat
695 .long sys_linkat
696 .long sys_symlinkat /* 305 */
697 .long sys_readlinkat
698 .long sys_fchmodat
699 .long sys_faccessat
700 .long sys_pselect6
701 .long sys_ppoll /* 310 */
702 .long sys_unshare
703 .long sys_set_robust_list
704 .long sys_get_robust_list
705 .long sys_splice
706 .long sys_sync_file_range /* 315 */
707 .long sys_tee
708 .long sys_vmsplice
709 .long sys_move_pages
710 .long sys_getcpu
711 .long sys_epoll_pwait /* 320 */
712 .long sys_utimensat
713 .long sys_signalfd
714 .long sys_timerfd_create
715 .long sys_eventfd
716 .long sys_fallocate /* 325 */
717 .long sys_timerfd_settime
718 .long sys_timerfd_gettime
719
720
721nr_syscalls=(.-sys_call_table)/4