X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/69777bdcab284335651a8002e2896f3862fa423d..270869139db617e29a35bb9ded41087bb702f9ac:/lunaix-os/kernel/mm/cake.c diff --git a/lunaix-os/kernel/mm/cake.c b/lunaix-os/kernel/mm/cake.c index 9707d52..d9ef381 100644 --- a/lunaix-os/kernel/mm/cake.c +++ b/lunaix-os/kernel/mm/cake.c @@ -12,8 +12,7 @@ #include #include -#include -#include +#include #include #include @@ -28,11 +27,12 @@ struct llist_header piles = { .next = &piles, .prev = &piles }; void* __alloc_cake(unsigned int cake_pg) { - ptr_t pa = (ptr_t)pmm_alloc_cpage(cake_pg, 0); - if (!pa) { + struct leaflet* leaflet = alloc_leaflet(count_order(cake_pg)); + if (!leaflet) { return NULL; } - return (void*)vmap(pa, cake_pg * PAGE_SIZE, KERNEL_DATA); + + return (void*)vmap(leaflet, KERNEL_DATA); } struct cake_s* @@ -117,6 +117,9 @@ cake_new_pile(char* name, { struct cake_pile* pile = (struct cake_pile*)cake_grab(&master_pile); + // must aligned to napot order! + assert(is_pot(pg_per_cake)); + __init_pile(pile, name, piece_size, pg_per_cake, options); return pile;