feat: better rtc framework which aims to remove single rtc restrictions.
[lunaix-os.git] / lunaix-os / kernel / mm / cake.c
index 5e03d347706c8943b08c9f2792aecb9d7765aad7..2a70ab76d823f7d09d6d62cbc08bc6e70f70372b 100644 (file)
@@ -28,11 +28,11 @@ struct llist_header piles = { .next = &piles, .prev = &piles };
 void*
 __alloc_cake(unsigned int cake_pg)
 {
 void*
 __alloc_cake(unsigned int cake_pg)
 {
-    uintptr_t pa = pmm_alloc_cpage(KERNEL_PID, cake_pg, 0);
+    ptr_t pa = (ptr_t)pmm_alloc_cpage(KERNEL_PID, cake_pg, 0);
     if (!pa) {
         return NULL;
     }
     if (!pa) {
         return NULL;
     }
-    return vmm_vmap(pa, cake_pg * PG_SIZE, PG_PREM_RW);
+    return vmap(pa, cake_pg * PG_SIZE, PG_PREM_RW, 0);
 }
 
 struct cake_s*
 }
 
 struct cake_s*
@@ -44,9 +44,11 @@ __new_cake(struct cake_pile* pile)
         return NULL;
     }
 
         return NULL;
     }
 
-    int max_piece = pile->pieces_per_cake;
+    u32_t max_piece = pile->pieces_per_cake;
 
 
-    cake->first_piece = (void*)((uintptr_t)cake + pile->offset);
+    assert(max_piece);
+
+    cake->first_piece = (void*)((ptr_t)cake + pile->offset);
     cake->next_free = 0;
     pile->cakes_count++;
 
     cake->next_free = 0;
     pile->cakes_count++;
 
@@ -75,7 +77,7 @@ __init_pile(struct cake_pile* pile,
     unsigned int offset = sizeof(long);
 
     // 默认每块儿蛋糕对齐到地址总线宽度
     unsigned int offset = sizeof(long);
 
     // 默认每块儿蛋糕对齐到地址总线宽度
-    if ((options & PILE_CACHELINE)) {
+    if ((options & PILE_ALIGN_CACHE)) {
         // 对齐到128字节缓存行大小,主要用于DMA
         offset = CACHE_LINE_SIZE;
     }
         // 对齐到128字节缓存行大小,主要用于DMA
         offset = CACHE_LINE_SIZE;
     }
@@ -154,7 +156,7 @@ cake_grab(struct cake_pile* pile)
     }
 
     void* ptr =
     }
 
     void* ptr =
-      (void*)((uintptr_t)pos->first_piece + found_index * pile->piece_size);
+      (void*)((ptr_t)pos->first_piece + found_index * pile->piece_size);
 
     if (pile->ctor) {
         pile->ctor(pile, ptr);
 
     if (pile->ctor) {
         pile->ctor(pile, ptr);
@@ -176,8 +178,7 @@ cake_release(struct cake_pile* pile, void* area)
             if (pos->first_piece > area) {
                 continue;
             }
             if (pos->first_piece > area) {
                 continue;
             }
-            piece_index =
-              (uintptr_t)(area - pos->first_piece) / pile->piece_size;
+            piece_index = (ptr_t)(area - pos->first_piece) / pile->piece_size;
             if (piece_index < pile->pieces_per_cake) {
                 goto found;
             }
             if (piece_index < pile->pieces_per_cake) {
                 goto found;
             }