1 /* 2 * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /* INTERNAL API 8 * generic interface to MMU memory protection features 9 */ 10 11 #pragma once 12 #include <stdbool.h> 13 #include <stdint.h> 14 #include "esp_attr.h" 15 #include "esp_err.h" 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 //convenient constants for better code readabilty 22 #define RD_ENA true 23 #define RD_DIS false 24 #define WR_ENA true 25 #define WR_DIS false 26 #define EX_ENA true 27 #define EX_DIS false 28 #define RD_LOW_ENA true 29 #define RD_LOW_DIS false 30 #define WR_LOW_ENA true 31 #define WR_LOW_DIS false 32 #define EX_LOW_ENA true 33 #define EX_LOW_DIS false 34 #define RD_HIGH_ENA true 35 #define RD_HIGH_DIS false 36 #define WR_HIGH_ENA true 37 #define WR_HIGH_DIS false 38 #define EX_HIGH_ENA true 39 #define EX_HIGH_DIS false 40 #define PANIC_HNDL_ON true 41 #define PANIC_HNDL_OFF false 42 #define MEMPROT_LOCK true 43 #define MEMPROT_UNLOCK false 44 #define DEF_SPLIT_LINE NULL 45 46 #define MEMPROT_INVALID_ADDRESS -1 47 48 //memory range types 49 typedef enum { 50 MEMPROT_NONE = 0x00000000, 51 MEMPROT_IRAM0_SRAM = 0x00000001, //0x40020000-0x4006FFFF, RWX 52 MEMPROT_DRAM0_SRAM = 0x00000002, //0x3FFB0000-0x3FFFFFFF, RW 53 MEMPROT_IRAM0_RTCFAST = 0x00000004, //0x40070000-0x40071FFF, RWX 54 MEMPROT_DRAM0_RTCFAST = 0x00000008, //0x3FF9E000-0x3FF9FFFF, RW 55 MEMPROT_PERI1_RTCSLOW = 0x00000010, //0x3F421000-0x3F423000, RW 56 MEMPROT_PERI2_RTCSLOW_0 = 0x00000020, //0x50001000-0x50003000, RWX 57 MEMPROT_PERI2_RTCSLOW_1 = 0x00000040, //0x60002000-0x60004000, RWX 58 MEMPROT_ALL = 0xFFFFFFFF 59 } mem_type_prot_t; 60 61 62 /** 63 * @brief Returns splitting address for required memory region 64 * 65 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 66 * 67 * @return Splitting address for the memory region required. 68 * The address is given by region-specific global symbol exported from linker script, 69 * it is not read out from related configuration register. 70 */ 71 uint32_t *IRAM_ATTR esp_memprot_get_split_addr(mem_type_prot_t mem_type); 72 73 /** 74 * @brief Initializes illegal memory access control for required memory section. 75 * 76 * All memory access interrupts share ETS_MEMACCESS_ERR_INUM input channel, it is caller's 77 * responsibility to properly detect actual intr. source as well as possible prioritization in case 78 * of multiple source reported during one intr.handling routine run 79 * 80 * @param mem_type Memory protection area type (see mem_type_prot_t enum)\ 81 * 82 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 83 */ 84 esp_err_t esp_memprot_intr_init(mem_type_prot_t mem_type); 85 86 /** 87 * @brief Enable/disable the memory protection interrupt 88 * 89 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 90 * @param enable enable/disable 91 * 92 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 93 */ 94 esp_err_t esp_memprot_intr_ena(mem_type_prot_t mem_type, bool enable); 95 96 /** 97 * @brief Sets a request for clearing interrupt-on flag for specified memory region (register write) 98 * 99 * @note When called without actual interrupt-on flag set, subsequent occurrence of related interrupt is ignored. 100 * Should be used only after the real interrupt appears, typically as the last step in interrupt handler's routine. 101 * 102 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 103 * 104 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 105 */ 106 esp_err_t esp_memprot_clear_intr(mem_type_prot_t mem_type); 107 108 /** 109 * @brief Detects which memory protection interrupt is active 110 * 111 * @note Check order 112 * MEMPROT_IRAM0_SRAM 113 * MEMPROT_IRAM0_RTCFAST 114 * MEMPROT_DRAM0_SRAM 115 * MEMPROT_DRAM0_RTCFAST 116 * 117 * @return Memory protection area type (see mem_type_prot_t enum) 118 */ 119 mem_type_prot_t IRAM_ATTR esp_memprot_get_active_intr_memtype(void); 120 121 /** 122 * @brief Gets interrupt status register contents for specified memory region 123 * 124 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 125 * @param fault_reg_val Contents of status register 126 * 127 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 128 */ 129 esp_err_t esp_memprot_get_fault_reg(mem_type_prot_t mem_type, uint32_t *fault_reg_val); 130 131 /** 132 * @brief Get details of given interrupt status 133 * 134 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 135 * @param faulting_address Faulting address causing the interrupt [out] 136 * @param op_type Operation being processed at the faulting address [out] 137 * IRAM0: 0 - read, 1 - write 138 * DRAM0: 0 - read, 1 - write 139 * @param op_subtype Additional info for op_type [out] 140 * IRAM0: 0 - instruction segment access, 1 - data segment access 141 * DRAM0: 0 - non-atomic operation, 1 - atomic operation 142 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 143 */ 144 esp_err_t IRAM_ATTR esp_memprot_get_fault_status(mem_type_prot_t mem_type, uint32_t **faulting_address, uint32_t *op_type, uint32_t *op_subtype); 145 146 /** 147 * @brief Gets string representation of required memory region identifier 148 * 149 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 150 * 151 * @return mem_type as string 152 */ 153 const char *IRAM_ATTR esp_memprot_type_to_str(mem_type_prot_t mem_type); 154 155 /** 156 * @brief Detects whether any of the interrupt locks is active (requires digital system reset to unlock) 157 * 158 * @return true/false 159 */ 160 bool esp_memprot_is_locked_any(void); 161 162 /** 163 * @brief Sets lock for specified memory region. 164 * 165 * Locks can be unlocked only by digital system reset 166 * 167 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 168 * 169 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 170 */ 171 esp_err_t esp_memprot_set_lock(mem_type_prot_t mem_type); 172 173 /** 174 * @brief Gets lock status for required memory region 175 * 176 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 177 * @param locked Settings locked: true/false (locked/unlocked) 178 * 179 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 180 */ 181 esp_err_t esp_memprot_get_lock(mem_type_prot_t mem_type, bool *locked); 182 183 /** 184 * @brief Gets permission control configuration register contents for required memory region 185 * 186 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 187 * @param conf_reg_val Permission control register contents 188 * 189 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 190 */ 191 esp_err_t esp_memprot_get_conf_reg(mem_type_prot_t mem_type, uint32_t *conf_reg_val); 192 193 /** 194 * @brief Gets interrupt permission settings for unified management block 195 * 196 * Gets interrupt permission settings register contents for required memory region, returns settings for unified management blocks 197 * 198 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 199 * @param perm_reg Permission settings register contents 200 * 201 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 202 */ 203 esp_err_t esp_memprot_get_perm_uni_reg(mem_type_prot_t mem_type, uint32_t *perm_reg); 204 205 /** 206 * @brief Gets interrupt permission settings for split management block 207 * 208 * Gets interrupt permission settings register contents for required memory region (unified management blocks) 209 * 210 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 211 * @return split_reg Unified management settings register contents 212 * 213 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 214 */ 215 esp_err_t esp_memprot_get_perm_split_reg(mem_type_prot_t mem_type, uint32_t *split_reg); 216 217 /** 218 * @brief Detects whether any of the memory protection interrupts is enabled 219 * 220 * @return true/false 221 */ 222 bool esp_memprot_is_intr_ena_any(void); 223 224 /** 225 * @brief Gets interrupt-enabled flag for given memory region 226 * 227 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 228 * @param enable_bit Interrupt-enabled flag 229 * 230 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 231 */ 232 esp_err_t esp_memprot_get_intr_ena_bit(mem_type_prot_t mem_type, uint32_t *enable_bit); 233 234 /** 235 * @brief Gets interrupt-active flag for given memory region 236 * 237 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 238 * @param intr_on_bit Interrupt-active flag 239 * 240 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ 241 esp_err_t esp_memprot_get_intr_on_bit(mem_type_prot_t mem_type, uint32_t *intr_on_bit); 242 243 /** 244 * @brief Gets interrupt-clear request flag for given memory region 245 * 246 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 247 * @param clear_bit Interrupt-clear request flag 248 * 249 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 250 */ 251 esp_err_t esp_memprot_get_intr_clr_bit(mem_type_prot_t mem_type, uint32_t *clear_bit); 252 253 /** 254 * @brief Gets read permission value for specified block and memory region 255 * 256 * Returns read permission bit value for required unified-management block (0-3) in given memory region. 257 * Applicable to all memory types. 258 * 259 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 260 * @param block Memory block identifier (0-3) 261 * @param read_bit Read permission value for required block 262 * 263 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 264 */ 265 esp_err_t esp_memprot_get_uni_block_read_bit(mem_type_prot_t mem_type, uint32_t block, uint32_t *read_bit); 266 267 /** 268 * @brief Gets write permission value for specified block and memory region 269 * 270 * Returns write permission bit value for required unified-management block (0-3) in given memory region. 271 * Applicable to all memory types. 272 * 273 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 274 * @param block Memory block identifier (0-3) 275 * @param write_bit Write permission value for required block 276 * 277 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 278 */ 279 esp_err_t esp_memprot_get_uni_block_write_bit(mem_type_prot_t mem_type, uint32_t block, uint32_t *write_bit); 280 281 /** 282 * @brief Gets execute permission value for specified block and memory region 283 * 284 * Returns execute permission bit value for required unified-management block (0-3) in given memory region. 285 * Applicable only to IRAM memory types 286 * 287 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 288 * @param block Memory block identifier (0-3) 289 * @param exec_bit Execute permission value for required block 290 * 291 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 292 */ 293 esp_err_t esp_memprot_get_uni_block_exec_bit(mem_type_prot_t mem_type, uint32_t block, uint32_t *exec_bit); 294 295 /** 296 * @brief Sets permissions for specified block in DRAM region 297 * 298 * Sets Read and Write permission for specified unified-management block (0-3) in given memory region. 299 * Applicable only to DRAM memory types 300 * 301 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 302 * @param block Memory block identifier (0-3) 303 * @param write_perm Write permission flag 304 * @param read_perm Read permission flag 305 * 306 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 307 */ 308 esp_err_t esp_memprot_set_uni_block_perm_dram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm); 309 310 /** 311 * @brief Sets permissions for high and low memory segment in DRAM region 312 * 313 * Sets Read and Write permission for both low and high memory segments given by splitting address. 314 * The splitting address must be equal to or higher then beginning of block 5 315 * Applicable only to DRAM memory types 316 * 317 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 318 * @param split_addr Address to split the memory region to lower and higher segment 319 * @param lw Low segment Write permission flag 320 * @param lr Low segment Read permission flag 321 * @param hw High segment Write permission flag 322 * @param hr High segment Read permission flag 323 * 324 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 325 */ 326 esp_err_t esp_memprot_set_prot_dram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); 327 328 /** 329 * @brief Sets permissions for specified block in IRAM region 330 * 331 * Sets Read, Write and Execute permission for specified unified-management block (0-3) in given memory region. 332 * Applicable only to IRAM memory types 333 * 334 * @param mem_type Memory protection area type (MEMPROT_IRAM0_SRAM) 335 * @param block Memory block identifier (0-3) 336 * @param write_perm Write permission flag 337 * @param read_perm Read permission flag 338 * @param exec_perm Execute permission flag 339 * 340 * @return ESP_OK on success 341 * ESP_ERR_NOT_SUPPORTED on invalid mem_type 342 * ESP_ERR_INVALID_ARG on incorrect block number 343 */ 344 esp_err_t esp_memprot_set_uni_block_perm_iram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm, bool exec_perm); 345 346 /** 347 * @brief Sets permissions for high and low memory segment in IRAM region 348 * 349 * Sets Read, Write and Execute permission for both low and high memory segments given by splitting address. 350 * The splitting address must be equal to or higher then beginning of block 5 351 * Applicable only to IRAM memory types 352 * 353 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 354 * @param split_addr Address to split the memory region to lower and higher segment 355 * @param lw Low segment Write permission flag 356 * @param lr Low segment Read permission flag 357 * @param lx Low segment Execute permission flag 358 * @param hw High segment Write permission flag 359 * @param hr High segment Read permission flag 360 * @param hx High segment Execute permission flag 361 * 362 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 363 */ 364 esp_err_t esp_memprot_set_prot_iram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); 365 366 /** 367 * @brief Activates memory protection for all supported memory region types 368 * 369 * @note The feature is disabled when JTAG interface is connected 370 * 371 * @param invoke_panic_handler map mem.prot interrupt to ETS_MEMACCESS_ERR_INUM and thus invokes panic handler when fired ('true' not suitable for testing) 372 * @param lock_feature sets LOCK bit, see esp_memprot_set_lock() ('true' not suitable for testing) 373 * @param mem_type_mask holds a set of required memory protection types (bitmask built of mem_type_prot_t). NULL means default (MEMPROT_ALL in this version) 374 * 375 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 376 */ 377 esp_err_t esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uint32_t *mem_type_mask); 378 379 /** 380 * @brief Get permission settings bits for IRAM0 split mgmt. Only IRAM0 memory types allowed 381 * 382 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 383 * @param lw Low segment Write permission flag 384 * @param lr Low segment Read permission flag 385 * @param lx Low segment Execute permission flag 386 * @param hw High segment Write permission flag 387 * @param hr High segment Read permission flag 388 * @param hx High segment Execute permission flag 389 * 390 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 391 */ 392 esp_err_t esp_memprot_get_perm_split_bits_iram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); 393 394 /** 395 * @brief Get permission settings bits for DRAM0 split mgmt. Only DRAM0 memory types allowed 396 * 397 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 398 * @param lw Low segment Write permission flag 399 * @param lr Low segment Read permission flag 400 * @param hw High segment Write permission flag 401 * @param hr High segment Read permission flag 402 * 403 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 404 */ 405 esp_err_t esp_memprot_get_perm_split_bits_dram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); 406 407 /** 408 * @brief Sets permissions for high and low memory segment in PERIBUS1 region 409 * 410 * Sets Read and Write permission for both low and high memory segments given by splitting address. 411 * Applicable only to PERIBUS1 memory types 412 * 413 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 414 * @param split_addr Address to split the memory region to lower and higher segment 415 * @param lw Low segment Write permission flag 416 * @param lr Low segment Read permission flag 417 * @param hw High segment Write permission flag 418 * @param hr High segment Read permission flag 419 * 420 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 421 */ 422 esp_err_t esp_memprot_set_prot_peri1(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); 423 424 /** 425 * @brief Get permission settings bits for PERIBUS1 split mgmt. Only PERIBUS1 memory types allowed 426 * 427 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 428 * @param lw Low segment Write permission flag 429 * @param lr Low segment Read permission flag 430 * @param hw High segment Write permission flag 431 * @param hr High segment Read permission flag 432 * 433 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 434 */ 435 esp_err_t esp_memprot_get_perm_split_bits_peri1(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); 436 437 /** 438 * @brief Get permission settings bits for PERIBUS2 split mgmt. Only PERIBUS2 memory types allowed 439 * 440 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 441 * @param lw Low segment Write permission flag 442 * @param lr Low segment Read permission flag 443 * @param lx Low segment Execute permission flag 444 * @param hw High segment Write permission flag 445 * @param hr High segment Read permission flag 446 * @param hx High segment Execute permission flag 447 * 448 * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure 449 */ 450 esp_err_t esp_memprot_get_perm_split_bits_peri2(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); 451 452 /** 453 * @brief Configures the memory protection for high and low segment in PERIBUS2 region 454 * 455 * Sets Read Write permission for both low and high memory segments given by splitting address. 456 * Applicable only to PERIBUS2 memory types 457 * 458 * @param mem_type Memory protection area type (MEMPROT_PERI2_RTCSLOW_0, MEMPROT_PERI2_RTCSLOW_1) 459 * @param split_addr Address to split the memory region to lower and higher segment (32bit aligned) 460 * @param lw Low segment Write permission flag 461 * @param lr Low segment Read permission flag 462 * @param lx Low segment Execute permission flag 463 * @param hw High segment Write permission flag 464 * @param hr High segment Read permission flag 465 * @param hx High segment Execute permission flag 466 * 467 * @return ESP_OK on success 468 * ESP_ERR_NOT_SUPPORTED on invalid mem_type 469 * ESP_ERR_INVALID_STATE on splitting address out of PERIBUS2 range 470 * ESP_ERR_INVALID_SIZE on splitting address not 32-bit aligned 471 */ 472 esp_err_t esp_memprot_set_prot_peri2(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); 473 474 /** 475 * @brief Get permissions for specified memory type. Irrelevant bits are ignored 476 * 477 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 478 * @param lw Low segment Write permission flag 479 * @param lr Low segment Read permission flag 480 * @param lx Low segment Execute permission flag 481 * @param hw High segment Write permission flag 482 * @param hr High segment Read permission flag 483 * @param hx High segment Execute permission flag 484 * 485 * @return ESP_OK on success 486 * ESP_ERR_INVALID_ARG on NULL lw/lr/lx/hw/hr/hx args 487 * ESP_ERR_NOT_SUPPORTED on invalid mem_type 488 */ 489 esp_err_t esp_memprot_get_permissions(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); 490 491 /** 492 * @brief Get Read permission settings for low and high regions of given memory type 493 * 494 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 495 * @param lr Low segment Read permission flag 496 * @param hr High segment Read permission flag 497 * 498 * @return ESP_OK on success 499 * ESP_ERR_INVALID_ARG on NULL lr/hr args 500 * ESP_ERR_NOT_SUPPORTED on invalid mem_type 501 */ 502 esp_err_t esp_memprot_get_perm_read(mem_type_prot_t mem_type, bool *lr, bool *hr); 503 504 /** 505 * @brief Get Write permission settings for low and high regions of given memory type 506 * 507 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 508 * @param lr Low segment Write permission flag 509 * @param hr High segment Write permission flag 510 * 511 * @return ESP_OK on success 512 * ESP_ERR_INVALID_ARG on NULL lw/hw args 513 * ESP_ERR_NOT_SUPPORTED on invalid mem_type 514 */ 515 esp_err_t esp_memprot_get_perm_write(mem_type_prot_t mem_type, bool *lw, bool *hw); 516 517 /** 518 * @brief Get Execute permission settings for low and high regions of given memory type 519 * Applicable only to IBUS-compatible memory types 520 * 521 * @param mem_type Memory protection area type (MEMPROT_IRAM0_SRAM, MEMPROT_IRAM0_RTCFAST, MEMPROT_PERI2_RTCSLOW_0, MEMPROT_PERI2_RTCSLOW_1) 522 * @param lx Low segment Exec permission flag 523 * @param hx High segment Exec permission flag 524 * 525 * @return ESP_OK on success 526 * ESP_ERR_INVALID_ARG on NULL lx/hx args 527 * ESP_ERR_NOT_SUPPORTED on invalid mem_type 528 */ 529 esp_err_t esp_memprot_get_perm_exec(mem_type_prot_t mem_type, bool *lx, bool *hx); 530 531 /** 532 * @brief Returns the lowest address in required memory region 533 * 534 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 535 * 536 * @return Required address or MEMPROT_INVALID_ADDRESS for invalid mem_type 537 */ 538 uint32_t esp_memprot_get_low_limit(mem_type_prot_t mem_type); 539 540 /** 541 * @brief Returns the highest address in required memory region 542 * 543 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 544 * 545 * @return Required address or MEMPROT_INVALID_ADDRESS for invalid mem_type 546 */ 547 uint32_t esp_memprot_get_high_limit(mem_type_prot_t mem_type); 548 549 /** 550 * @brief Sets READ permission bit for required memory region 551 * 552 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 553 * @param lr Low segment Read permission flag 554 * @param hr High segment Read permission flag 555 * 556 * @return ESP_OK on success 557 * ESP_ERR_NOT_SUPPORTED on invalid mem_type 558 */ 559 esp_err_t esp_memprot_set_read_perm(mem_type_prot_t mem_type, bool lr, bool hr); 560 561 /** 562 * @brief Sets WRITE permission bit for required memory region 563 * 564 * @param mem_type Memory protection area type (see mem_type_prot_t enum) 565 * @param lr Low segment Write permission flag 566 * @param hr High segment Write permission flag 567 * 568 * @return ESP_OK on success 569 * ESP_ERR_NOT_SUPPORTED on invalid mem_type 570 */ 571 esp_err_t esp_memprot_set_write_perm(mem_type_prot_t mem_type, bool lw, bool hw); 572 573 /** 574 * @brief Sets EXECUTE permission bit for required memory region 575 * 576 * @param mem_type Memory protection area type (MEMPROT_IRAM0_SRAM, MEMPROT_IRAM0_RTCFAST, MEMPROT_PERI2_RTCSLOW_0, MEMPROT_PERI2_RTCSLOW_1) 577 * @param lr Low segment Exec permission flag 578 * @param hr High segment Exec permission flag 579 * 580 * @return ESP_OK on success 581 * ESP_ERR_NOT_SUPPORTED on invalid mem_type 582 */ 583 esp_err_t esp_memprot_set_exec_perm(mem_type_prot_t mem_type, bool lx, bool hx); 584 585 586 #ifdef __cplusplus 587 } 588 #endif 589