2 * Copyright (c) 2009 Marcel Moolenaar
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
30 #include <sys/types.h>
31 #include <machine/bus.h>
33 extern u_long ia64_port_base;
35 #define __PIO_ADDR(port) \
36 (void *)(ia64_port_base | (((port) & 0xfffc) << 10) | ((port) & 0xFFF))
39 bus_space_read_io_1(u_long port)
44 v = ia64_ld1(__PIO_ADDR(port));
51 bus_space_read_io_2(u_long port)
56 v = ia64_ld2(__PIO_ADDR(port));
63 bus_space_read_io_4(u_long port)
68 v = ia64_ld4(__PIO_ADDR(port));
76 bus_space_read_io_8(u_long port)
82 bus_space_write_io_1(u_long port, uint8_t val)
86 ia64_st1(__PIO_ADDR(port), val);
92 bus_space_write_io_2(u_long port, uint16_t val)
96 ia64_st2(__PIO_ADDR(port), val);
102 bus_space_write_io_4(u_long port, uint32_t val)
106 ia64_st4(__PIO_ADDR(port), val);
113 bus_space_write_io_8(u_long port, uint64_t val)
119 bus_space_read_multi_io_1(u_long port, uint8_t *ptr, size_t count)
123 *ptr++ = bus_space_read_io_1(port);
127 bus_space_read_multi_io_2(u_long port, uint16_t *ptr, size_t count)
131 *ptr++ = bus_space_read_io_2(port);
135 bus_space_read_multi_io_4(u_long port, uint32_t *ptr, size_t count)
139 *ptr++ = bus_space_read_io_4(port);
144 bus_space_read_multi_io_8(u_long port, uint64_t *ptr, size_t count)
150 bus_space_write_multi_io_1(u_long port, const uint8_t *ptr, size_t count)
154 bus_space_write_io_1(port, *ptr++);
158 bus_space_write_multi_io_2(u_long port, const uint16_t *ptr, size_t count)
162 bus_space_write_io_2(port, *ptr++);
166 bus_space_write_multi_io_4(u_long port, const uint32_t *ptr, size_t count)
170 bus_space_write_io_4(port, *ptr++);
175 bus_space_write_multi_io_8(u_long port, const uint64_t *ptr, size_t count)
181 bus_space_read_region_io_1(u_long port, uint8_t *ptr, size_t count)
184 while (count-- > 0) {
185 *ptr++ = bus_space_read_io_1(port);
191 bus_space_read_region_io_2(u_long port, uint16_t *ptr, size_t count)
194 while (count-- > 0) {
195 *ptr++ = bus_space_read_io_2(port);
201 bus_space_read_region_io_4(u_long port, uint32_t *ptr, size_t count)
204 while (count-- > 0) {
205 *ptr++ = bus_space_read_io_4(port);
211 void bus_space_read_region_io_8(u_long, uint64_t *, size_t);
215 bus_space_write_region_io_1(u_long port, const uint8_t *ptr, size_t count)
218 while (count-- > 0) {
219 bus_space_write_io_1(port, *ptr++);
225 bus_space_write_region_io_2(u_long port, const uint16_t *ptr, size_t count)
228 while (count-- > 0) {
229 bus_space_write_io_2(port, *ptr++);
235 bus_space_write_region_io_4(u_long port, const uint32_t *ptr, size_t count)
238 while (count-- > 0) {
239 bus_space_write_io_4(port, *ptr++);
246 bus_space_write_region_io_8(u_long port, const uint64_t *ptr, size_t count)
252 bus_space_set_region_io_1(u_long port, uint8_t val, size_t count)
255 while (count-- > 0) {
256 bus_space_write_io_1(port, val);
262 bus_space_set_region_io_2(u_long port, uint16_t val, size_t count)
265 while (count-- > 0) {
266 bus_space_write_io_2(port, val);
272 bus_space_set_region_io_4(u_long port, uint32_t val, size_t count)
275 while (count-- > 0) {
276 bus_space_write_io_4(port, val);
283 bus_space_set_region_io_8(u_long port, uint64_t val, size_t count)
289 bus_space_copy_region_io_1(u_long src, u_long dst, size_t count)
301 while (count-- > 0) {
302 val = bus_space_read_io_1(src);
303 bus_space_write_io_1(dst, val);
310 bus_space_copy_region_io_2(u_long src, u_long dst, size_t count)
316 src += 2 * (count - 1);
317 dst += 2 * (count - 1);
322 while (count-- > 0) {
323 val = bus_space_read_io_2(src);
324 bus_space_write_io_2(dst, val);
331 bus_space_copy_region_io_4(u_long src, u_long dst, size_t count)
337 src += 4 * (count - 1);
338 dst += 4 * (count - 1);
343 while (count-- > 0) {
344 val = bus_space_read_io_4(src);
345 bus_space_write_io_4(dst, val);
353 bus_space_copy_region_io_8(u_long src, u_long dst, size_t count)