Port-i386 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bus_space/bus_dma and PAE



Hi,
I started looking at PCI passthough for Xen, and as part of this
at getting a XEN3PAE i386 kernel building (which is usefull if we ever want
to suppport native i386 PAE too). The attached patch allows to build
a XEN3PAE_XENU kernel with bus_space and bus_dma linked in.
What it does is change bus_addr_t to be paddr_t (so its size changes with
options PAE); and remplace a view bus_addr_t with vaddr_t where
the value is used as a virtual address (and so is not a physical bus
address, strictly speaking).

comment ?

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--
Index: x86/include/bus.h
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/include/bus.h,v
retrieving revision 1.17
diff -u -p -u -r1.17 bus.h
--- x86/include/bus.h   6 Nov 2008 01:17:24 -0000       1.17
+++ x86/include/bus.h   24 Jan 2009 23:33:49 -0000
@@ -77,11 +77,11 @@
 /*
  * Bus address and size types
  */
-typedef u_long bus_addr_t;
-typedef u_long bus_size_t;
+typedef paddr_t bus_addr_t;
+typedef paddr_t bus_size_t;
 
 typedef        int bus_space_tag_t;
-typedef        u_long bus_space_handle_t;
+typedef        vaddr_t bus_space_handle_t;
 
 int    _x86_memio_map(bus_space_tag_t t, bus_addr_t addr,
            bus_size_t size, int flags, bus_space_handle_t *bshp);
Index: x86/include/isa_machdep.h
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/include/isa_machdep.h,v
retrieving revision 1.6
diff -u -p -u -r1.6 isa_machdep.h
--- x86/include/isa_machdep.h   27 Jun 2008 11:03:13 -0000      1.6
+++ x86/include/isa_machdep.h   24 Jan 2009 23:33:49 -0000
@@ -202,19 +202,19 @@ extern struct x86_bus_dma_tag isa_bus_dm
  * function definitions, invoked through the softc.
  */
 
-extern u_long atdevbase;           /* kernel virtual address of "hole" */
+extern vaddr_t atdevbase;         /* kernel virtual address of "hole" */
 
 /*
  * Given a kernel virtual address for some location
  * in the "hole" I/O space, return a physical address.
  */
-#define ISA_PHYSADDR(v) ((void *) ((u_long)(v) - atdevbase + IOM_BEGIN))
+#define ISA_PHYSADDR(v) ((bus_addr_t)(v) - atdevbase + IOM_BEGIN)
 
 /*
  * Given a physical address in the "hole",
  * return a kernel virtual address.
  */
