Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/broadcom Sync with armv7_generic_space.c



details:   https://anonhg.NetBSD.org/src/rev/3d836f2fa207
branches:  trunk
changeset: 357796:3d836f2fa207
user:      skrll <skrll%NetBSD.org@localhost>
date:      Tue Nov 28 08:39:31 2017 +0000

description:
Sync with armv7_generic_space.c

- BE support (probably not needed)
- a4x subreagion/mmap support
- fix some a4x stream methods
- add UVM_KMF_COLORMATCH in bs_map when allocating KVA
- support BUS_SPACE_MAP_PREFETCHABLE

diffstat:

 sys/arch/arm/broadcom/bcm2835_space.c |  155 ++++++++++++++++++++-------------
 1 files changed, 92 insertions(+), 63 deletions(-)

diffs (truncated from 337 to 300 lines):

diff -r cdf0381e6d7b -r 3d836f2fa207 sys/arch/arm/broadcom/bcm2835_space.c
--- a/sys/arch/arm/broadcom/bcm2835_space.c     Tue Nov 28 07:36:08 2017 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_space.c     Tue Nov 28 08:39:31 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm2835_space.c,v 1.12 2017/11/27 17:27:37 skrll Exp $ */
+/*     $NetBSD: bcm2835_space.c,v 1.13 2017/11/28 08:39:31 skrll Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_space.c,v 1.12 2017/11/27 17:27:37 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_space.c,v 1.13 2017/11/28 08:39:31 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -51,6 +51,12 @@
 bs_protos(a4x);
 bs_protos(bs_notimpl);
 
+#if __ARMEB__
+#define NSWAP(n)       n ## _swap
+#else
+#define NSWAP(n)       n
+#endif
+
 struct bus_space bcm2835_bs_tag = {
        /* cookie */
        (void *) 0,
@@ -75,38 +81,38 @@
 
        /* read (single) */
        generic_bs_r_1,
-       generic_armv4_bs_r_2,
-       generic_bs_r_4,
+       NSWAP(generic_armv4_bs_r_2),
+       NSWAP(generic_bs_r_4),
        bs_notimpl_bs_r_8,
 
        /* read multiple */
        generic_bs_rm_1,
-       generic_armv4_bs_rm_2,
-       generic_bs_rm_4,
+       NSWAP(generic_armv4_bs_rm_2),
+       NSWAP(generic_bs_rm_4),
        bs_notimpl_bs_rm_8,
 
        /* read region */
        generic_bs_rr_1,
-       generic_armv4_bs_rr_2,
-       generic_bs_rr_4,
+       NSWAP(generic_armv4_bs_rr_2),
+       NSWAP(generic_bs_rr_4),
        bs_notimpl_bs_rr_8,
 
        /* write (single) */
        generic_bs_w_1,
-       generic_armv4_bs_w_2,
-       generic_bs_w_4,
+       NSWAP(generic_armv4_bs_w_2),
+       NSWAP(generic_bs_w_4),
        bs_notimpl_bs_w_8,
 
        /* write multiple */
        generic_bs_wm_1,
-       generic_armv4_bs_wm_2,
-       generic_bs_wm_4,
+       NSWAP(generic_armv4_bs_wm_2),
+       NSWAP(generic_bs_wm_4),
        bs_notimpl_bs_wm_8,
 
        /* write region */
        generic_bs_wr_1,
-       generic_armv4_bs_wr_2,
-       generic_bs_wr_4,
+       NSWAP(generic_armv4_bs_wr_2),
+       NSWAP(generic_bs_wr_4),
        bs_notimpl_bs_wr_8,
 
        /* set multiple */
@@ -117,8 +123,8 @@
 
        /* set region */
        generic_bs_sr_1,
-       generic_armv4_bs_sr_2,
-       bs_notimpl_bs_sr_4,
+       NSWAP(generic_armv4_bs_sr_2),
+       NSWAP(generic_bs_sr_4),
        bs_notimpl_bs_sr_8,
 
        /* copy */
@@ -130,38 +136,38 @@
 #ifdef __BUS_SPACE_HAS_STREAM_METHODS
        /* read (single) */
        generic_bs_r_1,
-       generic_armv4_bs_r_2,
-       generic_bs_r_4,
+       NSWAP(generic_armv4_bs_r_2),
+       NSWAP(generic_bs_r_4),
        bs_notimpl_bs_r_8,
 
        /* read multiple */
        generic_bs_rm_1,
-       generic_armv4_bs_rm_2,
-       generic_bs_rm_4,
+       NSWAP(generic_armv4_bs_rm_2),
+       NSWAP(generic_bs_rm_4),
        bs_notimpl_bs_rm_8,
 
        /* read region */
        generic_bs_rr_1,
-       generic_armv4_bs_rr_2,
-       generic_bs_rr_4,
+       NSWAP(generic_armv4_bs_rr_2),
+       NSWAP(generic_bs_rr_4),
        bs_notimpl_bs_rr_8,
 
        /* write (single) */
        generic_bs_w_1,
-       generic_armv4_bs_w_2,
-       generic_bs_w_4,
+       NSWAP(generic_armv4_bs_w_2),
+       NSWAP(generic_bs_w_4),
        bs_notimpl_bs_w_8,
 
        /* write multiple */
        generic_bs_wm_1,
-       generic_armv4_bs_wm_2,
-       generic_bs_wm_4,
+       NSWAP(generic_armv4_bs_wm_2),
+       NSWAP(generic_bs_wm_4),
        bs_notimpl_bs_wm_8,
 
        /* write region */
        generic_bs_wr_1,
