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]
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.
36 #include <sys/types.h>
41 #include <sys/asm_linkage.h>
45 #define ENTRY_NP(x) .inline x,0
46 #define retl /* nop */
47 #define SET_SIZE(x) .end
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.
67 bcopy32_il(uint64_t paddr1
, uint64_t paddr2
)
73 .register %g2
, #scratch
74 .register %g3
, #scratch
76 andn
%o4
, PSTATE_IE
| PSTATE_AM
, %g3
! clear IE
, AM bits
77 wrpr
%g0
, %g3
, %pstate
79 ldxa
[%o0
]ASI_MEM
, %o2
81 ldxa
[%o0
]ASI_MEM
, %o3
83 ldxa
[%o0
]ASI_MEM
, %g1
85 ldxa
[%o0
]ASI_MEM
, %g2
87 stxa
%o2
, [%o1
]ASI_MEM
89 stxa
%o3
, [%o1
]ASI_MEM
91 stxa
%g1
, [%o1
]ASI_MEM
93 stxa
%g2
, [%o1
]ASI_MEM
95 stxa
%g0
, [%o1
]ASI_DC_INVAL
/* flush line from dcache */
99 wrpr
%g0
, %o4
, %pstate
! restore earlier pstate
register value
108 flush_ecache_il(uint64_t physaddr
, uint_t size
, uint_t linesize
)
113 ENTRY_NP(flush_ecache_il
)
115 andn
%o3
, PSTATE_IE
| PSTATE_AM
, %o4
116 wrpr
%g0
, %o4
, %pstate
! clear AM to access
64 bit physaddr
118 cmp
%o4
, PANTHER_IMPL
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
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
)
139 stphysio_il(uint64_t physaddr
, u_int value
)
144 ldphysio_il(uint64_t physaddr
)
148 lddphys_il(uint64_t physaddr
)
152 ldxasi_il(uint64_t physaddr
, uint_t asi
)
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 */
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 */
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
)
187 andn
%o4
, PSTATE_IE
| PSTATE_AM
, %o5
189 ldxa
[%o0
]ASI_MEM
, %o0
191 wrpr
%g0
, %o4
, %pstate
/* restore earlier pstate register value */
195 ! Load
long word value from designated asi
.
197 ! uint64_t ldxasi_il(uint64_t physaddr
, uint_t asi
)
201 andn
%o4
, PSTATE_IE
| PSTATE_AM
, %o5
206 wrpr
%g0
, %o4
, %pstate
/* restore earlier pstate register value */
214 * Argument to sbdp_exec_script_il is a pointer to:
217 * uint64_t masr_addr;
221 * } sbdp_rename_script_t;
226 sbdp_exec_script_il(void *sp
)
231 ENTRY_NP(sbdp_exec_script_il
)
234 rdpr
%pstate
, %o4
/* read PSTATE reg */
235 andn
%o4
, PSTATE_IE
| PSTATE_AM
, %o1
236 wrpr
%g0
, %o1
, %pstate
240 0: /* cache script */
265 ldxa
[%o1
]%asi
, %g0
/* read back to insure written */
267 b
1b
/* caching done */
271 wrpr
%g0
, %o4
, %pstate
/* restore the PSTATE */
272 SET_SIZE(sbdp_exec_script_il
)