2 * Copyright (c) 2006 Oleksandr Tymoshenko.
3 * Copyright (c) KATO Takenori, 1999.
5 * All rights reserved. Unpublished rights reserved under the copyright
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer as
14 * the first lines of this file unmodified.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 /* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */
38 * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
39 * All rights reserved.
41 * This code is derived from software contributed to The NetBSD Foundation
42 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
43 * NASA Ames Research Center.
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 the NetBSD
56 * Foundation, Inc. and its contributors.
57 * 4. Neither the name of The NetBSD Foundation nor the names of its
58 * contributors may be used to endorse or promote products derived
59 * from this software without specific prior written permission.
61 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
62 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
63 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
64 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
65 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
66 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
67 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
68 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
69 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
70 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
71 * POSSIBILITY OF SUCH DAMAGE.
75 * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
76 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
78 * Redistribution and use in source and binary forms, with or without
79 * modification, are permitted provided that the following conditions
81 * 1. Redistributions of source code must retain the above copyright
82 * notice, this list of conditions and the following disclaimer.
83 * 2. Redistributions in binary form must reproduce the above copyright
84 * notice, this list of conditions and the following disclaimer in the
85 * documentation and/or other materials provided with the distribution.
86 * 3. All advertising materials mentioning features or use of this software
87 * must display the following acknowledgement:
88 * This product includes software developed by Christopher G. Demetriou
89 * for the NetBSD Project.
90 * 4. The name of the author may not be used to endorse or promote products
91 * derived from this software without specific prior written permission
93 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
94 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
95 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
96 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
97 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
99 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
100 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
101 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
102 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
105 #ifndef _MIPS_BUS_OCTEON_H_
106 #define _MIPS_BUS_OCTEON_H_
108 #include "../../mips32/octeon32/octeon_pcmap_regs.h"
109 #include <machine/_bus_octeon.h>
110 #include <machine/cpufunc.h>
113 * Values for the mips64 bus space tag, not to be used directly by MI code.
115 #define MIPS_BUS_SPACE_IO 0 /* space is i/o space */
116 #define MIPS_BUS_SPACE_MEM 1 /* space is mem space */
118 #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
119 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
120 #define BUS_SPACE_MAXSIZE 0xFFFFFFFF
121 #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
122 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
123 #define BUS_SPACE_MAXADDR 0xFFFFFFFF
125 #define BUS_SPACE_UNRESTRICTED (~0)
128 * Map a region of device bus space into CPU virtual address space.
131 static __inline int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
132 bus_size_t size, int flags,
133 bus_space_handle_t *bshp);
136 bus_space_map(bus_space_tag_t t __unused, bus_addr_t addr,
137 bus_size_t size __unused, int flags __unused,
138 bus_space_handle_t *bshp)
146 * Unmap a region of device bus space.
149 static __inline void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
153 bus_space_unmap(bus_space_tag_t t __unused, bus_space_handle_t bsh __unused,
154 bus_size_t size __unused)
159 * Get a new handle for a subregion of an already-mapped area of bus space.
162 static __inline int bus_space_subregion(bus_space_tag_t t,
163 bus_space_handle_t bsh,
164 bus_size_t offset, bus_size_t size,
165 bus_space_handle_t *nbshp);
168 bus_space_subregion(bus_space_tag_t t __unused, bus_space_handle_t bsh,
169 bus_size_t offset, bus_size_t size __unused,
170 bus_space_handle_t *nbshp)
172 *nbshp = bsh + offset;
177 * Allocate a region of memory that is accessible to devices in bus space.
180 int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart,
181 bus_addr_t rend, bus_size_t size, bus_size_t align,
182 bus_size_t boundary, int flags, bus_addr_t *addrp,
183 bus_space_handle_t *bshp);
186 * Free a region of bus space accessible memory.
189 static __inline void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
193 bus_space_free(bus_space_tag_t t __unused, bus_space_handle_t bsh __unused,
194 bus_size_t size __unused)
200 * Read a 1, 2, 4, or 8 byte quantity from bus space
201 * described by tag/handle/offset.
203 static __inline u_int8_t bus_space_read_1(bus_space_tag_t tag,
204 bus_space_handle_t handle,
207 static __inline u_int16_t bus_space_read_2(bus_space_tag_t tag,
208 bus_space_handle_t handle,
211 static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag,
212 bus_space_handle_t handle,
215 static __inline u_int8_t
216 bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
222 oct64_addr = handle + offset;
223 ret_val = oct_read8(oct64_addr);
224 return ((u_int8_t) ret_val);
227 static __inline u_int16_t
228 bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle,
234 oct64_addr = handle + offset;
235 ret_val = oct_read16(oct64_addr);
236 return ((u_int16_t) ret_val);
239 static __inline u_int32_t
240 bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
246 oct64_addr = handle + offset;
247 ret_val = oct_read32(oct64_addr);
248 return ((u_int32_t) ret_val);
252 static __inline u_int64_t
253 bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t handle,
259 oct64_addr = handle + offset;
260 ret_val = oct_read64(oct64_addr);
266 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
267 * described by tag/handle/offset and copy into buffer provided.
269 static __inline void bus_space_read_region_1(bus_space_tag_t tag,
270 bus_space_handle_t bsh,
271 bus_size_t offset, u_int8_t *addr,
274 static __inline void bus_space_read_region_2(bus_space_tag_t tag,
275 bus_space_handle_t bsh,
276 bus_size_t offset, u_int16_t *addr,
279 static __inline void bus_space_read_region_4(bus_space_tag_t tag,
280 bus_space_handle_t bsh,
281 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 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
290 for(; count > 0; count--, addr++, ptr++) {
291 *addr = oct_read8(ptr);
296 bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
297 bus_size_t offset, u_int16_t *addr, size_t count)
299 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
301 for(; count > 0; count--, addr++, ptr+=2) {
302 *addr = oct_read16(ptr);
307 bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
308 bus_size_t offset, u_int32_t *addr, size_t count)
310 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
312 for(; count > 0; count--, addr++, ptr+=4) {
313 *addr = oct_read32(ptr);
318 bus_space_read_region_8(bus_space_tag_t tag, bus_space_handle_t bsh,
319 bus_size_t offset, u_int64_t *addr, size_t count)
321 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
323 for(; count > 0; count--, addr++, ptr+=4) {
324 *addr = oct_read64(ptr);
329 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
330 * described by tag/handle and starting at `offset' and copy into
333 static __inline void bus_space_read_multi_1(bus_space_tag_t tag,
334 bus_space_handle_t bsh,
335 bus_size_t offset, u_int8_t *addr,
338 static __inline void bus_space_read_multi_2(bus_space_tag_t tag,
339 bus_space_handle_t bsh,
340 bus_size_t offset, u_int16_t *addr,
343 static __inline void bus_space_read_multi_4(bus_space_tag_t tag,
344 bus_space_handle_t bsh,
345 bus_size_t offset, u_int32_t *addr,
350 bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
351 bus_size_t offset, u_int8_t *addr, size_t count)
353 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
355 for(; count > 0; count--, addr++) {
356 *addr = oct_read8(ptr);
361 bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
362 bus_size_t offset, u_int16_t *addr, size_t count)
364 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
366 for(; count > 0; count--, addr++) {
367 *addr = oct_read16(ptr);
372 bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
373 bus_size_t offset, u_int32_t *addr, size_t count)
375 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
377 for(; count > 0; count--, addr++) {
378 *addr = oct_read32(ptr);
383 bus_space_read_multi_8(bus_space_tag_t tag, bus_space_handle_t bsh,
384 bus_size_t offset, u_int64_t *addr, size_t count)
386 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
388 for(; count > 0; count--, addr++) {
389 *addr = oct_read64(ptr);
395 * Write the 1, 2, 4, or 8 byte value `value' to bus space
396 * described by tag/handle/offset.
399 static __inline void bus_space_write_1(bus_space_tag_t tag,
400 bus_space_handle_t bsh,
401 bus_size_t offset, u_int8_t value);
403 static __inline void bus_space_write_2(bus_space_tag_t tag,
404 bus_space_handle_t bsh,
405 bus_size_t offset, u_int16_t value);
407 static __inline void bus_space_write_4(bus_space_tag_t tag,
408 bus_space_handle_t bsh,
409 bus_size_t offset, u_int32_t value);
412 bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
413 bus_size_t offset, u_int8_t value)
415 oct_write8(bsh+offset, value);
419 bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t bsh,
420 bus_size_t offset, u_int16_t value)
422 oct_write16(bsh+offset, value);
426 bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh,
427 bus_size_t offset, u_int32_t value)
429 oct_write32(bsh+offset, value);
433 bus_space_write_8(bus_space_tag_t tag, bus_space_handle_t bsh,
434 bus_size_t offset, u_int64_t value)
436 oct_write64(bsh+offset, value);
440 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
441 * provided to bus space described by tag/handle/offset.
444 static __inline void bus_space_write_region_1(bus_space_tag_t tag,
445 bus_space_handle_t bsh,
447 const u_int8_t *addr,
449 static __inline void bus_space_write_region_2(bus_space_tag_t tag,
450 bus_space_handle_t bsh,
452 const u_int16_t *addr,
455 static __inline void bus_space_write_region_4(bus_space_tag_t tag,
456 bus_space_handle_t bsh,
458 const u_int32_t *addr,
462 bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
463 bus_size_t offset, const u_int8_t *addr, size_t count)
465 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
467 for(; count > 0; count--, addr++, ptr++) {
468 oct_write8(ptr, *addr);
473 bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
474 bus_size_t offset, const u_int16_t *addr, size_t count)
476 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
478 for(; count > 0; count--, addr++, ptr++) {
479 oct_write16(ptr, *addr);
484 bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
485 bus_size_t offset, const u_int32_t *addr, size_t count)
487 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
489 for(; count > 0; count--, addr++, ptr++) {
490 oct_write32(ptr, *addr);
495 bus_space_write_region_8(bus_space_tag_t tag, bus_space_handle_t bsh,
496 bus_size_t offset, const u_int64_t *addr, size_t count)
498 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
500 for(; count > 0; count--, addr++, ptr++) {
501 oct_write64(ptr, *addr);
506 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
507 * to bus space described by tag/handle starting at `offset'.
510 static __inline void bus_space_write_multi_1(bus_space_tag_t tag,
511 bus_space_handle_t bsh,
513 const u_int8_t *addr,
515 static __inline void bus_space_write_multi_2(bus_space_tag_t tag,
516 bus_space_handle_t bsh,
518 const u_int16_t *addr,
520 static __inline void bus_space_write_multi_4(bus_space_tag_t tag,
521 bus_space_handle_t bsh,
523 const u_int32_t *addr,
527 bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
528 bus_size_t offset, const u_int8_t *addr, size_t count)
530 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
532 for(; count > 0; count--, addr++) {
533 oct_write8(ptr, *addr);
538 bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
539 bus_size_t offset, const u_int16_t *addr, size_t count)
541 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
543 for(; count > 0; count--, addr++) {
544 oct_write16(ptr, *addr);
549 bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
550 bus_size_t offset, const u_int32_t *addr, size_t count)
552 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
554 for(; count > 0; count--, addr++) {
555 oct_write32(ptr, *addr);
560 bus_space_write_multi_8(bus_space_tag_t tag, bus_space_handle_t bsh,
561 bus_size_t offset, const u_int64_t *addr, size_t count)
563 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
565 for(; count > 0; count--, addr++) {
566 oct_write64(ptr, *addr);
571 * Write the 1, 2, 4, or 8 byte value `val' to bus space described
572 * by tag/handle/offset `count' times.
575 static __inline void bus_space_set_multi_1(bus_space_tag_t tag,
576 bus_space_handle_t bsh,
578 u_int8_t value, size_t count);
579 static __inline void bus_space_set_multi_2(bus_space_tag_t tag,
580 bus_space_handle_t bsh,
582 u_int16_t value, size_t count);
583 static __inline void bus_space_set_multi_4(bus_space_tag_t tag,
584 bus_space_handle_t bsh,
586 u_int32_t value, size_t count);
589 bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
590 bus_size_t offset, u_int8_t value, size_t count)
592 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
594 for(; count > 0; count--) {
595 oct_write8(ptr, value);
600 bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
601 bus_size_t offset, u_int16_t value, size_t count)
603 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
605 for(; count > 0; count--) {
606 oct_write16(ptr, value);
611 bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
612 bus_size_t offset, u_int32_t value, size_t count)
614 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
616 for(; count > 0; count--) {
617 oct_write32(ptr, value);
622 bus_space_set_multi_8(bus_space_tag_t tag, bus_space_handle_t bsh,
623 bus_size_t offset, u_int64_t value, size_t count)
625 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
627 for(; count > 0; count--) {
628 oct_write64(ptr, value);
633 * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
634 * by tag/handle starting at `offset'.
637 static __inline void bus_space_set_region_1(bus_space_tag_t tag,
638 bus_space_handle_t bsh,
639 bus_size_t offset, u_int8_t value,
641 static __inline void bus_space_set_region_2(bus_space_tag_t tag,
642 bus_space_handle_t bsh,
643 bus_size_t offset, u_int16_t value,
645 static __inline void bus_space_set_region_4(bus_space_tag_t tag,
646 bus_space_handle_t bsh,
647 bus_size_t offset, u_int32_t value,
651 bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
652 bus_size_t offset, u_int8_t value, size_t count)
654 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
656 for(; count > 0; count--, ptr++) {
657 oct_write8(ptr, value);
662 bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
663 bus_size_t offset, u_int16_t value, size_t count)
665 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
667 for(; count > 0; count--, ptr++) {
668 oct_write16(ptr, value);
673 bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
674 bus_size_t offset, u_int32_t value, size_t count)
676 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
678 for(; count > 0; count--, ptr++) {
679 oct_write32(ptr, value);
684 bus_space_set_region_8(bus_space_tag_t tag, bus_space_handle_t bsh,
685 bus_size_t offset, u_int64_t value, size_t count)
687 uint64_t ptr = ((uint64_t) bsh + (uint64_t) offset);
689 for(; count > 0; count--, ptr++) {
690 oct_write64(ptr, value);
695 * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
696 * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
699 static __inline void bus_space_copy_region_1(bus_space_tag_t tag,
700 bus_space_handle_t bsh1,
702 bus_space_handle_t bsh2,
703 bus_size_t off2, size_t count);
705 static __inline void bus_space_copy_region_2(bus_space_tag_t tag,
706 bus_space_handle_t bsh1,
708 bus_space_handle_t bsh2,
709 bus_size_t off2, size_t count);
711 static __inline void bus_space_copy_region_4(bus_space_tag_t tag,
712 bus_space_handle_t bsh1,
714 bus_space_handle_t bsh2,
715 bus_size_t off2, size_t count);
718 bus_space_copy_region_1(bus_space_tag_t tag, bus_space_handle_t bsh1,
719 bus_size_t off1, bus_space_handle_t bsh2,
720 bus_size_t off2, size_t count)
722 uint64_t ptr1 = ((uint64_t) bsh1 + (uint64_t) off1);
723 uint64_t ptr2 = ((uint64_t) bsh2 + (uint64_t) off2);
726 for(; count > 0; count--, ptr1++, ptr2++) {
727 val = oct_read8(ptr1);
728 oct_write8(ptr2, val);
733 bus_space_copy_region_2(bus_space_tag_t tag, bus_space_handle_t bsh1,
734 bus_size_t off1, bus_space_handle_t bsh2,
735 bus_size_t off2, size_t count)
737 uint64_t ptr1 = ((uint64_t) bsh1 + (uint64_t) off1);
738 uint64_t ptr2 = ((uint64_t) bsh2 + (uint64_t) off2);
741 for(; count > 0; count--, ptr1++, ptr2++) {
742 val = oct_read16(ptr1);
743 oct_write16(ptr2, val);
748 bus_space_copy_region_4(bus_space_tag_t tag, bus_space_handle_t bsh1,
749 bus_size_t off1, bus_space_handle_t bsh2,
750 bus_size_t off2, size_t count)
752 uint64_t ptr1 = ((uint64_t) bsh1 + (uint64_t) off1);
753 uint64_t ptr2 = ((uint64_t) bsh2 + (uint64_t) off2);
756 for(; count > 0; count--, ptr1++, ptr2++) {
757 val = oct_read32(ptr1);
758 oct_write32(ptr2, val);
763 bus_space_copy_region_8(bus_space_tag_t tag, bus_space_handle_t bsh1,
764 bus_size_t off1, bus_space_handle_t bsh2,
765 bus_size_t off2, size_t count)
767 uint64_t ptr1 = ((uint64_t) bsh1 + (uint64_t) off1);
768 uint64_t ptr2 = ((uint64_t) bsh2 + (uint64_t) off2);
771 for(; count > 0; count--, ptr1++, ptr2++) {
772 val = oct_read64(ptr1);
773 oct_write64(ptr2, val);
778 * Bus read/write barrier methods.
780 * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
781 * bus_size_t offset, bus_size_t len, int flags);
784 * Note that BUS_SPACE_BARRIER_WRITE doesn't do anything other than
785 * prevent reordering by the compiler; all Intel x86 processors currently
786 * retire operations outside the CPU in program order.
788 #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
789 #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
792 bus_space_barrier(bus_space_tag_t tag __unused, bus_space_handle_t bsh __unused,
793 bus_size_t offset __unused, bus_size_t len __unused, int flags)
796 #ifdef __GNUCLIKE_ASM
797 if (flags & BUS_SPACE_BARRIER_READ)
798 __asm __volatile("lock; addl $0,0(%%rsp)" : : : "memory");
800 __asm __volatile("" : : : "memory");
803 oct_read64(OCTEON_MIO_BOOT_BIST_STAT);
806 #ifdef BUS_SPACE_NO_LEGACY
809 #define inb(a) compiler_error
810 #define inw(a) compiler_error
811 #define inl(a) compiler_error
812 #define outb(a, b) compiler_error
813 #define outw(a, b) compiler_error
814 #define outl(a, b) compiler_error
817 #include <machine/bus_dma.h>
820 * Stream accesses are the same as normal accesses on amd64; there are no
821 * supported bus systems with an endianess different from the host one.
823 #define bus_space_read_stream_1(t, h, o) bus_space_read_1((t), (h), (o))
824 #define bus_space_read_stream_2(t, h, o) bus_space_read_2((t), (h), (o))
825 #define bus_space_read_stream_4(t, h, o) bus_space_read_4((t), (h), (o))
827 #define bus_space_read_multi_stream_1(t, h, o, a, c) \
828 bus_space_read_multi_1((t), (h), (o), (a), (c))
829 #define bus_space_read_multi_stream_2(t, h, o, a, c) \
830 bus_space_read_multi_2((t), (h), (o), (a), (c))
831 #define bus_space_read_multi_stream_4(t, h, o, a, c) \
832 bus_space_read_multi_4((t), (h), (o), (a), (c))
834 #define bus_space_write_stream_1(t, h, o, v) \
835 bus_space_write_1((t), (h), (o), (v))
836 #define bus_space_write_stream_2(t, h, o, v) \
837 bus_space_write_2((t), (h), (o), (v))
838 #define bus_space_write_stream_4(t, h, o, v) \
839 bus_space_write_4((t), (h), (o), (v))
841 #define bus_space_write_multi_stream_1(t, h, o, a, c) \
842 bus_space_write_multi_1((t), (h), (o), (a), (c))
843 #define bus_space_write_multi_stream_2(t, h, o, a, c) \
844 bus_space_write_multi_2((t), (h), (o), (a), (c))
845 #define bus_space_write_multi_stream_4(t, h, o, a, c) \
846 bus_space_write_multi_4((t), (h), (o), (a), (c))
848 #define bus_space_set_multi_stream_1(t, h, o, v, c) \
849 bus_space_set_multi_1((t), (h), (o), (v), (c))
850 #define bus_space_set_multi_stream_2(t, h, o, v, c) \
851 bus_space_set_multi_2((t), (h), (o), (v), (c))
852 #define bus_space_set_multi_stream_4(t, h, o, v, c) \
853 bus_space_set_multi_4((t), (h), (o), (v), (c))
855 #define bus_space_read_region_stream_1(t, h, o, a, c) \
856 bus_space_read_region_1((t), (h), (o), (a), (c))
857 #define bus_space_read_region_stream_2(t, h, o, a, c) \
858 bus_space_read_region_2((t), (h), (o), (a), (c))
859 #define bus_space_read_region_stream_4(t, h, o, a, c) \
860 bus_space_read_region_4((t), (h), (o), (a), (c))
862 #define bus_space_write_region_stream_1(t, h, o, a, c) \
863 bus_space_write_region_1((t), (h), (o), (a), (c))
864 #define bus_space_write_region_stream_2(t, h, o, a, c) \
865 bus_space_write_region_2((t), (h), (o), (a), (c))
866 #define bus_space_write_region_stream_4(t, h, o, a, c) \
867 bus_space_write_region_4((t), (h), (o), (a), (c))
869 #define bus_space_set_region_stream_1(t, h, o, v, c) \
870 bus_space_set_region_1((t), (h), (o), (v), (c))
871 #define bus_space_set_region_stream_2(t, h, o, v, c) \
872 bus_space_set_region_2((t), (h), (o), (v), (c))
873 #define bus_space_set_region_stream_4(t, h, o, v, c) \
874 bus_space_set_region_4((t), (h), (o), (v), (c))
876 #define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c) \
877 bus_space_copy_region_1((t), (h1), (o1), (h2), (o2), (c))
878 #define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
879 bus_space_copy_region_2((t), (h1), (o1), (h2), (o2), (c))
880 #define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
881 bus_space_copy_region_4((t), (h1), (o1), (h2), (o2), (c))
883 #endif /* _MIPS_BUS_OCTEON_H_ */