xref: /onnv-gate/usr/src/uts/sun4u/starcat/ml/drmach.il.cpp (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate /*
30*0Sstevel@tonic-gate  * This file is through cpp before being used as
31*0Sstevel@tonic-gate  * an inline.  It contains support routines used
32*0Sstevel@tonic-gate  * only by DR for the copy-rename sequence.
33*0Sstevel@tonic-gate  */
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate #if defined(lint)
36*0Sstevel@tonic-gate #include <sys/types.h>
37*0Sstevel@tonic-gate #endif /* lint */
38*0Sstevel@tonic-gate 
39*0Sstevel@tonic-gate #include <sys/sun4asi.h>
40*0Sstevel@tonic-gate #include <sys/privregs.h>
41*0Sstevel@tonic-gate #include <sys/cheetahregs.h>
42*0Sstevel@tonic-gate #include <sys/machparam.h>
43*0Sstevel@tonic-gate #include <sys/machthread.h>
44*0Sstevel@tonic-gate #include <sys/mmu.h>
45*0Sstevel@tonic-gate #include <sys/cheetahasm.h>
46*0Sstevel@tonic-gate 
47*0Sstevel@tonic-gate #if defined(lint)
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate /*ARGSUSED*/
50*0Sstevel@tonic-gate void
bcopy32_il(uint64_t paddr1,uint64_t paddr2)51*0Sstevel@tonic-gate bcopy32_il(uint64_t paddr1, uint64_t paddr2)
52*0Sstevel@tonic-gate {}
53*0Sstevel@tonic-gate 
54*0Sstevel@tonic-gate void
flush_dcache_il(void)55*0Sstevel@tonic-gate flush_dcache_il(void)
56*0Sstevel@tonic-gate {}
57*0Sstevel@tonic-gate 
58*0Sstevel@tonic-gate void
flush_icache_il(void)59*0Sstevel@tonic-gate flush_icache_il(void)
60*0Sstevel@tonic-gate {}
61*0Sstevel@tonic-gate 
62*0Sstevel@tonic-gate void
flush_pcache_il(void)63*0Sstevel@tonic-gate flush_pcache_il(void)
64*0Sstevel@tonic-gate {}
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate /*ARGSUSED*/
67*0Sstevel@tonic-gate void
flush_ecache_il(uint64_t physaddr,uint_t size,uint_t linesz)68*0Sstevel@tonic-gate flush_ecache_il(uint64_t physaddr, uint_t size, uint_t linesz)
69*0Sstevel@tonic-gate {}
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate #else /* lint */
72*0Sstevel@tonic-gate 
73*0Sstevel@tonic-gate 	!
74*0Sstevel@tonic-gate 	! bcopy32_il
75*0Sstevel@tonic-gate 	!
76*0Sstevel@tonic-gate 	! input:
77*0Sstevel@tonic-gate 	!	%o0	source PA
78*0Sstevel@tonic-gate 	!	%o1	destination PA
79*0Sstevel@tonic-gate 	!
80*0Sstevel@tonic-gate 	! returns:
81*0Sstevel@tonic-gate 	!	nothing
82*0Sstevel@tonic-gate 	!
83*0Sstevel@tonic-gate 	! A simple copy routine that copies 32 bytes using physical
84*0Sstevel@tonic-gate 	! addresses. Used by drmach_copy_rename() to copy permanent
85*0Sstevel@tonic-gate 	! memory. Assumes domain is quiesced and addresses are
86*0Sstevel@tonic-gate 	! aligned appropriately.
87*0Sstevel@tonic-gate 	!
88*0Sstevel@tonic-gate 	! Derived from Starfire DR 2.6 version of bcopy32_il.
89*0Sstevel@tonic-gate 	!
90*0Sstevel@tonic-gate 	! NOTE: The rdpr instruction executes as a noop. It has no
91*0Sstevel@tonic-gate 	! runtime value or purpose. It exists here solely for its
92*0Sstevel@tonic-gate 	! magical property that protects bcopy32_il from the
93*0Sstevel@tonic-gate 	! actions of Sun Pro's code generator. The ldxa instructions
94*0Sstevel@tonic-gate 	! used in this inline are not supported by the inline feature
95*0Sstevel@tonic-gate 	! of the Sun Pro 5.0 product. See inline(1) for details.
96*0Sstevel@tonic-gate 	! Without the rdpr, the code generator improperly rewrites
97*0Sstevel@tonic-gate 	! the instructions and emits a misrepresentation of the logic.
98*0Sstevel@tonic-gate 	!
99*0Sstevel@tonic-gate 	.inline bcopy32_il, 0
100*0Sstevel@tonic-gate 	rdpr	%pstate, %g0		! See note.
101*0Sstevel@tonic-gate         ldxa    [%o0]ASI_MEM, %o2
102*0Sstevel@tonic-gate 	add	%o0, 8, %o0
103*0Sstevel@tonic-gate         ldxa    [%o0]ASI_MEM, %o3
104*0Sstevel@tonic-gate 	add	%o0, 8, %o0
105*0Sstevel@tonic-gate         ldxa    [%o0]ASI_MEM, %o4
106*0Sstevel@tonic-gate 	add	%o0, 8, %o0
107*0Sstevel@tonic-gate         ldxa    [%o0]ASI_MEM, %o5
108*0Sstevel@tonic-gate 	stxa    %o2, [%o1]ASI_MEM
109*0Sstevel@tonic-gate 	add	%o1, 8, %o1
110*0Sstevel@tonic-gate 	stxa    %o3, [%o1]ASI_MEM
111*0Sstevel@tonic-gate 	add	%o1, 8, %o1
112*0Sstevel@tonic-gate 	stxa    %o4, [%o1]ASI_MEM
113*0Sstevel@tonic-gate 	add	%o1, 8, %o1
114*0Sstevel@tonic-gate 	stxa    %o5, [%o1]ASI_MEM
115*0Sstevel@tonic-gate 	.end
116*0Sstevel@tonic-gate 
117*0Sstevel@tonic-gate 	!
118*0Sstevel@tonic-gate 	! flush_dcache_il
119*0Sstevel@tonic-gate 	!
120*0Sstevel@tonic-gate 	! input:
121*0Sstevel@tonic-gate 	!	nothing
122*0Sstevel@tonic-gate 	!
123*0Sstevel@tonic-gate 	! output:
124*0Sstevel@tonic-gate 	!	nothing
125*0Sstevel@tonic-gate 	!
126*0Sstevel@tonic-gate 	! Flushes data cache. Used by drmach_copy_rename() after
127*0Sstevel@tonic-gate 	! the rename step to ensure the data cache tags and mtags
128*0Sstevel@tonic-gate 	! are properly synchronized. Assumes domain is quiesced.
129*0Sstevel@tonic-gate 	!
130*0Sstevel@tonic-gate 	.inline	flush_dcache_il, 0
131*0Sstevel@tonic-gate 	set	dcache_size, %o0
132*0Sstevel@tonic-gate 	ld	[%o0], %o0
133*0Sstevel@tonic-gate 	set	dcache_linesize, %o1
134*0Sstevel@tonic-gate 	ld	[%o1], %o1
135*0Sstevel@tonic-gate 	CH_DCACHE_FLUSHALL(%o0, %o1, %o2)
136*0Sstevel@tonic-gate 	.end
137*0Sstevel@tonic-gate 
138*0Sstevel@tonic-gate 	!
139*0Sstevel@tonic-gate 	! flush_icache_il
140*0Sstevel@tonic-gate 	!
141*0Sstevel@tonic-gate 	! input:
142*0Sstevel@tonic-gate 	!	nothing
143*0Sstevel@tonic-gate 	!
144*0Sstevel@tonic-gate 	! output:
145*0Sstevel@tonic-gate 	!	nothing
146*0Sstevel@tonic-gate 	!
147*0Sstevel@tonic-gate 	! Flushes instruction cache. Used by drmach_copy_rename()
148*0Sstevel@tonic-gate 	! after the rename step to ensure the instruction cache tags
149*0Sstevel@tonic-gate 	! and mtags are properly synchronized. Assumes domain is
150*0Sstevel@tonic-gate 	! quiesced.
151*0Sstevel@tonic-gate 	!
152*0Sstevel@tonic-gate 	! Panther has a larger Icache compared to Cheetahplus or Jaguar.
153*0Sstevel@tonic-gate 	!
154*0Sstevel@tonic-gate 	.inline flush_icache_il, 0
155*0Sstevel@tonic-gate 	GET_CPU_IMPL(%o0)
156*0Sstevel@tonic-gate 	cmp	%o0, PANTHER_IMPL
157*0Sstevel@tonic-gate 	bne	%xcc, 1f
158*0Sstevel@tonic-gate 	  nop
159*0Sstevel@tonic-gate 	set	PN_ICACHE_SIZE, %o0
160*0Sstevel@tonic-gate 	set	PN_ICACHE_LSIZE, %o1
161*0Sstevel@tonic-gate 	ba	2f
162*0Sstevel@tonic-gate 	  nop
163*0Sstevel@tonic-gate 1:
164*0Sstevel@tonic-gate 	set	CH_ICACHE_SIZE, %o0
165*0Sstevel@tonic-gate 	set	CH_ICACHE_LSIZE, %o1
166*0Sstevel@tonic-gate 2:
167*0Sstevel@tonic-gate 	CH_ICACHE_FLUSHALL(%o0, %o1, %o2, %o3)
168*0Sstevel@tonic-gate 	.end
169*0Sstevel@tonic-gate 
170*0Sstevel@tonic-gate 	!
171*0Sstevel@tonic-gate 	! flush_pcache_il
172*0Sstevel@tonic-gate 	!
173*0Sstevel@tonic-gate 	! input:
174*0Sstevel@tonic-gate 	!	nothing
175*0Sstevel@tonic-gate 	!
176*0Sstevel@tonic-gate 	! output:
177*0Sstevel@tonic-gate 	!	nothing
178*0Sstevel@tonic-gate 	!
179*0Sstevel@tonic-gate 	! Flushes prefetch cache. Used by drmach_copy_rename() after
180*0Sstevel@tonic-gate 	! the rename step to ensure the prefetch cache tags and mtags
181*0Sstevel@tonic-gate 	! are properly synchronized. Assumes domain is quiesced.
182*0Sstevel@tonic-gate 	!
183*0Sstevel@tonic-gate 	.inline	flush_pcache_il, 0
184*0Sstevel@tonic-gate 	PCACHE_FLUSHALL(%o1, %o2, %o3)
185*0Sstevel@tonic-gate 	.end
186*0Sstevel@tonic-gate 
187*0Sstevel@tonic-gate 	!
188*0Sstevel@tonic-gate 	! flush_ecache_il
189*0Sstevel@tonic-gate 	!
190*0Sstevel@tonic-gate 	! input:
191*0Sstevel@tonic-gate 	!	%o0	PA of flush span
192*0Sstevel@tonic-gate 	!	%o1	size of this processor's E$
193*0Sstevel@tonic-gate 	!	%o2	line size of this processor's E$
194*0Sstevel@tonic-gate 	!
195*0Sstevel@tonic-gate 	! output:
196*0Sstevel@tonic-gate 	!	nothing
197*0Sstevel@tonic-gate 	!
198*0Sstevel@tonic-gate 	! Flushes external cache. Used by drmach_copy_rename() after
199*0Sstevel@tonic-gate 	! the rename step to ensure the external cache tags and mtags
200*0Sstevel@tonic-gate 	! are properly synchronized. Assumes domain is quiesced.
201*0Sstevel@tonic-gate 	!
202*0Sstevel@tonic-gate 	! Panther needs to flush L2 cache before L3 cache.
203*0Sstevel@tonic-gate 	!
204*0Sstevel@tonic-gate 	.inline flush_ecache_il, 0
205*0Sstevel@tonic-gate         PN_L2_FLUSHALL(%o3, %o4, %o5)
206*0Sstevel@tonic-gate 	ECACHE_FLUSHALL(%o1, %o2, %o0, %o3)
207*0Sstevel@tonic-gate 	.end
208*0Sstevel@tonic-gate 
209*0Sstevel@tonic-gate #endif /* lint */
210*0Sstevel@tonic-gate 
211