[coreboot-gerrit] New patch to review for coreboot: 32a3d97 ARMV7: add a function to disable MMU entries

Ronald G. Minnich (rminnich@gmail.com) gerrit at coreboot.org
Tue Apr 30 19:13:58 CEST 2013


Ronald G. Minnich (rminnich at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3160

-gerrit

commit 32a3d97b1f0357e33977f65ce719fa0e27a8de83
Author: Ronald G. Minnich <rminnich at gmail.com>
Date:   Tue Apr 30 10:11:30 2013 -0700

    ARMV7: add a function to disable MMU entries
    
    It is useful to be able to lock out certain address ranges,
    NULL being the most important example.
    
    void mmu_disable_range(unsigned long start_mb, unsigned long size_mb)
    
    Will allow us to lock out selected virtual addresses on MiB boundaries.
    As in other ARM mmu functions, the addresses and quantities are in units
    of MiB.
    
    Change-Id: If516ce955ee2d12c5a409f25acbb5a4b424f699b
    Signed-off-by: Ronald G. Minnich <rminnich at gmail.com>
---
 src/arch/armv7/include/arch/cache.h |  2 ++
 src/arch/armv7/lib/mmu.c            | 14 ++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/src/arch/armv7/include/arch/cache.h b/src/arch/armv7/include/arch/cache.h
index 1db86dc..df335a0 100644
--- a/src/arch/armv7/include/arch/cache.h
+++ b/src/arch/armv7/include/arch/cache.h
@@ -297,6 +297,8 @@ enum dcache_policy {
 	DCACHE_WRITETHROUGH,
 };
 
+/* disable the mmu for a range. Primarily useful to lock out address 0. */
+void mmu_disable_range(unsigned long start_mb, unsigned long size_mb);
 /* mmu range configuration (set dcache policy) */
 void mmu_config_range(unsigned long start_mb, unsigned long size_mb,
 						enum dcache_policy policy);
diff --git a/src/arch/armv7/lib/mmu.c b/src/arch/armv7/lib/mmu.c
index 224b566..9d61c56 100644
--- a/src/arch/armv7/lib/mmu.c
+++ b/src/arch/armv7/lib/mmu.c
@@ -39,6 +39,20 @@
 
 static uintptr_t ttb_addr;
 
+void mmu_disable_range(unsigned long start_mb, unsigned long size_mb)
+{
+	unsigned int i;
+	uint32_t *ttb_entry = (uint32_t *)ttb_addr;
+	printk(BIOS_DEBUG, "Disabling: 0x%08lx:0x%08lx\n",
+			start_mb << 20, ((start_mb + size_mb) << 20) - 1);
+
+	for (i = start_mb; i < start_mb + size_mb; i++)
+		ttb_entry[i] = 0;
+
+	/* TODO: add helper to invalidate TLB by MVA */
+	tlb_invalidate_all();
+}
+
 void mmu_config_range(unsigned long start_mb, unsigned long size_mb,
 		enum dcache_policy policy)
 {



More information about the coreboot-gerrit mailing list