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