1 /* $NetBSD: pci_bwx_bus_io_chipdep.c,v 1.17 2008/04/28 20:23:11 martin Exp $ */
4 * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
34 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
35 * All rights reserved.
37 * Author: Chris G. Demetriou
39 * Permission to use, copy, modify and distribute this software and
40 * its documentation is hereby granted, provided that both the copyright
41 * notice and this permission notice appear in all copies of the
42 * software, derivative works or modified versions, and any portions
43 * thereof, and that both notices appear in supporting documentation.
45 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
46 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
47 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
49 * Carnegie Mellon requests users of this software to return to
51 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
52 * School of Computer Science
53 * Carnegie Mellon University
54 * Pittsburgh PA 15213-3890
56 * any improvements or extensions that they make and grant Carnegie the
57 * rights to redistribute these changes.
61 * Common PCI Chipset "bus I/O" functions, for chipsets which have to
62 * deal with only a single PCI interface chip in a machine.
65 * CHIP name of the 'chip' it's being compiled for.
66 * CHIP_IO_BASE I/O space base to use.
68 * If defined, device-provided static storage area
69 * for the I/O space extent. If this is defined,
70 * CHIP_IO_EX_STORE_SIZE must also be defined. If
71 * this is not defined, a static area will be
73 * CHIP_IO_EX_STORE_SIZE
74 * Size of the device-provided static storage area
75 * for the I/O memory space extent.
78 #include <sys/cdefs.h>
79 __KERNEL_RCSID(1, "$NetBSD: pci_bwx_bus_io_chipdep.c,v 1.17 2008/04/28 20:23:11 martin Exp $");
81 #include <sys/extent.h>
83 #include <machine/bwx.h>
85 #define __C(A,B) __CONCAT(A,B)
86 #define __S(S) __STRING(S)
88 /* mapping/unmapping */
89 int __C(CHIP
,_io_map
)(void *, bus_addr_t
, bus_size_t
, int,
90 bus_space_handle_t
*, int);
91 void __C(CHIP
,_io_unmap
)(void *, bus_space_handle_t
,
93 int __C(CHIP
,_io_subregion
)(void *, bus_space_handle_t
,
94 bus_size_t
, bus_size_t
, bus_space_handle_t
*);
96 int __C(CHIP
,_io_translate
)(void *, bus_addr_t
, bus_size_t
,
97 int, struct alpha_bus_space_translation
*);
98 int __C(CHIP
,_io_get_window
)(void *, int,
99 struct alpha_bus_space_translation
*);
101 /* allocation/deallocation */
102 int __C(CHIP
,_io_alloc
)(void *, bus_addr_t
, bus_addr_t
,
103 bus_size_t
, bus_size_t
, bus_addr_t
, int, bus_addr_t
*,
104 bus_space_handle_t
*);
105 void __C(CHIP
,_io_free
)(void *, bus_space_handle_t
,
108 /* get kernel virtual address */
109 void * __C(CHIP
,_io_vaddr
)(void *, bus_space_handle_t
);
112 paddr_t
__C(CHIP
,_io_mmap
)(void *, bus_addr_t
, off_t
, int, int);
115 inline void __C(CHIP
,_io_barrier
)(void *, bus_space_handle_t
,
116 bus_size_t
, bus_size_t
, int);
119 inline u_int8_t
__C(CHIP
,_io_read_1
)(void *, bus_space_handle_t
,
121 inline u_int16_t
__C(CHIP
,_io_read_2
)(void *, bus_space_handle_t
,
123 inline u_int32_t
__C(CHIP
,_io_read_4
)(void *, bus_space_handle_t
,
125 inline u_int64_t
__C(CHIP
,_io_read_8
)(void *, bus_space_handle_t
,
129 void __C(CHIP
,_io_read_multi_1
)(void *, bus_space_handle_t
,
130 bus_size_t
, u_int8_t
*, bus_size_t
);
131 void __C(CHIP
,_io_read_multi_2
)(void *, bus_space_handle_t
,
132 bus_size_t
, u_int16_t
*, bus_size_t
);
133 void __C(CHIP
,_io_read_multi_4
)(void *, bus_space_handle_t
,
134 bus_size_t
, u_int32_t
*, bus_size_t
);
135 void __C(CHIP
,_io_read_multi_8
)(void *, bus_space_handle_t
,
136 bus_size_t
, u_int64_t
*, bus_size_t
);
139 void __C(CHIP
,_io_read_region_1
)(void *, bus_space_handle_t
,
140 bus_size_t
, u_int8_t
*, bus_size_t
);
141 void __C(CHIP
,_io_read_region_2
)(void *, bus_space_handle_t
,
142 bus_size_t
, u_int16_t
*, bus_size_t
);
143 void __C(CHIP
,_io_read_region_4
)(void *, bus_space_handle_t
,
144 bus_size_t
, u_int32_t
*, bus_size_t
);
145 void __C(CHIP
,_io_read_region_8
)(void *, bus_space_handle_t
,
146 bus_size_t
, u_int64_t
*, bus_size_t
);
149 inline void __C(CHIP
,_io_write_1
)(void *, bus_space_handle_t
,
150 bus_size_t
, u_int8_t
);
151 inline void __C(CHIP
,_io_write_2
)(void *, bus_space_handle_t
,
152 bus_size_t
, u_int16_t
);
153 inline void __C(CHIP
,_io_write_4
)(void *, bus_space_handle_t
,
154 bus_size_t
, u_int32_t
);
155 inline void __C(CHIP
,_io_write_8
)(void *, bus_space_handle_t
,
156 bus_size_t
, u_int64_t
);
159 void __C(CHIP
,_io_write_multi_1
)(void *, bus_space_handle_t
,
160 bus_size_t
, const u_int8_t
*, bus_size_t
);
161 void __C(CHIP
,_io_write_multi_2
)(void *, bus_space_handle_t
,
162 bus_size_t
, const u_int16_t
*, bus_size_t
);
163 void __C(CHIP
,_io_write_multi_4
)(void *, bus_space_handle_t
,
164 bus_size_t
, const u_int32_t
*, bus_size_t
);
165 void __C(CHIP
,_io_write_multi_8
)(void *, bus_space_handle_t
,
166 bus_size_t
, const u_int64_t
*, bus_size_t
);
169 void __C(CHIP
,_io_write_region_1
)(void *, bus_space_handle_t
,
170 bus_size_t
, const u_int8_t
*, bus_size_t
);
171 void __C(CHIP
,_io_write_region_2
)(void *, bus_space_handle_t
,
172 bus_size_t
, const u_int16_t
*, bus_size_t
);
173 void __C(CHIP
,_io_write_region_4
)(void *, bus_space_handle_t
,
174 bus_size_t
, const u_int32_t
*, bus_size_t
);
175 void __C(CHIP
,_io_write_region_8
)(void *, bus_space_handle_t
,
176 bus_size_t
, const u_int64_t
*, bus_size_t
);
179 void __C(CHIP
,_io_set_multi_1
)(void *, bus_space_handle_t
,
180 bus_size_t
, u_int8_t
, bus_size_t
);
181 void __C(CHIP
,_io_set_multi_2
)(void *, bus_space_handle_t
,
182 bus_size_t
, u_int16_t
, bus_size_t
);
183 void __C(CHIP
,_io_set_multi_4
)(void *, bus_space_handle_t
,
184 bus_size_t
, u_int32_t
, bus_size_t
);
185 void __C(CHIP
,_io_set_multi_8
)(void *, bus_space_handle_t
,
186 bus_size_t
, u_int64_t
, bus_size_t
);
189 void __C(CHIP
,_io_set_region_1
)(void *, bus_space_handle_t
,
190 bus_size_t
, u_int8_t
, bus_size_t
);
191 void __C(CHIP
,_io_set_region_2
)(void *, bus_space_handle_t
,
192 bus_size_t
, u_int16_t
, bus_size_t
);
193 void __C(CHIP
,_io_set_region_4
)(void *, bus_space_handle_t
,
194 bus_size_t
, u_int32_t
, bus_size_t
);
195 void __C(CHIP
,_io_set_region_8
)(void *, bus_space_handle_t
,
196 bus_size_t
, u_int64_t
, bus_size_t
);
199 void __C(CHIP
,_io_copy_region_1
)(void *, bus_space_handle_t
,
200 bus_size_t
, bus_space_handle_t
, bus_size_t
, bus_size_t
);
201 void __C(CHIP
,_io_copy_region_2
)(void *, bus_space_handle_t
,
202 bus_size_t
, bus_space_handle_t
, bus_size_t
, bus_size_t
);
203 void __C(CHIP
,_io_copy_region_4
)(void *, bus_space_handle_t
,
204 bus_size_t
, bus_space_handle_t
, bus_size_t
, bus_size_t
);
205 void __C(CHIP
,_io_copy_region_8
)(void *, bus_space_handle_t
,
206 bus_size_t
, bus_space_handle_t
, bus_size_t
, bus_size_t
);
208 #ifndef CHIP_IO_EX_STORE
210 __C(CHIP
,_io_ex_storage
)[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
211 #define CHIP_IO_EX_STORE(v) (__C(CHIP, _io_ex_storage))
212 #define CHIP_IO_EX_STORE_SIZE(v) (sizeof __C(CHIP, _io_ex_storage))
216 __C(CHIP
,_bus_io_init
)(t
, v
)
223 * Initialize the bus space tag.
229 /* mapping/unmapping */
230 t
->abs_map
= __C(CHIP
,_io_map
);
231 t
->abs_unmap
= __C(CHIP
,_io_unmap
);
232 t
->abs_subregion
= __C(CHIP
,_io_subregion
);
234 t
->abs_translate
= __C(CHIP
,_io_translate
);
235 t
->abs_get_window
= __C(CHIP
,_io_get_window
);
237 /* allocation/deallocation */
238 t
->abs_alloc
= __C(CHIP
,_io_alloc
);
239 t
->abs_free
= __C(CHIP
,_io_free
);
241 /* get kernel virtual address */
242 t
->abs_vaddr
= __C(CHIP
,_io_vaddr
);
245 t
->abs_mmap
= __C(CHIP
,_io_mmap
);
248 t
->abs_barrier
= __C(CHIP
,_io_barrier
);
251 t
->abs_r_1
= __C(CHIP
,_io_read_1
);
252 t
->abs_r_2
= __C(CHIP
,_io_read_2
);
253 t
->abs_r_4
= __C(CHIP
,_io_read_4
);
254 t
->abs_r_8
= __C(CHIP
,_io_read_8
);
257 t
->abs_rm_1
= __C(CHIP
,_io_read_multi_1
);
258 t
->abs_rm_2
= __C(CHIP
,_io_read_multi_2
);
259 t
->abs_rm_4
= __C(CHIP
,_io_read_multi_4
);
260 t
->abs_rm_8
= __C(CHIP
,_io_read_multi_8
);
263 t
->abs_rr_1
= __C(CHIP
,_io_read_region_1
);
264 t
->abs_rr_2
= __C(CHIP
,_io_read_region_2
);
265 t
->abs_rr_4
= __C(CHIP
,_io_read_region_4
);
266 t
->abs_rr_8
= __C(CHIP
,_io_read_region_8
);
269 t
->abs_w_1
= __C(CHIP
,_io_write_1
);
270 t
->abs_w_2
= __C(CHIP
,_io_write_2
);
271 t
->abs_w_4
= __C(CHIP
,_io_write_4
);
272 t
->abs_w_8
= __C(CHIP
,_io_write_8
);
275 t
->abs_wm_1
= __C(CHIP
,_io_write_multi_1
);
276 t
->abs_wm_2
= __C(CHIP
,_io_write_multi_2
);
277 t
->abs_wm_4
= __C(CHIP
,_io_write_multi_4
);
278 t
->abs_wm_8
= __C(CHIP
,_io_write_multi_8
);
281 t
->abs_wr_1
= __C(CHIP
,_io_write_region_1
);
282 t
->abs_wr_2
= __C(CHIP
,_io_write_region_2
);
283 t
->abs_wr_4
= __C(CHIP
,_io_write_region_4
);
284 t
->abs_wr_8
= __C(CHIP
,_io_write_region_8
);
287 t
->abs_sm_1
= __C(CHIP
,_io_set_multi_1
);
288 t
->abs_sm_2
= __C(CHIP
,_io_set_multi_2
);
289 t
->abs_sm_4
= __C(CHIP
,_io_set_multi_4
);
290 t
->abs_sm_8
= __C(CHIP
,_io_set_multi_8
);
293 t
->abs_sr_1
= __C(CHIP
,_io_set_region_1
);
294 t
->abs_sr_2
= __C(CHIP
,_io_set_region_2
);
295 t
->abs_sr_4
= __C(CHIP
,_io_set_region_4
);
296 t
->abs_sr_8
= __C(CHIP
,_io_set_region_8
);
299 t
->abs_c_1
= __C(CHIP
,_io_copy_region_1
);
300 t
->abs_c_2
= __C(CHIP
,_io_copy_region_2
);
301 t
->abs_c_4
= __C(CHIP
,_io_copy_region_4
);
302 t
->abs_c_8
= __C(CHIP
,_io_copy_region_8
);
304 ex
= extent_create(__S(__C(CHIP
,_bus_io
)), 0x0UL
, 0xffffffffUL
,
305 M_DEVBUF
, (void *)CHIP_IO_EX_STORE(v
), CHIP_IO_EX_STORE_SIZE(v
),
306 EX_NOWAIT
|EX_NOCOALESCE
);
308 CHIP_IO_EXTENT(v
) = ex
;
312 __C(CHIP
,_io_translate
)(v
, ioaddr
, iolen
, flags
, abst
)
317 struct alpha_bus_space_translation
*abst
;
319 int linear
= flags
& BUS_SPACE_MAP_LINEAR
;
322 * Can't map i/o space linearly.
327 return (__C(CHIP
,_io_get_window
)(v
, 0, abst
));
331 __C(CHIP
,_io_get_window
)(v
, window
, abst
)
334 struct alpha_bus_space_translation
*abst
;
339 abst
->abst_bus_start
= 0;
340 abst
->abst_bus_end
= 0xffffffffUL
;
341 abst
->abst_sys_start
= CHIP_IO_SYS_START(v
);
342 abst
->abst_sys_end
= CHIP_IO_SYS_START(v
) + abst
->abst_bus_end
;
343 abst
->abst_addr_shift
= 0;
344 abst
->abst_size_shift
= 0;
345 abst
->abst_flags
= ABST_DENSE
|ABST_BWX
;
349 panic(__S(__C(CHIP
,_io_get_window
)) ": invalid window %d",
357 __C(CHIP
,_io_map
)(v
, ioaddr
, iosize
, flags
, iohp
, acct
)
362 bus_space_handle_t
*iohp
;
365 struct alpha_bus_space_translation abst
;
369 * Get the translation for this address.
371 error
= __C(CHIP
,_io_translate
)(v
, ioaddr
, iosize
, flags
, &abst
);
379 printf("io: allocating 0x%lx to 0x%lx\n", ioaddr
, ioaddr
+ iosize
- 1);
381 error
= extent_alloc_region(CHIP_IO_EXTENT(v
), ioaddr
, iosize
,
382 EX_NOWAIT
| (CHIP_EX_MALLOC_SAFE(v
) ? EX_MALLOCOK
: 0));
385 printf("io: allocation failed (%d)\n", error
);
386 extent_print(CHIP_IO_EXTENT(v
));
392 *iohp
= ALPHA_PHYS_TO_K0SEG(abst
.abst_sys_start
+ ioaddr
);
398 __C(CHIP
,_io_unmap
)(v
, ioh
, iosize
, acct
)
400 bus_space_handle_t ioh
;
411 printf("io: freeing handle 0x%lx for 0x%lx\n", ioh
, iosize
);
414 ioaddr
= ioh
- ALPHA_PHYS_TO_K0SEG(CHIP_IO_SYS_START(v
));
417 printf("io: freeing 0x%lx to 0x%lx\n", ioaddr
, ioaddr
+ iosize
- 1);
419 error
= extent_free(CHIP_IO_EXTENT(v
), ioaddr
, iosize
,
420 EX_NOWAIT
| (CHIP_EX_MALLOC_SAFE(v
) ? EX_MALLOCOK
: 0));
422 printf("%s: WARNING: could not unmap 0x%lx-0x%lx (error %d)\n",
423 __S(__C(CHIP
,_io_unmap
)), ioaddr
, ioaddr
+ iosize
- 1,
426 extent_print(CHIP_IO_EXTENT(v
));
432 __C(CHIP
,_io_subregion
)(v
, ioh
, offset
, size
, nioh
)
434 bus_space_handle_t ioh
, *nioh
;
435 bus_size_t offset
, size
;
438 *nioh
= ioh
+ offset
;
443 __C(CHIP
,_io_alloc
)(v
, rstart
, rend
, size
, align
, boundary
, flags
,
446 bus_addr_t rstart
, rend
, *addrp
;
447 bus_size_t size
, align
, boundary
;
449 bus_space_handle_t
*bshp
;
451 struct alpha_bus_space_translation abst
;
452 int linear
= flags
& BUS_SPACE_MAP_LINEAR
;
457 * Can't map i/o space linearly.
463 * Do the requested allocation.
466 printf("io: allocating from 0x%lx to 0x%lx\n", rstart
, rend
);
468 error
= extent_alloc_subregion(CHIP_IO_EXTENT(v
), rstart
, rend
,
469 size
, align
, boundary
,
470 EX_FAST
| EX_NOWAIT
| (CHIP_EX_MALLOC_SAFE(v
) ? EX_MALLOCOK
: 0),
474 printf("io: allocation failed (%d)\n", error
);
475 extent_print(CHIP_IO_EXTENT(v
));
481 printf("io: allocated 0x%lx to 0x%lx\n", ioaddr
, ioaddr
+ size
- 1);
484 error
= __C(CHIP
,_io_translate
)(v
, ioaddr
, size
, flags
, &abst
);
486 (void) extent_free(CHIP_IO_EXTENT(v
), ioaddr
, size
,
487 EX_NOWAIT
| (CHIP_EX_MALLOC_SAFE(v
) ? EX_MALLOCOK
: 0));
492 *bshp
= ALPHA_PHYS_TO_K0SEG(abst
.abst_sys_start
+ ioaddr
);
498 __C(CHIP
,_io_free
)(v
, bsh
, size
)
500 bus_space_handle_t bsh
;
504 /* Unmap does all we need to do. */
505 __C(CHIP
,_io_unmap
)(v
, bsh
, size
, 1);
509 __C(CHIP
,_io_vaddr
)(v
, bsh
)
511 bus_space_handle_t bsh
;
514 * _io_translate() catches BUS_SPACE_MAP_LINEAR,
515 * so we shouldn't get here
521 __C(CHIP
,_io_mmap
)(v
, addr
, off
, prot
, flags
)
529 /* Not supported for I/O space. */
534 __C(CHIP
,_io_barrier
)(v
, h
, o
, l
, f
)
536 bus_space_handle_t h
;
541 if ((f
& BUS_SPACE_BARRIER_READ
) != 0)
543 else if ((f
& BUS_SPACE_BARRIER_WRITE
) != 0)
548 __C(CHIP
,_io_read_1
)(v
, ioh
, off
)
550 bus_space_handle_t ioh
;
557 return (alpha_ldbu((u_int8_t
*)addr
));
561 __C(CHIP
,_io_read_2
)(v
, ioh
, off
)
563 bus_space_handle_t ioh
;
571 panic(__S(__C(CHIP
,_io_read_2
)) ": addr 0x%lx not aligned",
575 return (alpha_ldwu((u_int16_t
*)addr
));
579 __C(CHIP
,_io_read_4
)(v
, ioh
, off
)
581 bus_space_handle_t ioh
;
589 panic(__S(__C(CHIP
,_io_read_4
)) ": addr 0x%lx not aligned",
593 return (*(u_int32_t
*)addr
);
597 __C(CHIP
,_io_read_8
)(v
, ioh
, off
)
599 bus_space_handle_t ioh
;
604 panic("%s not implemented", __S(__C(CHIP
,_io_read_8
)));
607 #define CHIP_io_read_multi_N(BYTES,TYPE) \
609 __C(__C(CHIP,_io_read_multi_),BYTES)(v, h, o, a, c) \
611 bus_space_handle_t h; \
617 __C(CHIP,_io_barrier)(v, h, o, sizeof *a, \
618 BUS_SPACE_BARRIER_READ); \
619 *a++ = __C(__C(CHIP,_io_read_),BYTES)(v, h, o); \
622 CHIP_io_read_multi_N(1,u_int8_t
)
623 CHIP_io_read_multi_N(2,u_int16_t
)
624 CHIP_io_read_multi_N(4,u_int32_t
)
625 CHIP_io_read_multi_N(8,u_int64_t
)
627 #define CHIP_io_read_region_N(BYTES,TYPE) \
629 __C(__C(CHIP,_io_read_region_),BYTES)(v, h, o, a, c) \
631 bus_space_handle_t h; \
637 *a++ = __C(__C(CHIP,_io_read_),BYTES)(v, h, o); \
641 CHIP_io_read_region_N(1,u_int8_t
)
642 CHIP_io_read_region_N(2,u_int16_t
)
643 CHIP_io_read_region_N(4,u_int32_t
)
644 CHIP_io_read_region_N(8,u_int64_t
)
647 __C(CHIP
,_io_write_1
)(v
, ioh
, off
, val
)
649 bus_space_handle_t ioh
;
656 alpha_stb((u_int8_t
*)addr
, val
);
661 __C(CHIP
,_io_write_2
)(v
, ioh
, off
, val
)
663 bus_space_handle_t ioh
;
672 panic(__S(__C(CHIP
,_io_write_2
)) ": addr 0x%lx not aligned",
675 alpha_stw((u_int16_t
*)addr
, val
);
680 __C(CHIP
,_io_write_4
)(v
, ioh
, off
, val
)
682 bus_space_handle_t ioh
;
691 panic(__S(__C(CHIP
,_io_write_4
)) ": addr 0x%lx not aligned",
694 *(u_int32_t
*)addr
= val
;
699 __C(CHIP
,_io_write_8
)(v
, ioh
, off
, val
)
701 bus_space_handle_t ioh
;
707 panic("%s not implemented", __S(__C(CHIP
,_io_write_8
)));
711 #define CHIP_io_write_multi_N(BYTES,TYPE) \
713 __C(__C(CHIP,_io_write_multi_),BYTES)(v, h, o, a, c) \
715 bus_space_handle_t h; \
721 __C(__C(CHIP,_io_write_),BYTES)(v, h, o, *a++); \
722 __C(CHIP,_io_barrier)(v, h, o, sizeof *a, \
723 BUS_SPACE_BARRIER_WRITE); \
726 CHIP_io_write_multi_N(1,u_int8_t
)
727 CHIP_io_write_multi_N(2,u_int16_t
)
728 CHIP_io_write_multi_N(4,u_int32_t
)
729 CHIP_io_write_multi_N(8,u_int64_t
)
731 #define CHIP_io_write_region_N(BYTES,TYPE) \
733 __C(__C(CHIP,_io_write_region_),BYTES)(v, h, o, a, c) \
735 bus_space_handle_t h; \
741 __C(__C(CHIP,_io_write_),BYTES)(v, h, o, *a++); \
745 CHIP_io_write_region_N(1,u_int8_t
)
746 CHIP_io_write_region_N(2,u_int16_t
)
747 CHIP_io_write_region_N(4,u_int32_t
)
748 CHIP_io_write_region_N(8,u_int64_t
)
750 #define CHIP_io_set_multi_N(BYTES,TYPE) \
752 __C(__C(CHIP,_io_set_multi_),BYTES)(v, h, o, val, c) \
754 bus_space_handle_t h; \
760 __C(__C(CHIP,_io_write_),BYTES)(v, h, o, val); \
761 __C(CHIP,_io_barrier)(v, h, o, sizeof val, \
762 BUS_SPACE_BARRIER_WRITE); \
765 CHIP_io_set_multi_N(1,u_int8_t
)
766 CHIP_io_set_multi_N(2,u_int16_t
)
767 CHIP_io_set_multi_N(4,u_int32_t
)
768 CHIP_io_set_multi_N(8,u_int64_t
)
770 #define CHIP_io_set_region_N(BYTES,TYPE) \
772 __C(__C(CHIP,_io_set_region_),BYTES)(v, h, o, val, c) \
774 bus_space_handle_t h; \
780 __C(__C(CHIP,_io_write_),BYTES)(v, h, o, val); \
784 CHIP_io_set_region_N(1,u_int8_t
)
785 CHIP_io_set_region_N(2,u_int16_t
)
786 CHIP_io_set_region_N(4,u_int32_t
)
787 CHIP_io_set_region_N(8,u_int64_t
)
789 #define CHIP_io_copy_region_N(BYTES) \
791 __C(__C(CHIP,_io_copy_region_),BYTES)(v, h1, o1, h2, o2, c) \
793 bus_space_handle_t h1, h2; \
794 bus_size_t o1, o2, c; \
798 if ((h1 + o1) >= (h2 + o2)) { \
799 /* src after dest: copy forward */ \
800 for (o = 0; c != 0; c--, o += BYTES) { \
801 __C(__C(CHIP,_io_write_),BYTES)(v, h2, o2 + o, \
802 __C(__C(CHIP,_io_read_),BYTES)(v, h1, o1 + o)); \
805 /* dest after src: copy backwards */ \
806 for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES) { \
807 __C(__C(CHIP,_io_write_),BYTES)(v, h2, o2 + o, \
808 __C(__C(CHIP,_io_read_),BYTES)(v, h1, o1 + o)); \
812 CHIP_io_copy_region_N(1)
813 CHIP_io_copy_region_N(2)
814 CHIP_io_copy_region_N(4)
815 CHIP_io_copy_region_N(8)