| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: bus_space.c,v 1.20.4.1 2009/09/16 03:45:45 snj Exp $ */ | | 1 | /* $NetBSD: bus_space.c,v 1.20.4.2 2009/09/29 23:53:14 snj Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace | | 8 | * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace |
9 | * Simulation Facility, NASA Ames Research Center. | | 9 | * Simulation Facility, NASA Ames Research Center. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -21,27 +21,27 @@ | | | @@ -21,27 +21,27 @@ |
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30 | * POSSIBILITY OF SUCH DAMAGE. | | 30 | * POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include <sys/cdefs.h> | | 33 | #include <sys/cdefs.h> |
34 | __KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.20.4.1 2009/09/16 03:45:45 snj Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.20.4.2 2009/09/29 23:53:14 snj Exp $"); |
35 | | | 35 | |
36 | #include <sys/param.h> | | 36 | #include <sys/param.h> |
37 | #include <sys/systm.h> | | 37 | #include <sys/systm.h> |
38 | #include <sys/malloc.h> | | 38 | #include <sys/malloc.h> |
39 | #include <sys/extent.h> | | 39 | #include <sys/extent.h> |
40 | | | 40 | |
41 | #include <uvm/uvm_extern.h> | | 41 | #include <uvm/uvm_extern.h> |
42 | | | 42 | |
43 | #include <dev/isa/isareg.h> | | 43 | #include <dev/isa/isareg.h> |
44 | | | 44 | |
45 | #include <machine/bus.h> | | 45 | #include <machine/bus.h> |
46 | #include <machine/pio.h> | | 46 | #include <machine/pio.h> |
47 | #include <machine/isa_machdep.h> | | 47 | #include <machine/isa_machdep.h> |
| @@ -189,28 +189,28 @@ bus_space_map(bus_space_tag_t t, bus_add | | | @@ -189,28 +189,28 @@ bus_space_map(bus_space_tag_t t, bus_add |
189 | return(0); | | 189 | return(0); |
190 | } | | 190 | } |
191 | #endif /* !XEN */ | | 191 | #endif /* !XEN */ |
192 | | | 192 | |
193 | /* | | 193 | /* |
194 | * For memory space, map the bus physical address to | | 194 | * For memory space, map the bus physical address to |
195 | * a kernel virtual address. | | 195 | * a kernel virtual address. |
196 | */ | | 196 | */ |
197 | error = x86_mem_add_mapping(bpa, size, | | 197 | error = x86_mem_add_mapping(bpa, size, |
198 | (flags & BUS_SPACE_MAP_CACHEABLE) != 0, bshp); | | 198 | (flags & BUS_SPACE_MAP_CACHEABLE) != 0, bshp); |
199 | if (error) { | | 199 | if (error) { |
200 | if (extent_free(ex, bpa, size, EX_NOWAIT | | | 200 | if (extent_free(ex, bpa, size, EX_NOWAIT | |
201 | (ioport_malloc_safe ? EX_MALLOCOK : 0))) { | | 201 | (ioport_malloc_safe ? EX_MALLOCOK : 0))) { |
202 | printf("x86_memio_map: pa 0x%lx, size 0x%lx\n", | | 202 | printf("x86_memio_map: pa 0x%jx, size 0x%jx\n", |
203 | bpa, size); | | 203 | (uintmax_t)bpa, (uintmax_t)size); |
204 | printf("x86_memio_map: can't free region\n"); | | 204 | printf("x86_memio_map: can't free region\n"); |
205 | } | | 205 | } |
206 | } | | 206 | } |
207 | | | 207 | |
208 | return (error); | | 208 | return (error); |
209 | } | | 209 | } |
210 | | | 210 | |
211 | int | | 211 | int |
212 | _x86_memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, | | 212 | _x86_memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, |
213 | int flags, bus_space_handle_t *bshp) | | 213 | int flags, bus_space_handle_t *bshp) |
214 | { | | 214 | { |
215 | | | 215 | |
216 | /* | | 216 | /* |
| @@ -276,28 +276,28 @@ bus_space_alloc(bus_space_tag_t t, bus_a | | | @@ -276,28 +276,28 @@ bus_space_alloc(bus_space_tag_t t, bus_a |
276 | *bshp = *bpap = bpa; | | 276 | *bshp = *bpap = bpa; |
277 | return (0); | | 277 | return (0); |
278 | } | | 278 | } |
279 | | | 279 | |
280 | /* | | 280 | /* |
281 | * For memory space, map the bus physical address to | | 281 | * For memory space, map the bus physical address to |
282 | * a kernel virtual address. | | 282 | * a kernel virtual address. |
283 | */ | | 283 | */ |
284 | error = x86_mem_add_mapping(bpa, size, | | 284 | error = x86_mem_add_mapping(bpa, size, |
285 | (flags & BUS_SPACE_MAP_CACHEABLE) != 0, bshp); | | 285 | (flags & BUS_SPACE_MAP_CACHEABLE) != 0, bshp); |
286 | if (error) { | | 286 | if (error) { |
287 | if (extent_free(iomem_ex, bpa, size, EX_NOWAIT | | | 287 | if (extent_free(iomem_ex, bpa, size, EX_NOWAIT | |
288 | (ioport_malloc_safe ? EX_MALLOCOK : 0))) { | | 288 | (ioport_malloc_safe ? EX_MALLOCOK : 0))) { |
289 | printf("x86_memio_alloc: pa 0x%lx, size 0x%lx\n", | | 289 | printf("x86_memio_alloc: pa 0x%jx, size 0x%jx\n", |
290 | bpa, size); | | 290 | (uintmax_t)bpa, (uintmax_t)size); |
291 | printf("x86_memio_alloc: can't free region\n"); | | 291 | printf("x86_memio_alloc: can't free region\n"); |
292 | } | | 292 | } |
293 | } | | 293 | } |
294 | | | 294 | |
295 | *bpap = bpa; | | 295 | *bpap = bpa; |
296 | | | 296 | |
297 | return (error); | | 297 | return (error); |
298 | } | | 298 | } |
299 | | | 299 | |
300 | int | | 300 | int |
301 | x86_mem_add_mapping(bus_addr_t bpa, bus_size_t size, | | 301 | x86_mem_add_mapping(bus_addr_t bpa, bus_size_t size, |
302 | int cacheable, bus_space_handle_t *bshp) | | 302 | int cacheable, bus_space_handle_t *bshp) |
303 | { | | 303 | { |
| @@ -454,28 +454,29 @@ bus_space_unmap(bus_space_tag_t t, bus_s | | | @@ -454,28 +454,29 @@ bus_space_unmap(bus_space_tag_t t, bus_s |
454 | pmap_kremove(va, endva - va); | | 454 | pmap_kremove(va, endva - va); |
455 | pmap_update(pmap_kernel()); | | 455 | pmap_update(pmap_kernel()); |
456 | | | 456 | |
457 | /* | | 457 | /* |
458 | * Free the kernel virtual mapping. | | 458 | * Free the kernel virtual mapping. |
459 | */ | | 459 | */ |
460 | uvm_km_free(kernel_map, va, endva - va, UVM_KMF_VAONLY); | | 460 | uvm_km_free(kernel_map, va, endva - va, UVM_KMF_VAONLY); |
461 | } else | | 461 | } else |
462 | panic("x86_memio_unmap: bad bus space tag"); | | 462 | panic("x86_memio_unmap: bad bus space tag"); |
463 | | | 463 | |
464 | ok: | | 464 | ok: |
465 | if (extent_free(ex, bpa, size, | | 465 | if (extent_free(ex, bpa, size, |
466 | EX_NOWAIT | (ioport_malloc_safe ? EX_MALLOCOK : 0))) { | | 466 | EX_NOWAIT | (ioport_malloc_safe ? EX_MALLOCOK : 0))) { |
467 | printf("x86_memio_unmap: %s 0x%lx, size 0x%lx\n", | | 467 | printf("x86_memio_unmap: %s 0x%jx, size 0x%jx\n", |
468 | (t == X86_BUS_SPACE_IO) ? "port" : "pa", bpa, size); | | 468 | (t == X86_BUS_SPACE_IO) ? "port" : "pa", |
| | | 469 | (uintmax_t)bpa, (uintmax_t)size); |
469 | printf("x86_memio_unmap: can't free region\n"); | | 470 | printf("x86_memio_unmap: can't free region\n"); |
470 | } | | 471 | } |
471 | } | | 472 | } |
472 | | | 473 | |
473 | void | | 474 | void |
474 | bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size) | | 475 | bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size) |
475 | { | | 476 | { |
476 | | | 477 | |
477 | /* bus_space_unmap() does all that we need to do. */ | | 478 | /* bus_space_unmap() does all that we need to do. */ |
478 | bus_space_unmap(t, bsh, size); | | 479 | bus_space_unmap(t, bsh, size); |
479 | } | | 480 | } |
480 | | | 481 | |
481 | int | | 482 | int |
| @@ -500,121 +501,121 @@ bus_space_mmap(bus_space_tag_t t, bus_ad | | | @@ -500,121 +501,121 @@ bus_space_mmap(bus_space_tag_t t, bus_ad |
500 | * "addr" is the base address of the device we're mapping. | | 501 | * "addr" is the base address of the device we're mapping. |
501 | * "off" is the offset into that device. | | 502 | * "off" is the offset into that device. |
502 | * | | 503 | * |
503 | * Note we are called for each "page" in the device that | | 504 | * Note we are called for each "page" in the device that |
504 | * the upper layers want to map. | | 505 | * the upper layers want to map. |
505 | */ | | 506 | */ |
506 | return (x86_btop(addr + off)); | | 507 | return (x86_btop(addr + off)); |
507 | } | | 508 | } |
508 | | | 509 | |
509 | void | | 510 | void |
510 | bus_space_set_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, | | 511 | bus_space_set_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, |
511 | uint8_t v, size_t c) | | 512 | uint8_t v, size_t c) |
512 | { | | 513 | { |
513 | bus_addr_t addr = h + o; | | 514 | vaddr_t addr = h + o; |
514 | | | 515 | |
515 | if (t == X86_BUS_SPACE_IO) | | 516 | if (t == X86_BUS_SPACE_IO) |
516 | while (c--) | | 517 | while (c--) |
517 | outb(addr, v); | | 518 | outb(addr, v); |
518 | else | | 519 | else |
519 | while (c--) | | 520 | while (c--) |
520 | *(volatile uint8_t *)(addr) = v; | | 521 | *(volatile uint8_t *)(addr) = v; |
521 | } | | 522 | } |
522 | | | 523 | |
523 | void | | 524 | void |
524 | bus_space_set_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, | | 525 | bus_space_set_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, |
525 | uint16_t v, size_t c) | | 526 | uint16_t v, size_t c) |
526 | { | | 527 | { |
527 | bus_addr_t addr = h + o; | | 528 | vaddr_t addr = h + o; |
528 | | | 529 | |
529 | BUS_SPACE_ADDRESS_SANITY(addr, uint16_t, "bus addr"); | | 530 | BUS_SPACE_ADDRESS_SANITY(addr, uint16_t, "bus addr"); |
530 | | | 531 | |
531 | if (t == X86_BUS_SPACE_IO) | | 532 | if (t == X86_BUS_SPACE_IO) |
532 | while (c--) | | 533 | while (c--) |
533 | outw(addr, v); | | 534 | outw(addr, v); |
534 | else | | 535 | else |
535 | while (c--) | | 536 | while (c--) |
536 | *(volatile uint16_t *)(addr) = v; | | 537 | *(volatile uint16_t *)(addr) = v; |
537 | } | | 538 | } |
538 | | | 539 | |
539 | void | | 540 | void |
540 | bus_space_set_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, | | 541 | bus_space_set_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, |
541 | uint32_t v, size_t c) | | 542 | uint32_t v, size_t c) |
542 | { | | 543 | { |
543 | bus_addr_t addr = h + o; | | 544 | vaddr_t addr = h + o; |
544 | | | 545 | |
545 | BUS_SPACE_ADDRESS_SANITY(addr, uint32_t, "bus addr"); | | 546 | BUS_SPACE_ADDRESS_SANITY(addr, uint32_t, "bus addr"); |
546 | | | 547 | |
547 | if (t == X86_BUS_SPACE_IO) | | 548 | if (t == X86_BUS_SPACE_IO) |
548 | while (c--) | | 549 | while (c--) |
549 | outl(addr, v); | | 550 | outl(addr, v); |
550 | else | | 551 | else |
551 | while (c--) | | 552 | while (c--) |
552 | *(volatile uint32_t *)(addr) = v; | | 553 | *(volatile uint32_t *)(addr) = v; |
553 | } | | 554 | } |
554 | | | 555 | |
555 | void | | 556 | void |
556 | bus_space_set_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, | | 557 | bus_space_set_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, |
557 | uint8_t v, size_t c) | | 558 | uint8_t v, size_t c) |
558 | { | | 559 | { |
559 | bus_addr_t addr = h + o; | | 560 | vaddr_t addr = h + o; |
560 | | | 561 | |
561 | if (t == X86_BUS_SPACE_IO) | | 562 | if (t == X86_BUS_SPACE_IO) |
562 | for (; c != 0; c--, addr++) | | 563 | for (; c != 0; c--, addr++) |
563 | outb(addr, v); | | 564 | outb(addr, v); |
564 | else | | 565 | else |
565 | for (; c != 0; c--, addr++) | | 566 | for (; c != 0; c--, addr++) |
566 | *(volatile uint8_t *)(addr) = v; | | 567 | *(volatile uint8_t *)(addr) = v; |
567 | } | | 568 | } |
568 | | | 569 | |
569 | void | | 570 | void |
570 | bus_space_set_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, | | 571 | bus_space_set_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, |
571 | uint16_t v, size_t c) | | 572 | uint16_t v, size_t c) |
572 | { | | 573 | { |
573 | bus_addr_t addr = h + o; | | 574 | vaddr_t addr = h + o; |
574 | | | 575 | |
575 | BUS_SPACE_ADDRESS_SANITY(addr, uint16_t, "bus addr"); | | 576 | BUS_SPACE_ADDRESS_SANITY(addr, uint16_t, "bus addr"); |
576 | | | 577 | |
577 | if (t == X86_BUS_SPACE_IO) | | 578 | if (t == X86_BUS_SPACE_IO) |
578 | for (; c != 0; c--, addr += 2) | | 579 | for (; c != 0; c--, addr += 2) |
579 | outw(addr, v); | | 580 | outw(addr, v); |
580 | else | | 581 | else |
581 | for (; c != 0; c--, addr += 2) | | 582 | for (; c != 0; c--, addr += 2) |
582 | *(volatile uint16_t *)(addr) = v; | | 583 | *(volatile uint16_t *)(addr) = v; |
583 | } | | 584 | } |
584 | | | 585 | |
585 | void | | 586 | void |
586 | bus_space_set_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, | | 587 | bus_space_set_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, |
587 | uint32_t v, size_t c) | | 588 | uint32_t v, size_t c) |
588 | { | | 589 | { |
589 | bus_addr_t addr = h + o; | | 590 | vaddr_t addr = h + o; |
590 | | | 591 | |
591 | BUS_SPACE_ADDRESS_SANITY(addr, uint32_t, "bus addr"); | | 592 | BUS_SPACE_ADDRESS_SANITY(addr, uint32_t, "bus addr"); |
592 | | | 593 | |
593 | if (t == X86_BUS_SPACE_IO) | | 594 | if (t == X86_BUS_SPACE_IO) |
594 | for (; c != 0; c--, addr += 4) | | 595 | for (; c != 0; c--, addr += 4) |
595 | outl(addr, v); | | 596 | outl(addr, v); |
596 | else | | 597 | else |
597 | for (; c != 0; c--, addr += 4) | | 598 | for (; c != 0; c--, addr += 4) |
598 | *(volatile uint32_t *)(addr) = v; | | 599 | *(volatile uint32_t *)(addr) = v; |
599 | } | | 600 | } |
600 | | | 601 | |
601 | void | | 602 | void |
602 | bus_space_copy_region_1(bus_space_tag_t t, bus_space_handle_t h1, | | 603 | bus_space_copy_region_1(bus_space_tag_t t, bus_space_handle_t h1, |
603 | bus_size_t o1, bus_space_handle_t h2, | | 604 | bus_size_t o1, bus_space_handle_t h2, |
604 | bus_size_t o2, size_t c) | | 605 | bus_size_t o2, size_t c) |
605 | { | | 606 | { |
606 | bus_addr_t addr1 = h1 + o1; | | 607 | vaddr_t addr1 = h1 + o1; |
607 | bus_addr_t addr2 = h2 + o2; | | 608 | vaddr_t addr2 = h2 + o2; |
608 | | | 609 | |
609 | if (t == X86_BUS_SPACE_IO) { | | 610 | if (t == X86_BUS_SPACE_IO) { |
610 | if (addr1 >= addr2) { | | 611 | if (addr1 >= addr2) { |
611 | /* src after dest: copy forward */ | | 612 | /* src after dest: copy forward */ |
612 | for (; c != 0; c--, addr1++, addr2++) | | 613 | for (; c != 0; c--, addr1++, addr2++) |
613 | outb(addr2, inb(addr1)); | | 614 | outb(addr2, inb(addr1)); |
614 | } else { | | 615 | } else { |
615 | /* dest after src: copy backwards */ | | 616 | /* dest after src: copy backwards */ |
616 | for (addr1 += (c - 1), addr2 += (c - 1); | | 617 | for (addr1 += (c - 1), addr2 += (c - 1); |
617 | c != 0; c--, addr1--, addr2--) | | 618 | c != 0; c--, addr1--, addr2--) |
618 | outb(addr2, inb(addr1)); | | 619 | outb(addr2, inb(addr1)); |
619 | } | | 620 | } |
620 | } else { | | 621 | } else { |
| @@ -628,28 +629,28 @@ bus_space_copy_region_1(bus_space_tag_t | | | @@ -628,28 +629,28 @@ bus_space_copy_region_1(bus_space_tag_t |
628 | for (addr1 += (c - 1), addr2 += (c - 1); | | 629 | for (addr1 += (c - 1), addr2 += (c - 1); |
629 | c != 0; c--, addr1--, addr2--) | | 630 | c != 0; c--, addr1--, addr2--) |
630 | *(volatile uint8_t *)(addr2) = | | 631 | *(volatile uint8_t *)(addr2) = |
631 | *(volatile uint8_t *)(addr1); | | 632 | *(volatile uint8_t *)(addr1); |
632 | } | | 633 | } |
633 | } | | 634 | } |
634 | } | | 635 | } |
635 | | | 636 | |
636 | void | | 637 | void |
637 | bus_space_copy_region_2(bus_space_tag_t t, bus_space_handle_t h1, | | 638 | bus_space_copy_region_2(bus_space_tag_t t, bus_space_handle_t h1, |
638 | bus_size_t o1, bus_space_handle_t h2, | | 639 | bus_size_t o1, bus_space_handle_t h2, |
639 | bus_size_t o2, size_t c) | | 640 | bus_size_t o2, size_t c) |
640 | { | | 641 | { |
641 | bus_addr_t addr1 = h1 + o1; | | 642 | vaddr_t addr1 = h1 + o1; |
642 | bus_addr_t addr2 = h2 + o2; | | 643 | vaddr_t addr2 = h2 + o2; |
643 | | | 644 | |
644 | BUS_SPACE_ADDRESS_SANITY(addr1, uint16_t, "bus addr 1"); | | 645 | BUS_SPACE_ADDRESS_SANITY(addr1, uint16_t, "bus addr 1"); |
645 | BUS_SPACE_ADDRESS_SANITY(addr2, uint16_t, "bus addr 2"); | | 646 | BUS_SPACE_ADDRESS_SANITY(addr2, uint16_t, "bus addr 2"); |
646 | | | 647 | |
647 | if (t == X86_BUS_SPACE_IO) { | | 648 | if (t == X86_BUS_SPACE_IO) { |
648 | if (addr1 >= addr2) { | | 649 | if (addr1 >= addr2) { |
649 | /* src after dest: copy forward */ | | 650 | /* src after dest: copy forward */ |
650 | for (; c != 0; c--, addr1 += 2, addr2 += 2) | | 651 | for (; c != 0; c--, addr1 += 2, addr2 += 2) |
651 | outw(addr2, inw(addr1)); | | 652 | outw(addr2, inw(addr1)); |
652 | } else { | | 653 | } else { |
653 | /* dest after src: copy backwards */ | | 654 | /* dest after src: copy backwards */ |
654 | for (addr1 += 2 * (c - 1), addr2 += 2 * (c - 1); | | 655 | for (addr1 += 2 * (c - 1), addr2 += 2 * (c - 1); |
655 | c != 0; c--, addr1 -= 2, addr2 -= 2) | | 656 | c != 0; c--, addr1 -= 2, addr2 -= 2) |
| @@ -666,28 +667,28 @@ bus_space_copy_region_2(bus_space_tag_t | | | @@ -666,28 +667,28 @@ bus_space_copy_region_2(bus_space_tag_t |
666 | for (addr1 += 2 * (c - 1), addr2 += 2 * (c - 1); | | 667 | for (addr1 += 2 * (c - 1), addr2 += 2 * (c - 1); |
667 | c != 0; c--, addr1 -= 2, addr2 -= 2) | | 668 | c != 0; c--, addr1 -= 2, addr2 -= 2) |
668 | *(volatile uint16_t *)(addr2) = | | 669 | *(volatile uint16_t *)(addr2) = |
669 | *(volatile uint16_t *)(addr1); | | 670 | *(volatile uint16_t *)(addr1); |
670 | } | | 671 | } |
671 | } | | 672 | } |
672 | } | | 673 | } |
673 | | | 674 | |
674 | void | | 675 | void |
675 | bus_space_copy_region_4(bus_space_tag_t t, bus_space_handle_t h1, | | 676 | bus_space_copy_region_4(bus_space_tag_t t, bus_space_handle_t h1, |
676 | bus_size_t o1, bus_space_handle_t h2, | | 677 | bus_size_t o1, bus_space_handle_t h2, |
677 | bus_size_t o2, size_t c) | | 678 | bus_size_t o2, size_t c) |
678 | { | | 679 | { |
679 | bus_addr_t addr1 = h1 + o1; | | 680 | vaddr_t addr1 = h1 + o1; |
680 | bus_addr_t addr2 = h2 + o2; | | 681 | vaddr_t addr2 = h2 + o2; |
681 | | | 682 | |
682 | BUS_SPACE_ADDRESS_SANITY(addr1, uint32_t, "bus addr 1"); | | 683 | BUS_SPACE_ADDRESS_SANITY(addr1, uint32_t, "bus addr 1"); |
683 | BUS_SPACE_ADDRESS_SANITY(addr2, uint32_t, "bus addr 2"); | | 684 | BUS_SPACE_ADDRESS_SANITY(addr2, uint32_t, "bus addr 2"); |
684 | | | 685 | |
685 | if (t == X86_BUS_SPACE_IO) { | | 686 | if (t == X86_BUS_SPACE_IO) { |
686 | if (addr1 >= addr2) { | | 687 | if (addr1 >= addr2) { |
687 | /* src after dest: copy forward */ | | 688 | /* src after dest: copy forward */ |
688 | for (; c != 0; c--, addr1 += 4, addr2 += 4) | | 689 | for (; c != 0; c--, addr1 += 4, addr2 += 4) |
689 | outl(addr2, inl(addr1)); | | 690 | outl(addr2, inl(addr1)); |
690 | } else { | | 691 | } else { |
691 | /* dest after src: copy backwards */ | | 692 | /* dest after src: copy backwards */ |
692 | for (addr1 += 4 * (c - 1), addr2 += 4 * (c - 1); | | 693 | for (addr1 += 4 * (c - 1), addr2 += 4 * (c - 1); |
693 | c != 0; c--, addr1 -= 4, addr2 -= 4) | | 694 | c != 0; c--, addr1 -= 4, addr2 -= 4) |