For reference.  I had one before, but deleted it since it was so simple.
Though it took me longer than I liked to remember how to remake it.

Signed-off-by: Barret Rhoden <[email protected]>
---
 kern/src/page_alloc.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/kern/src/page_alloc.c b/kern/src/page_alloc.c
index 2a0e498304fb..cfb295e3e166 100644
--- a/kern/src/page_alloc.c
+++ b/kern/src/page_alloc.c
@@ -133,3 +133,29 @@ void unlock_page(struct page *page)
        atomic_and(&page->pg_flags, ~PG_LOCKED);
        sem_up(&page->pg_sem);
 }
+
+static void *__jumbo_pml2_alloc(struct arena *a, size_t size, int flags)
+{
+       return arena_xalloc(a, size, PML2_PTE_REACH, 0, 0, NULL, NULL, flags);
+}
+
+static struct arena *jumbo_pml2_arena;
+
+/* Just for example; we could add qcaches too.  Do this after kmalloc_init(). 
*/
+void jumbo_arena_init(void)
+{
+       jumbo_pml2_arena = arena_create("jumbo_pml2", NULL, 0, PML2_PTE_REACH,
+                                       __jumbo_pml2_alloc, arena_xfree,
+                                       base_arena, 0, MEM_WAIT);
+       assert(jumbo_pml2_arena);
+}
+
+void *jumbo_page_alloc(size_t nr, int flags)
+{
+       return arena_alloc(jumbo_pml2_arena, nr * PML2_PTE_REACH, flags);
+}
+
+void jumbo_page_free(void *buf, size_t nr)
+{
+       arena_free(jumbo_pml2_arena, buf, nr * PML2_PTE_REACH);
+}
-- 
2.15.0.rc0.271.g36b669edcc-goog

-- 
You received this message because you are subscribed to the Google Groups 
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to