Skip to content

Commit

Permalink
options/glibc: Add __riscv_flush_icache()
Browse files Browse the repository at this point in the history
  • Loading branch information
avdgrinten committed Dec 31, 2024
1 parent 264f3fc commit 8f9c93b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
16 changes: 16 additions & 0 deletions options/glibc/generic/sys-cachectl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <bits/ensure.h>
#include <errno.h>
#include <mlibc/glibc-sysdeps.hpp>
#include <sys/cachectl.h>

#ifdef __riscv
int __riscv_flush_icache(void *start, void *end, unsigned long flags) {
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_riscv_flush_icache, -1);

if(int e = sysdep(start, end, flags); e) {
errno = e;
return -1;
}
return 0;
}
#endif
4 changes: 4 additions & 0 deletions options/glibc/include/mlibc/glibc-sysdeps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ namespace [[gnu::visibility("hidden")]] mlibc {
[[gnu::weak]] int sys_ioperm(unsigned long int from, unsigned long int num, int turn_on);
[[gnu::weak]] int sys_iopl(int level);

#ifdef __riscv
[[gnu::weak]] int sys_riscv_flush_icache(void *start, void *end, unsigned long flags);
#endif

} // namespace mlibc

#endif // MLIBC_GLIBC_SYSDEPS
16 changes: 16 additions & 0 deletions options/glibc/include/sys/cachectl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef _SYS_CACHECTL_H
#define _SYS_CACHECTL_H

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __riscv
int __riscv_flush_icache(void *, void *, unsigned long);
#endif

#ifdef __cplusplus
}
#endif

#endif
2 changes: 2 additions & 0 deletions options/glibc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ libc_sources += files(
'generic/sys-timex.cpp',
'generic/glibc-assert.cpp',
'generic/malloc.cpp',
'generic/sys-cachectl.cpp',
'generic/sys-io.cpp',
'generic/search.cpp'
)
Expand All @@ -41,6 +42,7 @@ if not no_headers
'include/features.h'
)
install_headers(
'include/sys/cachectl.h',
'include/sys/dir.h',
'include/sys/ioctl.h',
'include/sys/user.h',
Expand Down

0 comments on commit 8f9c93b

Please sign in to comment.