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