Author: ian
Date: Fri Dec 13 23:56:53 2013
New Revision: 259364
URL: http://svnweb.freebsd.org/changeset/base/259364

Log:
  MFC r257648, r257649, r257660:
  
    Begin reducing code duplication in arm pmap.c and pmap-v6.c by factoring
    out common code related to mapping device memory into a new devmap.c file.
  
    Remove the growing duplication of code that used pmap_devmap_find_pa() and
    then did some math with the returned results to generate a virtual address,
    and likewise in reverse to get a physical address.  Now there are a pair
    of functions, arm_devmap_vtop() and arm_devmap_ptov(), to do that.  The
    bus_space_map() implementations are rewritten in terms of these.
  
    Move remaining code and data related to static device mapping into the
    new devmap.[ch] files.  Emphasize the MD nature of these things by using
    the prefix arm_devmap_ on the function and type names (already a few of
    these things found their way into MI code, hopefully it will be harder to
    do by accident in the future).

Added:
  stable/10/sys/arm/arm/devmap.c
     - copied, changed from r257648, head/sys/arm/arm/devmap.c
  stable/10/sys/arm/include/devmap.h
     - copied, changed from r257648, head/sys/arm/include/devmap.h
Modified:
  stable/10/sys/arm/allwinner/a10_machdep.c
  stable/10/sys/arm/arm/bus_space_generic.c
  stable/10/sys/arm/arm/machdep.c
  stable/10/sys/arm/arm/pmap-v6.c
  stable/10/sys/arm/arm/pmap.c
  stable/10/sys/arm/at91/at91.c
  stable/10/sys/arm/at91/at91_machdep.c
  stable/10/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
  stable/10/sys/arm/econa/econa_machdep.c
  stable/10/sys/arm/freescale/imx/imx6_machdep.c
  stable/10/sys/arm/freescale/imx/imx_machdep.c
  stable/10/sys/arm/include/fdt.h
  stable/10/sys/arm/include/machdep.h
  stable/10/sys/arm/include/pmap.h
  stable/10/sys/arm/lpc/lpc_machdep.c
  stable/10/sys/arm/mv/mv_localbus.c
  stable/10/sys/arm/mv/mv_machdep.c
  stable/10/sys/arm/mv/mvvar.h
  stable/10/sys/arm/rockchip/rk30xx_machdep.c
  stable/10/sys/arm/s3c2xx0/s3c24x0_machdep.c
  stable/10/sys/arm/sa11x0/assabet_machdep.c
  stable/10/sys/arm/samsung/exynos/exynos5_machdep.c
  stable/10/sys/arm/tegra/tegra2_machdep.c
  stable/10/sys/arm/ti/ti_machdep.c
  stable/10/sys/arm/versatile/versatile_machdep.c
  stable/10/sys/arm/xilinx/zy7_machdep.c
  stable/10/sys/arm/xscale/i80321/ep80219_machdep.c
  stable/10/sys/arm/xscale/i80321/iq31244_machdep.c
  stable/10/sys/arm/xscale/i8134x/crb_machdep.c
  stable/10/sys/arm/xscale/ixp425/avila_machdep.c
  stable/10/sys/arm/xscale/pxa/pxa_machdep.c
  stable/10/sys/conf/files.arm
  stable/10/sys/dev/fdt/fdt_pci.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/arm/allwinner/a10_machdep.c
==============================================================================
--- stable/10/sys/arm/allwinner/a10_machdep.c   Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/allwinner/a10_machdep.c   Fri Dec 13 23:56:53 2013        
(r259364)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/pmap.h>
 
 #include <machine/bus.h>
+#include <machine/devmap.h>
 #include <machine/machdep.h>
 
 #include <dev/fdt/fdt_common.h>
@@ -71,7 +72,7 @@ initarm_late_init(void)
 }
 
 #define FDT_DEVMAP_MAX         (1 + 2 + 1 + 1)
-static struct pmap_devmap fdt_devmap[FDT_DEVMAP_MAX] = {
+static struct arm_devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = {
        { 0, 0, 0, 0, 0, }
 };
 
@@ -91,7 +92,7 @@ platform_devmap_init(void)
 
        i++;
 
-       pmap_devmap_bootstrap_table = &fdt_devmap[0];
+       arm_devmap_register_table(&fdt_devmap[0]);
 
        return (0);
 }

Modified: stable/10/sys/arm/arm/bus_space_generic.c
==============================================================================
--- stable/10/sys/arm/arm/bus_space_generic.c   Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/arm/bus_space_generic.c   Fri Dec 13 23:56:53 2013        
(r259364)
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_extern.h>
 
 #include <machine/bus.h>
+#include <machine/devmap.h>
 
 /* Prototypes for all the bus_space structure functions */
 bs_protos(generic);
@@ -58,36 +59,20 @@ int
 generic_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags,
     bus_space_handle_t *bshp)
 {
-       const struct pmap_devmap *pd;
-       vm_paddr_t startpa, endpa, pa, offset;
-       vm_offset_t va;
-       pt_entry_t *pte;
-
-       if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) {
-               /* Device was statically mapped. */
-               *bshp = pd->pd_va + (bpa - pd->pd_pa);
-               return (0);
-       }
-
-       endpa = round_page(bpa + size);
-       offset = bpa & PAGE_MASK;
-       startpa = trunc_page(bpa);
-
-       va = kva_alloc(endpa - startpa);
-       if (va == 0)
-               return (ENOMEM);
-
-       *bshp = va + offset;
-
-       for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
-               pmap_kenter(va, pa);
-               pte = vtopte(va);
-               if (!(flags & BUS_SPACE_MAP_CACHEABLE)) {
-                       *pte &= ~L2_S_CACHE_MASK;
-                       PTE_SYNC(pte);
-               }
-       }
+       void *va;
 
