blob: cd847ad62c7ee4ccd45207473d118846afe432f3 [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001// 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 Deprez157378f2022-04-04 15:47:50 +02006#include <asm/cacheflush.h>
David Brazdil0f672f62019-12-10 10:32:29 +00007#include <asm/cachectl.h>
8
9SYSCALL_DEFINE3(cacheflush,
10 void __user *, addr,
11 unsigned long, bytes,
12 int, cache)
13{
14 switch (cache) {
Olivier Deprez157378f2022-04-04 15:47:50 +020015 case BCACHE:
David Brazdil0f672f62019-12-10 10:32:29 +000016 case DCACHE:
17 dcache_wb_range((unsigned long)addr,
18 (unsigned long)addr + bytes);
Olivier Deprez157378f2022-04-04 15:47:50 +020019 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 Brazdil0f672f62019-12-10 10:32:29 +000026 break;
27 default:
28 return -EINVAL;
29 }
30
31 return 0;
32}