mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-02 05:36:31 +00:00
esp32c3: memprot API upgrade and test application
Closes IDF-2641
This commit is contained in:
committed by
Angus Gratton
parent
2ed3e8b344
commit
6dfff2fdbd
@@ -26,6 +26,32 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//convenient constants for better code readabilty
|
||||
#define RD_ENA true
|
||||
#define RD_DIS false
|
||||
#define WR_ENA true
|
||||
#define WR_DIS false
|
||||
#define EX_ENA true
|
||||
#define EX_DIS false
|
||||
#define RD_LOW_ENA true
|
||||
#define RD_LOW_DIS false
|
||||
#define WR_LOW_ENA true
|
||||
#define WR_LOW_DIS false
|
||||
#define EX_LOW_ENA true
|
||||
#define EX_LOW_DIS false
|
||||
#define RD_HIGH_ENA true
|
||||
#define RD_HIGH_DIS false
|
||||
#define WR_HIGH_ENA true
|
||||
#define WR_HIGH_DIS false
|
||||
#define EX_HIGH_ENA true
|
||||
#define EX_HIGH_DIS false
|
||||
#define PANIC_HNDL_ON true
|
||||
#define PANIC_HNDL_OFF false
|
||||
#define MEMPROT_LOCK true
|
||||
#define MEMPROT_UNLOCK false
|
||||
#define DEF_SPLIT_LINE NULL
|
||||
|
||||
//memory range types
|
||||
typedef enum {
|
||||
MEMPROT_NONE = 0x00000000,
|
||||
MEMPROT_IRAM0_SRAM = 0x00000001, //0x40020000-0x4006FFFF, RWX
|
||||
|
||||
@@ -93,7 +93,7 @@ SECTIONS
|
||||
and will be retained during deep sleep.
|
||||
User data marked with RTC_NOINIT_ATTR will be placed
|
||||
into this section. See the file "esp_attr.h" for more information.
|
||||
The memory location of the data is dependent on
|
||||
The memory location of the data is dependent on
|
||||
CONFIG_ESP32S2_RTCDATA_IN_FAST_MEM option.
|
||||
*/
|
||||
.rtc_noinit (NOLOAD):
|
||||
@@ -186,6 +186,8 @@ SECTIONS
|
||||
|
||||
/* align + add 16B for CPU dummy speculative instr. fetch */
|
||||
. = ALIGN(4) + 16;
|
||||
/* iram_end_test section exists for use by memprot unit tests only */
|
||||
*(.iram_end_test)
|
||||
_iram_text_end = ABSOLUTE(.);
|
||||
_iram_end = ABSOLUTE(.);
|
||||
} > iram0_0_seg
|
||||
|
||||
@@ -694,25 +694,25 @@ void esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uint32_t
|
||||
|
||||
//set permissions
|
||||
if (required_mem_prot & MEMPROT_IRAM0_SRAM) {
|
||||
esp_memprot_set_prot_iram(MEMPROT_IRAM0_SRAM, NULL, false, true, true, true, true, true);
|
||||
esp_memprot_set_prot_iram(MEMPROT_IRAM0_SRAM, DEF_SPLIT_LINE, WR_LOW_DIS, RD_LOW_ENA, EX_LOW_ENA, WR_HIGH_DIS, RD_HIGH_DIS, EX_HIGH_DIS);
|
||||
}
|
||||
if (required_mem_prot & MEMPROT_IRAM0_RTCFAST) {
|
||||
esp_memprot_set_prot_iram(MEMPROT_IRAM0_RTCFAST, NULL, false, true, true, true, true, true);
|
||||
esp_memprot_set_prot_iram(MEMPROT_IRAM0_RTCFAST, DEF_SPLIT_LINE, WR_LOW_DIS, RD_LOW_ENA, EX_LOW_ENA, WR_HIGH_DIS, RD_HIGH_DIS, EX_HIGH_DIS);
|
||||
}
|
||||
if (required_mem_prot & MEMPROT_DRAM0_SRAM) {
|
||||
esp_memprot_set_prot_dram(MEMPROT_DRAM0_SRAM, NULL, false, true, true, true);
|
||||
esp_memprot_set_prot_dram(MEMPROT_DRAM0_SRAM, DEF_SPLIT_LINE, WR_LOW_DIS, RD_LOW_ENA, WR_HIGH_ENA, RD_HIGH_ENA);
|
||||
}
|
||||
if (required_mem_prot & MEMPROT_DRAM0_RTCFAST) {
|
||||
esp_memprot_set_prot_dram(MEMPROT_DRAM0_RTCFAST, NULL, false, true, true, true);
|
||||
esp_memprot_set_prot_dram(MEMPROT_DRAM0_RTCFAST, DEF_SPLIT_LINE, WR_LOW_DIS, RD_LOW_ENA, WR_HIGH_ENA, RD_HIGH_ENA);
|
||||
}
|
||||
if (required_mem_prot & MEMPROT_PERI1_RTCSLOW) {
|
||||
esp_memprot_set_prot_peri1(MEMPROT_PERI1_RTCSLOW, NULL, true, true, true, true);
|
||||
esp_memprot_set_prot_peri1(MEMPROT_PERI1_RTCSLOW, DEF_SPLIT_LINE, WR_LOW_DIS, RD_LOW_DIS, WR_HIGH_DIS, RD_HIGH_DIS);
|
||||
}
|
||||
if (required_mem_prot & MEMPROT_PERI2_RTCSLOW_0) {
|
||||
esp_memprot_set_prot_peri2(MEMPROT_PERI2_RTCSLOW_0, NULL, true, true, false, true, true, false);
|
||||
esp_memprot_set_prot_peri2(MEMPROT_PERI2_RTCSLOW_0, DEF_SPLIT_LINE, WR_LOW_ENA, RD_LOW_ENA, EX_LOW_DIS, WR_HIGH_ENA, RD_HIGH_ENA, EX_HIGH_DIS);
|
||||
}
|
||||
if (required_mem_prot & MEMPROT_PERI2_RTCSLOW_1) {
|
||||
esp_memprot_set_prot_peri2(MEMPROT_PERI2_RTCSLOW_1, NULL, true, true, false, true, true, false);
|
||||
esp_memprot_set_prot_peri2(MEMPROT_PERI2_RTCSLOW_1, DEF_SPLIT_LINE, WR_LOW_DIS, RD_LOW_DIS, EX_LOW_DIS, WR_HIGH_DIS, RD_HIGH_DIS, EX_HIGH_DIS);
|
||||
}
|
||||
|
||||
//reenable protection (bus based)
|
||||
|
||||
Reference in New Issue
Block a user