Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm/pmap Provide a shared pmap_devmap implementation and...



details:   https://anonhg.NetBSD.org/src/rev/b7bc06606d11
branches:  trunk
changeset: 374344:b7bc06606d11
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Apr 20 08:28:02 2023 +0000

description:
Provide a shared pmap_devmap implementation and convert all pmap_devmap
arrays to use DEVMAP_ENTRY{,_END}

diffstat:

 sys/arch/aarch64/aarch64/pmap.c                           |  119 +---------
 sys/arch/aarch64/aarch64/pmap_machdep.c                   |   95 +-------
 sys/arch/aarch64/conf/files.aarch64                       |    3 +-
 sys/arch/aarch64/include/cpufunc.h                        |    9 +-
 sys/arch/aarch64/include/pmap.h                           |   34 +--
 sys/arch/aarch64/include/pmap_machdep.h                   |    4 +-
 sys/arch/arm/arm32/pmap.c                                 |  108 +------
 sys/arch/arm/conf/files.arm                               |    3 +-
 sys/arch/arm/include/arm32/pmap.h                         |   33 +--
 sys/arch/cats/cats/cats_machdep.c                         |   48 +-
 sys/arch/epoc32/epoc32/machdep.c                          |   30 +-
 sys/arch/evbarm/adi_brh/brh_machdep.c                     |   76 ++---
 sys/arch/evbarm/armadaxp/armadaxp_machdep.c               |   25 +-
 sys/arch/evbarm/g42xxeb/g42xxeb_machdep.c                 |   65 ++---
 sys/arch/evbarm/gemini/gemini_machdep.c                   |  106 +++-----
 sys/arch/evbarm/gumstix/gumstix_machdep.c                 |   90 ++----
 sys/arch/evbarm/hdl_g/hdlg_machdep.c                      |   36 +-
 sys/arch/evbarm/imx23_olinuxino/imx23_olinuxino_machdep.c |   20 +-
 sys/arch/evbarm/imx31/imx31lk_machdep.c                   |   19 +-
 sys/arch/evbarm/integrator/integrator_machdep.c           |   44 +--
 sys/arch/evbarm/iq80310/iq80310_machdep.c                 |   44 +--
 sys/arch/evbarm/iq80321/iq80321_machdep.c                 |   56 +--
 sys/arch/evbarm/ixm1200/ixm1200_machdep.c                 |   52 +--
 sys/arch/evbarm/kobo/kobo_machdep.c                       |   24 +-
 sys/arch/evbarm/lubbock/lubbock_machdep.c                 |   54 +--
 sys/arch/evbarm/marvell/marvell_machdep.c                 |   19 +-
 sys/arch/evbarm/mini2440/mini2440_machdep.c               |   48 +--
 sys/arch/evbarm/netwalker/netwalker_machdep.c             |   24 +-
 sys/arch/evbarm/nslu2/nslu2_machdep.c                     |   60 +---
 sys/arch/evbarm/smdk2xx0/smdk2410_machdep.c               |   49 +--
 sys/arch/evbarm/smdk2xx0/smdk2800_machdep.c               |   13 +-
 sys/arch/evbarm/tsarm/tsarm_machdep.c                     |   44 +--
 sys/arch/hpcarm/hpcarm/netbookpro_machdep.c               |   16 +-
 sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c               |   73 ++---
 sys/arch/hpcarm/hpcarm/sa11x0_hpc_machdep.c               |   13 +-
 sys/arch/iyonix/iyonix/iyonix_machdep.c                   |   44 +--
 sys/arch/zaurus/zaurus/machdep.c                          |  102 +++----
 sys/uvm/pmap/pmap_devmap.c                                |  173 ++++++++++++++
 sys/uvm/pmap/pmap_devmap.h                                |   66 +++++
 39 files changed, 792 insertions(+), 1149 deletions(-)

diffs (truncated from 3026 to 300 lines):

diff -r a69f36040458 -r b7bc06606d11 sys/arch/aarch64/aarch64/pmap.c
--- a/sys/arch/aarch64/aarch64/pmap.c   Thu Apr 20 00:42:23 2023 +0000
+++ b/sys/arch/aarch64/aarch64/pmap.c   Thu Apr 20 08:28:02 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.148 2023/04/16 14:01:51 skrll Exp $ */
+/*     $NetBSD: pmap.c,v 1.149 2023/04/20 08:28:02 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.148 2023/04/16 14:01:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.149 2023/04/20 08:28:02 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -215,7 +215,6 @@ static vaddr_t pmap_maxkvaddr;
 
 vaddr_t virtual_avail, virtual_end;
 vaddr_t virtual_devmap_addr;
-bool pmap_devmap_bootstrap_done = false;
 
 static struct pool_cache _pmap_cache;
 static struct pool_cache _pmap_pv_pool;
@@ -336,10 +335,8 @@ phys_to_pp(paddr_t pa)
 #endif /* DIAGNOSTIC */
 
 
