You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/06/18 05:53:52 UTC

[incubator-nuttx] 03/06: risc-v/esp32c3/esp32c3_soc.h: Add a function to check if a pointer is within the RTC RAM range.

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

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

commit 7198b3ef4b8bd58d984f4b9c5f3f4b61c4e0f322
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Mon Jun 14 11:18:37 2021 +0100

    risc-v/esp32c3/esp32c3_soc.h: Add a function to check if a pointer is
    within the RTC RAM range.
    
    Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
 arch/risc-v/src/esp32c3/hardware/esp32c3_soc.h | 28 ++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/arch/risc-v/src/esp32c3/hardware/esp32c3_soc.h b/arch/risc-v/src/esp32c3/hardware/esp32c3_soc.h
index e9cb06b..6818bc5 100644
--- a/arch/risc-v/src/esp32c3/hardware/esp32c3_soc.h
+++ b/arch/risc-v/src/esp32c3/hardware/esp32c3_soc.h
@@ -25,6 +25,8 @@
 #include <stdint.h>
 #include <stdbool.h>
 
+#include "esp32c3_attr.h"
+
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
@@ -119,12 +121,8 @@
 #define SOC_IRAM_HIGH           0x403e0000
 #define SOC_DRAM_LOW            0x3fc80000
 #define SOC_DRAM_HIGH           0x3fce0000
-#define SOC_RTC_IRAM_LOW        0x50000000 /* ESP32-C3 only has RTC fast memory */
-#define SOC_RTC_IRAM_HIGH       0x50002000
-#define SOC_RTC_DRAM_LOW        0x50000000
-#define SOC_RTC_DRAM_HIGH       0x50002000
-#define SOC_RTC_DATA_LOW        0x50000000
-#define SOC_RTC_DATA_HIGH       0x50002000
+#define SOC_RTC_RAM_LOW         0x50000000 /* ESP32-C3 only has RTC fast memory */
+#define SOC_RTC_RAM_HIGH        0x50002000
 
 /* First and last words of the D/IRAM region, for both the DRAM address as
  * well as the IRAM alias.
@@ -306,4 +304,22 @@
 #define SOC_SYSTIMER_BIT_WIDTH_LO (32) /* Bit width of systimer low part */
 #define SOC_SYSTIMER_BIT_WIDTH_HI (20) /* Bit width of systimer high part */
 
+/****************************************************************************
+ * Inline Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp32c3_ptr_rtc
+ *
+ * Description:
+ *   Check if the buffer comes from the RTC RAM.
+ *
+ ****************************************************************************/
+
+static inline bool IRAM_ATTR esp32c3_ptr_rtc(const void *p)
+{
+  return ((intptr_t)p >= SOC_RTC_RAM_LOW &&
+          (intptr_t)p < SOC_RTC_RAM_HIGH);
+}
+
 #endif /* __ARCH_RISCV_SRC_ESP32C3_HARDWARE_ESP32C3_SOC_H */