| git.druid.rocks | index | druid520 | kaboom | src/ | kernel/ | alloc.nsh |
src/kernel/alloc.nsh
/*
* colosseums' public api -- the struct itself, plus every function
* another kernel file might need. see alloc.nsc for what each of
* these actually does, and docs/superpowers/specs/2026-09-30-
* colosseums-design.md for the full design.
*
* deliberately NOT here: the four "global struct arena .../global ptr
* ..." colosseum declarations themselves. every caller that needs one
* declares that specific one inline instead (idt.nsc needs only
* heap_colosseum; exec.nsc needs fs_colosseum+exec_filebuf; fd.nsc
* needs fs_colosseum+fd_cache_vec) - virtfs.nsc, which only ever
* calls the accessor functions above, needs none of the four raw
* globals at all. found for real, not by style preference alone: a
* caller declaring a colosseum global it never actually touches (via
* a blanket include of all four) reproduced a genuine boot hang - see
* this file's own git history/the design doc for the isolation that
* found it. */
struct arena
{
u64 start;
u64 current;
u64 limit;
u64 issued;
u64 done;
u64 child_size;
u64 child_count;
ptr children;
};
void arena_init(ptr a, u64 start, u64 size);
ptr arena_alloc(ptr a, u64 size);
i32 arena_carve(ptr parent, ptr child, u64 size);
ptr arena_vector(ptr parent, u64 child_size, u64 child_count);
ptr arena_child(ptr vector);
void arena_mark_done(ptr a);
void alloc_init(void);
u64 heap_colosseum_used(void);
u64 heap_colosseum_total(void);
u64 fs_colosseum_used(void);
u64 fs_colosseum_total(void);
u64 heap_colosseum_limit(void);