This is an automated email from the ASF dual-hosted git repository.

gustavonihei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit b4ea11f7b14d3168dab1951c4876d0626d632cf0
Author: zhuyanlin <[email protected]>
AuthorDate: Tue Oct 19 12:15:43 2021 +0800

    arch:cache: add lock feature for cache
    
    Some architectures support lock & unlock cache feature.
    
    Signed-off-by: zhuyanlin <[email protected]>
---
 arch/Kconfig          |  10 ++++
 include/nuttx/cache.h | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 140 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index 9171e8e..b2a933f 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -244,10 +244,20 @@ config ARCH_ICACHE
        bool
        default n
 
+config ARCH_ICACHE_LOCK
+       bool
+       depends on ARCH_ICACHE
+       default n
+
 config ARCH_DCACHE
        bool
        default n
 
+config ARCH_DCACHE_LOCK
+       bool
+       depends on ARCH_DCACHE
+       default n
+
 config ARCH_L2CACHE
        bool
        default n
diff --git a/include/nuttx/cache.h b/include/nuttx/cache.h
index 054eeff..139c034 100644
--- a/include/nuttx/cache.h
+++ b/include/nuttx/cache.h
@@ -133,6 +133,71 @@ void up_invalidate_icache_all(void);
 #endif
 
 /****************************************************************************
+ * Name: up_lock_icache
+ *
+ * Description:
+ *   Prefetch and lock the instruction cache within the specified region.
+ *   If the specified address if not present in the instruction cache,
+ *   some architectures transfer the line from memory, others wait the
+ *   address be read from memory, and then lock.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_ICACHE_LOCK
+void up_lock_icache(uintptr_t start, uintptr_t end);
+#else
+#  define up_lock_icache()
+#endif
+
+/****************************************************************************
+ * Name: up_unlock_icache
+ *
+ * Description:
+ *   Unlock the instruction cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_ICACHE_LOCK
+void up_unlock_icache(uintptr_t start, uintptr_t end);
+#else
+#  define up_unlock_icache()
+#endif
+
+/****************************************************************************
+ * Name: up_unlock_icache_all
+ *
+ * Description:
+ *   Unlock the entire contents of instruction cache.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_ICACHE_LOCK
+void up_unlock_icache_all(void);
+#else
+#  define up_unlock_icache_all()
+#endif
+
+/****************************************************************************
  * Name: up_enable_dcache
  *
  * Description:
@@ -304,6 +369,71 @@ void up_flush_dcache_all(void);
 #endif
 
 /****************************************************************************
+ * Name: up_lock_dcache
+ *
+ * Description:
+ *   Prefetch and lock the data cache within the specified region.
+ *   If the specified address is not present in the data cache,
+ *   some architectures transfer the line from memory, others wait the
+ *   address be read from memory, and then lock.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_DCACHE_LOCK
+void up_lock_dcache(uintptr_t start, uintptr_t end);
+#else
+#  define up_lock_dcache()
+#endif
+
+/****************************************************************************
+ * Name: up_unlock_dcache
+ *
+ * Description:
+ *   Unlock the data cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_DCACHE_LOCK
+void up_unlock_dcache(uintptr_t start, uintptr_t end);
+#else
+#  define up_unlock_dcache()
+#endif
+
+/****************************************************************************
+ * Name: up_unlock_dcache_all
+ *
+ * Description:
+ *   Unlock the entire contents of data cache.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_DCACHE_LOCK
+void up_unlock_dcache_all(void);
+#else
+#  define up_unlock_dcache_all()
+#endif
+
+/****************************************************************************
  * Name: up_coherent_dcache
  *
  * Description:

Reply via email to