spi_flash: Flush flash cache if flash_mmap()ing a written-to page

Without this, it's possible for stale information to be read from
cache via mmap, even if the MMU table entry had been invalidated
prior to writing flash (if  the same MMU table entry was re-used after
writing flash.)
This commit is contained in:
Angus Gratton
2017-01-05 15:51:02 +11:00
committed by Ivan Grokhotkov
parent 95c150fe2c
commit 36ccdee6ec
7 changed files with 170 additions and 6 deletions

View File

@@ -48,4 +48,12 @@ void spi_flash_disable_interrupts_caches_and_other_cpu_no_os();
// This function is implied to be called when other CPU is not running or running code from IRAM.
void spi_flash_enable_interrupts_caches_no_os();
// Mark the pages containing a flash region as having been
// erased or written to. This means the flash cache needs
// to be evicted before these pages can be flash_mmap()ed again,
// as they may contain stale data
//
// Only call this while holding spi_flash_op_lock()
void spi_flash_mark_modified_region(uint32_t start_addr, uint32_t length);
#endif //ESP_SPI_FLASH_CACHE_UTILS_H