8354 sync regcomp(3C) with upstream (fix make catalog)
[unleashed/tickless.git] / usr / src / uts / sun4u / serengeti / ml / sbdp.il.cpp
blobda0549af29c46b5ecb3c3fbf1bea2415ea5d8bf3
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
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.
35 #if defined(lint)
36 #include <sys/types.h>
37 #endif /* lint */
39 #ifndef INLINE
41 #include <sys/asm_linkage.h>
43 #else /* INLINE */
45 #define ENTRY_NP(x) .inline x,0
46 #define retl /* nop */
47 #define SET_SIZE(x) .end
49 #endif /* INLINE */
51 #include <sys/privregs.h>
52 #include <sys/sun4asi.h>
53 #include <sys/machparam.h>
54 #include <sys/machthread.h>
55 #include <sys/cheetahregs.h>
56 #include <sys/cheetahasm.h>
59 * Bcopy routine used by DR to copy
60 * between physical addresses.
61 * Borrowed from Starfire DR 2.6.
63 #if defined(lint)
65 /*ARGSUSED*/
66 void
67 bcopy32_il(uint64_t paddr1, uint64_t paddr2)
70 #else /* lint */
72 ENTRY_NP(bcopy32_il)
73 .register %g2, #scratch
74 .register %g3, #scratch
75 rdpr %pstate, %o4
76 andn %o4, PSTATE_IE | PSTATE_AM, %g3 ! clear IE, AM bits
77 wrpr %g0, %g3, %pstate
79 ldxa [%o0]ASI_MEM, %o2
80 add %o0, 8, %o0
81 ldxa [%o0]ASI_MEM, %o3
82 add %o0, 8, %o0
83 ldxa [%o0]ASI_MEM, %g1
84 add %o0, 8, %o0
85 ldxa [%o0]ASI_MEM, %g2
87 stxa %o2, [%o1]ASI_MEM
88 add %o1, 8, %o1
89 stxa %o3, [%o1]ASI_MEM
90 add %o1, 8, %o1
91 stxa %g1, [%o1]ASI_MEM
92 add %o1, 8, %o1
93 stxa %g2, [%o1]ASI_MEM
95 stxa %g0, [%o1]ASI_DC_INVAL /* flush line from dcache */
96 membar #Sync
98 retl
99 wrpr %g0, %o4, %pstate ! restore earlier pstate register value
100 SET_SIZE(bcopy32_il)
102 #endif /* lint */
104 #if defined(lint)
106 /*ARGSUSED*/
107 void
108 flush_ecache_il(uint64_t physaddr, uint_t size, uint_t linesize)
111 #else /* lint */
113 ENTRY_NP(flush_ecache_il)
114 rdpr %pstate, %o3
115 andn %o3, PSTATE_IE | PSTATE_AM, %o4
116 wrpr %g0, %o4, %pstate ! clear AM to access 64 bit physaddr
117 GET_CPU_IMPL(%o4)
118 cmp %o4, PANTHER_IMPL
119 bne %xcc, 3f
121 ! Panther needs to flush L2 before L3.
123 ! We need to free up a temp reg for the L2 flush macro (register usage
124 ! convention for inlines allows %o0-%o5, %f0-%f31 as temporaries.)
125 ! Since physaddr is only used for Cheetah, Panther can use %o0 for
126 ! the L2 flush.
127 PN_L2_FLUSHALL(%o0, %o4, %o5)
129 ECACHE_FLUSHALL(%o1, %o2, %o0, %o4)
130 wrpr %g0, %o3, %pstate ! restore earlier pstate
131 SET_SIZE(flush_ecache_il)
133 #endif /* lint */
135 #if defined(lint)
137 /*ARGUSED*/
138 void
139 stphysio_il(uint64_t physaddr, u_int value)
142 /*ARGSUSED*/
143 u_int
144 ldphysio_il(uint64_t physaddr)
145 { return(0); }
147 uint64_t
148 lddphys_il(uint64_t physaddr)
149 { return (0x0ull); }
151 uint64_t
152 ldxasi_il(uint64_t physaddr, uint_t asi)
153 { return (0x0ull); }
155 #else /* lint */
157 ENTRY_NP(stphysio_il)
158 rdpr %pstate, %o2 /* read PSTATE reg */
159 andn %o2, PSTATE_IE | PSTATE_AM, %o3
160 wrpr %g0, %o3, %pstate
161 stwa %o1, [%o0]ASI_IO /* store value via bypass ASI */
162 retl
163 wrpr %g0, %o2, %pstate /* restore the PSTATE */
164 SET_SIZE(stphysio_il)
167 ! load value at physical address in I/O space
169 ! u_int ldphysio_il(uint64_t physaddr)
171 ENTRY_NP(ldphysio_il)
172 rdpr %pstate, %o2 /* read PSTATE reg */
173 andn %o2, PSTATE_IE | PSTATE_AM, %o3
174 wrpr %g0, %o3, %pstate
175 lduwa [%o0]ASI_IO, %o0 /* load value via bypass ASI */
176 retl
177 wrpr %g0, %o2, %pstate /* restore pstate */
178 SET_SIZE(ldphysio_il)
181 ! Load long word value at physical address
183 ! uint64_t lddphys_il(uint64_t physaddr)
185 ENTRY_NP(lddphys_il)
186 rdpr %pstate, %o4
187 andn %o4, PSTATE_IE | PSTATE_AM, %o5
188 wrpr %o5, 0, %pstate
189 ldxa [%o0]ASI_MEM, %o0
190 retl
191 wrpr %g0, %o4, %pstate /* restore earlier pstate register value */
192 SET_SIZE(lddphys_il)
195 ! Load long word value from designated asi.
197 ! uint64_t ldxasi_il(uint64_t physaddr, uint_t asi)
199 ENTRY_NP(ldxasi_il)
200 rdpr %pstate, %o4
201 andn %o4, PSTATE_IE | PSTATE_AM, %o5
202 wrpr %o5, 0, %pstate
203 wr %o1, 0, %asi
204 ldxa [%o0]%asi, %o0
205 retl
206 wrpr %g0, %o4, %pstate /* restore earlier pstate register value */
207 SET_SIZE(ldxasi_il)
209 #endif /* lint */
211 #if defined(lint)
214 * Argument to sbdp_exec_script_il is a pointer to:
216 * typedef struct {
217 * uint64_t masr_addr;
218 * uint64_t masr;
219 * uint_t asi;
220 * uint_t _filler;
221 * } sbdp_rename_script_t;
224 /*ARGUSED*/
225 void
226 sbdp_exec_script_il(void *sp)
229 #else /* lint */
231 ENTRY_NP(sbdp_exec_script_il)
232 mov %o0, %o2
234 rdpr %pstate, %o4 /* read PSTATE reg */
235 andn %o4, PSTATE_IE | PSTATE_AM, %o1
236 wrpr %g0, %o1, %pstate
238 membar #Sync
240 0: /* cache script */
241 ldx [%o2], %o1
242 ldx [%o2 + 16], %o1
243 cmp %g0, %o1
244 bnz,pt %xcc, 0b
245 add %o2, 24, %o2
247 b 2f /* cache it */
250 ldx [%o0], %o1
251 brz,pn %o1, 5f
252 ld [%o0 + 16], %o2
253 wr %o2, 0, %asi
254 b 3f
257 b 4f /* cache it */
260 ldx [%o0 + 8], %o2
261 stxa %o2, [%o1]%asi
262 membar #Sync
263 add %o0, 24, %o0
264 b 1b
265 ldxa [%o1]%asi, %g0 /* read back to insure written */
267 b 1b /* caching done */
270 retl
271 wrpr %g0, %o4, %pstate /* restore the PSTATE */
272 SET_SIZE(sbdp_exec_script_il)
274 #endif /* lint */