aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-05-10 15:57:25 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-05-10 15:57:25 +0300
commitc18ec832ed592e4c6171139a8aaadde827cb13da (patch)
treeb08d5baee0c3890300ea2e539a93b90152397db7 /include
parent5f28eff9fbb39cdbaa7052b4b21b5943a88b2e7a (diff)
downloadkmi-c18ec832ed592e4c6171139a8aaadde827cb13da.tar.gz
kmi-c18ec832ed592e4c6171139a8aaadde827cb13da.zip
implement faster page allocator
Diffstat (limited to 'include')
-rw-r--r--include/kmi/bits.h18
-rw-r--r--include/kmi/pmem.h5
-rw-r--r--include/kmi/types.h2
3 files changed, 22 insertions, 3 deletions
diff --git a/include/kmi/bits.h b/include/kmi/bits.h
index a46f0ec..738f1d5 100644
--- a/include/kmi/bits.h
+++ b/include/kmi/bits.h
@@ -10,6 +10,7 @@
*/
#include <kmi/types.h>
+#include <kmi/string.h>
#include <kmi/builtin.h>
/** @name Arithmetic integer bit manipulation. */
@@ -146,6 +147,23 @@ static inline void bitmap_clear(void *bmap, size_t n)
}
/**
+ * Clear all bits in bitmap.
+ *
+ * @param bmap Bitmap.
+ * @param n Size of bitmap.
+ */
+static inline void bitmap_clear_all(void *bmap, size_t n)
+{
+ uint8_t *bitmap = bmap;
+ size_t i = n / 8;
+ size_t r = n - (i * 8);
+ memset(bitmap, 0, i);
+
+ for (size_t k = 0; k < r; ++k)
+ clear_nbit(bitmap[i], k);
+}
+
+/**
* Find first bit, either set or unset, in bitmap.
*
* @param bmap Bitmap.
diff --git a/include/kmi/pmem.h b/include/kmi/pmem.h
index 1eb1972..1917174 100644
--- a/include/kmi/pmem.h
+++ b/include/kmi/pmem.h
@@ -31,9 +31,8 @@ void mark_used(enum mm_order order, pm_t addr);
/**
* Allocate physical page.
- * Allows the user to specify a hint as to which address to start looking for.
- * Useful for allocating many pages for one virtual allocation, for example, and
- * allows us to skip already checked pages when allocating a second page.
+ * Page is returned as a virtual address within the kernel address space, and
+ * can be converted to a physical address via the \ref __pa() macro.
*
* @param order Order of page to allocate.
* @return pm_t Physical address of page when succesful, else \c NULL.
diff --git a/include/kmi/types.h b/include/kmi/types.h
index 2443f89..2b1492f 100644
--- a/include/kmi/types.h
+++ b/include/kmi/types.h
@@ -129,7 +129,9 @@ typedef int32_t ssize_t;
/** Maximum alignment. Works for most platforms, I think. */
typedef union {
+ /** Either the system has an integer as its maximum width */
intmax_t ll;
+ /** Or it has a long double. */
long double ld;
} max_align_t;