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 2005 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 * PCI nexus driver interface
31*7c478bd9Sstevel@tonic-gate */
32*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
33*7c478bd9Sstevel@tonic-gate #include <sys/conf.h> /* nulldev */
34*7c478bd9Sstevel@tonic-gate #include <sys/stat.h> /* devctl */
35*7c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
36*7c478bd9Sstevel@tonic-gate #include <sys/async.h> /* ecc_flt for pci_ecc.h */
37*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
38*7c478bd9Sstevel@tonic-gate #include <sys/sunndi.h>
39*7c478bd9Sstevel@tonic-gate #include <sys/ontrap.h>
40*7c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
41*7c478bd9Sstevel@tonic-gate #include <sys/ddi_subrdefs.h>
42*7c478bd9Sstevel@tonic-gate #include <sys/epm.h>
43*7c478bd9Sstevel@tonic-gate #include <sys/membar.h>
44*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
45*7c478bd9Sstevel@tonic-gate #include <sys/hotplug/pci/pcihp.h>
46*7c478bd9Sstevel@tonic-gate #include <sys/pci/pci_obj.h>
47*7c478bd9Sstevel@tonic-gate
48*7c478bd9Sstevel@tonic-gate /*LINTLIBRARY*/
49*7c478bd9Sstevel@tonic-gate
50*7c478bd9Sstevel@tonic-gate static uint8_t pci_axq_hack_get8(ddi_acc_impl_t *handle, uint8_t *addr);
51*7c478bd9Sstevel@tonic-gate static uint16_t pci_axq_hack_get16(ddi_acc_impl_t *handle, uint16_t *addr);
52*7c478bd9Sstevel@tonic-gate static uint32_t pci_axq_hack_get32(ddi_acc_impl_t *handle, uint32_t *addr);
53*7c478bd9Sstevel@tonic-gate static uint64_t pci_axq_hack_get64(ddi_acc_impl_t *handle, uint64_t *addr);
54*7c478bd9Sstevel@tonic-gate static void pci_axq_hack_put8(ddi_acc_impl_t *handle, uint8_t *addr,
55*7c478bd9Sstevel@tonic-gate uint8_t data);
56*7c478bd9Sstevel@tonic-gate static void pci_axq_hack_put16(ddi_acc_impl_t *handle, uint16_t *addr,
57*7c478bd9Sstevel@tonic-gate uint16_t data);
58*7c478bd9Sstevel@tonic-gate static void pci_axq_hack_put32(ddi_acc_impl_t *handle, uint32_t *addr,
59*7c478bd9Sstevel@tonic-gate uint32_t data);
60*7c478bd9Sstevel@tonic-gate static void pci_axq_hack_put64(ddi_acc_impl_t *handle, uint64_t *addr,
61*7c478bd9Sstevel@tonic-gate uint64_t data);
62*7c478bd9Sstevel@tonic-gate static void pci_axq_hack_rep_get8(ddi_acc_impl_t *handle,
63*7c478bd9Sstevel@tonic-gate uint8_t *host_addr, uint8_t *dev_addr,
64*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags);
65*7c478bd9Sstevel@tonic-gate static void pci_axq_hack_rep_get16(ddi_acc_impl_t *handle,
66*7c478bd9Sstevel@tonic-gate uint16_t *host_addr, uint16_t *dev_addr,
67*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags);
68*7c478bd9Sstevel@tonic-gate static void pci_axq_hack_rep_get32(ddi_acc_impl_t *handle,
69*7c478bd9Sstevel@tonic-gate uint32_t *host_addr, uint32_t *dev_addr,
70*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags);
71*7c478bd9Sstevel@tonic-gate static void pci_axq_hack_rep_get64(ddi_acc_impl_t *handle,
72*7c478bd9Sstevel@tonic-gate uint64_t *host_addr, uint64_t *dev_addr,
73*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags);
74*7c478bd9Sstevel@tonic-gate static void pci_axq_hack_rep_put8(ddi_acc_impl_t *handle,
75*7c478bd9Sstevel@tonic-gate uint8_t *host_addr, uint8_t *dev_addr,
76*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags);
77*7c478bd9Sstevel@tonic-gate static void pci_axq_hack_rep_put16(ddi_acc_impl_t *handle,
78*7c478bd9Sstevel@tonic-gate uint16_t *host_addr, uint16_t *dev_addr,
79*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags);
80*7c478bd9Sstevel@tonic-gate static void pci_axq_hack_rep_put32(ddi_acc_impl_t *handle,
81*7c478bd9Sstevel@tonic-gate uint32_t *host_addr, uint32_t *dev_addr,
82*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags);
83*7c478bd9Sstevel@tonic-gate static void pci_axq_hack_rep_put64(ddi_acc_impl_t *handle,
84*7c478bd9Sstevel@tonic-gate uint64_t *host_addr, uint64_t *dev_addr,
85*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags);
86*7c478bd9Sstevel@tonic-gate
87*7c478bd9Sstevel@tonic-gate /*
88*7c478bd9Sstevel@tonic-gate * On Sunfire 15k systems with AXQs less than 6.1
89*7c478bd9Sstevel@tonic-gate * we have to use special PIO routines that limit
90*7c478bd9Sstevel@tonic-gate * the number of outstanding PIOs. We setup the
91*7c478bd9Sstevel@tonic-gate * handle with pointers to our special functions
92*7c478bd9Sstevel@tonic-gate * after it has been succesfully mapped by our
93*7c478bd9Sstevel@tonic-gate * parent.
94*7c478bd9Sstevel@tonic-gate */
95*7c478bd9Sstevel@tonic-gate
96*7c478bd9Sstevel@tonic-gate void
pci_axq_pio_limit(pbm_t * pbm_p)97*7c478bd9Sstevel@tonic-gate pci_axq_pio_limit(pbm_t *pbm_p)
98*7c478bd9Sstevel@tonic-gate {
99*7c478bd9Sstevel@tonic-gate pci_t *pci_p = pbm_p->pbm_pci_p;
100*7c478bd9Sstevel@tonic-gate dev_info_t *dip = pci_p->pci_dip;
101*7c478bd9Sstevel@tonic-gate int (*axq_pio_workaround)(dev_info_t *) = NULL;
102*7c478bd9Sstevel@tonic-gate
103*7c478bd9Sstevel@tonic-gate axq_pio_workaround =
104*7c478bd9Sstevel@tonic-gate (int (*)(dev_info_t *)) modgetsymvalue(
105*7c478bd9Sstevel@tonic-gate "starcat_axq_pio_workaround", 0);
106*7c478bd9Sstevel@tonic-gate
107*7c478bd9Sstevel@tonic-gate if (axq_pio_workaround) {
108*7c478bd9Sstevel@tonic-gate pbm_p->pbm_pio_limit = (axq_pio_workaround)(dip);
109*7c478bd9Sstevel@tonic-gate pbm_p->pbm_pio_counter = pbm_p->pbm_pio_limit;
110*7c478bd9Sstevel@tonic-gate } else
111*7c478bd9Sstevel@tonic-gate pbm_p->pbm_pio_limit = 0;
112*7c478bd9Sstevel@tonic-gate }
113*7c478bd9Sstevel@tonic-gate
114*7c478bd9Sstevel@tonic-gate void
pci_axq_setup(ddi_map_req_t * mp,pbm_t * pbm_p)115*7c478bd9Sstevel@tonic-gate pci_axq_setup(ddi_map_req_t *mp, pbm_t *pbm_p)
116*7c478bd9Sstevel@tonic-gate {
117*7c478bd9Sstevel@tonic-gate ddi_acc_hdl_t *hp;
118*7c478bd9Sstevel@tonic-gate ddi_acc_impl_t *ap;
119*7c478bd9Sstevel@tonic-gate
120*7c478bd9Sstevel@tonic-gate if (mp->map_op != DDI_MO_MAP_LOCKED)
121*7c478bd9Sstevel@tonic-gate return;
122*7c478bd9Sstevel@tonic-gate if (!pbm_p->pbm_pio_limit)
123*7c478bd9Sstevel@tonic-gate return;
124*7c478bd9Sstevel@tonic-gate
125*7c478bd9Sstevel@tonic-gate hp = (ddi_acc_hdl_t *)mp->map_handlep;
126*7c478bd9Sstevel@tonic-gate ap = (ddi_acc_impl_t *)hp->ah_platform_private;
127*7c478bd9Sstevel@tonic-gate
128*7c478bd9Sstevel@tonic-gate ap->ahi_get8 = pci_axq_hack_get8;
129*7c478bd9Sstevel@tonic-gate ap->ahi_get16 = pci_axq_hack_get16;
130*7c478bd9Sstevel@tonic-gate ap->ahi_get32 = pci_axq_hack_get32;
131*7c478bd9Sstevel@tonic-gate ap->ahi_get64 = pci_axq_hack_get64;
132*7c478bd9Sstevel@tonic-gate ap->ahi_put8 = pci_axq_hack_put8;
133*7c478bd9Sstevel@tonic-gate ap->ahi_put16 = pci_axq_hack_put16;
134*7c478bd9Sstevel@tonic-gate ap->ahi_put32 = pci_axq_hack_put32;
135*7c478bd9Sstevel@tonic-gate ap->ahi_put64 = pci_axq_hack_put64;
136*7c478bd9Sstevel@tonic-gate ap->ahi_rep_get8 = pci_axq_hack_rep_get8;
137*7c478bd9Sstevel@tonic-gate ap->ahi_rep_get16 = pci_axq_hack_rep_get16;
138*7c478bd9Sstevel@tonic-gate ap->ahi_rep_get32 = pci_axq_hack_rep_get32;
139*7c478bd9Sstevel@tonic-gate ap->ahi_rep_get64 = pci_axq_hack_rep_get64;
140*7c478bd9Sstevel@tonic-gate ap->ahi_rep_put8 = pci_axq_hack_rep_put8;
141*7c478bd9Sstevel@tonic-gate ap->ahi_rep_put16 = pci_axq_hack_rep_put16;
142*7c478bd9Sstevel@tonic-gate ap->ahi_rep_put32 = pci_axq_hack_rep_put32;
143*7c478bd9Sstevel@tonic-gate ap->ahi_rep_put64 = pci_axq_hack_rep_put64;
144*7c478bd9Sstevel@tonic-gate
145*7c478bd9Sstevel@tonic-gate hp->ah_bus_private = (void *)pbm_p;
146*7c478bd9Sstevel@tonic-gate }
147*7c478bd9Sstevel@tonic-gate
148*7c478bd9Sstevel@tonic-gate /*
149*7c478bd9Sstevel@tonic-gate * get/put routines for SunFire 15K systems that have AXQ versions
150*7c478bd9Sstevel@tonic-gate * less than 6.1. These routines limit the number of outsanding
151*7c478bd9Sstevel@tonic-gate * PIOs issues across a PCI Bus.
152*7c478bd9Sstevel@tonic-gate */
153*7c478bd9Sstevel@tonic-gate static uint8_t
pci_axq_hack_get8(ddi_acc_impl_t * handle,uint8_t * addr)154*7c478bd9Sstevel@tonic-gate pci_axq_hack_get8(ddi_acc_impl_t *handle, uint8_t *addr)
155*7c478bd9Sstevel@tonic-gate {
156*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
157*7c478bd9Sstevel@tonic-gate uint8_t data;
158*7c478bd9Sstevel@tonic-gate uint32_t spl;
159*7c478bd9Sstevel@tonic-gate
160*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
161*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
162*7c478bd9Sstevel@tonic-gate data = i_ddi_get8(handle, addr);
163*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
164*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
165*7c478bd9Sstevel@tonic-gate
166*7c478bd9Sstevel@tonic-gate return (data);
167*7c478bd9Sstevel@tonic-gate }
168*7c478bd9Sstevel@tonic-gate
169*7c478bd9Sstevel@tonic-gate static uint16_t
pci_axq_hack_get16(ddi_acc_impl_t * handle,uint16_t * addr)170*7c478bd9Sstevel@tonic-gate pci_axq_hack_get16(ddi_acc_impl_t *handle, uint16_t *addr)
171*7c478bd9Sstevel@tonic-gate {
172*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
173*7c478bd9Sstevel@tonic-gate uint16_t data;
174*7c478bd9Sstevel@tonic-gate uint32_t spl;
175*7c478bd9Sstevel@tonic-gate
176*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
177*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
178*7c478bd9Sstevel@tonic-gate data = i_ddi_swap_get16(handle, addr);
179*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
180*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
181*7c478bd9Sstevel@tonic-gate
182*7c478bd9Sstevel@tonic-gate return (data);
183*7c478bd9Sstevel@tonic-gate }
184*7c478bd9Sstevel@tonic-gate
185*7c478bd9Sstevel@tonic-gate static uint32_t
pci_axq_hack_get32(ddi_acc_impl_t * handle,uint32_t * addr)186*7c478bd9Sstevel@tonic-gate pci_axq_hack_get32(ddi_acc_impl_t *handle, uint32_t *addr)
187*7c478bd9Sstevel@tonic-gate {
188*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
189*7c478bd9Sstevel@tonic-gate uint32_t data;
190*7c478bd9Sstevel@tonic-gate uint32_t spl;
191*7c478bd9Sstevel@tonic-gate
192*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
193*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
194*7c478bd9Sstevel@tonic-gate data = i_ddi_swap_get32(handle, addr);
195*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
196*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
197*7c478bd9Sstevel@tonic-gate
198*7c478bd9Sstevel@tonic-gate return (data);
199*7c478bd9Sstevel@tonic-gate }
200*7c478bd9Sstevel@tonic-gate
201*7c478bd9Sstevel@tonic-gate static uint64_t
pci_axq_hack_get64(ddi_acc_impl_t * handle,uint64_t * addr)202*7c478bd9Sstevel@tonic-gate pci_axq_hack_get64(ddi_acc_impl_t *handle, uint64_t *addr)
203*7c478bd9Sstevel@tonic-gate {
204*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
205*7c478bd9Sstevel@tonic-gate uint64_t data;
206*7c478bd9Sstevel@tonic-gate uint32_t spl;
207*7c478bd9Sstevel@tonic-gate
208*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
209*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
210*7c478bd9Sstevel@tonic-gate data = i_ddi_swap_get64(handle, addr);
211*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
212*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
213*7c478bd9Sstevel@tonic-gate
214*7c478bd9Sstevel@tonic-gate return (data);
215*7c478bd9Sstevel@tonic-gate }
216*7c478bd9Sstevel@tonic-gate
217*7c478bd9Sstevel@tonic-gate static void
pci_axq_hack_put8(ddi_acc_impl_t * handle,uint8_t * addr,uint8_t data)218*7c478bd9Sstevel@tonic-gate pci_axq_hack_put8(ddi_acc_impl_t *handle, uint8_t *addr, uint8_t data)
219*7c478bd9Sstevel@tonic-gate {
220*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
221*7c478bd9Sstevel@tonic-gate uint32_t spl;
222*7c478bd9Sstevel@tonic-gate
223*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
224*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
225*7c478bd9Sstevel@tonic-gate i_ddi_put8(handle, addr, data);
226*7c478bd9Sstevel@tonic-gate membar_sync();
227*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
228*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
229*7c478bd9Sstevel@tonic-gate }
230*7c478bd9Sstevel@tonic-gate
231*7c478bd9Sstevel@tonic-gate static void
pci_axq_hack_put16(ddi_acc_impl_t * handle,uint16_t * addr,uint16_t data)232*7c478bd9Sstevel@tonic-gate pci_axq_hack_put16(ddi_acc_impl_t *handle, uint16_t *addr, uint16_t data)
233*7c478bd9Sstevel@tonic-gate {
234*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
235*7c478bd9Sstevel@tonic-gate uint32_t spl;
236*7c478bd9Sstevel@tonic-gate
237*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
238*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
239*7c478bd9Sstevel@tonic-gate i_ddi_swap_put16(handle, addr, data);
240*7c478bd9Sstevel@tonic-gate membar_sync();
241*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
242*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
243*7c478bd9Sstevel@tonic-gate }
244*7c478bd9Sstevel@tonic-gate
245*7c478bd9Sstevel@tonic-gate static void
pci_axq_hack_put32(ddi_acc_impl_t * handle,uint32_t * addr,uint32_t data)246*7c478bd9Sstevel@tonic-gate pci_axq_hack_put32(ddi_acc_impl_t *handle, uint32_t *addr, uint32_t data)
247*7c478bd9Sstevel@tonic-gate {
248*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
249*7c478bd9Sstevel@tonic-gate uint32_t spl;
250*7c478bd9Sstevel@tonic-gate
251*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
252*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
253*7c478bd9Sstevel@tonic-gate i_ddi_swap_put32(handle, addr, data);
254*7c478bd9Sstevel@tonic-gate membar_sync();
255*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
256*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
257*7c478bd9Sstevel@tonic-gate }
258*7c478bd9Sstevel@tonic-gate
259*7c478bd9Sstevel@tonic-gate static void
pci_axq_hack_put64(ddi_acc_impl_t * handle,uint64_t * addr,uint64_t data)260*7c478bd9Sstevel@tonic-gate pci_axq_hack_put64(ddi_acc_impl_t *handle, uint64_t *addr, uint64_t data)
261*7c478bd9Sstevel@tonic-gate {
262*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
263*7c478bd9Sstevel@tonic-gate uint32_t spl;
264*7c478bd9Sstevel@tonic-gate
265*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
266*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
267*7c478bd9Sstevel@tonic-gate i_ddi_swap_put64(handle, addr, data);
268*7c478bd9Sstevel@tonic-gate membar_sync();
269*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
270*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
271*7c478bd9Sstevel@tonic-gate }
272*7c478bd9Sstevel@tonic-gate
273*7c478bd9Sstevel@tonic-gate static void
pci_axq_hack_rep_get8(ddi_acc_impl_t * handle,uint8_t * host_addr,uint8_t * dev_addr,size_t repcount,uint_t flags)274*7c478bd9Sstevel@tonic-gate pci_axq_hack_rep_get8(ddi_acc_impl_t *handle, uint8_t *host_addr,
275*7c478bd9Sstevel@tonic-gate uint8_t *dev_addr, size_t repcount, uint_t flags)
276*7c478bd9Sstevel@tonic-gate {
277*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
278*7c478bd9Sstevel@tonic-gate uint32_t spl;
279*7c478bd9Sstevel@tonic-gate
280*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
281*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
282*7c478bd9Sstevel@tonic-gate i_ddi_rep_get8(handle, host_addr, dev_addr, repcount, flags);
283*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
284*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
285*7c478bd9Sstevel@tonic-gate }
286*7c478bd9Sstevel@tonic-gate
287*7c478bd9Sstevel@tonic-gate static void
pci_axq_hack_rep_get16(ddi_acc_impl_t * handle,uint16_t * host_addr,uint16_t * dev_addr,size_t repcount,uint_t flags)288*7c478bd9Sstevel@tonic-gate pci_axq_hack_rep_get16(ddi_acc_impl_t *handle, uint16_t *host_addr,
289*7c478bd9Sstevel@tonic-gate uint16_t *dev_addr, size_t repcount, uint_t flags)
290*7c478bd9Sstevel@tonic-gate {
291*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
292*7c478bd9Sstevel@tonic-gate uint32_t spl;
293*7c478bd9Sstevel@tonic-gate
294*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
295*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
296*7c478bd9Sstevel@tonic-gate i_ddi_swap_rep_get16(handle, host_addr, dev_addr, repcount, flags);
297*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
298*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
299*7c478bd9Sstevel@tonic-gate }
300*7c478bd9Sstevel@tonic-gate
301*7c478bd9Sstevel@tonic-gate static void
pci_axq_hack_rep_get32(ddi_acc_impl_t * handle,uint32_t * host_addr,uint32_t * dev_addr,size_t repcount,uint_t flags)302*7c478bd9Sstevel@tonic-gate pci_axq_hack_rep_get32(ddi_acc_impl_t *handle, uint32_t *host_addr,
303*7c478bd9Sstevel@tonic-gate uint32_t *dev_addr, size_t repcount, uint_t flags)
304*7c478bd9Sstevel@tonic-gate {
305*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
306*7c478bd9Sstevel@tonic-gate uint32_t spl;
307*7c478bd9Sstevel@tonic-gate
308*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
309*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
310*7c478bd9Sstevel@tonic-gate i_ddi_swap_rep_get32(handle, host_addr, dev_addr, repcount, flags);
311*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
312*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
313*7c478bd9Sstevel@tonic-gate }
314*7c478bd9Sstevel@tonic-gate
315*7c478bd9Sstevel@tonic-gate static void
pci_axq_hack_rep_get64(ddi_acc_impl_t * handle,uint64_t * host_addr,uint64_t * dev_addr,size_t repcount,uint_t flags)316*7c478bd9Sstevel@tonic-gate pci_axq_hack_rep_get64(ddi_acc_impl_t *handle, uint64_t *host_addr,
317*7c478bd9Sstevel@tonic-gate uint64_t *dev_addr, size_t repcount, uint_t flags)
318*7c478bd9Sstevel@tonic-gate {
319*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
320*7c478bd9Sstevel@tonic-gate uint32_t spl;
321*7c478bd9Sstevel@tonic-gate
322*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
323*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
324*7c478bd9Sstevel@tonic-gate i_ddi_swap_rep_get64(handle, host_addr, dev_addr, repcount, flags);
325*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
326*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
327*7c478bd9Sstevel@tonic-gate }
328*7c478bd9Sstevel@tonic-gate
329*7c478bd9Sstevel@tonic-gate static void
pci_axq_hack_rep_put8(ddi_acc_impl_t * handle,uint8_t * host_addr,uint8_t * dev_addr,size_t repcount,uint_t flags)330*7c478bd9Sstevel@tonic-gate pci_axq_hack_rep_put8(ddi_acc_impl_t *handle, uint8_t *host_addr,
331*7c478bd9Sstevel@tonic-gate uint8_t *dev_addr, size_t repcount, uint_t flags)
332*7c478bd9Sstevel@tonic-gate {
333*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
334*7c478bd9Sstevel@tonic-gate uint32_t spl;
335*7c478bd9Sstevel@tonic-gate
336*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
337*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
338*7c478bd9Sstevel@tonic-gate while (repcount--) {
339*7c478bd9Sstevel@tonic-gate i_ddi_put8(handle, dev_addr, *host_addr);
340*7c478bd9Sstevel@tonic-gate membar_sync();
341*7c478bd9Sstevel@tonic-gate if (flags == DDI_DEV_AUTOINCR)
342*7c478bd9Sstevel@tonic-gate dev_addr++;
343*7c478bd9Sstevel@tonic-gate host_addr++;
344*7c478bd9Sstevel@tonic-gate }
345*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
346*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
347*7c478bd9Sstevel@tonic-gate }
348*7c478bd9Sstevel@tonic-gate
349*7c478bd9Sstevel@tonic-gate static void
pci_axq_hack_rep_put16(ddi_acc_impl_t * handle,uint16_t * host_addr,uint16_t * dev_addr,size_t repcount,uint_t flags)350*7c478bd9Sstevel@tonic-gate pci_axq_hack_rep_put16(ddi_acc_impl_t *handle, uint16_t *host_addr,
351*7c478bd9Sstevel@tonic-gate uint16_t *dev_addr, size_t repcount, uint_t flags)
352*7c478bd9Sstevel@tonic-gate {
353*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
354*7c478bd9Sstevel@tonic-gate uint32_t spl;
355*7c478bd9Sstevel@tonic-gate
356*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
357*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
358*7c478bd9Sstevel@tonic-gate while (repcount--) {
359*7c478bd9Sstevel@tonic-gate i_ddi_put16(handle, dev_addr, *host_addr);
360*7c478bd9Sstevel@tonic-gate membar_sync();
361*7c478bd9Sstevel@tonic-gate if (flags == DDI_DEV_AUTOINCR)
362*7c478bd9Sstevel@tonic-gate dev_addr++;
363*7c478bd9Sstevel@tonic-gate host_addr++;
364*7c478bd9Sstevel@tonic-gate }
365*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
366*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
367*7c478bd9Sstevel@tonic-gate }
368*7c478bd9Sstevel@tonic-gate
369*7c478bd9Sstevel@tonic-gate static void
pci_axq_hack_rep_put32(ddi_acc_impl_t * handle,uint32_t * host_addr,uint32_t * dev_addr,size_t repcount,uint_t flags)370*7c478bd9Sstevel@tonic-gate pci_axq_hack_rep_put32(ddi_acc_impl_t *handle, uint32_t *host_addr,
371*7c478bd9Sstevel@tonic-gate uint32_t *dev_addr, size_t repcount, uint_t flags)
372*7c478bd9Sstevel@tonic-gate {
373*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
374*7c478bd9Sstevel@tonic-gate uint32_t spl;
375*7c478bd9Sstevel@tonic-gate
376*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
377*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
378*7c478bd9Sstevel@tonic-gate while (repcount--) {
379*7c478bd9Sstevel@tonic-gate i_ddi_put32(handle, dev_addr, *host_addr);
380*7c478bd9Sstevel@tonic-gate membar_sync();
381*7c478bd9Sstevel@tonic-gate if (flags == DDI_DEV_AUTOINCR)
382*7c478bd9Sstevel@tonic-gate dev_addr++;
383*7c478bd9Sstevel@tonic-gate host_addr++;
384*7c478bd9Sstevel@tonic-gate }
385*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
386*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
387*7c478bd9Sstevel@tonic-gate }
388*7c478bd9Sstevel@tonic-gate static void
pci_axq_hack_rep_put64(ddi_acc_impl_t * handle,uint64_t * host_addr,uint64_t * dev_addr,size_t repcount,uint_t flags)389*7c478bd9Sstevel@tonic-gate pci_axq_hack_rep_put64(ddi_acc_impl_t *handle, uint64_t *host_addr,
390*7c478bd9Sstevel@tonic-gate uint64_t *dev_addr, size_t repcount, uint_t flags)
391*7c478bd9Sstevel@tonic-gate {
392*7c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)handle->ahi_common.ah_bus_private;
393*7c478bd9Sstevel@tonic-gate uint32_t spl;
394*7c478bd9Sstevel@tonic-gate
395*7c478bd9Sstevel@tonic-gate spl = ddi_enter_critical();
396*7c478bd9Sstevel@tonic-gate PIO_LIMIT_ENTER(pbm_p);
397*7c478bd9Sstevel@tonic-gate while (repcount--) {
398*7c478bd9Sstevel@tonic-gate i_ddi_put64(handle, dev_addr, *host_addr);
399*7c478bd9Sstevel@tonic-gate membar_sync();
400*7c478bd9Sstevel@tonic-gate if (flags == DDI_DEV_AUTOINCR)
401*7c478bd9Sstevel@tonic-gate dev_addr++;
402*7c478bd9Sstevel@tonic-gate host_addr++;
403*7c478bd9Sstevel@tonic-gate }
404*7c478bd9Sstevel@tonic-gate PIO_LIMIT_EXIT(pbm_p);
405*7c478bd9Sstevel@tonic-gate ddi_exit_critical(spl);
406*7c478bd9Sstevel@tonic-gate }
407