]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/sparc64/kernel/entry.S
[SPARC64]: Refine code sequences to get the cpu id.
[linux-2.6-omap-h63xx.git] / arch / sparc64 / kernel / entry.S
index a73553ae7e53b76d04d979227bee32f26a9ddd91..b3511ff5d04a9c8ff2360f9d7e29b27261a65169 100644 (file)
@@ -50,7 +50,8 @@ do_fpdis:
        add             %g0, %g0, %g0
        ba,a,pt         %xcc, rtrap_clr_l6
 
-1:     ldub            [%g6 + TI_FPSAVED], %g5
+1:     TRAP_LOAD_THREAD_REG
+       ldub            [%g6 + TI_FPSAVED], %g5
        wr              %g0, FPRS_FEF, %fprs
        andcc           %g5, FPRS_FEF, %g0
        be,a,pt         %icc, 1f
@@ -189,6 +190,7 @@ fp_other_bounce:
        .globl          do_fpother_check_fitos
        .align          32
 do_fpother_check_fitos:
+       TRAP_LOAD_THREAD_REG
        sethi           %hi(fp_other_bounce - 4), %g7
        or              %g7, %lo(fp_other_bounce - 4), %g7
 
@@ -353,8 +355,6 @@ do_fptrap_after_fsr:
         *
         * With this method we can do most of the cross-call tlb/cache
         * flushing very quickly.
-        *
-        * Current CPU's IRQ worklist table is locked into %g6, don't touch.
         */
        .text
        .align          32
@@ -378,6 +378,8 @@ do_ivec:
        sllx            %g2, %g4, %g2
        sllx            %g4, 2, %g4
 
+       TRAP_LOAD_IRQ_WORK
+
        lduw            [%g6 + %g4], %g5        /* g5 = irq_work(cpu, pil) */
        stw             %g5, [%g3 + 0x00]       /* bucket->irq_chain = g5 */
        stw             %g3, [%g6 + %g4]        /* irq_work(cpu, pil) = bucket */
@@ -399,76 +401,6 @@ do_ivec_xcall:
 1:     jmpl            %g3, %g0
         nop
 
-       .globl          save_alternate_globals
-save_alternate_globals: /* %o0 = save_area */
-       rdpr            %pstate, %o5
-       andn            %o5, PSTATE_IE, %o1
-       wrpr            %o1, PSTATE_AG, %pstate
-       stx             %g0, [%o0 + 0x00]
-       stx             %g1, [%o0 + 0x08]
-       stx             %g2, [%o0 + 0x10]
-       stx             %g3, [%o0 + 0x18]
-       stx             %g4, [%o0 + 0x20]
-       stx             %g5, [%o0 + 0x28]
-       stx             %g6, [%o0 + 0x30]
-       stx             %g7, [%o0 + 0x38]
-       wrpr            %o1, PSTATE_IG, %pstate
-       stx             %g0, [%o0 + 0x40]
-       stx             %g1, [%o0 + 0x48]
-       stx             %g2, [%o0 + 0x50]
-       stx             %g3, [%o0 + 0x58]
-       stx             %g4, [%o0 + 0x60]
-       stx             %g5, [%o0 + 0x68]
-       stx             %g6, [%o0 + 0x70]
-       stx             %g7, [%o0 + 0x78]
-       wrpr            %o1, PSTATE_MG, %pstate
-       stx             %g0, [%o0 + 0x80]
-       stx             %g1, [%o0 + 0x88]
-       stx             %g2, [%o0 + 0x90]
-       stx             %g3, [%o0 + 0x98]
-       stx             %g4, [%o0 + 0xa0]
-       stx             %g5, [%o0 + 0xa8]
-       stx             %g6, [%o0 + 0xb0]
-       stx             %g7, [%o0 + 0xb8]
-       wrpr            %o5, 0x0, %pstate
-       retl
-        nop
-
-       .globl          restore_alternate_globals
-restore_alternate_globals: /* %o0 = save_area */
-       rdpr            %pstate, %o5
-       andn            %o5, PSTATE_IE, %o1
-       wrpr            %o1, PSTATE_AG, %pstate
-       ldx             [%o0 + 0x00], %g0
-       ldx             [%o0 + 0x08], %g1
-       ldx             [%o0 + 0x10], %g2
-       ldx             [%o0 + 0x18], %g3
-       ldx             [%o0 + 0x20], %g4
-       ldx             [%o0 + 0x28], %g5
-       ldx             [%o0 + 0x30], %g6
-       ldx             [%o0 + 0x38], %g7
-       wrpr            %o1, PSTATE_IG, %pstate
-       ldx             [%o0 + 0x40], %g0
-       ldx             [%o0 + 0x48], %g1
-       ldx             [%o0 + 0x50], %g2
-       ldx             [%o0 + 0x58], %g3
-       ldx             [%o0 + 0x60], %g4
-       ldx             [%o0 + 0x68], %g5
-       ldx             [%o0 + 0x70], %g6
-       ldx             [%o0 + 0x78], %g7
-       wrpr            %o1, PSTATE_MG, %pstate
-       ldx             [%o0 + 0x80], %g0
-       ldx             [%o0 + 0x88], %g1
-       ldx             [%o0 + 0x90], %g2
-       ldx             [%o0 + 0x98], %g3
-       ldx             [%o0 + 0xa0], %g4
-       ldx             [%o0 + 0xa8], %g5
-       ldx             [%o0 + 0xb0], %g6
-       ldx             [%o0 + 0xb8], %g7
-       wrpr            %o5, 0x0, %pstate
-       retl
-        nop
-
        .globl          getcc, setcc
 getcc:
        ldx             [%o0 + PT_V9_TSTATE], %o1