-static const struct pmap_devmap *pmap_devmap_table;
-
-static vsize_t
-pmap_map_chunk(vaddr_t va, paddr_t pa, vsize_t size,
+vsize_t
+pmap_kenter_range(vaddr_t va, paddr_t pa, vsize_t size,
     vm_prot_t prot, u_int flags)
 {
        pt_entry_t attr;
@@ -352,114 +349,6 @@ pmap_map_chunk(vaddr_t va, paddr_t pa, v
        return resid;
 }
 
-void
-pmap_devmap_register(const struct pmap_devmap *table)
-{
-       pmap_devmap_table = table;
-}
-
-void
-pmap_devmap_bootstrap(vaddr_t l0pt, const struct pmap_devmap *table)
-{
-       bool done = false;
-       vaddr_t va;
-       int i;
-
-       pmap_devmap_register(table);
-
-       VPRINTF("%s:\n", __func__);
-       for (i = 0; table[i].pd_size != 0; i++) {
-               VPRINTF(" devmap: pa %08lx-%08lx = va %016lx\n",
-                   table[i].pd_pa,
-                   table[i].pd_pa + table[i].pd_size - 1,
-                   table[i].pd_va);
-               va = table[i].pd_va;
-
-               KASSERT((VM_KERNEL_IO_BASE <= va) &&
-                   (va < (VM_KERNEL_IO_BASE + VM_KERNEL_IO_SIZE)));
-
-               /* update and check virtual_devmap_addr */
-               if (virtual_devmap_addr == 0 || virtual_devmap_addr > va) {
-                       virtual_devmap_addr = va;
-               }
-
-               pmap_map_chunk(
-                   table[i].pd_va,
-                   table[i].pd_pa,
-                   table[i].pd_size,
-                   table[i].pd_prot,
-                   table[i].pd_flags);
-               done = true;
-       }
-       if (done)
-               pmap_devmap_bootstrap_done = true;
-}
-
-const struct pmap_devmap *
-pmap_devmap_find_va(vaddr_t va, vsize_t size)
-{
-       paddr_t endva;
-       int i;
-
-       if (pmap_devmap_table == NULL)
-               return NULL;
-
-       endva = va + size;
-       for (i = 0; pmap_devmap_table[i].pd_size != 0; i++) {
-               if ((va >= pmap_devmap_table[i].pd_va) &&
-                   (endva <= pmap_devmap_table[i].pd_va +
-                             pmap_devmap_table[i].pd_size))
-                       return &pmap_devmap_table[i];
-       }
-       return NULL;
-}
-
-const struct pmap_devmap *
-pmap_devmap_find_pa(paddr_t pa, psize_t size)
-{
-       paddr_t endpa;
-       int i;
-
-       if (pmap_devmap_table == NULL)
-               return NULL;
-
-       endpa = pa + size;
-       for (i = 0; pmap_devmap_table[i].pd_size != 0; i++) {
-               if (pa >= pmap_devmap_table[i].pd_pa &&
-                   (endpa <= pmap_devmap_table[i].pd_pa +
-                            pmap_devmap_table[i].pd_size))
-                       return (&pmap_devmap_table[i]);
-       }
-       return NULL;
-}
-
-vaddr_t
-pmap_devmap_phystov(paddr_t pa)
-{
-       const struct pmap_devmap *table;
-       paddr_t offset;
-
-       table = pmap_devmap_find_pa(pa, 0);
-       if (table == NULL)
-               return 0;
-
-       offset = pa - table->pd_pa;
-       return table->pd_va + offset;
-}
-
-vaddr_t
-pmap_devmap_vtophys(paddr_t va)
-{
-       const struct pmap_devmap *table;
-       vaddr_t offset;
-
-       table = pmap_devmap_find_va(va, 0);
-       if (table == NULL)
-               return 0;
-
-       offset = va - table->pd_va;
-       return table->pd_pa + offset;
-}
 
 void
 pmap_bootstrap(vaddr_t vstart, vaddr_t vend)
diff -r a69f36040458 -r b7bc06606d11 sys/arch/aarch64/aarch64/pmap_machdep.c
--- a/sys/arch/aarch64/aarch64/pmap_machdep.c   Thu Apr 20 00:42:23 2023 +0000
+++ b/sys/arch/aarch64/aarch64/pmap_machdep.c   Thu Apr 20 08:28:02 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_machdep.c,v 1.5 2023/04/16 14:01:51 skrll Exp $   */
+/*     $NetBSD: pmap_machdep.c,v 1.6 2023/04/20 08:28:02 skrll Exp $   */
 
 /*-
  * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 #define __PMAP_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_machdep.c,v 1.5 2023/04/16 14:01:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_machdep.c,v 1.6 2023/04/20 08:28:02 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -69,8 +69,6 @@ uint64_t pmap_attr_gp = 0;
 vaddr_t virtual_avail;
 vaddr_t virtual_end;
 
-bool pmap_devmap_bootstrap_done = false;
-
 paddr_t
 vtophys(vaddr_t va)
 {
@@ -647,9 +645,6 @@ pmap_l0table(struct pmap *pm)
 }
 
 
-static const struct pmap_devmap *pmap_devmap_table;
-vaddr_t virtual_devmap_addr;
-
 #define        L1_BLK_MAPPABLE_P(va, pa, size)                                 \
     ((((va) | (pa)) & L1_OFFSET) == 0 && (size) >= L1_SIZE)
 
@@ -657,8 +652,8 @@ vaddr_t virtual_devmap_addr;
     ((((va) | (pa)) & L2_OFFSET) == 0 && (size) >= L2_SIZE)
 
 
-static vsize_t
-pmap_map_chunk(vaddr_t va, paddr_t pa, vsize_t size,
+vsize_t
+pmap_kenter_range(vaddr_t va, paddr_t pa, vsize_t size,
     vm_prot_t prot, u_int flags)
 {
        pt_entry_t attr;
@@ -694,88 +689,6 @@ pmap_map_chunk(vaddr_t va, paddr_t pa, v
        return mapped;
 }
 
-
-void
-pmap_devmap_register(const struct pmap_devmap *table)
-{
-       pmap_devmap_table = table;
-}
-
-
-void
-pmap_devmap_bootstrap(vaddr_t l0pt, const struct pmap_devmap *table)
-{
-       vaddr_t va;
-       int i;
-
-       pmap_devmap_register(table);
-
-       VPRINTF("%s:\n", __func__);
-       for (i = 0; table[i].pd_size != 0; i++) {
-               VPRINTF(" devmap: pa %08lx-%08lx = va %016lx\n",
-                   table[i].pd_pa,
-                   table[i].pd_pa + table[i].pd_size - 1,
-                   table[i].pd_va);
-               va = table[i].pd_va;
-
-               KASSERT((VM_KERNEL_IO_BASE <= va) &&
-                   (va < (VM_KERNEL_IO_BASE + VM_KERNEL_IO_SIZE)));
-
-               /* update and check virtual_devmap_addr */
-               if ((virtual_devmap_addr == 0) ||
-                   (virtual_devmap_addr > va)) {
-                       virtual_devmap_addr = va;
-               }
-
-               pmap_map_chunk(
-                   table[i].pd_va,
-                   table[i].pd_pa,
-                   table[i].pd_size,
-                   table[i].pd_prot,
-                   table[i].pd_flags);
-
-               pmap_devmap_bootstrap_done = true;
-       }
-}
-
-
-const struct pmap_devmap *
-pmap_devmap_find_va(vaddr_t va, vsize_t size)
-{
-
-       if (pmap_devmap_table == NULL)
-               return NULL;
-
-       const vaddr_t endva = va + size;
-       for (size_t i = 0; pmap_devmap_table[i].pd_size != 0; i++) {
-               if ((va >= pmap_devmap_table[i].pd_va) &&
-                   (endva <= pmap_devmap_table[i].pd_va +
-                             pmap_devmap_table[i].pd_size)) {
-                       return &pmap_devmap_table[i];
-               }
-       }
-       return NULL;
-}
-
-
-const struct pmap_devmap *
-pmap_devmap_find_pa(paddr_t pa, psize_t size)
-{
-
-       if (pmap_devmap_table == NULL)
-               return NULL;
-
-       const paddr_t endpa = pa + size;
-       for (size_t i = 0; pmap_devmap_table[i].pd_size != 0; i++) {
-               if (pa >= pmap_devmap_table[i].pd_pa &&
-                   (endpa <= pmap_devmap_table[i].pd_pa +
-                             pmap_devmap_table[i].pd_size))
-                       return (&pmap_devmap_table[i]);
-       }
-       return NULL;
-}
-
-
 #ifdef MULTIPROCESSOR
 void
 pmap_md_tlb_info_attach(struct pmap_tlb_info *ti, struct cpu_info *ci)
diff -r a69f36040458 -r b7bc06606d11 sys/arch/aarch64/conf/files.aarch64
--- a/sys/arch/aarch64/conf/files.aarch64       Thu Apr 20 00:42:23 2023 +0000
+++ b/sys/arch/aarch64/conf/files.aarch64       Thu Apr 20 08:28:02 2023 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.aarch64,v 1.42 2022/11/05 08:29:17 skrll Exp $
+#      $NetBSD: files.aarch64,v 1.43 2023/04/20 08:28:02 skrll Exp $
 
 defflag opt_cpuoptions.h       AARCH64_ALIGNMENT_CHECK
 defflag opt_cpuoptions.h       AARCH64_EL0_STACK_ALIGNMENT_CHECK



Home | Main Index | Thread Index | Old Index