MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / sys_cacheflush

Function sys_cacheflush

components/lwp/lwp_syscall.c:9424–9446  ·  view source on GitHub ↗

* @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.

Source from the content-addressed store, hash-verified

9422 * cache coherence between memory and cache is critical.
9423 */
9424rt_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.

Callers

nothing calls this directly

Tested by

no test coverage detected