Tue Sep 29 23:53:14 2009 UTC ()
Pull up following revision(s) (requested by bouyer in ticket #1040):
	sys/arch/x86/include/bus.h: revision 1.18
	sys/arch/x86/include/isa_machdep.h: revision 1.7
	sys/arch/x86/x86/bus_space.c: revision 1.21
Apply patch proposed on port-amd64/port-i386, allowing to use a 64bit
bus_addr_t on i386PAE kernels:
change bus_addr_t to be a paddr_t (so its size follows paddr_t depending
   on options PAE)
remplace bus_addr_t with vaddr_t where the value is used as a virtual address.
Difference with the proposed patch: cast to uintmax_t and use %jx in
printf() as suggested by Joerg.


(snj)
diff -r1.16 -r1.16.10.1 src/sys/arch/x86/include/bus.h
diff -r1.6 -r1.6.6.1 src/sys/arch/x86/include/isa_machdep.h
diff -r1.20.4.1 -r1.20.4.2 src/sys/arch/x86/x86/bus_space.c

cvs diff -r1.16 -r1.16.10.1 src/sys/arch/x86/include/Attic/bus.h (expand / switch to unified diff)

--- src/sys/arch/x86/include/Attic/bus.h 2008/04/28 20:23:40 1.16
+++ src/sys/arch/x86/include/Attic/bus.h 2009/09/29 23:53:14 1.16.10.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bus.h,v 1.16 2008/04/28 20:23:40 martin Exp $ */ 1/* $NetBSD: bus.h,v 1.16.10.1 2009/09/29 23:53:14 snj Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1998, 2001 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 Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * 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
@@ -67,31 +67,31 @@ @@ -67,31 +67,31 @@
67#include <x86/busdefs.h> 67#include <x86/busdefs.h>
68 68
69#ifdef BUS_SPACE_DEBUG  69#ifdef BUS_SPACE_DEBUG
70#define BUS_SPACE_ALIGNED_ADDRESS(p, t) \ 70#define BUS_SPACE_ALIGNED_ADDRESS(p, t) \
71 ((((u_long)(p)) & (sizeof(t)-1)) == 0) 71 ((((u_long)(p)) & (sizeof(t)-1)) == 0)
72#define BUS_SPACE_ALIGNED_POINTER(p, t) BUS_SPACE_ALIGNED_ADDRESS(p, t) 72#define BUS_SPACE_ALIGNED_POINTER(p, t) BUS_SPACE_ALIGNED_ADDRESS(p, t)
73#else 73#else
74#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) 74#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
75#endif /* BUS_SPACE_DEBUG */ 75#endif /* BUS_SPACE_DEBUG */
76 76
77/* 77/*
78 * Bus address and size types 78 * Bus address and size types
79 */ 79 */
80typedef u_long bus_addr_t; 80typedef paddr_t bus_addr_t;
81typedef u_long bus_size_t; 81typedef paddr_t bus_size_t;
82 82
83typedef int bus_space_tag_t; 83typedef int bus_space_tag_t;
84typedef u_long bus_space_handle_t; 84typedef vaddr_t bus_space_handle_t;
85 85
86int _x86_memio_map(bus_space_tag_t t, bus_addr_t addr, 86int _x86_memio_map(bus_space_tag_t t, bus_addr_t addr,
87 bus_size_t size, int flags, bus_space_handle_t *bshp); 87 bus_size_t size, int flags, bus_space_handle_t *bshp);
88void _x86_memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, 88void _x86_memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
89 bus_size_t size, bus_addr_t *); 89 bus_size_t size, bus_addr_t *);
90 90
91typedef struct x86_bus_dma_tag *bus_dma_tag_t; 91typedef struct x86_bus_dma_tag *bus_dma_tag_t;
92typedef struct x86_bus_dmamap *bus_dmamap_t; 92typedef struct x86_bus_dmamap *bus_dmamap_t;
93 93
94#define BUS_DMA_TAG_VALID(t) ((t) != (bus_dma_tag_t)0) 94#define BUS_DMA_TAG_VALID(t) ((t) != (bus_dma_tag_t)0)
95 95
96/* 96/*
97 * bus_dma_segment_t 97 * bus_dma_segment_t

cvs diff -r1.6 -r1.6.6.1 src/sys/arch/x86/include/isa_machdep.h (expand / switch to unified diff)

--- src/sys/arch/x86/include/isa_machdep.h 2008/06/27 11:03:13 1.6
+++ src/sys/arch/x86/include/isa_machdep.h 2009/09/29 23:53:14 1.6.6.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: isa_machdep.h,v 1.6 2008/06/27 11:03:13 cegger Exp $ */ 1/* $NetBSD: isa_machdep.h,v 1.6.6.1 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 Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * 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
@@ -192,34 +192,34 @@ extern struct x86_bus_dma_tag isa_bus_dm @@ -192,34 +192,34 @@ extern struct x86_bus_dma_tag isa_bus_dm
192 * stuff that used to be in pccons.c 192 * stuff that used to be in pccons.c
193 */ 193 */
194#define MONO_BASE 0x3B4 194#define MONO_BASE 0x3B4
195#define MONO_BUF 0xB0000 195#define MONO_BUF 0xB0000
196#define CGA_BASE 0x3D4 196#define CGA_BASE 0x3D4
197#define CGA_BUF 0xB8000 197#define CGA_BUF 0xB8000
198 198
199/* 199/*
200 * Variables and macros to deal with the ISA I/O hole. 200 * Variables and macros to deal with the ISA I/O hole.
201 * XXX These should be converted to machine- and bus-mapping-independent 201 * XXX These should be converted to machine- and bus-mapping-independent
202 * function definitions, invoked through the softc. 202 * function definitions, invoked through the softc.
203 */ 203 */
204 204
205extern u_long atdevbase; /* kernel virtual address of "hole" */ 205extern vaddr_t atdevbase; /* kernel virtual address of "hole" */
206 206
207/* 207/*
208 * Given a kernel virtual address for some location 208 * Given a kernel virtual address for some location
209 * in the "hole" I/O space, return a physical address. 209 * in the "hole" I/O space, return a physical address.
210 */ 210 */
211#define ISA_PHYSADDR(v) ((void *) ((u_long)(v) - atdevbase + IOM_BEGIN)) 211#define ISA_PHYSADDR(v) ((bus_addr_t)(v) - atdevbase + IOM_BEGIN)
212 212
213/* 213/*
214 * Given a physical address in the "hole", 214 * Given a physical address in the "hole",
215 * return a kernel virtual address. 215 * return a kernel virtual address.
216 */ 216 */
217#define ISA_HOLE_VADDR(p) ((void *) ((u_long)(p) - IOM_BEGIN + atdevbase)) 217#define ISA_HOLE_VADDR(p) ((void *) ((vaddr_t)(p) - IOM_BEGIN + atdevbase))
218 218
219 219
220/* 220/*
221 * Miscellanous functions. 221 * Miscellanous functions.
222 */ 222 */
223void sysbeep(int, int); /* beep with the system speaker */ 223void sysbeep(int, int); /* beep with the system speaker */
224 224
225#endif /* _X86_ISA_MACHDEP_H_ XXX */ 225#endif /* _X86_ISA_MACHDEP_H_ XXX */

cvs diff -r1.20.4.1 -r1.20.4.2 src/sys/arch/x86/x86/bus_space.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/bus_space.c 2009/09/16 03:45:45 1.20.4.1
+++ src/sys/arch/x86/x86/bus_space.c 2009/09/29 23:53:14 1.20.4.2
@@ -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
211int 211int
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
300int 300int
301x86_mem_add_mapping(bus_addr_t bpa, bus_size_t size, 301x86_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
464ok: 464ok:
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
473void 474void
474bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size) 475bus_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
481int 482int
@@ -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
509void 510void
510bus_space_set_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, 511bus_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
523void 524void
524bus_space_set_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, 525bus_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
539void 540void
540bus_space_set_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, 541bus_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
555void 556void
556bus_space_set_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, 557bus_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
569void 570void
570bus_space_set_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, 571bus_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
585void 586void
586bus_space_set_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, 587bus_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
601void 602void
602bus_space_copy_region_1(bus_space_tag_t t, bus_space_handle_t h1, 603bus_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
636void 637void
637bus_space_copy_region_2(bus_space_tag_t t, bus_space_handle_t h1, 638bus_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
674void 675void
675bus_space_copy_region_4(bus_space_tag_t t, bus_space_handle_t h1, 676bus_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)