Merge branch 'sh/dmaengine'
[safe/jmp/linux-2.6] / arch / sh / kernel / cpu / sh5 / entry.S
index 2f505a7..6b80295 100644 (file)
@@ -1,18 +1,18 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * arch/sh64/kernel/entry.S
+ * arch/sh/kernel/cpu/sh5/entry.S
  *
  * Copyright (C) 2000, 2001  Paolo Alberelli
- * Copyright (C) 2004, 2005  Paul Mundt
- * Copyright (C) 2003, 2004 Richard Curnow
+ * Copyright (C) 2004 - 2008  Paul Mundt
+ * Copyright (C) 2003, 2004  Richard Curnow
  *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
  */
 #include <linux/errno.h>
+#include <linux/init.h>
 #include <linux/sys.h>
-#include <asm/cpu/registers.h>
+#include <cpu/registers.h>
 #include <asm/processor.h>
 #include <asm/unistd.h>
 #include <asm/thread_info.h>
@@ -144,12 +144,22 @@ resvec_save_area:
 trap_jtable:
        .long   do_exception_error              /* 0x000 */
        .long   do_exception_error              /* 0x020 */
+#ifdef CONFIG_MMU
        .long   tlb_miss_load                           /* 0x040 */
        .long   tlb_miss_store                          /* 0x060 */
+#else
+       .long   do_exception_error
+       .long   do_exception_error
+#endif
        ! ARTIFICIAL pseudo-EXPEVT setting
        .long   do_debug_interrupt              /* 0x080 */
+#ifdef CONFIG_MMU
        .long   tlb_miss_load                           /* 0x0A0 */
        .long   tlb_miss_store                          /* 0x0C0 */
+#else
+       .long   do_exception_error
+       .long   do_exception_error
+#endif
        .long   do_address_error_load   /* 0x0E0 */
        .long   do_address_error_store  /* 0x100 */
 #ifdef CONFIG_SH_FPU
@@ -161,7 +171,7 @@ trap_jtable:
        .long   system_call                             /* 0x160 */
        .long   do_reserved_inst                /* 0x180 */
        .long   do_illegal_slot_inst    /* 0x1A0 */
-       .long   do_NMI                  /* 0x1C0 */
+       .long   do_exception_error              /* 0x1C0 - NMI */
        .long   do_exception_error              /* 0x1E0 */
        .rept 15
                .long do_IRQ            /* 0x200 - 0x3C0 */
@@ -177,7 +187,7 @@ trap_jtable:
        .rept 6
                .long do_exception_error        /* 0x880 - 0x920 */
        .endr
-       .long   do_software_break_point /* 0x940 */
+       .long   breakpoint_trap_handler /* 0x940 */
        .long   do_exception_error              /* 0x960 */
        .long   do_single_step          /* 0x980 */
 
@@ -186,10 +196,18 @@ trap_jtable:
        .endr
        .long   do_IRQ                  /* 0xA00 */
        .long   do_IRQ                  /* 0xA20 */
+#ifdef CONFIG_MMU
        .long   itlb_miss_or_IRQ                        /* 0xA40 */
+#else
+       .long   do_IRQ
+#endif
        .long   do_IRQ                  /* 0xA60 */
        .long   do_IRQ                  /* 0xA80 */
+#ifdef CONFIG_MMU
        .long   itlb_miss_or_IRQ                        /* 0xAA0 */
+#else
+       .long   do_IRQ
+#endif
        .long   do_exception_error              /* 0xAC0 */
        .long   do_address_error_exec   /* 0xAE0 */
        .rept 8
@@ -275,6 +293,7 @@ not_a_tlb_miss:
         * Instead of '.space 1024-TEXT_SIZE' place the RESVEC
         * block making sure the final alignment is correct.
         */
+#ifdef CONFIG_MMU
 tlb_miss:
        synco   /* TAKum03020 (but probably a good idea anyway.) */
        putcon  SP, KCR1
@@ -378,6 +397,9 @@ fixup_to_invoke_general_handler:
        getcon  KCR1, SP
        pta     handle_exception, tr0
        blink   tr0, ZERO
