]> err.no Git - linux-2.6/blobdiff - arch/sparc64/kernel/trampoline.S
[ARM] 4652/1: pxa: fix a typo of pxa27x usb host clk definition
[linux-2.6] / arch / sparc64 / kernel / trampoline.S
index 22fb24eac9976f7070ec5cfb572697aaae2451dd..04e81dda13d008b83032cc2b251759a8fe4e8417 100644 (file)
@@ -17,6 +17,7 @@
 #include <asm/thread_info.h>
 #include <asm/mmu.h>
 #include <asm/hypervisor.h>
+#include <asm/cpudata.h>
 
        .data
        .align  8
@@ -29,12 +30,16 @@ itlb_load:
 dtlb_load:
        .asciz  "SUNW,dtlb-load"
 
+       /* XXX __cpuinit this thing XXX */
+#define TRAMP_STACK_SIZE       1024
+       .align  16
+tramp_stack:
+       .skip   TRAMP_STACK_SIZE
+
        .text
        .align          8
        .globl          sparc64_cpu_startup, sparc64_cpu_startup_end
 sparc64_cpu_startup:
-       flushw
-
        BRANCH_IF_SUN4V(g1, niagara_startup)
        BRANCH_IF_CHEETAH_BASE(g1, g5, cheetah_startup)
        BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1, g5, cheetah_plus_startup)
@@ -57,6 +62,7 @@ cheetah_startup:
        or      %g5, DCU_DM | DCU_IM | DCU_DC | DCU_IC, %g5
        stxa    %g5, [%g0] ASI_DCU_CONTROL_REG
        membar  #Sync
+       /* fallthru */
 
 cheetah_generic_startup:
        mov     TSB_EXTENSION_P, %g3
@@ -89,19 +95,16 @@ spitfire_startup:
        membar          #Sync
 
 startup_continue:
-       wrpr            %g0, 15, %pil
+       mov             %o0, %l0
+       BRANCH_IF_SUN4V(g1, niagara_lock_tlb)
 
        sethi           %hi(0x80000000), %g2
        sllx            %g2, 32, %g2
        wr              %g2, 0, %tick_cmpr
 
-       BRANCH_IF_SUN4V(g1, niagara_lock_tlb)
-
        /* Call OBP by hand to lock KERNBASE into i/d tlbs.
         * We lock 2 consequetive entries if we are 'bigkernel'.
         */
-       mov             %o0, %l0
-
        sethi           %hi(prom_entry_lock), %g2
 1:     ldstub          [%g2 + %lo(prom_entry_lock)], %g1
        membar          #StoreLoad | #StoreStore
@@ -111,7 +114,6 @@ startup_continue:
        sethi           %hi(p1275buf), %g2
        or              %g2, %lo(p1275buf), %g2
        ldx             [%g2 + 0x10], %l2
-       mov             %sp, %l1
        add             %l2, -(192 + 128), %sp
        flushw
 
@@ -307,18 +309,9 @@ niagara_lock_tlb:
        ta              HV_FAST_TRAP
 
 after_lock_tlb:
-       mov             %l1, %sp
-       flushw
-
-       mov             %l0, %o0
-
        wrpr            %g0, (PSTATE_PRIV | PSTATE_PEF), %pstate
        wr              %g0, 0, %fprs
 
-       /* XXX Buggy PROM... */
-       srl             %o0, 0, %o0
-       ldx             [%o0], %g6
-
        wr              %g0, ASI_P, %asi
 
        mov             PRIMARY_CONTEXT, %g7
@@ -340,22 +333,25 @@ after_lock_tlb:
 
        membar          #Sync
 
-       mov             1, %g5
-       sllx            %g5, THREAD_SHIFT, %g5
-       sub             %g5, (STACKFRAME_SZ + STACK_BIAS), %g5
-       add             %g6, %g5, %sp
+       /* Everything we do here, until we properly take over the
+        * trap table, must be done with extreme care.  We cannot
+        * make any references to %g6 (current thread pointer),
+        * %g4 (current task pointer), or %g5 (base of current cpu's
+        * per-cpu area) until we properly take over the trap table
+        * from the firmware and hypervisor.
+        *
+        * Get onto temporary stack which is in the locked kernel image.
+        */
+       sethi           %hi(tramp_stack), %g1
+       or              %g1, %lo(tramp_stack), %g1
+       add             %g1, TRAMP_STACK_SIZE, %g1
+       sub             %g1, STACKFRAME_SZ + STACK_BIAS + 256, %sp
        mov             0, %fp
 
