mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Aring <alex.aring@gmail.com>
To: barebox@lists.infradead.org
Cc: marc@cpdesign.com
Subject: [PATCH 5/9] mmu: make remap_range global accessable
Date: Sun, 13 Jan 2013 18:42:19 +0100	[thread overview]
Message-ID: <1358098943-18928-6-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1358098943-18928-1-git-send-email-alex.aring@gmail.com>

There is only one implementation of 'remap_range' in
arm architecture. Added dummy function for others architectures.

Added new function 'mmu_get_pte_cached_flags' and
'mmu_get_pte_uncached_flags' to get pte flags for caching and
uncaching pages.

These flags are in arm architecture configured at runtime.
Others architectures will return 0, which don't have a mmu
implementation for this.

Also moved PAGE_ALIGN and add PAGE_ALIGN_DOWN macros to common.h.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 arch/arm/cpu/mmu.c              | 18 +++++++++++++++---
 arch/arm/include/asm/mmu.h      | 17 +++++++++++++++++
 arch/blackfin/include/asm/mmu.h | 19 +++++++++++++++++++
 arch/mips/include/asm/mmu.h     | 19 +++++++++++++++++++
 arch/nios2/include/asm/mmu.h    | 19 +++++++++++++++++++
 arch/openrisc/include/asm/mmu.h | 19 +++++++++++++++++++
 arch/ppc/include/asm/mmu.h      | 15 +++++++++++++++
 arch/sandbox/include/asm/mmu.h  | 19 +++++++++++++++++++
 arch/x86/include/asm/mmu.h      | 19 +++++++++++++++++++
 include/common.h                |  2 ++
 10 files changed, 163 insertions(+), 3 deletions(-)
 create mode 100644 arch/blackfin/include/asm/mmu.h
 create mode 100644 arch/mips/include/asm/mmu.h
 create mode 100644 arch/nios2/include/asm/mmu.h
 create mode 100644 arch/openrisc/include/asm/mmu.h
 create mode 100644 arch/sandbox/include/asm/mmu.h
 create mode 100644 arch/x86/include/asm/mmu.h

diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 40b7ec4..50112d2 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -52,9 +52,23 @@ extern int arm_architecture;
 #define PTE_FLAGS_CACHED_V4 (PTE_SMALL_AP_UNO_SRW | PTE_BUFFERABLE | PTE_CACHEABLE)
 #define PTE_FLAGS_UNCACHED_V4 PTE_SMALL_AP_UNO_SRW
 
+/*
+ * PTE flags to set cached and uncached areas.
+ * This will be determined at runtime.
+ */
 static uint32_t PTE_FLAGS_CACHED;
 static uint32_t PTE_FLAGS_UNCACHED;
 