+#else /* CONFIG_MMU */
+       .balign 256
+#endif
 
 /* NB TAKE GREAT CARE HERE TO ENSURE THAT THE INTERRUPT CODE
    DOES END UP AT VBR+0x600 */
@@ -432,7 +454,7 @@ reset_or_panic:
        synco   /* TAKum03020 (but probably a good idea anyway.) */
        putcon  SP, DCR
        /* First save r0-1 and tr0, as we need to use these */
-       movi    resvec_save_area-CONFIG_CACHED_MEMORY_OFFSET, SP
+       movi    resvec_save_area-CONFIG_PAGE_OFFSET, SP
        st.q    SP, 0, r0
        st.q    SP, 8, r1
        gettr   tr0, r0
@@ -442,7 +464,7 @@ reset_or_panic:
        getcon  EXPEVT, r0
        movi    RESET_CAUSE, r1
        sub     r1, r0, r1              /* r1=0 if reset */
-       movi    _stext-CONFIG_CACHED_MEMORY_OFFSET, r0
+       movi    _stext-CONFIG_PAGE_OFFSET, r0
        ori     r0, 1, r0
        ptabs   r0, tr0
        beqi    r1, 0, tr0              /* Jump to start address if reset */
@@ -454,7 +476,7 @@ reset_or_panic:
        beqi    r1, 0, tr0              /* jump if single step */
 
        /* Now jump to where we save the registers. */
-       movi    panic_stash_regs-CONFIG_CACHED_MEMORY_OFFSET, r1
+       movi    panic_stash_regs-CONFIG_PAGE_OFFSET, r1
        ptabs   r1, tr0
        blink   tr0, r63
 
@@ -490,7 +512,7 @@ debug_exception:
         */
        putcon  SP, DCR
        /* Save SSR & SPC, together with R0 & R1, as we need to use 2 regs. */
-       movi    resvec_save_area-CONFIG_CACHED_MEMORY_OFFSET, SP
+       movi    resvec_save_area-CONFIG_PAGE_OFFSET, SP
 
        /* With the MMU off, we are bypassing the cache, so purge any
          * data that will be made stale by the following stores.
@@ -558,7 +580,7 @@ debug_interrupt:
        /* Save original stack pointer into KCR1 */
        synco
        putcon  SP, KCR1
-       movi    resvec_save_area-CONFIG_CACHED_MEMORY_OFFSET, SP
+       movi    resvec_save_area-CONFIG_PAGE_OFFSET, SP
        ocbp    SP, 0
        ocbp    SP, 32
        synco
@@ -607,7 +629,7 @@ debug_interrupt:
        movi    EVENT_FAULT_NOT_TLB, r4
 
        or      SP, ZERO, r5
-       movi    CONFIG_CACHED_MEMORY_OFFSET, r6
+       movi    CONFIG_PAGE_OFFSET, r6
        add     r6, r5, r5
        getcon  KCR1, SP
 
@@ -790,27 +812,6 @@ no_underflow:
        ! exceptions
        add     SP, ZERO, r14
 
-#ifdef CONFIG_POOR_MANS_STRACE
-       /* We've pushed all the registers now, so only r2-r4 hold anything
-        * useful. Move them into callee save registers */
-       or      r2, ZERO, r28
-       or      r3, ZERO, r29
-       or      r4, ZERO, r30
-
-       /* Preserve r2 as the event code */
-       movi    evt_debug, r3
-       ori     r3, 1, r3
-       ptabs   r3, tr0
-
-       or      SP, ZERO, r6
-       getcon  TRA, r5
-       blink   tr0, LINK
-
-       or      r28, ZERO, r2
-       or      r29, ZERO, r3
-       or      r30, ZERO, r4
-#endif
-
        /* For syscall and debug race condition, get TRA now */
        getcon  TRA, r5
 
@@ -865,11 +866,6 @@ no_underflow:
  */
        .global ret_from_irq
 ret_from_irq:
