From 7198b3ef4b8bd58d984f4b9c5f3f4b61c4e0f322 Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Mon, 14 Jun 2021 11:18:37 +0100 Subject: [PATCH] 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 --- .../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 e9cb06b1c5d..6818bc5ab9c 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 #include +#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 */