-#define ISA_HOLE_VADDR(p)  ((void *) ((u_long)(p) - IOM_BEGIN + atdevbase))
+#define ISA_HOLE_VADDR(p)  ((void *) ((vaddr_t)(p) - IOM_BEGIN + atdevbase))
 
 
 /*
Index: x86/x86/bus_space.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/bus_space.c,v
retrieving revision 1.20
diff -u -p -u -r1.20 bus_space.c
--- x86/x86/bus_space.c 21 Oct 2008 15:46:32 -0000      1.20
+++ x86/x86/bus_space.c 24 Jan 2009 23:33:49 -0000
@@ -199,8 +199,8 @@ bus_space_map(bus_space_tag_t t, bus_add
        if (error) {
                if (extent_free(ex, bpa, size, EX_NOWAIT |
                    (ioport_malloc_safe ? EX_MALLOCOK : 0))) {
-                       printf("x86_memio_map: pa 0x%lx, size 0x%lx\n",
-                           bpa, size);
+                       printf("x86_memio_map: pa 0x%" PRIx64 ", size 0x%"
+                           PRIx64 "\n", (uint64_t)bpa, (uint64_t)size);
                        printf("x86_memio_map: can't free region\n");
                }
        }
@@ -286,8 +286,8 @@ bus_space_alloc(bus_space_tag_t t, bus_a
        if (error) {
                if (extent_free(iomem_ex, bpa, size, EX_NOWAIT |
                    (ioport_malloc_safe ? EX_MALLOCOK : 0))) {
-                       printf("x86_memio_alloc: pa 0x%lx, size 0x%lx\n",
-                           bpa, size);
+                       printf("x86_memio_alloc: pa 0x%" PRIx64 ", size 0x%"
+                           PRIx64 "\n", (uint64_t)bpa, (uint64_t)size);
                        printf("x86_memio_alloc: can't free region\n");
                }
        }
@@ -463,8 +463,9 @@ bus_space_unmap(bus_space_tag_t t, bus_s
 ok:
        if (extent_free(ex, bpa, size,
            EX_NOWAIT | (ioport_malloc_safe ? EX_MALLOCOK : 0))) {
-               printf("x86_memio_unmap: %s 0x%lx, size 0x%lx\n",
-                   (t == X86_BUS_SPACE_IO) ? "port" : "pa", bpa, size);
+               printf("x86_memio_unmap: %s 0x%" PRIx64 ", size 0x%"
+                   PRIx64 "\n", (t == X86_BUS_SPACE_IO) ? "port" : "pa",
+                   (uint64_t)bpa, (uint64_t)size);
                printf("x86_memio_unmap: can't free region\n");
        }
 }
@@ -509,7 +510,7 @@ void
 bus_space_set_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
                      uint8_t v, size_t c)
 {
-       bus_addr_t addr = h + o;
+       vaddr_t addr = h + o;
 
        if (t == X86_BUS_SPACE_IO)
                while (c--)
@@ -523,7 +524,7 @@ void
 bus_space_set_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
                      uint16_t v, size_t c)
 {
-       bus_addr_t addr = h + o;
+       vaddr_t addr = h + o;
 
        BUS_SPACE_ADDRESS_SANITY(addr, uint16_t, "bus addr");
 
@@ -539,7 +540,7 @@ void
 bus_space_set_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
                      uint32_t v, size_t c)
 {
-       bus_addr_t addr = h + o;
+       vaddr_t addr = h + o;
 
        BUS_SPACE_ADDRESS_SANITY(addr, uint32_t, "bus addr");
 
@@ -555,7 +556,7 @@ void
 bus_space_set_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
                      uint8_t v, size_t c)
 {
-       bus_addr_t addr = h + o;
+       vaddr_t addr = h + o;
 
        if (t == X86_BUS_SPACE_IO)
                for (; c != 0; c--, addr++)
@@ -569,7 +570,7 @@ void
 bus_space_set_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
                       uint16_t v, size_t c)
 {
-       bus_addr_t addr = h + o;
+       vaddr_t addr = h + o;
 
        BUS_SPACE_ADDRESS_SANITY(addr, uint16_t, "bus addr");
 
@@ -585,7 +586,7 @@ void
 bus_space_set_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
                       uint32_t v, size_t c)
 {
-       bus_addr_t addr = h + o;
+       vaddr_t addr = h + o;
 
        BUS_SPACE_ADDRESS_SANITY(addr, uint32_t, "bus addr");
 
@@ -602,8 +603,8 @@ bus_space_copy_region_1(bus_space_tag_t 
                        bus_size_t o1, bus_space_handle_t h2,
                        bus_size_t o2, size_t c)
 {
-       bus_addr_t addr1 = h1 + o1;
-       bus_addr_t addr2 = h2 + o2;
+       vaddr_t addr1 = h1 + o1;
+       vaddr_t addr2 = h2 + o2;
 
        if (t == X86_BUS_SPACE_IO) {
                if (addr1 >= addr2) {
@@ -637,8 +638,8 @@ bus_space_copy_region_2(bus_space_tag_t 
                        bus_size_t o1, bus_space_handle_t h2,
                        bus_size_t o2, size_t c)
 {
-       bus_addr_t addr1 = h1 + o1;
-       bus_addr_t addr2 = h2 + o2;
+       vaddr_t addr1 = h1 + o1;
+       vaddr_t addr2 = h2 + o2;
 
        BUS_SPACE_ADDRESS_SANITY(addr1, uint16_t, "bus addr 1");
        BUS_SPACE_ADDRESS_SANITY(addr2, uint16_t, "bus addr 2");
@@ -675,8 +676,8 @@ bus_space_copy_region_4(bus_space_tag_t 
                        bus_size_t o1, bus_space_handle_t h2,
                        bus_size_t o2, size_t c)
 {
-       bus_addr_t addr1 = h1 + o1;
-       bus_addr_t addr2 = h2 + o2;
+       vaddr_t addr1 = h1 + o1;
+       vaddr_t addr2 = h2 + o2;
 
        BUS_SPACE_ADDRESS_SANITY(addr1, uint32_t, "bus addr 1");
        BUS_SPACE_ADDRESS_SANITY(addr2, uint32_t, "bus addr 2");


Home | Main Index | Thread Index | Old Index