-#ifdef CONFIG_POOR_MANS_STRACE
-       pta     evt_debug_ret_from_irq, tr0
-       ori     SP, 0, r2
-       blink   tr0, LINK
-#endif
        ld.q    SP, FRAME_S(FSSR), r6
        shlri   r6, 30, r6
        andi    r6, 1, r6
@@ -883,12 +879,6 @@ ret_from_irq:
 ret_from_exception:
        preempt_stop()
 
-#ifdef CONFIG_POOR_MANS_STRACE
-       pta     evt_debug_ret_from_exc, tr0
-       ori     SP, 0, r2
-       blink   tr0, LINK
-#endif
-
        ld.q    SP, FRAME_S(FSSR), r6
        shlri   r6, 30, r6
        andi    r6, 1, r6
@@ -902,6 +892,8 @@ ret_from_exception:
        blink   tr0, ZERO
 
 resume_kernel:
+       CLI()
+
        pta     restore_all, tr0
 
        getcon  KCR0, r6
@@ -918,19 +910,11 @@ need_resched:
        andi    r7, 0xf0, r7
        bne     r7, ZERO, tr0
 
-       movi    ((PREEMPT_ACTIVE >> 16) & 65535), r8
-       shori   (PREEMPT_ACTIVE & 65535), r8
-       st.l    r6, TI_PRE_COUNT, r8
-
-       STI()
-       movi    schedule, r7
+       movi    preempt_schedule_irq, r7
        ori     r7, 1, r7
        ptabs   r7, tr1
        blink   tr1, LINK
 
-       st.l    r6, TI_PRE_COUNT, ZERO
-       CLI()
-
        pta     need_resched, tr1
        blink   tr1, ZERO
 #endif
@@ -942,9 +926,6 @@ ret_with_reschedule:
        getcon  KCR0, r6                ! r6 contains current_thread_info
        ld.l    r6, TI_FLAGS, r7        ! r7 contains current_thread_info->flags
 
-       ! FIXME:!!!
-       ! no handling of TIF_SYSCALL_TRACE yet!!
-
        movi    _TIF_NEED_RESCHED, r8
        and     r8, r7, r8
        pta     work_resched, tr0
@@ -952,7 +933,7 @@ ret_with_reschedule:
 
        pta     restore_all, tr1
 
-       movi    (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), r8
+       movi    _TIF_SIGPENDING, r8
        and     r8, r7, r8
        pta     work_notifysig, tr0
        bne     r8, ZERO, tr0
@@ -969,11 +950,11 @@ work_resched:
 work_notifysig:
        gettr   tr1, LINK
 
-       movi    do_signal, r6
+       movi    do_notify_resume, r6
        ptabs   r6, tr0
        or      SP, ZERO, r2
-       or      ZERO, ZERO, r3
-       blink   tr0, LINK           /* Call do_signal(regs, 0), return here */
+       or      r7, ZERO, r3
+       blink   tr0, LINK           /* Call do_notify_resume(regs, current_thread_info->flags), return here */
 
 restore_all:
        /* Do prefetches */
@@ -1107,6 +1088,7 @@ restore_all:
  * fpu_error_or_IRQ? is a helper to deflect to the right cause.
  *
  */
+#ifdef CONFIG_MMU
 tlb_miss_load:
        or      SP, ZERO, r2
        or      ZERO, ZERO, r3          /* Read */
@@ -1136,12 +1118,13 @@ call_do_page_fault:
        movi    do_page_fault, r6
         ptabs  r6, tr0
         blink  tr0, ZERO
+#endif /* CONFIG_MMU */
 
 fpu_error_or_IRQA:
        pta     its_IRQ, tr0
        beqi/l  r4, EVENT_INTERRUPT, tr0
 #ifdef CONFIG_SH_FPU
-       movi    do_fpu_state_restore, r6
+       movi    fpu_state_restore_trap_handler, r6
 #else
        movi    do_exception_error, r6
 #endif
@@ -1152,7 +1135,7 @@ fpu_error_or_IRQB:
        pta     its_IRQ, tr0
        beqi/l  r4, EVENT_INTERRUPT, tr0
 #ifdef CONFIG_SH_FPU