+       /*
+        * Look up the address in the static device mappings.  If it's not
+        * there, establish a new dynamic mapping.
+        *
+        * We don't even examine the passed-in flags.  For ARM, the CACHEABLE
+        * flag doesn't make sense (we create PTE_DEVICE mappings), and the
+        * LINEAR flag is just implied because we use kva_alloc(size).
+        */
+       if ((va = arm_devmap_ptov(bpa, size)) == NULL)
+               if ((va = pmap_mapdev(bpa, size)) == NULL)
+                       return (ENOMEM);
+       *bshp = (bus_space_handle_t)va;
        return (0);
 }
 
@@ -104,21 +89,13 @@ generic_bs_alloc(void *t, bus_addr_t rst
 void
 generic_bs_unmap(void *t, bus_space_handle_t h, bus_size_t size)
 {
-       vm_offset_t va, endva, origva;
 
-       if (pmap_devmap_find_va((vm_offset_t)h, size) != NULL) {
-               /* Device was statically mapped; nothing to do. */
-               return;
-       }
-
-       endva = round_page((vm_offset_t)h + size);
-       origva = va = trunc_page((vm_offset_t)h);
-
-       while (va < endva) {
-               pmap_kremove(va);
-               va += PAGE_SIZE;
-       }
-       kva_free(origva, endva - origva);
+       /*
+        * If the region is static-mapped do nothing, otherwise remove the
+        * dynamic mapping.
+        */
+       if (arm_devmap_vtop((void*)h, size) == DEVMAP_PADDR_NOTFOUND)
+               pmap_unmapdev((vm_offset_t)h, size);
 }
 
 void

Copied and modified: stable/10/sys/arm/arm/devmap.c (from r257648, 
head/sys/arm/arm/devmap.c)
==============================================================================
--- head/sys/arm/arm/devmap.c   Mon Nov  4 19:44:37 2013        (r257648, copy 
source)
+++ stable/10/sys/arm/arm/devmap.c      Fri Dec 13 23:56:53 2013        
(r259364)
@@ -38,18 +38,42 @@ __FBSDID("$FreeBSD$");
 #include <vm/pmap.h>
 #include <machine/devmap.h>
 
-static const struct pmap_devmap *devmap_table;
+static const struct arm_devmap_entry *devmap_table;
 
 /*
- * Map all of the static regions in the devmap table, and remember
- * the devmap table so other parts of the kernel can do lookups later.
+ * Register the given table as the one to use in arm_devmap_bootstrap().
  */
 void
-pmap_devmap_bootstrap(vm_offset_t l1pt, const struct pmap_devmap *table)
+arm_devmap_register_table(const struct arm_devmap_entry *table)
 {
-       const struct pmap_devmap *pd;
 
        devmap_table = table;
+}
+
+/*
+ * Map all of the static regions in the devmap table, and remember the devmap
+ * table so the mapdev, ptov, and vtop functions can do lookups later.
+ *
+ * If a non-NULL table pointer is given it is used unconditionally, otherwise
+ * the previously-registered table is used.  This smooths transition from 
legacy
+ * code that fills in a local table then calls this function passing that 
table,
+ * and newer code that uses arm_devmap_register_table() in platform-specific
+ * code, then lets the common initarm() call this function with a NULL pointer.
+ */
+void
+arm_devmap_bootstrap(vm_offset_t l1pt, const struct arm_devmap_entry *table)
+{
+       const struct arm_devmap_entry *pd;
+
+       /*
+        * If given a table pointer, use it, else ensure a table was previously
+        * registered.  This happens early in boot, and there's a good chance
+        * the panic message won't be seen, but there's not much we can do.
+        */
+       if (table != NULL)
+               devmap_table = table;
+       else if (devmap_table == NULL)
+               panic("arm_devmap_bootstrap: No devmap table registered.");
 
        for (pd = devmap_table; pd->pd_size != 0; ++pd) {
                pmap_map_chunk(l1pt, pd->pd_va, pd->pd_pa, pd->pd_size,
@@ -64,7 +88,7 @@ pmap_devmap_bootstrap(vm_offset_t l1pt, 
 void *
 arm_devmap_ptov(vm_paddr_t pa, vm_size_t size)
 {
-       const struct pmap_devmap *pd;
+       const struct arm_devmap_entry *pd;
 
        if (devmap_table == NULL)
                return (NULL);
@@ -84,7 +108,7 @@ arm_devmap_ptov(vm_paddr_t pa, vm_size_t
 vm_paddr_t
 arm_devmap_vtop(void * vpva, vm_size_t size)
 {
-       const struct pmap_devmap *pd;
+       const struct arm_devmap_entry *pd;
        vm_offset_t va;
 
        if (devmap_table == NULL)

Modified: stable/10/sys/arm/arm/machdep.c
==============================================================================
--- stable/10/sys/arm/arm/machdep.c     Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/arm/machdep.c     Fri Dec 13 23:56:53 2013        
(r259364)
@@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/armreg.h>
 #include <machine/atags.h>
 #include <machine/cpu.h>
+#include <machine/devmap.h>
 #include <machine/frame.h>
 #include <machine/machdep.h>
 #include <machine/md_var.h>
@@ -158,7 +159,6 @@ struct pv_addr undstack;
 struct pv_addr abtstack;
 static struct pv_addr kernelstack;
 
-const struct pmap_devmap *pmap_devmap_bootstrap_table;
 #endif
 
 #if defined(LINUX_BOOT_ABI)
@@ -1417,7 +1417,7 @@ initarm(struct arm_boot_params *abp)
 
        /* Map pmap_devmap[] entries */
        err_devmap = platform_devmap_init();
-       pmap_devmap_bootstrap(l1pagetable, pmap_devmap_bootstrap_table);
+       arm_devmap_bootstrap(l1pagetable, NULL);
 
        cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2)) | 
DOMAIN_CLIENT);
        pmap_pa = kernel_l1pt.pv_pa;

Modified: stable/10/sys/arm/arm/pmap-v6.c
==============================================================================
--- stable/10/sys/arm/arm/pmap-v6.c     Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/arm/pmap-v6.c     Fri Dec 13 23:56:53 2013        
(r259364)
@@ -137,7 +137,9 @@
 /*
  * Special compilation symbols
  * PMAP_DEBUG           - Build in pmap_debug_level code
- */
+ *
+ * Note that pmap_mapdev() and pmap_unmapdev() are implemented in arm/devmap.c
+*/
 /* Include header files */
 
 #include "opt_vm.h"
@@ -2424,6 +2426,17 @@ pmap_kenter_nocache(vm_offset_t va, vm_p
 }
 
 void
+pmap_kenter_device(vm_offset_t va, vm_paddr_t pa)
+{
+
+       /*
+        * XXX - Need a way for kenter_internal to handle PTE_DEVICE mapping as
+        * a potentially different thing than PTE_NOCACHE.
+        */
+       pmap_kenter_internal(va, pa, 0);
+}
+
+void
 pmap_kenter_user(vm_offset_t va, vm_paddr_t pa)
 {
 
@@ -5008,36 +5021,6 @@ pmap_align_superpage(vm_object_t object,
 {
 }
 
-
-/*
- * Map a set of physical memory pages into the kernel virtual
- * address space. Return a pointer to where it is mapped. This
- * routine is intended to be used for mapping device memory,
- * NOT real memory.
- */
-void *
-pmap_mapdev(vm_offset_t pa, vm_size_t size)
-{
-       vm_offset_t va, tmpva, offset;
-
-       offset = pa & PAGE_MASK;
-       size = roundup(size, PAGE_SIZE);
-
-       GIANT_REQUIRED;
-
-       va = kva_alloc(size);
-       if (!va)
-               panic("pmap_mapdev: Couldn't alloc kernel virtual memory");
-       for (tmpva = va; size > 0;) {
-               pmap_kenter_internal(tmpva, pa, 0);
-               size -= PAGE_SIZE;
-               tmpva += PAGE_SIZE;
-               pa += PAGE_SIZE;
-       }
-
-       return ((void *)(va + offset));
-}
-
 /*
  * pmap_map_section:
  *
@@ -5220,86 +5203,6 @@ pmap_map_chunk(vm_offset_t l1pt, vm_offs
 
 }
 
-/********************** Static device map routines ***************************/
-
-static const struct pmap_devmap *pmap_devmap_table;
-
-/*
- * Register the devmap table.  This is provided in case early console
- * initialization needs to register mappings created by bootstrap code
- * before pmap_devmap_bootstrap() is called.
- */
-void
-pmap_devmap_register(const struct pmap_devmap *table)
-{
-
-       pmap_devmap_table = table;
-}
-
-/*
- * Map all of the static regions in the devmap table, and remember
- * the devmap table so other parts of the kernel can look up entries
- * later.
- */
-void
-pmap_devmap_bootstrap(vm_offset_t l1pt, const struct pmap_devmap *table)
-{
-       int i;
-
-       pmap_devmap_table = table;
-
-       for (i = 0; pmap_devmap_table[i].pd_size != 0; i++) {
-#ifdef VERBOSE_INIT_ARM
-               printf("devmap: %08x -> %08x @ %08x\n",
-                   pmap_devmap_table[i].pd_pa,
-                   pmap_devmap_table[i].pd_pa +
-                       pmap_devmap_table[i].pd_size - 1,
-                   pmap_devmap_table[i].pd_va);
-#endif
-               pmap_map_chunk(l1pt, pmap_devmap_table[i].pd_va,
-                   pmap_devmap_table[i].pd_pa,
-                   pmap_devmap_table[i].pd_size,
-                   pmap_devmap_table[i].pd_prot,
-                   pmap_devmap_table[i].pd_cache);
-       }
-}
-
-const struct pmap_devmap *
-pmap_devmap_find_pa(vm_paddr_t pa, vm_size_t size)
-{
-       int i;
-
-       if (pmap_devmap_table == NULL)
-               return (NULL);
-
-       for (i = 0; pmap_devmap_table[i].pd_size != 0; i++) {
-               if (pa >= pmap_devmap_table[i].pd_pa &&
-                   pa + size <= pmap_devmap_table[i].pd_pa +
-                                pmap_devmap_table[i].pd_size)
-                       return (&pmap_devmap_table[i]);
-       }
-
-       return (NULL);
-}
-
-const struct pmap_devmap *
-pmap_devmap_find_va(vm_offset_t va, vm_size_t size)
-{
-       int i;
-
-       if (pmap_devmap_table == NULL)
-               return (NULL);
-
-       for (i = 0; pmap_devmap_table[i].pd_size != 0; i++) {
-               if (va >= pmap_devmap_table[i].pd_va &&
-                   va + size <= pmap_devmap_table[i].pd_va +
-                                pmap_devmap_table[i].pd_size)
-                       return (&pmap_devmap_table[i]);
-       }
-
-       return (NULL);
-}
-
 int
 pmap_dmap_iscurrent(pmap_t pmap)
 {

Modified: stable/10/sys/arm/arm/pmap.c
==============================================================================
--- stable/10/sys/arm/arm/pmap.c        Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/arm/pmap.c        Fri Dec 13 23:56:53 2013        
(r259364)
@@ -134,6 +134,8 @@
 /*
  * Special compilation symbols
  * PMAP_DEBUG           - Build in pmap_debug_level code
+ *
+ * Note that pmap_mapdev() and pmap_unmapdev() are implemented in arm/devmap.c
  */
 /* Include header files */
 
@@ -2842,6 +2844,17 @@ pmap_kenter_nocache(vm_offset_t va, vm_p
 }
 
 void
+pmap_kenter_device(vm_offset_t va, vm_paddr_t pa)
+{
+
+       /*
+        * XXX - Need a way for kenter_internal to handle PTE_DEVICE mapping as
+        * a potentially different thing than PTE_NOCACHE.
+        */
+       pmap_kenter_internal(va, pa, 0);
+}
+
+void
 pmap_kenter_user(vm_offset_t va, vm_paddr_t pa)
 {
 
@@ -4690,36 +4703,6 @@ pmap_align_superpage(vm_object_t object,
 {
 }
 
-
-/*
- * Map a set of physical memory pages into the kernel virtual
- * address space. Return a pointer to where it is mapped. This
- * routine is intended to be used for mapping device memory,
- * NOT real memory.
- */
-void *
-pmap_mapdev(vm_offset_t pa, vm_size_t size)
-{
-       vm_offset_t va, tmpva, offset;
-       
-       offset = pa & PAGE_MASK;
-       size = roundup(size, PAGE_SIZE);
-       
-       GIANT_REQUIRED;
-       
-       va = kva_alloc(size);
-       if (!va)
-               panic("pmap_mapdev: Couldn't alloc kernel virtual memory");
-       for (tmpva = va; size > 0;) {
-               pmap_kenter_internal(tmpva, pa, 0);
-               size -= PAGE_SIZE;
-               tmpva += PAGE_SIZE;
-               pa += PAGE_SIZE;
-       }
-       
-       return ((void *)(va + offset));
-}
-
 #define BOOTSTRAP_DEBUG
 
 /*
@@ -4940,86 +4923,6 @@ pmap_map_chunk(vm_offset_t l1pt, vm_offs
 
 }
 
-/********************** Static device map routines ***************************/
-
-static const struct pmap_devmap *pmap_devmap_table;
-
-/*
- * Register the devmap table.  This is provided in case early console
- * initialization needs to register mappings created by bootstrap code
- * before pmap_devmap_bootstrap() is called.
- */
-void
-pmap_devmap_register(const struct pmap_devmap *table)
-{
-
-       pmap_devmap_table = table;
-}
-
-/*
- * Map all of the static regions in the devmap table, and remember
- * the devmap table so other parts of the kernel can look up entries
- * later.
- */
-void
-pmap_devmap_bootstrap(vm_offset_t l1pt, const struct pmap_devmap *table)
-{
-       int i;
-
-       pmap_devmap_table = table;
-
-       for (i = 0; pmap_devmap_table[i].pd_size != 0; i++) {
-#ifdef VERBOSE_INIT_ARM
-               printf("devmap: %08x -> %08x @ %08x\n",
-                   pmap_devmap_table[i].pd_pa,
-                   pmap_devmap_table[i].pd_pa +
-                       pmap_devmap_table[i].pd_size - 1,
-                   pmap_devmap_table[i].pd_va);
-#endif
-               pmap_map_chunk(l1pt, pmap_devmap_table[i].pd_va,
-                   pmap_devmap_table[i].pd_pa,
-                   pmap_devmap_table[i].pd_size,
-                   pmap_devmap_table[i].pd_prot,
-                   pmap_devmap_table[i].pd_cache);
-       }
-}
-
-const struct pmap_devmap *
-pmap_devmap_find_pa(vm_paddr_t pa, vm_size_t size)
-{
-       int i;
-
-       if (pmap_devmap_table == NULL)
-               return (NULL);
-
-       for (i = 0; pmap_devmap_table[i].pd_size != 0; i++) {
-               if (pa >= pmap_devmap_table[i].pd_pa &&
-                   pa + size <= pmap_devmap_table[i].pd_pa +
-                                pmap_devmap_table[i].pd_size)
-                       return (&pmap_devmap_table[i]);
-       }
-
-       return (NULL);
-}
-
-const struct pmap_devmap *
-pmap_devmap_find_va(vm_offset_t va, vm_size_t size)
-{
-       int i;
-
-       if (pmap_devmap_table == NULL)
-               return (NULL);
-
-       for (i = 0; pmap_devmap_table[i].pd_size != 0; i++) {
-               if (va >= pmap_devmap_table[i].pd_va &&
-                   va + size <= pmap_devmap_table[i].pd_va +
-                                pmap_devmap_table[i].pd_size)
-                       return (&pmap_devmap_table[i]);
-       }
-
-       return (NULL);
-}
-
 void
 pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma)
 {

Modified: stable/10/sys/arm/at91/at91.c
==============================================================================
--- stable/10/sys/arm/at91/at91.c       Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/at91/at91.c       Fri Dec 13 23:56:53 2013        
(r259364)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 
 #define        _ARM32_BUS_DMA_PRIVATE
 #include <machine/bus.h>
+#include <machine/devmap.h>
 #include <machine/intr.h>
 
 #include <arm/at91/at91var.h>
@@ -52,7 +53,7 @@ static struct at91_softc *at91_softc;
 
 static void at91_eoi(void *);
 
-extern const struct pmap_devmap at91_devmap[];
+extern const struct arm_devmap_entry at91_devmap[];
 
 uint32_t at91_master_clock;
 
@@ -258,7 +259,7 @@ static int
 at91_attach(device_t dev)
 {
        struct at91_softc *sc = device_get_softc(dev);
-       const struct pmap_devmap *pdevmap;
+       const struct arm_devmap_entry *pdevmap;
        int i;
 
        at91_softc = sc;

Modified: stable/10/sys/arm/at91/at91_machdep.c
==============================================================================
--- stable/10/sys/arm/at91/at91_machdep.c       Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/at91/at91_machdep.c       Fri Dec 13 23:56:53 2013        
(r259364)
@@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
 #include <vm/vm_map.h>
+#include <machine/devmap.h>
 #include <machine/vmparam.h>
 #include <machine/pcb.h>
 #include <machine/undefined.h>
@@ -128,7 +129,7 @@ struct pv_addr abtstack;
 struct pv_addr kernelstack;
 
 /* Static device mappings. */
-const struct pmap_devmap at91_devmap[] = {
+const struct arm_devmap_entry at91_devmap[] = {
        /*
         * Map the on-board devices VA == PA so that we can access them
         * with the MMU on or off.
@@ -566,7 +567,7 @@ initarm(struct arm_boot_params *abp)
                    VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
        }
 
-       pmap_devmap_bootstrap(l1pagetable, at91_devmap);
+       arm_devmap_bootstrap(l1pagetable, at91_devmap);
        cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2)) | 
DOMAIN_CLIENT);
        setttb(kernel_l1pt.pv_pa);
        cpu_tlb_flushID();

Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
==============================================================================
--- stable/10/sys/arm/broadcom/bcm2835/bcm2835_machdep.c        Fri Dec 13 
23:07:22 2013        (r259363)
+++ stable/10/sys/arm/broadcom/bcm2835/bcm2835_machdep.c        Fri Dec 13 
23:56:53 2013        (r259364)
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/pmap.h>
 
 #include <machine/bus.h>
+#include <machine/devmap.h>
 #include <machine/machdep.h>
 
 #include <dev/fdt/fdt_common.h>
@@ -93,7 +94,7 @@ initarm_late_init(void)
 }
 
 #define FDT_DEVMAP_MAX (2)             // FIXME
-static struct pmap_devmap fdt_devmap[FDT_DEVMAP_MAX] = {
+static struct arm_devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = {
        { 0, 0, 0, 0, 0, }
 };
 
@@ -113,7 +114,7 @@ platform_devmap_init(void)
        fdt_devmap[i].pd_cache = PTE_DEVICE;
        i++;
 
-       pmap_devmap_bootstrap_table = &fdt_devmap[0];
+       arm_devmap_register_table(&fdt_devmap[0]);
        return (0);
 }
 

Modified: stable/10/sys/arm/econa/econa_machdep.c
==============================================================================
--- stable/10/sys/arm/econa/econa_machdep.c     Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/econa/econa_machdep.c     Fri Dec 13 23:56:53 2013        
(r259364)
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
 #include <vm/vm_map.h>
+#include <machine/devmap.h>
 #include <machine/vmparam.h>
 #include <machine/pcb.h>
 #include <machine/undefined.h>
@@ -108,7 +109,7 @@ struct pv_addr abtstack;
 struct pv_addr kernelstack;
 
 /* Static device mappings. */
-static const struct pmap_devmap econa_devmap[] = {
+static const struct arm_devmap_entry econa_devmap[] = {
        {
                /*
                 * This maps DDR SDRAM
@@ -275,7 +276,7 @@ initarm(struct arm_boot_params *abp)
                    VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
        }
 
-       pmap_devmap_bootstrap(l1pagetable, econa_devmap);
+       arm_devmap_bootstrap(l1pagetable, econa_devmap);
        cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
        setttb(kernel_l1pt.pv_pa);
        cpu_tlb_flushID();

Modified: stable/10/sys/arm/freescale/imx/imx6_machdep.c
==============================================================================
--- stable/10/sys/arm/freescale/imx/imx6_machdep.c      Fri Dec 13 23:07:22 
2013        (r259363)
+++ stable/10/sys/arm/freescale/imx/imx6_machdep.c      Fri Dec 13 23:56:53 
2013        (r259364)
@@ -34,9 +34,12 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/reboot.h>
 
-#include <machine/bus.h>
 #include <vm/vm.h>
 #include <vm/pmap.h>
+
+#include <machine/bus.h>
+#include <machine/devmap.h>
+
 #include <arm/freescale/imx/imx6_anatopreg.h>
 #include <arm/freescale/imx/imx6_anatopvar.h>
 #include <arm/freescale/imx/imx_machdep.h>
@@ -112,7 +115,6 @@ cpu_reset(void)
  */
 u_int imx_soc_type()
 {
-       const struct pmap_devmap *pd;
        uint32_t digprog, hwsoc;
        uint32_t *pcr;
        const uint32_t HWSOC_MX6SL   = 0x60;
@@ -131,10 +133,8 @@ u_int imx_soc_type()
                    IMX6_ANALOG_DIGPROG_SOCTYPE_SHIFT;
                /*printf("digprog = 0x%08x\n", digprog);*/
                if (hwsoc == HWSOC_MX6DL) {
-                       pd = pmap_devmap_find_pa(SCU_CONFIG_PHYSADDR, 4);
-                       if (pd != NULL) {
-                               pcr = (uint32_t *)(pd->pd_va + 
-                                   (SCU_CONFIG_PHYSADDR - pd->pd_pa));
+                       pcr = arm_devmap_ptov(SCU_CONFIG_PHYSADDR, 4);
+                       if (pcr != NULL) {
                                /*printf("scu config = 0x%08x\n", *pcr);*/
                                if ((*pcr & 0x03) == 0) {
                                        hwsoc = HWSOC_MX6SOLO;

Modified: stable/10/sys/arm/freescale/imx/imx_machdep.c
==============================================================================
--- stable/10/sys/arm/freescale/imx/imx_machdep.c       Fri Dec 13 23:07:22 
2013        (r259363)
+++ stable/10/sys/arm/freescale/imx/imx_machdep.c       Fri Dec 13 23:56:53 
2013        (r259364)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 
 #include <machine/armreg.h>
 #include <machine/bus.h>
+#include <machine/devmap.h>
 #include <machine/machdep.h>
 
 #include <arm/freescale/imx/imx_machdep.h>
@@ -46,14 +47,14 @@ __FBSDID("$FreeBSD$");
 
 #define        IMX_MAX_DEVMAP_ENTRIES  8
 
-static struct pmap_devmap devmap_entries[IMX_MAX_DEVMAP_ENTRIES];
+static struct arm_devmap_entry devmap_entries[IMX_MAX_DEVMAP_ENTRIES];
 static u_int             devmap_idx;
 static vm_offset_t       devmap_vaddr = ARM_VECTORS_HIGH;
 
 void
 imx_devmap_addentry(vm_paddr_t pa, vm_size_t sz) 
 {
-       struct pmap_devmap *m;
+       struct arm_devmap_entry *m;
 
        /*
         * The last table entry is the all-zeroes end-of-table marker.  If we're
@@ -102,7 +103,7 @@ initarm_lastaddr(void)
         */
        imx_devmap_init();
 
-       pmap_devmap_bootstrap_table = devmap_entries;
+       arm_devmap_register_table(devmap_entries);
 
        return (devmap_vaddr);
 }
@@ -127,7 +128,7 @@ initarm_gpio_init(void)
 void
 initarm_late_init(void)
 {
-       struct pmap_devmap *m;
+       struct arm_devmap_entry *m;
 
        /*
         * We did the static devmap setup earlier, during initarm_lastaddr(),
@@ -168,7 +169,6 @@ bus_dma_get_range_nb(void)
 void
 imx_wdog_cpu_reset(vm_offset_t wdcr_physaddr)
 {
-       const struct pmap_devmap *pd;
        volatile uint16_t * pcr;
 
        /*
@@ -178,10 +178,9 @@ imx_wdog_cpu_reset(vm_offset_t wdcr_phys
         * reset) bit being set in the watchdog status register after the reset.
         * This is how software can distinguish a reset from a wdog timeout.
         */
-       if ((pd = pmap_devmap_find_pa(wdcr_physaddr, 2)) == NULL) {
+       if ((pcr = arm_devmap_ptov(wdcr_physaddr, sizeof(*pcr))) == NULL) {
                printf("cpu_reset() can't find its control register... locking 
up now.");
        } else {
-               pcr = (uint16_t *)(pd->pd_va + (wdcr_physaddr - pd->pd_pa));
                *pcr = WDOG_CR_WDE;
        }
        for (;;)

Copied and modified: stable/10/sys/arm/include/devmap.h (from r257648, 
head/sys/arm/include/devmap.h)
==============================================================================
--- head/sys/arm/include/devmap.h       Mon Nov  4 19:44:37 2013        
(r257648, copy source)
+++ stable/10/sys/arm/include/devmap.h  Fri Dec 13 23:56:53 2013        
(r259364)
@@ -30,6 +30,33 @@
 #define        _MACHINE_DEVMAP_H_
 
 /*
+ * This structure is used by MD code to describe static mappings of devices
+ * which are established as part of bringing up the MMU early in the boot.
+ */
+struct arm_devmap_entry {
+       vm_offset_t     pd_va;          /* virtual address */
+       vm_paddr_t      pd_pa;          /* physical address */
+       vm_size_t       pd_size;        /* size of region */
+       vm_prot_t       pd_prot;        /* protection code */
+       int             pd_cache;       /* cache attributes */
+};
+
+/*
+ * Register a platform-local table to be bootstrapped by the generic
+ * initarm() in arm/machdep.c.  This is used by newer code that allocates and
+ * fills in its own local table but does not have its own initarm() routine.
+ */
+void arm_devmap_register_table(const struct arm_devmap_entry * _table);
+
+/*
+ * Directly process a table; called from initarm() of older platforms that 
don't
+ * use the generic initarm() in arm/machdep.c.  If the table pointer is NULL,
+ * this will use the table installed previously by arm_devmap_register_table().
+ */
+void arm_devmap_bootstrap(vm_offset_t _l1pt, 
+    const struct arm_devmap_entry *_table);
+
+/*
  * Routines to translate between virtual and physical addresses within a region
  * that is static-mapped by the devmap code.  If the given address range isn't
  * static-mapped, then ptov returns NULL and vtop returns 
DEVMAP_PADDR_NOTFOUND.

Modified: stable/10/sys/arm/include/fdt.h
==============================================================================
--- stable/10/sys/arm/include/fdt.h     Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/include/fdt.h     Fri Dec 13 23:56:53 2013        
(r259364)
@@ -56,8 +56,10 @@ struct mem_region {
        vm_size_t       mr_size;
 };
 
-int fdt_localbus_devmap(phandle_t, struct pmap_devmap *, int, int *);
-int fdt_pci_devmap(phandle_t, struct pmap_devmap *devmap, vm_offset_t,
+struct arm_devmap_entry;
+
+int fdt_localbus_devmap(phandle_t, struct arm_devmap_entry *, int, int *);
+int fdt_pci_devmap(phandle_t, struct arm_devmap_entry *devmap, vm_offset_t,
     vm_offset_t);
 
 #endif /* _MACHINE_FDT_H_ */

Modified: stable/10/sys/arm/include/machdep.h
==============================================================================
--- stable/10/sys/arm/include/machdep.h Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/include/machdep.h Fri Dec 13 23:56:53 2013        
(r259364)
@@ -43,9 +43,6 @@ int platform_devmap_init(void);
 void board_set_serial(uint64_t);
 void board_set_revision(uint32_t);
 
-/* Needs to be initialised by platform_devmap_init */
-extern const struct pmap_devmap *pmap_devmap_bootstrap_table;
-
 /* Setup standard arrays */
 void arm_dump_avail_init( vm_offset_t memsize, size_t max);
 

Modified: stable/10/sys/arm/include/pmap.h
==============================================================================
--- stable/10/sys/arm/include/pmap.h    Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/include/pmap.h    Fri Dec 13 23:56:53 2013        
(r259364)
@@ -254,6 +254,7 @@ void        pmap_bootstrap(vm_offset_t firstadd
 int    pmap_change_attr(vm_offset_t, vm_size_t, int);
 void   pmap_kenter(vm_offset_t va, vm_paddr_t pa);
 void   pmap_kenter_nocache(vm_offset_t va, vm_paddr_t pa);
+void   pmap_kenter_device(vm_offset_t va, vm_paddr_t pa);
 void   *pmap_kenter_temp(vm_paddr_t pa, int i);
 void   pmap_kenter_user(vm_offset_t va, vm_paddr_t pa);
 vm_paddr_t pmap_kextract(vm_offset_t va);
@@ -687,24 +688,6 @@ void       pmap_use_minicache(vm_offset_t, vm_
 
 void vector_page_setprot(int);
 
-/*
- * This structure is used by machine-dependent code to describe
- * static mappings of devices, created at bootstrap time.
- */
-struct pmap_devmap {
-       vm_offset_t     pd_va;          /* virtual address */
-       vm_paddr_t      pd_pa;          /* physical address */
-       vm_size_t       pd_size;        /* size of region */
-       vm_prot_t       pd_prot;        /* protection code */
-       int             pd_cache;       /* cache attributes */
-};
-
-const struct pmap_devmap *pmap_devmap_find_pa(vm_paddr_t, vm_size_t);
-const struct pmap_devmap *pmap_devmap_find_va(vm_offset_t, vm_size_t);
-
-void   pmap_devmap_bootstrap(vm_offset_t, const struct pmap_devmap *);
-void   pmap_devmap_register(const struct pmap_devmap *);
-
 #define SECTION_CACHE  0x1
 #define SECTION_PT     0x2
 void   pmap_kenter_section(vm_offset_t, vm_paddr_t, int flags);

Modified: stable/10/sys/arm/lpc/lpc_machdep.c
==============================================================================
--- stable/10/sys/arm/lpc/lpc_machdep.c Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/lpc/lpc_machdep.c Fri Dec 13 23:56:53 2013        
(r259364)
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/pmap.h>
 
 #include <machine/bus.h>
+#include <machine/devmap.h>
 #include <machine/machdep.h>
 
 #include <arm/lpc/lpcreg.h>
@@ -85,7 +86,7 @@ initarm_late_init(void)
 }
 
 #define FDT_DEVMAP_MAX (1 + 2 + 1 + 1)
-static struct pmap_devmap fdt_devmap[FDT_DEVMAP_MAX] = {
+static struct arm_devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = {
        { 0, 0, 0, 0, 0, }
 };
 
@@ -105,7 +106,7 @@ platform_devmap_init(void)
        fdt_devmap[0].pd_prot = VM_PROT_READ | VM_PROT_WRITE;
        fdt_devmap[0].pd_cache = PTE_NOCACHE;
        
-       pmap_devmap_bootstrap_table = &fdt_devmap[0];
+       arm_devmap_register_table(&fdt_devmap[0]);
        return (0);
 }
 

Modified: stable/10/sys/arm/mv/mv_localbus.c
==============================================================================
--- stable/10/sys/arm/mv/mv_localbus.c  Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/mv/mv_localbus.c  Fri Dec 13 23:56:53 2013        
(r259364)
@@ -37,6 +37,9 @@ __FBSDID("$FreeBSD$");
 #include <sys/rman.h>
 #include <sys/malloc.h>
 
+#include <vm/vm.h>
+
+#include <machine/devmap.h>
 #include <machine/fdt.h>
 
 #include <dev/ofw/ofw_bus.h>
@@ -380,7 +383,7 @@ localbus_get_devinfo(device_t bus, devic
 }
 
 int
-fdt_localbus_devmap(phandle_t dt_node, struct pmap_devmap *fdt_devmap,
+fdt_localbus_devmap(phandle_t dt_node, struct arm_devmap_entry *fdt_devmap,
     int banks_max_num, int *banks_added)
 {
        pcell_t ranges[MV_LOCALBUS_MAX_BANKS * MV_LOCALBUS_MAX_BANK_CELLS];

Modified: stable/10/sys/arm/mv/mv_machdep.c
==============================================================================
--- stable/10/sys/arm/mv/mv_machdep.c   Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/mv/mv_machdep.c   Fri Dec 13 23:56:53 2013        
(r259364)
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/pmap.h>
 
 #include <machine/bus.h>
+#include <machine/devmap.h>
 #include <machine/machdep.h>
 
 #include <arm/mv/mvreg.h>      /* XXX */
@@ -245,12 +246,12 @@ initarm_late_init(void)
 }
 
 #define FDT_DEVMAP_MAX (MV_WIN_CPU_MAX + 2)
-static struct pmap_devmap fdt_devmap[FDT_DEVMAP_MAX] = {
+static struct arm_devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = {
        { 0, 0, 0, 0, 0, }
 };
 
 static int
-platform_sram_devmap(struct pmap_devmap *map)
+platform_sram_devmap(struct arm_devmap_entry *map)
 {
 #if !defined(SOC_MV_ARMADAXP)
        phandle_t child, root;
@@ -295,10 +296,10 @@ out:
  * real implementation of this function in dev/fdt/fdt_pci.c overrides the weak
  * alias defined here.
  */
-int mv_default_fdt_pci_devmap(phandle_t node, struct pmap_devmap *devmap,
+int mv_default_fdt_pci_devmap(phandle_t node, struct arm_devmap_entry *devmap,
     vm_offset_t io_va, vm_offset_t mem_va);
 int
-mv_default_fdt_pci_devmap(phandle_t node, struct pmap_devmap *devmap,
+mv_default_fdt_pci_devmap(phandle_t node, struct arm_devmap_entry *devmap,
     vm_offset_t io_va, vm_offset_t mem_va)
 {
 
@@ -322,7 +323,7 @@ platform_devmap_init(void)
        int i, num_mapped;
 
        i = 0;
-       pmap_devmap_bootstrap_table = &fdt_devmap[0];
+       arm_devmap_register_table(&fdt_devmap[0]);
 
        /*
         * IMMR range.

Modified: stable/10/sys/arm/mv/mvvar.h
==============================================================================
--- stable/10/sys/arm/mv/mvvar.h        Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/mv/mvvar.h        Fri Dec 13 23:56:53 2013        
(r259364)
@@ -66,7 +66,6 @@ struct decode_win {
        vm_paddr_t      remap;
 };
 
-extern const struct pmap_devmap pmap_devmap[];
 extern const struct gpio_config mv_gpio_config[];
 extern const struct decode_win *cpu_wins;
 extern const struct decode_win *idma_wins;

Modified: stable/10/sys/arm/rockchip/rk30xx_machdep.c
==============================================================================
--- stable/10/sys/arm/rockchip/rk30xx_machdep.c Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/rockchip/rk30xx_machdep.c Fri Dec 13 23:56:53 2013        
(r259364)
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 
 #include <machine/armreg.h>
 #include <machine/bus.h>
+#include <machine/devmap.h>
 #include <machine/machdep.h>
 
 #include <dev/fdt/fdt_common.h>
@@ -73,7 +74,7 @@ initarm_late_init(void)
 }
 
 #define FDT_DEVMAP_MAX         (1 + 2 + 1 + 1)
-static struct pmap_devmap fdt_devmap[FDT_DEVMAP_MAX] = {
+static struct arm_devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = {
        { 0, 0, 0, 0, 0, }
 };
 
@@ -92,8 +93,8 @@ platform_devmap_init(void)
        fdt_devmap[i].pd_cache = PTE_DEVICE;
        i++;
 
-       pmap_devmap_bootstrap_table = &fdt_devmap[0];
-
+       arm_devmap_register_table(&fdt_devmap[0]);
+       
        return (0);
 }
 

Modified: stable/10/sys/arm/s3c2xx0/s3c24x0_machdep.c
==============================================================================
--- stable/10/sys/arm/s3c2xx0/s3c24x0_machdep.c Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/s3c2xx0/s3c24x0_machdep.c Fri Dec 13 23:56:53 2013        
(r259364)
@@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
 #include <vm/vm_map.h>
+#include <machine/devmap.h>
 #include <machine/vmparam.h>
 #include <machine/pcb.h>
 #include <machine/undefined.h>
@@ -126,7 +127,7 @@ struct pv_addr kernelstack;
 #define        _S(s)   (((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))
 
 /* Static device mappings. */
-static const struct pmap_devmap s3c24x0_devmap[] = {
+static const struct arm_devmap_entry s3c24x0_devmap[] = {
        /*
         * Map the devices we need early on.
         */
@@ -324,7 +325,7 @@ initarm(struct arm_boot_params *abp)
                    VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
        }
 
-       pmap_devmap_bootstrap(l1pagetable, s3c24x0_devmap);
+       arm_devmap_bootstrap(l1pagetable, s3c24x0_devmap);
 
        cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
        setttb(kernel_l1pt.pv_pa);

Modified: stable/10/sys/arm/sa11x0/assabet_machdep.c
==============================================================================
--- stable/10/sys/arm/sa11x0/assabet_machdep.c  Fri Dec 13 23:07:22 2013        
(r259363)
+++ stable/10/sys/arm/sa11x0/assabet_machdep.c  Fri Dec 13 23:56:53 2013        
(r259364)
@@ -80,6 +80,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to