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 __inline int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
105 bus_size_t size, int flags, bus_space_handle_t *bshp);
108 bus_space_map(bus_space_tag_t t __unused, bus_addr_t addr,
109 bus_size_t size __unused, int flags __unused,
110 bus_space_handle_t *bshp)
118 * Unmap a region of device bus space.
121 void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
125 * Get a new handle for a subregion of an already-mapped area of bus space.
128 int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
129 bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp);
132 * Allocate a region of memory that is accessible to devices in bus space.
135 int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart,
136 bus_addr_t rend, bus_size_t size, bus_size_t align,
137 bus_size_t boundary, int flags, bus_addr_t *addrp,
138 bus_space_handle_t *bshp);
141 * Free a region of bus space accessible memory.
144 void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
149 * Read a 1, 2, 4, or 8 byte quantity from bus space
150 * described by tag/handle/offset.
152 static __inline u_int8_t bus_space_read_1(bus_space_tag_t tag,
153 bus_space_handle_t handle,
156 static __inline u_int16_t bus_space_read_2(bus_space_tag_t tag,
157 bus_space_handle_t handle,
160 static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag,
161 bus_space_handle_t handle,
164 static __inline u_int8_t
165 bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
169 if (tag == MIPS_BUS_SPACE_IO)
170 return (inb(handle + offset));
171 return (readb(handle + offset));
174 static __inline u_int16_t
175 bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle,
179 if (tag == MIPS_BUS_SPACE_IO)
180 return (inw(handle + offset));
181 return (readw(handle + offset));
184 static __inline u_int32_t
185 bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
189 if (tag == MIPS_BUS_SPACE_IO)
190 return (inl(handle + offset));
191 return (readl(handle + offset));
194 #if 0 /* Cause a link error for bus_space_read_8 */
195 #define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
199 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
200 * described by tag/handle/offset and copy into buffer provided.
202 static __inline void bus_space_read_multi_1(bus_space_tag_t tag,
203 bus_space_handle_t bsh,
204 bus_size_t offset, u_int8_t *addr,
207 static __inline void bus_space_read_multi_2(bus_space_tag_t tag,
208 bus_space_handle_t bsh,
209 bus_size_t offset, u_int16_t *addr,
212 static __inline void bus_space_read_multi_4(bus_space_tag_t tag,
213 bus_space_handle_t bsh,
214 bus_size_t offset, u_int32_t *addr,
218 bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
219 bus_size_t offset, u_int8_t *addr, size_t count)
222 if (tag == MIPS_BUS_SPACE_IO)
224 *addr++ = inb(bsh + offset);
227 *addr++ = readb(bsh + offset);
231 bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
232 bus_size_t offset, u_int16_t *addr, size_t count)
234 bus_addr_t baddr = bsh + offset;
236 if (tag == MIPS_BUS_SPACE_IO)
238 *addr++ = inw(baddr);
241 *addr++ = readw(baddr);
245 bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
246 bus_size_t offset, u_int32_t *addr, size_t count)
248 bus_addr_t baddr = bsh + offset;
250 if (tag == MIPS_BUS_SPACE_IO)
252 *addr++ = inl(baddr);
255 *addr++ = readl(baddr);
258 #if 0 /* Cause a link error for bus_space_read_multi_8 */
259 #define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
263 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
264 * described by tag/handle and starting at `offset' and copy into
267 static __inline void bus_space_read_region_1(bus_space_tag_t tag,
268 bus_space_handle_t bsh,
269 bus_size_t offset, u_int8_t *addr,
272 static __inline void bus_space_read_region_2(bus_space_tag_t tag,
273 bus_space_handle_t bsh,
274 bus_size_t offset, u_int16_t *addr,
277 static __inline void bus_space_read_region_4(bus_space_tag_t tag,
278 bus_space_handle_t bsh,
279 bus_size_t offset, u_int32_t *addr,
284 bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
285 bus_size_t offset, u_int8_t *addr, size_t count)
287 bus_addr_t baddr = bsh + offset;
289 if (tag == MIPS_BUS_SPACE_IO)
291 *addr++ = inb(baddr);
296 *addr++ = readb(baddr);
302 bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
303 bus_size_t offset, u_int16_t *addr, size_t count)
305 bus_addr_t baddr = bsh + offset;
307 if (tag == MIPS_BUS_SPACE_IO)
309 *addr++ = inw(baddr);
314 *addr++ = readw(baddr);
320 bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
321 bus_size_t offset, u_int32_t *addr, size_t count)
323 bus_addr_t baddr = bsh + offset;
325 if (tag == MIPS_BUS_SPACE_IO)
327 *addr++ = inl(baddr);
332 *addr++ = readb(baddr);
337 #if 0 /* Cause a link error for bus_space_read_region_8 */
338 #define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
342 * Write the 1, 2, 4, or 8 byte value `value' to bus space
343 * described by tag/handle/offset.
346 static __inline void bus_space_write_1(bus_space_tag_t tag,
347 bus_space_handle_t bsh,
348 bus_size_t offset, u_int8_t value);
350 static __inline void bus_space_write_2(bus_space_tag_t tag,
351 bus_space_handle_t bsh,
352 bus_size_t offset, u_int16_t value);
354 static __inline void bus_space_write_4(bus_space_tag_t tag,
355 bus_space_handle_t bsh,
356 bus_size_t offset, u_int32_t value);
359 bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
360 bus_size_t offset, u_int8_t value)
363 if (tag == MIPS_BUS_SPACE_IO)
364 outb(bsh + offset, value);
366 writeb(bsh + offset, value);
370 bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t bsh,
371 bus_size_t offset, u_int16_t value)
374 if (tag == MIPS_BUS_SPACE_IO)
375 outw(bsh + offset, value);
377 writew(bsh + offset, value);
381 bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh,
382 bus_size_t offset, u_int32_t value)
385 if (tag == MIPS_BUS_SPACE_IO)
386 outl(bsh + offset, value);
388 writel(bsh + offset, value);
391 #if 0 /* Cause a link error for bus_space_write_8 */
392 #define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
396 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
397 * provided to bus space described by tag/handle/offset.
400 static __inline void bus_space_write_multi_1(bus_space_tag_t tag,
401 bus_space_handle_t bsh,
403 const u_int8_t *addr,
405 static __inline void bus_space_write_multi_2(bus_space_tag_t tag,
406 bus_space_handle_t bsh,
408 const u_int16_t *addr,
411 static __inline void bus_space_write_multi_4(bus_space_tag_t tag,
412 bus_space_handle_t bsh,
414 const u_int32_t *addr,
418 bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
419 bus_size_t offset, const u_int8_t *addr, size_t count)
421 bus_addr_t baddr = bsh + offset;
423 if (tag == MIPS_BUS_SPACE_IO)
425 outb(baddr, *addr++);
428 writeb(baddr, *addr++);
432 bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
433 bus_size_t offset, const u_int16_t *addr, size_t count)
435 bus_addr_t baddr = bsh + offset;
437 if (tag == MIPS_BUS_SPACE_IO)
439 outw(baddr, *addr++);
442 writew(baddr, *addr++);
446 bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
447 bus_size_t offset, const u_int32_t *addr, size_t count)
449 bus_addr_t baddr = bsh + offset;
451 if (tag == MIPS_BUS_SPACE_IO)
453 outl(baddr, *addr++);
456 writel(baddr, *addr++);
459 #if 0 /* Cause a link error for bus_space_write_multi_8 */
460 #define bus_space_write_multi_8(t, h, o, a, c) \
461 !!! bus_space_write_multi_8 unimplemented !!!
465 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
466 * to bus space described by tag/handle starting at `offset'.
469 static __inline void bus_space_write_region_1(bus_space_tag_t tag,
470 bus_space_handle_t bsh,
472 const u_int8_t *addr,
474 static __inline void bus_space_write_region_2(bus_space_tag_t tag,
475 bus_space_handle_t bsh,
477 const u_int16_t *addr,
479 static __inline void bus_space_write_region_4(bus_space_tag_t tag,
480 bus_space_handle_t bsh,
482 const u_int32_t *addr,
486 bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
487 bus_size_t offset, const u_int8_t *addr, size_t count)
489 bus_addr_t baddr = bsh + offset;
491 if (tag == MIPS_BUS_SPACE_IO)
493 outb(baddr, *addr++);
498 writeb(baddr, *addr++);
504 bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
505 bus_size_t offset, const u_int16_t *addr, size_t count)
507 bus_addr_t baddr = bsh + offset;
509 if (tag == MIPS_BUS_SPACE_IO)
511 outw(baddr, *addr++);
516 writew(baddr, *addr++);
522 bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
523 bus_size_t offset, const u_int32_t *addr, size_t count)
525 bus_addr_t baddr = bsh + offset;
527 if (tag == MIPS_BUS_SPACE_IO)
529 outl(baddr, *addr++);
534 writel(baddr, *addr++);
539 #if 0 /* Cause a link error for bus_space_write_region_8 */
540 #define bus_space_write_region_8 \
541 !!! bus_space_write_region_8 unimplemented !!!
545 * Write the 1, 2, 4, or 8 byte value `val' to bus space described
546 * by tag/handle/offset `count' times.
549 static __inline void bus_space_set_multi_1(bus_space_tag_t tag,
550 bus_space_handle_t bsh,
552 u_int8_t value, size_t count);
553 static __inline void bus_space_set_multi_2(bus_space_tag_t tag,
554 bus_space_handle_t bsh,
556 u_int16_t value, size_t count);
557 static __inline void bus_space_set_multi_4(bus_space_tag_t tag,
558 bus_space_handle_t bsh,
560 u_int32_t value, size_t count);
563 bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
564 bus_size_t offset, u_int8_t value, size_t count)
566 bus_addr_t addr = bsh + offset;
568 if (tag == MIPS_BUS_SPACE_IO)
577 bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
578 bus_size_t offset, u_int16_t value, size_t count)
580 bus_addr_t addr = bsh + offset;
582 if (tag == MIPS_BUS_SPACE_IO)
591 bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
592 bus_size_t offset, u_int32_t value, size_t count)
594 bus_addr_t addr = bsh + offset;
596 if (tag == MIPS_BUS_SPACE_IO)
604 #if 0 /* Cause a link error for bus_space_set_multi_8 */
605 #define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!!
609 * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
610 * by tag/handle starting at `offset'.
613 static __inline void bus_space_set_region_1(bus_space_tag_t tag,
614 bus_space_handle_t bsh,
615 bus_size_t offset, u_int8_t value,
617 static __inline void bus_space_set_region_2(bus_space_tag_t tag,
618 bus_space_handle_t bsh,
619 bus_size_t offset, u_int16_t value,
621 static __inline void bus_space_set_region_4(bus_space_tag_t tag,
622 bus_space_handle_t bsh,
623 bus_size_t offset, u_int32_t value,
627 bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
628 bus_size_t offset, u_int8_t value, size_t count)
630 bus_addr_t addr = bsh + offset;
632 if (tag == MIPS_BUS_SPACE_IO)
633 for (; count != 0; count--, addr++)
636 for (; count != 0; count--, addr++)
641 bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
642 bus_size_t offset, u_int16_t value, size_t count)
644 bus_addr_t addr = bsh + offset;
646 if (tag == MIPS_BUS_SPACE_IO)
647 for (; count != 0; count--, addr += 2)
650 for (; count != 0; count--, addr += 2)
655 bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
656 bus_size_t offset, u_int32_t value, size_t count)
658 bus_addr_t addr = bsh + offset;
660 if (tag == MIPS_BUS_SPACE_IO)
661 for (; count != 0; count--, addr += 4)
664 for (; count != 0; count--, addr += 4)
668 #if 0 /* Cause a link error for bus_space_set_region_8 */
669 #define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!!
673 * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
674 * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
677 static __inline void bus_space_copy_region_1(bus_space_tag_t tag,
678 bus_space_handle_t bsh1,
680 bus_space_handle_t bsh2,
681 bus_size_t off2, size_t count);
683 static __inline void bus_space_copy_region_2(bus_space_tag_t tag,
684 bus_space_handle_t bsh1,
686 bus_space_handle_t bsh2,
687 bus_size_t off2, size_t count);
689 static __inline void bus_space_copy_region_4(bus_space_tag_t tag,
690 bus_space_handle_t bsh1,
692 bus_space_handle_t bsh2,
693 bus_size_t off2, size_t count);
696 bus_space_copy_region_1(bus_space_tag_t tag, bus_space_handle_t bsh1,
697 bus_size_t off1, bus_space_handle_t bsh2,
698 bus_size_t off2, size_t count)
700 bus_addr_t addr1 = bsh1 + off1;
701 bus_addr_t addr2 = bsh2 + off2;
703 if (tag == MIPS_BUS_SPACE_IO)
705 if (addr1 >= addr2) {
706 /* src after dest: copy forward */
707 for (; count != 0; count--, addr1++, addr2++)
708 outb(addr2, inb(addr1));
710 /* dest after src: copy backwards */
711 for (addr1 += (count - 1), addr2 += (count - 1);
712 count != 0; count--, addr1--, addr2--)
713 outb(addr2, inb(addr1));
716 if (addr1 >= addr2) {
717 /* src after dest: copy forward */
718 for (; count != 0; count--, addr1++, addr2++)
719 writeb(addr2, readb(addr1));
721 /* dest after src: copy backwards */
722 for (addr1 += (count - 1), addr2 += (count - 1);
723 count != 0; count--, addr1--, addr2--)
724 writeb(addr2, readb(addr1));
730 bus_space_copy_region_2(bus_space_tag_t tag, bus_space_handle_t bsh1,
731 bus_size_t off1, bus_space_handle_t bsh2,
732 bus_size_t off2, size_t count)
734 bus_addr_t addr1 = bsh1 + off1;
735 bus_addr_t addr2 = bsh2 + off2;
737 if (tag == MIPS_BUS_SPACE_IO)
739 if (addr1 >= addr2) {
740 /* src after dest: copy forward */
741 for (; count != 0; count--, addr1 += 2, addr2 += 2)
742 outw(addr2, inw(addr1));
744 /* dest after src: copy backwards */
745 for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
746 count != 0; count--, addr1 -= 2, addr2 -= 2)
747 outw(addr2, inw(addr1));
750 if (addr1 >= addr2) {
751 /* src after dest: copy forward */
752 for (; count != 0; count--, addr1 += 2, addr2 += 2)
753 writew(addr2, readw(addr1));
755 /* dest after src: copy backwards */
756 for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
757 count != 0; count--, addr1 -= 2, addr2 -= 2)
758 writew(addr2, readw(addr1));
764 bus_space_copy_region_4(bus_space_tag_t tag, bus_space_handle_t bsh1,
765 bus_size_t off1, bus_space_handle_t bsh2,
766 bus_size_t off2, size_t count)
768 bus_addr_t addr1 = bsh1 + off1;
769 bus_addr_t addr2 = bsh2 + off2;
771 if (tag == MIPS_BUS_SPACE_IO)
773 if (addr1 >= addr2) {
774 /* src after dest: copy forward */
775 for (; count != 0; count--, addr1 += 4, addr2 += 4)
776 outl(addr2, inl(addr1));
778 /* dest after src: copy backwards */
779 for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
780 count != 0; count--, addr1 -= 4, addr2 -= 4)
781 outl(addr2, inl(addr1));
784 if (addr1 >= addr2) {
785 /* src after dest: copy forward */
786 for (; count != 0; count--, addr1 += 4, addr2 += 4)
787 writel(addr2, readl(addr1));
789 /* dest after src: copy backwards */
790 for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
791 count != 0; count--, addr1 -= 4, addr2 -= 4)
792 writel(addr2, readl(addr1));
798 #if 0 /* Cause a link error for bus_space_copy_8 */
799 #define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!!
804 * Bus read/write barrier methods.
806 * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
807 * bus_size_t offset, bus_size_t len, int flags);
810 * Note that BUS_SPACE_BARRIER_WRITE doesn't do anything other than
811 * prevent reordering by the compiler; all Intel x86 processors currently
812 * retire operations outside the CPU in program order.
814 #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
815 #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
818 bus_space_barrier(bus_space_tag_t tag __unused, bus_space_handle_t bsh __unused,
819 bus_size_t offset __unused, bus_size_t len __unused, int flags)
822 #ifdef __GNUCLIKE_ASM
823 if (flags & BUS_SPACE_BARRIER_READ)
824 __asm __volatile("lock; addl $0,0(%%rsp)" : : : "memory");
826 __asm __volatile("" : : : "memory");
831 #ifdef BUS_SPACE_NO_LEGACY
834 #define inb(a) compiler_error
835 #define inw(a) compiler_error
836 #define inl(a) compiler_error
837 #define outb(a, b) compiler_error
838 #define outw(a, b) compiler_error
839 #define outl(a, b) compiler_error
842 #include <machine/bus_dma.h>
845 * Stream accesses are the same as normal accesses on amd64; there are no
846 * supported bus systems with an endianess different from the host one.
848 #define bus_space_read_stream_1(t, h, o) bus_space_read_1((t), (h), (o))
849 #define bus_space_read_stream_2(t, h, o) bus_space_read_2((t), (h), (o))
850 #define bus_space_read_stream_4(t, h, o) bus_space_read_4((t), (h), (o))
852 #define bus_space_read_multi_stream_1(t, h, o, a, c) \
853 bus_space_read_multi_1((t), (h), (o), (a), (c))
854 #define bus_space_read_multi_stream_2(t, h, o, a, c) \
855 bus_space_read_multi_2((t), (h), (o), (a), (c))
856 #define bus_space_read_multi_stream_4(t, h, o, a, c) \
857 bus_space_read_multi_4((t), (h), (o), (a), (c))
859 #define bus_space_write_stream_1(t, h, o, v) \
860 bus_space_write_1((t), (h), (o), (v))
861 #define bus_space_write_stream_2(t, h, o, v) \
862 bus_space_write_2((t), (h), (o), (v))
863 #define bus_space_write_stream_4(t, h, o, v) \
864 bus_space_write_4((t), (h), (o), (v))
866 #define bus_space_write_multi_stream_1(t, h, o, a, c) \
867 bus_space_write_multi_1((t), (h), (o), (a), (c))
868 #define bus_space_write_multi_stream_2(t, h, o, a, c) \
869 bus_space_write_multi_2((t), (h), (o), (a), (c))
870 #define bus_space_write_multi_stream_4(t, h, o, a, c) \
871 bus_space_write_multi_4((t), (h), (o), (a), (c))
873 #define bus_space_set_multi_stream_1(t, h, o, v, c) \
874 bus_space_set_multi_1((t), (h), (o), (v), (c))
875 #define bus_space_set_multi_stream_2(t, h, o, v, c) \
876 bus_space_set_multi_2((t), (h), (o), (v), (c))
877 #define bus_space_set_multi_stream_4(t, h, o, v, c) \
878 bus_space_set_multi_4((t), (h), (o), (v), (c))
880 #define bus_space_read_region_stream_1(t, h, o, a, c) \
881 bus_space_read_region_1((t), (h), (o), (a), (c))
882 #define bus_space_read_region_stream_2(t, h, o, a, c) \
883 bus_space_read_region_2((t), (h), (o), (a), (c))
884 #define bus_space_read_region_stream_4(t, h, o, a, c) \
885 bus_space_read_region_4((t), (h), (o), (a), (c))
887 #define bus_space_write_region_stream_1(t, h, o, a, c) \
888 bus_space_write_region_1((t), (h), (o), (a), (c))
889 #define bus_space_write_region_stream_2(t, h, o, a, c) \
890 bus_space_write_region_2((t), (h), (o), (a), (c))
891 #define bus_space_write_region_stream_4(t, h, o, a, c) \
892 bus_space_write_region_4((t), (h), (o), (a), (c))
894 #define bus_space_set_region_stream_1(t, h, o, v, c) \
895 bus_space_set_region_1((t), (h), (o), (v), (c))
896 #define bus_space_set_region_stream_2(t, h, o, v, c) \
897 bus_space_set_region_2((t), (h), (o), (v), (c))
898 #define bus_space_set_region_stream_4(t, h, o, v, c) \
899 bus_space_set_region_4((t), (h), (o), (v), (c))
901 #define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c) \
902 bus_space_copy_region_1((t), (h1), (o1), (h2), (o2), (c))
903 #define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
904 bus_space_copy_region_2((t), (h1), (o1), (h2), (o2), (c))
905 #define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
906 bus_space_copy_region_4((t), (h1), (o1), (h2), (o2), (c))
908 #endif /* !TARGET_OCTEON */
909 #endif /* !_MACHINE_BUS_H_ */