aboutsummaryrefslogtreecommitdiff
path: root/include/apos
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2021-09-12 21:51:10 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2021-09-12 21:51:10 +0300
commitd95c714c8cfdc5818b0e0f0c99cf2e5be66de202 (patch)
tree3b7b7a4fda733f284a4f77a9e67cc509201cfeca /include/apos
parent1ab464d959b9ee3d3bb6758ac0d9d33fc6c77e46 (diff)
downloadkmi-d95c714c8cfdc5818b0e0f0c99cf2e5be66de202.tar.gz
kmi-d95c714c8cfdc5818b0e0f0c99cf2e5be66de202.zip
Initial physical page manager
+ Will probably still need a fair bit of tweakind and documentation improvements, but seems to work outside of the kernel. Also no valgrind errors, which is quite promising I guess.
Diffstat (limited to 'include/apos')
-rw-r--r--include/apos/attrs.h3
-rw-r--r--include/apos/bits.h4
-rw-r--r--include/apos/pmem.h35
3 files changed, 41 insertions, 1 deletions
diff --git a/include/apos/attrs.h b/include/apos/attrs.h
index e088ec9..ae936d9 100644
--- a/include/apos/attrs.h
+++ b/include/apos/attrs.h
@@ -3,7 +3,8 @@
#define __section(section) __attribute__((__section__(section)))
#define __fmt(x, y) __attribute__((format (__printf__, x, y)))
#define __noinline __attribute__((noinline))
-#define __weak __attribute__((weak))
+#define __noreturn __attribute__((noreturn))
#define __packed __attribute__((packed))
+#define __weak __attribute__((weak))
#endif /* APOS_COMPILER_ATTRIBUTES_H */
diff --git a/include/apos/bits.h b/include/apos/bits.h
index 77bdde4..79523db 100644
--- a/include/apos/bits.h
+++ b/include/apos/bits.h
@@ -5,4 +5,8 @@
#define __set_bit(x, y) ((x) |= (y))
#define __clear_bit(x, y) ((x) &= ~(y))
+#define __is_nset(x, y) (__is_set((x), 1 << (y)))
+#define __set_nbit(x, y) (__set_bit((x), 1 << (y)))
+#define __clear_nbit(x, y) (__clear_bit((x), 1 << (y)))
+
#endif /* APOS_BITS_H */
diff --git a/include/apos/pmem.h b/include/apos/pmem.h
new file mode 100644
index 0000000..ec98cbf
--- /dev/null
+++ b/include/apos/pmem.h
@@ -0,0 +1,35 @@
+#ifndef APOS_PMEM_H
+#define APOS_PMEM_H
+
+#include <apos/types.h>
+
+enum mm_order_t {
+ MM_O0,
+ MM_O1,
+ MM_O2,
+ MM_O3,
+ MM_O4,
+ MM_O5,
+ MM_O6,
+ MM_O7,
+ MM_O8,
+ MM_O9,
+};
+
+typedef size_t paddr_t;
+typedef ssize_t pnum_t;
+
+void update_pmap(paddr_t offset);
+void free_page(enum mm_order_t order, paddr_t paddr);
+void mark_used(enum mm_order_t order, paddr_t paddr);
+paddr_t alloc_page(enum mm_order_t order, paddr_t offset);
+
+#if defined(INIT)
+void populate_pmap(paddr_t ram_base, size_t ram_size, paddr_t cont);
+#endif
+
+#if defined(KERNEL)
+void init_pmap(void *p);
+#endif
+
+#endif /* APOS_PMEM_H */