summaryrefslogtreecommitdiffstats
path: root/include/mmu.h
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-10-23 11:06:56 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-11-03 07:27:44 +0100
commitb792124a7dd30f03b9ad0e06589b5b58ed930d3b (patch)
tree9811bbbc0b5bb5baade7d32309ced5b3c59046df /include/mmu.h
parent6b127d4f189c03f4417f6185de1aeb55b1706f94 (diff)
downloadbarebox-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 'include/mmu.h')
-rw-r--r--include/mmu.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/mmu.h b/include/mmu.h
new file mode 100644
index 0000000000..66b246f6d2
--- /dev/null
+++ b/include/mmu.h
@@ -0,0 +1,41 @@
+#ifndef __MMU_H
+#define __MMU_H
+
+#define MAP_UNCACHED 0
+#define MAP_CACHED 1
+
+/*
+ * Depending on the architecture the default mapping can be
+ * cached or uncached. Without ARCH_HAS_REMAP being set this
+ * is mapping type is the only one supported.
+ */
+#define MAP_DEFAULT MAP_ARCH_DEFAULT
+
+#include <asm/mmu.h>
+
+#ifndef ARCH_HAS_REMAP
+static inline int arch_remap_range(void *start, size_t size, unsigned flags)
+{
+ if (flags == MAP_ARCH_DEFAULT)
+ return 0;
+
+ return -EINVAL;
+}
+
+static inline bool arch_can_remap(void)
+{
+ return false;
+}
+#else
+static inline bool arch_can_remap(void)
+{
+ return true;
+}
+#endif
+
+static inline int remap_range(void *start, size_t size, unsigned flags)
+{
+ return arch_remap_range(start, size, flags);
+}
+
+#endif