1 /* hvtramp.S: Hypervisor start-cpu trampoline code.
3 * Copyright (C) 2007 David S. Miller <davem@davemloft.net>
6 #include <asm/thread_info.h>
7 #include <asm/hypervisor.h>
8 #include <asm/scratchpad.h>
9 #include <asm/spitfire.h>
10 #include <asm/hvtramp.h>
11 #include <asm/pstate.h>
12 #include <asm/ptrace.h>
17 .globl hv_cpu_startup, hv_cpu_startup_end
19 /* This code executes directly out of the hypervisor
20 * with physical addressing (va==pa). %o0 contains
21 * our client argument which for Linux points to
22 * a descriptor data structure which defines the
23 * MMU entries we need to load up.
25 * After we set things up we enable the MMU and call
28 * First setup basic privileged cpu state.
33 wrpr %g0, 0, %canrestore
34 wrpr %g0, 0, %otherwin
36 wrpr %g0, 6, %cleanwin
41 sethi %hi(sparc64_ttable_tl0), %g1
46 lduw [%l0 + HVTRAMP_DESCR_CPU], %g1
47 mov SCRATCHPAD_CPUID, %g2
48 stxa %g1, [%g2] ASI_SCRATCHPAD
50 ldx [%l0 + HVTRAMP_DESCR_FAULT_INFO_VA], %g2
51 stxa %g2, [%g0] ASI_SCRATCHPAD
54 lduw [%l0 + HVTRAMP_DESCR_NUM_MAPPINGS], %l2
55 add %l0, HVTRAMP_DESCR_MAPS, %l3
57 1: ldx [%l3 + HVTRAMP_MAPPING_VADDR], %o0
59 ldx [%l3 + HVTRAMP_MAPPING_TTE], %o2
60 mov HV_MMU_IMMU | HV_MMU_DMMU, %o3
61 mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
70 add %l3, HVTRAMP_MAPPING_SIZE, %l3
72 ldx [%l0 + HVTRAMP_DESCR_FAULT_INFO_PA], %o0
73 mov HV_FAST_MMU_FAULT_AREA_CONF, %o5
79 wrpr %g0, (PSTATE_PRIV | PSTATE_PEF), %pstate
81 ldx [%l0 + HVTRAMP_DESCR_THREAD_REG], %l6
85 mov HV_FAST_MMU_ENABLE, %o5
95 mov PRIMARY_CONTEXT, %g7
96 stxa %g0, [%g7] ASI_MMU
99 mov SECONDARY_CONTEXT, %g7
100 stxa %g0, [%g7] ASI_MMU
104 ldx [%g6 + TI_TASK], %g4
107 sllx %g5, THREAD_SHIFT, %g5
108 sub %g5, (STACKFRAME_SZ + STACK_BIAS), %g5
112 call init_irqwork_curcpu
114 call hard_smp_processor_id
120 call sun4v_init_mondo_queues
123 call init_cur_cpu_trap
126 wrpr %g0, (PSTATE_PRIV | PSTATE_PEF | PSTATE_IE), %pstate