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> |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 6 | #include <asm/cacheflush.h> |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 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) { |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 15 | case BCACHE: |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 16 | case DCACHE: |
| 17 | dcache_wb_range((unsigned long)addr, |
| 18 | (unsigned long)addr + bytes); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 19 | if (cache != BCACHE) |
| 20 | break; |
| 21 | fallthrough; |
| 22 | case ICACHE: |
| 23 | flush_icache_mm_range(current->mm, |
| 24 | (unsigned long)addr, |
| 25 | (unsigned long)addr + bytes); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 26 | break; |
| 27 | default: |
| 28 | return -EINVAL; |
| 29 | } |
| 30 | |
| 31 | return 0; |
| 32 | } |