* @brief Flush the cache for a specified memory region. * * This function flushes the cache for a specified memory region. It is commonly used * to ensure that the contents of a memory region are written back to the main memory * or that stale cache entries are invalidated. The cache operation can be controlled * by the `cache` parameter to determine whether to clean or invalidate the cache.
| 9422 | * cache coherence between memory and cache is critical. |
| 9423 | */ |
| 9424 | rt_weak sysret_t sys_cacheflush(void *addr, int size, int cache) |
| 9425 | { |
| 9426 | if (!lwp_user_accessable(addr, size)) |
| 9427 | return -EFAULT; |
| 9428 | |
| 9429 | if (((size_t)addr < (size_t)addr + size) && |
| 9430 | ((size_t)addr >= USER_VADDR_START) && |
| 9431 | ((size_t)addr + size < USER_VADDR_TOP)) |
| 9432 | { |
| 9433 | if ((cache & DCACHE)) |
| 9434 | { |
| 9435 | rt_hw_cpu_dcache_clean_and_invalidate(addr, size); |
| 9436 | } |
| 9437 | |
| 9438 | if ((cache & ICACHE)) |
| 9439 | { |
| 9440 | rt_hw_cpu_icache_invalidate(addr, size); |
| 9441 | } |
| 9442 | |
| 9443 | return 0; |
| 9444 | } |
| 9445 | return -EFAULT; |
| 9446 | } |
| 9447 | |
| 9448 | /** |
| 9449 | * @brief Get system information. |
nothing calls this directly
no test coverage detected