David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. |
| 3 | |
| 4 | #include <linux/syscalls.h> |
| 5 | #include <asm/page.h> |
| 6 | #include <asm/cache.h> |
| 7 | #include <asm/cachectl.h> |
| 8 | |
| 9 | SYSCALL_DEFINE3(cacheflush, |
| 10 | void __user *, addr, |
| 11 | unsigned long, bytes, |
| 12 | int, cache) |
| 13 | { |
| 14 | switch (cache) { |
| 15 | case ICACHE: |
| 16 | icache_inv_range((unsigned long)addr, |
| 17 | (unsigned long)addr + bytes); |
| 18 | break; |
| 19 | case DCACHE: |
| 20 | dcache_wb_range((unsigned long)addr, |
| 21 | (unsigned long)addr + bytes); |
| 22 | break; |
| 23 | case BCACHE: |
| 24 | cache_wbinv_range((unsigned long)addr, |
| 25 | (unsigned long)addr + bytes); |
| 26 | break; |
| 27 | default: |
| 28 | return -EINVAL; |
| 29 | } |
| 30 | |
| 31 | return 0; |
| 32 | } |