-       movi    do_fpu_state_restore, r6
+       movi    fpu_state_restore_trap_handler, r6
 #else
        movi    do_exception_error, r6
 #endif
@@ -1221,18 +1204,6 @@ syscall_bad:
        .global syscall_ret
 syscall_ret:
        st.q    SP, FRAME_R(9), r2      /* Expecting SP back to BASIC frame */
-
-#ifdef CONFIG_POOR_MANS_STRACE
-       /* nothing useful in registers at this point */
-
-       movi    evt_debug2, r5
-       ori     r5, 1, r5
-       ptabs   r5, tr0
-       ld.q    SP, FRAME_R(9), r2
-       or      SP, ZERO, r3
-       blink   tr0, LINK
-#endif
-
        ld.q    SP, FRAME_S(FSPC), r2
        addi    r2, 4, r2               /* Move PC, being pre-execution event */
        st.q    SP, FRAME_S(FSPC), r2
@@ -1253,25 +1224,12 @@ ret_from_fork:
        ptabs   r5, tr0
        blink   tr0, LINK
 
-#ifdef CONFIG_POOR_MANS_STRACE
-       /* nothing useful in registers at this point */
-
-       movi    evt_debug2, r5
-       ori     r5, 1, r5
-       ptabs   r5, tr0
-       ld.q    SP, FRAME_R(9), r2
-       or      SP, ZERO, r3
-       blink   tr0, LINK
-#endif
-
        ld.q    SP, FRAME_S(FSPC), r2
        addi    r2, 4, r2               /* Move PC, being pre-execution event */
        st.q    SP, FRAME_S(FSPC), r2
        pta     ret_from_syscall, tr0
        blink   tr0, ZERO
 
-
-
 syscall_allowed:
        /* Use LINK to deflect the exit point, default is syscall_ret */
        pta     syscall_ret, tr0
@@ -1280,15 +1238,20 @@ syscall_allowed:
 
        getcon  KCR0, r2
        ld.l    r2, TI_FLAGS, r4
-       movi    (1 << TIF_SYSCALL_TRACE), r6
+       movi    _TIF_WORK_SYSCALL_MASK, r6
        and     r6, r4, r6
        beq/l   r6, ZERO, tr0
 
        /* Trace it by calling syscall_trace before and after */
-       movi    syscall_trace, r4
+       movi    do_syscall_trace_enter, r4
+       or      SP, ZERO, r2
        ptabs   r4, tr0
        blink   tr0, LINK
-       /* Reload syscall number as r5 is trashed by syscall_trace */
+
+       /* Save the retval */
+       st.q    SP, FRAME_R(2), r2
+
+       /* Reload syscall number as r5 is trashed by do_syscall_trace_enter */
        ld.q    SP, FRAME_S(FSYSCALL_ID), r5
        andi    r5, 0x1ff, r5
 
@@ -1320,7 +1283,8 @@ syscall_ret_trace:
        /* We get back here only if under trace */
        st.q    SP, FRAME_R(9), r2      /* Save return value */
 
-       movi    syscall_trace, LINK
+       movi    do_syscall_trace_leave, LINK
+       or      SP, ZERO, r2
        ptabs   LINK, tr0
        blink   tr0, LINK
 
@@ -1366,7 +1330,7 @@ route_to_panic_handler:
           last-chance debugging, e.g. if no output wants to go to the console.
           */
 
-       movi    panic_handler - CONFIG_CACHED_MEMORY_OFFSET, r1
+       movi    panic_handler - CONFIG_PAGE_OFFSET, r1
        ptabs   r1, tr0
        pta     1f, tr1
        gettr   tr1, r0
@@ -1389,8 +1353,8 @@ peek_real_address_q:
           r2(out) : result quadword
 
           This is provided as a cheapskate way of manipulating device
