xref: /onnv-gate/usr/src/uts/intel/ia32/os/ddi_i86.c (revision 0:68f95e015346)
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 2004 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 #include <sys/conf.h>
30*0Sstevel@tonic-gate #include <sys/kmem.h>
31*0Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
32*0Sstevel@tonic-gate #include <sys/ddi.h>
33*0Sstevel@tonic-gate #include <sys/sunddi.h>
34*0Sstevel@tonic-gate #include <sys/ddifm.h>
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate 
37*0Sstevel@tonic-gate /*
38*0Sstevel@tonic-gate  * DDI DMA Engine functions for x86.
39*0Sstevel@tonic-gate  * These functions are more naturally generic, but do not apply to SPARC.
40*0Sstevel@tonic-gate  */
41*0Sstevel@tonic-gate 
42*0Sstevel@tonic-gate int
43*0Sstevel@tonic-gate ddi_dmae_alloc(dev_info_t *dip, int chnl, int (*dmae_waitfp)(), caddr_t arg)
44*0Sstevel@tonic-gate {
45*0Sstevel@tonic-gate 	return (ddi_dma_mctl(dip, dip, 0, DDI_DMA_E_ACQUIRE,
46*0Sstevel@tonic-gate 	    (off_t *)dmae_waitfp, (size_t *)arg,
47*0Sstevel@tonic-gate 	    (caddr_t *)(uintptr_t)chnl, 0));
48*0Sstevel@tonic-gate }
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate int
51*0Sstevel@tonic-gate ddi_dmae_release(dev_info_t *dip, int chnl)
52*0Sstevel@tonic-gate {
53*0Sstevel@tonic-gate 	return (ddi_dma_mctl(dip, dip, 0, DDI_DMA_E_FREE, 0, 0,
54*0Sstevel@tonic-gate 	    (caddr_t *)(uintptr_t)chnl, 0));
55*0Sstevel@tonic-gate }
56*0Sstevel@tonic-gate 
57*0Sstevel@tonic-gate int
58*0Sstevel@tonic-gate ddi_dmae_getlim(dev_info_t *dip, ddi_dma_lim_t *limitsp)
59*0Sstevel@tonic-gate {
60*0Sstevel@tonic-gate 	return (ddi_dma_mctl(dip, dip, 0, DDI_DMA_E_GETLIM, 0, 0,
61*0Sstevel@tonic-gate 	    (caddr_t *)limitsp, 0));
62*0Sstevel@tonic-gate }
63*0Sstevel@tonic-gate 
64*0Sstevel@tonic-gate int
65*0Sstevel@tonic-gate ddi_dmae_getattr(dev_info_t *dip, ddi_dma_attr_t *attrp)
66*0Sstevel@tonic-gate {
67*0Sstevel@tonic-gate 	return (ddi_dma_mctl(dip, dip, 0, DDI_DMA_E_GETATTR, 0, 0,
68*0Sstevel@tonic-gate 	    (caddr_t *)attrp, 0));
69*0Sstevel@tonic-gate }
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate int
72*0Sstevel@tonic-gate ddi_dmae_1stparty(dev_info_t *dip, int chnl)
73*0Sstevel@tonic-gate {
74*0Sstevel@tonic-gate 	return (ddi_dma_mctl(dip, dip, 0, DDI_DMA_E_1STPTY, 0, 0,
75*0Sstevel@tonic-gate 	    (caddr_t *)(uintptr_t)chnl, 0));
76*0Sstevel@tonic-gate }
77*0Sstevel@tonic-gate 
78*0Sstevel@tonic-gate int
79*0Sstevel@tonic-gate ddi_dmae_prog(dev_info_t *dip, struct ddi_dmae_req *dmaereqp,
80*0Sstevel@tonic-gate 	ddi_dma_cookie_t *cookiep, int chnl)
81*0Sstevel@tonic-gate {
82*0Sstevel@tonic-gate 	return (ddi_dma_mctl(dip, dip, 0, DDI_DMA_E_PROG, (off_t *)dmaereqp,
83*0Sstevel@tonic-gate 	    (size_t *)cookiep, (caddr_t *)(uintptr_t)chnl, 0));
84*0Sstevel@tonic-gate }
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate int
87*0Sstevel@tonic-gate ddi_dmae_swsetup(dev_info_t *dip, struct ddi_dmae_req *dmaereqp,
88*0Sstevel@tonic-gate 	ddi_dma_cookie_t *cookiep, int chnl)
89*0Sstevel@tonic-gate {
90*0Sstevel@tonic-gate 	return (ddi_dma_mctl(dip, dip, 0, DDI_DMA_E_SWSETUP, (off_t *)dmaereqp,
91*0Sstevel@tonic-gate 	    (size_t *)cookiep, (caddr_t *)(uintptr_t)chnl, 0));
92*0Sstevel@tonic-gate }
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate int
95*0Sstevel@tonic-gate ddi_dmae_swstart(dev_info_t *dip, int chnl)
96*0Sstevel@tonic-gate {
97*0Sstevel@tonic-gate 	return (ddi_dma_mctl(dip, dip, 0, DDI_DMA_E_SWSTART, 0, 0,
98*0Sstevel@tonic-gate 	    (caddr_t *)(uintptr_t)chnl, 0));
99*0Sstevel@tonic-gate }
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate int
102*0Sstevel@tonic-gate ddi_dmae_stop(dev_info_t *dip, int chnl)
103*0Sstevel@tonic-gate {
104*0Sstevel@tonic-gate 	return (ddi_dma_mctl(dip, dip, 0, DDI_DMA_E_STOP, 0, 0,
105*0Sstevel@tonic-gate 	    (caddr_t *)(uintptr_t)chnl, 0));
106*0Sstevel@tonic-gate }
107*0Sstevel@tonic-gate 
108*0Sstevel@tonic-gate int
109*0Sstevel@tonic-gate ddi_dmae_enable(dev_info_t *dip, int chnl)
110*0Sstevel@tonic-gate {
111*0Sstevel@tonic-gate 	return (ddi_dma_mctl(dip, dip, 0, DDI_DMA_E_ENABLE, 0, 0,
112*0Sstevel@tonic-gate 	    (caddr_t *)(uintptr_t)chnl, 0));
113*0Sstevel@tonic-gate }
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate int
116*0Sstevel@tonic-gate ddi_dmae_disable(dev_info_t *dip, int chnl)
117*0Sstevel@tonic-gate {
118*0Sstevel@tonic-gate 	return (ddi_dma_mctl(dip, dip, 0, DDI_DMA_E_DISABLE, 0, 0,
119*0Sstevel@tonic-gate 	    (caddr_t *)(uintptr_t)chnl, 0));
120*0Sstevel@tonic-gate }
121*0Sstevel@tonic-gate 
122*0Sstevel@tonic-gate int
123*0Sstevel@tonic-gate ddi_dmae_getcnt(dev_info_t *dip, int chnl, int *countp)
124*0Sstevel@tonic-gate {
125*0Sstevel@tonic-gate 	return (ddi_dma_mctl(dip, dip, 0, DDI_DMA_E_GETCNT, 0, (size_t *)countp,
126*0Sstevel@tonic-gate 	    (caddr_t *)(uintptr_t)chnl, 0));
127*0Sstevel@tonic-gate }
128*0Sstevel@tonic-gate 
129*0Sstevel@tonic-gate /*
130*0Sstevel@tonic-gate  * implementation specific access handle and routines:
131*0Sstevel@tonic-gate  */
132*0Sstevel@tonic-gate 
133*0Sstevel@tonic-gate static uintptr_t impl_acc_hdl_id = 0;
134*0Sstevel@tonic-gate 
135*0Sstevel@tonic-gate /*
136*0Sstevel@tonic-gate  * access handle allocator
137*0Sstevel@tonic-gate  */
138*0Sstevel@tonic-gate ddi_acc_hdl_t *
139*0Sstevel@tonic-gate impl_acc_hdl_get(ddi_acc_handle_t hdl)
140*0Sstevel@tonic-gate {
141*0Sstevel@tonic-gate 	/*
142*0Sstevel@tonic-gate 	 * recast to ddi_acc_hdl_t instead of
143*0Sstevel@tonic-gate 	 * casting to ddi_acc_impl_t and then return the ah_platform_private
144*0Sstevel@tonic-gate 	 *
145*0Sstevel@tonic-gate 	 * this optimization based on the ddi_acc_hdl_t is the
146*0Sstevel@tonic-gate 	 * first member of the ddi_acc_impl_t.
147*0Sstevel@tonic-gate 	 */
148*0Sstevel@tonic-gate 	return ((ddi_acc_hdl_t *)hdl);
149*0Sstevel@tonic-gate }
150*0Sstevel@tonic-gate 
151*0Sstevel@tonic-gate ddi_acc_handle_t
152*0Sstevel@tonic-gate impl_acc_hdl_alloc(int (*waitfp)(caddr_t), caddr_t arg)
153*0Sstevel@tonic-gate {
154*0Sstevel@tonic-gate 	ddi_acc_impl_t *hp;
155*0Sstevel@tonic-gate 	int sleepflag;
156*0Sstevel@tonic-gate 
157*0Sstevel@tonic-gate 	sleepflag = ((waitfp == (int (*)())KM_SLEEP) ? KM_SLEEP : KM_NOSLEEP);
158*0Sstevel@tonic-gate 	/*
159*0Sstevel@tonic-gate 	 * Allocate and initialize the data access handle.
160*0Sstevel@tonic-gate 	 */
161*0Sstevel@tonic-gate 	hp = kmem_zalloc(sizeof (ddi_acc_impl_t), sleepflag);
162*0Sstevel@tonic-gate 	if (!hp) {
163*0Sstevel@tonic-gate 		if ((waitfp != (int (*)())KM_SLEEP) &&
164*0Sstevel@tonic-gate 		    (waitfp != (int (*)())KM_NOSLEEP))
165*0Sstevel@tonic-gate 			ddi_set_callback(waitfp, arg, &impl_acc_hdl_id);
166*0Sstevel@tonic-gate 		return (NULL);
167*0Sstevel@tonic-gate 	}
168*0Sstevel@tonic-gate 	hp->ahi_common.ah_platform_private = (void *)hp;
169*0Sstevel@tonic-gate 	return ((ddi_acc_handle_t)hp);
170*0Sstevel@tonic-gate }
171*0Sstevel@tonic-gate 
172*0Sstevel@tonic-gate void
173*0Sstevel@tonic-gate impl_acc_hdl_free(ddi_acc_handle_t handle)
174*0Sstevel@tonic-gate {
175*0Sstevel@tonic-gate 	ddi_acc_impl_t *hp;
176*0Sstevel@tonic-gate 
177*0Sstevel@tonic-gate 	hp = (ddi_acc_impl_t *)handle;
178*0Sstevel@tonic-gate 	if (hp) {
179*0Sstevel@tonic-gate 		kmem_free(hp, sizeof (*hp));
180*0Sstevel@tonic-gate 		if (impl_acc_hdl_id)
181*0Sstevel@tonic-gate 			ddi_run_callback(&impl_acc_hdl_id);
182*0Sstevel@tonic-gate 	}
183*0Sstevel@tonic-gate }
184*0Sstevel@tonic-gate 
185*0Sstevel@tonic-gate void
186*0Sstevel@tonic-gate impl_acc_err_init(ddi_acc_hdl_t *handlep)
187*0Sstevel@tonic-gate {
188*0Sstevel@tonic-gate 	/* Error handling not supported */
189*0Sstevel@tonic-gate 	handlep->ah_acc.devacc_attr_access = DDI_DEFAULT_ACC;
190*0Sstevel@tonic-gate }
191*0Sstevel@tonic-gate 
192*0Sstevel@tonic-gate void
193*0Sstevel@tonic-gate impl_acc_hdl_init(ddi_acc_hdl_t *handlep)
194*0Sstevel@tonic-gate {
195*0Sstevel@tonic-gate 	ddi_acc_impl_t *hp;
196*0Sstevel@tonic-gate 
197*0Sstevel@tonic-gate 	if (!handlep)
198*0Sstevel@tonic-gate 		return;
199*0Sstevel@tonic-gate 	hp = (ddi_acc_impl_t *)handlep->ah_platform_private;
200*0Sstevel@tonic-gate 
201*0Sstevel@tonic-gate 	if (hp->ahi_acc_attr & DDI_ACCATTR_IO_SPACE) {
202*0Sstevel@tonic-gate 		hp->ahi_get8 = i_ddi_io_get8;
203*0Sstevel@tonic-gate 		hp->ahi_put8 = i_ddi_io_put8;
204*0Sstevel@tonic-gate 		hp->ahi_rep_get8 = i_ddi_io_rep_get8;
205*0Sstevel@tonic-gate 		hp->ahi_rep_put8 = i_ddi_io_rep_put8;
206*0Sstevel@tonic-gate 
207*0Sstevel@tonic-gate 		/* temporary set these 64 functions to no-ops */
208*0Sstevel@tonic-gate 		hp->ahi_get64 = i_ddi_io_get64;
209*0Sstevel@tonic-gate 		hp->ahi_put64 = i_ddi_io_put64;
210*0Sstevel@tonic-gate 		hp->ahi_rep_get64 = i_ddi_io_rep_get64;
211*0Sstevel@tonic-gate 		hp->ahi_rep_put64 = i_ddi_io_rep_put64;
212*0Sstevel@tonic-gate 
213*0Sstevel@tonic-gate 		/*
214*0Sstevel@tonic-gate 		 * check for BIG endian access
215*0Sstevel@tonic-gate 		 */
216*0Sstevel@tonic-gate 		if (handlep->ah_acc.devacc_attr_endian_flags ==
217*0Sstevel@tonic-gate 			DDI_STRUCTURE_BE_ACC) {
218*0Sstevel@tonic-gate 			hp->ahi_get16 = i_ddi_io_swap_get16;
219*0Sstevel@tonic-gate 			hp->ahi_get32 = i_ddi_io_swap_get32;
220*0Sstevel@tonic-gate 			hp->ahi_put16 = i_ddi_io_swap_put16;
221*0Sstevel@tonic-gate 			hp->ahi_put32 = i_ddi_io_swap_put32;
222*0Sstevel@tonic-gate 			hp->ahi_rep_get16 = i_ddi_io_swap_rep_get16;
223*0Sstevel@tonic-gate 			hp->ahi_rep_get32 = i_ddi_io_swap_rep_get32;
224*0Sstevel@tonic-gate 			hp->ahi_rep_put16 = i_ddi_io_swap_rep_put16;
225*0Sstevel@tonic-gate 			hp->ahi_rep_put32 = i_ddi_io_swap_rep_put32;
226*0Sstevel@tonic-gate 		} else {
227*0Sstevel@tonic-gate 			hp->ahi_acc_attr |= DDI_ACCATTR_DIRECT;
228*0Sstevel@tonic-gate 			hp->ahi_get16 = i_ddi_io_get16;
229*0Sstevel@tonic-gate 			hp->ahi_get32 = i_ddi_io_get32;
230*0Sstevel@tonic-gate 			hp->ahi_put16 = i_ddi_io_put16;
231*0Sstevel@tonic-gate 			hp->ahi_put32 = i_ddi_io_put32;
232*0Sstevel@tonic-gate 			hp->ahi_rep_get16 = i_ddi_io_rep_get16;
233*0Sstevel@tonic-gate 			hp->ahi_rep_get32 = i_ddi_io_rep_get32;
234*0Sstevel@tonic-gate 			hp->ahi_rep_put16 = i_ddi_io_rep_put16;
235*0Sstevel@tonic-gate 			hp->ahi_rep_put32 = i_ddi_io_rep_put32;
236*0Sstevel@tonic-gate 		}
237*0Sstevel@tonic-gate 
238*0Sstevel@tonic-gate 	} else if (hp->ahi_acc_attr & DDI_ACCATTR_CPU_VADDR) {
239*0Sstevel@tonic-gate 
240*0Sstevel@tonic-gate 		hp->ahi_get8 = i_ddi_vaddr_get8;
241*0Sstevel@tonic-gate 		hp->ahi_put8 = i_ddi_vaddr_put8;
242*0Sstevel@tonic-gate 		hp->ahi_rep_get8 = i_ddi_vaddr_rep_get8;
243*0Sstevel@tonic-gate 		hp->ahi_rep_put8 = i_ddi_vaddr_rep_put8;
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate 		/*
246*0Sstevel@tonic-gate 		 * check for BIG endian access
247*0Sstevel@tonic-gate 		 */
248*0Sstevel@tonic-gate 		if (handlep->ah_acc.devacc_attr_endian_flags ==
249*0Sstevel@tonic-gate 			DDI_STRUCTURE_BE_ACC) {
250*0Sstevel@tonic-gate 
251*0Sstevel@tonic-gate 			hp->ahi_get16 = i_ddi_vaddr_swap_get16;
252*0Sstevel@tonic-gate 			hp->ahi_get32 = i_ddi_vaddr_swap_get32;
253*0Sstevel@tonic-gate 			hp->ahi_get64 = i_ddi_vaddr_swap_get64;
254*0Sstevel@tonic-gate 			hp->ahi_put16 = i_ddi_vaddr_swap_put16;
255*0Sstevel@tonic-gate 			hp->ahi_put32 = i_ddi_vaddr_swap_put32;
256*0Sstevel@tonic-gate 			hp->ahi_put64 = i_ddi_vaddr_swap_put64;
257*0Sstevel@tonic-gate 			hp->ahi_rep_get16 = i_ddi_vaddr_swap_rep_get16;
258*0Sstevel@tonic-gate 			hp->ahi_rep_get32 = i_ddi_vaddr_swap_rep_get32;
259*0Sstevel@tonic-gate 			hp->ahi_rep_get64 = i_ddi_vaddr_swap_rep_get64;
260*0Sstevel@tonic-gate 			hp->ahi_rep_put16 = i_ddi_vaddr_swap_rep_put16;
261*0Sstevel@tonic-gate 			hp->ahi_rep_put32 = i_ddi_vaddr_swap_rep_put32;
262*0Sstevel@tonic-gate 			hp->ahi_rep_put64 = i_ddi_vaddr_swap_rep_put64;
263*0Sstevel@tonic-gate 		} else {
264*0Sstevel@tonic-gate 			hp->ahi_acc_attr |= DDI_ACCATTR_DIRECT;
265*0Sstevel@tonic-gate 			hp->ahi_get16 = i_ddi_vaddr_get16;
266*0Sstevel@tonic-gate 			hp->ahi_get32 = i_ddi_vaddr_get32;
267*0Sstevel@tonic-gate 			hp->ahi_get64 = i_ddi_vaddr_get64;
268*0Sstevel@tonic-gate 			hp->ahi_put16 = i_ddi_vaddr_put16;
269*0Sstevel@tonic-gate 			hp->ahi_put32 = i_ddi_vaddr_put32;
270*0Sstevel@tonic-gate 			hp->ahi_put64 = i_ddi_vaddr_put64;
271*0Sstevel@tonic-gate 			hp->ahi_rep_get16 = i_ddi_vaddr_rep_get16;
272*0Sstevel@tonic-gate 			hp->ahi_rep_get32 = i_ddi_vaddr_rep_get32;
273*0Sstevel@tonic-gate 			hp->ahi_rep_get64 = i_ddi_vaddr_rep_get64;
274*0Sstevel@tonic-gate 			hp->ahi_rep_put16 = i_ddi_vaddr_rep_put16;
275*0Sstevel@tonic-gate 			hp->ahi_rep_put32 = i_ddi_vaddr_rep_put32;
276*0Sstevel@tonic-gate 			hp->ahi_rep_put64 = i_ddi_vaddr_rep_put64;
277*0Sstevel@tonic-gate 		}
278*0Sstevel@tonic-gate 	}
279*0Sstevel@tonic-gate 	hp->ahi_fault_check = i_ddi_acc_fault_check;
280*0Sstevel@tonic-gate 	hp->ahi_fault_notify = i_ddi_acc_fault_notify;
281*0Sstevel@tonic-gate 	hp->ahi_fault = 0;
282*0Sstevel@tonic-gate 	impl_acc_err_init(handlep);
283*0Sstevel@tonic-gate }
284*0Sstevel@tonic-gate 
285*0Sstevel@tonic-gate /*
286*0Sstevel@tonic-gate  * The followings are low-level routines for data access.
287*0Sstevel@tonic-gate  *
288*0Sstevel@tonic-gate  * All of these routines should be implemented in assembly. Those
289*0Sstevel@tonic-gate  * that have been rewritten be found in ~ml/ddi_i86_asm.s
290*0Sstevel@tonic-gate  */
291*0Sstevel@tonic-gate 
292*0Sstevel@tonic-gate /*ARGSUSED*/
293*0Sstevel@tonic-gate uint16_t
294*0Sstevel@tonic-gate i_ddi_vaddr_swap_get16(ddi_acc_impl_t *hdlp, uint16_t *addr)
295*0Sstevel@tonic-gate {
296*0Sstevel@tonic-gate 	return (ddi_swap16(*addr));
297*0Sstevel@tonic-gate }
298*0Sstevel@tonic-gate 
299*0Sstevel@tonic-gate /*ARGSUSED*/
300*0Sstevel@tonic-gate uint16_t
301*0Sstevel@tonic-gate i_ddi_io_swap_get16(ddi_acc_impl_t *hdlp, uint16_t *addr)
302*0Sstevel@tonic-gate {
303*0Sstevel@tonic-gate 	return (ddi_swap16(inw((uintptr_t)addr)));
304*0Sstevel@tonic-gate }
305*0Sstevel@tonic-gate 
306*0Sstevel@tonic-gate /*ARGSUSED*/
307*0Sstevel@tonic-gate uint32_t
308*0Sstevel@tonic-gate i_ddi_vaddr_swap_get32(ddi_acc_impl_t *hdlp, uint32_t *addr)
309*0Sstevel@tonic-gate {
310*0Sstevel@tonic-gate 	return (ddi_swap32(*addr));
311*0Sstevel@tonic-gate }
312*0Sstevel@tonic-gate 
313*0Sstevel@tonic-gate /*ARGSUSED*/
314*0Sstevel@tonic-gate uint32_t
315*0Sstevel@tonic-gate i_ddi_io_swap_get32(ddi_acc_impl_t *hdlp, uint32_t *addr)
316*0Sstevel@tonic-gate {
317*0Sstevel@tonic-gate 	return (ddi_swap32(inl((uintptr_t)addr)));
318*0Sstevel@tonic-gate }
319*0Sstevel@tonic-gate 
320*0Sstevel@tonic-gate /*ARGSUSED*/
321*0Sstevel@tonic-gate uint64_t
322*0Sstevel@tonic-gate i_ddi_vaddr_swap_get64(ddi_acc_impl_t *hdlp, uint64_t *addr)
323*0Sstevel@tonic-gate {
324*0Sstevel@tonic-gate 	return (ddi_swap64(*addr));
325*0Sstevel@tonic-gate }
326*0Sstevel@tonic-gate 
327*0Sstevel@tonic-gate /*ARGSUSED*/
328*0Sstevel@tonic-gate void
329*0Sstevel@tonic-gate i_ddi_vaddr_swap_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value)
330*0Sstevel@tonic-gate {
331*0Sstevel@tonic-gate 	*addr = ddi_swap16(value);
332*0Sstevel@tonic-gate }
333*0Sstevel@tonic-gate 
334*0Sstevel@tonic-gate /*ARGSUSED*/
335*0Sstevel@tonic-gate void
336*0Sstevel@tonic-gate i_ddi_io_swap_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value)
337*0Sstevel@tonic-gate {
338*0Sstevel@tonic-gate 	outw((uintptr_t)addr, ddi_swap16(value));
339*0Sstevel@tonic-gate }
340*0Sstevel@tonic-gate 
341*0Sstevel@tonic-gate /*ARGSUSED*/
342*0Sstevel@tonic-gate void
343*0Sstevel@tonic-gate i_ddi_vaddr_swap_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value)
344*0Sstevel@tonic-gate {
345*0Sstevel@tonic-gate 	*addr = ddi_swap32(value);
346*0Sstevel@tonic-gate }
347*0Sstevel@tonic-gate 
348*0Sstevel@tonic-gate /*ARGSUSED*/
349*0Sstevel@tonic-gate void
350*0Sstevel@tonic-gate i_ddi_io_swap_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value)
351*0Sstevel@tonic-gate {
352*0Sstevel@tonic-gate 	outl((uintptr_t)addr, ddi_swap32(value));
353*0Sstevel@tonic-gate }
354*0Sstevel@tonic-gate 
355*0Sstevel@tonic-gate /*ARGSUSED*/
356*0Sstevel@tonic-gate void
357*0Sstevel@tonic-gate i_ddi_vaddr_swap_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value)
358*0Sstevel@tonic-gate {
359*0Sstevel@tonic-gate 	*addr = ddi_swap64(value);
360*0Sstevel@tonic-gate }
361*0Sstevel@tonic-gate 
362*0Sstevel@tonic-gate /*ARGSUSED*/
363*0Sstevel@tonic-gate void
364*0Sstevel@tonic-gate i_ddi_vaddr_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
365*0Sstevel@tonic-gate 	uint8_t *dev_addr, size_t repcount, uint_t flags)
366*0Sstevel@tonic-gate {
367*0Sstevel@tonic-gate 	uint8_t	*h, *d;
368*0Sstevel@tonic-gate 
369*0Sstevel@tonic-gate 	h = host_addr;
370*0Sstevel@tonic-gate 	d = dev_addr;
371*0Sstevel@tonic-gate 
372*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
373*0Sstevel@tonic-gate 		for (; repcount; repcount--)
374*0Sstevel@tonic-gate 			*h++ = *d++;
375*0Sstevel@tonic-gate 	else
376*0Sstevel@tonic-gate 		for (; repcount; repcount--)
377*0Sstevel@tonic-gate 			*h++ = *d;
378*0Sstevel@tonic-gate }
379*0Sstevel@tonic-gate 
380*0Sstevel@tonic-gate /*ARGSUSED*/
381*0Sstevel@tonic-gate void
382*0Sstevel@tonic-gate i_ddi_vaddr_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
383*0Sstevel@tonic-gate 	uint16_t *dev_addr, size_t repcount, uint_t flags)
384*0Sstevel@tonic-gate {
385*0Sstevel@tonic-gate 	uint16_t *h, *d;
386*0Sstevel@tonic-gate 
387*0Sstevel@tonic-gate 	h = host_addr;
388*0Sstevel@tonic-gate 	d = dev_addr;
389*0Sstevel@tonic-gate 
390*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
391*0Sstevel@tonic-gate 		for (; repcount; repcount--)
392*0Sstevel@tonic-gate 			*h++ = *d++;
393*0Sstevel@tonic-gate 	else
394*0Sstevel@tonic-gate 		for (; repcount; repcount--)
395*0Sstevel@tonic-gate 			*h++ = *d;
396*0Sstevel@tonic-gate }
397*0Sstevel@tonic-gate 
398*0Sstevel@tonic-gate /*ARGSUSED*/
399*0Sstevel@tonic-gate void
400*0Sstevel@tonic-gate i_ddi_vaddr_swap_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
401*0Sstevel@tonic-gate 	uint16_t *dev_addr, size_t repcount, uint_t flags)
402*0Sstevel@tonic-gate {
403*0Sstevel@tonic-gate 	uint16_t *h, *d;
404*0Sstevel@tonic-gate 
405*0Sstevel@tonic-gate 	h = host_addr;
406*0Sstevel@tonic-gate 	d = dev_addr;
407*0Sstevel@tonic-gate 
408*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
409*0Sstevel@tonic-gate 		for (; repcount; repcount--)
410*0Sstevel@tonic-gate 			*h++ = ddi_swap16(*d++);
411*0Sstevel@tonic-gate 	else
412*0Sstevel@tonic-gate 		for (; repcount; repcount--)
413*0Sstevel@tonic-gate 			*h++ = ddi_swap16(*d);
414*0Sstevel@tonic-gate }
415*0Sstevel@tonic-gate 
416*0Sstevel@tonic-gate /*ARGSUSED*/
417*0Sstevel@tonic-gate void
418*0Sstevel@tonic-gate i_ddi_io_swap_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
419*0Sstevel@tonic-gate 	uint16_t *dev_addr, size_t repcount, uint_t flags)
420*0Sstevel@tonic-gate {
421*0Sstevel@tonic-gate 	uint16_t *h;
422*0Sstevel@tonic-gate 	uintptr_t port;
423*0Sstevel@tonic-gate 
424*0Sstevel@tonic-gate 	h = host_addr;
425*0Sstevel@tonic-gate 	port = (uintptr_t)dev_addr;
426*0Sstevel@tonic-gate 
427*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
428*0Sstevel@tonic-gate 		for (; repcount; repcount--, port += 2)
429*0Sstevel@tonic-gate 			*h++ = ddi_swap16(inw(port));
430*0Sstevel@tonic-gate 	else
431*0Sstevel@tonic-gate 		for (; repcount; repcount--)
432*0Sstevel@tonic-gate 			*h++ = ddi_swap16(inw(port));
433*0Sstevel@tonic-gate }
434*0Sstevel@tonic-gate 
435*0Sstevel@tonic-gate /*ARGSUSED*/
436*0Sstevel@tonic-gate void
437*0Sstevel@tonic-gate i_ddi_vaddr_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
438*0Sstevel@tonic-gate 	uint32_t *dev_addr, size_t repcount, uint_t flags)
439*0Sstevel@tonic-gate {
440*0Sstevel@tonic-gate 	uint32_t *h, *d;
441*0Sstevel@tonic-gate 
442*0Sstevel@tonic-gate 	h = host_addr;
443*0Sstevel@tonic-gate 	d = dev_addr;
444*0Sstevel@tonic-gate 
445*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
446*0Sstevel@tonic-gate 		for (; repcount; repcount--)
447*0Sstevel@tonic-gate 			*h++ = *d++;
448*0Sstevel@tonic-gate 	else
449*0Sstevel@tonic-gate 		for (; repcount; repcount--)
450*0Sstevel@tonic-gate 			*h++ = *d;
451*0Sstevel@tonic-gate }
452*0Sstevel@tonic-gate 
453*0Sstevel@tonic-gate /*ARGSUSED*/
454*0Sstevel@tonic-gate void
455*0Sstevel@tonic-gate i_ddi_vaddr_swap_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
456*0Sstevel@tonic-gate 	uint32_t *dev_addr, size_t repcount, uint_t flags)
457*0Sstevel@tonic-gate {
458*0Sstevel@tonic-gate 	uint32_t *h, *d;
459*0Sstevel@tonic-gate 
460*0Sstevel@tonic-gate 	h = host_addr;
461*0Sstevel@tonic-gate 	d = dev_addr;
462*0Sstevel@tonic-gate 
463*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
464*0Sstevel@tonic-gate 		for (; repcount; repcount--)
465*0Sstevel@tonic-gate 			*h++ = ddi_swap32(*d++);
466*0Sstevel@tonic-gate 	else
467*0Sstevel@tonic-gate 		for (; repcount; repcount--)
468*0Sstevel@tonic-gate 			*h++ = ddi_swap32(*d);
469*0Sstevel@tonic-gate }
470*0Sstevel@tonic-gate 
471*0Sstevel@tonic-gate /*ARGSUSED*/
472*0Sstevel@tonic-gate void
473*0Sstevel@tonic-gate i_ddi_io_swap_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
474*0Sstevel@tonic-gate 	uint32_t *dev_addr, size_t repcount, uint_t flags)
475*0Sstevel@tonic-gate {
476*0Sstevel@tonic-gate 	uint32_t *h;
477*0Sstevel@tonic-gate 	uintptr_t port;
478*0Sstevel@tonic-gate 
479*0Sstevel@tonic-gate 	h = host_addr;
480*0Sstevel@tonic-gate 	port = (uintptr_t)dev_addr;
481*0Sstevel@tonic-gate 
482*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
483*0Sstevel@tonic-gate 		for (; repcount; repcount--, port += 4)
484*0Sstevel@tonic-gate 			*h++ = ddi_swap32(inl(port));
485*0Sstevel@tonic-gate 	else
486*0Sstevel@tonic-gate 		for (; repcount; repcount--)
487*0Sstevel@tonic-gate 			*h++ = ddi_swap32(inl(port));
488*0Sstevel@tonic-gate }
489*0Sstevel@tonic-gate 
490*0Sstevel@tonic-gate /*ARGSUSED*/
491*0Sstevel@tonic-gate void
492*0Sstevel@tonic-gate i_ddi_vaddr_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
493*0Sstevel@tonic-gate 	uint64_t *dev_addr, size_t repcount, uint_t flags)
494*0Sstevel@tonic-gate {
495*0Sstevel@tonic-gate 	uint64_t *h, *d;
496*0Sstevel@tonic-gate 
497*0Sstevel@tonic-gate 	h = host_addr;
498*0Sstevel@tonic-gate 	d = dev_addr;
499*0Sstevel@tonic-gate 
500*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
501*0Sstevel@tonic-gate 		for (; repcount; repcount--)
502*0Sstevel@tonic-gate 			*h++ = *d++;
503*0Sstevel@tonic-gate 	else
504*0Sstevel@tonic-gate 		for (; repcount; repcount--)
505*0Sstevel@tonic-gate 			*h++ = *d;
506*0Sstevel@tonic-gate }
507*0Sstevel@tonic-gate 
508*0Sstevel@tonic-gate /*ARGSUSED*/
509*0Sstevel@tonic-gate void
510*0Sstevel@tonic-gate i_ddi_vaddr_swap_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
511*0Sstevel@tonic-gate 	uint64_t *dev_addr, size_t repcount, uint_t flags)
512*0Sstevel@tonic-gate {
513*0Sstevel@tonic-gate 	uint64_t *h, *d;
514*0Sstevel@tonic-gate 
515*0Sstevel@tonic-gate 	h = host_addr;
516*0Sstevel@tonic-gate 	d = dev_addr;
517*0Sstevel@tonic-gate 
518*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
519*0Sstevel@tonic-gate 		for (; repcount; repcount--)
520*0Sstevel@tonic-gate 			*h++ = ddi_swap64(*d++);
521*0Sstevel@tonic-gate 	else
522*0Sstevel@tonic-gate 		for (; repcount; repcount--)
523*0Sstevel@tonic-gate 			*h++ = ddi_swap64(*d);
524*0Sstevel@tonic-gate }
525*0Sstevel@tonic-gate 
526*0Sstevel@tonic-gate /*ARGSUSED*/
527*0Sstevel@tonic-gate void
528*0Sstevel@tonic-gate i_ddi_vaddr_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
529*0Sstevel@tonic-gate 	uint8_t *dev_addr, size_t repcount, uint_t flags)
530*0Sstevel@tonic-gate {
531*0Sstevel@tonic-gate 	uint8_t	*h, *d;
532*0Sstevel@tonic-gate 
533*0Sstevel@tonic-gate 	h = host_addr;
534*0Sstevel@tonic-gate 	d = dev_addr;
535*0Sstevel@tonic-gate 
536*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
537*0Sstevel@tonic-gate 		for (; repcount; repcount--)
538*0Sstevel@tonic-gate 			*d++ = *h++;
539*0Sstevel@tonic-gate 	else
540*0Sstevel@tonic-gate 		for (; repcount; repcount--)
541*0Sstevel@tonic-gate 			*d = *h++;
542*0Sstevel@tonic-gate }
543*0Sstevel@tonic-gate 
544*0Sstevel@tonic-gate /*ARGSUSED*/
545*0Sstevel@tonic-gate void
546*0Sstevel@tonic-gate i_ddi_vaddr_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
547*0Sstevel@tonic-gate 	uint16_t *dev_addr, size_t repcount, uint_t flags)
548*0Sstevel@tonic-gate {
549*0Sstevel@tonic-gate 	uint16_t *h, *d;
550*0Sstevel@tonic-gate 
551*0Sstevel@tonic-gate 	h = host_addr;
552*0Sstevel@tonic-gate 	d = dev_addr;
553*0Sstevel@tonic-gate 
554*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
555*0Sstevel@tonic-gate 		for (; repcount; repcount--)
556*0Sstevel@tonic-gate 			*d++ = *h++;
557*0Sstevel@tonic-gate 	else
558*0Sstevel@tonic-gate 		for (; repcount; repcount--)
559*0Sstevel@tonic-gate 			*d = *h++;
560*0Sstevel@tonic-gate }
561*0Sstevel@tonic-gate 
562*0Sstevel@tonic-gate /*ARGSUSED*/
563*0Sstevel@tonic-gate void
564*0Sstevel@tonic-gate i_ddi_vaddr_swap_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
565*0Sstevel@tonic-gate 	uint16_t *dev_addr, size_t repcount, uint_t flags)
566*0Sstevel@tonic-gate {
567*0Sstevel@tonic-gate 	uint16_t *h, *d;
568*0Sstevel@tonic-gate 
569*0Sstevel@tonic-gate 	h = host_addr;
570*0Sstevel@tonic-gate 	d = dev_addr;
571*0Sstevel@tonic-gate 
572*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
573*0Sstevel@tonic-gate 		for (; repcount; repcount--)
574*0Sstevel@tonic-gate 			*d++ = ddi_swap16(*h++);
575*0Sstevel@tonic-gate 	else
576*0Sstevel@tonic-gate 		for (; repcount; repcount--)
577*0Sstevel@tonic-gate 			*d = ddi_swap16(*h++);
578*0Sstevel@tonic-gate }
579*0Sstevel@tonic-gate 
580*0Sstevel@tonic-gate /*ARGSUSED*/
581*0Sstevel@tonic-gate void
582*0Sstevel@tonic-gate i_ddi_io_swap_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
583*0Sstevel@tonic-gate 	uint16_t *dev_addr, size_t repcount, uint_t flags)
584*0Sstevel@tonic-gate {
585*0Sstevel@tonic-gate 	uint16_t *h;
586*0Sstevel@tonic-gate 	uintptr_t port;
587*0Sstevel@tonic-gate 
588*0Sstevel@tonic-gate 	h = host_addr;
589*0Sstevel@tonic-gate 	port = (uintptr_t)dev_addr;
590*0Sstevel@tonic-gate 
591*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
592*0Sstevel@tonic-gate 		for (; repcount; repcount--, port += 2)
593*0Sstevel@tonic-gate 			outw(port, ddi_swap16(*h++));
594*0Sstevel@tonic-gate 	else
595*0Sstevel@tonic-gate 		for (; repcount; repcount--)
596*0Sstevel@tonic-gate 			outw(port, ddi_swap16(*h++));
597*0Sstevel@tonic-gate }
598*0Sstevel@tonic-gate 
599*0Sstevel@tonic-gate /*ARGSUSED*/
600*0Sstevel@tonic-gate void
601*0Sstevel@tonic-gate i_ddi_vaddr_rep_put32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
602*0Sstevel@tonic-gate 	uint32_t *dev_addr, size_t repcount, uint_t flags)
603*0Sstevel@tonic-gate {
604*0Sstevel@tonic-gate 	uint32_t *h, *d;
605*0Sstevel@tonic-gate 
606*0Sstevel@tonic-gate 	h = host_addr;
607*0Sstevel@tonic-gate 	d = dev_addr;
608*0Sstevel@tonic-gate 
609*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
610*0Sstevel@tonic-gate 		for (; repcount; repcount--)
611*0Sstevel@tonic-gate 			*d++ = *h++;
612*0Sstevel@tonic-gate 	else
613*0Sstevel@tonic-gate 		for (; repcount; repcount--)
614*0Sstevel@tonic-gate 			*d = *h++;
615*0Sstevel@tonic-gate }
616*0Sstevel@tonic-gate 
617*0Sstevel@tonic-gate /*ARGSUSED*/
618*0Sstevel@tonic-gate void
619*0Sstevel@tonic-gate i_ddi_vaddr_swap_rep_put32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
620*0Sstevel@tonic-gate 	uint32_t *dev_addr, size_t repcount, uint_t flags)
621*0Sstevel@tonic-gate {
622*0Sstevel@tonic-gate 	uint32_t *h, *d;
623*0Sstevel@tonic-gate 
624*0Sstevel@tonic-gate 	h = host_addr;
625*0Sstevel@tonic-gate 	d = dev_addr;
626*0Sstevel@tonic-gate 
627*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
628*0Sstevel@tonic-gate 		for (; repcount; repcount--)
629*0Sstevel@tonic-gate 			*d++ = ddi_swap32(*h++);
630*0Sstevel@tonic-gate 	else
631*0Sstevel@tonic-gate 		for (; repcount; repcount--)
632*0Sstevel@tonic-gate 			*d = ddi_swap32(*h++);
633*0Sstevel@tonic-gate }
634*0Sstevel@tonic-gate 
635*0Sstevel@tonic-gate /*ARGSUSED*/
636*0Sstevel@tonic-gate void
637*0Sstevel@tonic-gate i_ddi_io_swap_rep_put32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
638*0Sstevel@tonic-gate 	uint32_t *dev_addr, size_t repcount, uint_t flags)
639*0Sstevel@tonic-gate {
640*0Sstevel@tonic-gate 	uint32_t *h;
641*0Sstevel@tonic-gate 	uintptr_t port;
642*0Sstevel@tonic-gate 
643*0Sstevel@tonic-gate 	h = host_addr;
644*0Sstevel@tonic-gate 	port = (uintptr_t)dev_addr;
645*0Sstevel@tonic-gate 
646*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
647*0Sstevel@tonic-gate 		for (; repcount; repcount--, port += 4)
648*0Sstevel@tonic-gate 			outl(port, ddi_swap32(*h++));
649*0Sstevel@tonic-gate 	else
650*0Sstevel@tonic-gate 		for (; repcount; repcount--)
651*0Sstevel@tonic-gate 			outl(port, ddi_swap32(*h++));
652*0Sstevel@tonic-gate }
653*0Sstevel@tonic-gate 
654*0Sstevel@tonic-gate /*ARGSUSED*/
655*0Sstevel@tonic-gate void
656*0Sstevel@tonic-gate i_ddi_vaddr_rep_put64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
657*0Sstevel@tonic-gate 	uint64_t *dev_addr, size_t repcount, uint_t flags)
658*0Sstevel@tonic-gate {
659*0Sstevel@tonic-gate 	uint64_t *h, *d;
660*0Sstevel@tonic-gate 
661*0Sstevel@tonic-gate 	h = host_addr;
662*0Sstevel@tonic-gate 	d = dev_addr;
663*0Sstevel@tonic-gate 
664*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
665*0Sstevel@tonic-gate 		for (; repcount; repcount--)
666*0Sstevel@tonic-gate 			*d++ = *h++;
667*0Sstevel@tonic-gate 	else
668*0Sstevel@tonic-gate 		for (; repcount; repcount--)
669*0Sstevel@tonic-gate 			*d = *h++;
670*0Sstevel@tonic-gate }
671*0Sstevel@tonic-gate 
672*0Sstevel@tonic-gate /*ARGSUSED*/
673*0Sstevel@tonic-gate void
674*0Sstevel@tonic-gate i_ddi_vaddr_swap_rep_put64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
675*0Sstevel@tonic-gate 	uint64_t *dev_addr, size_t repcount, uint_t flags)
676*0Sstevel@tonic-gate {
677*0Sstevel@tonic-gate 	uint64_t *h, *d;
678*0Sstevel@tonic-gate 
679*0Sstevel@tonic-gate 	h = host_addr;
680*0Sstevel@tonic-gate 	d = dev_addr;
681*0Sstevel@tonic-gate 
682*0Sstevel@tonic-gate 	if (flags == DDI_DEV_AUTOINCR)
683*0Sstevel@tonic-gate 		for (; repcount; repcount--)
684*0Sstevel@tonic-gate 			*d++ = ddi_swap64(*h++);
685*0Sstevel@tonic-gate 	else
686*0Sstevel@tonic-gate 		for (; repcount; repcount--)
687*0Sstevel@tonic-gate 			*d = ddi_swap64(*h++);
688*0Sstevel@tonic-gate }
689*0Sstevel@tonic-gate 
690*0Sstevel@tonic-gate /*ARGSUSED*/
691*0Sstevel@tonic-gate uint64_t
692*0Sstevel@tonic-gate i_ddi_io_get64(ddi_acc_impl_t *hdlp, uint64_t *addr)
693*0Sstevel@tonic-gate {
694*0Sstevel@tonic-gate 	panic("ddi_get64 from i/o space");
695*0Sstevel@tonic-gate 	/*NOTREACHED*/
696*0Sstevel@tonic-gate 	return (0);
697*0Sstevel@tonic-gate }
698*0Sstevel@tonic-gate 
699*0Sstevel@tonic-gate /*ARGSUSED*/
700*0Sstevel@tonic-gate void
701*0Sstevel@tonic-gate i_ddi_io_put64(ddi_acc_impl_t *hdlp, uint64_t *host_addr, uint64_t value)
702*0Sstevel@tonic-gate {
703*0Sstevel@tonic-gate 	panic("ddi_put64 to i/o space");
704*0Sstevel@tonic-gate 	/*NOTREACHED*/
705*0Sstevel@tonic-gate }
706*0Sstevel@tonic-gate 
707*0Sstevel@tonic-gate #ifdef _LP64
708*0Sstevel@tonic-gate void
709*0Sstevel@tonic-gate ddi_io_rep_get8(ddi_acc_handle_t handle,
710*0Sstevel@tonic-gate 	uint8_t *host_addr, uint8_t *dev_addr, size_t repcount)
711*0Sstevel@tonic-gate #else /* _ILP32 */
712*0Sstevel@tonic-gate void
713*0Sstevel@tonic-gate ddi_io_rep_getb(ddi_acc_handle_t handle,
714*0Sstevel@tonic-gate 	uint8_t *host_addr, uint8_t *dev_addr, size_t repcount)
715*0Sstevel@tonic-gate #endif
716*0Sstevel@tonic-gate {
717*0Sstevel@tonic-gate 	(((ddi_acc_impl_t *)handle)->ahi_rep_get8)
718*0Sstevel@tonic-gate 		((ddi_acc_impl_t *)handle, host_addr, dev_addr,
719*0Sstevel@tonic-gate 		repcount, DDI_DEV_NO_AUTOINCR);
720*0Sstevel@tonic-gate }
721*0Sstevel@tonic-gate 
722*0Sstevel@tonic-gate #ifdef _LP64
723*0Sstevel@tonic-gate void
724*0Sstevel@tonic-gate ddi_io_rep_get16(ddi_acc_handle_t handle,
725*0Sstevel@tonic-gate 	uint16_t *host_addr, uint16_t *dev_addr, size_t repcount)
726*0Sstevel@tonic-gate #else /* _ILP32 */
727*0Sstevel@tonic-gate void
728*0Sstevel@tonic-gate ddi_io_rep_getw(ddi_acc_handle_t handle,
729*0Sstevel@tonic-gate 	uint16_t *host_addr, uint16_t *dev_addr, size_t repcount)
730*0Sstevel@tonic-gate #endif
731*0Sstevel@tonic-gate {
732*0Sstevel@tonic-gate 	(((ddi_acc_impl_t *)handle)->ahi_rep_get16)
733*0Sstevel@tonic-gate 		((ddi_acc_impl_t *)handle, host_addr, dev_addr,
734*0Sstevel@tonic-gate 		repcount, DDI_DEV_NO_AUTOINCR);
735*0Sstevel@tonic-gate }
736*0Sstevel@tonic-gate 
737*0Sstevel@tonic-gate #ifdef _LP64
738*0Sstevel@tonic-gate void
739*0Sstevel@tonic-gate ddi_io_rep_get32(ddi_acc_handle_t handle,
740*0Sstevel@tonic-gate 	uint32_t *host_addr, uint32_t *dev_addr, size_t repcount)
741*0Sstevel@tonic-gate #else /* _ILP32 */
742*0Sstevel@tonic-gate void
743*0Sstevel@tonic-gate ddi_io_rep_getl(ddi_acc_handle_t handle,
744*0Sstevel@tonic-gate 	uint32_t *host_addr, uint32_t *dev_addr, size_t repcount)
745*0Sstevel@tonic-gate #endif
746*0Sstevel@tonic-gate {
747*0Sstevel@tonic-gate 	(((ddi_acc_impl_t *)handle)->ahi_rep_get32)
748*0Sstevel@tonic-gate 		((ddi_acc_impl_t *)handle, host_addr, dev_addr,
749*0Sstevel@tonic-gate 		repcount, DDI_DEV_NO_AUTOINCR);
750*0Sstevel@tonic-gate }
751*0Sstevel@tonic-gate 
752*0Sstevel@tonic-gate /*ARGSUSED*/
753*0Sstevel@tonic-gate void
754*0Sstevel@tonic-gate i_ddi_io_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
755*0Sstevel@tonic-gate 	uint64_t *dev_addr, size_t repcount, uint_t flags)
756*0Sstevel@tonic-gate {
757*0Sstevel@tonic-gate 	cmn_err(CE_PANIC, "ddi_rep_get64 from i/o space");
758*0Sstevel@tonic-gate }
759*0Sstevel@tonic-gate 
760*0Sstevel@tonic-gate #ifdef _LP64
761*0Sstevel@tonic-gate void
762*0Sstevel@tonic-gate ddi_io_rep_put8(ddi_acc_handle_t handle,
763*0Sstevel@tonic-gate 	uint8_t *host_addr, uint8_t *dev_addr, size_t repcount)
764*0Sstevel@tonic-gate #else /* _ILP32 */
765*0Sstevel@tonic-gate void
766*0Sstevel@tonic-gate ddi_io_rep_putb(ddi_acc_handle_t handle,
767*0Sstevel@tonic-gate 	uint8_t *host_addr, uint8_t *dev_addr, size_t repcount)
768*0Sstevel@tonic-gate #endif
769*0Sstevel@tonic-gate {
770*0Sstevel@tonic-gate 	(((ddi_acc_impl_t *)handle)->ahi_rep_put8)
771*0Sstevel@tonic-gate 		((ddi_acc_impl_t *)handle, host_addr, dev_addr,
772*0Sstevel@tonic-gate 		repcount, DDI_DEV_NO_AUTOINCR);
773*0Sstevel@tonic-gate }
774*0Sstevel@tonic-gate 
775*0Sstevel@tonic-gate #ifdef _LP64
776*0Sstevel@tonic-gate void
777*0Sstevel@tonic-gate ddi_io_rep_put16(ddi_acc_handle_t handle,
778*0Sstevel@tonic-gate 	uint16_t *host_addr, uint16_t *dev_addr, size_t repcount)
779*0Sstevel@tonic-gate #else /* _ILP32 */
780*0Sstevel@tonic-gate void
781*0Sstevel@tonic-gate ddi_io_rep_putw(ddi_acc_handle_t handle,
782*0Sstevel@tonic-gate 	uint16_t *host_addr, uint16_t *dev_addr, size_t repcount)
783*0Sstevel@tonic-gate #endif
784*0Sstevel@tonic-gate {
785*0Sstevel@tonic-gate 	(((ddi_acc_impl_t *)handle)->ahi_rep_put16)
786*0Sstevel@tonic-gate 		((ddi_acc_impl_t *)handle, host_addr, dev_addr,
787*0Sstevel@tonic-gate 		repcount, DDI_DEV_NO_AUTOINCR);
788*0Sstevel@tonic-gate }
789*0Sstevel@tonic-gate 
790*0Sstevel@tonic-gate #ifdef _LP64
791*0Sstevel@tonic-gate void
792*0Sstevel@tonic-gate ddi_io_rep_put32(ddi_acc_handle_t handle,
793*0Sstevel@tonic-gate 	uint32_t *host_addr, uint32_t *dev_addr, size_t repcount)
794*0Sstevel@tonic-gate #else /* _ILP32 */
795*0Sstevel@tonic-gate void
796*0Sstevel@tonic-gate ddi_io_rep_putl(ddi_acc_handle_t handle,
797*0Sstevel@tonic-gate 	uint32_t *host_addr, uint32_t *dev_addr, size_t repcount)
798*0Sstevel@tonic-gate #endif
799*0Sstevel@tonic-gate {
800*0Sstevel@tonic-gate 	(((ddi_acc_impl_t *)handle)->ahi_rep_put32)
801*0Sstevel@tonic-gate 		((ddi_acc_impl_t *)handle, host_addr, dev_addr,
802*0Sstevel@tonic-gate 		repcount, DDI_DEV_NO_AUTOINCR);
803*0Sstevel@tonic-gate }
804*0Sstevel@tonic-gate 
805*0Sstevel@tonic-gate /*ARGSUSED*/
806*0Sstevel@tonic-gate void
807*0Sstevel@tonic-gate i_ddi_io_rep_put64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
808*0Sstevel@tonic-gate 	uint64_t *dev_addr, size_t repcount, uint_t flags)
809*0Sstevel@tonic-gate {
810*0Sstevel@tonic-gate 	cmn_err(CE_PANIC, "ddi_rep_put64 to i/o space");
811*0Sstevel@tonic-gate }
812*0Sstevel@tonic-gate 
813*0Sstevel@tonic-gate /*
814*0Sstevel@tonic-gate  * These next two functions could be translated into assembler someday
815*0Sstevel@tonic-gate  */
816*0Sstevel@tonic-gate int
817*0Sstevel@tonic-gate ddi_check_acc_handle(ddi_acc_handle_t handle)
818*0Sstevel@tonic-gate {
819*0Sstevel@tonic-gate 	ddi_acc_impl_t *hdlp = (ddi_acc_impl_t *)handle;
820*0Sstevel@tonic-gate 	return (((*hdlp->ahi_fault_check)(hdlp) == DDI_SUCCESS) ? DDI_SUCCESS :
821*0Sstevel@tonic-gate 	    DDI_FAILURE);
822*0Sstevel@tonic-gate }
823*0Sstevel@tonic-gate 
824*0Sstevel@tonic-gate int
825*0Sstevel@tonic-gate i_ddi_acc_fault_check(ddi_acc_impl_t *hdlp)
826*0Sstevel@tonic-gate {
827*0Sstevel@tonic-gate 	/* Default version, just returns flag value */
828*0Sstevel@tonic-gate 	return (hdlp->ahi_fault);
829*0Sstevel@tonic-gate }
830*0Sstevel@tonic-gate 
831*0Sstevel@tonic-gate /*ARGSUSED*/
832*0Sstevel@tonic-gate void
833*0Sstevel@tonic-gate i_ddi_acc_fault_notify(ddi_acc_impl_t *hdlp)
834*0Sstevel@tonic-gate {
835*0Sstevel@tonic-gate 	/* Default version, does nothing for now */
836*0Sstevel@tonic-gate }
837*0Sstevel@tonic-gate 
838*0Sstevel@tonic-gate void
839*0Sstevel@tonic-gate i_ddi_acc_set_fault(ddi_acc_handle_t handle)
840*0Sstevel@tonic-gate {
841*0Sstevel@tonic-gate 	ddi_acc_impl_t *hdlp = (ddi_acc_impl_t *)handle;
842*0Sstevel@tonic-gate 
843*0Sstevel@tonic-gate 	if (!hdlp->ahi_fault) {
844*0Sstevel@tonic-gate 		hdlp->ahi_fault = 1;
845*0Sstevel@tonic-gate 		(*hdlp->ahi_fault_notify)(hdlp);
846*0Sstevel@tonic-gate 	}
847*0Sstevel@tonic-gate }
848*0Sstevel@tonic-gate 
849*0Sstevel@tonic-gate void
850*0Sstevel@tonic-gate i_ddi_acc_clr_fault(ddi_acc_handle_t handle)
851*0Sstevel@tonic-gate {
852*0Sstevel@tonic-gate 	ddi_acc_impl_t *hdlp = (ddi_acc_impl_t *)handle;
853*0Sstevel@tonic-gate 
854*0Sstevel@tonic-gate 	if (hdlp->ahi_fault) {
855*0Sstevel@tonic-gate 		hdlp->ahi_fault = 0;
856*0Sstevel@tonic-gate 		(*hdlp->ahi_fault_notify)(hdlp);
857*0Sstevel@tonic-gate 	}
858*0Sstevel@tonic-gate }
859