-       wrpr            %g0, 0, %wstate
-       wrpr            %g0, 0, %tl
-
-       /* Load TBA, then we can resurface. */
-       sethi           %hi(sparc64_ttable_tl0), %g5
-       wrpr            %g5, %tba
-
-       ldx             [%g6 + TI_TASK], %g4
-
-       wrpr            %g0, 0, %wstate
+       /* Put garbage in these registers to trap any access to them.  */
+       set             0xdeadbeef, %g4
+       set             0xdeadbeef, %g5
+       set             0xdeadbeef, %g6
 
        call            init_irqwork_curcpu
         nop
@@ -366,11 +362,14 @@ after_lock_tlb:
        bne,pt          %icc, 1f
         nop
 
-       call            sun4v_init_mondo_queues
-        mov            0, %o0
+       call            hard_smp_processor_id
+        nop
+       
+       call            sun4v_register_mondo_queues
+        nop
 
 1:     call            init_cur_cpu_trap
-        nop
+        ldx            [%l0], %o0
 
        /* Start using proper page size encodings in ctx register.  */
        sethi           %hi(sparc64_kern_pri_context), %g3
@@ -385,9 +384,14 @@ after_lock_tlb:
 
        membar          #Sync
 
-       rdpr            %pstate, %o1
-       or              %o1, PSTATE_IE, %o1
-       wrpr            %o1, 0, %pstate
+       wrpr            %g0, 0, %wstate
+
+       /* As a hack, put &init_thread_union into %g6.
+        * prom_world() loads from here to restore the %asi
+        * register.
+        */
+       sethi           %hi(init_thread_union), %g6
+       or              %g6, %lo(init_thread_union), %g6
 
        sethi           %hi(is_sun4v), %o0
        lduw            [%o0 + %lo(is_sun4v)], %o0
@@ -407,17 +411,53 @@ after_lock_tlb:
        sethi           %hi(kern_base), %g3
        ldx             [%g3 + %lo(kern_base)], %g3
        add             %g2, %g3, %o1
+       sethi           %hi(sparc64_ttable_tl0), %o0
 
-       call            prom_set_trap_table_sun4v
-        sethi          %hi(sparc64_ttable_tl0), %o0
+       set             prom_set_trap_table_name, %g2
+       stx             %g2, [%sp + 2047 + 128 + 0x00]
+       mov             2, %g2
+       stx             %g2, [%sp + 2047 + 128 + 0x08]
+       mov             0, %g2
+       stx             %g2, [%sp + 2047 + 128 + 0x10]
+       stx             %o0, [%sp + 2047 + 128 + 0x18]
+       stx             %o1, [%sp + 2047 + 128 + 0x20]
+       sethi           %hi(p1275buf), %g2
+       or              %g2, %lo(p1275buf), %g2
+       ldx             [%g2 + 0x08], %o1
+       call            %o1
+        add            %sp, (2047 + 128), %o0
 
        ba,pt           %xcc, 2f
         nop
 
-1:     call            prom_set_trap_table
-        sethi          %hi(sparc64_ttable_tl0), %o0
+1:     sethi           %hi(sparc64_ttable_tl0), %o0
+       set             prom_set_trap_table_name, %g2
+       stx             %g2, [%sp + 2047 + 128 + 0x00]
+       mov             1, %g2
+       stx             %g2, [%sp + 2047 + 128 + 0x08]
+       mov             0, %g2
+       stx             %g2, [%sp + 2047 + 128 + 0x10]
+       stx             %o0, [%sp + 2047 + 128 + 0x18]
+       sethi           %hi(p1275buf), %g2
+       or              %g2, %lo(p1275buf), %g2
+       ldx             [%g2 + 0x08], %o1
+       call            %o1
+        add            %sp, (2047 + 128), %o0
+
+2:     ldx             [%l0], %g6
+       ldx             [%g6 + TI_TASK], %g4
+
+       mov             1, %g5
+       sllx            %g5, THREAD_SHIFT, %g5
+       sub             %g5, (STACKFRAME_SZ + STACK_BIAS), %g5
+       add             %g6, %g5, %sp
+       mov             0, %fp
+
+       rdpr            %pstate, %o1
+       or              %o1, PSTATE_IE, %o1
+       wrpr            %o1, 0, %pstate
 
-2:     call            smp_callin
+       call            smp_callin
         nop
        call            cpu_idle
         mov            0, %o0