#include <klibc/string.h>
#include <lunaix/mm/cake.h>
-#include <lunaix/mm/pmm.h>
-#include <lunaix/mm/vmm.h>
+#include <lunaix/mm/page.h>
#include <lunaix/spike.h>
#include <lunaix/syslog.h>
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 vmap(pa, cake_pg * PG_SIZE, PG_PREM_RW, 0);
+
+ return (void*)vmap(leaflet, KERNEL_DATA);
}
struct cake_s*
*pile = (struct cake_pile){ .piece_size = piece_size,
.cakes_count = 0,
.pieces_per_cake =
- (pg_per_cake * PG_SIZE) /
+ (pg_per_cake * PAGE_SIZE) /
(piece_size + sizeof(piece_index_t)),
.pg_per_cake = pg_per_cake };
{
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;