authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-07-07 00:37:25+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-07-07 09:05:07+02:00
log9a1e754a58a6d85be220aee2de56db464e42bc33
tree52a3fdf100140104e23d71f5aceef4cbef67a2d0
parent5209e7e458f6522778c5da62623627bd8f06d007

compiler-rt: Implement __clear_cache() for mips-netbsd


1 files changed, 20 insertions(+), 0 deletions(-)

lib/compiler_rt/clear_cache.zig+20
...@@ -86,6 +86,26 @@ fn clear_cache(start: usize, end: usize) callconv(.c) void {...@@ -86,6 +86,26 @@ fn clear_cache(start: usize, end: usize) callconv(.c) void {
86 const result = std.os.linux.syscall3(.cacheflush, start, end - start, flags);86 const result = std.os.linux.syscall3(.cacheflush, start, end - start, flags);
87 std.debug.assert(result == 0);87 std.debug.assert(result == 0);
88 exportIt();88 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();
89 } else if (mips and os == .openbsd) {109 } else if (mips and os == .openbsd) {
90 // TODO110 // TODO
91 //cacheflush(start, (uintptr_t)end - (uintptr_t)start, BCACHE);111 //cacheflush(start, (uintptr_t)end - (uintptr_t)start, BCACHE);