1 /* RISC-V instruction cache flushing VDSO calls
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
20 #include <sys/syscall.h>
22 #ifndef __NR_riscv_flush_icache
23 #define __NR_riscv_flush_icache 259
26 typedef int (*func_type
) (void *, void *, unsigned long int);
29 __riscv_flush_icache_syscall (void *start
, void *end
, unsigned long int flags
)
31 return INLINE_SYSCALL (riscv_flush_icache
, 3, start
, end
, flags
);
35 __lookup_riscv_flush_icache (void)
37 /* always call the system call directly.*/
38 return &__riscv_flush_icache_syscall
;
42 __riscv_flush_icache (void *start
, void *end
, unsigned long int flags
)
44 static volatile func_type cached_func
;
46 func_type func
= atomic_load_relaxed (&cached_func
);
50 func
= __lookup_riscv_flush_icache ();
51 atomic_store_relaxed (&cached_func
, func
);
54 return func (start
, end
, flags
);