1 /* hvtramp.S: Hypervisor start-cpu trampoline code.
3 * Copyright (C) 2007, 2008 David S. Miller <davem@davemloft.net>
6 #include <linux/init.h>
8 #include <asm/thread_info.h>
9 #include <asm/hypervisor.h>
10 #include <asm/scratchpad.h>
11 #include <asm/spitfire.h>
12 #include <asm/hvtramp.h>
13 #include <asm/pstate.h>
14 #include <asm/ptrace.h>
21 .globl hv_cpu_startup, hv_cpu_startup_end
23 /* This code executes directly out of the hypervisor
24 * with physical addressing (va==pa). %o0 contains
25 * our client argument which for Linux points to
26 * a descriptor data structure which defines the
27 * MMU entries we need to load up.
29 * After we set things up we enable the MMU and call
32 * First setup basic privileged cpu state.
36 wrpr %g0, PIL_NORMAL_MAX, %pil
37 wrpr %g0, 0, %canrestore
38 wrpr %g0, 0, %otherwin
40 wrpr %g0, 6, %cleanwin
45 sethi %hi(sparc64_ttable_tl0), %g1
50 lduw [%l0 + HVTRAMP_DESCR_CPU], %g1
51 mov SCRATCHPAD_CPUID, %g2
52 stxa %g1, [%g2] ASI_SCRATCHPAD
54 ldx [%l0 + HVTRAMP_DESCR_FAULT_INFO_VA], %g2
55 stxa %g2, [%g0] ASI_SCRATCHPAD
58 lduw [%l0 + HVTRAMP_DESCR_NUM_MAPPINGS], %l2
59 add %l0, HVTRAMP_DESCR_MAPS, %l3
61 1: ldx [%l3 + HVTRAMP_MAPPING_VADDR], %o0
63 ldx [%l3 + HVTRAMP_MAPPING_TTE], %o2
64 mov HV_MMU_IMMU | HV_MMU_DMMU, %o3
65 mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
74 add %l3, HVTRAMP_MAPPING_SIZE, %l3
76 ldx [%l0 + HVTRAMP_DESCR_FAULT_INFO_PA], %o0
77 mov HV_FAST_MMU_FAULT_AREA_CONF, %o5
83 wrpr %g0, (PSTATE_PRIV | PSTATE_PEF), %pstate
85 ldx [%l0 + HVTRAMP_DESCR_THREAD_REG], %l6
89 mov HV_FAST_MMU_ENABLE, %o5
99 mov PRIMARY_CONTEXT, %g7
100 stxa %g0, [%g7] ASI_MMU
103 mov SECONDARY_CONTEXT, %g7
104 stxa %g0, [%g7] ASI_MMU
108 ldx [%g6 + TI_TASK], %g4
111 sllx %g5, THREAD_SHIFT, %g5
112 sub %g5, (STACKFRAME_SZ + STACK_BIAS), %g5
116 call init_irqwork_curcpu
118 call hard_smp_processor_id
121 call sun4v_register_mondo_queues
124 call init_cur_cpu_trap
127 wrpr %g0, (PSTATE_PRIV | PSTATE_PEF | PSTATE_IE), %pstate