-       generic_armv4_bs_wr_2,
-       generic_bs_wr_4,
+       NSWAP(generic_armv4_bs_wr_2),
+       NSWAP(generic_bs_wr_4),
        bs_notimpl_bs_wr_8,
 #endif
 };
@@ -173,7 +179,7 @@
        /* mapping/unmapping */
        bcm2835_bs_map,
        bcm2835_bs_unmap,
-       bcm2835_bs_subregion,
+       bcm2835_a4x_bs_subregion,
 
        /* allocation/deallocation */
        bcm2835_bs_alloc,       /* not implemented */
@@ -183,21 +189,21 @@
        bcm2835_bs_vaddr,
 
        /* mmap */
-       bs_notimpl_bs_mmap,
+       bcm2835_a4x_bs_mmap,
 
        /* barrier */
        bcm2835_bs_barrier,
 
        /* read (single) */
        a4x_bs_r_1,
-       a4x_bs_r_2,
-       a4x_bs_r_4,
+       NSWAP(a4x_bs_r_2),
+       NSWAP(a4x_bs_r_4),
        bs_notimpl_bs_r_8,
 
        /* read multiple */
        a4x_bs_rm_1,
-       a4x_bs_rm_2,
-       a4x_bs_rm_4,
+       NSWAP(a4x_bs_rm_2),
+       NSWAP(a4x_bs_rm_4),
        bs_notimpl_bs_rm_8,
 
        /* read region */
@@ -208,15 +214,16 @@
 
        /* write (single) */
        a4x_bs_w_1,
-       a4x_bs_w_2,
-       a4x_bs_w_4,
+       NSWAP(a4x_bs_w_2),
+       NSWAP(a4x_bs_w_4),
        bs_notimpl_bs_w_8,
 
        /* write multiple */
        a4x_bs_wm_1,
-       a4x_bs_wm_2,
-       a4x_bs_wm_4,
+       NSWAP(a4x_bs_wm_2),
+       NSWAP(a4x_bs_wm_4),
        bs_notimpl_bs_wm_8,
+
        /* write region */
        bs_notimpl_bs_wr_1,
        bs_notimpl_bs_wr_2,
@@ -243,39 +250,39 @@
 
 #ifdef __BUS_SPACE_HAS_STREAM_METHODS
        /* read (single) */
-       generic_bs_r_1,
-       generic_armv4_bs_r_2,
-       generic_bs_r_4,
+       a4x_bs_r_1,
+       NSWAP(a4x_bs_r_2),
+       NSWAP(a4x_bs_r_4),
        bs_notimpl_bs_r_8,
 
        /* read multiple */
-       generic_bs_rm_1,
-       generic_armv4_bs_rm_2,
-       generic_bs_rm_4,
+       a4x_bs_rm_1,
+       NSWAP(a4x_bs_rm_2),
+       NSWAP(a4x_bs_rm_4),
        bs_notimpl_bs_rm_8,
 
        /* read region */
-       generic_bs_rr_1,
-       generic_armv4_bs_rr_2,
-       generic_bs_rr_4,
+       bs_notimpl_bs_rr_1,
+       bs_notimpl_bs_rr_2,
+       bs_notimpl_bs_rr_4,
        bs_notimpl_bs_rr_8,
 
        /* write (single) */
-       generic_bs_w_1,
-       generic_armv4_bs_w_2,
-       generic_bs_w_4,
+       a4x_bs_w_1,
+       NSWAP(a4x_bs_w_2),
+       NSWAP(a4x_bs_w_4),
        bs_notimpl_bs_w_8,
 
        /* write multiple */
-       generic_bs_wm_1,
-       generic_armv4_bs_wm_2,
-       generic_bs_wm_4,
+       a4x_bs_wm_1,
+       NSWAP(a4x_bs_wm_2),
+       NSWAP(a4x_bs_wm_4),
        bs_notimpl_bs_wm_8,
 
        /* write region */
-       generic_bs_wr_1,
-       generic_armv4_bs_wr_2,
-       generic_bs_wr_4,
+       bs_notimpl_bs_wr_1,
+       bs_notimpl_bs_wr_2,
+       bs_notimpl_bs_wr_4,
        bs_notimpl_bs_wr_8,
 #endif
 
@@ -289,7 +296,6 @@
        u_long startpa, endpa, pa;
        vaddr_t va;
        const struct pmap_devmap *pd;
-       int pmap_flags;
        bool match = false;
 
        /* Attempt to find the PA device mapping */
@@ -322,16 +328,18 @@
        /* XXX use extent manager to check duplicate mapping */
 
        va = uvm_km_alloc(kernel_map, endpa - startpa, 0,
-           UVM_KMF_VAONLY | UVM_KMF_NOWAIT);
+           UVM_KMF_VAONLY | UVM_KMF_NOWAIT | UVM_KMF_COLORMATCH);
        if (!va)
                return ENOMEM;
 
        *bshp = (bus_space_handle_t)(va + (pa - startpa));
 
-       pmap_flags = (flag & BUS_SPACE_MAP_CACHEABLE) ? 0 : PMAP_NOCACHE;
+       const int pmapflags =
+           (flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE))
+               ? 0
+               : PMAP_NOCACHE;
        for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
-               pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE,
-                   pmap_flags);
+               pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags);
        }
        pmap_update(pmap_kernel());
 
@@ -367,6 +375,15 @@
        return 0;
 }
 
+int
+bcm2835_a4x_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset,
+    bus_size_t size, bus_space_handle_t *nbshp)
+{
+
+       *nbshp = bsh + 4 * offset;



Home | Main Index | Thread Index | Old Index