]> granicus.if.org Git - esp-idf/blob - components/spi_flash/cache_utils.h
console/linenoise: support buffered stdout
[esp-idf] / components / spi_flash / cache_utils.h
1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef ESP_SPI_FLASH_CACHE_UTILS_H
16 #define ESP_SPI_FLASH_CACHE_UTILS_H
17
18 /**
19  * This header file contains declarations of cache manipulation functions
20  * used both in flash_ops.c and flash_mmap.c.
21  *
22  * These functions are considered internal and are not designed to be called from applications.
23  */
24
25 // Init mutex protecting access to spi_flash_* APIs
26 void spi_flash_init_lock();
27
28 // Take mutex protecting access to spi_flash_* APIs
29 void spi_flash_op_lock();
30
31 // Release said mutex
32 void spi_flash_op_unlock();
33
34 // Suspend the scheduler on both CPUs, disable cache.
35 // Contrary to its name this doesn't do anything with interrupts, yet.
36 // Interrupt disabling capability will be added once we implement
37 // interrupt allocation API.
38 void spi_flash_disable_interrupts_caches_and_other_cpu();
39
40 // Enable cache, enable interrupts (to be added in future), resume scheduler
41 void spi_flash_enable_interrupts_caches_and_other_cpu();
42
43 // Disables non-IRAM interrupt handlers on current CPU and caches on both CPUs.
44 // This function is implied to be called when other CPU is not running or running code from IRAM.
45 void spi_flash_disable_interrupts_caches_and_other_cpu_no_os();
46
47 // Enable cache, enable interrupts on current CPU.
48 // This function is implied to be called when other CPU is not running or running code from IRAM.
49 void spi_flash_enable_interrupts_caches_no_os();
50
51 // Mark the pages containing a flash region as having been
52 // erased or written to. This means the flash cache needs
53 // to be evicted before these pages can be flash_mmap()ed again,
54 // as they may contain stale data
55 //
56 // Only call this while holding spi_flash_op_lock()
57 void spi_flash_mark_modified_region(uint32_t start_addr, uint32_t length);
58
59 #endif //ESP_SPI_FLASH_CACHE_UTILS_H