+uint32_t mmu_get_pte_cached_flags()
+{
+	return PTE_FLAGS_CACHED;
+}
+
+uint32_t mmu_get_pte_uncached_flags()
+{
+	return PTE_FLAGS_UNCACHED;
+}
+
 #define PTE_MASK ((1 << 12) - 1)
 
 /*
@@ -93,7 +107,7 @@ static u32 *find_pte(unsigned long adr)
 	return &table[(adr >> PAGE_SHIFT) & 0xff];
 }
 
-static void remap_range(void *_start, size_t size, uint32_t flags)
+void remap_range(void *_start, size_t size, uint32_t flags)
 {
 	unsigned long start = (unsigned long)_start;
 	u32 *p;
@@ -294,8 +308,6 @@ void mmu_disable(void)
 	__mmu_cache_off();
 }
 
-#define PAGE_ALIGN(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
-
 void *dma_alloc_coherent(size_t size)
 {
 	void *ret;
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index a66da8c..f32cea6 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -41,7 +41,10 @@ void dma_flush_range(unsigned long, unsigned long);
 void dma_inv_range(unsigned long, unsigned long);
 unsigned long virt_to_phys(void *virt);
 void *phys_to_virt(unsigned long phys);
+void remap_range(void *_start, size_t size, uint32_t flags);
 void *map_io_sections(unsigned long physaddr, void *start, size_t size);
+uint32_t mmu_get_pte_cached_flags(void);
+uint32_t mmu_get_pte_uncached_flags(void);
 
 #else
 static inline void *dma_alloc_coherent(size_t size)
@@ -76,11 +79,25 @@ static inline void dma_inv_range(unsigned long s, unsigned long e)
 {
 }
 
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
 static inline void *map_io_sections(unsigned long phys, void *start, size_t size)
 {
 	return (void *)phys;
 }
 
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	return 0;
+}
+
 #endif
 
 #ifdef CONFIG_CACHE_L2X0
diff --git a/arch/blackfin/include/asm/mmu.h b/arch/blackfin/include/asm/mmu.h
new file mode 100644
index 0000000..71f671f
--- /dev/null
+++ b/arch/blackfin/include/asm/mmu.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/mips/include/asm/mmu.h b/arch/mips/include/asm/mmu.h
new file mode 100644
index 0000000..71f671f
--- /dev/null
+++ b/arch/mips/include/asm/mmu.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/nios2/include/asm/mmu.h b/arch/nios2/include/asm/mmu.h
new file mode 100644
index 0000000..71f671f
--- /dev/null
+++ b/arch/nios2/include/asm/mmu.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/openrisc/include/asm/mmu.h b/arch/openrisc/include/asm/mmu.h
new file mode 100644
index 0000000..71f671f
--- /dev/null
+++ b/arch/openrisc/include/asm/mmu.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/ppc/include/asm/mmu.h b/arch/ppc/include/asm/mmu.h
index b2dd0b7..799653a 100644
--- a/arch/ppc/include/asm/mmu.h
+++ b/arch/ppc/include/asm/mmu.h
@@ -540,4 +540,19 @@ extern int write_bat(ppc_bat_t bat, unsigned long upper, unsigned long lower);
 					(rt<<21)|(ra<<16)|(ws<<11)|(946<<1)
 
 #endif
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
 #endif /* _PPC_MMU_H_ */
diff --git a/arch/sandbox/include/asm/mmu.h b/arch/sandbox/include/asm/mmu.h
new file mode 100644
index 0000000..71f671f
--- /dev/null
+++ b/arch/sandbox/include/asm/mmu.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
new file mode 100644
index 0000000..71f671f
--- /dev/null
+++ b/arch/x86/include/asm/mmu.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/include/common.h b/include/common.h
index b1c96de..3e67164 100644
--- a/include/common.h
+++ b/include/common.h
@@ -225,6 +225,8 @@ int run_shell(void);
 
 #define PAGE_SIZE	4096
 #define PAGE_SHIFT	12
+#define PAGE_ALIGN(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
+#define PAGE_ALIGN_DOWN(x) ((x) & ~(PAGE_SIZE - 1))
 
 int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab);
 
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-01-13 17:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-13 17:42 [PATCH 0/9] reimplement memtest command Alexander Aring
2013-01-13 17:42 ` [PATCH 1/9] meminfo: fix missing include Alexander Aring
2013-01-13 17:42 ` [PATCH 2/9] memory: fix size address calculation Alexander Aring
2013-01-13 17:42 ` [PATCH 3/9] meminfo: fix display of allocated addresses Alexander Aring
2013-01-13 17:42 ` [PATCH 4/9] arm-mmu: remove semicolon in arm mmu.c Alexander Aring
2013-01-13 17:42 ` Alexander Aring [this message]
2013-01-13 17:42 ` [PATCH 6/9] memory: add function address_in_sdram_regions Alexander Aring
2013-01-13 17:42 ` [PATCH 7/9] barebox-data: add barebox-data sections Alexander Aring
2013-01-14  9:51   ` Sascha Hauer
2013-01-14 10:39     ` Alexander Aring
2013-01-13 17:42 ` [PATCH 8/9] memtest: remove memtest command Alexander Aring
2013-01-13 17:42 ` [PATCH 9/9] memtest: add rewritten " Alexander Aring
2013-01-14 13:11 ` [PATCH 0/9] reimplement " Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1358098943-18928-6-git-send-email-alex.aring@gmail.com \
    --to=alex.aring@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=marc@cpdesign.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox