summaryrefslogtreecommitdiffstats
path: root/mem/zone.h
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2024-03-19 13:03:52 -0400
committerJon Santmyer <jon@jonsantmyer.com>2024-03-19 13:03:52 -0400
commitf004c1ade8d617a82cea2fe249434cccb47a2358 (patch)
tree34571e76039cf2ee2fee93c3f1bdb1bc6d2de5f6 /mem/zone.h
parentdd5d9e1d48396cbc226ff14fe557a55613c91fcb (diff)
downloadjove-kernel-f004c1ade8d617a82cea2fe249434cccb47a2358.tar.gz
jove-kernel-f004c1ade8d617a82cea2fe249434cccb47a2358.tar.bz2
jove-kernel-f004c1ade8d617a82cea2fe249434cccb47a2358.zip
rename abi to sys. better memory allocation
Diffstat (limited to 'mem/zone.h')
-rw-r--r--mem/zone.h33
1 files changed, 26 insertions, 7 deletions
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