1 /* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */
3 * $Id: bus.h,v 1.6 2007/08/09 11:23:32 katta Exp $
5 * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
10 * NASA Ames Research Center.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the NetBSD
23 * Foundation, Inc. and its contributors.
24 * 4. Neither the name of The NetBSD Foundation nor the names of its
25 * contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
42 * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
43 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
45 * Redistribution and use in source and binary forms, with or without
46 * modification, are permitted provided that the following conditions
48 * 1. Redistributions of source code must retain the above copyright
49 * notice, this list of conditions and the following disclaimer.
50 * 2. Redistributions in binary form must reproduce the above copyright
51 * notice, this list of conditions and the following disclaimer in the
52 * documentation and/or other materials provided with the distribution.
53 * 3. All advertising materials mentioning features or use of this software
54 * must display the following acknowledgement:
55 * This product includes software developed by Christopher G. Demetriou
56 * for the NetBSD Project.
57 * 4. The name of the author may not be used to endorse or promote products
58 * derived from this software without specific prior written permission
60 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
61 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
62 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
63 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
64 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
65 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
66 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
67 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
68 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
69 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
71 * from: src/sys/alpha/include/bus.h,v 1.5 1999/08/28 00:38:40 peter
75 #ifndef _MACHINE_BUS_H_
76 #define _MACHINE_BUS_H_
79 #include <machine/bus_octeon.h>
81 #include <machine/_bus.h>
82 #include <machine/cpufunc.h>
85 * Values for the mips bus space tag, not to be used directly by MI code.
87 #define MIPS_BUS_SPACE_IO 0 /* space is i/o space */
88 #define MIPS_BUS_SPACE_MEM 1 /* space is mem space */
91 #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
92 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
93 #define BUS_SPACE_MAXSIZE 0xFFFFFFFF /* Maximum supported size */
94 #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
95 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
96 #define BUS_SPACE_MAXADDR 0xFFFFFFFF
98 #define BUS_SPACE_UNRESTRICTED (~0)
101 * Map a region of device bus space into CPU virtual address space.
104 static __inline int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
105 bus_size_t size, int flags,
106 bus_space_handle_t *bshp);
109 bus_space_map(bus_space_tag_t t __unused, bus_addr_t addr,
110 bus_size_t size __unused, int flags __unused,
111 bus_space_handle_t *bshp)
119 * Unmap a region of device bus space.
122 void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
126 * Get a new handle for a subregion of an already-mapped area of bus space.
129 int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
130 bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp);
133 * Allocate a region of memory that is accessible to devices in bus space.
136 int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart,
137 bus_addr_t rend, bus_size_t size, bus_size_t align,
138 bus_size_t boundary, int flags, bus_addr_t *addrp,
139 bus_space_handle_t *bshp);
142 * Free a region of bus space accessible memory.
145 void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
150 * Read a 1, 2, 4, or 8 byte quantity from bus space
151 * described by tag/handle/offset.
153 static __inline u_int8_t bus_space_read_1(bus_space_tag_t tag,
154 bus_space_handle_t handle,
157 static __inline u_int16_t bus_space_read_2(bus_space_tag_t tag,
158 bus_space_handle_t handle,
161 static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag,
162 bus_space_handle_t handle,
165 static __inline u_int8_t
166 bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
170 if (tag == MIPS_BUS_SPACE_IO)
171 return (inb(handle + offset));
172 return (readb(handle + offset));
175 static __inline u_int16_t
176 bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle,
180 if (tag == MIPS_BUS_SPACE_IO)
181 return (inw(handle + offset));
182 return (readw(handle + offset));
185 static __inline u_int32_t
186 bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
190 if (tag == MIPS_BUS_SPACE_IO)
191 return (inl(handle + offset));
192 return (readl(handle + offset));
195 #if 0 /* Cause a link error for bus_space_read_8 */
196 #define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
200 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
201 * described by tag/handle/offset and copy into buffer provided.
203 static __inline void bus_space_read_multi_1(bus_space_tag_t tag,
204 bus_space_handle_t bsh,
205 bus_size_t offset, u_int8_t *addr,
208 static __inline void bus_space_read_multi_2(bus_space_tag_t tag,
209 bus_space_handle_t bsh,
210 bus_size_t offset, u_int16_t *addr,
213 static __inline void bus_space_read_multi_4(bus_space_tag_t tag,
214 bus_space_handle_t bsh,
215 bus_size_t offset, u_int32_t *addr,
219 bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
220 bus_size_t offset, u_int8_t *addr, size_t count)
223 if (tag == MIPS_BUS_SPACE_IO)
225 *addr++ = inb(bsh + offset);
228 *addr++ = readb(bsh + offset);
232 bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
233 bus_size_t offset, u_int16_t *addr, size_t count)
235 bus_addr_t baddr = bsh + offset;
237 if (tag == MIPS_BUS_SPACE_IO)
239 *addr++ = inw(baddr);
242 *addr++ = readw(baddr);
246 bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
247 bus_size_t offset, u_int32_t *addr, size_t count)
249 bus_addr_t baddr = bsh + offset;
251 if (tag == MIPS_BUS_SPACE_IO)
253 *addr++ = inl(baddr);
256 *addr++ = readl(baddr);
259 #if 0 /* Cause a link error for bus_space_read_multi_8 */
260 #define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
264 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
265 * described by tag/handle and starting at `offset' and copy into
268 static __inline void bus_space_read_region_1(bus_space_tag_t tag,
269 bus_space_handle_t bsh,
270 bus_size_t offset, u_int8_t *addr,
273 static __inline void bus_space_read_region_2(bus_space_tag_t tag,
274 bus_space_handle_t bsh,
275 bus_size_t offset, u_int16_t *addr,
278 static __inline void bus_space_read_region_4(bus_space_tag_t tag,
279 bus_space_handle_t bsh,
280 bus_size_t offset, u_int32_t *addr,
285 bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
286 bus_size_t offset, u_int8_t *addr, size_t count)
288 bus_addr_t baddr = bsh + offset;
290 if (tag == MIPS_BUS_SPACE_IO)
292 *addr++ = inb(baddr);
297 *addr++ = readb(baddr);
303 bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
304 bus_size_t offset, u_int16_t *addr, size_t count)
306 bus_addr_t baddr = bsh + offset;
308 if (tag == MIPS_BUS_SPACE_IO)
310 *addr++ = inw(baddr);
315 *addr++ = readw(baddr);
321 bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
322 bus_size_t offset, u_int32_t *addr, size_t count)
324 bus_addr_t baddr = bsh + offset;
326 if (tag == MIPS_BUS_SPACE_IO)
328 *addr++ = inl(baddr);
333 *addr++ = readb(baddr);
338 #if 0 /* Cause a link error for bus_space_read_region_8 */
339 #define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
343 * Write the 1, 2, 4, or 8 byte value `value' to bus space
344 * described by tag/handle/offset.
347 static __inline void bus_space_write_1(bus_space_tag_t tag,
348 bus_space_handle_t bsh,
349 bus_size_t offset, u_int8_t value);
351 static __inline void bus_space_write_2(bus_space_tag_t tag,
352 bus_space_handle_t bsh,
353 bus_size_t offset, u_int16_t value);
355 static __inline void bus_space_write_4(bus_space_tag_t tag,
356 bus_space_handle_t bsh,
357 bus_size_t offset, u_int32_t value);
360 bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
361 bus_size_t offset, u_int8_t value)
364 if (tag == MIPS_BUS_SPACE_IO)
365 outb(bsh + offset, value);
367 writeb(bsh + offset, value);
371 bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t bsh,
372 bus_size_t offset, u_int16_t value)
375 if (tag == MIPS_BUS_SPACE_IO)
376 outw(bsh + offset, value);
378 writew(bsh + offset, value);
382 bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh,
383 bus_size_t offset, u_int32_t value)
386 if (tag == MIPS_BUS_SPACE_IO)
387 outl(bsh + offset, value);
389 writel(bsh + offset, value);
392 #if 0 /* Cause a link error for bus_space_write_8 */
393 #define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
397 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
398 * provided to bus space described by tag/handle/offset.
401 static __inline void bus_space_write_multi_1(bus_space_tag_t tag,
402 bus_space_handle_t bsh,
404 const u_int8_t *addr,
406 static __inline void bus_space_write_multi_2(bus_space_tag_t tag,
407 bus_space_handle_t bsh,
409 const u_int16_t *addr,
412 static __inline void bus_space_write_multi_4(bus_space_tag_t tag,
413 bus_space_handle_t bsh,
415 const u_int32_t *addr,
419 bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
420 bus_size_t offset, const u_int8_t *addr, size_t count)
422 bus_addr_t baddr = bsh + offset;
424 if (tag == MIPS_BUS_SPACE_IO)
426 outb(baddr, *addr++);
429 writeb(baddr, *addr++);
433 bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
434 bus_size_t offset, const u_int16_t *addr, size_t count)
436 bus_addr_t baddr = bsh + offset;
438 if (tag == MIPS_BUS_SPACE_IO)
440 outw(baddr, *addr++);
443 writew(baddr, *addr++);
447 bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
448 bus_size_t offset, const u_int32_t *addr, size_t count)
450 bus_addr_t baddr = bsh + offset;
452 if (tag == MIPS_BUS_SPACE_IO)
454 outl(baddr, *addr++);
457 writel(baddr, *addr++);
460 #if 0 /* Cause a link error for bus_space_write_multi_8 */
461 #define bus_space_write_multi_8(t, h, o, a, c) \
462 !!! bus_space_write_multi_8 unimplemented !!!
466 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
467 * to bus space described by tag/handle starting at `offset'.
470 static __inline void bus_space_write_region_1(bus_space_tag_t tag,
471 bus_space_handle_t bsh,
473 const u_int8_t *addr,
475 static __inline void bus_space_write_region_2(bus_space_tag_t tag,
476 bus_space_handle_t bsh,
478 const u_int16_t *addr,
480 static __inline void bus_space_write_region_4(bus_space_tag_t tag,
481 bus_space_handle_t bsh,
483 const u_int32_t *addr,
487 bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
488 bus_size_t offset, const u_int8_t *addr, size_t count)
490 bus_addr_t baddr = bsh + offset;
492 if (tag == MIPS_BUS_SPACE_IO)
494 outb(baddr, *addr++);
499 writeb(baddr, *addr++);
505 bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
506 bus_size_t offset, const u_int16_t *addr, size_t count)
508 bus_addr_t baddr = bsh + offset;
510 if (tag == MIPS_BUS_SPACE_IO)
512 outw(baddr, *addr++);
517 writew(baddr, *addr++);
523 bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
524 bus_size_t offset, const u_int32_t *addr, size_t count)
526 bus_addr_t baddr = bsh + offset;
528 if (tag == MIPS_BUS_SPACE_IO)
530 outl(baddr, *addr++);
535 writel(baddr, *addr++);
540 #if 0 /* Cause a link error for bus_space_write_region_8 */
541 #define bus_space_write_region_8 \
542 !!! bus_space_write_region_8 unimplemented !!!
546 * Write the 1, 2, 4, or 8 byte value `val' to bus space described
547 * by tag/handle/offset `count' times.
550 static __inline void bus_space_set_multi_1(bus_space_tag_t tag,
551 bus_space_handle_t bsh,
553 u_int8_t value, size_t count);
554 static __inline void bus_space_set_multi_2(bus_space_tag_t tag,
555 bus_space_handle_t bsh,
557 u_int16_t value, size_t count);
558 static __inline void bus_space_set_multi_4(bus_space_tag_t tag,
559 bus_space_handle_t bsh,
561 u_int32_t value, size_t count);
564 bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
565 bus_size_t offset, u_int8_t value, size_t count)
567 bus_addr_t addr = bsh + offset;
569 if (tag == MIPS_BUS_SPACE_IO)
578 bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
579 bus_size_t offset, u_int16_t value, size_t count)
581 bus_addr_t addr = bsh + offset;
583 if (tag == MIPS_BUS_SPACE_IO)
592 bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
593 bus_size_t offset, u_int32_t value, size_t count)
595 bus_addr_t addr = bsh + offset;
597 if (tag == MIPS_BUS_SPACE_IO)
605 #if 0 /* Cause a link error for bus_space_set_multi_8 */
606 #define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!!
610 * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
611 * by tag/handle starting at `offset'.
614 static __inline void bus_space_set_region_1(bus_space_tag_t tag,
615 bus_space_handle_t bsh,
616 bus_size_t offset, u_int8_t value,
618 static __inline void bus_space_set_region_2(bus_space_tag_t tag,
619 bus_space_handle_t bsh,
620 bus_size_t offset, u_int16_t value,
622 static __inline void bus_space_set_region_4(bus_space_tag_t tag,
623 bus_space_handle_t bsh,
624 bus_size_t offset, u_int32_t value,
628 bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
629 bus_size_t offset, u_int8_t value, size_t count)
631 bus_addr_t addr = bsh + offset;
633 if (tag == MIPS_BUS_SPACE_IO)
634 for (; count != 0; count--, addr++)
637 for (; count != 0; count--, addr++)
642 bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
643 bus_size_t offset, u_int16_t value, size_t count)
645 bus_addr_t addr = bsh + offset;
647 if (tag == MIPS_BUS_SPACE_IO)
648 for (; count != 0; count--, addr += 2)
651 for (; count != 0; count--, addr += 2)
656 bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
657 bus_size_t offset, u_int32_t value, size_t count)
659 bus_addr_t addr = bsh + offset;
661 if (tag == MIPS_BUS_SPACE_IO)
662 for (; count != 0; count--, addr += 4)
665 for (; count != 0; count--, addr += 4)
669 #if 0 /* Cause a link error for bus_space_set_region_8 */
670 #define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!!
674 * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
675 * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
678 static __inline void bus_space_copy_region_1(bus_space_tag_t tag,
679 bus_space_handle_t bsh1,
681 bus_space_handle_t bsh2,
682 bus_size_t off2, size_t count);
684 static __inline void bus_space_copy_region_2(bus_space_tag_t tag,
685 bus_space_handle_t bsh1,
687 bus_space_handle_t bsh2,
688 bus_size_t off2, size_t count);
690 static __inline void bus_space_copy_region_4(bus_space_tag_t tag,
691 bus_space_handle_t bsh1,
693 bus_space_handle_t bsh2,
694 bus_size_t off2, size_t count);
697 bus_space_copy_region_1(bus_space_tag_t tag, bus_space_handle_t bsh1,
698 bus_size_t off1, bus_space_handle_t bsh2,
699 bus_size_t off2, size_t count)
701 bus_addr_t addr1 = bsh1 + off1;
702 bus_addr_t addr2 = bsh2 + off2;
704 if (tag == MIPS_BUS_SPACE_IO)
706 if (addr1 >= addr2) {
707 /* src after dest: copy forward */
708 for (; count != 0; count--, addr1++, addr2++)
709 outb(addr2, inb(addr1));
711 /* dest after src: copy backwards */
712 for (addr1 += (count - 1), addr2 += (count - 1);
713 count != 0; count--, addr1--, addr2--)
714 outb(addr2, inb(addr1));
717 if (addr1 >= addr2) {
718 /* src after dest: copy forward */
719 for (; count != 0; count--, addr1++, addr2++)
720 writeb(addr2, readb(addr1));
722 /* dest after src: copy backwards */
723 for (addr1 += (count - 1), addr2 += (count - 1);
724 count != 0; count--, addr1--, addr2--)
725 writeb(addr2, readb(addr1));
731 bus_space_copy_region_2(bus_space_tag_t tag, bus_space_handle_t bsh1,
732 bus_size_t off1, bus_space_handle_t bsh2,
733 bus_size_t off2, size_t count)
735 bus_addr_t addr1 = bsh1 + off1;
736 bus_addr_t addr2 = bsh2 + off2;
738 if (tag == MIPS_BUS_SPACE_IO)
740 if (addr1 >= addr2) {
741 /* src after dest: copy forward */
742 for (; count != 0; count--, addr1 += 2, addr2 += 2)
743 outw(addr2, inw(addr1));
745 /* dest after src: copy backwards */
746 for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
747 count != 0; count--, addr1 -= 2, addr2 -= 2)
748 outw(addr2, inw(addr1));
751 if (addr1 >= addr2) {
752 /* src after dest: copy forward */
753 for (; count != 0; count--, addr1 += 2, addr2 += 2)
754 writew(addr2, readw(addr1));
756 /* dest after src: copy backwards */
757 for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
758 count != 0; count--, addr1 -= 2, addr2 -= 2)
759 writew(addr2, readw(addr1));
765 bus_space_copy_region_4(bus_space_tag_t tag, bus_space_handle_t bsh1,
766 bus_size_t off1, bus_space_handle_t bsh2,
767 bus_size_t off2, size_t count)
769 bus_addr_t addr1 = bsh1 + off1;
770 bus_addr_t addr2 = bsh2 + off2;
772 if (tag == MIPS_BUS_SPACE_IO)
774 if (addr1 >= addr2) {
775 /* src after dest: copy forward */
776 for (; count != 0; count--, addr1 += 4, addr2 += 4)
777 outl(addr2, inl(addr1));
779 /* dest after src: copy backwards */
780 for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
781 count != 0; count--, addr1 -= 4, addr2 -= 4)
782 outl(addr2, inl(addr1));
785 if (addr1 >= addr2) {
786 /* src after dest: copy forward */
787 for (; count != 0; count--, addr1 += 4, addr2 += 4)
788 writel(addr2, readl(addr1));
790 /* dest after src: copy backwards */
791 for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
792 count != 0; count--, addr1 -= 4, addr2 -= 4)
793 writel(addr2, readl(addr1));
799 #if 0 /* Cause a link error for bus_space_copy_8 */
800 #define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!!
805 * Bus read/write barrier methods.
807 * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
808 * bus_size_t offset, bus_size_t len, int flags);
811 * Note that BUS_SPACE_BARRIER_WRITE doesn't do anything other than
812 * prevent reordering by the compiler; all Intel x86 processors currently
813 * retire operations outside the CPU in program order.
815 #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
816 #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
819 bus_space_barrier(bus_space_tag_t tag __unused, bus_space_handle_t bsh __unused,
820 bus_size_t offset __unused, bus_size_t len __unused, int flags)
823 #ifdef __GNUCLIKE_ASM
824 if (flags & BUS_SPACE_BARRIER_READ)
825 __asm __volatile("lock; addl $0,0(%%rsp)" : : : "memory");
827 __asm __volatile("" : : : "memory");
832 #ifdef BUS_SPACE_NO_LEGACY
835 #define inb(a) compiler_error
836 #define inw(a) compiler_error
837 #define inl(a) compiler_error
838 #define outb(a, b) compiler_error
839 #define outw(a, b) compiler_error
840 #define outl(a, b) compiler_error
843 #include <machine/bus_dma.h>
846 * Stream accesses are the same as normal accesses on amd64; there are no
847 * supported bus systems with an endianess different from the host one.
849 #define bus_space_read_stream_1(t, h, o) bus_space_read_1((t), (h), (o))
850 #define bus_space_read_stream_2(t, h, o) bus_space_read_2((t), (h), (o))
851 #define bus_space_read_stream_4(t, h, o) bus_space_read_4((t), (h), (o))
853 #define bus_space_read_multi_stream_1(t, h, o, a, c) \
854 bus_space_read_multi_1((t), (h), (o), (a), (c))
855 #define bus_space_read_multi_stream_2(t, h, o, a, c) \
856 bus_space_read_multi_2((t), (h), (o), (a), (c))
857 #define bus_space_read_multi_stream_4(t, h, o, a, c) \
858 bus_space_read_multi_4((t), (h), (o), (a), (c))
860 #define bus_space_write_stream_1(t, h, o, v) \
861 bus_space_write_1((t), (h), (o), (v))
862 #define bus_space_write_stream_2(t, h, o, v) \
863 bus_space_write_2((t), (h), (o), (v))
864 #define bus_space_write_stream_4(t, h, o, v) \
865 bus_space_write_4((t), (h), (o), (v))
867 #define bus_space_write_multi_stream_1(t, h, o, a, c) \
868 bus_space_write_multi_1((t), (h), (o), (a), (c))
869 #define bus_space_write_multi_stream_2(t, h, o, a, c) \
870 bus_space_write_multi_2((t), (h), (o), (a), (c))
871 #define bus_space_write_multi_stream_4(t, h, o, a, c) \
872 bus_space_write_multi_4((t), (h), (o), (a), (c))
874 #define bus_space_set_multi_stream_1(t, h, o, v, c) \
875 bus_space_set_multi_1((t), (h), (o), (v), (c))
876 #define bus_space_set_multi_stream_2(t, h, o, v, c) \
877 bus_space_set_multi_2((t), (h), (o), (v), (c))
878 #define bus_space_set_multi_stream_4(t, h, o, v, c) \
879 bus_space_set_multi_4((t), (h), (o), (v), (c))
881 #define bus_space_read_region_stream_1(t, h, o, a, c) \
882 bus_space_read_region_1((t), (h), (o), (a), (c))
883 #define bus_space_read_region_stream_2(t, h, o, a, c) \
884 bus_space_read_region_2((t), (h), (o), (a), (c))
885 #define bus_space_read_region_stream_4(t, h, o, a, c) \
886 bus_space_read_region_4((t), (h), (o), (a), (c))
888 #define bus_space_write_region_stream_1(t, h, o, a, c) \
889 bus_space_write_region_1((t), (h), (o), (a), (c))
890 #define bus_space_write_region_stream_2(t, h, o, a, c) \
891 bus_space_write_region_2((t), (h), (o), (a), (c))
892 #define bus_space_write_region_stream_4(t, h, o, a, c) \
893 bus_space_write_region_4((t), (h), (o), (a), (c))
895 #define bus_space_set_region_stream_1(t, h, o, v, c) \
896 bus_space_set_region_1((t), (h), (o), (v), (c))
897 #define bus_space_set_region_stream_2(t, h, o, v, c) \
898 bus_space_set_region_2((t), (h), (o), (v), (c))
899 #define bus_space_set_region_stream_4(t, h, o, v, c) \
900 bus_space_set_region_4((t), (h), (o), (v), (c))
902 #define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c) \
903 bus_space_copy_region_1((t), (h1), (o1), (h2), (o2), (c))
904 #define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
905 bus_space_copy_region_2((t), (h1), (o1), (h2), (o2), (c))
906 #define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
907 bus_space_copy_region_4((t), (h1), (o1), (h2), (o2), (c))
909 #endif /* !TARGET_OCTEON */
910 #endif /* !_MACHINE_BUS_H_ */