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 2001,2003 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 #ifndef INLINE
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gate #include <sys/asm_linkage.h>
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gate #else /* INLINE */
44*0Sstevel@tonic-gate
45*0Sstevel@tonic-gate #define ENTRY_NP(x) .inline x,0
46*0Sstevel@tonic-gate #define retl /* nop */
47*0Sstevel@tonic-gate #define SET_SIZE(x) .end
48*0Sstevel@tonic-gate
49*0Sstevel@tonic-gate #endif /* INLINE */
50*0Sstevel@tonic-gate
51*0Sstevel@tonic-gate #include <sys/privregs.h>
52*0Sstevel@tonic-gate #include <sys/sun4asi.h>
53*0Sstevel@tonic-gate #include <sys/machparam.h>
54*0Sstevel@tonic-gate
55*0Sstevel@tonic-gate /*
56*0Sstevel@tonic-gate * Bcopy routine used by DR to copy
57*0Sstevel@tonic-gate * between physical addresses.
58*0Sstevel@tonic-gate * Borrowed from Starfire DR 2.6.
59*0Sstevel@tonic-gate */
60*0Sstevel@tonic-gate #if defined(lint)
61*0Sstevel@tonic-gate
62*0Sstevel@tonic-gate /*ARGSUSED*/
63*0Sstevel@tonic-gate void
bcopy32_il(uint64_t paddr1,uint64_t paddr2)64*0Sstevel@tonic-gate bcopy32_il(uint64_t paddr1, uint64_t paddr2)
65*0Sstevel@tonic-gate {}
66*0Sstevel@tonic-gate
67*0Sstevel@tonic-gate #else /* lint */
68*0Sstevel@tonic-gate
69*0Sstevel@tonic-gate ENTRY_NP(bcopy32_il)
70*0Sstevel@tonic-gate .register %g2, #scratch
71*0Sstevel@tonic-gate .register %g3, #scratch
72*0Sstevel@tonic-gate rdpr %pstate, %o4
73*0Sstevel@tonic-gate andn %o4, PSTATE_IE | PSTATE_AM, %g3 ! clear IE, AM bits
74*0Sstevel@tonic-gate wrpr %g0, %g3, %pstate
75*0Sstevel@tonic-gate
76*0Sstevel@tonic-gate ldxa [%o0]ASI_MEM, %o2
77*0Sstevel@tonic-gate add %o0, 8, %o0
78*0Sstevel@tonic-gate ldxa [%o0]ASI_MEM, %o3
79*0Sstevel@tonic-gate add %o0, 8, %o0
80*0Sstevel@tonic-gate ldxa [%o0]ASI_MEM, %g1
81*0Sstevel@tonic-gate add %o0, 8, %o0
82*0Sstevel@tonic-gate ldxa [%o0]ASI_MEM, %g2
83*0Sstevel@tonic-gate
84*0Sstevel@tonic-gate stxa %o2, [%o1]ASI_MEM
85*0Sstevel@tonic-gate add %o1, 8, %o1
86*0Sstevel@tonic-gate stxa %o3, [%o1]ASI_MEM
87*0Sstevel@tonic-gate add %o1, 8, %o1
88*0Sstevel@tonic-gate stxa %g1, [%o1]ASI_MEM
89*0Sstevel@tonic-gate add %o1, 8, %o1
90*0Sstevel@tonic-gate stxa %g2, [%o1]ASI_MEM
91*0Sstevel@tonic-gate
92*0Sstevel@tonic-gate retl
93*0Sstevel@tonic-gate wrpr %g0, %o4, %pstate ! restore earlier pstate register value
94*0Sstevel@tonic-gate SET_SIZE(bcopy32_il)
95*0Sstevel@tonic-gate
96*0Sstevel@tonic-gate #endif /* lint */
97*0Sstevel@tonic-gate
98*0Sstevel@tonic-gate #if defined(lint)
99*0Sstevel@tonic-gate
100*0Sstevel@tonic-gate /*ARGSUSED*/
101*0Sstevel@tonic-gate void
102*0Sstevel@tonic-gate flush_ecache_il(uint64_t physaddr, uint_t size, uint_t linesize)
103*0Sstevel@tonic-gate {}
104*0Sstevel@tonic-gate
105*0Sstevel@tonic-gate #else /* lint */
106*0Sstevel@tonic-gate
107*0Sstevel@tonic-gate ENTRY_NP(flush_ecache_il)
108*0Sstevel@tonic-gate srl %o1, 0, %o1 ! clear upper 32 bits
109*0Sstevel@tonic-gate srl %o2, 0, %o2 ! clear upper 32 bits
110*0Sstevel@tonic-gate rdpr %pstate, %o3
111*0Sstevel@tonic-gate andn %o3, PSTATE_IE | PSTATE_AM, %o4
112*0Sstevel@tonic-gate wrpr %g0, %o4, %pstate ! clear AM to access 64 bit physaddr
113*0Sstevel@tonic-gate b 2f
114*0Sstevel@tonic-gate nop
115*0Sstevel@tonic-gate 1:
116*0Sstevel@tonic-gate ldxa [%o0 + %o1]ASI_MEM, %g0 ! start reading from physaddr + size
117*0Sstevel@tonic-gate 2:
118*0Sstevel@tonic-gate subcc %o1, %o2, %o1
119*0Sstevel@tonic-gate bgeu,a 1b
120*0Sstevel@tonic-gate nop
121*0Sstevel@tonic-gate
122*0Sstevel@tonic-gate ! retl
123*0Sstevel@tonic-gate wrpr %g0, %o3, %pstate ! restore earlier pstate
124*0Sstevel@tonic-gate SET_SIZE(flush_ecache_il)
125*0Sstevel@tonic-gate
126*0Sstevel@tonic-gate #endif /* lint */
127*0Sstevel@tonic-gate
128*0Sstevel@tonic-gate #if defined(lint)
129*0Sstevel@tonic-gate
130*0Sstevel@tonic-gate /*ARGUSED*/
131*0Sstevel@tonic-gate void
stphysio_il(uint64_t physaddr,u_int value)132*0Sstevel@tonic-gate stphysio_il(uint64_t physaddr, u_int value)
133*0Sstevel@tonic-gate {}
134*0Sstevel@tonic-gate
135*0Sstevel@tonic-gate /*ARGSUSED*/
136*0Sstevel@tonic-gate u_int
ldphysio_il(uint64_t physaddr)137*0Sstevel@tonic-gate ldphysio_il(uint64_t physaddr)
138*0Sstevel@tonic-gate { return(0); }
139*0Sstevel@tonic-gate
140*0Sstevel@tonic-gate #else /* lint */
141*0Sstevel@tonic-gate
142*0Sstevel@tonic-gate ENTRY_NP(stphysio_il)
143*0Sstevel@tonic-gate rdpr %pstate, %o2 /* read PSTATE reg */
144*0Sstevel@tonic-gate andn %o2, PSTATE_IE | PSTATE_AM, %o3
145*0Sstevel@tonic-gate wrpr %g0, %o3, %pstate
146*0Sstevel@tonic-gate stwa %o1, [%o0]ASI_IO /* store value via bypass ASI */
147*0Sstevel@tonic-gate retl
148*0Sstevel@tonic-gate wrpr %g0, %o2, %pstate /* restore the PSTATE */
149*0Sstevel@tonic-gate SET_SIZE(stphysio_il)
150*0Sstevel@tonic-gate
151*0Sstevel@tonic-gate !
152*0Sstevel@tonic-gate ! load value at physical address in I/O space
153*0Sstevel@tonic-gate !
154*0Sstevel@tonic-gate ! u_int ldphysio_il(uint64_t physaddr)
155*0Sstevel@tonic-gate !
156*0Sstevel@tonic-gate ENTRY_NP(ldphysio_il)
157*0Sstevel@tonic-gate rdpr %pstate, %o2 /* read PSTATE reg */
158*0Sstevel@tonic-gate andn %o2, PSTATE_IE | PSTATE_AM, %o3
159*0Sstevel@tonic-gate wrpr %g0, %o3, %pstate
160*0Sstevel@tonic-gate lduwa [%o0]ASI_IO, %o0 /* load value via bypass ASI */
161*0Sstevel@tonic-gate retl
162*0Sstevel@tonic-gate wrpr %g0, %o2, %pstate /* restore pstate */
163*0Sstevel@tonic-gate SET_SIZE(ldphysio_il)
164*0Sstevel@tonic-gate
165*0Sstevel@tonic-gate #endif /* lint */
166*0Sstevel@tonic-gate
167*0Sstevel@tonic-gate #if defined(lint)
168*0Sstevel@tonic-gate
169*0Sstevel@tonic-gate /*
170*0Sstevel@tonic-gate * Argument to drmach_exec_script_il is a pointer to:
171*0Sstevel@tonic-gate *
172*0Sstevel@tonic-gate * typedef struct {
173*0Sstevel@tonic-gate * uint64_t masr_addr;
174*0Sstevel@tonic-gate * uint_t masr;
175*0Sstevel@tonic-gate * uint_t _filler;
176*0Sstevel@tonic-gate * } drmach_rename_script_t;
177*0Sstevel@tonic-gate */
178*0Sstevel@tonic-gate
179*0Sstevel@tonic-gate /*ARGUSED*/
180*0Sstevel@tonic-gate void
181*0Sstevel@tonic-gate drmach_exec_script_il(void *sp)
182*0Sstevel@tonic-gate {}
183*0Sstevel@tonic-gate
184*0Sstevel@tonic-gate #else /* lint */
185*0Sstevel@tonic-gate
186*0Sstevel@tonic-gate ENTRY_NP(drmach_exec_script_il)
187*0Sstevel@tonic-gate mov %o0, %o2
188*0Sstevel@tonic-gate 0: /* cache script */
189*0Sstevel@tonic-gate ldx [%o2], %o1
190*0Sstevel@tonic-gate cmp %g0, %o1
191*0Sstevel@tonic-gate bnz,pt %xcc, 0b
192*0Sstevel@tonic-gate add %o2, 16, %o2
193*0Sstevel@tonic-gate
194*0Sstevel@tonic-gate rdpr %pstate, %o4 /* read PSTATE reg */
195*0Sstevel@tonic-gate andn %o4, PSTATE_IE | PSTATE_AM, %o1
196*0Sstevel@tonic-gate wrpr %g0, %o1, %pstate
197*0Sstevel@tonic-gate
198*0Sstevel@tonic-gate b 2f /* cache it */
199*0Sstevel@tonic-gate nop
200*0Sstevel@tonic-gate 1:
201*0Sstevel@tonic-gate ldx [%o0], %o1
202*0Sstevel@tonic-gate cmp %g0, %o1
203*0Sstevel@tonic-gate bz,pn %xcc, 5f
204*0Sstevel@tonic-gate ld [%o0 + 8], %o2
205*0Sstevel@tonic-gate b 3f
206*0Sstevel@tonic-gate stwa %o2, [%o1]ASI_IO
207*0Sstevel@tonic-gate 2:
208*0Sstevel@tonic-gate b 4f /* cache it */
209*0Sstevel@tonic-gate nop
210*0Sstevel@tonic-gate 3:
211*0Sstevel@tonic-gate add %o0, 16, %o0
212*0Sstevel@tonic-gate b 1b
213*0Sstevel@tonic-gate lduwa [%o1]ASI_IO, %g0 /* read back to insure written */
214*0Sstevel@tonic-gate 4:
215*0Sstevel@tonic-gate b 1b /* caching done */
216*0Sstevel@tonic-gate nop
217*0Sstevel@tonic-gate 5:
218*0Sstevel@tonic-gate retl
219*0Sstevel@tonic-gate wrpr %g0, %o4, %pstate /* restore the PSTATE */
220*0Sstevel@tonic-gate SET_SIZE(drmach_exec_script_il)
221*0Sstevel@tonic-gate
222*0Sstevel@tonic-gate #endif /* lint */
223