From ace65b453151845bc361f21f3e5b651c35f9f126 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 22 May 2024 13:00:41 -0400 Subject: massive refactor for mp and organization --- include/zone.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 include/zone.h (limited to 'include/zone.h') diff --git a/include/zone.h b/include/zone.h new file mode 100644 index 0000000..002d1fc --- /dev/null +++ b/include/zone.h @@ -0,0 +1,38 @@ +#ifndef JOVE_MEM_ZONE_H +#define JOVE_MEM_ZONE_H 1 + +#include +#include "klib/buddymap.h" + +enum { + MEM_ZONE_STANDARD = 0, /* First GiB of physical memory. */ + MEM_ZONE_HIGHER, + MEM_ZONE_COUNT +}; + +#define MEM_ZONE_STANDARD_BASE 0 +#define MEM_ZONE_STANDARD_LIMIT (1 * GiB) +#define MEM_ZONE_HIGHER_BASE MEM_ZONE_STANDARD_LIMIT + +#define MEM_BUDDY_ORDERS 12 +struct PhysicalMemoryZone +{ + const char *name; + + uintptr_t base; + uintptr_t limit; + + struct BuddyMap freemap; +}; + +int pm_zone_for(uintptr_t addr); +uintptr_t pm_zone_bound_lower(size_t zone); +uintptr_t pm_zone_bound_upper(size_t zone); +size_t pm_zone_pages_free(size_t zone); +int pm_zone_resv(size_t zone, uintptr_t base, uintptr_t limit); +int pm_zone_free(size_t zone, uintptr_t base, uintptr_t limit); +uintptr_t pm_zone_alloc(size_t zone, size_t pages); + +void pm_zone_setup(void); + +#endif -- cgit v1.2.1