Skip to content

Commit 9a1e754

Browse files
committed
compiler-rt: Implement __clear_cache() for mips-netbsd
1 parent 5209e7e commit 9a1e754

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/compiler_rt/clear_cache.zig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,26 @@ fn clear_cache(start: usize, end: usize) callconv(.c) void {
8686
const result = std.os.linux.syscall3(.cacheflush, start, end - start, flags);
8787
std.debug.assert(result == 0);
8888
exportIt();
89+
} else if (os == .netbsd and mips) {
90+
// Replace with https://github.com/ziglang/zig/issues/23904 in the future.
91+
const cfa: extern struct {
92+
va: usize,
93+
nbytes: usize,
94+
whichcache: u32,
95+
} = .{
96+
.va = start,
97+
.nbytes = end - start,
98+
.whichcache = 3, // ICACHE | DCACHE
99+
};
100+
asm volatile (
101+
\\ syscall
102+
:
103+
: [_] "{$2}" (165), // nr = SYS_sysarch
104+
[_] "{$4}" (0), // op = MIPS_CACHEFLUSH
105+
[_] "{$5}" (&cfa), // args = &cfa
106+
: "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory"
107+
);
108+
exportIt();
89109
} else if (mips and os == .openbsd) {
90110
// TODO
91111
//cacheflush(start, (uintptr_t)end - (uintptr_t)start, BCACHE);

0 commit comments

Comments
 (0)