summaryrefslogtreecommitdiffstats
path: root/include/zone.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/zone.h')
-rw-r--r--include/zone.h38
1 files changed, 38 insertions, 0 deletions
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 <stdint.h>
+#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