Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / arch / sun4v / hslave.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: hslave.fth
4\
5\ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6\
7\ - Do no alter or remove copyright notices
8\
9\ - Redistribution and use of this software in source and binary forms, with
10\ or without modification, are permitted provided that the following
11\ conditions are met:
12\
13\ - Redistribution of source code must retain the above copyright notice,
14\ this list of conditions and the following disclaimer.
15\
16\ - Redistribution in binary form must reproduce the above copyright notice,
17\ this list of conditions and the following disclaimer in the
18\ documentation and/or other materials provided with the distribution.
19\
20\ Neither the name of Sun Microsystems, Inc. or the names of contributors
21\ may be used to endorse or promote products derived from this software
22\ without specific prior written permission.
23\
24\ This software is provided "AS IS," without a warranty of any kind.
25\ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
26\ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
27\ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
28\ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
29\ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
30\ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
31\ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
32\ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
33\ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
34\ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
35\ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
36\
37\ You acknowledge that this software is not designed, licensed or
38\ intended for use in the design, construction, operation or maintenance of
39\ any nuclear facility.
40\
41\ ========== Copyright Header End ============================================
42id: @(#)hslave.fth 1.3 07/05/04
43purpose:
44copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved
45copyright: Use is subject to license terms.
46
47headerless
48
49label start-slave-cpus
50 \ Turn OFF everything except for PRIV bit in %pstate
51
52 %g0 h# f wrpil
53 %g0 4 wrpstate
54 %i0 %g1 move
55 %i1 %g2 move
56 %g0 0 wrtba
57 \ XXX %g0 0 %r22 wrasr \ Clear SoftInt Reg.
58 %g0 7 wrcleanwin
59 %g0 0 wrotherwin
60 %g0 0 wrwstate
61 %g0 0 wrcanrestore
62 %g0 6 wrcansave
63 %g0 0 wrcwp
64 %g1 %i0 move
65 %g2 %i1 move
66 %g0 0 wrtl \ TL = 0
67 %g0 0 wrgl
68
69 %g0 h# 16 %o5 add
70 %g0 0 always htrapif
71 %g0 h# 20 wrasi
72 %o1 %g0 h# 08 %asi stxa \ MID in scratchpad1
73
74 %i1 %o1 move \ Size of Memory
75 setup-i/d-tlbs call
76 %i0 %o0 move \ Base of Memory
77
78 \ ick ick
79 \ need a PA, so we reverse engineer one
80 \ this needs to move to 'reset'..
81 mmu-info >mmu-miss-pa rombase + 4meg 1- land %o0 set \ relative to start
82 %i0 %o0 memory-asi %o0 ldxa \ PA
83 %o1 get-mid
84 %o1 /mmu-miss-area log2 %o1 sllx
85 %o0 %o1 %o0 add
86 %g0 h# 30 %o1 add
87 %o0 %g0 %o1 h# 20 stxa \ Scratch6, MISS AREA PA
88 mmu-miss-area-func# %o5 set
89 %g0 fast-trap# always htrapif \ set it
90
91 \ Set the base register
92 ROMbase base set
93
94 \ Set %tba register
95 base %g0 wrtba
96
97 %g0 1 %o0 add \ MMU On
98 %g0 mmu-on-off-func# %o5 add
99 here origin - %g4 set
100 base %g4 %g4 add
101 %g4 h# 18 %o1 add \ Return PC
102 %g0 fast-trap# always htrapif
103 nop
104
105 \ Set up register
106 prom-main-task up set
107
108 release-slaves? origin- scr set
109 scr base scr add
110 scr %g0 sc2 ld
111 begin
112 sc2 %g0 %g0 subcc
113 0<> until
114 scr %g0 sc2 ld
115
116 scr rdpstate
117 scr h# 16 scr or
118 scr 0 wrpstate
119
120 \ can clear post-run magic in %i5
121 %g0 %i5 move
122
123 \ Enter the initial idle loop
124 slave-init always brif
125 nop
126end-code
127
1281 4 h# 10 0 hypercall: hyper-startcpu
129: idle-slaves ( -- )
130 0 tba@ >physical drop ( 0 tba )
131 start-slave-cpus origin- over + ( 0 tba pc )
132 max-#cpus 0 do ( 0 tba pc )
133 mid@ i <> if ( 0 tba pc )
134 \ Start CPU only if there is a node for it in MD
135 i mid-ok? if ( 0 tba pc )
136 0 i >cpu-struct >cpu-status ! ( 0 tba pc )
137 3dup i hyper-startcpu ( 0 tba pc status )
138 0= if ( 0 tba pc )
139 \ Give a second for the CPU to park in slave loop
140 get-msecs d# 1000 + begin ( 0 tba pc msecs )
141 get-msecs over < ( 0 tba pc msecs timeout? )
142 i >cpu-struct >cpu-status @ 0= and ( 0 tba pc msecs ok? )
143 while 10 ms ( 0 tba pc msecs )
144 repeat drop ( 0 tba pc )
145 then ( 0 tba pc )
146 then ( 0 tba pc )
147 then ( 0 tba pc )
148 loop 3drop ( )
149;
150
151stand-init: Kicking slave CPU(s) into idle loop
152 init-per-cpu-data
153 ['] init-per-cpu-data is slave-idle-loop-hook
154 idle-slaves
155;
156
157headers