mm: make physical allocation blocking (WIP)

This commit is contained in:
Loïc Grégoire
2026-06-29 22:33:43 -04:00
parent 11c858c5e8
commit 85e6a8fec9
11 changed files with 160 additions and 72 deletions
+9 -10
View File
@@ -7,23 +7,22 @@ pub fn init() void {
mi.kernel_space.arena.init("kernel heap", mi.impl.kernel_heap_base, r.tib(16), mm.page_size) catch @panic("failed to initialize kernel heap arena");
}
pub fn alloc(size: usize) mm.Error!*anyopaque {
const ipl = mi.kernel_space.lock.acquire();
defer mi.kernel_space.lock.release(ipl);
pub fn alloc(size: usize, policy: mm.WaitPolicy) mm.Error!*anyopaque {
_ = policy;
mi.kernel_space.lock.acquire();
const addr = try mi.kernel_space.arena.alloc(size, .{});
mi.kernel_space.pmap.map_range_allocating(addr, size, .{
.read = true,
.write = true,
.global = false,
});
mi.kernel_space.pmap.map_range_allocating(addr, size, .{ .read = true, .write = true }, .DontWaitForMemory);
mi.kernel_space.lock.release();
return @ptrFromInt(addr);
}
pub fn free(va: r.VAddr, size: usize) void {
const ipl = mi.kernel_space.lock.acquire();
mi.kernel_space.lock.acquire();
mi.tlb.reclaim_range(&mi.kernel_space, va, size);
mi.kernel_space.lock.release(ipl);
mi.kernel_space.lock.release();
}