diff --git a/src/mm/heap.zig b/src/mm/heap.zig index 98ecf73..fb155fd 100644 --- a/src/mm/heap.zig +++ b/src/mm/heap.zig @@ -10,7 +10,7 @@ pub fn init() void { heap_arena.init("kernel heap", mi.impl.kernel_heap_base, b.tib(16), mm.page_size) catch @panic("failed to initialize kernel heap arena"); } -pub fn alloc_pages(size: usize) mm.Error!*anyopaque { +pub fn alloc(size: usize) mm.Error!*anyopaque { const ipl = heap_lock.acquire(); defer heap_lock.release(ipl); diff --git a/src/mm/root.zig b/src/mm/root.zig index 3716aeb..3029f81 100644 --- a/src/mm/root.zig +++ b/src/mm/root.zig @@ -9,6 +9,7 @@ pub const init = private.init.init; pub const vmem = private.vmem; pub const phys = private.phys; pub const zone = private.zone; +pub const heap = private.heap; // 16 TB of maximum physical memory. // This should be fine on consumer hardware for at least a decade :^) diff --git a/src/mm/zone.zig b/src/mm/zone.zig index b78f8f8..1dd0ab2 100644 --- a/src/mm/zone.zig +++ b/src/mm/zone.zig @@ -577,7 +577,7 @@ pub const Zone = struct { } const capacity = (self.slab_size - self.color) / self.chunk_size; - const buf = try mi.heap.alloc_pages(self.slab_size); + const buf = try mi.heap.alloc(self.slab_size); var ret: *Slab = try slab_zone.create(); @@ -746,7 +746,7 @@ fn gpa_alloc( if (ptr_align.toByteUnits() > mm.page_size) return null; const pages = std.mem.alignForward(usize, len, mm.page_size); - const ptr = mi.heap.alloc_pages(pages) catch return null; + const ptr = mi.heap.alloc(pages) catch return null; return @ptrCast(ptr); }