From f004c1ade8d617a82cea2fe249434cccb47a2358 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Tue, 19 Mar 2024 13:03:52 -0400 Subject: rename abi to sys. better memory allocation --- mem/zone.h | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'mem/zone.h') diff --git a/mem/zone.h b/mem/zone.h index 7e863bf..c0b0f52 100644 --- a/mem/zone.h +++ b/mem/zone.h @@ -22,23 +22,42 @@ struct PhysicalMemoryZone uintptr_t base; uintptr_t limit; - size_t npages_total; - size_t npages_free; - struct BuddyMap freemap; }; +/**Return the zone index for the given address + * @param addr address to look up + * @return zone index*/ +int mem_zone_for(uintptr_t addr); + +/**Return the lower bound for the given zone index. + * @param zone index into zones. + * @return lower bound.*/ +uintptr_t mem_zone_bound_lower(size_t zone); + +/**Return the upper bound for the given zone index. + * @param zone index into zones. + * @return upper bound.*/ +uintptr_t mem_zone_bound_upper(size_t zone); + +/**Return the number of pages free in the given zone. + * @param zone index into zones. + * @return number of free pages.*/ +size_t mem_zone_pages_free(size_t zone); + /** Using a given zone, reserve a range of physical addresses * @param zone identifier of zone to modify * @param base starting address to reserve - * @param limit ending address to reserve*/ -void mem_zone_resv(size_t zone, uintptr_t base, uintptr_t limit); + * @param limit ending address to reserve + * @return error code or 0 if success */ +int mem_zone_resv(size_t zone, uintptr_t base, uintptr_t limit); /** Using a given zone, free a range of physical addresses * @param zone identifier of zone to modify * @param base starting address to free - * @param limit ending address to free*/ -void mem_zone_free(size_t zone, uintptr_t base, uintptr_t limit); + * @param limit ending address to free + * @return error code or 0 if success*/ +int mem_zone_free(size_t zone, uintptr_t base, uintptr_t limit); /** Allocate a number of pages from the given zone * @param zone identifier of the zone to modify -- cgit v1.2.1