bus_space_generic.c revision 263687
1/* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */ 2/*- 3 * $Id: bus.h,v 1.6 2007/08/09 11:23:32 katta Exp $ 4 * 5 * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 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. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 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 * 21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34/* 35 * Copyright (c) 1996 Charles M. Hannum. All rights reserved. 36 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 37 * 38 * Redistribution and use in source and binary forms, with or without 39 * modification, are permitted provided that the following conditions 40 * are met: 41 * 1. Redistributions of source code must retain the above copyright 42 * notice, this list of conditions and the following disclaimer. 43 * 2. Redistributions in binary form must reproduce the above copyright 44 * notice, this list of conditions and the following disclaimer in the 45 * documentation and/or other materials provided with the distribution. 46 * 3. All advertising materials mentioning features or use of this software 47 * must display the following acknowledgement: 48 * This product includes software developed by Christopher G. Demetriou 49 * for the NetBSD Project. 50 * 4. The name of the author may not be used to endorse or promote products 51 * derived from this software without specific prior written permission 52 * 53 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 54 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 55 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 56 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 57 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 58 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 59 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 60 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 61 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 62 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 63 * 64 * from: src/sys/alpha/include/bus.h,v 1.5 1999/08/28 00:38:40 peter 65 * $FreeBSD: stable/10/sys/mips/mips/bus_space_generic.c 263687 2014-03-24 13:48:04Z emaste $ 66 */ 67#include <sys/cdefs.h> 68__FBSDID("$FreeBSD: stable/10/sys/mips/mips/bus_space_generic.c 263687 2014-03-24 13:48:04Z emaste $"); 69 70#include <sys/param.h> 71#include <sys/systm.h> 72#include <sys/bus.h> 73#include <sys/kernel.h> 74#include <sys/malloc.h> 75#include <sys/ktr.h> 76 77#include <vm/vm.h> 78#include <vm/pmap.h> 79#include <vm/vm_kern.h> 80#include <vm/vm_extern.h> 81 82#include <machine/bus.h> 83#include <machine/cache.h> 84 85static struct bus_space generic_space = { 86 /* cookie */ 87 .bs_cookie = (void *) 0, 88 89 /* mapping/unmapping */ 90 .bs_map = generic_bs_map, 91 .bs_unmap = generic_bs_unmap, 92 .bs_subregion = generic_bs_subregion, 93 94 /* allocation/deallocation */ 95 .bs_alloc = generic_bs_alloc, 96 .bs_free = generic_bs_free, 97 98 /* barrier */ 99 .bs_barrier = generic_bs_barrier, 100 101 /* read (single) */ 102 .bs_r_1 = generic_bs_r_1, 103 .bs_r_2 = generic_bs_r_2, 104 .bs_r_4 = generic_bs_r_4, 105 .bs_r_8 = generic_bs_r_8, 106 107 /* read multiple */ 108 .bs_rm_1 = generic_bs_rm_1, 109 .bs_rm_2 = generic_bs_rm_2, 110 .bs_rm_4 = generic_bs_rm_4, 111 .bs_rm_8 = generic_bs_rm_8, 112 113 /* read region */ 114 .bs_rr_1 = generic_bs_rr_1, 115 .bs_rr_2 = generic_bs_rr_2, 116 .bs_rr_4 = generic_bs_rr_4, 117 .bs_rr_8 = generic_bs_rr_8, 118 119 /* write (single) */ 120 .bs_w_1 = generic_bs_w_1, 121 .bs_w_2 = generic_bs_w_2, 122 .bs_w_4 = generic_bs_w_4, 123 .bs_w_8 = generic_bs_w_8, 124 125 /* write multiple */ 126 .bs_wm_1 = generic_bs_wm_1, 127 .bs_wm_2 = generic_bs_wm_2, 128 .bs_wm_4 = generic_bs_wm_4, 129 .bs_wm_8 = generic_bs_wm_8, 130 131 /* write region */ 132 .bs_wr_1 = generic_bs_wr_1, 133 .bs_wr_2 = generic_bs_wr_2, 134 .bs_wr_4 = generic_bs_wr_4, 135 .bs_wr_8 = generic_bs_wr_8, 136 137 /* set multiple */ 138 .bs_sm_1 = generic_bs_sm_1, 139 .bs_sm_2 = generic_bs_sm_2, 140 .bs_sm_4 = generic_bs_sm_4, 141 .bs_sm_8 = generic_bs_sm_8, 142 143 /* set region */ 144 .bs_sr_1 = generic_bs_sr_1, 145 .bs_sr_2 = generic_bs_sr_2, 146 .bs_sr_4 = generic_bs_sr_4, 147 .bs_sr_8 = generic_bs_sr_8, 148 149 /* copy */ 150 .bs_c_1 = generic_bs_c_1, 151 .bs_c_2 = generic_bs_c_2, 152 .bs_c_4 = generic_bs_c_4, 153 .bs_c_8 = generic_bs_c_8, 154 155 /* read (single) stream */ 156 .bs_r_1_s = generic_bs_r_1, 157 .bs_r_2_s = generic_bs_r_2, 158 .bs_r_4_s = generic_bs_r_4, 159 .bs_r_8_s = generic_bs_r_8, 160 161 /* read multiple stream */ 162 .bs_rm_1_s = generic_bs_rm_1, 163 .bs_rm_2_s = generic_bs_rm_2, 164 .bs_rm_4_s = generic_bs_rm_4, 165 .bs_rm_8_s = generic_bs_rm_8, 166 167 /* read region stream */ 168 .bs_rr_1_s = generic_bs_rr_1, 169 .bs_rr_2_s = generic_bs_rr_2, 170 .bs_rr_4_s = generic_bs_rr_4, 171 .bs_rr_8_s = generic_bs_rr_8, 172 173 /* write (single) stream */ 174 .bs_w_1_s = generic_bs_w_1, 175 .bs_w_2_s = generic_bs_w_2, 176 .bs_w_4_s = generic_bs_w_4, 177 .bs_w_8_s = generic_bs_w_8, 178 179 /* write multiple stream */ 180 .bs_wm_1_s = generic_bs_wm_1, 181 .bs_wm_2_s = generic_bs_wm_2, 182 .bs_wm_4_s = generic_bs_wm_4, 183 .bs_wm_8_s = generic_bs_wm_8, 184 185 /* write region stream */ 186 .bs_wr_1_s = generic_bs_wr_1, 187 .bs_wr_2_s = generic_bs_wr_2, 188 .bs_wr_4_s = generic_bs_wr_4, 189 .bs_wr_8_s = generic_bs_wr_8, 190}; 191 192/* Ultra-gross kludge */ 193#if defined(CPU_CNMIPS) && (defined(__mips_n32) || defined(__mips_o32)) 194#include <contrib/octeon-sdk/cvmx.h> 195#define rd8(a) cvmx_read64_uint8(a) 196#define rd16(a) cvmx_read64_uint16(a) 197#define rd32(a) cvmx_read64_uint32(a) 198#define rd64(a) cvmx_read64_uint64(a) 199#define wr8(a, v) cvmx_write64_uint8(a, v) 200#define wr16(a, v) cvmx_write64_uint16(a, v) 201#define wr32(a, v) cvmx_write64_uint32(a, v) 202#define wr64(a, v) cvmx_write64_uint64(a, v) 203#elif defined(CPU_SB1) && _BYTE_ORDER == _BIG_ENDIAN 204#include <mips/sibyte/sb_bus_space.h> 205#define rd8(a) sb_big_endian_read8(a) 206#define rd16(a) sb_big_endian_read16(a) 207#define rd32(a) sb_big_endian_read32(a) 208#define wr8(a, v) sb_big_endian_write8(a, v) 209#define wr16(a, v) sb_big_endian_write16(a, v) 210#define wr32(a, v) sb_big_endian_write32(a, v) 211#else 212#define rd8(a) readb(a) 213#define rd16(a) readw(a) 214#define rd32(a) readl(a) 215#ifdef readq 216#define rd64(a) readq((a)) 217#endif 218#define wr8(a, v) writeb(a, v) 219#define wr16(a, v) writew(a, v) 220#define wr32(a, v) writel(a, v) 221#ifdef writeq 222#define wr64(a, v) writeq(a, v) 223#endif 224#endif 225 226/* generic bus_space tag */ 227bus_space_tag_t mips_bus_space_generic = &generic_space; 228 229int 230generic_bs_map(void *t __unused, bus_addr_t addr, 231 bus_size_t size __unused, int flags __unused, 232 bus_space_handle_t *bshp) 233{ 234 235 *bshp = addr; 236 return (0); 237} 238 239void 240generic_bs_unmap(void *t __unused, bus_space_handle_t bh __unused, 241 bus_size_t size __unused) 242{ 243 244 /* Do nothing */ 245} 246 247int 248generic_bs_subregion(void *t __unused, bus_space_handle_t handle, 249 bus_size_t offset, bus_size_t size __unused, 250 bus_space_handle_t *bshp) 251{ 252 253 *bshp = handle + offset; 254 return (0); 255} 256 257int 258generic_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, 259 bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags, 260 bus_addr_t *bpap, bus_space_handle_t *bshp) 261{ 262 263 panic("%s: not implemented", __func__); 264} 265 266void 267generic_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size) 268{ 269 270 panic("%s: not implemented", __func__); 271} 272 273uint8_t 274generic_bs_r_1(void *t, bus_space_handle_t handle, 275 bus_size_t offset) 276{ 277 278 return (rd8(handle + offset)); 279} 280 281uint16_t 282generic_bs_r_2(void *t, bus_space_handle_t handle, 283 bus_size_t offset) 284{ 285 286 return (rd16(handle + offset)); 287} 288 289uint32_t 290generic_bs_r_4(void *t, bus_space_handle_t handle, 291 bus_size_t offset) 292{ 293 294 return (rd32(handle + offset)); 295} 296 297uint64_t 298generic_bs_r_8(void *t, bus_space_handle_t handle, bus_size_t offset) 299{ 300 301#ifdef rd64 302 return(rd64(handle + offset)); 303#else 304 panic("%s: not implemented", __func__); 305#endif 306} 307 308void 309generic_bs_rm_1(void *t, bus_space_handle_t bsh, 310 bus_size_t offset, uint8_t *addr, size_t count) 311{ 312 313 while (count--) 314 *addr++ = rd8(bsh + offset); 315} 316 317void 318generic_bs_rm_2(void *t, bus_space_handle_t bsh, 319 bus_size_t offset, uint16_t *addr, size_t count) 320{ 321 bus_addr_t baddr = bsh + offset; 322 323 while (count--) 324 *addr++ = rd16(baddr); 325} 326 327void 328generic_bs_rm_4(void *t, bus_space_handle_t bsh, 329 bus_size_t offset, uint32_t *addr, size_t count) 330{ 331 bus_addr_t baddr = bsh + offset; 332 333 while (count--) 334 *addr++ = rd32(baddr); 335} 336 337void 338generic_bs_rm_8(void *t, bus_space_handle_t bsh, bus_size_t offset, 339 uint64_t *addr, size_t count) 340{ 341#ifdef rd64 342 bus_addr_t baddr = bsh + offset; 343 344 while (count--) 345 *addr++ = rd64(baddr); 346#else 347 panic("%s: not implemented", __func__); 348#endif 349} 350 351/* 352 * Read `count' 1, 2, 4, or 8 byte quantities from bus space 353 * described by tag/handle and starting at `offset' and copy into 354 * buffer provided. 355 */ 356void 357generic_bs_rr_1(void *t, bus_space_handle_t bsh, 358 bus_size_t offset, uint8_t *addr, size_t count) 359{ 360 bus_addr_t baddr = bsh + offset; 361 362 while (count--) { 363 *addr++ = rd8(baddr); 364 baddr += 1; 365 } 366} 367 368void 369generic_bs_rr_2(void *t, bus_space_handle_t bsh, 370 bus_size_t offset, uint16_t *addr, size_t count) 371{ 372 bus_addr_t baddr = bsh + offset; 373 374 while (count--) { 375 *addr++ = rd16(baddr); 376 baddr += 2; 377 } 378} 379 380void 381generic_bs_rr_4(void *t, bus_space_handle_t bsh, 382 bus_size_t offset, uint32_t *addr, size_t count) 383{ 384 bus_addr_t baddr = bsh + offset; 385 386 while (count--) { 387 *addr++ = rd32(baddr); 388 baddr += 4; 389 } 390} 391 392void 393generic_bs_rr_8(void *t, bus_space_handle_t bsh, bus_size_t offset, 394 uint64_t *addr, size_t count) 395{ 396#ifdef rd64 397 bus_addr_t baddr = bsh + offset; 398 399 while (count--) { 400 *addr++ = rd64(baddr); 401 baddr += 8; 402 } 403#else 404 panic("%s: not implemented", __func__); 405#endif 406} 407 408/* 409 * Write the 1, 2, 4, or 8 byte value `value' to bus space 410 * described by tag/handle/offset. 411 */ 412void 413generic_bs_w_1(void *t, bus_space_handle_t bsh, 414 bus_size_t offset, uint8_t value) 415{ 416 417 wr8(bsh + offset, value); 418} 419 420void 421generic_bs_w_2(void *t, bus_space_handle_t bsh, 422 bus_size_t offset, uint16_t value) 423{ 424 425 wr16(bsh + offset, value); 426} 427 428void 429generic_bs_w_4(void *t, bus_space_handle_t bsh, 430 bus_size_t offset, uint32_t value) 431{ 432 433 wr32(bsh + offset, value); 434} 435 436void 437generic_bs_w_8(void *t, bus_space_handle_t bsh, bus_size_t offset, 438 uint64_t value) 439{ 440 441#ifdef wr64 442 wr64(bsh + offset, value); 443#else 444 panic("%s: not implemented", __func__); 445#endif 446} 447 448/* 449 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer 450 * provided to bus space described by tag/handle/offset. 451 */ 452void 453generic_bs_wm_1(void *t, bus_space_handle_t bsh, 454 bus_size_t offset, const uint8_t *addr, size_t count) 455{ 456 bus_addr_t baddr = bsh + offset; 457 458 while (count--) 459 wr8(baddr, *addr++); 460} 461 462void 463generic_bs_wm_2(void *t, bus_space_handle_t bsh, 464 bus_size_t offset, const uint16_t *addr, size_t count) 465{ 466 bus_addr_t baddr = bsh + offset; 467 468 while (count--) 469 wr16(baddr, *addr++); 470} 471 472void 473generic_bs_wm_4(void *t, bus_space_handle_t bsh, 474 bus_size_t offset, const uint32_t *addr, size_t count) 475{ 476 bus_addr_t baddr = bsh + offset; 477 478 while (count--) 479 wr32(baddr, *addr++); 480} 481 482void 483generic_bs_wm_8(void *t, bus_space_handle_t bsh, bus_size_t offset, 484 const uint64_t *addr, size_t count) 485{ 486#ifdef wr64 487 bus_addr_t baddr = bsh + offset; 488 489 while (count--) 490 wr64(baddr, *addr++); 491#else 492 panic("%s: not implemented", __func__); 493#endif 494} 495 496/* 497 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided 498 * to bus space described by tag/handle starting at `offset'. 499 */ 500void 501generic_bs_wr_1(void *t, bus_space_handle_t bsh, 502 bus_size_t offset, const uint8_t *addr, size_t count) 503{ 504 bus_addr_t baddr = bsh + offset; 505 506 while (count--) { 507 wr8(baddr, *addr++); 508 baddr += 1; 509 } 510} 511 512void 513generic_bs_wr_2(void *t, bus_space_handle_t bsh, 514 bus_size_t offset, const uint16_t *addr, size_t count) 515{ 516 bus_addr_t baddr = bsh + offset; 517 518 while (count--) { 519 wr16(baddr, *addr++); 520 baddr += 2; 521 } 522} 523 524void 525generic_bs_wr_4(void *t, bus_space_handle_t bsh, 526 bus_size_t offset, const uint32_t *addr, size_t count) 527{ 528 bus_addr_t baddr = bsh + offset; 529 530 while (count--) { 531 wr32(baddr, *addr++); 532 baddr += 4; 533 } 534} 535 536void 537generic_bs_wr_8(void *t, bus_space_handle_t bsh, bus_size_t offset, 538 const uint64_t *addr, size_t count) 539{ 540#ifdef wr64 541 bus_addr_t baddr = bsh + offset; 542 543 while (count--) { 544 wr64(baddr, *addr++); 545 baddr += 8; 546 } 547#else 548 panic("%s: not implemented", __func__); 549#endif 550} 551 552/* 553 * Write the 1, 2, 4, or 8 byte value `val' to bus space described 554 * by tag/handle/offset `count' times. 555 */ 556void 557generic_bs_sm_1(void *t, bus_space_handle_t bsh, 558 bus_size_t offset, uint8_t value, size_t count) 559{ 560 bus_addr_t addr = bsh + offset; 561 562 while (count--) 563 wr8(addr, value); 564} 565 566void 567generic_bs_sm_2(void *t, bus_space_handle_t bsh, 568 bus_size_t offset, uint16_t value, size_t count) 569{ 570 bus_addr_t addr = bsh + offset; 571 572 while (count--) 573 wr16(addr, value); 574} 575 576void 577generic_bs_sm_4(void *t, bus_space_handle_t bsh, 578 bus_size_t offset, uint32_t value, size_t count) 579{ 580 bus_addr_t addr = bsh + offset; 581 582 while (count--) 583 wr32(addr, value); 584} 585 586void 587generic_bs_sm_8(void *t, bus_space_handle_t bsh, bus_size_t offset, 588 uint64_t value, size_t count) 589{ 590#ifdef wr64 591 bus_addr_t addr = bsh + offset; 592 593 while (count--) 594 wr64(addr, value); 595#else 596 panic("%s: not implemented", __func__); 597#endif 598} 599 600/* 601 * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described 602 * by tag/handle starting at `offset'. 603 */ 604void 605generic_bs_sr_1(void *t, bus_space_handle_t bsh, 606 bus_size_t offset, uint8_t value, size_t count) 607{ 608 bus_addr_t addr = bsh + offset; 609 610 for (; count != 0; count--, addr++) 611 wr8(addr, value); 612} 613 614void 615generic_bs_sr_2(void *t, bus_space_handle_t bsh, 616 bus_size_t offset, uint16_t value, size_t count) 617{ 618 bus_addr_t addr = bsh + offset; 619 620 for (; count != 0; count--, addr += 2) 621 wr16(addr, value); 622} 623 624void 625generic_bs_sr_4(void *t, bus_space_handle_t bsh, 626 bus_size_t offset, uint32_t value, size_t count) 627{ 628 bus_addr_t addr = bsh + offset; 629 630 for (; count != 0; count--, addr += 4) 631 wr32(addr, value); 632} 633 634void 635generic_bs_sr_8(void *t, bus_space_handle_t bsh, bus_size_t offset, 636 uint64_t value, size_t count) 637{ 638#ifdef wr64 639 bus_addr_t addr = bsh + offset; 640 641 for (; count != 0; count--, addr += 8) 642 wr64(addr, value); 643#else 644 panic("%s: not implemented", __func__); 645#endif 646} 647 648/* 649 * Copy `count' 1, 2, 4, or 8 byte values from bus space starting 650 * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. 651 */ 652void 653generic_bs_c_1(void *t, bus_space_handle_t bsh1, 654 bus_size_t off1, bus_space_handle_t bsh2, 655 bus_size_t off2, size_t count) 656{ 657 bus_addr_t addr1 = bsh1 + off1; 658 bus_addr_t addr2 = bsh2 + off2; 659 660 if (addr1 >= addr2) { 661 /* src after dest: copy forward */ 662 for (; count != 0; count--, addr1++, addr2++) 663 wr8(addr2, rd8(addr1)); 664 } else { 665 /* dest after src: copy backwards */ 666 for (addr1 += (count - 1), addr2 += (count - 1); 667 count != 0; count--, addr1--, addr2--) 668 wr8(addr2, rd8(addr1)); 669 } 670} 671 672void 673generic_bs_c_2(void *t, bus_space_handle_t bsh1, 674 bus_size_t off1, bus_space_handle_t bsh2, 675 bus_size_t off2, size_t count) 676{ 677 bus_addr_t addr1 = bsh1 + off1; 678 bus_addr_t addr2 = bsh2 + off2; 679 680 if (addr1 >= addr2) { 681 /* src after dest: copy forward */ 682 for (; count != 0; count--, addr1 += 2, addr2 += 2) 683 wr16(addr2, rd16(addr1)); 684 } else { 685 /* dest after src: copy backwards */ 686 for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1); 687 count != 0; count--, addr1 -= 2, addr2 -= 2) 688 wr16(addr2, rd16(addr1)); 689 } 690} 691 692void 693generic_bs_c_4(void *t, bus_space_handle_t bsh1, 694 bus_size_t off1, bus_space_handle_t bsh2, 695 bus_size_t off2, size_t count) 696{ 697 bus_addr_t addr1 = bsh1 + off1; 698 bus_addr_t addr2 = bsh2 + off2; 699 700 if (addr1 >= addr2) { 701 /* src after dest: copy forward */ 702 for (; count != 0; count--, addr1 += 4, addr2 += 4) 703 wr32(addr2, rd32(addr1)); 704 } else { 705 /* dest after src: copy backwards */ 706 for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1); 707 count != 0; count--, addr1 -= 4, addr2 -= 4) 708 wr32(addr2, rd32(addr1)); 709 } 710} 711 712void 713generic_bs_c_8(void *t, bus_space_handle_t bsh1, bus_size_t off1, 714 bus_space_handle_t bsh2, bus_size_t off2, size_t count) 715{ 716#if defined(rd64) && defined(wr64) 717 bus_addr_t addr1 = bsh1 + off1; 718 bus_addr_t addr2 = bsh2 + off2; 719 720 if (addr1 >= addr2) { 721 /* src after dest: copy forward */ 722 for (; count != 0; count--, addr1 += 8, addr2 += 8) 723 wr64(addr2, rd64(addr1)); 724 } else { 725 /* dest after src: copy backwards */ 726 for (addr1 += 8 * (count - 1), addr2 += 8 * (count - 1); 727 count != 0; count--, addr1 -= 8, addr2 -= 8) 728 wr64(addr2, rd64(addr1)); 729 } 730#else 731 panic("%s: not implemented", __func__); 732#endif 733} 734 735void 736generic_bs_barrier(void *t __unused, 737 bus_space_handle_t bsh __unused, 738 bus_size_t offset __unused, bus_size_t len __unused, 739 int flags) 740{ 741#if 0 742 if (flags & BUS_SPACE_BARRIER_WRITE) 743 mips_dcache_wbinv_all(); 744#endif 745 if (flags & BUS_SPACE_BARRIER_READ) 746 rmb(); 747 if (flags & BUS_SPACE_BARRIER_WRITE) 748 wmb(); 749} 750