diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-10-23 11:06:56 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-11-03 07:27:44 +0100 |
commit | b792124a7dd30f03b9ad0e06589b5b58ed930d3b (patch) | |
tree | 9811bbbc0b5bb5baade7d32309ced5b3c59046df /arch/arm/cpu | |
parent | 6b127d4f189c03f4417f6185de1aeb55b1706f94 (diff) | |
download | barebox-b792124a7dd30f03b9ad0e06589b5b58ed930d3b.tar.gz barebox-b792124a7dd30f03b9ad0e06589b5b58ed930d3b.tar.xz |
rework remap_range
remap_range is for remapping regions with different cache attributes.
It is implemented for ARM and PowerPC only, the other architectures only
provide stubs.
Currently the new cache attributes are passed in an architecture specific
way and the attributes have to be retrieved by calls to
mmu_get_pte_cached_flags() and mmu_get_pte_uncached_flags().
Make this simpler by providing architecture independent flags which can
be directly passed to remap_range()
Also provide a MAP_ARCH_DEFAULT flag and a arch_can_remap() function.
The MAP_ARCH_DEFAULT defaults to whatever caching type the architecture
has as default. the arch_can_remap() function returns true if the
architecture can change the cache attributes, false otherwise. This
allows the memtest code to better find out what it has to do.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/cpu')
-rw-r--r-- | arch/arm/cpu/mmu.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c index 470b448957..81c23947b7 100644 --- a/arch/arm/cpu/mmu.c +++ b/arch/arm/cpu/mmu.c @@ -20,7 +20,7 @@ #include <common.h> #include <dma-dir.h> #include <init.h> -#include <asm/mmu.h> +#include <mmu.h> #include <errno.h> #include <linux/sizes.h> #include <asm/memory.h> @@ -81,16 +81,6 @@ static uint32_t pte_flags_uncached; #define PTE_MASK ((1 << 12) - 1) -uint32_t mmu_get_pte_cached_flags() -{ - return pte_flags_cached; -} - -uint32_t mmu_get_pte_uncached_flags() -{ - return pte_flags_uncached; -} - static void arm_mmu_not_initialized_error(void) { /* @@ -173,24 +163,38 @@ static void dma_inv_range(unsigned long start, unsigned long end) __dma_inv_range(start, end); } -void remap_range(void *_start, size_t size, uint32_t flags) +int arch_remap_range(void *_start, size_t size, unsigned flags) { unsigned long start = (unsigned long)_start; u32 *p; int numentries, i; + u32 pte_flags; + + switch (flags) { + case MAP_CACHED: + pte_flags = pte_flags_cached; + break; + case MAP_UNCACHED: + pte_flags = pte_flags_uncached; + break; + default: + return -EINVAL; + } numentries = size >> PAGE_SHIFT; p = find_pte(start); for (i = 0; i < numentries; i++) { p[i] &= ~PTE_MASK; - p[i] |= flags | PTE_TYPE_SMALL; + p[i] |= pte_flags | PTE_TYPE_SMALL; } dma_flush_range((unsigned long)p, (unsigned long)p + numentries * sizeof(u32)); tlb_invalidate(); + + return 0; } void *map_io_sections(unsigned long phys, void *_start, size_t size) |