-          registers for debugging (to avoid the need to onchip_remap the debug
-          module, and to avoid the need to onchip_remap the watchpoint
+          registers for debugging (to avoid the need to ioremap the debug
+          module, and to avoid the need to ioremap the watchpoint
           controller in a way that identity maps sufficient bits to avoid the
           SH5-101 cut2 silicon defect).
 
@@ -1408,7 +1372,7 @@ peek_real_address_q:
        andc    r1, r36, r1     /* turn sr.mmu off in real mode section */
 
        putcon  r1, ssr
-       movi    .peek0 - CONFIG_CACHED_MEMORY_OFFSET, r36 /* real mode target address */
+       movi    .peek0 - CONFIG_PAGE_OFFSET, r36 /* real mode target address */
        movi    1f, r37         /* virtual mode return addr */
        putcon  r36, spc
 
@@ -1438,8 +1402,8 @@ poke_real_address_q:
           r3 : quadword value to write.
 
           This is provided as a cheapskate way of manipulating device
-          registers for debugging (to avoid the need to onchip_remap the debug
-          module, and to avoid the need to onchip_remap the watchpoint
+          registers for debugging (to avoid the need to ioremap the debug
+          module, and to avoid the need to ioremap the watchpoint
           controller in a way that identity maps sufficient bits to avoid the
           SH5-101 cut2 silicon defect).
 
@@ -1457,7 +1421,7 @@ poke_real_address_q:
        andc    r1, r36, r1     /* turn sr.mmu off in real mode section */
 
        putcon  r1, ssr
-       movi    .poke0-CONFIG_CACHED_MEMORY_OFFSET, r36 /* real mode target address */
+       movi    .poke0-CONFIG_PAGE_OFFSET, r36 /* real mode target address */
        movi    1f, r37         /* virtual mode return addr */
        putcon  r36, spc
 
@@ -1480,6 +1444,7 @@ poke_real_address_q:
        ptabs   LINK, tr0
        blink   tr0, r63
 
+#ifdef CONFIG_MMU
 /*
  * --- User Access Handling Section
  */
@@ -1603,6 +1568,7 @@ ___clear_user_exit:
        ptabs   LINK, tr0
        blink   tr0, ZERO
 
+#endif /* CONFIG_MMU */
 
 /*
  * int __strncpy_from_user(unsigned long __dest, unsigned long __src,
@@ -1954,7 +1920,7 @@ panic_stash_regs:
        getcon  SSR,r3
        getcon  EXPEVT,r4
        /* Prepare to jump to C - physical address */
-       movi    panic_handler-CONFIG_CACHED_MEMORY_OFFSET, r1
+       movi    panic_handler-CONFIG_PAGE_OFFSET, r1
        ori     r1, 1, r1
        ptabs   r1, tr0
        getcon  DCR, SP
@@ -2013,9 +1979,11 @@ sa_default_restorer:
        .global asm_uaccess_start       /* Just a marker */
 asm_uaccess_start:
 
+#ifdef CONFIG_MMU
        .long   ___copy_user1, ___copy_user_exit
        .long   ___copy_user2, ___copy_user_exit
        .long   ___clear_user1, ___clear_user_exit
+#endif
        .long   ___strncpy_from_user1, ___strncpy_from_user_exit
        .long   ___strnlen_user1, ___strnlen_user_exit
        .long   ___get_user_asm_b1, ___get_user_asm_b_exit
@@ -2034,10 +2002,10 @@ asm_uaccess_end:
 
 
 /*
- * --- .text.init Section
+ * --- .init.text Section
  */
 
-       .section        .text.init, "ax"
+       __INIT
 
 /*
  * void trap_init (void)
@@ -2055,7 +2023,7 @@ trap_init:
        andi    r19, -4, r19                    /* reset MMUOFF + reserved */
        /* For RESVEC exceptions we force the MMU off, which means we need the
           physical address. */
-       movi    LRESVEC_block-CONFIG_CACHED_MEMORY_OFFSET, r20
+       movi    LRESVEC_block-CONFIG_PAGE_OFFSET, r20
        andi    r20, -4, r20                    /* reset reserved */
        ori     r20, 1, r20                     /* set MMUOFF */
        putcon  r19, VBR