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