@@ -488,9 +420,24 @@ setcc:
        retl
         stx            %o1, [%o0 + PT_V9_TSTATE]
 
-       .globl          utrap, utrap_ill
-utrap: brz,pn          %g1, etrap
+       .globl          utrap_trap
+utrap_trap:            /* %g3=handler,%g4=level */
+       TRAP_LOAD_THREAD_REG
+       ldx             [%g6 + TI_UTRAPS], %g1
+       brnz,pt         %g1, invoke_utrap
         nop
+
+       ba,pt           %xcc, etrap
+        rd             %pc, %g7
+       mov             %l4, %o1
+        call           bad_trap
+        add            %sp, PTREGS_OFF, %o0
+       ba,pt           %xcc, rtrap
+        clr            %l6
+
+invoke_utrap:
+       sllx            %g3, 3, %g3
+       ldx             [%g1 + %g3], %g1
        save            %sp, -128, %sp
        rdpr            %tstate, %l6
        rdpr            %cwp, %l7
@@ -500,17 +447,6 @@ utrap:     brz,pn          %g1, etrap
        rdpr            %tnpc, %l7
        wrpr            %g1, 0, %tnpc
        done
-utrap_ill:
-        call           bad_trap
-        add            %sp, PTREGS_OFF, %o0
-       ba,pt           %xcc, rtrap
-        clr            %l6
-
-       /* XXX Here is stuff we still need to write... -DaveM XXX */
-       .globl          netbsd_syscall
-netbsd_syscall:
-       retl
-        nop
 
        /* We need to carefully read the error status, ACK
         * the errors, prevent recursive traps, and pass the
@@ -1001,7 +937,7 @@ dcpe_icpe_tl1_common:
         * %g3:         scratch
         * %g4:         AFSR
         * %g5:         AFAR
-        * %g6:         current thread ptr
+        * %g6:         unused, will have current thread ptr after etrap
         * %g7:         scratch
         */
 __cheetah_log_error:
@@ -1539,13 +1475,14 @@ ret_from_syscall:
 
 1:             b,pt            %xcc, ret_sys_call
                 ldx            [%sp + PTREGS_OFF + PT_V9_I0], %o0
-sparc_exit:    wrpr            %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV), %pstate
+sparc_exit:    rdpr            %pstate, %g2
+               wrpr            %g2, PSTATE_IE, %pstate
                rdpr            %otherwin, %g1
                rdpr            %cansave, %g3
                add             %g3, %g1, %g3
                wrpr            %g3, 0x0, %cansave
                wrpr            %g0, 0x0, %otherwin
-               wrpr            %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV | PSTATE_IE), %pstate
+               wrpr            %g2, 0x0, %pstate
                ba,pt           %xcc, sys_exit
                 stb            %g0, [%g6 + TI_WSAVED]
 
@@ -1690,3 +1627,11 @@ __flushw_user:
         restore        %g0, %g0, %g0
 2:     retl
         nop
+
+#ifdef CONFIG_SMP
+       .globl          hard_smp_processor_id
+hard_smp_processor_id:
+       __GET_CPUID(%o0)
+       retl
+        nop
+#endif