Enable MMU in EL2.
diff --git a/src/alloc.c b/src/alloc.c
index cd7c614..b9dc585 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -7,7 +7,7 @@
static size_t alloc_limit;
static struct spinlock alloc_lock = SPINLOCK_INIT;
-/*
+/**
* Initializes the allocator.
*/
void halloc_init(size_t base, size_t size)
@@ -16,16 +16,16 @@
alloc_limit = base + size;
}
-/*
- * Allocates the requested amount of memory. Return NULL when there isn't enough
- * free memory.
+/**
+ * Allocates the requested amount of memory. Returns NULL when there isn't
+ * enough free memory.
*/
void *halloc(size_t size)
{
return halloc_aligned(size, 2 * sizeof(size_t));
}
-/*
+/**
* Frees the provided memory.
*
* Currently unimplemented.
@@ -35,7 +35,7 @@
dlog("Attempted to free pointer %p\n", ptr);
}
-/*
+/**
* Allocates the requested amount of memory, with the requested alignment.
*
* Alignment must be a power of two. Returns NULL when there isn't enough free
@@ -43,10 +43,27 @@
*/
void *halloc_aligned(size_t size, size_t align)
{
- size_t begin;
- size_t end;
+ void *ret;
sl_lock(&alloc_lock);
+ ret = halloc_aligned_nosync(size, align);
+ sl_unlock(&alloc_lock);
+
+ return ret;
+}
+
+/**
+ * Allocates the requested amount of memory, with the requested alignment, but
+ * no synchronisation with other CPUs. The caller is responsible for serialising
+ * all such calls.
+ *
+ * Alignment must be a power of two. Returns NULL when there isn't enough free
+ * memory.
+ */
+void *halloc_aligned_nosync(size_t size, size_t align)
+{
+ size_t begin;
+ size_t end;
begin = (alloc_base + align - 1) & ~(align - 1);
end = begin + size;
@@ -57,7 +74,5 @@
else
begin = 0;
- sl_unlock(&alloc_lock);
-
return (void *)begin;
}