summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2013-12-13 23:56:53 +0000
committerian <ian@FreeBSD.org>2013-12-13 23:56:53 +0000
commiteae48ec05ef90176b68b7b5c7ebf3e4c792448aa (patch)
tree95426e39c61df08e259d54ab1d73d5aefa98c198
parent689fd5c39017daa19a00a6cce247ad10ba00c1e7 (diff)
downloadFreeBSD-src-eae48ec05ef90176b68b7b5c7ebf3e4c792448aa.zip
FreeBSD-src-eae48ec05ef90176b68b7b5c7ebf3e4c792448aa.tar.gz
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).
-rw-r--r--sys/arm/allwinner/a10_machdep.c5
-rw-r--r--sys/arm/arm/bus_space_generic.c65
-rw-r--r--sys/arm/arm/devmap.c174
-rw-r--r--sys/arm/arm/machdep.c4
-rw-r--r--sys/arm/arm/pmap-v6.c125
-rw-r--r--sys/arm/arm/pmap.c123
-rw-r--r--sys/arm/at91/at91.c5
-rw-r--r--sys/arm/at91/at91_machdep.c5
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_machdep.c5
-rw-r--r--sys/arm/econa/econa_machdep.c5
-rw-r--r--sys/arm/freescale/imx/imx6_machdep.c12
-rw-r--r--sys/arm/freescale/imx/imx_machdep.c13
-rw-r--r--sys/arm/include/devmap.h73
-rw-r--r--sys/arm/include/fdt.h6
-rw-r--r--sys/arm/include/machdep.h3
-rw-r--r--sys/arm/include/pmap.h19
-rw-r--r--sys/arm/lpc/lpc_machdep.c5
-rw-r--r--sys/arm/mv/mv_localbus.c5
-rw-r--r--sys/arm/mv/mv_machdep.c11
-rw-r--r--sys/arm/mv/mvvar.h1
-rw-r--r--sys/arm/rockchip/rk30xx_machdep.c7
-rw-r--r--sys/arm/s3c2xx0/s3c24x0_machdep.c5
-rw-r--r--sys/arm/sa11x0/assabet_machdep.c5
-rw-r--r--sys/arm/samsung/exynos/exynos5_machdep.c5
-rw-r--r--sys/arm/tegra/tegra2_machdep.c5
-rw-r--r--sys/arm/ti/ti_machdep.c5
-rw-r--r--sys/arm/versatile/versatile_machdep.c5
-rw-r--r--sys/arm/xilinx/zy7_machdep.c5
-rw-r--r--sys/arm/xscale/i80321/ep80219_machdep.c5
-rw-r--r--sys/arm/xscale/i80321/iq31244_machdep.c5
-rw-r--r--sys/arm/xscale/i8134x/crb_machdep.c5
-rw-r--r--sys/arm/xscale/ixp425/avila_machdep.c9
-rw-r--r--sys/arm/xscale/pxa/pxa_machdep.c5
-rw-r--r--sys/conf/files.arm1
-rw-r--r--sys/dev/fdt/fdt_pci.c5
35 files changed, 389 insertions, 352 deletions
diff --git a/sys/arm/allwinner/a10_machdep.c b/sys/arm/allwinner/a10_machdep.c
index 90badf2..e9f93e8 100644
--- a/sys/arm/allwinner/a10_machdep.c
+++ b/sys/arm/allwinner/a10_machdep.c
@@ -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);
}
diff --git a/sys/arm/arm/bus_space_generic.c b/sys/arm/arm/bus_space_generic.c
index 19ba73b..551d956 100644
--- a/sys/arm/arm/bus_space_generic.c
+++ b/sys/arm/arm/bus_space_generic.c
@@ -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 rstart, bus_addr_t rend, bus_size_t size,
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
diff --git a/sys/arm/arm/devmap.c b/sys/arm/arm/devmap.c
new file mode 100644
index 0000000..a8819bd
--- /dev/null
+++ b/sys/arm/arm/devmap.c
@@ -0,0 +1,174 @@
+/*-
+ * Copyright (c) 2013 Ian Lepore <ian@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * Routines for mapping device memory.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <vm/vm.h>
+#include <vm/vm_extern.h>
+#include <vm/pmap.h>
+#include <machine/devmap.h>
+
+static const struct arm_devmap_entry *devmap_table;
+
+/*
+ * Register the given table as the one to use in arm_devmap_bootstrap().
+ */
+void
+arm_devmap_register_table(const struct arm_devmap_entry *table)
+{
+
+ 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,
+ pd->pd_prot,pd->pd_cache);
+ }
+}
+
+/*
+ * Look up the given physical address in the static mapping data and return the
+ * corresponding virtual address, or NULL if not found.
+ */
+void *
+arm_devmap_ptov(vm_paddr_t pa, vm_size_t size)
+{
+ const struct arm_devmap_entry *pd;
+
+ if (devmap_table == NULL)
+ return (NULL);
+
+ for (pd = devmap_table; pd->pd_size != 0; ++pd) {
+ if (pa >= pd->pd_pa && pa + size <= pd->pd_pa + pd->pd_size)
+ return ((void *)(pd->pd_va + (pa - pd->pd_pa)));
+ }
+
+ return (NULL);
+}
+
+/*
+ * Look up the given virtual address in the static mapping data and return the
+ * corresponding physical address, or DEVMAP_PADDR_NOTFOUND if not found.
+ */
+vm_paddr_t
+arm_devmap_vtop(void * vpva, vm_size_t size)
+{
+ const struct arm_devmap_entry *pd;
+ vm_offset_t va;
+
+ if (devmap_table == NULL)
+ return (DEVMAP_PADDR_NOTFOUND);
+
+ va = (vm_offset_t)vpva;
+ for (pd = devmap_table; pd->pd_size != 0; ++pd) {
+ if (va >= pd->pd_va && va + size <= pd->pd_va + pd->pd_size)
+ return ((vm_paddr_t)(pd->pd_pa + (va - pd->pd_va)));
+ }
+
+ return (DEVMAP_PADDR_NOTFOUND);
+}
+
+/*
+ * 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;
+ pa = trunc_page(pa);
+ size = round_page(size + offset);
+
+ va = kva_alloc(size);
+ if (!va)
+ panic("pmap_mapdev: Couldn't alloc kernel virtual memory");
+
+ for (tmpva = va; size > 0;) {
+ pmap_kenter_device(tmpva, pa);
+ size -= PAGE_SIZE;
+ tmpva += PAGE_SIZE;
+ pa += PAGE_SIZE;
+ }
+
+ return ((void *)(va + offset));
+}
+
+/*
+ * Unmap device memory and free the kva space.
+ */
+void
+pmap_unmapdev(vm_offset_t va, vm_size_t size)
+{
+ vm_offset_t tmpva, offset;
+
+ offset = va & PAGE_MASK;
+ va = trunc_page(va);
+ size = round_page(size + offset);
+
+ for (tmpva = va; size > 0;) {
+ pmap_kremove(tmpva);
+ size -= PAGE_SIZE;
+ tmpva += PAGE_SIZE;
+ }
+
+ kva_free(va, size);
+}
+
diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c
index 8f77b77..6ab5529 100644
--- a/sys/arm/arm/machdep.c
+++ b/sys/arm/arm/machdep.c
@@ -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;
diff --git a/sys/arm/arm/pmap-v6.c b/sys/arm/arm/pmap-v6.c
index ba3f81b..017aefd 100644
--- a/sys/arm/arm/pmap-v6.c
+++ b/sys/arm/arm/pmap-v6.c
@@ -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_paddr_t pa)
}
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, vm_ooffset_t offset,
{
}
-
-/*
- * 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_offset_t va, vm_offset_t pa,
}
-/********************** 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)
{
diff --git a/sys/arm/arm/pmap.c b/sys/arm/arm/pmap.c
index b3eef01..86db596 100644
--- a/sys/arm/arm/pmap.c
+++ b/sys/arm/arm/pmap.c
@@ -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_paddr_t pa)
}
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, vm_ooffset_t offset,
{
}
-
-/*
- * 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_offset_t va, vm_offset_t pa,
}
-/********************** 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)
{
diff --git a/sys/arm/at91/at91.c b/sys/arm/at91/at91.c
index a3f9556..cceed8a 100644
--- a/sys/arm/at91/at91.c
+++ b/sys/arm/at91/at91.c
@@ -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;
diff --git a/sys/arm/at91/at91_machdep.c b/sys/arm/at91/at91_machdep.c
index f4a9316..f7c21f9 100644
--- a/sys/arm/at91/at91_machdep.c
+++ b/sys/arm/at91/at91_machdep.c
@@ -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();
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
index 2a549a2..dcf8178 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
@@ -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);
}
diff --git a/sys/arm/econa/econa_machdep.c b/sys/arm/econa/econa_machdep.c
index d64e826..0323e7b 100644
--- a/sys/arm/econa/econa_machdep.c
+++ b/sys/arm/econa/econa_machdep.c
@@ -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();
diff --git a/sys/arm/freescale/imx/imx6_machdep.c b/sys/arm/freescale/imx/imx6_machdep.c
index a1bbf4a..d009adc 100644
--- a/sys/arm/freescale/imx/imx6_machdep.c
+++ b/sys/arm/freescale/imx/imx6_machdep.c
@@ -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;
diff --git a/sys/arm/freescale/imx/imx_machdep.c b/sys/arm/freescale/imx/imx_machdep.c
index 8226849..de0eb68 100644
--- a/sys/arm/freescale/imx/imx_machdep.c
+++ b/sys/arm/freescale/imx/imx_machdep.c
@@ -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_physaddr)
* 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 (;;)
diff --git a/sys/arm/include/devmap.h b/sys/arm/include/devmap.h
new file mode 100644
index 0000000..ee16b67
--- /dev/null
+++ b/sys/arm/include/devmap.h
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2013 Ian Lepore <ian@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _MACHINE_DEVMAP_H_
+#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.
+ * The latter implies that you can't vtop just the last byte of physical address
+ * space. This is not as limiting as it might sound, because even if a device
+ * occupies the end of the physical address space, you're only prevented from
+ * doing vtop for that single byte. If you vtop a size bigger than 1 it works.
+ */
+#define DEVMAP_PADDR_NOTFOUND ((vm_paddr_t)(-1))
+
+void * arm_devmap_ptov(vm_paddr_t _pa, vm_size_t _sz);
+vm_paddr_t arm_devmap_vtop(void * _va, vm_size_t _sz);
+
+#endif
diff --git a/sys/arm/include/fdt.h b/sys/arm/include/fdt.h
index bff86d8..0be9927 100644
--- a/sys/arm/include/fdt.h
+++ b/sys/arm/include/fdt.h
@@ -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_ */
diff --git a/sys/arm/include/machdep.h b/sys/arm/include/machdep.h
index c48b0a3..08e9e21 100644
--- a/sys/arm/include/machdep.h
+++ b/sys/arm/include/machdep.h
@@ -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);
diff --git a/sys/arm/include/pmap.h b/sys/arm/include/pmap.h
index ef834aa..9dee28d 100644
--- a/sys/arm/include/pmap.h
+++ b/sys/arm/include/pmap.h
@@ -254,6 +254,7 @@ void pmap_bootstrap(vm_offset_t firstaddr, struct pv_addr *l1pt);
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_size_t);
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);
diff --git a/sys/arm/lpc/lpc_machdep.c b/sys/arm/lpc/lpc_machdep.c
index cb3ab84..576eda4 100644
--- a/sys/arm/lpc/lpc_machdep.c
+++ b/sys/arm/lpc/lpc_machdep.c
@@ -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);
}
diff --git a/sys/arm/mv/mv_localbus.c b/sys/arm/mv/mv_localbus.c
index 09f9348..363a2b7 100644
--- a/sys/arm/mv/mv_localbus.c
+++ b/sys/arm/mv/mv_localbus.c
@@ -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, device_t child)
}
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];
diff --git a/sys/arm/mv/mv_machdep.c b/sys/arm/mv/mv_machdep.c
index 8dfeb7b..5002839 100644
--- a/sys/arm/mv/mv_machdep.c
+++ b/sys/arm/mv/mv_machdep.c
@@ -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.
diff --git a/sys/arm/mv/mvvar.h b/sys/arm/mv/mvvar.h
index 754541f..54abf46 100644
--- a/sys/arm/mv/mvvar.h
+++ b/sys/arm/mv/mvvar.h
@@ -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;
diff --git a/sys/arm/rockchip/rk30xx_machdep.c b/sys/arm/rockchip/rk30xx_machdep.c
index 6496d5e..e4eb162 100644
--- a/sys/arm/rockchip/rk30xx_machdep.c
+++ b/sys/arm/rockchip/rk30xx_machdep.c
@@ -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);
}
diff --git a/sys/arm/s3c2xx0/s3c24x0_machdep.c b/sys/arm/s3c2xx0/s3c24x0_machdep.c
index 1811b52..3fc0f8e 100644
--- a/sys/arm/s3c2xx0/s3c24x0_machdep.c
+++ b/sys/arm/s3c2xx0/s3c24x0_machdep.c
@@ -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);
diff --git a/sys/arm/sa11x0/assabet_machdep.c b/sys/arm/sa11x0/assabet_machdep.c
index 0808798..79014f2 100644
--- a/sys/arm/sa11x0/assabet_machdep.c
+++ b/sys/arm/sa11x0/assabet_machdep.c
@@ -80,6 +80,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>
@@ -134,7 +135,7 @@ struct pv_addr abtstack;
struct pv_addr kernelstack;
/* Static device mappings. */
-static const struct pmap_devmap assabet_devmap[] = {
+static const struct arm_devmap_entry assabet_devmap[] = {
/*
* Map the on-board devices VA == PA so that we can access them
* with the MMU on or off.
@@ -324,7 +325,7 @@ initarm(struct arm_boot_params *abp)
pmap_map_entry(l1pagetable, vector_page, systempage.pv_pa,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
/* Map the statically mapped devices. */
- pmap_devmap_bootstrap(l1pagetable, assabet_devmap);
+ arm_devmap_bootstrap(l1pagetable, assabet_devmap);
pmap_map_chunk(l1pagetable, sa1_cache_clean_addr, 0xf0000000,
CPU_SA110_CACHE_CLEAN_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
diff --git a/sys/arm/samsung/exynos/exynos5_machdep.c b/sys/arm/samsung/exynos/exynos5_machdep.c
index 007bdb5..1c5a879 100644
--- a/sys/arm/samsung/exynos/exynos5_machdep.c
+++ b/sys/arm/samsung/exynos/exynos5_machdep.c
@@ -39,6 +39,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>
@@ -63,7 +64,7 @@ initarm_late_init(void)
}
#define FDT_DEVMAP_MAX (1 + 2 + 1 + 1) /* 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, }
};
@@ -83,7 +84,7 @@ platform_devmap_init(void)
fdt_devmap[i].pd_cache = PTE_NOCACHE;
i++;
- pmap_devmap_bootstrap_table = &fdt_devmap[0];
+ arm_devmap_register_table(&fdt_devmap[0]);
return (0);
}
diff --git a/sys/arm/tegra/tegra2_machdep.c b/sys/arm/tegra/tegra2_machdep.c
index 66fe0a9..92ca04a 100644
--- a/sys/arm/tegra/tegra2_machdep.c
+++ b/sys/arm/tegra/tegra2_machdep.c
@@ -45,6 +45,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>
@@ -123,7 +124,7 @@ initarm_late_init(void)
}
#define FDT_DEVMAP_MAX (1 + 2 + 1 + 1) /* 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, }
};
@@ -141,7 +142,7 @@ platform_devmap_init(void)
fdt_devmap[i].pd_cache = PTE_NOCACHE;
i++;
- pmap_devmap_bootstrap_table = &fdt_devmap[0];
+ arm_devmap_register_table(&fdt_devmap[0]);
return (0);
}
diff --git a/sys/arm/ti/ti_machdep.c b/sys/arm/ti/ti_machdep.c
index 66bd4a0..8a3184a 100644
--- a/sys/arm/ti/ti_machdep.c
+++ b/sys/arm/ti/ti_machdep.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <vm/pmap.h>
#include <machine/bus.h>
+#include <machine/devmap.h>
#include <machine/machdep.h>
#include <arm/ti/omap4/omap4_reg.h>
@@ -77,7 +78,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, }
};
@@ -107,7 +108,7 @@ platform_devmap_init(void)
#error "Unknown SoC"
#endif
- pmap_devmap_bootstrap_table = &fdt_devmap[0];
+ arm_devmap_register_table(&fdt_devmap[0]);
return (0);
}
diff --git a/sys/arm/versatile/versatile_machdep.c b/sys/arm/versatile/versatile_machdep.c
index 0a8c0d8..08ce039 100644
--- a/sys/arm/versatile/versatile_machdep.c
+++ b/sys/arm/versatile/versatile_machdep.c
@@ -49,6 +49,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>
@@ -74,7 +75,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, },
{ 0, 0, 0, 0, 0, }
};
@@ -93,7 +94,7 @@ platform_devmap_init(void)
fdt_devmap[i].pd_prot = VM_PROT_READ | VM_PROT_WRITE;
fdt_devmap[i].pd_cache = PTE_DEVICE;
- pmap_devmap_bootstrap_table = &fdt_devmap[0];
+ arm_devmap_register_table(&fdt_devmap[0]);
return (0);
}
diff --git a/sys/arm/xilinx/zy7_machdep.c b/sys/arm/xilinx/zy7_machdep.c
index edda8d7..a2b01b5 100644
--- a/sys/arm/xilinx/zy7_machdep.c
+++ b/sys/arm/xilinx/zy7_machdep.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <dev/fdt/fdt_common.h>
#include <machine/bus.h>
+#include <machine/devmap.h>
#include <machine/machdep.h>
#include <arm/xilinx/zy7_reg.h>
@@ -73,7 +74,7 @@ initarm_late_init(void)
}
#define FDT_DEVMAP_SIZE 3
-static struct pmap_devmap fdt_devmap[FDT_DEVMAP_SIZE];
+static struct arm_devmap_entry fdt_devmap[FDT_DEVMAP_SIZE];
/*
* Construct pmap_devmap[] with DT-derived config data.
@@ -104,7 +105,7 @@ platform_devmap_init(void)
fdt_devmap[i].pd_prot = 0;
fdt_devmap[i].pd_cache = 0;
- pmap_devmap_bootstrap_table = &fdt_devmap[0];
+ arm_devmap_register_table(&fdt_devmap[0]);
return (0);
}
diff --git a/sys/arm/xscale/i80321/ep80219_machdep.c b/sys/arm/xscale/i80321/ep80219_machdep.c
index ff2f1c3..94b94da 100644
--- a/sys/arm/xscale/i80321/ep80219_machdep.c
+++ b/sys/arm/xscale/i80321/ep80219_machdep.c
@@ -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>
@@ -125,7 +126,7 @@ struct pv_addr minidataclean;
/* #define IQ80321_OBIO_SIZE 0x00100000UL */
/* Static device mappings. */
-static const struct pmap_devmap ep80219_devmap[] = {
+static const struct arm_devmap_entry ep80219_devmap[] = {
/*
* Map the on-board devices VA == PA so that we can access them
* with the MMU on or off.
@@ -300,7 +301,7 @@ initarm(struct arm_boot_params *abp)
/* Map the vector page. */
pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
- pmap_devmap_bootstrap(l1pagetable, ep80219_devmap);
+ arm_devmap_bootstrap(l1pagetable, ep80219_devmap);
/*
* Give the XScale global cache clean code an appropriately
* sized chunk of unmapped VA space starting at 0xff000000
diff --git a/sys/arm/xscale/i80321/iq31244_machdep.c b/sys/arm/xscale/i80321/iq31244_machdep.c
index 1412635..f1f9128 100644
--- a/sys/arm/xscale/i80321/iq31244_machdep.c
+++ b/sys/arm/xscale/i80321/iq31244_machdep.c
@@ -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>
@@ -123,7 +124,7 @@ struct pv_addr minidataclean;
#define IQ80321_OBIO_BASE 0xfe800000UL
#define IQ80321_OBIO_SIZE 0x00100000UL
/* Static device mappings. */
-static const struct pmap_devmap iq80321_devmap[] = {
+static const struct arm_devmap_entry iq80321_devmap[] = {
/*
* Map the on-board devices VA == PA so that we can access them
* with the MMU on or off.
@@ -301,7 +302,7 @@ initarm(struct arm_boot_params *abp)
/* Map the vector page. */
pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
- pmap_devmap_bootstrap(l1pagetable, iq80321_devmap);
+ arm_devmap_bootstrap(l1pagetable, iq80321_devmap);
/*
* Give the XScale global cache clean code an appropriately
* sized chunk of unmapped VA space starting at 0xff000000
diff --git a/sys/arm/xscale/i8134x/crb_machdep.c b/sys/arm/xscale/i8134x/crb_machdep.c
index 4ae836b..6b56290 100644
--- a/sys/arm/xscale/i8134x/crb_machdep.c
+++ b/sys/arm/xscale/i8134x/crb_machdep.c
@@ -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>
@@ -123,7 +124,7 @@ struct pv_addr abtstack;
struct pv_addr kernelstack;
/* Static device mappings. */
-static const struct pmap_devmap iq81342_devmap[] = {
+static const struct arm_devmap_entry iq81342_devmap[] = {
{
IOP34X_VADDR,
IOP34X_HWADDR,
@@ -285,7 +286,7 @@ initarm(struct arm_boot_params *abp)
/* Map the vector page. */
pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
- pmap_devmap_bootstrap(l1pagetable, iq81342_devmap);
+ arm_devmap_bootstrap(l1pagetable, iq81342_devmap);
/*
* Give the XScale global cache clean code an appropriately
* sized chunk of unmapped VA space starting at 0xff000000
diff --git a/sys/arm/xscale/ixp425/avila_machdep.c b/sys/arm/xscale/ixp425/avila_machdep.c
index 82e1aab0..825ccb5 100644
--- a/sys/arm/xscale/ixp425/avila_machdep.c
+++ b/sys/arm/xscale/ixp425/avila_machdep.c
@@ -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>
@@ -125,7 +126,7 @@ struct pv_addr kernelstack;
struct pv_addr minidataclean;
/* Static device mappings. */
-static const struct pmap_devmap ixp425_devmap[] = {
+static const struct arm_devmap_entry ixp425_devmap[] = {
/* Physical/Virtual address for I/O space */
{ IXP425_IO_VBASE, IXP425_IO_HWBASE, IXP425_IO_SIZE,
VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
@@ -158,7 +159,7 @@ static const struct pmap_devmap ixp425_devmap[] = {
};
/* Static device mappings. */
-static const struct pmap_devmap ixp435_devmap[] = {
+static const struct arm_devmap_entry ixp435_devmap[] = {
/* Physical/Virtual address for I/O space */
{ IXP425_IO_VBASE, IXP425_IO_HWBASE, IXP425_IO_SIZE,
VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
@@ -368,9 +369,9 @@ initarm(struct arm_boot_params *abp)
pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
if (cpu_is_ixp43x())
- pmap_devmap_bootstrap(l1pagetable, ixp435_devmap);
+ arm_devmap_bootstrap(l1pagetable, ixp435_devmap);
else
- pmap_devmap_bootstrap(l1pagetable, ixp425_devmap);
+ arm_devmap_bootstrap(l1pagetable, ixp425_devmap);
/*
* Give the XScale global cache clean code an appropriately
* sized chunk of unmapped VA space starting at 0xff000000
diff --git a/sys/arm/xscale/pxa/pxa_machdep.c b/sys/arm/xscale/pxa/pxa_machdep.c
index 5640622..b3c32e0 100644
--- a/sys/arm/xscale/pxa/pxa_machdep.c
+++ b/sys/arm/xscale/pxa/pxa_machdep.c
@@ -80,6 +80,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>
@@ -124,7 +125,7 @@ static void pxa_probe_sdram(bus_space_tag_t, bus_space_handle_t,
uint32_t *, uint32_t *);
/* Static device mappings. */
-static const struct pmap_devmap pxa_devmap[] = {
+static const struct arm_devmap_entry pxa_devmap[] = {
/*
* Map the on-board devices up into the KVA region so we don't muck
* up user-space.
@@ -281,7 +282,7 @@ initarm(struct arm_boot_params *abp)
/* Map the vector page. */
pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
- pmap_devmap_bootstrap(l1pagetable, pxa_devmap);
+ arm_devmap_bootstrap(l1pagetable, pxa_devmap);
/*
* Give the XScale global cache clean code an appropriately
diff --git a/sys/conf/files.arm b/sys/conf/files.arm
index dbb9ffc2..6fd5df1 100644
--- a/sys/conf/files.arm
+++ b/sys/conf/files.arm
@@ -14,6 +14,7 @@ arm/arm/cpufunc_asm_armv4.S standard
arm/arm/db_disasm.c optional ddb
arm/arm/db_interface.c optional ddb
arm/arm/db_trace.c optional ddb
+arm/arm/devmap.c standard
arm/arm/disassem.c optional ddb
arm/arm/dump_machdep.c standard
arm/arm/elf_machdep.c standard
diff --git a/sys/dev/fdt/fdt_pci.c b/sys/dev/fdt/fdt_pci.c
index 40f12cb..a4cf9d1 100644
--- a/sys/dev/fdt/fdt_pci.c
+++ b/sys/dev/fdt/fdt_pci.c
@@ -42,6 +42,9 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcireg.h>
#include <machine/fdt.h>
+#if defined(__arm__)
+#include <machine/devmap.h>
+#endif
#include "ofw_bus_if.h"
#include "pcib_if.h"
@@ -332,7 +335,7 @@ next:
#if defined(__arm__)
int
-fdt_pci_devmap(phandle_t node, struct pmap_devmap *devmap, vm_offset_t io_va,
+fdt_pci_devmap(phandle_t node, struct arm_devmap_entry *devmap, vm_offset_t io_va,
vm_offset_t mem_va)
{
struct fdt_pci_range io_space, mem_space;
OpenPOWER on IntegriCloud